code
stringlengths 38
801k
| repo_path
stringlengths 6
263
|
---|---|
const std = @import("std");
const epsilonEq = @import("utils.zig").epsilonEq;
pub const Color = struct {
const Self = @This();
red: f64,
green: f64,
blue: f64,
pub const Black = Self.init(0, 0, 0);
pub const White = Self.init(1, 1, 1);
pub fn init(red: f64, green: f64, blue: f64) Self {
return .{
.red = red,
.green = green,
.blue = blue,
};
}
pub fn eql(self: Self, other: Self) bool {
return epsilonEq(self.red, other.red) and
epsilonEq(self.green, other.green) and
epsilonEq(self.blue, other.blue);
}
pub fn add(self: Self, other: Self) Self {
return .{
.red = self.red + other.red,
.green = self.green + other.green,
.blue = self.blue + other.blue,
};
}
pub fn sub(self: Self, other: Self) Self {
return .{
.red = self.red - other.red,
.green = self.green - other.green,
.blue = self.blue - other.blue,
};
}
pub fn scale(self: Self, scalar: f64) Self {
return .{
.red = scalar * self.red,
.green = scalar * self.green,
.blue = scalar * self.blue,
};
}
pub fn mult(self: Self, other: Self) Self {
return .{
.red = self.red * other.red,
.green = self.green * other.green,
.blue = self.blue * other.blue,
};
}
};
test "adding colors" {
const c1 = Color.init(0.9, 0.6, 0.75);
const c2 = Color.init(0.7, 0.1, 0.25);
try std.testing.expect(c1.add(c2).eql(Color.init(1.6, 0.7, 1.0)));
}
test "subtracting colors" {
const c1 = Color.init(0.9, 0.6, 0.75);
const c2 = Color.init(0.7, 0.1, 0.25);
try std.testing.expect(c1.sub(c2).eql(Color.init(0.2, 0.5, 0.5)));
}
test "multiplying colors" {
const c1 = Color.init(1, 0.2, 0.4);
const c2 = Color.init(0.9, 1, 0.1);
try std.testing.expect(c1.mult(c2).eql(Color.init(0.9, 0.2, 0.04)));
} | color.zig |
const std = @import("std");
const renderkit = @import("renderkit");
const gk = @import("gamekit");
const gfx = gk.gfx;
const math = gk.math;
const shaders = @import("assets/shaders.zig");
pub const renderer: gk.renderkit.Renderer = .opengl;
const Texture = gk.gfx.Texture;
const Color = gk.math.Color;
const Block = struct {
tex: Texture,
pos: math.Vec2,
scale: f32,
dist: f32,
};
const Camera = struct {
sw: f32,
sh: f32,
x: f32 = 0,
y: f32 = 0,
r: f32 = 0,
z: f32 = 32,
f: f32 = 1,
o: f32 = 1,
x1: f32 = 0,
y1: f32 = 0,
x2: f32 = 0,
y2: f32 = 0,
sprites: std.ArrayList(Block) = undefined,
pub fn init(sw: f32, sh: f32) Camera {
var cam = Camera{ .sw = sw, .sh = sh, .sprites = std.ArrayList(Block).init(std.testing.allocator) };
cam.setRotation(0);
return cam;
}
pub fn deinit(self: Camera) void {
self.sprites.deinit();
}
pub fn setRotation(self: *Camera, rot: f32) void {
self.r = rot;
self.x1 = std.math.sin(rot);
self.y1 = std.math.cos(rot);
self.x2 = -std.math.cos(rot);
self.y2 = std.math.sin(rot);
}
pub fn toWorld(self: Camera, pos: gk.math.Vec2) gk.math.Vec2 {
const sx = (self.sw / 2 - pos.x) * self.z / (self.sw / self.sh);
const sy = (self.o * self.sh - pos.y) * (self.z / self.f);
const rot_x = sx * self.x1 + sy * self.y1;
const rot_y = sx * self.x2 + sy * self.y2;
return .{ .x = rot_x / pos.y + self.x, .y = rot_y / pos.y + self.y };
}
pub fn toScreen(self: Camera, pos: gk.math.Vec2) struct { x: f32, y: f32, size: f32 } {
const obj_x = -(self.x - pos.x) / self.z;
const obj_y = (self.y - pos.y) / self.z;
const space_x = (-obj_x * self.x1 - obj_y * self.y1);
const space_y = (obj_x * self.x2 + obj_y * self.y2) * self.f;
const distance = 1 - space_y;
const screen_x = (space_x / distance) * self.o * self.sw + self.sw / 2;
const screen_y = ((space_y + self.o - 1) / distance) * self.sh + self.sh;
// Should be approximately one pixel on the plane
const size = ((1 / distance) / self.z * self.o) * self.sw;
return .{ .x = screen_x, .y = screen_y, .size = size };
}
pub fn placeSprite(self: *Camera, tex: gk.gfx.Texture, pos: gk.math.Vec2, scale: f32) void {
const dim = self.toScreen(pos);
const sx2 = (dim.size * scale) / tex.width;
if (sx2 < 0) return;
_ = self.sprites.append(.{
.tex = tex,
.pos = .{ .x = dim.x, .y = dim.y },
.scale = sx2,
.dist = dim.size,
}) catch unreachable;
}
pub fn renderSprites(self: *Camera) void {
if (self.sprites.items.len > 0) {
std.sort.sort(Block, self.sprites.items, {}, sort);
}
for (self.sprites.items) |sprite| {
gfx.draw.texScaleOrigin(sprite.tex, sprite.pos.x, sprite.pos.y, sprite.scale, sprite.tex.width / 2, sprite.tex.height);
}
self.sprites.items.len = 0;
}
fn sort(ctx: void, a: Block, b: Block) bool {
_ = ctx;
return a.dist < b.dist;
}
};
var map: Texture = undefined;
var block: Texture = undefined;
var mode7_shader: shaders.Mode7Shader = undefined;
var camera: Camera = undefined;
var blocks: std.ArrayList(math.Vec2) = undefined;
var wrap: f32 = 0;
pub fn main() !void {
try gk.run(.{
.init = init,
.update = update,
.render = render,
.shutdown = shutdown,
.window = .{ .resizable = false },
});
}
fn init() !void {
const drawable_size = gk.window.drawableSize();
camera = Camera.init(@intToFloat(f32, drawable_size.w), @intToFloat(f32, drawable_size.h));
map = Texture.initFromFile(std.testing.allocator, "examples/assets/textures/mario_kart.png", .nearest) catch unreachable;
block = Texture.initFromFile(std.testing.allocator, "examples/assets/textures/block.png", .nearest) catch unreachable;
mode7_shader = shaders.createMode7Shader();
blocks = std.ArrayList(math.Vec2).init(std.testing.allocator);
_ = blocks.append(.{ .x = 0, .y = 0 }) catch unreachable;
// uncomment for sorting stress test
// var x: usize = 4;
// while (x < 512) : (x += 12) {
// var y: usize = 4;
// while (y < 512) : (y += 12) {
// _ = blocks.append(.{ .x = @intToFloat(f32, x), .y = @intToFloat(f32, y) }) catch unreachable;
// }
// }
}
fn shutdown() !void {
map.deinit();
block.deinit();
mode7_shader.deinit();
blocks.deinit();
camera.deinit();
}
fn update() !void {
const move_speed = 140.0;
if (gk.input.keyDown(.w)) {
camera.x += std.math.cos(camera.r) * move_speed * gk.time.rawDeltaTime();
camera.y += std.math.sin(camera.r) * move_speed * gk.time.rawDeltaTime();
} else if (gk.input.keyDown(.s)) {
camera.x = camera.x - std.math.cos(camera.r) * move_speed * gk.time.rawDeltaTime();
camera.y = camera.y - std.math.sin(camera.r) * move_speed * gk.time.rawDeltaTime();
}
if (gk.input.keyDown(.a)) {
camera.x += std.math.cos(camera.r - std.math.pi / 2.0) * move_speed * gk.time.rawDeltaTime();
camera.y += std.math.sin(camera.r - std.math.pi / 2.0) * move_speed * gk.time.rawDeltaTime();
} else if (gk.input.keyDown(.d)) {
camera.x += std.math.cos(camera.r + std.math.pi / 2.0) * move_speed * gk.time.rawDeltaTime();
camera.y += std.math.sin(camera.r + std.math.pi / 2.0) * move_speed * gk.time.rawDeltaTime();
}
if (gk.input.keyDown(.i)) {
camera.f += gk.time.rawDeltaTime();
} else if (gk.input.keyDown(.o)) {
camera.f -= gk.time.rawDeltaTime();
}
if (gk.input.keyDown(.k)) {
camera.o += gk.time.rawDeltaTime();
} else if (gk.input.keyDown(.l)) {
camera.o -= gk.time.rawDeltaTime();
}
if (gk.input.keyDown(.minus)) {
camera.z += gk.time.rawDeltaTime() * 10;
} else if (gk.input.keyDown(.equals)) {
camera.z -= gk.time.rawDeltaTime() * 10;
}
if (gk.input.keyDown(.q)) {
camera.setRotation(@mod(camera.r, std.math.tau) - gk.time.rawDeltaTime());
} else if (gk.input.keyDown(.e)) {
camera.setRotation(@mod(camera.r, std.math.tau) + gk.time.rawDeltaTime());
}
if (gk.input.mousePressed(.left)) {
var pos = camera.toWorld(gk.input.mousePos());
_ = blocks.append(pos) catch unreachable;
}
if (gk.input.mousePressed(.right)) {
wrap = if (wrap == 0) 1 else 0;
}
}
fn render() !void {
// bind our mode7 shader, draw the plane which will then unset the shader for regular sprite drawing
updateMode7Uniforms();
gfx.beginPass(.{ .shader = &mode7_shader.shader });
drawPlane();
var pos = camera.toScreen(camera.toWorld(gk.input.mousePos()));
gfx.draw.circle(.{ .x = pos.x, .y = pos.y }, pos.size, 2, 8, gk.math.Color.white);
gfx.draw.texScaleOrigin(block, pos.x, pos.y, pos.size, block.width / 2, block.height);
for (blocks.items) |b| camera.placeSprite(block, b, 8);
camera.renderSprites();
gfx.draw.text("WASD to move", 5, 20, null);
gfx.draw.text("i/o to change fov", 5, 40, null);
gfx.draw.text("k/l to change offset", 5, 60, null);
gfx.draw.text("-/= to change z pos", 5, 80, null);
gfx.draw.text("q/e to rotate cam", 5, 100, null);
gfx.draw.text("left click to place block", 5, 120, null);
gfx.draw.text("right click to toggle wrap", 5, 140, null);
gfx.endPass();
}
fn updateMode7Uniforms() void {
mode7_shader.frag_uniform.mapw = map.width;
mode7_shader.frag_uniform.maph = map.height;
mode7_shader.frag_uniform.x = camera.x;
mode7_shader.frag_uniform.y = camera.y;
mode7_shader.frag_uniform.zoom = camera.z;
mode7_shader.frag_uniform.fov = camera.f;
mode7_shader.frag_uniform.offset = camera.o;
mode7_shader.frag_uniform.wrap = wrap;
mode7_shader.frag_uniform.x1 = camera.x1;
mode7_shader.frag_uniform.y1 = camera.y1;
mode7_shader.frag_uniform.x2 = camera.x2;
mode7_shader.frag_uniform.y2 = camera.y2;
}
fn drawPlane() void {
// bind out map to the second texture slot and we need a full screen render for the shader so we just draw a full screen rect
gfx.draw.bindTexture(map, 1);
const drawable_size = gk.window.size();
gfx.draw.rect(.{}, @intToFloat(f32, drawable_size.w), @intToFloat(f32, drawable_size.h), math.Color.white);
gfx.setShader(null);
} | examples/mode7.zig |
const std = @import("std");
const stdx = @import("stdx");
const fatal = stdx.fatal;
const platform = @import("platform");
const vk = @import("vk");
const graphics = @import("../../graphics.zig");
const gpu = graphics.gpu;
const gvk = graphics.vk;
const log = stdx.log.scoped(.swapchain);
pub const SwapChain = struct {
w: *platform.Window,
swapchain: vk.VkSwapchainKHR,
image_available_semas: [gpu.MaxActiveFrames]vk.VkSemaphore,
render_finished_semas: [gpu.MaxActiveFrames]vk.VkSemaphore,
inflight_fences: [gpu.MaxActiveFrames]vk.VkFence,
images: []vk.VkImage,
image_views: []vk.VkImageView,
depth_images: []vk.VkImage,
depth_images_mem: []vk.VkDeviceMemory,
depth_image_views: []vk.VkImageView,
buf_format: vk.VkFormat,
buf_dim: vk.VkExtent2D,
device: vk.VkDevice,
cur_frame_idx: u32,
cur_image_idx: u32,
present_queue: vk.VkQueue,
const Self = @This();
pub fn init(self: *Self, alloc: std.mem.Allocator, w: *platform.Window) void {
self.* = .{
.w = w,
.image_available_semas = undefined,
.render_finished_semas = undefined,
.inflight_fences = undefined,
.buf_format = undefined,
.buf_dim = undefined,
.images = undefined,
.image_views = undefined,
.depth_images = undefined,
.depth_images_mem = undefined,
.depth_image_views = undefined,
.cur_frame_idx = 0,
.device = w.impl.inner.device,
.swapchain = undefined,
.cur_image_idx = 0,
.present_queue = undefined,
};
const physical = w.impl.inner.physical_device;
const surface = w.impl.inner.surface;
const device = w.impl.inner.device;
const queue_family = w.impl.inner.queue_family;
vk.getDeviceQueue(device, queue_family.present_family.?, 0, &self.present_queue);
const swapc_info = platform.window_sdl.vkQuerySwapChainSupport(alloc, physical, surface);
defer swapc_info.deinit(alloc);
const surface_format = swapc_info.getDefaultSurfaceFormat();
self.buf_format = surface_format.format;
const present_mode = swapc_info.getDefaultPresentMode();
self.buf_dim = swapc_info.getDefaultExtent();
var image_count: u32 = swapc_info.capabilities.minImageCount + 1;
if (swapc_info.capabilities.maxImageCount > 0 and image_count > swapc_info.capabilities.maxImageCount) {
image_count = swapc_info.capabilities.maxImageCount;
}
const queue_family_idxes = [_]u32{ queue_family.graphics_family.?, queue_family.present_family.? };
// const different_families = indices.graphicsFamily.? != indices.presentFamily.?;
const different_families = false;
var swapc_create_info = vk.VkSwapchainCreateInfoKHR{
.sType = vk.VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
.surface = w.impl.inner.surface,
.minImageCount = image_count,
.imageFormat = surface_format.format,
.imageColorSpace = surface_format.colorSpace,
.imageExtent = self.buf_dim,
.imageArrayLayers = 1,
.imageUsage = vk.VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
.imageSharingMode = if (different_families) vk.VK_SHARING_MODE_CONCURRENT else vk.VK_SHARING_MODE_EXCLUSIVE,
.queueFamilyIndexCount = if (different_families) @as(u32, 2) else @as(u32, 0),
.pQueueFamilyIndices = if (different_families) &queue_family_idxes else &([_]u32{ 0, 0 }),
.preTransform = swapc_info.capabilities.currentTransform,
.compositeAlpha = vk.VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR,
.presentMode = present_mode,
.clipped = vk.VK_TRUE,
.oldSwapchain = null,
.pNext = null,
.flags = 0,
};
var res = vk.createSwapchainKHR(device, &swapc_create_info, null, &self.swapchain);
vk.assertSuccess(res);
res = vk.getSwapchainImagesKHR(device, self.swapchain, &image_count, null);
vk.assertSuccess(res);
self.images = alloc.alloc(vk.VkImage, image_count) catch fatal();
res = vk.getSwapchainImagesKHR(device, self.swapchain, &image_count, self.images.ptr);
vk.assertSuccess(res);
// Create image views.
self.image_views = alloc.alloc(vk.VkImageView, self.images.len) catch fatal();
for (self.images) |image, i| {
self.image_views[i] = gvk.image.createDefaultImageView(device, image, self.buf_format);
}
self.depth_images = alloc.alloc(vk.VkImage, image_count) catch fatal();
self.depth_images_mem = alloc.alloc(vk.VkDeviceMemory, image_count) catch fatal();
self.depth_image_views = alloc.alloc(vk.VkImageView, image_count) catch fatal();
for (self.depth_images) |_, i| {
gvk.image.createDefaultImage(physical, device, self.buf_dim.width, self.buf_dim.height, vk.VK_FORMAT_D32_SFLOAT, vk.VK_IMAGE_TILING_OPTIMAL,
vk.VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, vk.VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &self.depth_images[i], &self.depth_images_mem[i]);
self.depth_image_views[i] = gvk.image.createDefaultImageView(device, self.depth_images[i], vk.VK_FORMAT_D32_SFLOAT);
}
createSyncObjects(self);
}
pub fn deinit(self: Self, alloc: std.mem.Allocator) void {
// Wait on all frame fences first.
const res = vk.waitForFences(self.device, self.inflight_fences.len, &self.inflight_fences, vk.VK_TRUE, std.math.maxInt(u64));
vk.assertSuccess(res);
for (self.image_available_semas) |sema| {
vk.destroySemaphore(self.device, sema, null);
}
for (self.render_finished_semas) |sema| {
vk.destroySemaphore(self.device, sema, null);
}
for (self.inflight_fences) |fence| {
vk.destroyFence(self.device, fence, null);
}
for (self.depth_image_views) |image_view| {
vk.destroyImageView(self.device, image_view, null);
}
alloc.free(self.depth_image_views);
for (self.depth_images) |image| {
vk.destroyImage(self.device, image, null);
}
alloc.free(self.depth_images);
for (self.depth_images_mem) |mem| {
vk.freeMemory(self.device, mem, null);
}
alloc.free(self.depth_images_mem);
for (self.image_views) |image_view| {
vk.destroyImageView(self.device, image_view, null);
}
alloc.free(self.image_views);
// images are destroyed from destroySwapchainKHR.
alloc.free(self.images);
vk.destroySwapchainKHR(self.device, self.swapchain, null);
}
/// Waits to get the next available swapchain image idx.
pub fn beginFrame(self: *Self) void {
var res = vk.waitForFences(self.device, 1, &self.inflight_fences[self.cur_frame_idx], vk.VK_TRUE, std.math.maxInt(u64));
vk.assertSuccess(res);
res = vk.resetFences(self.device, 1, &self.inflight_fences[self.cur_frame_idx]);
vk.assertSuccess(res);
res = vk.acquireNextImageKHR(self.device, self.swapchain, std.math.maxInt(u64), self.image_available_semas[self.cur_frame_idx], null, &self.cur_image_idx);
vk.assertSuccess(res);
}
pub fn endFrame(self: *Self) void {
const present_info = vk.VkPresentInfoKHR{
.sType = vk.VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
.waitSemaphoreCount = 1,
.pWaitSemaphores = &self.render_finished_semas[self.cur_frame_idx],
.swapchainCount = 1,
.pSwapchains = &self.swapchain,
.pImageIndices = &self.cur_image_idx,
.pNext = null,
.pResults = null,
};
const res = vk.queuePresentKHR(self.present_queue, &present_info);
vk.assertSuccess(res);
self.cur_frame_idx = (self.cur_frame_idx + 1) % gpu.MaxActiveFrames;
}
};
fn createSyncObjects(swapchain: *SwapChain) void {
const sema_info = vk.VkSemaphoreCreateInfo{
.sType = vk.VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
.pNext = null,
.flags = 0,
};
const fence_info = vk.VkFenceCreateInfo{
.sType = vk.VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
.flags = vk.VK_FENCE_CREATE_SIGNALED_BIT,
.pNext = null,
};
const device = swapchain.w.impl.inner.device;
var i: usize = 0;
var res: vk.VkResult = undefined;
while (i < gpu.MaxActiveFrames) : (i += 1) {
res = vk.createSemaphore(device, &sema_info, null, &swapchain.image_available_semas[i]);
vk.assertSuccess(res);
res = vk.createSemaphore(device, &sema_info, null, &swapchain.render_finished_semas[i]);
vk.assertSuccess(res);
res = vk.createFence(device, &fence_info, null, &swapchain.inflight_fences[i]);
vk.assertSuccess(res);
}
} | graphics/src/backend/vk/swapchain.zig |
const std = @import("std");
const builtin = @import("builtin");
const fmt = std.fmt;
const fs = std.fs;
const heap = std.heap;
const mem = std.mem;
pub fn build(b: *std.build.Builder) !void {
var target = b.standardTargetOptions(.{});
var mode = b.standardReleaseOptions();
const libsodium = b.addStaticLibrary("sodium", null);
libsodium.setTarget(target);
libsodium.setBuildMode(mode);
libsodium.install();
if (mode != .Debug) {
libsodium.strip = true;
}
libsodium.linkLibC();
libsodium.addIncludeDir("src/libsodium/include/sodium");
libsodium.defineCMacro("CONFIGURED", "1");
libsodium.defineCMacro("DEV_MODE", "1");
libsodium.defineCMacro("_GNU_SOURCE", "1");
libsodium.defineCMacro("HAVE_INLINE_ASM", "1");
libsodium.defineCMacro("HAVE_TI_MODE", "1");
libsodium.defineCMacro("HAVE_ATOMIC_OPS", "1");
libsodium.defineCMacro("ASM_HIDE_SYMBOL", ".private_extern");
switch (target.getCpuArch()) {
.x86_64 => {
libsodium.defineCMacro("HAVE_AMD64_ASM", "1");
libsodium.defineCMacro("HAVE_AVX_ASM", "1");
libsodium.defineCMacro("HAVE_CPUID", "1");
libsodium.defineCMacro("HAVE_MMINTRIN_H", "1");
libsodium.defineCMacro("HAVE_EMMINTRIN_H", "1");
libsodium.defineCMacro("HAVE_PMMINTRIN_H", "1");
},
.aarch64, .aarch64_be => {
libsodium.defineCMacro("HAVE_ARMCRYTO", "1");
},
.wasm32, .wasm64 => {
libsodium.defineCMacro("__wasm__", "1");
},
else => {},
}
switch (target.getOsTag()) {
.wasi => {
libsodium.defineCMacro("__wasi__", "1");
},
else => {},
}
const base = "src/libsodium";
const dir = try fs.Dir.openDir(fs.cwd(), base, .{ .iterate = true, .no_follow = true });
var allocator = heap.page_allocator;
var walker = try dir.walk(allocator);
while (try walker.next()) |entry| {
const name = entry.basename;
if (mem.endsWith(u8, name, ".c")) {
const full_path = try fmt.allocPrint(allocator, "{s}/{s}", .{ base, entry.path });
libsodium.addCSourceFiles(&.{full_path}, &.{
"-fvisibility=hidden",
"-fno-strict-aliasing",
"-fno-strict-overflow",
"-fwrapv",
"-flax-vector-conversions",
});
} else if (mem.endsWith(u8, name, ".S")) {
const full_path = try fmt.allocPrint(allocator, "{s}/{s}", .{ base, entry.path });
libsodium.addAssemblyFile(full_path);
}
}
} | deps/libsodium/build.zig |
const std = @import("std");
const builtin = @import("builtin");
const Pkg = std.build.Pkg;
const string = []const u8;
pub const cache = ".zigmod\\deps";
pub fn addAllTo(exe: *std.build.LibExeObjStep) void {
@setEvalBranchQuota(1_000_000);
for (packages) |pkg| {
exe.addPackage(pkg.pkg.?);
}
var llc = false;
var vcpkg = false;
inline for (std.meta.declarations(package_data)) |decl| {
const pkg = @as(Package, @field(package_data, decl.name));
inline for (pkg.system_libs) |item| {
exe.linkSystemLibrary(item);
llc = true;
}
inline for (pkg.c_include_dirs) |item| {
exe.addIncludeDir(@field(dirs, decl.name) ++ "/" ++ item);
llc = true;
}
inline for (pkg.c_source_files) |item| {
exe.addCSourceFile(@field(dirs, decl.name) ++ "/" ++ item, pkg.c_source_flags);
llc = true;
}
}
if (llc) exe.linkLibC();
if (builtin.os.tag == .windows and vcpkg) exe.addVcpkgPaths(.static) catch |err| @panic(@errorName(err));
}
pub const Package = struct {
directory: string,
pkg: ?Pkg = null,
c_include_dirs: []const string = &.{},
c_source_files: []const string = &.{},
c_source_flags: []const string = &.{},
system_libs: []const string = &.{},
vcpkg: bool = false,
};
const dirs = struct {
pub const _root = "";
pub const _3oldm2uf7rpx = cache ++ "/../..";
pub const _uxw7q1ovyv4z = cache ++ "/git/github.com/Snektron/vulkan-zig";
};
pub const package_data = struct {
pub const _3oldm2uf7rpx = Package{
.directory = dirs._3oldm2uf7rpx,
};
pub const _uxw7q1ovyv4z = Package{
.directory = dirs._uxw7q1ovyv4z,
.pkg = Pkg{ .name = "vulkan-zig", .path = .{ .path = dirs._uxw7q1ovyv4z ++ "/generator/index.zig" }, .dependencies = null },
};
pub const _root = Package{
.directory = dirs._root,
};
};
pub const packages = &[_]Package{
package_data._uxw7q1ovyv4z,
};
pub const pkgs = struct {
pub const vulkan_zig = package_data._uxw7q1ovyv4z;
};
pub const imports = struct {
pub const vulkan_zig = @import(".zigmod\\deps/git/github.com/Snektron/vulkan-zig/generator/index.zig");
}; | deps.zig |
const std = @import("std");
const tvg = @import("tvg.zig");
pub const Header = struct {
version: u8,
scale: tvg.Scale,
custom_color_space: bool,
width: f32,
height: f32,
};
const Point = tvg.Point;
const Rectangle = tvg.Rectangle;
const Line = tvg.Line;
pub const DrawCommand = union(enum) {
fill_polygon: FillPolygon,
fill_rectangles: FillRectangles,
fill_path: FillPath,
draw_lines: DrawLines,
draw_line_loop: DrawLineSegments,
draw_line_strip: DrawLineSegments,
draw_line_path: DrawPath,
outline_fill_polygon: OutlineFillPolygon,
outline_fill_rectangles: OutlineFillRectangles,
outline_fill_path: OutlineFillPath,
pub const FillPolygon = struct {
style: Style,
vertices: []Point,
};
pub const FillRectangles = struct {
style: Style,
rectangles: []Rectangle,
};
pub const FillPath = struct {
style: Style,
start: Point,
path: []PathNode,
};
pub const OutlineFillPolygon = struct {
fill_style: Style,
line_style: Style,
line_width: f32,
vertices: []Point,
};
pub const OutlineFillRectangles = struct {
fill_style: Style,
line_style: Style,
line_width: f32,
rectangles: []Rectangle,
};
pub const OutlineFillPath = struct {
fill_style: Style,
line_style: Style,
line_width: f32,
start: Point,
path: []PathNode,
};
pub const DrawLines = struct {
style: Style,
line_width: f32,
lines: []Line,
};
pub const DrawLineSegments = struct {
style: Style,
line_width: f32,
vertices: []Point,
};
pub const DrawPath = struct {
style: Style,
line_width: f32,
start: Point,
path: []PathNode,
};
};
pub const PathNode = union(enum) {
const Self = @This();
line: NodeData(Point),
horiz: NodeData(f32),
vert: NodeData(f32),
bezier: NodeData(Bezier),
arc_circle: NodeData(ArcCircle),
arc_ellipse: NodeData(ArcEllipse),
close: NodeData(void),
fn NodeData(comptime Payload: type) type {
return struct {
line_width: ?f32,
data: Payload,
fn init(
line_width: ?f32,
data: Payload,
) @This() {
return .{ .line_width = line_width, .data = data };
}
};
}
pub const ArcCircle = struct {
radius: f32,
large_arc: bool,
sweep: bool,
target: Point,
};
pub const ArcEllipse = struct {
radius_x: f32,
radius_y: f32,
rotation: f32,
large_arc: bool,
sweep: bool,
target: Point,
};
pub const Bezier = struct {
c0: Point,
c1: Point,
p1: Point,
};
const Type = packed enum(u3) {
line = 0, // x,y
horiz = 1, // x
vert = 2, // y
bezier = 3, // c0x,c0y,c1x,c1y,x,y
arc_circ = 4, //r,x,y
arc_ellipse = 5, // rx,ry,x,y
close = 6,
reserved = 7,
};
const Tag = packed struct {
type: Type,
padding0: u1 = 0,
has_line_width: bool,
padding1: u3 = 0,
};
fn read(scale: tvg.Scale, reader: anytype) !Self {
const tag = @bitCast(Tag, try readByte(reader));
var line_width: ?f32 = if (tag.has_line_width)
try readUnit(scale, reader)
else
null;
return switch (tag.type) {
.line => Self{ .line = NodeData(Point).init(line_width, .{
.x = try readUnit(scale, reader),
.y = try readUnit(scale, reader),
}) },
.horiz => Self{ .horiz = NodeData(f32).init(line_width, try readUnit(scale, reader)) },
.vert => Self{ .vert = NodeData(f32).init(line_width, try readUnit(scale, reader)) },
.bezier => Self{ .bezier = NodeData(Bezier).init(line_width, Bezier{
.c0 = Point{
.x = try readUnit(scale, reader),
.y = try readUnit(scale, reader),
},
.c1 = Point{
.x = try readUnit(scale, reader),
.y = try readUnit(scale, reader),
},
.p1 = Point{
.x = try readUnit(scale, reader),
.y = try readUnit(scale, reader),
},
}) },
.arc_circ => blk: {
var flags = try readByte(reader);
break :blk Self{ .arc_circle = NodeData(ArcCircle).init(line_width, ArcCircle{
.radius = try readUnit(scale, reader),
.large_arc = (flags & 1) != 0,
.sweep = (flags & 2) != 0,
.target = Point{
.x = try readUnit(scale, reader),
.y = try readUnit(scale, reader),
},
}) };
},
.arc_ellipse => blk: {
var flags = try readByte(reader);
break :blk Self{ .arc_ellipse = NodeData(ArcEllipse).init(line_width, ArcEllipse{
.radius_x = try readUnit(scale, reader),
.radius_y = try readUnit(scale, reader),
.rotation = try readUnit(scale, reader),
.large_arc = (flags & 1) != 0,
.sweep = (flags & 2) != 0,
.target = Point{
.x = try readUnit(scale, reader),
.y = try readUnit(scale, reader),
},
}) };
},
.close => Self{ .close = NodeData(void).init(line_width, {}) },
.reserved => return error.InvalidData,
};
}
};
const StyleType = enum(u2) {
flat = 0,
linear = 1,
radial = 2,
};
pub const Style = union(StyleType) {
const Self = @This();
flat: u32, // color index
linear: Gradient,
radial: Gradient,
fn read(reader: anytype, scale: tvg.Scale, kind: StyleType) !Self {
return switch (kind) {
.flat => Style{ .flat = try readUInt(reader) },
.linear => Style{ .linear = try Gradient.loadFromStream(scale, reader) },
.radial => Style{ .radial = try Gradient.loadFromStream(scale, reader) },
};
}
};
const Gradient = struct {
const Self = @This();
point_0: Point,
point_1: Point,
color_0: u32,
color_1: u32,
fn loadFromStream(scale: tvg.Scale, reader: anytype) !Self {
var grad: Gradient = undefined;
grad.point_0 = Point{
.x = try readUnit(scale, reader),
.y = try readUnit(scale, reader),
};
grad.point_1 = Point{
.x = try readUnit(scale, reader),
.y = try readUnit(scale, reader),
};
grad.color_0 = try readUInt(reader);
grad.color_1 = try readUInt(reader);
return grad;
}
};
pub fn Parser(comptime Reader: type) type {
return struct {
const Self = @This();
reader: Reader,
allocator: *std.mem.Allocator,
temp_buffer: std.ArrayList(u8),
end_of_document: bool = false,
header: Header,
color_table: []tvg.Color,
pub fn init(allocator: *std.mem.Allocator, reader: Reader) !Self {
var actual_magic_number: [2]u8 = undefined;
reader.readNoEof(&actual_magic_number) catch return error.InvalidData;
if (!std.mem.eql(u8, &actual_magic_number, &tvg.magic_number))
return error.InvalidData;
const version = reader.readByte() catch return error.InvalidData;
var header: Header = undefined;
var color_table: []tvg.Color = undefined;
switch (version) {
1 => {
const ScaleAndFlags = packed struct {
scale: u4,
custom_color_space: bool,
padding: u3,
};
const scale_and_flags = @bitCast(ScaleAndFlags, try readByte(reader));
if (scale_and_flags.scale > 8)
return error.InvalidData;
const scale = @intToEnum(tvg.Scale, scale_and_flags.scale);
const width = try readUnit(scale, reader);
const height = try readUnit(scale, reader);
const color_count = reader.readIntLittle(u16) catch return error.InvalidData;
color_table = try allocator.alloc(tvg.Color, color_count);
errdefer allocator.free(color_table);
for (color_table) |*c| {
c.* = tvg.Color{
.r = try reader.readByte(),
.g = try reader.readByte(),
.b = try reader.readByte(),
.a = try reader.readByte(),
};
}
header = Header{
.version = version,
.scale = scale,
.width = width,
.height = height,
.custom_color_space = scale_and_flags.custom_color_space,
};
},
else => return error.UnsupportedVersion,
}
return Self{
.allocator = allocator,
.reader = reader,
.temp_buffer = std.ArrayList(u8).init(allocator),
.header = header,
.color_table = color_table,
};
}
pub fn deinit(self: *Self) void {
self.temp_buffer.deinit();
self.allocator.free(self.color_table);
self.* = undefined;
}
fn setTempStorage(self: *Self, comptime T: type, length: usize) ![]T {
try self.temp_buffer.resize(@sizeOf(T) * length);
var items = @alignCast(@alignOf(T), std.mem.bytesAsSlice(T, self.temp_buffer.items));
std.debug.assert(items.len == length);
return items;
}
pub fn next(self: *Self) !?DrawCommand {
if (self.end_of_document)
return null;
const command_byte = try self.reader.readByte();
return switch (@intToEnum(tvg.format.Command, command_byte)) {
.end_of_document => {
self.end_of_document = true;
return null;
},
.fill_polygon => blk: {
const count_and_grad = @bitCast(CountAndStyleTag, try readByte(self.reader));
const vertex_count = count_and_grad.getCount();
if (vertex_count < 2) return error.InvalidData;
const style = try Style.read(self.reader, self.header.scale, try count_and_grad.getStyleType());
var vertices = try self.setTempStorage(Point, vertex_count);
for (vertices) |*pt| {
pt.x = try readUnit(self.header.scale, self.reader);
pt.y = try readUnit(self.header.scale, self.reader);
}
break :blk DrawCommand{
.fill_polygon = DrawCommand.FillPolygon{
.style = style,
.vertices = vertices,
},
};
},
.fill_rectangles => blk: {
const count_and_grad = @bitCast(CountAndStyleTag, try readByte(self.reader));
const style = try Style.read(self.reader, self.header.scale, try count_and_grad.getStyleType());
const rectangle_count = count_and_grad.getCount();
var rectangles = try self.setTempStorage(Rectangle, rectangle_count);
for (rectangles) |*rect| {
rect.x = try readUnit(self.header.scale, self.reader);
rect.y = try readUnit(self.header.scale, self.reader);
rect.width = try readUnit(self.header.scale, self.reader);
rect.height = try readUnit(self.header.scale, self.reader);
if (rect.width <= 0 or rect.height <= 0)
return error.InvalidFormat;
}
break :blk DrawCommand{
.fill_rectangles = DrawCommand.FillRectangles{
.style = style,
.rectangles = rectangles,
},
};
},
.fill_path => blk: {
const count_and_grad = @bitCast(CountAndStyleTag, try readByte(self.reader));
const style = try Style.read(self.reader, self.header.scale, try count_and_grad.getStyleType());
const path_length = count_and_grad.getCount();
const start_x = try readUnit(self.header.scale, self.reader);
const start_y = try readUnit(self.header.scale, self.reader);
var path = try self.setTempStorage(PathNode, path_length);
for (path) |*node| {
node.* = try PathNode.read(self.header.scale, self.reader);
}
break :blk DrawCommand{
.fill_path = DrawCommand.FillPath{
.style = style,
.start = Point{
.x = start_x,
.y = start_y,
},
.path = path,
},
};
},
.draw_lines => blk: {
const count_and_grad = @bitCast(CountAndStyleTag, try readByte(self.reader));
const style = try Style.read(self.reader, self.header.scale, try count_and_grad.getStyleType());
const line_count = count_and_grad.getCount();
const line_width = try readUnit(self.header.scale, self.reader);
var lines = try self.setTempStorage(Line, line_count);
for (lines) |*line| {
line.start.x = try readUnit(self.header.scale, self.reader);
line.start.y = try readUnit(self.header.scale, self.reader);
line.end.x = try readUnit(self.header.scale, self.reader);
line.end.y = try readUnit(self.header.scale, self.reader);
}
break :blk DrawCommand{
.draw_lines = DrawCommand.DrawLines{
.style = style,
.line_width = line_width,
.lines = lines,
},
};
},
.draw_line_loop => blk: {
const count_and_grad = @bitCast(CountAndStyleTag, try readByte(self.reader));
const style = try Style.read(self.reader, self.header.scale, try count_and_grad.getStyleType());
const point_count = count_and_grad.getCount() + 1;
const line_width = try readUnit(self.header.scale, self.reader);
var points = try self.setTempStorage(Point, point_count);
for (points) |*point| {
point.x = try readUnit(self.header.scale, self.reader);
point.y = try readUnit(self.header.scale, self.reader);
}
break :blk DrawCommand{
.draw_line_loop = DrawCommand.DrawLineSegments{
.style = style,
.line_width = line_width,
.vertices = points,
},
};
},
.draw_line_strip => blk: {
const count_and_grad = @bitCast(CountAndStyleTag, try readByte(self.reader));
const style = try Style.read(self.reader, self.header.scale, try count_and_grad.getStyleType());
const point_count = count_and_grad.getCount() + 1;
const line_width = try readUnit(self.header.scale, self.reader);
var points = try self.setTempStorage(Point, point_count);
for (points) |*point| {
point.x = try readUnit(self.header.scale, self.reader);
point.y = try readUnit(self.header.scale, self.reader);
}
break :blk DrawCommand{
.draw_line_strip = DrawCommand.DrawLineSegments{
.style = style,
.line_width = line_width,
.vertices = points,
},
};
},
.draw_line_path => blk: {
const count_and_grad = @bitCast(CountAndStyleTag, try readByte(self.reader));
const style = try Style.read(self.reader, self.header.scale, try count_and_grad.getStyleType());
const path_length = count_and_grad.getCount();
const line_width = try readUnit(self.header.scale, self.reader);
const start_x = try readUnit(self.header.scale, self.reader);
const start_y = try readUnit(self.header.scale, self.reader);
var path = try self.setTempStorage(PathNode, path_length);
for (path) |*node| {
node.* = try PathNode.read(self.header.scale, self.reader);
}
break :blk DrawCommand{
.draw_line_path = DrawCommand.DrawPath{
.style = style,
.line_width = line_width,
.start = Point{
.x = start_x,
.y = start_y,
},
.path = path,
},
};
},
.outline_fill_polygon => @panic("parsing outline_fill_polygon not implemented yet!"),
.outline_fill_rectangles => blk: {
const count_and_grad = @bitCast(CountAndStyleTag, try readByte(self.reader));
const line_style_dat = try readByte(self.reader);
const line_style = try Style.read(self.reader, self.header.scale, try convertStyleType(@truncate(u2, line_style_dat)));
const fill_style = try Style.read(self.reader, self.header.scale, try count_and_grad.getStyleType());
const line_width = try readUnit(self.header.scale, self.reader);
const rectangle_count = count_and_grad.getCount();
var rectangles = try self.setTempStorage(Rectangle, rectangle_count);
for (rectangles) |*rect| {
rect.x = try readUnit(self.header.scale, self.reader);
rect.y = try readUnit(self.header.scale, self.reader);
rect.width = try readUnit(self.header.scale, self.reader);
rect.height = try readUnit(self.header.scale, self.reader);
if (rect.width <= 0 or rect.height <= 0)
return error.InvalidFormat;
}
break :blk DrawCommand{
.outline_fill_rectangles = DrawCommand.OutlineFillRectangles{
.fill_style = fill_style,
.line_style = line_style,
.line_width = line_width,
.rectangles = rectangles,
},
};
},
.outline_fill_path => @panic("parsing outline_fill_path not implemented yet!"),
_ => return error.InvalidData,
};
}
};
}
const CountAndStyleTag = packed struct {
const Self = @This();
raw_count: u6,
style_kind: u2,
pub fn getCount(self: Self) usize {
if (self.raw_count == 0)
return self.raw_count -% 1;
return self.raw_count;
}
pub fn getStyleType(self: Self) !StyleType {
return convertStyleType(self.style_kind);
}
};
fn convertStyleType(value: u2) !StyleType {
return switch (value) {
@enumToInt(StyleType.flat) => StyleType.flat,
@enumToInt(StyleType.linear) => StyleType.linear,
@enumToInt(StyleType.radial) => StyleType.radial,
else => error.InvalidData,
};
}
fn readUInt(reader: anytype) error{InvalidData}!u32 {
var byte_count: u8 = 0;
var result: u32 = 0;
while (true) {
const byte = reader.readByte() catch return error.InvalidData;
// check for too long *and* out of range in a single check
if (byte_count == 4 and (byte & 0xF0) != 0)
return error.InvalidData;
const val = @as(u32, (byte & 0x7F)) << @intCast(u5, (7 * byte_count));
result |= val;
if ((byte & 0x80) == 0)
break;
byte_count += 1;
std.debug.assert(byte_count <= 5);
}
return result;
}
fn readUnit(scale: tvg.Scale, reader: anytype) !f32 {
return @intToEnum(tvg.Unit, try reader.readIntLittle(i16)).toFloat(scale);
}
fn readByte(reader: anytype) !u8 {
return reader.readByte();
}
test "readUInt" {
const T = struct {
fn run(seq: []const u8) !u32 {
var stream = std.io.fixedBufferStream(seq);
return try readUInt(stream.reader());
}
};
std.testing.expectEqual(@as(u32, 0x00), try T.run(&[_]u8{0x00}));
std.testing.expectEqual(@as(u32, 0x40), try T.run(&[_]u8{0x40}));
std.testing.expectEqual(@as(u32, 0x80), try T.run(&[_]u8{ 0x80, 0x01 }));
std.testing.expectEqual(@as(u32, 0x100000), try T.run(&[_]u8{ 0x80, 0x80, 0x40 }));
std.testing.expectEqual(@as(u32, 0x8000_0000), try T.run(&[_]u8{ 0x80, 0x80, 0x80, 0x80, 0x08 }));
std.testing.expectError(error.InvalidData, T.run(&[_]u8{ 0x80, 0x80, 0x80, 0x80, 0x10 })); // out of range
std.testing.expectError(error.InvalidData, T.run(&[_]u8{ 0x80, 0x80, 0x80, 0x80, 0x80, 0x10 })); // too long
}
test "coverage test" {
const source = &@import("ground-truth").feature_showcase;
var stream = std.io.fixedBufferStream(@as([]const u8, source));
var parser = try Parser(@TypeOf(stream).Reader).init(std.testing.allocator, stream.reader());
defer parser.deinit();
while (try parser.next()) |node| {
_ = node;
}
} | src/lib/parsing.zig |
pub const CLSID_XMLGraphBuilder = Guid.initString("1bb05961-5fbf-11d2-a521-44df07c10000");
//--------------------------------------------------------------------------------
// Section: Types (1)
//--------------------------------------------------------------------------------
// TODO: this type is limited to platform 'windows5.0'
const IID_IXMLGraphBuilder_Value = @import("../../zig.zig").Guid.initString("1bb05960-5fbf-11d2-a521-44df07c10000");
pub const IID_IXMLGraphBuilder = &IID_IXMLGraphBuilder_Value;
pub const IXMLGraphBuilder = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
BuildFromXML: fn(
self: *const IXMLGraphBuilder,
pGraph: ?*IGraphBuilder,
pxml: ?*IXMLElement,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SaveToXML: fn(
self: *const IXMLGraphBuilder,
pGraph: ?*IGraphBuilder,
pbstrxml: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
BuildFromXMLFile: fn(
self: *const IXMLGraphBuilder,
pGraph: ?*IGraphBuilder,
wszFileName: ?[*:0]const u16,
wszBaseURL: ?[*: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 IXMLGraphBuilder_BuildFromXML(self: *const T, pGraph: ?*IGraphBuilder, pxml: ?*IXMLElement) callconv(.Inline) HRESULT {
return @ptrCast(*const IXMLGraphBuilder.VTable, self.vtable).BuildFromXML(@ptrCast(*const IXMLGraphBuilder, self), pGraph, pxml);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IXMLGraphBuilder_SaveToXML(self: *const T, pGraph: ?*IGraphBuilder, pbstrxml: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IXMLGraphBuilder.VTable, self.vtable).SaveToXML(@ptrCast(*const IXMLGraphBuilder, self), pGraph, pbstrxml);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IXMLGraphBuilder_BuildFromXMLFile(self: *const T, pGraph: ?*IGraphBuilder, wszFileName: ?[*:0]const u16, wszBaseURL: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IXMLGraphBuilder.VTable, self.vtable).BuildFromXMLFile(@ptrCast(*const IXMLGraphBuilder, self), pGraph, wszFileName, wszBaseURL);
}
};}
pub usingnamespace MethodMixin(@This());
};
//--------------------------------------------------------------------------------
// Section: Functions (0)
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
// Section: Unicode Aliases (0)
//--------------------------------------------------------------------------------
const thismodule = @This();
pub usingnamespace switch (@import("../../zig.zig").unicode_mode) {
.ansi => struct {
},
.wide => struct {
},
.unspecified => if (@import("builtin").is_test) struct {
} else struct {
},
};
//--------------------------------------------------------------------------------
// Section: Imports (7)
//--------------------------------------------------------------------------------
const Guid = @import("../../zig.zig").Guid;
const BSTR = @import("../../foundation.zig").BSTR;
const HRESULT = @import("../../foundation.zig").HRESULT;
const IGraphBuilder = @import("../../media/direct_show.zig").IGraphBuilder;
const IUnknown = @import("../../system/com.zig").IUnknown;
const IXMLElement = @import("../../data/xml/ms_xml.zig").IXMLElement;
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/media/direct_show/xml.zig |
const std = @import("std");
const builtin = @import("builtin");
const Builder = std.build.Builder;
pub fn build(b: *Builder) void {
const build_mode = b.standardReleaseOptions();
const target = b.standardTargetOptions(.{});
const compile_image_commands = [_]*std.build.RunStep{
b.addSystemCommand(&[_][]const u8{
"./tools/compile_spritesheet.py",
"assets/img32/",
"--glob=*.png",
"--tile-size=32",
"--spritesheet-path=zig-cache/spritesheet32_resource",
"--defs-path=zig-cache/spritesheet32.zig",
"--deps=zig-cache/spritesheet32_resource.d",
}),
b.addSystemCommand(&[_][]const u8{
"./tools/compile_spritesheet.py",
"assets/img200/",
"--glob=*.png",
"--tile-size=200",
"--spritesheet-path=zig-cache/spritesheet200_resource",
"--defs-path=zig-cache/spritesheet200.zig",
"--deps=zig-cache/spritesheet200_resource.d",
}),
b.addSystemCommand(&[_][]const u8{
"./tools/compile_spritesheet.py",
"assets/font/",
"--glob=*.png",
"--slice-tiles=12x16",
"--spritesheet-path=zig-cache/fontsheet_resource",
"--defs-path=zig-cache/fontsheet.zig",
"--deps=zig-cache/fontsheet_resource.d",
}),
b.addSystemCommand(&[_][]const u8{
"python3",
"-c",
\\import subprocess
\\tag_str = subprocess.check_output(["git", "describe", "--tags"]).strip()
\\with open("zig-cache/version.txt", "wb") as f:
\\ f.write(tag_str)
}),
};
for (compile_image_commands) |compile_image_command| {
compile_image_command.setEnvironmentVariable("PYTHONPATH", "deps/simplepng.py/");
}
const headless_build = make_binary_variant(b, build_mode, target, "legend-of-swarkland_headless", true);
const gui_build = make_binary_variant(b, build_mode, target, "legend-of-swarkland", false);
for (compile_image_commands) |compile_image_command| {
gui_build.dependOn(&compile_image_command.step);
}
b.default_step.dependOn(headless_build);
b.default_step.dependOn(gui_build);
const do_fmt = b.option(bool, "fmt", "zig fmt before building") orelse true;
if (do_fmt) {
const fmt_command = b.addFmt(&[_][]const u8{
"build.zig",
"src/core",
"src/gui",
});
headless_build.dependOn(&fmt_command.step);
gui_build.dependOn(&fmt_command.step);
}
}
fn make_binary_variant(
b: *Builder,
build_mode: builtin.Mode,
target: std.build.Target,
name: []const u8,
headless: bool,
) *std.build.Step {
const exe = if (headless) b.addExecutable(name, "src/server/server_main.zig") else b.addExecutable(name, "src/gui/gui_main.zig");
exe.setTarget(target);
exe.install();
exe.addPackagePath("core", "src/index.zig");
if (!headless) {
if (target.getOsTag() == .windows and target.getAbi() == .gnu) {
@import("deps/zig-sdl/build.zig").linkArtifact(b, .{
.artifact = exe,
.prefix = "deps/zig-sdl",
.override_mode = .ReleaseFast,
});
} else {
exe.linkSystemLibrary("SDL2");
}
exe.linkSystemLibrary("c");
} else {
// TODO: only used for malloc
exe.linkSystemLibrary("c");
}
// FIXME: workaround https://github.com/ziglang/zig/issues/855
exe.setMainPkgPath(".");
exe.setBuildMode(build_mode);
return &exe.step;
} | build.zig |
const std = @import("std");
const iup = @import("iup.zig");
const MainLoop = iup.MainLoop;
const Dialog = iup.Dialog;
const Button = iup.Button;
const MessageDlg = iup.MessageDlg;
const Multiline = iup.Multiline;
const Label = iup.Label;
const Text = iup.Text;
const VBox = iup.VBox;
const HBox = iup.HBox;
const Menu = iup.Menu;
const SubMenu = iup.SubMenu;
const Separator = iup.Separator;
const Fill = iup.Fill;
const Item = iup.Item;
const FileDlg = iup.FileDlg;
const Toggle = iup.Toggle;
const List = iup.List;
const Frame = iup.Frame;
const Radio = iup.Radio;
const Canvas = iup.Canvas;
const ScreenSize = iup.ScreenSize;
const Image = iup.Image;
const ImageRgb = iup.ImageRgb;
const ImageRgba = iup.ImageRgba;
const Rgb = iup.Rgb;
const Gauge = iup.Gauge;
const DEFAULT_SPEED: f64 = 0.00001;
var speed = DEFAULT_SPEED;
pub fn main() !void {
try MainLoop.open();
defer MainLoop.close();
MainLoop.setIdleCallback(onIdle);
var dlg = try createDialog();
defer dlg.deinit();
try dlg.showXY(.Center, .Center);
try MainLoop.beginLoop();
}
fn createDialog() !*Dialog {
var img_pause = try images.getPause();
var img_forward = try images.getForward();
var img_rewind = try images.getRewind();
var img_show = try images.getShow();
return try (Dialog.init()
.setSize(ScreenSize{ .Size = 200 }, null)
.setTitle("IupGauge")
.setChildren(
.{
VBox.init()
.setMargin(10, 10)
.setGap(5)
.setChildren(
.{
Gauge.init()
.setHandle("gauge")
.setExpand(.Yes),
HBox.init()
.setChildren(
.{
Fill.init(),
Button.init().setActionCallback(onPause)
.setImage(img_pause)
.setTip("Pause"),
Button.init()
.setActionCallback(onRewind)
.setImage(img_rewind)
.setTip("Rewind"),
Button.init()
.setActionCallback(onForward)
.setImage(img_forward)
.setTip("Forward"),
Button.init()
.setActionCallback(onShow)
.setImage(img_show)
.setTip("Show"),
Fill.init(),
},
),
},
),
},
)
.unwrap());
}
fn onPause(self: *Button) anyerror!void {
if (speed == 0) {
speed = DEFAULT_SPEED;
var img = try images.getPause();
try self.setImage(img);
} else {
speed = 0;
var img = try images.getPlay();
try self.setImage(img);
}
}
fn onRewind(self: *Button) anyerror!void {
_ = self;
if (speed < 0) {
speed *= 2;
} else {
speed = -1 * DEFAULT_SPEED;
}
}
fn onForward(self: *Button) anyerror!void {
_ = self;
if (speed > 0) {
speed *= 2;
} else {
speed = DEFAULT_SPEED;
}
}
fn onShow(self: *Button) anyerror!void {
_ = self;
var gauge = Gauge.fromHandleName("gauge") orelse return;
if (gauge.getShowText()) {
gauge.setShowText(false);
gauge.setDashed(true);
} else {
gauge.setShowText(true);
gauge.setDashed(false);
}
}
fn onIdle() anyerror!void {
if (speed == 0) return;
var gauge = Gauge.fromHandleName("gauge") orelse return;
var value = gauge.getValue();
value += speed;
if (value > gauge.getMax()) {
value = gauge.getMin();
} else if (value < gauge.getMin()) {
value = gauge.getMax();
}
gauge.setValue(value);
}
const images = struct {
const pixmap_play = [_]u8{ // zig fmt: off
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2
,2,2,2,2,2,2,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
}; // zig fmt: on
const pixmap_pause = [_]u8{ // zig fmt: off
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
}; // zig fmt: on
const pixmap_rewind = [_]u8{ // zig fmt: off
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,1,2,2,2,2,1,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,1,1,2,2,2,1,1,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,1,1,1,2,2,1,1,1,2,2,2,2,2,2,2
,2,2,2,2,2,2,1,1,1,1,2,1,1,1,1,2,2,2,2,2,2,2
,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2
,2,2,2,2,2,2,1,1,1,1,2,1,1,1,1,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,1,1,1,2,2,1,1,1,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,1,1,2,2,2,1,1,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,1,2,2,2,2,1,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
}; // zig fmt: on
const pixmap_forward = [_]u8{ // zig fmt: off
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,1,2,2,2,2,1,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,1,1,2,2,2,1,1,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,1,1,1,2,2,1,1,1,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,1,1,1,1,2,1,1,1,1,2,2,2,2,2,2
,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2
,2,2,2,2,2,2,2,1,1,1,1,2,1,1,1,1,2,2,2,2,2,2
,2,2,2,2,2,2,2,1,1,1,2,2,1,1,1,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,1,1,2,2,2,1,1,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,1,2,2,2,2,1,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
}; // zig fmt: on
const pixmap_show = [_]u8{ // zig fmt: off
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,1,1,1,1,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,1,1,2,2,2,2,1,1,2,2,2,2,2,2,2
,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2
,2,2,2,2,2,1,2,2,2,1,1,1,2,2,2,2,1,2,2,2,2,2
,2,2,2,2,1,2,2,2,1,1,2,2,1,2,2,2,2,1,2,2,2,2
,2,2,2,1,2,2,2,2,1,1,1,2,1,2,2,2,2,2,1,2,2,2
,2,2,2,2,1,2,2,2,1,1,1,1,1,2,2,2,2,1,2,2,2,2
,2,2,2,2,2,1,2,2,2,1,1,1,2,2,2,2,1,2,2,2,2,2
,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2
,2,2,2,2,2,2,2,1,1,2,2,2,2,1,1,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,1,1,1,1,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
}; // zig fmt: on
pub fn getPause() !*Image {
if (Image.fromHandleName("img_pause")) |value| return value;
return try (Image.init(22, 22, pixmap_pause[0..])
.setHandle("img_pause")
.setColors(1, .{ .r = 0, .g = 0, .b = 0 })
.setColors(2, Rgb.BG_COLOR)
.unwrap());
}
pub fn getPlay() !*Image {
if (Image.fromHandleName("img_play")) |value| return value;
return try (Image.init(22, 22, pixmap_play[0..])
.setHandle("img_play")
.setColors(1, .{ .r = 0, .g = 0, .b = 0 })
.setColors(2, Rgb.BG_COLOR)
.unwrap());
}
pub fn getForward() !*Image {
if (Image.fromHandleName("img_forward")) |value| return value;
return try (Image.init(22, 22, pixmap_forward[0..])
.setHandle("img_forward")
.setColors(1, .{ .r = 0, .g = 0, .b = 0 })
.setColors(2, Rgb.BG_COLOR)
.unwrap());
}
pub fn getRewind() !*Image {
if (Image.fromHandleName("img_rewind")) |value| return value;
return try (Image.init(22, 22, pixmap_rewind[0..])
.setHandle("img_rewind")
.setColors(1, .{ .r = 0, .g = 0, .b = 0 })
.setColors(2, Rgb.BG_COLOR)
.unwrap());
}
pub fn getShow() !*Image {
if (Image.fromHandleName("img_show")) |value| return value;
return try (Image.init(22, 22, pixmap_show[0..])
.setHandle("img_show")
.setColors(1, .{ .r = 0, .g = 0, .b = 0 })
.setColors(2, Rgb.BG_COLOR)
.unwrap());
}
}; | src/gauge_example.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const RGBColor = struct {
b: u8,
g: u8,
r: u8,
a: u8,
};
const WORD = u16;
const DWORD = u32;
const LONG = i32;
const BITMAPINFOHEADER = struct {
biSize: DWORD,
biWidth: LONG,
biHeight: LONG,
biPlanes: WORD,
biBitCount: WORD,
biCompression: DWORD,
biSizeImage: DWORD,
biXPelsPerMeter: LONG,
biYPelsPerMeter: LONG,
biClrUsed: DWORD,
biClrImportant: DWORD,
};
const BITMAPFILEHEADER = packed struct {
bfType: WORD,
bfSize: DWORD,
bfReserved1: WORD,
bfReserved2: WORD,
bfOffBits: DWORD,
};
const Vector = struct {
x: f64,
y: f64,
z: f64,
pub fn init(x: f64, y: f64, z: f64) Vector {
return Vector{ .x = x, .y = y, .z = z };
}
pub fn scale(self: Vector, k: f64) Vector {
return Vector.init(k * self.x, k * self.y, k * self.z);
}
pub fn add(self: Vector, v: Vector) Vector {
return Vector.init(self.x + v.x, self.y + v.y, self.z + v.z);
}
pub fn sub(self: Vector, v: Vector) Vector {
return Vector.init(self.x - v.x, self.y - v.y, self.z - v.z);
}
pub fn dot(self: Vector, v: Vector) f64 {
return self.x * v.x + self.y * v.y + self.z * v.z;
}
pub fn mag(self: Vector) f64 {
return std.math.sqrt(self.x * self.x + self.y * self.y + self.z * self.z);
}
pub fn norm(self: Vector) Vector {
var magnitude = self.mag();
var div: f64 = 0.0;
if (magnitude == 0.0) {
div = FarAway;
} else {
div = 1.0 / magnitude;
}
return self.scale(div);
}
pub fn cross(self: Vector, v: Vector) Vector {
return Vector.init(self.y * v.z - self.z * v.y, self.z * v.x - self.x * v.z, self.x * v.y - self.y * v.x);
}
};
const Color = struct {
r: f64 = 0,
g: f64 = 0,
b: f64 = 0,
pub fn init(r: f64, g: f64, b: f64) Color {
return Color{ .r = r, .g = g, .b = b };
}
pub fn scale(self: Color, k: f64) Color {
return Color.init(k * self.r, k * self.g, k * self.b);
}
pub fn add(self: Color, color: Color) Color {
return Color.init(self.r + color.r, self.g + color.g, self.b + color.b);
}
pub fn mul(self: Color, color: Color) Color {
return Color.init(self.r * color.r, self.g * color.g, self.b * color.b);
}
pub fn toDrawingColor(self: Color) RGBColor {
return RGBColor{
.r = clamp(self.r),
.g = clamp(self.g),
.b = clamp(self.b),
.a = 255,
};
}
pub fn clamp(c: f64) u8 {
if (c < 0.0) return 1;
if (c > 1.0) return 255;
return @floatToInt(u8, c * 255.0);
}
};
const FarAway = 1000000.0;
const MaxDepth = 5;
const White = Color.init(1.0, 1.0, 1.0);
const Grey = Color.init(0.5, 0.5, 0.5);
const Black = Color.init(0.0, 0.0, 0.0);
const Background = Black;
const DefaultColor = Black;
const Camera = struct {
forward: Vector,
right: Vector,
up: Vector,
pos: Vector,
pub fn init(pos: Vector, lookAt: Vector) Camera {
const down = Vector.init(0.0, -1.0, 0.0);
const forward = lookAt.sub(pos);
const right = forward.cross(down).norm().scale(1.5);
const up = forward.cross(right).norm().scale(1.5);
return Camera{
.pos = pos,
.forward = forward.norm(),
.right = right,
.up = up,
};
}
};
const Ray = struct {
start: Vector,
dir: Vector,
pub fn init(start: Vector, dir: Vector) Ray {
return Ray{ .start = start, .dir = dir };
}
};
const Intersection = struct {
thing: Thing,
ray: Ray,
dist: f64,
pub fn init(thing: Thing, ray: Ray, dist: f64) Intersection {
return Intersection{ .thing = thing, .ray = ray, .dist = dist };
}
};
const SurfaceProperties = struct {
diffuse: Color,
specular: Color,
reflect: f64,
roughness: f64,
};
const Light = struct {
pos: Vector,
color: Color,
pub fn init(pos: Vector, color: Color) Light {
return Light{ .pos = pos, .color = color };
}
};
const Surface = enum {
ShinySurface,
CheckerboardSurface,
};
const Thing = union(enum) {
Plane: struct {
norm: Vector, offset: f64, surface: Surface
},
Sphere: struct {
center: Vector, radius2: f64, surface: Surface
},
};
fn GetNormal(thing: Thing, pos: Vector) Vector {
return switch (thing) {
Thing.Plane => |plane| plane.norm,
Thing.Sphere => |sphere| (pos.sub(sphere.center)).norm(),
};
}
fn GetSurface(thing: Thing) Surface {
return switch (thing) {
Thing.Plane => |plane| plane.surface,
Thing.Sphere => |sphere| sphere.surface,
};
}
fn GetIntersection(thing: Thing, ray: Ray) ?Intersection {
return switch (thing) {
Thing.Plane => |plane| {
var denom = plane.norm.dot(ray.dir);
if (denom > 0) {
return null;
}
var dist = (plane.norm.dot(ray.start) + plane.offset) / (-denom);
return Intersection.init(thing, ray, dist);
},
Thing.Sphere => |sphere| {
var eo = sphere.center.sub(ray.start);
var v = eo.dot(ray.dir);
var dist: f64 = 0.0;
if (v >= 0) {
var disc = sphere.radius2 - (eo.dot(eo) - v * v);
if (disc >= 0) {
dist = v - std.math.sqrt(disc);
}
}
if (dist == 0) {
return null;
}
return Intersection.init(thing, ray, dist);
},
};
}
fn GetSurfaceProperties(surface: Surface, pos: Vector) SurfaceProperties {
return switch (surface) {
Surface.ShinySurface => {
return SurfaceProperties{
.diffuse = White,
.specular = Grey,
.reflect = 0.7,
.roughness = 250.0,
};
},
Surface.CheckerboardSurface => {
var condition = @mod(@floatToInt(i32, std.math.floor(pos.z) + std.math.floor(pos.x)), 2) != 0;
var color = Black;
var reflect: f64 = 0.7;
if (condition) {
color = White;
reflect = 0.1;
}
return SurfaceProperties{
.diffuse = color,
.specular = White,
.reflect = reflect,
.roughness = 150.0,
};
},
};
}
const Scene = struct {
things: [3]Thing,
lights: [4]Light,
camera: Camera,
pub fn init() Scene {
var things = [3]Thing{
Thing{ .Plane = .{ .norm = Vector.init(0.0, 1.0, 0.0), .offset = 0.0, .surface = Surface.CheckerboardSurface } },
Thing{ .Sphere = .{ .center = Vector.init(0.0, 1.0, -0.25), .radius2 = 1.0, .surface = Surface.ShinySurface } },
Thing{ .Sphere = .{ .center = Vector.init(-1.0, 0.5, 1.5), .radius2 = 0.25, .surface = Surface.ShinySurface } },
};
var lights = [4]Light{
Light.init(Vector.init(-2.0, 2.5, 0.0), Color.init(0.49, 0.07, 0.07)),
Light.init(Vector.init(1.5, 2.5, 1.5), Color.init(0.07, 0.07, 0.49)),
Light.init(Vector.init(1.5, 2.5, -1.5), Color.init(0.07, 0.49, 0.071)),
Light.init(Vector.init(0.0, 3.5, 0.0), Color.init(0.21, 0.21, 0.35)),
};
var camera = Camera.init(Vector.init(3.0, 2.0, 4.0), Vector.init(-1.0, 0.5, 0.0));
return Scene{ .things = things, .lights = lights, .camera = camera };
}
};
const Image = struct {
width: i32,
height: i32,
data: [*]RGBColor,
pub fn init(allocator: *Allocator, w: i32, h: i32) Image {
var size: usize = @intCast(usize, w*h);
var data = try allocator.alloc(RGBColor, size);
return Image{ .width = w, .height = h, .data = data };
}
pub fn setColor(self: Image, x: i32, y: i32, c: RGBColor) void {
var idx: usize = @intCast(usize, y * self.width + x);
self.data[idx] = c;
}
pub fn save(self:Image, fileName:[]const u8) void {
// bmpInfoHeader := BITMAPINFOHEADER{};
// bmpInfoHeader.biSize = size_of(BITMAPINFOHEADER);
// bmpInfoHeader.biBitCount = 32;
// bmpInfoHeader.biClrImportant = 0;
// bmpInfoHeader.biClrUsed = 0;
// bmpInfoHeader.biCompression = 0;
// bmpInfoHeader.biHeight = LONG(-image.height);
// bmpInfoHeader.biWidth = LONG(image.width);
// bmpInfoHeader.biPlanes = 1;
// bmpInfoHeader.biSizeImage = DWORD(image.width * image.height * 4);
// bfh := BITMAPFILEHEADER{};
// bfh.bfType = 'B' + ('M' << 8);
// bfh.bfOffBits = size_of(BITMAPINFOHEADER) + size_of(BITMAPFILEHEADER);
// bfh.bfSize = bfh.bfOffBits + bmpInfoHeader.biSizeImage;
// f, err := os.open(fileName, os.O_WRONLY | os.O_CREATE);
// if err == os.ERROR_NONE {
// os.write_ptr(f, &bfh, size_of(bfh));
// os.write_ptr(f, &bmpInfoHeader, size_of(bmpInfoHeader));
// os.write_ptr(f, &image.data[0], len(image.data) * size_of(RgbColor));
// }
// os.close(f);
}
};
pub fn GetClosestIntersection(scene: Scene, ray: Ray) ?Intersection {
var closest: f64 = FarAway;
var closestInter: ?Intersection = null;
for (scene.things) |thing| {
var isect = GetIntersection(thing, ray);
if (isect != null and isect.?.dist < closest) {
closestInter = isect;
closest = isect.?.dist;
}
}
return closestInter;
}
pub fn TraceRay(scene: Scene, ray: Ray, depth: i32) Color {
var isect = GetClosestIntersection(scene, ray);
if (isect == null) {
return Background;
}
return Shade(scene, isect.?, depth);
}
pub fn Shade(scene: Scene, isect: Intersection, depth: i32) Color {
var d = isect.ray.dir;
var pos = d.scale(isect.dist).add(isect.ray.start);
var normal = GetNormal(isect.thing, pos);
var vec = normal.scale(normal.dot(d) * 2.0);
var reflectDir = d.sub(vec);
var naturalColor = Background.add(GetNaturalColor(scene, isect.thing, pos, normal, reflectDir));
var reflectedColor = Grey;
if (depth < MaxDepth) {
reflectedColor = GetReflectionColor(scene, isect.thing, pos, reflectDir, depth);
}
return naturalColor.add(reflectedColor);
}
pub fn GetReflectionColor(scene: Scene, thing: Thing, pos: Vector, reflectDir: Vector, depth: i32) Color {
var ray = Ray.init(pos, reflectDir);
var surface = GetSurfaceProperties(GetSurface(thing), pos);
return TraceRay(scene, ray, depth + 1).scale(surface.reflect);
}
pub fn GetNaturalColor(scene: Scene, thing: Thing, pos: Vector, norm: Vector, rd: Vector) Color {
var resultColor = Black;
var surface = GetSurfaceProperties(GetSurface(thing), pos);
var rayDirNormal = rd.norm();
var colDiffuse = surface.diffuse;
var colSpecular = surface.specular;
for (scene.lights) |light| {
var ldis = light.pos.sub(pos);
var livec = ldis.norm();
var ray = Ray.init(pos, livec);
var isect = GetClosestIntersection(scene, ray);
var isInShadow = isect != null and isect.?.dist < ldis.mag();
if (!isInShadow) {
var illum = livec.dot(norm);
var specular = livec.dot(rayDirNormal);
var lcolor = DefaultColor;
var scolor = DefaultColor;
if (illum > 0) {
lcolor = light.color.scale(illum);
}
if (specular > 0) {
scolor = light.color.scale(std.math.pow(f64, specular, surface.roughness));
}
lcolor = lcolor.mul(colDiffuse);
scolor = scolor.mul(colSpecular);
resultColor = resultColor.add(lcolor).add(scolor);
}
}
return resultColor;
}
pub fn GetPoint(camera: Camera, x: i32, y: i32, screenWidth: i32, screenHeight: i32) Vector {
var xf = @intToFloat(f64, x);
var yf = @intToFloat(f64, y);
var wf = @intToFloat(f64, screenWidth);
var hf = @intToFloat(f64, screenHeight);
var recenterX = (xf - (wf / 2.0)) / 2.0 / wf;
var recenterY = -(yf - (hf / 2.0)) / 2.0 / hf;
var vx = camera.right.scale(recenterX);
var vy = camera.up.scale(recenterY);
var v = vx.add(vy);
return camera.forward.add(v).norm();
}
pub fn Render(scene: Scene, image: Image) void {
var x: i32 = 0;
var y: i32 = 0;
while (y < image.height) {
x = 0;
while (x < image.width) {
var pt = GetPoint(scene.camera, x, y, image.width, image.height);
var ray = Ray.init(scene.camera.pos, pt);
var color = TraceRay(scene, ray, 0).toDrawingColor();
image.setColor(x, y, color);
x += 1;
}
y += 1;
}
}
pub fn main() !void {
const stdout = std.io.getStdOut().outStream();
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = &arena.allocator;
var data = allocator.alloc(RGBColor, 10);
data[0] = RGBColor.init(0,0,0);
try stdout.print("Data: {}!\n", .{ data });
// var image = Image.init(allocator, 500, 500);
// var scene = Scene.init();
// Render(scene, image);
// image.save("zig-ray.bmp");
try stdout.print("Completed, {}!\n", .{"OK"});
} | zig/src/RayTracer.zig |
const std = @import("std");
/// fixed size array wrapper that provides ArrayList-like semantics. Appending more items than fit in the
/// list ignores the item and logs a warning. Use the FixedList.len field to get the actual number of items present.
pub fn FixedList(comptime T: type, comptime len: usize) type {
return struct {
const Self = @This();
items: [len]T = undefined,
len: usize = 0,
pub const Iterator = struct {
list: Self,
index: usize = 0,
pub fn next(self: *Iterator) ?T {
if (self.index == self.list.len) return null;
var next_item = self.list.items[self.index];
self.index += 1;
return next_item;
}
};
pub fn init() Self {
return Self{ .items = [_]T{0} ** len };
}
pub fn initWithValue(comptime value: T) Self {
return Self{ .items = [_]T{value} ** len };
}
pub fn append(self: *Self, item: T) void {
if (self.len == self.items.len) {
std.debug.warn("attemped to append to a full FixedList\n", .{});
return;
}
self.items[self.len] = item;
self.len += 1;
}
pub fn clear(self: *Self) void {
self.len = 0;
}
pub fn pop(self: *Self) T {
var item = self.items[self.len - 1];
self.len -= 1;
return item;
}
pub fn contains(self: Self, value: T) bool {
return self.indexOf(value) != null;
}
pub fn indexOf(self: Self, value: T) ?usize {
var i: usize = 0;
while (i < self.len) : (i += 1) {
if (self.items[i] == value) return i;
}
return null;
}
/// Removes the element at the specified index and returns it. The empty slot is filled from the end of the list.
pub fn swapRemove(self: *Self, i: usize) T {
if (self.len - 1 == i) return self.pop();
const old_item = self.items[i];
self.items[i] = self.pop();
return old_item;
}
pub fn iter(self: Self) Iterator {
return Iterator{ .list = self };
}
};
}
test "fixed list" {
var list = FixedList(u32, 4).init();
list.append(4);
std.testing.expectEqual(list.len, 1);
list.append(46);
list.append(146);
list.append(4456);
std.testing.expectEqual(list.len, 4);
_ = list.pop();
std.testing.expectEqual(list.len, 3);
list.clear();
std.testing.expectEqual(list.len, 0);
} | src/utils/fixed_list.zig |
const u = @import("util.zig");
const std = @import("std");
const SParser = @import("SParser.zig");
const SweetParser = @import("SweetParser.zig");
const Expr = SParser.Expr;
const TextIterator = SParser.TextIterator;
pub const Type = enum { wasm, text };
pub const Any = union(Type) {
wasm: Wasm,
text: Text,
pub fn read(path: u.Txt, allocator: std.mem.Allocator) !Any {
const stdin = u.strEql("-", path);
const safepath = if (stdin) try allocator.dupe(u8, path) else try std.fs.realpathAlloc(allocator, path);
const file = if (stdin) std.io.getStdIn() else try std.fs.openFileAbsolute(safepath, .{ .read = true });
defer file.close();
const bytes = try file.readToEndAllocOptions(allocator, 1 << 48, try file.getEndPos(), @alignOf(u8), null);
_ = try file.read(bytes);
if (std.mem.startsWith(u8, bytes, &std.wasm.magic))
return Any{ .wasm = .{ .realpath = safepath, .bytes = bytes, .allocator = allocator } };
return Any{ .text = .{ .realpath = safepath, .text = try u.toTxt(bytes), .allocator = allocator } };
}
pub fn deinit(self: Any) void {
switch (self) {
.wasm => |wasm| wasm.deinit(),
.text => |text| text.deinit(),
}
}
pub inline fn realpath(self: Any) u.Txt {
return switch (self) {
.wasm => |wasm| wasm.realpath,
.text => |text| text.realpath,
};
}
};
pub const read = Any.read;
pub const Wasm = struct {
realpath: u.Txt,
bytes: u.Bin,
allocator: std.mem.Allocator,
pub fn deinit(self: Wasm) void {
self.allocator.free(self.bytes);
self.allocator.free(self.realpath);
}
};
pub const Text = struct {
realpath: u.Txt,
text: u.Txt,
allocator: std.mem.Allocator,
pub fn deinit(self: Text) void {
self.allocator.free(self.text);
self.allocator.free(self.realpath);
}
inline fn iter(self: Text) TextIterator {
return TextIterator.unsafeInit(self.text);
}
inline fn parseAs(comptime sweet: bool) fn (*TextIterator, std.mem.Allocator) SweetParser.Error!Expr.Root {
return if (comptime sweet) SweetParser.parseAll else SParser.parseAll;
}
pub fn readAs(self: Text, comptime sweet: bool) ![]Expr {
var iter_ = self.iter();
return parseAs(sweet)(&iter_, self.allocator);
}
pub inline fn read(self: Text) ![]Expr {
return self.readAs(true);
}
pub fn tryReadAs(self: Text, comptime sweet: bool) ReadResult {
var iter_ = self.iter();
const exprs = parseAs(sweet)(&iter_, self.allocator) catch |err|
return .{ .err = .{ .kind = err, .at = iter_.peek().offset, .file = &self } };
return .{ .ok = exprs };
}
pub inline fn tryRead(self: Text) ReadResult {
return self.tryReadAs(true);
}
pub inline fn linePoint(self: Text, at: usize) LinePoint {
return LinePoint.init(self.text, at, self.realpath);
}
};
pub const ErrPoint = struct {
kind: anyerror,
at: usize,
file: *const Text,
pub fn format(
self: ErrPoint,
comptime _: []const u8,
_: std.fmt.FormatOptions,
writer: anytype,
) !void {
const point = self.file.linePoint(self.at);
try writer.print("{/}{}\n{^}", .{ point, self.kind, point });
}
};
pub const ReadResult = u.Result(Expr.Root, ErrPoint);
/// Human readable text file position
pub const Position = struct {
column: usize = 1,
line: usize = 1,
};
/// Human readable text file position pointer
pub const LinePoint = struct {
path: u.Txt,
line: u.Txt,
offset: usize,
at: Position,
pub fn init(text: u.Txt, offset: usize, path: u.Txt) LinePoint {
std.debug.assert(u.isTxt(text));
var iter = TextIterator{ .cur = null, .bytes = text };
var p: Position = .{};
var last_line: usize = 0;
while (iter.next()) |cp| {
if (cp.offset >= offset)
break;
if (cp.scalar == '\n') {
last_line = cp.offset + cp.bytes.len;
p.line += 1;
p.column = 1;
} else {
p.column += 1;
}
}
const end_line = last_line + (TextIterator.indexOfCodePoint(text[last_line..], '\n') orelse text[last_line..].len);
return LinePoint{ .path = path, .line = text[last_line..end_line], .offset = offset - last_line, .at = p };
}
pub fn format(
self: LinePoint,
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
writer: anytype,
) !void {
const link = std.mem.eql(u8, fmt, "/");
const line = std.mem.eql(u8, fmt, "^");
if (!line)
try writer.print("{s}:{}:{}: ", .{ self.path, self.at.line, self.at.column });
if (!(link or line))
try writer.print("{s}\n", .{fmt});
if (!link) {
try writer.print("{s}\n", .{self.line});
var i: usize = 1;
while (i < self.at.column) : (i += 1) {
try writer.writeByte(options.fill);
}
try writer.writeAll("^");
}
}
}; | src/File.zig |
const std = @import("std");
const json = std.json;
pub const json_rpc_version = "2.0";
const default_message_size: usize = 8192;
const Allocator = std.mem.Allocator;
pub const ErrorCode = enum(i64) {
// UnknownError should be used for all non coded errors.
UnknownError = -32001,
// ParseError is used when invalid JSON was received by the server.
ParseError = -32700,
//InvalidRequest is used when the JSON sent is not a valid Request object.
InvalidRequest = -32600,
// MethodNotFound should be returned by the handler when the method does
// not exist / is not available.
MethodNotFound = -32601,
// InvalidParams should be returned by the handler when method
// parameter(s) were invalid.
InvalidParams = -32602,
// InternalError is not currently returned but defined for completeness.
InternalError = -32603,
//ServerOverloaded is returned when a message was refused due to a
//server being temporarily unable to accept any new messages.
ServerOverloaded = -32000,
};
pub fn RPCError(
comptime ResultErrorData: type,
) type {
return struct {
code: i64,
message: []const u8,
data: ?ResultErrorData,
};
}
const HdrContentLength = "Content-Length";
pub const ID = union(enum) {
Name: []const u8,
Number: i64,
};
pub fn RPCequest(
comptime ParamType: type,
) type {
return struct {
jsonrpc: []const u8 = "2.0",
method: []const u8,
params: ?ParamType = null,
id: ID,
};
}
test "Request.ecnode jsonrpc 2.0" {
var dyn = DynamicWriter.init(std.testing.allocator);
defer dyn.deinit();
var r = RPCequest(struct {}){
.method = "",
.id = .{
.Number = 0,
},
};
try json.stringify(r, .{}, dyn.writer());
const expect =
\\{"jsonrpc":"2.0","method":"","params":null,"id":0}
;
try std.testing.expectEqualStrings(expect, dyn.list.items);
// std.debug.print("\n{s}\n", .{dyn.list.items});
}
pub fn RPCResponse(
comptime ResultType: type,
comptime ResultErrorData: type,
) type {
return struct {
jsonrpc: []const u8,
result: ?ResultType,
@"error": ?RPCError(ResultErrorData),
id: ?ID,
};
}
pub fn Conn(
// Read/write types and options
comptime ReaderType: type,
comptime read_buffer_size: usize,
comptime WriterType: type,
//rpc
comptime ParamType: type,
comptime ResultType: type,
comptime ResultErrorDataType: type,
) type {
return struct {
const Self = @This();
id_sequence: std.atomic.Atomic(u64),
request_queue: Queue,
response_queue: Queue,
read_stream: ReadStream,
write_sream: WriterType,
allocator: Allocator,
pub const ReadStream = std.io.BufferedReader(read_buffer_size, ReaderType);
pub const Request = RPCequest(ParamType);
pub const Response = RPCResponse(ResultType, ResultErrorDataType);
const QueueEntry = struct {
request: Request = undefined,
response: ?Response = null,
arena: std.heap.ArenaAllocator,
fn init(a: Allocator) QueueEntry {
return QueueEntry{
.arena = std.heap.ArenaAllocator.init(a),
};
}
};
const Queue = std.atomic.Queue(QueueEntry);
pub fn init(
write_to: WriterType,
read_from: ReaderType,
) Self {
return Self{
.id_sequence = std.atomic.Atomic(u64).init(0),
.read_stream = ReadStream{
.unbuffered_reader = read_from,
},
.write_stream = write_to,
.request_queue = Queue.init(),
.response_queue = Queue.init(),
};
}
fn trimSpace(s: []const u8) []const u8 {
return std.mem.trim(u8, s, [_]u8{ ' ', '\n', '\r' });
}
fn newQueueEntry(self: *Self) !QueueEntry {
var q = try self.allocator.create(QueueEntry);
q.* = QueueEntry.init(self.allocator);
return q;
}
// readRequest reads request for the read_stream and queue decoded request.
fn readRequest(self: *Self) !void {
var r = self.read_stream.reader();
var q = try self.newQueueEntry();
errdefer {
// q is not going anywhere we need to destroy it.
q.arena.deinit();
self.allocator.destroy(q);
}
// all allocations relating to the incoming reques are tied to the
// QueueEntry and will be freed once
var alloc = q.arena.allocator();
var length: usize = 0;
while (true) {
var line = try r.readUntilDelimiterOrEofAlloc(alloc, '\n', default_message_size);
if (trimSpace(line).len == 0) {
break;
}
const colon = std.mem.indexOfScalar(u8, line, ':') orelse return error.InvalidHeader;
const name = line[0..colon];
const value = trimSpace(line[colon + 1 ..]);
if (std.mem.eql(u8, name, HdrContentLength)) {
length = try std.fmt.parseInt(usize, value, 10);
}
}
if (length == 0) {
return error.MissingContentLengthHeader;
}
const data = try alloc.alloc(u8, length);
try r.readNoEof(data);
q.request = try json.parse(Request, &json.TokenStream.init(data), json.ParseOptions{
.allocator = alloc,
.duplicate_field_behavior = .UseFirst,
.ignore_unknown_fields = true,
});
var node = self.allocator.create(Queue.Node);
node.* = Queue.Node{
.prev = undefined,
.next = undefined,
.data = q,
};
self.request_queue.put(node);
}
fn handleResponse(self: *Self, node: *Queue.Node) !void {
self.response_queue.put(node);
}
fn respond(self: *Self, node: *Queue.Node) !void {
defer {
node.data.arena.deinit();
self.allocator.destroy(node);
}
try self.writeResponse(node.data);
}
fn writeResponse(self: *Self, q: *QueueEntry) !void {
if (self.response) |response| {
var w = DynamicWriter.init(q.arena.allocator());
try json.stringify(response, .{}, w.writer());
try self.write_sream.print("{}: {}\r\n\r\n", .{
HdrContentLength, w.list.items.len,
});
try self.write_sream.write(w.list.items);
}
}
};
}
const DynamicWriter = struct {
list: std.ArrayList(u8),
fn init(a: Allocator) DynamicWriter {
return .{ .list = std.ArrayList(u8).init(a) };
}
fn deinit(self: *DynamicWriter) void {
self.list.deinit();
}
const Writer = std.io.Writer(*DynamicWriter, Allocator.Error, write);
fn write(self: *DynamicWriter, bytes: []const u8) Allocator.Error!usize {
try self.list.appendSlice(bytes);
return bytes.len;
}
fn writer(self: *DynamicWriter) Writer {
return .{ .context = self };
}
}; | src/jsonrpc2.zig |
//--------------------------------------------------------------------------------
// Section: Types (3)
//--------------------------------------------------------------------------------
pub const OVERLAPPED = extern struct {
Internal: usize,
InternalHigh: usize,
Anonymous: extern union {
Anonymous: extern struct {
Offset: u32,
OffsetHigh: u32,
},
Pointer: ?*anyopaque,
},
hEvent: ?HANDLE,
};
pub const OVERLAPPED_ENTRY = extern struct {
lpCompletionKey: usize,
lpOverlapped: ?*OVERLAPPED,
Internal: usize,
dwNumberOfBytesTransferred: u32,
};
pub const LPOVERLAPPED_COMPLETION_ROUTINE = fn(
dwErrorCode: u32,
dwNumberOfBytesTransfered: u32,
lpOverlapped: ?*OVERLAPPED,
) callconv(@import("std").os.windows.WINAPI) void;
//--------------------------------------------------------------------------------
// Section: Functions (11)
//--------------------------------------------------------------------------------
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn CreateIoCompletionPort(
FileHandle: ?HANDLE,
ExistingCompletionPort: ?HANDLE,
CompletionKey: usize,
NumberOfConcurrentThreads: u32,
) callconv(@import("std").os.windows.WINAPI) ?HANDLE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn GetQueuedCompletionStatus(
CompletionPort: ?HANDLE,
lpNumberOfBytesTransferred: ?*u32,
lpCompletionKey: ?*usize,
lpOverlapped: ?*?*OVERLAPPED,
dwMilliseconds: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "KERNEL32" fn GetQueuedCompletionStatusEx(
CompletionPort: ?HANDLE,
lpCompletionPortEntries: [*]OVERLAPPED_ENTRY,
ulCount: u32,
ulNumEntriesRemoved: ?*u32,
dwMilliseconds: u32,
fAlertable: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn PostQueuedCompletionStatus(
CompletionPort: ?HANDLE,
dwNumberOfBytesTransferred: u32,
dwCompletionKey: usize,
lpOverlapped: ?*OVERLAPPED,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn DeviceIoControl(
hDevice: ?HANDLE,
dwIoControlCode: u32,
// TODO: what to do with BytesParamIndex 3?
lpInBuffer: ?*anyopaque,
nInBufferSize: u32,
// TODO: what to do with BytesParamIndex 5?
lpOutBuffer: ?*anyopaque,
nOutBufferSize: u32,
lpBytesReturned: ?*u32,
lpOverlapped: ?*OVERLAPPED,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn GetOverlappedResult(
hFile: ?HANDLE,
lpOverlapped: ?*OVERLAPPED,
lpNumberOfBytesTransferred: ?*u32,
bWait: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "KERNEL32" fn CancelIoEx(
hFile: ?HANDLE,
lpOverlapped: ?*OVERLAPPED,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn CancelIo(
hFile: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "KERNEL32" fn GetOverlappedResultEx(
hFile: ?HANDLE,
lpOverlapped: ?*OVERLAPPED,
lpNumberOfBytesTransferred: ?*u32,
dwMilliseconds: u32,
bAlertable: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "KERNEL32" fn CancelSynchronousIo(
hThread: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn BindIoCompletionCallback(
FileHandle: ?HANDLE,
Function: ?LPOVERLAPPED_COMPLETION_ROUTINE,
Flags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
//--------------------------------------------------------------------------------
// 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 (2)
//--------------------------------------------------------------------------------
const BOOL = @import("../foundation.zig").BOOL;
const HANDLE = @import("../foundation.zig").HANDLE;
test {
// The following '_ = <FuncPtrType>' lines are a workaround for https://github.com/ziglang/zig/issues/4476
if (@hasDecl(@This(), "LPOVERLAPPED_COMPLETION_ROUTINE")) { _ = LPOVERLAPPED_COMPLETION_ROUTINE; }
@setEvalBranchQuota(
@import("std").meta.declarations(@This()).len * 3
);
// reference all the pub declarations
if (!@import("builtin").is_test) return;
inline for (@import("std").meta.declarations(@This())) |decl| {
if (decl.is_pub) {
_ = decl;
}
}
} | win32/system/io.zig |
const std = @import("std");
pub const RegionHeader = struct {
name: []const u8,
ip: []const u8,
server_count: u8
};
pub const ServerInfo = struct {
name: []const u8,
ip: []const u8,
port: u16
};
fn ipTou32(ip: []const u8) !u32 {
var components: [4]u8 = undefined;
var split = std.mem.split(ip, ".");
var i: usize = 0;
while (split.next()) |num| {
components[i] = try std.fmt.parseInt(u8, num, 10);
i += 1;
}
return std.mem.bytesAsSlice(u32, &components)[0];
}
pub fn RegionFileReader(comptime ReaderType: type) type {
return struct {
const Self = @This();
reader: ReaderType,
pub fn init(reader: ReaderType) Self {
return Self{
.reader = reader
};
}
/// Caller must free returned memory.
pub fn readString(self: Self, allocator: *std.mem.Allocator) ![]const u8 {
var string = try allocator.alloc(u8, try self.reader.readInt(u8, std.builtin.Endian.Little));
_ = try self.reader.read(string);
return string;
}
/// Caller must free returned memory with `freeHeader`.
pub fn readHeader(self: Self, allocator: *std.mem.Allocator) !RegionHeader {
var i: usize = 0;
while (i < 4) : (i += 1) _ = try self.reader.readByte();
var name = try self.readString(allocator);
var ip = try self.readString(allocator);
var server_count = try self.reader.readInt(u8, std.builtin.Endian.Little);
i = 0;
while (i < 3) : (i += 1) _ = try self.reader.readByte();
return RegionHeader{
.name = name,
.ip = ip,
.server_count = server_count
};
}
pub fn freeHeader(self: Self, allocator: *std.mem.Allocator, header: RegionHeader) void {
allocator.free(header.ip);
allocator.free(header.name);
}
/// Caller must free returned memory with `freeServerInfo`.
pub fn readServerInfo(self: Self, allocator: *std.mem.Allocator) !ServerInfo {
var name = try self.readString(allocator);
var ip = try self.reader.readInt(u32, std.builtin.Endian.Little);
var port = try self.reader.readInt(u16, std.builtin.Endian.Little);
var i: usize = 0;
while (i < 4) : (i += 1) _ = try self.reader.readByte();
var components = std.mem.sliceAsBytes(&[1]u32{ip});
return ServerInfo{
.name = name,
.ip = try std.fmt.allocPrint(allocator, "{}.{}.{}.{}", .{components[0], components[1], components[2], components[3]}),
.port = port
};
}
pub fn freeServerInfo(self: Self, allocator: *std.mem.Allocator, info: ServerInfo) void {
allocator.free(info.name);
allocator.free(info.ip);
}
};
}
pub fn RegionFileWriter(comptime WriterType: type) type {
return struct {
const Self = @This();
writer: WriterType,
pub fn init(writer: WriterType) Self {
return Self{
.writer = writer
};
}
pub fn writeString(self: Self, string: []const u8) !void {
try self.writer.writeInt(u8, @intCast(u8, string.len), std.builtin.Endian.Little);
_ = try self.writer.write(string);
}
pub fn writeHeader(self: Self, header: RegionHeader) !void {
var i: usize = 0;
while (i < 4) : (i += 1) _ = try self.writer.writeByte(0);
try self.writeString(header.name);
try self.writeString(header.ip);
try self.writer.writeInt(u8, header.server_count, std.builtin.Endian.Little);
i = 0;
while (i < 3) : (i += 1) _ = try self.writer.writeByte(0);
}
pub fn writeServerInfo(self: Self, header: ServerInfo) !void {
try self.writeString(header.name);
_ = try self.writer.writeInt(u32, try ipTou32(header.ip), std.builtin.Endian.Little);
_ = try self.writer.writeInt(u16, header.port, std.builtin.Endian.Little);
var i: usize = 0;
while (i < 4) : (i += 1) _ = try self.writer.writeByte(0);
}
};
}
test "Read/Write Region Data File" {
const allocator = std.testing.allocator;
const test_in = @embedFile("test.dat");
var test_out: [test_in.len]u8 = undefined;
var test_reader = std.io.fixedBufferStream(test_in).reader();
var region_reader = RegionFileReader(@TypeOf(test_reader)).init(test_reader);
var test_writer = std.io.fixedBufferStream(&test_out).writer();
var region_writer = RegionFileWriter(@TypeOf(test_writer)).init(test_writer);
var header = try region_reader.readHeader(allocator);
defer region_reader.freeHeader(allocator, header);
try region_writer.writeHeader(header);
var index: usize = 0;
while (index < header.server_count) : (index += 1) {
var info = try region_reader.readServerInfo(allocator);
try region_writer.writeServerInfo(info);
region_reader.freeServerInfo(allocator, info);
}
std.testing.expectEqualSlices(u8, test_in, &test_out);
} | src/region.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const input = @embedFile("../input/day16.txt");
const Rule = struct {
name: []const u8,
min1: u32,
max1: u32,
min2: u32,
max2: u32,
pos: ?usize = null,
pub fn init(string: []const u8) Rule {
var s = std.mem.split(string, ":");
const name = s.next().?;
var t = std.mem.tokenize(s.next().?, " - or");
return Rule{
.name = name,
.min1 = std.fmt.parseUnsigned(u32, t.next().?, 10) catch unreachable,
.max1 = std.fmt.parseUnsigned(u32, t.next().?, 10) catch unreachable,
.min2 = std.fmt.parseUnsigned(u32, t.next().?, 10) catch unreachable,
.max2 = std.fmt.parseUnsigned(u32, t.next().?, 10) catch unreachable,
};
}
pub fn inRange(self: Rule, value: u32) bool {
return (self.min1 <= value and value <= self.max1) or (self.min2 <= value and value <= self.max2);
}
};
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
var allocator = &gpa.allocator;
var blocks = std.mem.split(input, "\n\n");
const rule_block = blocks.next().?;
const my_ticket_block = blocks.next().?;
const tickets_block = blocks.next().?;
var rules: [20]Rule = undefined;
var lines = std.mem.tokenize(rule_block, "\n");
var i: usize = 0;
while (lines.next()) |line| : (i += 1) {
rules[i] = Rule.init(line);
}
var my_ticket: [20]u32 = undefined;
lines = std.mem.tokenize(my_ticket_block, "\n");
_ = lines.next();
if (lines.next()) |line| {
var token = std.mem.tokenize(line, ",");
i = 0;
while (token.next()) |t| : (i += 1) {
my_ticket[i] = try std.fmt.parseUnsigned(u32, t, 10);
}
assert(i == my_ticket.len);
}
var error_rate: u32 = 0;
var tickets = std.ArrayList([20]u32).init(allocator);
defer tickets.deinit();
lines = std.mem.tokenize(tickets_block, "\n");
_ = lines.next();
while (lines.next()) |line| {
var other_ticket: [20]u32 = undefined;
var token = std.mem.tokenize(line, ",");
i = 0;
const ticket_valid = while (token.next()) |t| : (i += 1) {
other_ticket[i] = try std.fmt.parseUnsigned(u32, t, 10);
var valid = false;
for (rules) |rule| {
if (rule.inRange(other_ticket[i])) {
valid = true;
break;
}
}
if (!valid) {
error_rate += other_ticket[i];
break false;
}
} else true;
if (ticket_valid) try tickets.append(other_ticket);
}
print("part1: {}\n", .{error_rate});
var found = [_]bool{false}**20;
var done: bool = false;
while (!done) {
done = true;
for (rules) |*rule, rule_pos| {
if (rule.pos != null) continue;
var valid_count: usize = 0;
var valid_pos: usize = 0;
for (found) |f, pos| {
if (f) continue;
const all_valid = for (tickets.items) |ticket| {
if (!rule.inRange(ticket[pos])) break false;
} else true;
if (all_valid) {
valid_pos = pos;
valid_count += 1;
}
}
if (valid_count == 1) { // just one candidate
rule.pos = valid_pos;
found[valid_pos] = true;
print("found rule{} pos {}\n", .{rule_pos, valid_pos});
} else {
done = false;
}
}
print("next\n", .{});
}
var part2: u64 = 1;
for (rules[0..6]) |rule| {
part2 *= my_ticket[rule.pos.?];
}
print("part2: {}\n", .{part2});
} | src/day16.zig |
const std = @import("std");
const parser = @import("common.zig");
const debug = std.debug;
const math = std.math;
const mem = std.mem;
const fmt = std.fmt;
const testing = std.testing;
const ParseResult = parser.ParseResult;
pub const Input = struct {
str: []const u8,
pub fn init(str: []const u8) Input {
return Input{ .str = str };
}
pub fn curr(input: Input) ?u8 {
if (input.str.len != 0)
return input.str[0];
return null;
}
pub fn next(input: Input) Input {
return Input{ .str = if (input.str.len != 0) input.str[1..] else input.str };
}
};
pub fn char(comptime c1: u8) type {
return parser.eatIf(u8, struct {
fn predicate(c2: u8) bool {
return c1 == c2;
}
}.predicate);
}
pub fn range(comptime a: u8, comptime b: u8) type {
return parser.eatIf(u8, struct {
fn predicate(c: u8) bool {
return a <= c and c <= b;
}
}.predicate);
}
pub fn uint(comptime Int: type, comptime base: u8) type {
return struct {
pub const Result = Int;
pub fn parse(input: var) ?ParseResult(@TypeOf(input), Result) {
const first = input.curr() orelse return null;
const first_digit = fmt.charToDigit(first, base) catch return null;
var res = math.cast(Result, first_digit) catch return null;
var next = input.next();
while (next.curr()) |curr| : (next = next.next()) {
const digit = fmt.charToDigit(curr, base) catch break;
res = math.mul(Result, res, base) catch return null;
res = math.add(Result, res, digit) catch return null;
}
return ParseResult(@TypeOf(input), Result){
.input = next,
.result = res,
};
}
};
}
pub fn string(comptime s: []const u8) type {
return struct {
pub const Result = []const u8;
pub fn parse(input: var) ?ParseResult(@TypeOf(input), Result) {
var next = input;
for (s) |c| {
const curr = next.curr() orelse return null;
if (c != curr)
return null;
next = next.next();
}
return ParseResult(@TypeOf(input), Result){
.input = next,
.result = s,
};
}
};
}
fn testSuccess(comptime P: type, str: []const u8, result: var) void {
const res = P.parse(Input.init(str)) orelse unreachable;
testing.expectEqual(res.input.str.len, 0);
comptime testing.expectEqual(@sizeOf(P.Result), @sizeOf(@TypeOf(result)));
if (@sizeOf(P.Result) != 0)
testing.expectEqualSlices(u8, &mem.toBytes(result), &mem.toBytes(res.result));
}
fn testFail(comptime P: type, str: []const u8) void {
if (P.parse(Input.init(str))) |res| {
testing.expect(res.input.str.len != 0);
}
}
test "parser.string.char" {
const P = char('a');
comptime var i = 0;
inline while (i < 'a') : (i += 1)
testFail(P, &[_]u8{i});
inline while (i <= 'a') : (i += 1)
testSuccess(P, &[_]u8{i}, @as(u8, i));
inline while (i <= math.maxInt(u8)) : (i += 1)
testFail(P, &[_]u8{i});
}
test "parser.string.range" {
const P = range('a', 'z');
comptime var i = 0;
inline while (i < 'a') : (i += 1)
testFail(P, &[_]u8{i});
inline while (i <= 'z') : (i += 1)
testSuccess(P, &[_]u8{i}, @as(u8, i));
inline while (i <= math.maxInt(u8)) : (i += 1)
testFail(P, &[_]u8{i});
}
test "parser.string.uint" {
for ([_][]const u8{
"0000", "1111", "7777", "9999",
"aaaa", "AAAA", "ffff", "FFFF",
"zzzz", "ZZZZ", "0123", "4567",
"89AB", "CDEF", "GHIJ", "KLMN",
"OPQR", "STUV", "WYZa", "bcde",
"fghi", "jklm", "nopq", "rstu",
"bwyz",
}) |str| {
comptime var base = 1;
inline while (base <= 36) : (base += 1) {
const P = uint(u64, base);
if (fmt.parseUnsigned(u64, str, base)) |res| {
testSuccess(P, str, res);
} else |err| {
testFail(P, str);
}
}
}
}
test "parser.string.string" {
const s: []const u8 = "1234";
const P = string(s);
testSuccess(P, s, s);
testFail(P, "1235");
} | src/parser/string.zig |
const Self = @This();
const std = @import("std");
const math = std.math;
const wlr = @import("wlroots");
const wl = @import("wayland").server.wl;
const server = &@import("main.zig").server;
const Box = @import("Box.zig");
const View = @import("View.zig");
const ViewStack = @import("view_stack.zig").ViewStack;
const XdgPopup = @import("XdgPopup.zig");
/// The view this xwayland view implements
view: *View,
/// The corresponding wlroots object
xwayland_surface: *wlr.XwaylandSurface,
// Listeners that are always active over the view's lifetime
destroy: wl.Listener(*wlr.XwaylandSurface) = wl.Listener(*wlr.XwaylandSurface).init(handleDestroy),
map: wl.Listener(*wlr.XwaylandSurface) = wl.Listener(*wlr.XwaylandSurface).init(handleMap),
unmap: wl.Listener(*wlr.XwaylandSurface) = wl.Listener(*wlr.XwaylandSurface).init(handleUnmap),
request_configure: wl.Listener(*wlr.XwaylandSurface.event.Configure) =
wl.Listener(*wlr.XwaylandSurface.event.Configure).init(handleRequestConfigure),
// Listeners that are only active while the view is mapped
commit: wl.Listener(*wlr.Surface) = wl.Listener(*wlr.Surface).init(handleCommit),
set_title: wl.Listener(*wlr.XwaylandSurface) = wl.Listener(*wlr.XwaylandSurface).init(handleSetTitle),
set_class: wl.Listener(*wlr.XwaylandSurface) = wl.Listener(*wlr.XwaylandSurface).init(handleSetClass),
request_fullscreen: wl.Listener(*wlr.XwaylandSurface) =
wl.Listener(*wlr.XwaylandSurface).init(handleRequestFullscreen),
pub fn init(self: *Self, view: *View, xwayland_surface: *wlr.XwaylandSurface) void {
self.* = .{ .view = view, .xwayland_surface = xwayland_surface };
xwayland_surface.data = @ptrToInt(self);
// Add listeners that are active over the view's entire lifetime
xwayland_surface.events.destroy.add(&self.destroy);
xwayland_surface.events.map.add(&self.map);
xwayland_surface.events.unmap.add(&self.unmap);
xwayland_surface.events.request_configure.add(&self.request_configure);
}
pub fn needsConfigure(self: Self) bool {
const output = self.view.output;
const output_box = server.root.output_layout.getBox(output.wlr_output).?;
return self.xwayland_surface.x != self.view.pending.box.x + output_box.x or
self.xwayland_surface.y != self.view.pending.box.y + output_box.y or
self.xwayland_surface.width != self.view.pending.box.width or
self.xwayland_surface.height != self.view.pending.box.height;
}
/// Apply pending state. Note: we don't set View.serial as
/// shouldTrackConfigure() is always false for xwayland views.
pub fn configure(self: Self) void {
const output = self.view.output;
const output_box = server.root.output_layout.getBox(output.wlr_output).?;
const state = &self.view.pending;
self.xwayland_surface.configure(
@intCast(i16, state.box.x + output_box.x),
@intCast(i16, state.box.y + output_box.y),
@intCast(u16, state.box.width),
@intCast(u16, state.box.height),
);
}
/// Close the view. This will lead to the unmap and destroy events being sent
pub fn close(self: Self) void {
self.xwayland_surface.close();
}
pub fn setActivated(self: Self, activated: bool) void {
self.xwayland_surface.activate(activated);
}
pub fn setFullscreen(self: Self, fullscreen: bool) void {
self.xwayland_surface.setFullscreen(fullscreen);
}
/// Return the surface at output coordinates ox, oy and set sx, sy to the
/// corresponding surface-relative coordinates, if there is a surface.
pub fn surfaceAt(self: Self, ox: f64, oy: f64, sx: *f64, sy: *f64) ?*wlr.Surface {
return self.xwayland_surface.surface.?.surfaceAt(
ox - @intToFloat(f64, self.view.current.box.x),
oy - @intToFloat(f64, self.view.current.box.y),
sx,
sy,
);
}
/// Get the current title of the xwayland surface if any.
pub fn getTitle(self: Self) ?[*:0]const u8 {
return self.xwayland_surface.title;
}
/// X11 clients don't have an app_id but the class serves a similar role.
/// Get the current class of the xwayland surface if any.
pub fn getAppId(self: Self) ?[*:0]const u8 {
return self.xwayland_surface.class;
}
/// Return bounds on the dimensions of the view
pub fn getConstraints(self: Self) View.Constraints {
const hints = self.xwayland_surface.size_hints orelse return .{
.min_width = View.min_size,
.min_height = View.min_size,
.max_width = math.maxInt(u32),
.max_height = math.maxInt(u32),
};
return .{
.min_width = @intCast(u32, math.max(hints.min_width, View.min_size)),
.min_height = @intCast(u32, math.max(hints.min_height, View.min_size)),
.max_width = if (hints.max_width > 0)
math.max(@intCast(u32, hints.max_width), View.min_size)
else
math.maxInt(u32),
.max_height = if (hints.max_height > 0)
math.max(@intCast(u32, hints.max_height), View.min_size)
else
math.maxInt(u32),
};
}
/// Called when the xwayland surface is destroyed
fn handleDestroy(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wlr.XwaylandSurface) void {
const self = @fieldParentPtr(Self, "destroy", listener);
// Remove listeners that are active for the entire lifetime of the view
self.destroy.link.remove();
self.map.link.remove();
self.unmap.link.remove();
self.request_configure.link.remove();
self.view.destroy();
}
/// Called when the xwayland surface is mapped, or ready to display on-screen.
fn handleMap(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wlr.XwaylandSurface) void {
const self = @fieldParentPtr(Self, "map", listener);
const view = self.view;
// Add listeners that are only active while mapped
const surface = xwayland_surface.surface.?;
surface.events.commit.add(&self.commit);
xwayland_surface.events.set_title.add(&self.set_title);
xwayland_surface.events.set_class.add(&self.set_class);
xwayland_surface.events.request_fullscreen.add(&self.request_fullscreen);
view.surface = surface;
self.view.surface_box = .{
.x = 0,
.y = 0,
.width = @intCast(u32, surface.current.width),
.height = @intCast(u32, surface.current.height),
};
// Use the view's "natural" size centered on the output as the default
// floating dimensions
view.float_box.width = self.xwayland_surface.width;
view.float_box.height = self.xwayland_surface.height;
view.float_box.x = math.max(0, @divTrunc(@intCast(i32, view.output.usable_box.width) -
@intCast(i32, view.float_box.width), 2));
view.float_box.y = math.max(0, @divTrunc(@intCast(i32, view.output.usable_box.height) -
@intCast(i32, view.float_box.height), 2));
const has_fixed_size = if (self.xwayland_surface.size_hints) |size_hints|
size_hints.min_width != 0 and size_hints.min_height != 0 and
(size_hints.min_width == size_hints.max_width or size_hints.min_height == size_hints.max_height)
else
false;
if (self.xwayland_surface.parent != null or has_fixed_size) {
// If the toplevel has a parent or has a fixed size make it float
view.current.float = true;
view.pending.float = true;
view.pending.box = view.float_box;
} else if (server.config.shouldFloat(view)) {
view.current.float = true;
view.pending.float = true;
view.pending.box = view.float_box;
}
view.map() catch {
std.log.crit("out of memory", .{});
surface.resource.getClient().postNoMemory();
};
}
/// Called when the surface is unmapped and will no longer be displayed.
fn handleUnmap(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wlr.XwaylandSurface) void {
const self = @fieldParentPtr(Self, "unmap", listener);
// Remove listeners that are only active while mapped
self.commit.link.remove();
self.set_title.link.remove();
self.set_class.link.remove();
self.request_fullscreen.link.remove();
self.view.unmap();
}
fn handleRequestConfigure(
listener: *wl.Listener(*wlr.XwaylandSurface.event.Configure),
event: *wlr.XwaylandSurface.event.Configure,
) void {
const self = @fieldParentPtr(Self, "request_configure", listener);
// If unmapped, let the client do whatever it wants
if (self.view.surface == null) {
self.xwayland_surface.configure(event.x, event.y, event.width, event.height);
return;
}
// Allow xwayland views to set their own dimensions (but not position) if floating
if (self.view.pending.float) {
self.view.pending.box.width = event.width;
self.view.pending.box.height = event.height;
}
self.configure();
}
fn handleCommit(listener: *wl.Listener(*wlr.Surface), surface: *wlr.Surface) void {
const self = @fieldParentPtr(Self, "commit", listener);
self.view.output.damage.addWhole();
self.view.surface_box = .{
.x = 0,
.y = 0,
.width = @intCast(u32, surface.current.width),
.height = @intCast(u32, surface.current.height),
};
}
fn handleSetTitle(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wlr.XwaylandSurface) void {
const self = @fieldParentPtr(Self, "set_title", listener);
self.view.notifyTitle();
}
fn handleSetClass(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wlr.XwaylandSurface) void {
const self = @fieldParentPtr(Self, "set_class", listener);
self.view.notifyAppId();
}
fn handleRequestFullscreen(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wlr.XwaylandSurface) void {
const self = @fieldParentPtr(Self, "request_fullscreen", listener);
self.view.pending.fullscreen = xwayland_surface.fullscreen;
self.view.applyPending();
} | source/river-0.1.0/river/XwaylandView.zig |
const std = @import("std");
const Arena = std.heap.ArenaAllocator;
const panic = std.debug.panic;
const assert = std.debug.assert;
const expect = std.testing.expect;
const expectEqual = std.testing.expectEqual;
const expectEqualStrings = std.testing.expectEqualStrings;
const expectEqualSlices = std.testing.expectEqualSlices;
const List = @import("list.zig").List;
pub fn typeid(comptime _: type) usize {
const S = struct {
var N: usize = 0;
};
return @ptrToInt(&S.N);
}
pub fn Component(comptime T: type) type {
const initial_capacity = 1024;
const Data = List(T, .{ .initial_capacity = initial_capacity });
const Inverse = List(u64, .{ .initial_capacity = initial_capacity });
return struct {
lookup: std.AutoHashMap(u64, u64),
data: Data,
inverse: Inverse,
const Self = @This();
fn init(arena: *Arena) Self {
const allocator = arena.allocator();
return Self{
.lookup = std.AutoHashMap(u64, u64).init(allocator),
.data = Data.init(allocator),
.inverse = Inverse.init(allocator),
};
}
fn set(self: *Self, entity: Entity, value: T) !void {
const result = try self.lookup.getOrPut(entity.uuid);
if (result.found_existing) {
self.data.items[result.value_ptr.*] = value;
} else {
result.value_ptr.* = self.data.len;
try self.data.append(value);
try self.inverse.append(entity.uuid);
}
}
fn get(self: Self, entity: Entity) T {
return self.data.slice()[self.lookup.get(entity.uuid).?];
}
fn has(self: Self, entity: Entity) ?T {
if (self.lookup.get(entity.uuid)) |index| {
return self.data.slice()[index];
}
return null;
}
fn contains(self: Self, entity: Entity) bool {
return self.lookup.contains(entity.uuid);
}
fn getPtr(self: *Self, entity: Entity) *T {
return &self.data.mutSlice()[self.lookup.get(entity.uuid).?];
}
};
}
const TypeInfo = std.builtin.TypeInfo;
const StructField = TypeInfo.StructField;
pub fn IteratorComponents(components: anytype) type {
const components_type_info = @typeInfo(@TypeOf(components)).Struct;
const components_fields = components_type_info.fields;
comptime var data_fields: [components_fields.len]StructField = undefined;
inline for (components_type_info.fields) |field, i| {
const T = @field(components, field.name);
data_fields[i] = .{
.name = @typeName(T),
.field_type = *Component(T),
.default_value = null,
.is_comptime = false,
.alignment = 8,
};
}
return @Type(.{ .Struct = .{
.layout = .Auto,
.fields = &data_fields,
.decls = &.{},
.is_tuple = false,
} });
}
fn Iterator(components: anytype) type {
const IteratorComponentsT = IteratorComponents(components);
const type_info = @typeInfo(@TypeOf(components)).Struct;
const fields = type_info.fields;
return struct {
iterator_components: IteratorComponentsT,
inverse: []const u64,
ecs: *ECS,
const Self = @This();
fn init(ecs: *ECS) Self {
var iterator_components: IteratorComponentsT = undefined;
inline for (fields) |field| {
const T = @field(components, field.name);
const component = ecs.components.get(typeid(T)).?;
@field(iterator_components, @typeName(T)) = @intToPtr(*Component(T), component);
}
const T = components[0];
const inverse = @intToPtr(*Component(T), ecs.components.get(typeid(T)).?).inverse.slice();
return .{
.iterator_components = iterator_components,
.inverse = inverse,
.ecs = ecs,
};
}
pub fn next(self: *Self) ?Entity {
while (self.inverse.len > 0) {
const uuid = self.inverse[0];
var matches = true;
inline for (fields[1..]) |field| {
const T = @field(components, field.name);
const component = @field(self.iterator_components, @typeName(T));
if (!component.lookup.contains(uuid)) matches = false;
}
self.inverse = self.inverse[1..];
if (matches) return Entity{ .uuid = uuid, .ecs = self.ecs };
}
return null;
}
};
}
pub const ECS = struct {
components: std.AutoHashMap(u64, u64),
resources: std.AutoHashMap(u64, u64),
next_uuid: u64,
arena: *Arena,
pub fn init(arena: *Arena) ECS {
const allocator = arena.allocator();
return ECS{
.components = std.AutoHashMap(u64, u64).init(allocator),
.resources = std.AutoHashMap(u64, u64).init(allocator),
.next_uuid = 0,
.arena = arena,
};
}
pub fn createEntity(self: *ECS, components: anytype) !Entity {
const uuid = self.next_uuid;
self.next_uuid += 1;
const entity = Entity{
.uuid = uuid,
.ecs = self,
};
return try entity.set(components);
}
pub fn set(self: *ECS, resources: anytype) !void {
const type_info = @typeInfo(@TypeOf(resources)).Struct;
assert(type_info.is_tuple);
inline for (type_info.fields) |field| {
const T = field.field_type;
const result = try self.resources.getOrPut(typeid(T));
if (result.found_existing) {
const resource = @intToPtr(*T, result.value_ptr.*);
resource.* = @field(resources, field.name);
} else {
const resource = try self.arena.allocator().create(T);
resource.* = @field(resources, field.name);
result.value_ptr.* = @ptrToInt(resource);
}
}
}
pub fn get(self: ECS, comptime T: type) T {
return @intToPtr(*T, self.resources.get(typeid(T)).?).*;
}
pub fn getPtr(self: ECS, comptime T: type) *T {
return @intToPtr(*T, self.resources.get(typeid(T)).?);
}
pub fn contains(self: ECS, comptime T: type) bool {
return self.resources.contains(typeid(T));
}
pub fn query(self: *ECS, components: anytype) Iterator(components) {
return Iterator(components).init(self);
}
};
pub const Entity = struct {
uuid: u64,
ecs: *ECS,
pub fn set(self: Entity, components: anytype) !Entity {
const type_info = @typeInfo(@TypeOf(components)).Struct;
assert(type_info.is_tuple);
inline for (type_info.fields) |field| {
const T = field.field_type;
const result = try self.ecs.components.getOrPut(typeid(T));
if (result.found_existing) {
const component = @intToPtr(*Component(T), result.value_ptr.*);
try component.*.set(self, @field(components, field.name));
} else {
const component = try self.ecs.arena.allocator().create(Component(T));
component.* = Component(T).init(self.ecs.arena);
try component.*.set(self, @field(components, field.name));
result.value_ptr.* = @ptrToInt(component);
}
}
return self;
}
pub fn get(self: Entity, comptime T: type) T {
const component = self.ecs.components.get(typeid(T)).?;
return @intToPtr(*Component(T), component).get(self);
}
pub fn has(self: Entity, comptime T: type) ?T {
if (self.ecs.components.get(typeid(T))) |component| {
return @intToPtr(*Component(T), component).has(self);
}
return null;
}
pub fn contains(self: Entity, comptime T: type) bool {
if (self.ecs.components.get(typeid(T))) |component| {
return @intToPtr(*Component(T), component).contains(self);
}
return false;
}
pub fn getPtr(self: Entity, comptime T: type) *T {
const component = self.ecs.components.get(typeid(T)).?;
return @intToPtr(*Component(T), component).getPtr(self);
}
}; | src/ecs.zig |
const std = @import("std");
const log = std.log.scoped(.@"brucelib.audio.wav");
const SoundBuffer = @import("common.zig").SoundBuffer;
const Format = enum {
unsigned8,
signed16,
signed24,
signed32,
};
/// Caller is responsible for freeing memory allocated for returned samples buffer
pub fn readFromBytes(allocator: std.mem.Allocator, bytes: []const u8) !SoundBuffer {
var reader = std.io.fixedBufferStream(bytes).reader();
return read(allocator, reader);
}
/// Caller is responsible for freeing memory allocated for returned samples buffer
pub fn read(allocator: std.mem.Allocator, reader: anytype) !SoundBuffer {
try readExpectedQuad(reader, .{ 'R', 'I', 'F', 'F' });
try reader.skipBytes(4, .{});
try readExpectedQuad(reader, .{ 'W', 'A', 'V', 'E' });
var format: Format = undefined;
var channels: u16 = undefined;
var sample_rate: u32 = undefined;
var byte_rate: u32 = undefined;
var block_align: u16 = undefined;
var bits_per_sample: u16 = undefined;
var bytes_per_sample: u16 = undefined;
var samples: []f32 = undefined;
var read_fmt = false;
var read_data = false;
while (read_fmt == false or read_data == false) {
const block_id = try readQuad(reader);
const block_size = try reader.readIntLittle(u32);
if (std.mem.eql(u8, block_id[0..], "fmt ")) {
if (read_fmt) return error.UnexpectedFormat;
format = @intToEnum(Format, try reader.readIntLittle(u16));
channels = try reader.readIntLittle(u16);
if (channels == 0) return error.UnexpectedFormat;
sample_rate = try reader.readIntLittle(u32);
if (sample_rate == 0) return error.UnexpectedFormat;
byte_rate = try reader.readIntLittle(u32);
if (byte_rate == 0) return error.UnexpectedFormat;
block_align = try reader.readIntLittle(u16);
if (block_align == 0) return error.UnexpectedFormat;
bits_per_sample = try reader.readIntLittle(u16);
if (bits_per_sample == 0) return error.UnexpectedFormat;
// skip any trailing fmt block bytes
if (block_size > 16) {
try reader.skipBytes(block_size - 16, .{});
}
bytes_per_sample = switch (format) {
.unsigned8 => 1,
.signed16 => 2,
.signed24 => 3,
.signed32 => 4,
};
if (byte_rate != @intCast(u32, sample_rate) * channels * bytes_per_sample) {
return error.InvalidByteRate;
}
if (block_align != channels * bytes_per_sample) {
return error.InvalidBlockAlign;
}
// skip any trailing fmt block bytes
if (block_size > 16) {
try reader.skipBytes(block_size - 16, .{});
}
read_fmt = true;
} else if (std.mem.eql(u8, block_id[0..], "data")) {
if (read_data) return error.UnexpectedFormat;
if (block_size % (channels * bytes_per_sample) != 0) {
return error.InvalidDataSize;
}
const num_samples = block_size / bytes_per_sample;
samples = try allocator.alloc(f32, num_samples);
errdefer allocator.free(samples);
const recip_conv_factor = @intToFloat(f32, std.math.pow(u32, 2, bits_per_sample - 1) - 1);
switch (format) {
.unsigned8 => for (samples) |*sample| {
const max = std.math.pow(i16, 2, @intCast(i16, bits_per_sample - 1));
const int = @intCast(i16, try reader.readIntLittle(u8)) - max;
sample.* = @intToFloat(f32, int) / recip_conv_factor;
},
.signed16 => for (samples) |*sample| {
const int = try reader.readIntLittle(i16);
sample.* = @intToFloat(f32, int) / recip_conv_factor;
},
.signed24 => for (samples) |*sample| {
const int = try reader.readIntLittle(i24);
sample.* = @intToFloat(f32, int) / recip_conv_factor;
},
.signed32 => for (samples) |*sample| {
const int = try reader.readIntLittle(i32);
sample.* = @intToFloat(f32, int) / recip_conv_factor;
},
}
read_data = true;
} else {
// skip unrecognised block
try reader.skipBytes(block_size, .{});
// log.debug("block \"{s}\" skipped", .{block_id});
}
}
log.debug(
"read wav: {} channels, {} Hz, {} bit, {} samples",
.{ channels, sample_rate, bits_per_sample, samples.len },
);
return SoundBuffer{
.channels = channels,
.sample_rate = sample_rate,
.samples = samples,
};
}
fn readQuad(reader: anytype) ![4]u8 {
var quad: [4]u8 = undefined;
try reader.readNoEof(&quad);
return quad;
}
fn readExpectedQuad(reader: anytype, expected: [4]u8) !void {
const quad = try readQuad(reader);
if (std.mem.eql(u8, &quad, &expected) == false) {
log.warn("Expected \"{s}\", read \"{s}\"", .{ &expected, &quad });
return error.UnexpectedFormat;
}
} | modules/audio/src/wav.zig |
const std = @import("std");
const stdx = @import("stdx");
const stbtt = @import("stbtt");
const gl = @import("gl");
const graphics = @import("../../graphics.zig");
const gpu = graphics.gpu;
const TextMetrics = graphics.TextMetrics;
const FontGroupId = graphics.FontGroupId;
const FontGroup = graphics.FontGroup;
const Font = graphics.Font;
const RenderFont = gpu.RenderFont;
const OpenTypeFont = graphics.OpenTypeFont;
const ImageTex = gpu.ImageTex;
const font_cache = @import("font_cache.zig");
const BitmapFontStrike = graphics.BitmapFontStrike;
const log = stdx.log.scoped(.text_renderer);
const Glyph = @import("glyph.zig").Glyph;
/// Returns an glyph iterator over UTF8 text.
pub fn textGlyphIter(g: *gpu.Graphics, font_gid: FontGroupId, font_size: f32, dpr: u32, str: []const u8) graphics.TextGlyphIterator {
var iter: graphics.TextGlyphIterator = undefined;
const fgroup = g.font_cache.getFontGroup(font_gid);
iter.inner.init(g, fgroup, font_size, dpr, str, &iter);
return iter;
}
pub fn measureCharAdvance(g: *gpu.Graphics, font_gid: FontGroupId, font_size: f32, dpr: u32, prev_cp: u21, cp: u21) f32 {
const font_grp = g.font_cache.getFontGroup(font_gid);
var req_font_size = font_size;
const render_font_size = font_cache.computeRenderFontSize(&req_font_size) * @intCast(u16, dpr);
const primary = g.font_cache.getOrCreateRenderFont(font_grp.fonts[0], render_font_size);
const to_user_scale = primary.getScaleToUserFontSize(req_font_size);
const glyph_info = g.getOrLoadFontGroupGlyph(font_grp, cp);
const glyph = glyph_info.glyph;
var advance = glyph.advance_width * to_user_scale;
const prev_glyph_info = g.getOrLoadFontGroupGlyph(font_grp, prev_cp);
const prev_glyph = prev_glyph_info.glyph;
advance += computeKern(prev_glyph.glyph_id, prev_glyph_info.font, glyph.glyph_id, glyph_info.font, to_user_scale, cp);
return @round(advance);
}
/// For lower font sizes, snap_to_grid is desired since baked fonts don't have subpixel rendering. TODO: Could this be achieved if multiple subpixel variation renders were baked as well?
pub fn measureText(g: *gpu.Graphics, font_gid: FontGroupId, font_size: f32, dpr: u32, str: []const u8, res: *TextMetrics, comptime snap_to_grid: bool) void {
var iter = textGlyphIter(g, font_gid, font_size, dpr, str);
res.height = iter.primary_height;
res.width = 0;
while (iter.nextCodepoint()) {
res.width += iter.state.kern;
if (snap_to_grid) {
res.width = @round(res.width);
}
// Add advance width.
res.width += iter.state.advance_width;
}
}
pub const TextGlyphIterator = struct {
g: *gpu.Graphics,
fgroup: *FontGroup,
cp_iter: std.unicode.Utf8Iterator,
user_scale: f32,
prev_glyph_id_opt: ?u16,
prev_glyph_font: ?*Font,
req_font_size: f32,
render_font_size: u16,
primary_font: graphics.FontId,
primary_ascent: f32,
const Self = @This();
fn init(self: *Self, g: *gpu.Graphics, fgroup: *FontGroup, font_size: f32, dpr: u32, str: []const u8, iter: *graphics.TextGlyphIterator) void {
var req_font_size = font_size;
const render_font_size = font_cache.computeRenderFontSize(fgroup.primary_font_desc, &req_font_size) * @intCast(u16, dpr);
const primary = g.font_cache.getOrCreateRenderFont(fgroup.primary_font, render_font_size);
const user_scale = primary.getScaleToUserFontSize(req_font_size);
iter.primary_ascent = primary.ascent * user_scale;
iter.primary_descent = -primary.descent * user_scale;
iter.primary_height = primary.font_height * user_scale;
iter.state = .{
// TODO: Update ascent, descent, height depending on current font.
.ascent = iter.primary_ascent,
.descent = iter.primary_descent,
.height = iter.primary_height,
.start_idx = 0,
.end_idx = 0,
.cp = undefined,
.kern = undefined,
.advance_width = undefined,
.primary_offset_y = 0,
};
self.* = .{
.g = g,
.fgroup = fgroup,
.user_scale = user_scale,
.cp_iter = std.unicode.Utf8View.initUnchecked(str).iterator(),
.prev_glyph_id_opt = null,
.prev_glyph_font = null,
.req_font_size = req_font_size,
.render_font_size = render_font_size,
.primary_font = fgroup.primary_font,
.primary_ascent = iter.primary_ascent,
};
}
pub fn setIndex(self: *Self, i: usize) void {
self.cp_iter.i = i;
}
/// Provide a callback to the glyph data so a renderer can prepare a quad.
pub fn nextCodepoint(self: *Self, state: *graphics.TextGlyphIterator.State, ctx: anytype, comptime m_cb: ?fn (@TypeOf(ctx), Glyph) void) bool {
state.start_idx = self.cp_iter.i;
state.cp = self.cp_iter.nextCodepoint() orelse return false;
state.end_idx = self.cp_iter.i;
const glyph_info = self.g.font_cache.getOrLoadFontGroupGlyph(self.g, self.fgroup, self.render_font_size, state.cp);
const glyph = glyph_info.glyph;
if (self.prev_glyph_font != glyph_info.font) {
// Recompute the scale for the new font.
self.user_scale = glyph_info.render_font.getScaleToUserFontSize(self.req_font_size);
if (glyph_info.font.id != self.primary_font) {
state.primary_offset_y = self.primary_ascent - glyph_info.render_font.ascent * self.user_scale;
} else {
state.primary_offset_y = 0;
}
}
if (self.prev_glyph_id_opt) |prev_glyph_id| {
// Advance kerning from previous codepoint.
switch (glyph_info.font.font_type) {
.Outline => {
state.kern = computeKern(prev_glyph_id, self.prev_glyph_font.?, glyph.glyph_id, glyph_info.font, glyph_info.render_font, self.user_scale, state.cp);
},
.Bitmap => {
const bm_font = glyph_info.font.getBitmapFontBySize(@floatToInt(u16, self.req_font_size));
state.kern += computeBitmapKern(prev_glyph_id, self.prev_glyph_font.?, glyph.glyph_id, glyph_info.font, bm_font, glyph_info.render_font, self.user_scale, state.cp);
},
}
} else {
state.kern = 0;
}
state.advance_width = glyph.advance_width * self.user_scale;
if (m_cb) |cb| {
// Once the state has updated, invoke the callback.
cb(ctx, glyph.*);
}
self.prev_glyph_id_opt = glyph.glyph_id;
self.prev_glyph_font = glyph_info.font;
return true;
}
// Consumes until the next non space cp or end of string.
pub fn nextNonSpaceCodepoint(self: *Self) bool {
const parent = @fieldParentPtr(graphics.MeasureTextIterator, "inner", self);
while (self.next_codepoint()) {
if (!stdx.unicode.isSpace(parent.state.cp)) {
return true;
}
}
return false;
}
// Consumes until the next space cp or end of string.
pub fn nextSpaceCodepoint(self: *Self) bool {
const parent = @fieldParentPtr(graphics.MeasureTextIterator, "inner", self);
while (self.next_codepoint()) {
if (stdx.unicode.isSpace(parent.state.cp)) {
return true;
}
}
return false;
}
};
// TODO: Cache results since each time it scans the in memory ot font data.
/// Return kerning from previous glyph id.
inline fn computeKern(prev_glyph_id: u16, prev_font: *Font, glyph_id: u16, fnt: *Font, render_font: *RenderFont, user_scale: f32, cp: u21) f32 {
_ = cp;
if (prev_font == fnt) {
const kern = fnt.getKernAdvance(prev_glyph_id, glyph_id);
return @intToFloat(f32, kern) * render_font.scale_from_ttf * user_scale;
} else {
// TODO: What to do for kerning between two different fonts?
// Maybe it's best to just always return the current font's kerning.
}
return 0;
}
inline fn computeBitmapKern(prev_glyph_id: u16, prev_font: *Font, glyph_id: u16, fnt: *Font, bm_font: BitmapFontStrike, render_font: *RenderFont, user_scale: f32, cp: u21) f32 {
_ = cp;
if (prev_font == fnt) {
const kern = bm_font.getKernAdvance(prev_glyph_id, glyph_id);
return @intToFloat(f32, kern) * render_font.scale_from_ttf * user_scale;
} else {
// TODO, maybe it's best to just always return the current font kerning.
}
return 0;
}
pub const RenderTextIterator = struct {
iter: graphics.TextGlyphIterator,
quad: TextureQuad,
// cur top left position for next codepoint to be drawn.
x: f32,
y: f32,
const Self = @This();
pub fn init(g: *gpu.Graphics, group_id: FontGroupId, font_size: f32, dpr: u32, x: f32, y: f32, str: []const u8) Self {
return .{
.iter = textGlyphIter(g, group_id, font_size, dpr, str),
.quad = undefined,
// Start at snapped pos.
.x = @round(x),
.y = @round(y),
};
}
/// Writes the vertex data of the next codepoint to ctx.quad
pub fn nextCodepointQuad(self: *Self, comptime snap_to_grid: bool) bool {
const S = struct {
fn onGlyphSnap(self_: *Self, glyph: Glyph) void {
const scale = self_.iter.inner.user_scale;
self_.x += self_.iter.state.kern;
// Snap to pixel after applying advance and kern.
self_.x = @round(self_.x);
// Update quad result.
self_.quad.image = glyph.image;
self_.quad.cp = self_.iter.state.cp;
self_.quad.is_color_bitmap = glyph.is_color_bitmap;
// quad.x0 = ctx.x + glyph.x_offset * user_scale;
// Snap to pixel for consistent glyph rendering.
self_.quad.x0 = @round(self_.x + glyph.x_offset * scale);
self_.quad.y0 = self_.y + glyph.y_offset * scale + self_.iter.state.primary_offset_y;
self_.quad.x1 = self_.quad.x0 + glyph.dst_width * scale;
self_.quad.y1 = self_.quad.y0 + glyph.dst_height * scale;
self_.quad.u0 = glyph.u0;
self_.quad.v0 = glyph.v0;
self_.quad.u1 = glyph.u1;
self_.quad.v1 = glyph.v1;
// Advance draw x.
self_.x += self_.iter.state.advance_width;
}
fn onGlyph(self_: *Self, glyph: Glyph) void {
const scale = self_.iter.inner.user_scale;
self_.x += self_.iter.state.kern;
// Update quad result.
self_.quad.image = glyph.image;
self_.quad.cp = self_.iter.state.cp;
self_.quad.is_color_bitmap = glyph.is_color_bitmap;
self_.quad.x0 = self_.x + glyph.x_offset * scale;
self_.quad.y0 = self_.y + glyph.y_offset * scale + self_.iter.state.primary_offset_y;
self_.quad.x1 = self_.quad.x0 + glyph.dst_width * scale;
self_.quad.y1 = self_.quad.y0 + glyph.dst_height * scale;
self_.quad.u0 = glyph.u0;
self_.quad.v0 = glyph.v0;
self_.quad.u1 = glyph.u1;
self_.quad.v1 = glyph.v1;
// Advance draw x.
self_.x += self_.iter.state.advance_width;
}
};
const onGlyph = if (snap_to_grid) S.onGlyphSnap else S.onGlyph;
return self.iter.inner.nextCodepoint(&self.iter.state, self, onGlyph);
}
};
// Holds compact data relevant to adding texture vertex data.
pub const TextureQuad = struct {
image: ImageTex,
cp: u21,
is_color_bitmap: bool,
x0: f32,
y0: f32,
x1: f32,
y1: f32,
u0: f32,
v0: f32,
u1: f32,
v1: f32,
}; | graphics/src/backend/gpu/text_renderer.zig |
const std = @import("std");
const stdx = @import("../stdx.zig");
const string = stdx.string;
const t = stdx.testing;
const compact = @import("compact.zig");
pub const CompactSinglyLinkedListNode = compact.CompactSinglyLinkedListNode;
pub const CompactNull = compact.CompactNull;
pub const CompactSinglyLinkedListBuffer = compact.CompactSinglyLinkedListBuffer;
pub const CompactUnorderedList = compact.CompactUnorderedList;
pub const CompactSinglyLinkedList = compact.CompactSinglyLinkedList;
pub const CompactManySinglyLinkedList = compact.CompactManySinglyLinkedList;
pub const CompactIdGenerator = compact.CompactIdGenerator;
const complete_tree = @import("complete_tree.zig");
pub const CompleteTreeArray = complete_tree.CompleteTreeArray;
pub const DynamicArrayList = @import("dynamic_array_list.zig").DynamicArrayList;
pub const BitArrayList = @import("bit_array_list.zig").BitArrayList;
const box = @import("box.zig");
pub const Box = box.Box;
pub const SizedBox = box.SizedBox;
pub const RbTree = @import("rb_tree.zig").RbTree;
// Shared opaque type.
pub const Opaque = opaque {
pub fn fromPtr(comptime T: type, ptr: T) *Opaque {
return @ptrCast(*Opaque, ptr);
}
pub fn toPtr(comptime T: type, ptr: *Opaque) T {
return @intToPtr(T, @ptrToInt(ptr));
}
};
// TODO: Rename to IndexSlice
// Relative slice. Use to reference slice in a growing memory buffer.
pub fn RelSlice(comptime T: type) type {
return struct {
start: T,
end: T,
pub fn len(self: *const @This()) T {
return self.end - self.start;
}
};
}
// std.StringHashMap except key is duped and managed.
pub fn OwnedKeyStringHashMap(comptime T: type) type {
return struct {
const Self = @This();
alloc: std.mem.Allocator,
map: std.StringHashMap(T),
pub fn init(alloc: std.mem.Allocator) @This() {
return .{
.alloc = alloc,
.map = std.StringHashMap(T).init(alloc),
};
}
pub fn get(self: *const Self, key: []const u8) ?T {
return self.map.get(key);
}
pub fn keyIterator(self: *Self) std.StringHashMap(T).KeyIterator {
return self.map.keyIterator();
}
pub fn getEntry(self: Self, key: []const u8) ?std.StringHashMap(T).Entry {
return self.map.getEntry(key);
}
pub fn count(self: Self) std.StringHashMap(T).Size {
return self.map.count();
}
pub fn getOrPut(self: *Self, key: []const u8) !std.StringHashMap(T).GetOrPutResult {
const res = try self.map.getOrPut(key);
if (!res.found_existing) {
res.key_ptr.* = string.dupe(self.alloc, key) catch unreachable;
}
return res;
}
pub fn put(self: *Self, key: []const u8, val: T) !void {
const res = try self.map.getOrPut(key);
if (res.found_existing) {
res.value_ptr.* = val;
} else {
const key_dupe = try self.alloc.dupe(u8, key);
errdefer self.alloc.free(key_dupe);
res.key_ptr.* = key_dupe;
res.value_ptr.* = val;
}
}
pub fn iterator(self: *const Self) std.StringHashMap(T).Iterator {
return self.map.iterator();
}
pub fn deinit(self: *Self) void {
var iter = self.map.iterator();
while (iter.next()) |it| {
self.alloc.free(it.key_ptr.*);
}
self.map.deinit();
}
};
}
test "OwnedKeyStringHashMap.put doesn't dupe an existing key" {
var map = OwnedKeyStringHashMap(u32).init(t.alloc);
defer map.deinit();
try map.put("foo", 123);
try map.put("foo", 234);
// Test should end without memory leak.
}
// TODO: Might want a better interface for a hash set. https://github.com/ziglang/zig/issues/6919
pub fn AutoHashSet(comptime Key: type) type {
return std.AutoHashMap(Key, void);
}
pub const SizedPtr = struct {
const Self = @This();
ptr: *Opaque,
size: u32,
pub fn init(ptr: anytype) Self {
const Ptr = @TypeOf(ptr);
return .{
.ptr = Opaque.fromPtr(Ptr, ptr),
.size = @sizeOf(@typeInfo(Ptr).Pointer.child),
};
}
pub fn deinit(self: *Self, alloc: std.mem.Allocator) void {
const slice = Opaque.toPtr([*]u8, self.ptr)[0..self.size];
alloc.free(slice);
}
};
/// The ptr or slice inside should be freed depending on the flag.
/// Use case: Sometimes a branching condition returns heap or non-heap memory. The deinit logic can just skip non-heap memory.
pub fn MaybeOwned(comptime PtrOrSlice: type) type {
return struct {
inner: PtrOrSlice,
owned: bool,
pub fn initOwned(inner: PtrOrSlice) @This() {
return .{
.inner = inner,
.owned = true,
};
}
pub fn initUnowned(inner: PtrOrSlice) @This() {
return .{
.inner = inner,
.owned = false,
};
}
pub fn deinit(self: @This(), alloc: std.mem.Allocator) void {
if (self.owned) {
if (@typeInfo(PtrOrSlice) == .Pointer and @typeInfo(PtrOrSlice).Pointer.size == .Slice) {
alloc.free(self.inner);
} else {
alloc.destroy(self.inner);
}
}
}
};
} | stdx/ds/ds.zig |
const std = @import("std");
const v8 = @import("v8");
const runtime = @import("runtime.zig");
// TODO: Move other types here from runtime.zig
// ------
// Types used to import into native code.
// ------
/// Contains the v8.Object of the js function's this.
pub const This = struct {
obj: v8.Object,
};
/// Contains the v8.Object and the matching value type.
pub fn ThisValue(comptime T: type) type {
return struct {
pub const ThisValue = true;
obj: v8.Object,
val: T,
};
}
/// Contains the v8.Object of the js function's this and the resource that it is bound to (id from the first internal field).
pub fn ThisResource(comptime Tag: runtime.ResourceTag) type {
return struct {
pub const ThisResource = true;
res_id: runtime.ResourceId,
res: *runtime.Resource(Tag),
obj: v8.Object,
};
}
/// Contains the v8.Object of the js function's this and the weak handle that it is bound to (id from the first internal field).
pub fn ThisHandle(comptime Tag: runtime.WeakHandleTag) type {
return struct {
pub const ThisHandle = true;
id: runtime.WeakHandleId,
ptr: runtime.WeakHandlePtr(Tag),
obj: v8.Object,
};
}
/// Contains the v8.Object of an arg and the weak handle that it is bound to (id from the first internal field).
pub fn Handle(comptime Tag: runtime.WeakHandleTag) type {
return struct {
pub const Handle = true;
id: runtime.WeakHandleId,
ptr: runtime.WeakHandlePtr(Tag),
obj: v8.Object,
};
}
/// Contains the v8.Function data unconverted.
pub const FuncData = struct {
val: v8.Value,
};
/// Contains a pointer converted from v8.Function data's second internal field.
/// The first internal field is reserved for the rt pointer.
pub fn FuncDataUserPtr(comptime Ptr: type) type {
return struct {
pub const FuncDataUserPtr = true;
ptr: Ptr,
};
}
// ------
// Types used to export to js.
// ------
/// Contains a v8.Promise that will be returned to js.
/// Auto generation for async function wrappers will exclude functions with this return type.
pub const PromiseSkipJsGen = struct {
inner: v8.Promise,
};
/// A temp struct that will call deinit with the runtime's allocator after converting to js.
pub fn RtTempStruct(comptime T: type) type {
return struct {
pub const RtTempStruct = true;
inner: T,
pub fn init(inner: T) @This() {
return .{ .inner = inner };
}
pub fn deinit(self: @This(), alloc: std.mem.Allocator) void {
self.inner.deinit(alloc);
}
};
}
/// A slice that knows how to deinit itself and it's items.
pub fn ManagedSlice(comptime T: type) type {
return struct {
pub const ManagedSlice = true;
alloc: std.mem.Allocator,
slice: []const T,
pub fn deinit(self: @This()) void {
for (self.slice) |it| {
it.deinit(self.alloc);
}
self.alloc.free(self.slice);
}
};
}
/// A struct that knows how to deinit itself.
pub fn ManagedStruct(comptime T: type) type {
return struct {
pub const ManagedStruct = true;
alloc: std.mem.Allocator,
val: T,
pub fn init(alloc: std.mem.Allocator, val: T) @This() {
return .{ .alloc = alloc, .val = val };
}
pub fn deinit(self: @This()) void {
self.val.deinit(self.alloc);
}
};
} | runtime/adapter.zig |
const std = @import("std");
const stdx = @import("stdx");
const t = stdx.testing;
const Vec2 = stdx.math.Vec2;
const vec2 = Vec2.init;
const math = std.math;
const trace = stdx.debug.tracy.trace;
const traceN = stdx.debug.tracy.traceN;
const log = stdx.log.scoped(.curve);
pub const QuadBez = struct {
const Self = @This();
const BasicTransform = struct {
x0: f32,
x1: f32,
scale: f32,
cross: f32,
};
x0: f32,
y0: f32,
cx: f32,
cy: f32,
x1: f32,
y1: f32,
/// Return transform values to map from the quadratic bezier to the basic parabola.
fn mapToBasic(self: Self) BasicTransform {
const ddx = 2 * self.cx - self.x0 - self.x1;
const ddy = 2 * self.cy - self.y0 - self.y1;
const r0 = (self.cx - self.x0) * ddx + (self.cy - self.y0) * ddy;
const r1 = (self.x1 - self.cx) * ddx + (self.y1 - self.cy) * ddy;
const cross = (self.x1 - self.x0) * ddy - (self.y1 - self.y0) * ddx;
const x0 = r0 / cross;
const x1 = r1 / cross;
// There's probably a more elegant formulation of this...
const scale = @fabs(cross) / (math.hypot(f32, ddx, ddy) * @fabs(x1 - x0));
return BasicTransform{
.x0 = x0,
.x1 = x1,
.scale = scale,
.cross = cross,
};
}
/// Given t, return the (x, y) along the curve.
pub fn eval(self: Self, t_: f32) Vec2 {
const mt = 1 - t_;
const x = self.x0 * mt * mt + 2 * self.cx * t_ * mt + self.x1 * t_ * t_;
const y = self.y0 * mt * mt + 2 * self.cy * t_ * mt + self.y1 * t_ * t_;
return Vec2.init(x, y);
}
/// Given error tolerance, output the minimum points needed to flatten the curve.
/// The algorithm was developed by <NAME>.
/// This has an advantage over other methods since it determines the t values beforehand
/// so that each t value can be evaluated in parallel, although the implementation is not taking advantage of that right now.
pub fn flatten(self: Self, tol: f32, buf: *std.ArrayList(Vec2)) void {
const t__ = trace(@src());
defer t__.end();
const params = self.mapToBasic();
const a0 = approx_myint(params.x0);
const a1 = approx_myint(params.x1);
var count = 0.5 * @fabs(a1 - a0) * math.sqrt(params.scale / tol);
// If count is NaN the curve can be approximated by a single straight line or a point.
if (!math.isFinite(count)) {
count = 1;
}
const n = @floatToInt(u32, @ceil(count));
const start = @intCast(u32, buf.items.len);
buf.ensureUnusedCapacity(n + 1) catch unreachable;
buf.items.len = start + n + 1;
const r0 = approx_inv_myint(a0);
const r1 = approx_inv_myint(a1);
buf.items[start] = vec2(self.x0, self.y0);
var i: u32 = 1;
while (i < n) : (i += 1) {
const r = approx_inv_myint(a0 + ((a1 - a0) * @intToFloat(f32, i)) / @intToFloat(f32, n));
const t_ = (r - r0) / (r1 - r0);
buf.items[start + i] = self.eval(t_);
}
buf.items[start + i] = vec2(self.x1, self.y1);
}
};
// Compute an approximation to int (1 + 4x^2) ^ -0.25 dx
// This isn't especially good but will do.
fn approx_myint(x: f32) f32 {
const d = 0.67;
return x / (1 - d + math.pow(f32, math.pow(f32, d, 4) + 0.25 * x * x, 0.25));
}
// Approximate the inverse of the function above.
// This is better.
fn approx_inv_myint(x: f32) f32 {
const b = 0.39;
return x * (1 - b + math.sqrt(b * b + 0.25 * x * x));
}
pub const SubQuadBez = struct {
bez: QuadBez,
a0: f32,
a1: f32,
val: f32,
};
pub const CubicBez = struct {
const Self = @This();
x0: f32,
y0: f32,
cx0: f32,
cy0: f32,
cx1: f32,
cy1: f32,
x1: f32,
y1: f32,
fn weightsum(self: Self, c0: f32, c1: f32, c2: f32, c3: f32) Vec2 {
const x = c0 * self.x0 + c1 * self.cx0 + c2 * self.cx1 + c3 * self.x1;
const y = c0 * self.y0 + c1 * self.cy0 + c2 * self.cy1 + c3 * self.y1;
return vec2(x, y);
}
/// Given error tolerance, output the minimum points needed to flatten the curve.
/// The cubic bezier is first converted into quad bezier curves and then uses the same quad bezier flatten algorithm.
/// TODO: add comptime "continued" param to add points after the start point. Like a "curveTo".
pub fn flatten(self: Self, tol: f32, buf: *std.ArrayList(Vec2), qbez_buf: *std.ArrayList(SubQuadBez)) void {
const t__ = trace(@src());
defer t__.end();
const tol1 = 0.1 * tol; // error for subdivision into quads
const tol2 = tol - tol1; // error for subdivision of quads into lines
const sqrt_tol2 = math.sqrt(tol2);
const err2 = self.weightsum(1, -3, 3, -1).squareLength();
const n_quads = @ceil(math.pow(f32, err2 / (432 * tol1 * tol1), @as(f32, 1)/@as(f32, 6)));
// n_quads is usually 2 or more quads.
const n_quads_i = @floatToInt(u32, n_quads);
qbez_buf.ensureTotalCapacity(n_quads_i) catch unreachable;
qbez_buf.items.len = n_quads_i;
var sum: f32 = 0;
var i: u32 = 0;
while (i < n_quads_i) : (i += 1) {
const t0 = @intToFloat(f32, i) / n_quads;
const t1 = @intToFloat(f32, i + 1) / n_quads;
const sub = self.subsegment(t0, t1);
const quad = sub.midpointQBez();
const params = quad.mapToBasic();
const a0 = approx_myint(params.x0);
const a1 = approx_myint(params.x1);
const scale = math.sqrt(params.scale);
var val = @fabs(a1 - a0) * scale;
if (math.signbit(params.x0) != math.signbit(params.x1)) {
// min x value in basic parabola to make sure we don't skip cusp
const xmin = sqrt_tol2 / scale;
const cusp_val = sqrt_tol2 * @fabs(a1 - a0) / approx_myint(xmin);
// I *think* it will always be larger, but just in case...
val = math.max(val, cusp_val);
}
qbez_buf.items[i] = .{
.bez = quad,
.a0 = a0,
.a1 = a1,
.val = val,
};
sum += val;
}
var count = 0.5 * sum / sqrt_tol2;
// If count is NaN the curve can be approximated by a single straight line or a point.
if (!math.isFinite(count)) {
count = 1;
}
const n = @ceil(count);
const ni = @floatToInt(u32, n);
const start = @intCast(u32, buf.items.len);
buf.ensureUnusedCapacity(ni + 1) catch unreachable;
buf.items.len = start + ni + 1;
buf.items[start] = vec2(self.x0, self.y0);
// TODO: See if kurbo's implementation is faster (https://github.com/linebender/kurbo/blob/master/src/bezpath.rs)
var val: f32 = 0; // sum of vals from [0..i]
i = 0;
var j: u32 = 1;
while (j < ni) : (j += 1) {
const target = sum * @intToFloat(f32, j) / n;
while (val + qbez_buf.items[i].val < target) {
val += qbez_buf.items[i].val;
i += 1;
}
const a0 = qbez_buf.items[i].a0;
const a1 = qbez_buf.items[i].a1;
// Note: we can cut down on recomputing these
const r0 = approx_inv_myint(a0);
const r1 = approx_inv_myint(a1);
const a = a0 + (a1 - a0) * (target - val) / qbez_buf.items[i].val;
const r = approx_inv_myint(a);
const t_ = (r - r0) / (r1 - r0);
buf.items[start + j] = qbez_buf.items[i].bez.eval(t_);
}
buf.items[start + j] = vec2(self.x1, self.y1);
}
fn subsegment(self: Self, t0: f32, t1: f32) Self {
const p0 = self.eval(t0);
const p1 = self.eval(t1);
const scale = (t1 - t0) / 3;
const d0 = self.deriv(t0);
const d1 = self.deriv(t1);
return .{
.x0 = p0.x,
.y0 = p0.y,
.cx0 = p0.x + scale * d0.x,
.cy0 = p0.y + scale * d0.y,
.cx1 = p1.x - scale * d1.x,
.cy1 = p1.y - scale * d1.y,
.x1 = p1.x,
.y1 = p1.y,
};
}
fn deriv(self: Self, t_: f32) Vec2 {
const mt = 1 - t_;
const c0 = -3 * mt * mt;
const c3 = 3 * t_ * t_;
const c1 = -6 * t_ * mt - c0;
const c2 = 6 * t_ * mt - c3;
return self.weightsum(c0, c1, c2, c3);
}
fn eval(self: Self, t_: f32) Vec2 {
const mt = 1 - t_;
const c0 = mt * mt * mt;
const c1 = 3 * mt * mt * t_;
const c2 = 3 * mt * t_ * t_;
const c3 = t_ * t_ * t_;
return self.weightsum(c0, c1, c2, c3);
}
/// quadratic bezier with matching endpoints and minimum max vector error
fn midpointQBez(self: Self) QuadBez {
const p1 = self.weightsum(-0.25, 0.75, 0.75, -0.25);
return QuadBez{
.x0 = self.x0,
.y0 = self.y0,
.cx = p1.x,
.cy = p1.y,
.x1 = self.x1,
.y1 = self.y1,
};
}
};
test "Quadratic bezier flatten." {
const qbez = QuadBez{
.x0 = 0,
.y0 = 0,
.cx = 200,
.cy = 0,
.x1 = 200,
.y1 = 200,
};
var buf = std.ArrayList(Vec2).init(t.alloc);
defer buf.deinit();
qbez.flatten(0.5, &buf);
const exp: []const Vec2 = &.{
vec2(0, 0),
vec2(3.47196731e+01, 1.65378558e+00),
vec2(6.48403472e+01, 6.33185195e+00),
vec2(9.09474639e+01, 1.36849184e+01),
vec2(1.13562118e+02, 2.34734230e+01),
vec2(1.33128662e+02, 3.55769996e+01),
vec2(1.5e+02, 5.0e+01),
vec2(1.64423019e+02, 6.68713607e+01),
vec2(1.76526580e+02, 8.64378890e+01),
vec2(1.86315093e+02, 1.09052558e+02),
vec2(1.93668151e+02, 1.35159667e+02),
vec2(1.98346221e+02, 1.65280334e+02),
vec2(2.0e+02, 2.0e+02),
};
try t.eq(buf.items.len, exp.len);
var i: usize = 0;
while (i < buf.items.len) : (i += 1) {
try t.eqApprox(buf.items[i].x, exp[i].x, 1e-4);
try t.eqApprox(buf.items[i].y, exp[i].y, 1e-4);
}
}
test "Cubic bezier flatten." {
const cbez = CubicBez{
.x0 = 200,
.y0 = 450,
.cx0 = 400,
.cy0 = 450,
.cx1 = 500,
.cy1 = 100,
.x1 = 600,
.y1 = 50,
};
var buf = std.ArrayList(Vec2).init(t.alloc);
defer buf.deinit();
var qbez_buf = std.ArrayList(SubQuadBez).init(t.alloc);
defer qbez_buf.deinit();
cbez.flatten(0.5, &buf, &qbez_buf);
const exp: []const Vec2 = &.{
vec2(200, 450),
vec2(2.24316696e+02, 4.48221649e+02),
vec2(2.47434082e+02, 4.43284667e+02),
vec2(2.70417541e+02, 4.34863952e+02),
vec2(2.94486755e+02, 4.22462219e+02),
vec2(3.17744873e+02, 4.06724090e+02),
vec2(3.43482452e+02, 3.84952728e+02),
vec2(3.68587493e+02, 3.59402557e+02),
vec2(3.97798461e+02, 3.24399749e+02),
vec2(4.29767578e+02, 2.80172943e+02),
vec2(4.80043090e+02, 2.02067459e+02),
vec2(5.26117553e+02, 1.29646820e+02),
vec2(5.50330810e+02, 9.59812622e+01),
vec2(5.69920593e+02, 7.32915573e+01),
vec2(5.85504394e+02, 5.92830162e+01),
vec2(600, 50),
};
try t.eq(buf.items.len, exp.len);
var i: usize = 0;
while (i < buf.items.len) : (i += 1) {
try t.eqApprox(buf.items[i].x, exp[i].x, 1e-3);
try t.eqApprox(buf.items[i].y, exp[i].y, 1e-3);
}
} | graphics/src/curve.zig |
const std = @import("std");
const builtin = @import("builtin");
const assert = std.debug.assert;
const mem = std.mem;
const log = std.log.scoped(.c);
const link = @import("../link.zig");
const Module = @import("../Module.zig");
const Compilation = @import("../Compilation.zig");
const Value = @import("../value.zig").Value;
const Type = @import("../type.zig").Type;
const TypedValue = @import("../TypedValue.zig");
const C = link.File.C;
const Decl = Module.Decl;
const trace = @import("../tracy.zig").trace;
const LazySrcLoc = Module.LazySrcLoc;
const Air = @import("../Air.zig");
const Liveness = @import("../Liveness.zig");
const CType = @import("../type.zig").CType;
const Mutability = enum { Const, Mut };
const BigIntConst = std.math.big.int.Const;
pub const CValue = union(enum) {
none: void,
/// Index into local_names
local: usize,
/// Index into local_names, but take the address.
local_ref: usize,
/// A constant instruction, to be rendered inline.
constant: Air.Inst.Ref,
/// Index into the parameters
arg: usize,
/// By-value
decl: *Decl,
decl_ref: *Decl,
/// An undefined (void *) pointer (cannot be dereferenced)
undefined_ptr: void,
/// Render the slice as an identifier (using fmtIdent)
identifier: []const u8,
/// Render these bytes literally.
/// TODO make this a [*:0]const u8 to save memory
bytes: []const u8,
};
const BlockData = struct {
block_id: usize,
result: CValue,
};
pub const CValueMap = std.AutoHashMap(Air.Inst.Ref, CValue);
pub const TypedefMap = std.ArrayHashMap(
Type,
struct { name: []const u8, rendered: []u8 },
Type.HashContext32,
true,
);
fn formatTypeAsCIdentifier(
data: Type,
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
writer: anytype,
) !void {
_ = fmt;
_ = options;
var buffer = [1]u8{0} ** 128;
// We don't care if it gets cut off, it's still more unique than a number
var buf = std.fmt.bufPrint(&buffer, "{}", .{data}) catch &buffer;
return formatIdent(buf, "", .{}, writer);
}
pub fn typeToCIdentifier(t: Type) std.fmt.Formatter(formatTypeAsCIdentifier) {
return .{ .data = t };
}
const reserved_idents = std.ComptimeStringMap(void, .{
.{ "_Alignas", {
@setEvalBranchQuota(4000);
} },
.{ "_Alignof", {} },
.{ "_Atomic", {} },
.{ "_Bool", {} },
.{ "_Complex", {} },
.{ "_Decimal128", {} },
.{ "_Decimal32", {} },
.{ "_Decimal64", {} },
.{ "_Generic", {} },
.{ "_Imaginary", {} },
.{ "_Noreturn", {} },
.{ "_Pragma", {} },
.{ "_Static_assert", {} },
.{ "_Thread_local", {} },
.{ "alignas", {} },
.{ "alignof", {} },
.{ "asm", {} },
.{ "atomic_bool", {} },
.{ "atomic_char", {} },
.{ "atomic_char16_t", {} },
.{ "atomic_char32_t", {} },
.{ "atomic_int", {} },
.{ "atomic_int_fast16_t", {} },
.{ "atomic_int_fast32_t", {} },
.{ "atomic_int_fast64_t", {} },
.{ "atomic_int_fast8_t", {} },
.{ "atomic_int_least16_t", {} },
.{ "atomic_int_least32_t", {} },
.{ "atomic_int_least64_t", {} },
.{ "atomic_int_least8_t", {} },
.{ "atomic_intmax_t", {} },
.{ "atomic_intptr_t", {} },
.{ "atomic_llong", {} },
.{ "atomic_long", {} },
.{ "atomic_ptrdiff_t", {} },
.{ "atomic_schar", {} },
.{ "atomic_short", {} },
.{ "atomic_size_t", {} },
.{ "atomic_uchar", {} },
.{ "atomic_uint", {} },
.{ "atomic_uint_fast16_t", {} },
.{ "atomic_uint_fast32_t", {} },
.{ "atomic_uint_fast64_t", {} },
.{ "atomic_uint_fast8_t", {} },
.{ "atomic_uint_least16_t", {} },
.{ "atomic_uint_least32_t", {} },
.{ "atomic_uint_least64_t", {} },
.{ "atomic_uint_least8_t", {} },
.{ "atomic_uintmax_t", {} },
.{ "atomic_uintptr_t", {} },
.{ "atomic_ullong", {} },
.{ "atomic_ulong", {} },
.{ "atomic_ushort", {} },
.{ "atomic_wchar_t", {} },
.{ "auto", {} },
.{ "bool", {} },
.{ "break", {} },
.{ "case", {} },
.{ "char", {} },
.{ "complex", {} },
.{ "const", {} },
.{ "continue", {} },
.{ "default", {} },
.{ "do", {} },
.{ "double", {} },
.{ "else", {} },
.{ "enum", {} },
.{ "extern ", {} },
.{ "float", {} },
.{ "for", {} },
.{ "fortran", {} },
.{ "goto", {} },
.{ "if", {} },
.{ "imaginary", {} },
.{ "inline", {} },
.{ "int", {} },
.{ "int16_t", {} },
.{ "int32_t", {} },
.{ "int64_t", {} },
.{ "int8_t", {} },
.{ "intptr_t", {} },
.{ "long", {} },
.{ "noreturn", {} },
.{ "register", {} },
.{ "restrict", {} },
.{ "return", {} },
.{ "short ", {} },
.{ "signed", {} },
.{ "size_t", {} },
.{ "sizeof", {} },
.{ "ssize_t", {} },
.{ "static", {} },
.{ "static_assert", {} },
.{ "struct", {} },
.{ "switch", {} },
.{ "thread_local", {} },
.{ "typedef", {} },
.{ "uint16_t", {} },
.{ "uint32_t", {} },
.{ "uint64_t", {} },
.{ "uint8_t", {} },
.{ "uintptr_t", {} },
.{ "union", {} },
.{ "unsigned", {} },
.{ "void", {} },
.{ "volatile", {} },
.{ "while ", {} },
});
fn formatIdent(
ident: []const u8,
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
writer: anytype,
) !void {
_ = options;
const solo = fmt.len != 0 and fmt[0] == ' '; // space means solo; not part of a bigger ident.
if (solo and reserved_idents.has(ident)) {
try writer.writeAll("zig_e_");
}
for (ident) |c, i| {
switch (c) {
'a'...'z', 'A'...'Z', '_' => try writer.writeByte(c),
'.' => try writer.writeByte('_'),
'0'...'9' => if (i == 0) {
try writer.print("_{x:2}", .{c});
} else {
try writer.writeByte(c);
},
else => try writer.print("_{x:2}", .{c}),
}
}
}
pub fn fmtIdent(ident: []const u8) std.fmt.Formatter(formatIdent) {
return .{ .data = ident };
}
/// This data is available when outputting .c code for a `*Module.Fn`.
/// It is not available when generating .h file.
pub const Function = struct {
air: Air,
liveness: Liveness,
value_map: CValueMap,
blocks: std.AutoHashMapUnmanaged(Air.Inst.Index, BlockData) = .{},
next_arg_index: usize = 0,
next_local_index: usize = 0,
next_block_index: usize = 0,
object: Object,
func: *Module.Fn,
fn resolveInst(f: *Function, inst: Air.Inst.Ref) !CValue {
const gop = try f.value_map.getOrPut(inst);
if (gop.found_existing) return gop.value_ptr.*;
const val = f.air.value(inst).?;
const ty = f.air.typeOf(inst);
switch (ty.zigTypeTag()) {
.Array => {
const writer = f.object.code_header.writer();
const decl_c_value = f.allocLocalValue();
gop.value_ptr.* = decl_c_value;
try writer.writeAll("static ");
try f.object.dg.renderTypeAndName(
writer,
ty,
decl_c_value,
.Const,
0,
);
try writer.writeAll(" = ");
try f.object.dg.renderValue(writer, ty, val);
try writer.writeAll(";\n ");
return decl_c_value;
},
else => {
const result = CValue{ .constant = inst };
gop.value_ptr.* = result;
return result;
},
}
}
fn allocLocalValue(f: *Function) CValue {
const result = f.next_local_index;
f.next_local_index += 1;
return .{ .local = result };
}
fn allocLocal(f: *Function, ty: Type, mutability: Mutability) !CValue {
return f.allocAlignedLocal(ty, mutability, 0);
}
fn allocAlignedLocal(f: *Function, ty: Type, mutability: Mutability, alignment: u32) !CValue {
const local_value = f.allocLocalValue();
try f.object.dg.renderTypeAndName(
f.object.writer(),
ty,
local_value,
mutability,
alignment,
);
return local_value;
}
fn writeCValue(f: *Function, w: anytype, c_value: CValue) !void {
switch (c_value) {
.constant => |inst| {
const ty = f.air.typeOf(inst);
const val = f.air.value(inst).?;
return f.object.dg.renderValue(w, ty, val);
},
else => return f.object.dg.writeCValue(w, c_value),
}
}
fn writeCValueDeref(f: *Function, w: anytype, c_value: CValue) !void {
switch (c_value) {
.constant => |inst| {
const ty = f.air.typeOf(inst);
const val = f.air.value(inst).?;
try w.writeAll("(*");
try f.object.dg.renderValue(w, ty, val);
return w.writeByte(')');
},
else => return f.object.dg.writeCValueDeref(w, c_value),
}
}
fn fail(f: *Function, comptime format: []const u8, args: anytype) error{ AnalysisFail, OutOfMemory } {
return f.object.dg.fail(format, args);
}
fn renderType(f: *Function, w: anytype, t: Type) !void {
return f.object.dg.renderType(w, t);
}
fn renderTypecast(f: *Function, w: anytype, t: Type) !void {
return f.object.dg.renderTypecast(w, t);
}
};
/// This data is available when outputting .c code for a `Module`.
/// It is not available when generating .h file.
pub const Object = struct {
dg: DeclGen,
code: std.ArrayList(u8),
/// Goes before code. Initialized and deinitialized in `genFunc`.
code_header: std.ArrayList(u8) = undefined,
indent_writer: IndentWriter(std.ArrayList(u8).Writer),
fn writer(o: *Object) IndentWriter(std.ArrayList(u8).Writer).Writer {
return o.indent_writer.writer();
}
};
/// This data is available both when outputting .c code and when outputting an .h file.
pub const DeclGen = struct {
gpa: std.mem.Allocator,
module: *Module,
decl: *Decl,
fwd_decl: std.ArrayList(u8),
error_msg: ?*Module.ErrorMsg,
/// The key of this map is Type which has references to typedefs_arena.
typedefs: TypedefMap,
typedefs_arena: std.mem.Allocator,
fn fail(dg: *DeclGen, comptime format: []const u8, args: anytype) error{ AnalysisFail, OutOfMemory } {
@setCold(true);
const src: LazySrcLoc = .{ .node_offset = 0 };
const src_loc = src.toSrcLoc(dg.decl);
dg.error_msg = try Module.ErrorMsg.create(dg.module.gpa, src_loc, format, args);
return error.AnalysisFail;
}
fn getTypedefName(dg: *DeclGen, t: Type) ?[]const u8 {
if (dg.typedefs.get(t)) |some| {
return some.name;
} else {
return null;
}
}
fn renderDeclValue(
dg: *DeclGen,
writer: anytype,
ty: Type,
val: Value,
decl: *Decl,
) error{ OutOfMemory, AnalysisFail }!void {
decl.markAlive();
if (ty.isSlice()) {
try writer.writeByte('(');
try dg.renderTypecast(writer, ty);
try writer.writeAll("){");
var buf: Type.SlicePtrFieldTypeBuffer = undefined;
try dg.renderValue(writer, ty.slicePtrFieldType(&buf), val.slicePtr());
try writer.writeAll(", ");
try writer.print("{d}", .{val.sliceLen()});
try writer.writeAll("}");
return;
}
assert(decl.has_tv);
// We shouldn't cast C function pointers as this is UB (when you call
// them). The analysis until now should ensure that the C function
// pointers are compatible. If they are not, then there is a bug
// somewhere and we should let the C compiler tell us about it.
if (ty.castPtrToFn() == null) {
// Determine if we must pointer cast.
if (ty.eql(decl.ty)) {
try writer.writeByte('&');
try dg.renderDeclName(writer, decl);
return;
}
try writer.writeAll("((");
try dg.renderTypecast(writer, ty);
try writer.writeAll(")&");
try dg.renderDeclName(writer, decl);
try writer.writeByte(')');
return;
}
try dg.renderDeclName(writer, decl);
}
fn renderInt128(
writer: anytype,
int_val: anytype,
) error{ OutOfMemory, AnalysisFail }!void {
const int_info = @typeInfo(@TypeOf(int_val)).Int;
const is_signed = int_info.signedness == .signed;
const is_neg = int_val < 0;
comptime assert(int_info.bits > 64 and int_info.bits <= 128);
// Clang and GCC don't support 128-bit integer constants but will hopefully unfold them
// if we construct one manually.
const magnitude = std.math.absCast(int_val);
const high = @truncate(u64, magnitude >> 64);
const low = @truncate(u64, magnitude);
// (int128_t)/<->( ( (uint128_t)( val_high << 64 )u ) + (uint128_t)val_low/u )
if (is_signed) try writer.writeAll("(int128_t)");
if (is_neg) try writer.writeByte('-');
assert(high > 0);
try writer.print("(((uint128_t)0x{x}u<<64)", .{high});
if (low > 0)
try writer.print("+(uint128_t)0x{x}u", .{low});
return writer.writeByte(')');
}
fn renderBigIntConst(
dg: *DeclGen,
writer: anytype,
val: BigIntConst,
signed: bool,
) error{ OutOfMemory, AnalysisFail }!void {
if (signed) {
try renderInt128(writer, val.to(i128) catch {
return dg.fail("TODO implement integer constants larger than 128 bits", .{});
});
} else {
try renderInt128(writer, val.to(u128) catch {
return dg.fail("TODO implement integer constants larger than 128 bits", .{});
});
}
}
// Renders a "child" pointer (e.g. ElemPtr, FieldPtr) by recursing
// to the root decl/variable that acts as its parent
//
// Used for .elem_ptr, .field_ptr, .opt_payload_ptr, .eu_payload_ptr, since
// the Type of their container cannot be retrieved from their own Type
fn renderChildPtr(dg: *DeclGen, writer: anytype, ptr_val: Value) error{ OutOfMemory, AnalysisFail }!Type {
switch (ptr_val.tag()) {
.decl_ref_mut, .decl_ref, .variable => {
const decl = switch (ptr_val.tag()) {
.decl_ref => ptr_val.castTag(.decl_ref).?.data,
.decl_ref_mut => ptr_val.castTag(.decl_ref_mut).?.data.decl,
.variable => ptr_val.castTag(.variable).?.data.owner_decl,
else => unreachable,
};
try dg.renderDeclName(writer, decl);
return decl.ty;
},
.field_ptr => {
const field_ptr = ptr_val.castTag(.field_ptr).?.data;
const index = field_ptr.field_index;
try writer.writeAll("&(");
const container_ty = try dg.renderChildPtr(writer, field_ptr.container_ptr);
const field_name = switch (container_ty.zigTypeTag()) {
.Struct => container_ty.structFields().keys()[index],
.Union => container_ty.unionFields().keys()[index],
else => unreachable,
};
const field_ty = switch (container_ty.zigTypeTag()) {
.Struct => container_ty.structFields().values()[index].ty,
.Union => container_ty.unionFields().values()[index].ty,
else => unreachable,
};
try writer.print(").{ }", .{fmtIdent(field_name)});
return field_ty;
},
.elem_ptr => {
const elem_ptr = ptr_val.castTag(.elem_ptr).?.data;
try writer.writeAll("&(");
const container_ty = try dg.renderChildPtr(writer, elem_ptr.array_ptr);
try writer.print(")[{d}]", .{elem_ptr.index});
return container_ty.childType();
},
.opt_payload_ptr => return dg.fail("implement renderChildPtr for optional payload", .{}),
.eu_payload_ptr => return dg.fail("implement renderChildPtr for error union payload", .{}),
else => unreachable,
}
}
fn renderValue(
dg: *DeclGen,
writer: anytype,
ty: Type,
val: Value,
) error{ OutOfMemory, AnalysisFail }!void {
if (val.isUndefDeep()) {
switch (ty.zigTypeTag()) {
// Using '{}' for integer and floats seemed to error C compilers (both GCC and Clang)
// with 'error: expected expression' (including when built with 'zig cc')
.Int => {
const c_bits = toCIntBits(ty.intInfo(dg.module.getTarget()).bits) orelse
return dg.fail("TODO: C backend: implement integer types larger than 128 bits", .{});
switch (c_bits) {
8 => return writer.writeAll("0xaau"),
16 => return writer.writeAll("0xaaaau"),
32 => return writer.writeAll("0xaaaaaaaau"),
64 => return writer.writeAll("0xaaaaaaaaaaaaaaaau"),
128 => return renderInt128(writer, @as(u128, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)),
else => unreachable,
}
},
.Float => {
switch (ty.floatBits(dg.module.getTarget())) {
32 => return writer.writeAll("zig_bitcast_f32_u32(0xaaaaaaaau)"),
64 => return writer.writeAll("zig_bitcast_f64_u64(0xaaaaaaaaaaaaaaaau)"),
else => return dg.fail("TODO float types > 64 bits are not support in renderValue() as of now", .{}),
}
},
.Pointer => switch (dg.module.getTarget().cpu.arch.ptrBitWidth()) {
32 => return writer.writeAll("(void *)0xaaaaaaaa"),
64 => return writer.writeAll("(void *)0xaaaaaaaaaaaaaaaa"),
else => unreachable,
},
else => {
// This should lower to 0xaa bytes in safe modes, and for unsafe modes should
// lower to leaving variables uninitialized (that might need to be implemented
// outside of this function).
return writer.writeAll("{}");
},
}
}
switch (ty.zigTypeTag()) {
.Int => switch (val.tag()) {
.int_big_positive => try dg.renderBigIntConst(writer, val.castTag(.int_big_positive).?.asBigInt(), ty.isSignedInt()),
.int_big_negative => try dg.renderBigIntConst(writer, val.castTag(.int_big_negative).?.asBigInt(), true),
else => {
if (ty.isSignedInt())
return writer.print("{d}", .{val.toSignedInt()});
return writer.print("{d}u", .{val.toUnsignedInt()});
},
},
.Float => {
if (ty.floatBits(dg.module.getTarget()) <= 64) {
if (std.math.isNan(val.toFloat(f64)) or std.math.isInf(val.toFloat(f64))) {
// just generate a bit cast (exactly like we do in airBitcast)
switch (ty.tag()) {
.f32 => return writer.print("zig_bitcast_f32_u32(0x{x})", .{@bitCast(u32, val.toFloat(f32))}),
.f64 => return writer.print("zig_bitcast_f64_u64(0x{x})", .{@bitCast(u64, val.toFloat(f64))}),
else => return dg.fail("TODO float types > 64 bits are not support in renderValue() as of now", .{}),
}
} else {
return writer.print("{x}", .{val.toFloat(f64)});
}
}
return dg.fail("TODO: C backend: implement lowering large float values", .{});
},
.Pointer => switch (val.tag()) {
.null_value => try writer.writeAll("NULL"),
// Technically this should produce NULL but the integer literal 0 will always coerce
// to the assigned pointer type. Note this is just a hack to fix warnings from ordered comparisons (<, >, etc)
// between pointers and 0, which is an extension to begin with.
.zero => try writer.writeByte('0'),
.decl_ref => {
const decl = val.castTag(.decl_ref).?.data;
return dg.renderDeclValue(writer, ty, val, decl);
},
.variable => {
const decl = val.castTag(.variable).?.data.owner_decl;
return dg.renderDeclValue(writer, ty, val, decl);
},
.slice => {
const slice = val.castTag(.slice).?.data;
var buf: Type.SlicePtrFieldTypeBuffer = undefined;
try writer.writeByte('(');
try dg.renderTypecast(writer, ty);
try writer.writeAll("){");
try dg.renderValue(writer, ty.slicePtrFieldType(&buf), slice.ptr);
try writer.writeAll(", ");
try dg.renderValue(writer, Type.usize, slice.len);
try writer.writeAll("}");
},
.field_ptr, .elem_ptr, .opt_payload_ptr, .eu_payload_ptr => {
_ = try dg.renderChildPtr(writer, val);
},
.function => {
const func = val.castTag(.function).?.data;
try dg.renderDeclName(writer, func.owner_decl);
},
.extern_fn => {
const extern_fn = val.castTag(.extern_fn).?.data;
try dg.renderDeclName(writer, extern_fn.owner_decl);
},
.int_u64, .one => {
try writer.writeAll("((");
try dg.renderTypecast(writer, ty);
try writer.print(")0x{x}u)", .{val.toUnsignedInt()});
},
else => unreachable,
},
.Array => {
// First try specific tag representations for more efficiency.
switch (val.tag()) {
.undef, .empty_struct_value, .empty_array => {
try writer.writeByte('{');
const ai = ty.arrayInfo();
if (ai.sentinel) |s| {
try dg.renderValue(writer, ai.elem_type, s);
}
try writer.writeByte('}');
},
else => {
// Fall back to generic implementation.
var arena = std.heap.ArenaAllocator.init(dg.module.gpa);
defer arena.deinit();
const arena_allocator = arena.allocator();
try writer.writeByte('{');
const ai = ty.arrayInfo();
var index: usize = 0;
while (index < ai.len) : (index += 1) {
if (index != 0) try writer.writeAll(",");
const elem_val = try val.elemValue(arena_allocator, index);
try dg.renderValue(writer, ai.elem_type, elem_val);
}
if (ai.sentinel) |s| {
if (index != 0) try writer.writeAll(",");
try dg.renderValue(writer, ai.elem_type, s);
}
try writer.writeByte('}');
},
}
},
.Bool => return writer.print("{}", .{val.toBool()}),
.Optional => {
var opt_buf: Type.Payload.ElemType = undefined;
const payload_type = ty.optionalChild(&opt_buf);
if (ty.isPtrLikeOptional()) {
return dg.renderValue(writer, payload_type, val);
}
const target = dg.module.getTarget();
if (payload_type.abiSize(target) == 0) {
const is_null = val.castTag(.opt_payload) == null;
return writer.print("{}", .{is_null});
}
try writer.writeByte('(');
try dg.renderTypecast(writer, ty);
try writer.writeAll("){");
if (val.castTag(.opt_payload)) |pl| {
const payload_val = pl.data;
try writer.writeAll(" .is_null = false, .payload = ");
try dg.renderValue(writer, payload_type, payload_val);
try writer.writeAll(" }");
} else {
try writer.writeAll(" .is_null = true }");
}
},
.ErrorSet => {
switch (val.tag()) {
.@"error" => {
const payload = val.castTag(.@"error").?;
// error values will be #defined at the top of the file
return writer.print("zig_error_{s}", .{payload.data.name});
},
else => {
// In this case we are rendering an error union which has a
// 0 bits payload.
return writer.writeAll("0");
},
}
},
.ErrorUnion => {
const error_type = ty.errorUnionSet();
const payload_type = ty.errorUnionPayload();
if (!payload_type.hasRuntimeBits()) {
// We use the error type directly as the type.
const err_val = if (val.errorUnionIsPayload()) Value.initTag(.zero) else val;
return dg.renderValue(writer, error_type, err_val);
}
try writer.writeByte('(');
try dg.renderTypecast(writer, ty);
try writer.writeAll("){");
if (val.castTag(.eu_payload)) |pl| {
const payload_val = pl.data;
try writer.writeAll(" .payload = ");
try dg.renderValue(writer, payload_type, payload_val);
try writer.writeAll(", .error = 0 }");
} else {
try writer.writeAll(" .error = ");
try dg.renderValue(writer, error_type, val);
try writer.writeAll(" }");
}
},
.Enum => {
switch (val.tag()) {
.enum_field_index => {
const field_index = val.castTag(.enum_field_index).?.data;
switch (ty.tag()) {
.enum_simple => return writer.print("{d}", .{field_index}),
.enum_full, .enum_nonexhaustive => {
const enum_full = ty.cast(Type.Payload.EnumFull).?.data;
if (enum_full.values.count() != 0) {
const tag_val = enum_full.values.keys()[field_index];
return dg.renderValue(writer, enum_full.tag_ty, tag_val);
} else {
return writer.print("{d}", .{field_index});
}
},
.enum_numbered => {
const enum_obj = ty.castTag(.enum_numbered).?.data;
if (enum_obj.values.count() != 0) {
const tag_val = enum_obj.values.keys()[field_index];
return dg.renderValue(writer, enum_obj.tag_ty, tag_val);
} else {
return writer.print("{d}", .{field_index});
}
},
else => unreachable,
}
},
else => {
var int_tag_ty_buffer: Type.Payload.Bits = undefined;
const int_tag_ty = ty.intTagType(&int_tag_ty_buffer);
return dg.renderValue(writer, int_tag_ty, val);
},
}
},
.Fn => switch (val.tag()) {
.function => {
const decl = val.castTag(.function).?.data.owner_decl;
return dg.renderDeclValue(writer, ty, val, decl);
},
.extern_fn => {
const decl = val.castTag(.extern_fn).?.data.owner_decl;
return dg.renderDeclValue(writer, ty, val, decl);
},
else => unreachable,
},
.Struct => {
const field_vals = val.castTag(.aggregate).?.data;
try writer.writeAll("(");
try dg.renderTypecast(writer, ty);
try writer.writeAll("){");
for (field_vals) |field_val, i| {
const field_ty = ty.structFieldType(i);
if (!field_ty.hasRuntimeBits()) continue;
if (i != 0) try writer.writeAll(",");
try dg.renderValue(writer, field_ty, field_val);
}
try writer.writeAll("}");
},
.Union => {
const union_obj = val.castTag(.@"union").?.data;
const union_ty = ty.cast(Type.Payload.Union).?.data;
const target = dg.module.getTarget();
const layout = ty.unionGetLayout(target);
try writer.writeAll("(");
try dg.renderTypecast(writer, ty);
try writer.writeAll("){");
if (ty.unionTagType()) |tag_ty| {
if (layout.tag_size != 0) {
try writer.writeAll(".tag = ");
try dg.renderValue(writer, tag_ty, union_obj.tag);
try writer.writeAll(", ");
}
try writer.writeAll(".payload = {");
}
const index = union_ty.tag_ty.enumTagFieldIndex(union_obj.tag).?;
const field_ty = ty.unionFields().values()[index].ty;
const field_name = ty.unionFields().keys()[index];
if (field_ty.hasRuntimeBits()) {
try writer.print(".{ } = ", .{fmtIdent(field_name)});
try dg.renderValue(writer, field_ty, union_obj.val);
}
if (ty.unionTagType()) |_| {
try writer.writeAll("}");
}
try writer.writeAll("}");
},
.ComptimeInt => unreachable,
.ComptimeFloat => unreachable,
.Type => unreachable,
.EnumLiteral => unreachable,
.Void => unreachable,
.NoReturn => unreachable,
.Undefined => unreachable,
.Null => unreachable,
.BoundFn => unreachable,
.Opaque => unreachable,
.Frame,
.AnyFrame,
.Vector,
=> |tag| return dg.fail("TODO: C backend: implement value of type {s}", .{
@tagName(tag),
}),
}
}
fn renderFunctionSignature(dg: *DeclGen, w: anytype, is_global: bool) !void {
if (!is_global) {
try w.writeAll("static ");
}
if (dg.decl.val.castTag(.function)) |func_payload| {
const func: *Module.Fn = func_payload.data;
if (func.is_cold) {
try w.writeAll("ZIG_COLD ");
}
}
const return_ty = dg.decl.ty.fnReturnType();
if (return_ty.hasRuntimeBits()) {
try dg.renderType(w, return_ty);
} else if (return_ty.zigTypeTag() == .NoReturn) {
try w.writeAll("zig_noreturn void");
} else {
try w.writeAll("void");
}
try w.writeAll(" ");
try dg.renderDeclName(w, dg.decl);
try w.writeAll("(");
const param_len = dg.decl.ty.fnParamLen();
var index: usize = 0;
var params_written: usize = 0;
while (index < param_len) : (index += 1) {
const param_type = dg.decl.ty.fnParamType(index);
if (!param_type.hasRuntimeBitsIgnoreComptime()) continue;
if (params_written > 0) {
try w.writeAll(", ");
}
const name = CValue{ .arg = index };
try dg.renderTypeAndName(w, dg.decl.ty.fnParamType(index), name, .Mut, 0);
params_written += 1;
}
if (dg.decl.ty.fnIsVarArgs()) {
if (params_written != 0) try w.writeAll(", ");
try w.writeAll("...");
} else if (params_written == 0) {
try w.writeAll("void");
}
try w.writeByte(')');
}
fn renderPtrToFnTypedef(dg: *DeclGen, t: Type, fn_ty: Type) error{ OutOfMemory, AnalysisFail }![]const u8 {
var buffer = std.ArrayList(u8).init(dg.typedefs.allocator);
defer buffer.deinit();
const bw = buffer.writer();
const fn_info = fn_ty.fnInfo();
try bw.writeAll("typedef ");
try dg.renderType(bw, fn_info.return_type);
try bw.writeAll(" (*");
const name_start = buffer.items.len;
// TODO: typeToCIdentifier truncates to 128 bytes, we probably don't want to do this
try bw.print("zig_F_{s})(", .{typeToCIdentifier(t)});
const name_end = buffer.items.len - 2;
const param_len = fn_info.param_types.len;
var params_written: usize = 0;
var index: usize = 0;
while (index < param_len) : (index += 1) {
if (!fn_info.param_types[index].hasRuntimeBitsIgnoreComptime()) continue;
if (params_written > 0) {
try bw.writeAll(", ");
}
try dg.renderTypecast(bw, fn_info.param_types[index]);
params_written += 1;
}
if (fn_info.is_var_args) {
if (params_written != 0) try bw.writeAll(", ");
try bw.writeAll("...");
} else if (params_written == 0) {
try bw.writeAll("void");
}
try bw.writeAll(");\n");
const rendered = buffer.toOwnedSlice();
errdefer dg.typedefs.allocator.free(rendered);
const name = rendered[name_start..name_end];
try dg.typedefs.ensureUnusedCapacity(1);
dg.typedefs.putAssumeCapacityNoClobber(
try t.copy(dg.typedefs_arena),
.{ .name = name, .rendered = rendered },
);
return name;
}
fn renderSliceTypedef(dg: *DeclGen, t: Type) error{ OutOfMemory, AnalysisFail }![]const u8 {
var buffer = std.ArrayList(u8).init(dg.typedefs.allocator);
defer buffer.deinit();
const bw = buffer.writer();
try bw.writeAll("typedef struct { ");
var ptr_type_buf: Type.SlicePtrFieldTypeBuffer = undefined;
const ptr_type = t.slicePtrFieldType(&ptr_type_buf);
const ptr_name = CValue{ .bytes = "ptr" };
try dg.renderTypeAndName(bw, ptr_type, ptr_name, .Mut, 0);
const ptr_sentinel = ptr_type.ptrInfo().data.sentinel;
const child_type = t.childType();
try bw.writeAll("; size_t len; } ");
const name_index = buffer.items.len;
if (t.isConstPtr()) {
try bw.print("zig_L_{s}", .{typeToCIdentifier(child_type)});
} else {
try bw.print("zig_M_{s}", .{typeToCIdentifier(child_type)});
}
if (ptr_sentinel) |s| {
try bw.writeAll("_s_");
try dg.renderValue(bw, child_type, s);
}
try bw.writeAll(";\n");
const rendered = buffer.toOwnedSlice();
errdefer dg.typedefs.allocator.free(rendered);
const name = rendered[name_index .. rendered.len - 2];
try dg.typedefs.ensureUnusedCapacity(1);
dg.typedefs.putAssumeCapacityNoClobber(
try t.copy(dg.typedefs_arena),
.{ .name = name, .rendered = rendered },
);
return name;
}
fn renderStructTypedef(dg: *DeclGen, t: Type) error{ OutOfMemory, AnalysisFail }![]const u8 {
const struct_obj = t.castTag(.@"struct").?.data; // Handle 0 bit types elsewhere.
const fqn = try struct_obj.getFullyQualifiedName(dg.typedefs.allocator);
defer dg.typedefs.allocator.free(fqn);
var buffer = std.ArrayList(u8).init(dg.typedefs.allocator);
defer buffer.deinit();
try buffer.appendSlice("typedef struct {\n");
{
var it = struct_obj.fields.iterator();
while (it.next()) |entry| {
const field_ty = entry.value_ptr.ty;
if (!field_ty.hasRuntimeBits()) continue;
const alignment = entry.value_ptr.abi_align;
const name: CValue = .{ .identifier = entry.key_ptr.* };
try buffer.append(' ');
try dg.renderTypeAndName(buffer.writer(), field_ty, name, .Mut, alignment);
try buffer.appendSlice(";\n");
}
}
try buffer.appendSlice("} ");
const name_start = buffer.items.len;
try buffer.writer().print("zig_S_{};\n", .{fmtIdent(fqn)});
const rendered = buffer.toOwnedSlice();
errdefer dg.typedefs.allocator.free(rendered);
const name = rendered[name_start .. rendered.len - 2];
try dg.typedefs.ensureUnusedCapacity(1);
dg.typedefs.putAssumeCapacityNoClobber(
try t.copy(dg.typedefs_arena),
.{ .name = name, .rendered = rendered },
);
return name;
}
fn renderTupleTypedef(dg: *DeclGen, t: Type) error{ OutOfMemory, AnalysisFail }![]const u8 {
const tuple = t.tupleFields();
var buffer = std.ArrayList(u8).init(dg.typedefs.allocator);
defer buffer.deinit();
const writer = buffer.writer();
try buffer.appendSlice("typedef struct {\n");
{
for (tuple.types) |field_ty, i| {
const val = tuple.values[i];
if (val.tag() != .unreachable_value) continue;
var name = std.ArrayList(u8).init(dg.gpa);
defer name.deinit();
try name.writer().print("field_{d}", .{i});
try buffer.append(' ');
try dg.renderTypeAndName(writer, field_ty, .{ .bytes = name.items }, .Mut, 0);
try buffer.appendSlice(";\n");
}
}
try buffer.appendSlice("} ");
const name_start = buffer.items.len;
try writer.print("zig_T_{};\n", .{typeToCIdentifier(t)});
const rendered = buffer.toOwnedSlice();
errdefer dg.typedefs.allocator.free(rendered);
const name = rendered[name_start .. rendered.len - 2];
try dg.typedefs.ensureUnusedCapacity(1);
dg.typedefs.putAssumeCapacityNoClobber(
try t.copy(dg.typedefs_arena),
.{ .name = name, .rendered = rendered },
);
return name;
}
fn renderUnionTypedef(dg: *DeclGen, t: Type) error{ OutOfMemory, AnalysisFail }![]const u8 {
const union_ty = t.cast(Type.Payload.Union).?.data;
const fqn = try union_ty.getFullyQualifiedName(dg.typedefs.allocator);
defer dg.typedefs.allocator.free(fqn);
const target = dg.module.getTarget();
const layout = t.unionGetLayout(target);
var buffer = std.ArrayList(u8).init(dg.typedefs.allocator);
defer buffer.deinit();
try buffer.appendSlice("typedef ");
if (t.unionTagType()) |tag_ty| {
const name: CValue = .{ .bytes = "tag" };
try buffer.appendSlice("struct {\n ");
if (layout.tag_size != 0) {
try dg.renderTypeAndName(buffer.writer(), tag_ty, name, .Mut, 0);
try buffer.appendSlice(";\n");
}
}
try buffer.appendSlice("union {\n");
{
var it = t.unionFields().iterator();
while (it.next()) |entry| {
const field_ty = entry.value_ptr.ty;
if (!field_ty.hasRuntimeBits()) continue;
const alignment = entry.value_ptr.abi_align;
const name: CValue = .{ .identifier = entry.key_ptr.* };
try buffer.append(' ');
try dg.renderTypeAndName(buffer.writer(), field_ty, name, .Mut, alignment);
try buffer.appendSlice(";\n");
}
}
try buffer.appendSlice("} ");
if (t.unionTagType()) |_| {
try buffer.appendSlice("payload;\n} ");
}
const name_start = buffer.items.len;
try buffer.writer().print("zig_U_{};\n", .{fmtIdent(fqn)});
const rendered = buffer.toOwnedSlice();
errdefer dg.typedefs.allocator.free(rendered);
const name = rendered[name_start .. rendered.len - 2];
try dg.typedefs.ensureUnusedCapacity(1);
dg.typedefs.putAssumeCapacityNoClobber(
try t.copy(dg.typedefs_arena),
.{ .name = name, .rendered = rendered },
);
return name;
}
fn renderErrorUnionTypedef(dg: *DeclGen, t: Type) error{ OutOfMemory, AnalysisFail }![]const u8 {
const child_type = t.errorUnionPayload();
const err_set_type = t.errorUnionSet();
var buffer = std.ArrayList(u8).init(dg.typedefs.allocator);
defer buffer.deinit();
const bw = buffer.writer();
try bw.writeAll("typedef struct { ");
const payload_name = CValue{ .bytes = "payload" };
try dg.renderTypeAndName(bw, child_type, payload_name, .Mut, 0);
try bw.writeAll("; uint16_t error; } ");
const name_index = buffer.items.len;
if (err_set_type.castTag(.error_set_inferred)) |inf_err_set_payload| {
const func = inf_err_set_payload.data.func;
try bw.writeAll("zig_E_");
try dg.renderDeclName(bw, func.owner_decl);
try bw.writeAll(";\n");
} else {
try bw.print("zig_E_{s}_{s};\n", .{
typeToCIdentifier(err_set_type), typeToCIdentifier(child_type),
});
}
const rendered = buffer.toOwnedSlice();
errdefer dg.typedefs.allocator.free(rendered);
const name = rendered[name_index .. rendered.len - 2];
try dg.typedefs.ensureUnusedCapacity(1);
dg.typedefs.putAssumeCapacityNoClobber(
try t.copy(dg.typedefs_arena),
.{ .name = name, .rendered = rendered },
);
return name;
}
fn renderArrayTypedef(dg: *DeclGen, t: Type) error{ OutOfMemory, AnalysisFail }![]const u8 {
var buffer = std.ArrayList(u8).init(dg.typedefs.allocator);
defer buffer.deinit();
const bw = buffer.writer();
const elem_type = t.elemType();
const sentinel_bit = @boolToInt(t.sentinel() != null);
const c_len = t.arrayLen() + sentinel_bit;
try bw.writeAll("typedef ");
try dg.renderType(bw, elem_type);
const name_start = buffer.items.len + 1;
try bw.print(" zig_A_{s}_{d}", .{ typeToCIdentifier(elem_type), c_len });
const name_end = buffer.items.len;
try bw.print("[{d}];\n", .{c_len});
const rendered = buffer.toOwnedSlice();
errdefer dg.typedefs.allocator.free(rendered);
const name = rendered[name_start..name_end];
try dg.typedefs.ensureUnusedCapacity(1);
dg.typedefs.putAssumeCapacityNoClobber(
try t.copy(dg.typedefs_arena),
.{ .name = name, .rendered = rendered },
);
return name;
}
fn renderOptionalTypedef(dg: *DeclGen, t: Type, child_type: Type) error{ OutOfMemory, AnalysisFail }![]const u8 {
var buffer = std.ArrayList(u8).init(dg.typedefs.allocator);
defer buffer.deinit();
const bw = buffer.writer();
try bw.writeAll("typedef struct { ");
const payload_name = CValue{ .bytes = "payload" };
try dg.renderTypeAndName(bw, child_type, payload_name, .Mut, 0);
try bw.writeAll("; bool is_null; } ");
const name_index = buffer.items.len;
try bw.print("zig_Q_{s};\n", .{typeToCIdentifier(child_type)});
const rendered = buffer.toOwnedSlice();
errdefer dg.typedefs.allocator.free(rendered);
const name = rendered[name_index .. rendered.len - 2];
try dg.typedefs.ensureUnusedCapacity(1);
dg.typedefs.putAssumeCapacityNoClobber(
try t.copy(dg.typedefs_arena),
.{ .name = name, .rendered = rendered },
);
return name;
}
/// Renders a type as a single identifier, generating intermediate typedefs
/// if necessary.
///
/// This is guaranteed to be valid in both typedefs and declarations/definitions.
///
/// There are three type formats in total that we support rendering:
/// | Function | Example 1 (*u8) | Example 2 ([10]*u8) |
/// |---------------------|-----------------|---------------------|
/// | `renderTypecast` | "uint8_t *" | "uint8_t *[10]" |
/// | `renderTypeAndName` | "uint8_t *name" | "uint8_t *name[10]" |
/// | `renderType` | "uint8_t *" | "zig_A_uint8_t_10" |
///
fn renderType(dg: *DeclGen, w: anytype, t: Type) error{ OutOfMemory, AnalysisFail }!void {
const target = dg.module.getTarget();
switch (t.zigTypeTag()) {
.NoReturn, .Void => try w.writeAll("void"),
.Bool => try w.writeAll("bool"),
.Int => {
switch (t.tag()) {
.u1, .u8 => try w.writeAll("uint8_t"),
.i8 => try w.writeAll("int8_t"),
.u16 => try w.writeAll("uint16_t"),
.i16 => try w.writeAll("int16_t"),
.u32 => try w.writeAll("uint32_t"),
.i32 => try w.writeAll("int32_t"),
.u64 => try w.writeAll("uint64_t"),
.i64 => try w.writeAll("int64_t"),
.u128 => try w.writeAll("uint128_t"),
.i128 => try w.writeAll("int128_t"),
.usize => try w.writeAll("uintptr_t"),
.isize => try w.writeAll("intptr_t"),
.c_short => try w.writeAll("short"),
.c_ushort => try w.writeAll("unsigned short"),
.c_int => try w.writeAll("int"),
.c_uint => try w.writeAll("unsigned int"),
.c_long => try w.writeAll("long"),
.c_ulong => try w.writeAll("unsigned long"),
.c_longlong => try w.writeAll("long long"),
.c_ulonglong => try w.writeAll("unsigned long long"),
.int_signed, .int_unsigned => {
const info = t.intInfo(target);
const sign_prefix = switch (info.signedness) {
.signed => "",
.unsigned => "u",
};
const c_bits = toCIntBits(info.bits) orelse
return dg.fail("TODO: C backend: implement integer types larger than 128 bits", .{});
try w.print("{s}int{d}_t", .{ sign_prefix, c_bits });
},
else => unreachable,
}
},
.Float => {
switch (t.tag()) {
.f32 => try w.writeAll("float"),
.f64 => try w.writeAll("double"),
.c_longdouble => try w.writeAll("long double"),
.f16 => return dg.fail("TODO: C backend: implement float type f16", .{}),
.f128 => return dg.fail("TODO: C backend: implement float type f128", .{}),
else => unreachable,
}
},
.Pointer => {
if (t.isSlice()) {
const name = dg.getTypedefName(t) orelse
try dg.renderSliceTypedef(t);
return w.writeAll(name);
}
if (t.castPtrToFn()) |fn_ty| {
const name = dg.getTypedefName(t) orelse
try dg.renderPtrToFnTypedef(t, fn_ty);
return w.writeAll(name);
}
try dg.renderType(w, t.elemType());
if (t.isConstPtr()) {
try w.writeAll(" const");
}
if (t.isVolatilePtr()) {
try w.writeAll(" volatile");
}
return w.writeAll(" *");
},
.Array => {
const name = dg.getTypedefName(t) orelse
try dg.renderArrayTypedef(t);
return w.writeAll(name);
},
.Optional => {
var opt_buf: Type.Payload.ElemType = undefined;
const child_type = t.optionalChild(&opt_buf);
if (t.isPtrLikeOptional()) {
return dg.renderType(w, child_type);
}
if (child_type.abiSize(target) == 0) {
return w.writeAll("bool");
}
const name = dg.getTypedefName(t) orelse
try dg.renderOptionalTypedef(t, child_type);
return w.writeAll(name);
},
.ErrorSet => {
comptime std.debug.assert(Type.initTag(.anyerror).abiSize(builtin.target) == 2);
return w.writeAll("uint16_t");
},
.ErrorUnion => {
if (t.errorUnionPayload().abiSize(target) == 0) {
return dg.renderType(w, t.errorUnionSet());
}
const name = dg.getTypedefName(t) orelse
try dg.renderErrorUnionTypedef(t);
return w.writeAll(name);
},
.Struct => {
const name = dg.getTypedefName(t) orelse if (t.isTuple())
try dg.renderTupleTypedef(t)
else
try dg.renderStructTypedef(t);
return w.writeAll(name);
},
.Union => {
const name = dg.getTypedefName(t) orelse
try dg.renderUnionTypedef(t);
return w.writeAll(name);
},
.Enum => {
// For enums, we simply use the integer tag type.
var int_tag_ty_buffer: Type.Payload.Bits = undefined;
const int_tag_ty = t.intTagType(&int_tag_ty_buffer);
try dg.renderType(w, int_tag_ty);
},
.Frame,
.AnyFrame,
.Vector,
.Opaque,
=> |tag| return dg.fail("TODO: C backend: implement value of type {s}", .{
@tagName(tag),
}),
.Fn => unreachable, // This is a function body, not a function pointer.
.Null,
.Undefined,
.EnumLiteral,
.ComptimeFloat,
.ComptimeInt,
.Type,
=> unreachable, // must be const or comptime
.BoundFn => unreachable, // this type will be deleted from the language
}
}
/// Renders a type in C typecast format.
///
/// This is guaranteed to be valid in a typecast expression, but not
/// necessarily in a variable/field declaration.
///
/// There are three type formats in total that we support rendering:
/// | Function | Example 1 (*u8) | Example 2 ([10]*u8) |
/// |---------------------|-----------------|---------------------|
/// | `renderTypecast` | "uint8_t *" | "uint8_t *[10]" |
/// | `renderTypeAndName` | "uint8_t *name" | "uint8_t *name[10]" |
/// | `renderType` | "uint8_t *" | "zig_A_uint8_t_10" |
///
fn renderTypecast(
dg: *DeclGen,
w: anytype,
ty: Type,
) error{ OutOfMemory, AnalysisFail }!void {
const name = CValue{ .bytes = "" };
return renderTypeAndName(dg, w, ty, name, .Mut, 0);
}
/// Renders a type and name in field declaration/definition format.
///
/// There are three type formats in total that we support rendering:
/// | Function | Example 1 (*u8) | Example 2 ([10]*u8) |
/// |---------------------|-----------------|---------------------|
/// | `renderTypecast` | "uint8_t *" | "uint8_t *[10]" |
/// | `renderTypeAndName` | "uint8_t *name" | "uint8_t *name[10]" |
/// | `renderType` | "uint8_t *" | "zig_A_uint8_t_10" |
///
fn renderTypeAndName(
dg: *DeclGen,
w: anytype,
ty: Type,
name: CValue,
mutability: Mutability,
alignment: u32,
) error{ OutOfMemory, AnalysisFail }!void {
var suffix = std.ArrayList(u8).init(dg.gpa);
defer suffix.deinit();
// Any top-level array types are rendered here as a suffix, which
// avoids creating typedefs for every array type
var render_ty = ty;
while (render_ty.zigTypeTag() == .Array) {
const sentinel_bit = @boolToInt(render_ty.sentinel() != null);
const c_len = render_ty.arrayLen() + sentinel_bit;
try suffix.writer().print("[{d}]", .{c_len});
render_ty = render_ty.elemType();
}
if (alignment != 0)
try w.print("ZIG_ALIGN({}) ", .{alignment});
try dg.renderType(w, render_ty);
const const_prefix = switch (mutability) {
.Const => "const ",
.Mut => "",
};
try w.print(" {s}", .{const_prefix});
try dg.writeCValue(w, name);
try w.writeAll(suffix.items);
}
fn declIsGlobal(dg: *DeclGen, tv: TypedValue) bool {
switch (tv.val.tag()) {
.extern_fn => return true,
.function => {
const func = tv.val.castTag(.function).?.data;
return dg.module.decl_exports.contains(func.owner_decl);
},
.variable => {
const variable = tv.val.castTag(.variable).?.data;
return dg.module.decl_exports.contains(variable.owner_decl);
},
else => unreachable,
}
}
fn writeCValue(dg: DeclGen, w: anytype, c_value: CValue) !void {
switch (c_value) {
.none => unreachable,
.local => |i| return w.print("t{d}", .{i}),
.local_ref => |i| return w.print("&t{d}", .{i}),
.constant => unreachable,
.arg => |i| return w.print("a{d}", .{i}),
.decl => |decl| return dg.renderDeclName(w, decl),
.decl_ref => |decl| {
try w.writeByte('&');
return dg.renderDeclName(w, decl);
},
.undefined_ptr => {
const target = dg.module.getTarget();
switch (target.cpu.arch.ptrBitWidth()) {
32 => try w.writeAll("(void *)0xaaaaaaaa"),
64 => try w.writeAll("(void *)0xaaaaaaaaaaaaaaaa"),
else => unreachable,
}
},
.identifier => |ident| return w.print("{ }", .{fmtIdent(ident)}),
.bytes => |bytes| return w.writeAll(bytes),
}
}
fn writeCValueDeref(dg: DeclGen, w: anytype, c_value: CValue) !void {
switch (c_value) {
.none => unreachable,
.local => |i| return w.print("(*t{d})", .{i}),
.local_ref => |i| return w.print("t{d}", .{i}),
.constant => unreachable,
.arg => |i| return w.print("(*a{d})", .{i}),
.decl => |decl| {
try w.writeAll("(*");
try dg.renderDeclName(w, decl);
return w.writeByte(')');
},
.decl_ref => |decl| return dg.renderDeclName(w, decl),
.undefined_ptr => unreachable,
.identifier => |ident| return w.print("(*{ })", .{fmtIdent(ident)}),
.bytes => |bytes| {
try w.writeAll("(*");
try w.writeAll(bytes);
return w.writeByte(')');
},
}
}
fn renderDeclName(dg: DeclGen, writer: anytype, decl: *Decl) !void {
if (dg.module.decl_exports.get(decl)) |exports| {
return writer.writeAll(exports[0].options.name);
} else if (decl.val.tag() == .extern_fn) {
return writer.writeAll(mem.sliceTo(decl.name, 0));
} else {
const gpa = dg.module.gpa;
const name = try decl.getFullyQualifiedName(gpa);
defer gpa.free(name);
return writer.print("{ }", .{fmtIdent(name)});
}
}
};
pub fn genFunc(f: *Function) !void {
const tracy = trace(@src());
defer tracy.end();
const o = &f.object;
o.code_header = std.ArrayList(u8).init(f.object.dg.gpa);
defer o.code_header.deinit();
const is_global = o.dg.module.decl_exports.contains(f.func.owner_decl);
const fwd_decl_writer = o.dg.fwd_decl.writer();
if (is_global) {
try fwd_decl_writer.writeAll("ZIG_EXTERN_C ");
}
try o.dg.renderFunctionSignature(fwd_decl_writer, is_global);
try fwd_decl_writer.writeAll(";\n");
try o.indent_writer.insertNewline();
try o.dg.renderFunctionSignature(o.writer(), is_global);
try o.writer().writeByte(' ');
// In case we need to use the header, populate it with a copy of the function
// signature here. We anticipate a brace, newline, and space.
try o.code_header.ensureUnusedCapacity(o.code.items.len + 3);
o.code_header.appendSliceAssumeCapacity(o.code.items);
o.code_header.appendSliceAssumeCapacity("{\n ");
const empty_header_len = o.code_header.items.len;
const main_body = f.air.getMainBody();
try genBody(f, main_body);
try o.indent_writer.insertNewline();
// If we have a header to insert, append the body to the header
// and then return the result, freeing the body.
if (o.code_header.items.len > empty_header_len) {
try o.code_header.appendSlice(o.code.items[empty_header_len..]);
mem.swap(std.ArrayList(u8), &o.code, &o.code_header);
}
}
pub fn genDecl(o: *Object) !void {
const tracy = trace(@src());
defer tracy.end();
const tv: TypedValue = .{
.ty = o.dg.decl.ty,
.val = o.dg.decl.val,
};
if (tv.val.tag() == .extern_fn) {
const writer = o.writer();
try writer.writeAll("ZIG_EXTERN_C ");
try o.dg.renderFunctionSignature(writer, true);
try writer.writeAll(";\n");
} else if (tv.val.castTag(.variable)) |var_payload| {
const variable: *Module.Var = var_payload.data;
const is_global = o.dg.declIsGlobal(tv) or variable.is_extern;
const fwd_decl_writer = o.dg.fwd_decl.writer();
if (is_global) {
try fwd_decl_writer.writeAll("ZIG_EXTERN_C ");
}
if (variable.is_threadlocal) {
try fwd_decl_writer.writeAll("zig_threadlocal ");
}
const decl_c_value: CValue = if (is_global) .{ .bytes = mem.span(o.dg.decl.name) } else .{ .decl = o.dg.decl };
try o.dg.renderTypeAndName(fwd_decl_writer, o.dg.decl.ty, decl_c_value, .Mut, o.dg.decl.@"align");
try fwd_decl_writer.writeAll(";\n");
if (variable.init.isUndefDeep()) {
return;
}
try o.indent_writer.insertNewline();
const w = o.writer();
try o.dg.renderTypeAndName(w, o.dg.decl.ty, decl_c_value, .Mut, o.dg.decl.@"align");
try w.writeAll(" = ");
if (variable.init.tag() != .unreachable_value) {
try o.dg.renderValue(w, tv.ty, variable.init);
}
try w.writeAll(";");
try o.indent_writer.insertNewline();
} else {
const writer = o.writer();
try writer.writeAll("static ");
// TODO ask the Decl if it is const
// https://github.com/ziglang/zig/issues/7582
const decl_c_value: CValue = .{ .decl = o.dg.decl };
try o.dg.renderTypeAndName(writer, tv.ty, decl_c_value, .Mut, o.dg.decl.@"align");
try writer.writeAll(" = ");
try o.dg.renderValue(writer, tv.ty, tv.val);
try writer.writeAll(";\n");
}
}
pub fn genHeader(dg: *DeclGen) error{ AnalysisFail, OutOfMemory }!void {
const tracy = trace(@src());
defer tracy.end();
const tv: TypedValue = .{
.ty = dg.decl.ty,
.val = dg.decl.val,
};
const writer = dg.fwd_decl.writer();
switch (tv.ty.zigTypeTag()) {
.Fn => {
const is_global = dg.declIsGlobal(tv);
if (is_global) {
try writer.writeAll("ZIG_EXTERN_C ");
try dg.renderFunctionSignature(writer, is_global);
try dg.fwd_decl.appendSlice(";\n");
}
},
else => {},
}
}
fn genBody(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, OutOfMemory }!void {
const writer = f.object.writer();
if (body.len == 0) {
try writer.writeAll("{}");
return;
}
try writer.writeAll("{\n");
f.object.indent_writer.pushIndent();
const air_tags = f.air.instructions.items(.tag);
for (body) |inst| {
const result_value = switch (air_tags[inst]) {
// zig fmt: off
.constant => unreachable, // excluded from function bodies
.const_ty => unreachable, // excluded from function bodies
.arg => airArg(f),
.breakpoint => try airBreakpoint(f),
.ret_addr => try airRetAddr(f, inst),
.frame_addr => try airFrameAddress(f, inst),
.unreach => try airUnreach(f),
.fence => try airFence(f, inst),
// TODO use a different strategy for add that communicates to the optimizer
// that wrapping is UB.
.add => try airBinOp (f, inst, " + "),
.ptr_add => try airPtrAddSub (f, inst, " + "),
// TODO use a different strategy for sub that communicates to the optimizer
// that wrapping is UB.
.sub => try airBinOp (f, inst, " - "),
.ptr_sub => try airPtrAddSub (f, inst, " - "),
// TODO use a different strategy for mul that communicates to the optimizer
// that wrapping is UB.
.mul => try airBinOp (f, inst, " * "),
// TODO use a different strategy for div that communicates to the optimizer
// that wrapping is UB.
.div_float, .div_exact => try airBinOp( f, inst, " / "),
.div_trunc => blk: {
const bin_op = f.air.instructions.items(.data)[inst].bin_op;
const lhs_ty = f.air.typeOf(bin_op.lhs);
// For binary operations @TypeOf(lhs)==@TypeOf(rhs),
// so we only check one.
break :blk if (lhs_ty.isInt())
try airBinOp(f, inst, " / ")
else
try airBinOpBuiltinCall(f, inst, "div_trunc");
},
.div_floor => try airBinOpBuiltinCall(f, inst, "div_floor"),
.rem => try airBinOp( f, inst, " % "),
.mod => try airBinOpBuiltinCall(f, inst, "mod"),
.addwrap => try airWrapOp(f, inst, " + ", "addw_"),
.subwrap => try airWrapOp(f, inst, " - ", "subw_"),
.mulwrap => try airWrapOp(f, inst, " * ", "mulw_"),
.add_sat => try airSatOp(f, inst, "adds_"),
.sub_sat => try airSatOp(f, inst, "subs_"),
.mul_sat => try airSatOp(f, inst, "muls_"),
.shl_sat => try airSatOp(f, inst, "shls_"),
.sqrt,
.sin,
.cos,
.exp,
.exp2,
.log,
.log2,
.log10,
.fabs,
.floor,
.ceil,
.round,
.trunc_float,
=> |tag| return f.fail("TODO: C backend: implement unary op for tag '{s}'", .{@tagName(tag)}),
.mul_add => try airMulAdd(f, inst),
.add_with_overflow => try airAddWithOverflow(f, inst),
.sub_with_overflow => try airSubWithOverflow(f, inst),
.mul_with_overflow => try airMulWithOverflow(f, inst),
.shl_with_overflow => try airShlWithOverflow(f, inst),
.min => try airMinMax(f, inst, "<"),
.max => try airMinMax(f, inst, ">"),
.slice => try airSlice(f, inst),
.cmp_gt => try airBinOp(f, inst, " > "),
.cmp_gte => try airBinOp(f, inst, " >= "),
.cmp_lt => try airBinOp(f, inst, " < "),
.cmp_lte => try airBinOp(f, inst, " <= "),
.cmp_eq => try airEquality(f, inst, "((", "=="),
.cmp_neq => try airEquality(f, inst, "!((", "!="),
// bool_and and bool_or are non-short-circuit operations
.bool_and => try airBinOp(f, inst, " & "),
.bool_or => try airBinOp(f, inst, " | "),
.bit_and => try airBinOp(f, inst, " & "),
.bit_or => try airBinOp(f, inst, " | "),
.xor => try airBinOp(f, inst, " ^ "),
.shr, .shr_exact => try airBinOp(f, inst, " >> "),
.shl, .shl_exact => try airBinOp(f, inst, " << "),
.not => try airNot (f, inst),
.optional_payload => try airOptionalPayload(f, inst),
.optional_payload_ptr => try airOptionalPayload(f, inst),
.optional_payload_ptr_set => try airOptionalPayloadPtrSet(f, inst),
.is_err => try airIsErr(f, inst, false, "!="),
.is_non_err => try airIsErr(f, inst, false, "=="),
.is_err_ptr => try airIsErr(f, inst, true, "!="),
.is_non_err_ptr => try airIsErr(f, inst, true, "=="),
.is_null => try airIsNull(f, inst, "==", ""),
.is_non_null => try airIsNull(f, inst, "!=", ""),
.is_null_ptr => try airIsNull(f, inst, "==", "[0]"),
.is_non_null_ptr => try airIsNull(f, inst, "!=", "[0]"),
.alloc => try airAlloc(f, inst),
.ret_ptr => try airRetPtr(f, inst),
.assembly => try airAsm(f, inst),
.block => try airBlock(f, inst),
.bitcast => try airBitcast(f, inst),
.dbg_stmt => try airDbgStmt(f, inst),
.intcast => try airIntCast(f, inst),
.trunc => try airTrunc(f, inst),
.bool_to_int => try airBoolToInt(f, inst),
.load => try airLoad(f, inst),
.ret => try airRet(f, inst),
.ret_load => try airRetLoad(f, inst),
.store => try airStore(f, inst),
.loop => try airLoop(f, inst),
.cond_br => try airCondBr(f, inst),
.br => try airBr(f, inst),
.switch_br => try airSwitchBr(f, inst),
.wrap_optional => try airWrapOptional(f, inst),
.struct_field_ptr => try airStructFieldPtr(f, inst),
.array_to_slice => try airArrayToSlice(f, inst),
.cmpxchg_weak => try airCmpxchg(f, inst, "weak"),
.cmpxchg_strong => try airCmpxchg(f, inst, "strong"),
.atomic_rmw => try airAtomicRmw(f, inst),
.atomic_load => try airAtomicLoad(f, inst),
.memset => try airMemset(f, inst),
.memcpy => try airMemcpy(f, inst),
.set_union_tag => try airSetUnionTag(f, inst),
.get_union_tag => try airGetUnionTag(f, inst),
.clz => try airBuiltinCall(f, inst, "clz"),
.ctz => try airBuiltinCall(f, inst, "ctz"),
.popcount => try airBuiltinCall(f, inst, "popcount"),
.byte_swap => try airBuiltinCall(f, inst, "byte_swap"),
.bit_reverse => try airBuiltinCall(f, inst, "bit_reverse"),
.tag_name => try airTagName(f, inst),
.error_name => try airErrorName(f, inst),
.splat => try airSplat(f, inst),
.shuffle => try airShuffle(f, inst),
.reduce => try airReduce(f, inst),
.aggregate_init => try airAggregateInit(f, inst),
.union_init => try airUnionInit(f, inst),
.prefetch => try airPrefetch(f, inst),
.dbg_var_ptr,
.dbg_var_val,
=> try airDbgVar(f, inst),
.dbg_inline_begin,
.dbg_inline_end,
=> try airDbgInline(f, inst),
.dbg_block_begin,
.dbg_block_end,
=> CValue{ .none = {} },
.call => try airCall(f, inst, .auto),
.call_always_tail => try airCall(f, inst, .always_tail),
.call_never_tail => try airCall(f, inst, .never_tail),
.call_never_inline => try airCall(f, inst, .never_inline),
.int_to_float,
.float_to_int,
.fptrunc,
.fpext,
=> try airSimpleCast(f, inst),
.ptrtoint => try airPtrToInt(f, inst),
.atomic_store_unordered => try airAtomicStore(f, inst, toMemoryOrder(.Unordered)),
.atomic_store_monotonic => try airAtomicStore(f, inst, toMemoryOrder(.Monotonic)),
.atomic_store_release => try airAtomicStore(f, inst, toMemoryOrder(.Release)),
.atomic_store_seq_cst => try airAtomicStore(f, inst, toMemoryOrder(.SeqCst)),
.struct_field_ptr_index_0 => try airStructFieldPtrIndex(f, inst, 0),
.struct_field_ptr_index_1 => try airStructFieldPtrIndex(f, inst, 1),
.struct_field_ptr_index_2 => try airStructFieldPtrIndex(f, inst, 2),
.struct_field_ptr_index_3 => try airStructFieldPtrIndex(f, inst, 3),
.field_parent_ptr => try airFieldParentPtr(f, inst),
.struct_field_val => try airStructFieldVal(f, inst),
.slice_ptr => try airSliceField(f, inst, ".ptr;\n"),
.slice_len => try airSliceField(f, inst, ".len;\n"),
.ptr_slice_len_ptr => try airPtrSliceFieldPtr(f, inst, ".len;\n"),
.ptr_slice_ptr_ptr => try airPtrSliceFieldPtr(f, inst, ".ptr;\n"),
.ptr_elem_val => try airPtrElemVal(f, inst),
.ptr_elem_ptr => try airPtrElemPtr(f, inst),
.slice_elem_val => try airSliceElemVal(f, inst),
.slice_elem_ptr => try airSliceElemPtr(f, inst),
.array_elem_val => try airArrayElemVal(f, inst),
.unwrap_errunion_payload => try airUnwrapErrUnionPay(f, inst, ""),
.unwrap_errunion_err => try airUnwrapErrUnionErr(f, inst),
.unwrap_errunion_payload_ptr => try airUnwrapErrUnionPay(f, inst, "&"),
.unwrap_errunion_err_ptr => try airUnwrapErrUnionErr(f, inst),
.wrap_errunion_payload => try airWrapErrUnionPay(f, inst),
.wrap_errunion_err => try airWrapErrUnionErr(f, inst),
.errunion_payload_ptr_set => try airErrUnionPayloadPtrSet(f, inst),
.wasm_memory_size => try airWasmMemorySize(f, inst),
.wasm_memory_grow => try airWasmMemoryGrow(f, inst),
// zig fmt: on
};
switch (result_value) {
.none => {},
else => try f.value_map.putNoClobber(Air.indexToRef(inst), result_value),
}
}
f.object.indent_writer.popIndent();
try writer.writeAll("}");
}
fn airSliceField(f: *Function, inst: Air.Inst.Index, suffix: []const u8) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const inst_ty = f.air.typeOfIndex(inst);
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const operand = try f.resolveInst(ty_op.operand);
const writer = f.object.writer();
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = ");
try f.writeCValue(writer, operand);
try writer.writeAll(suffix);
return local;
}
fn airPtrSliceFieldPtr(f: *Function, inst: Air.Inst.Index, suffix: []const u8) !CValue {
if (f.liveness.isUnused(inst))
return CValue.none;
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const operand = try f.resolveInst(ty_op.operand);
const writer = f.object.writer();
_ = writer;
_ = operand;
_ = suffix;
return f.fail("TODO: C backend: airPtrSliceFieldPtr", .{});
}
fn airPtrElemVal(f: *Function, inst: Air.Inst.Index) !CValue {
const bin_op = f.air.instructions.items(.data)[inst].bin_op;
const ptr_ty = f.air.typeOf(bin_op.lhs);
if (!ptr_ty.isVolatilePtr() and f.liveness.isUnused(inst)) return CValue.none;
const ptr = try f.resolveInst(bin_op.lhs);
const index = try f.resolveInst(bin_op.rhs);
const writer = f.object.writer();
const local = try f.allocLocal(f.air.typeOfIndex(inst), .Const);
try writer.writeAll(" = ");
try f.writeCValue(writer, ptr);
try writer.writeByte('[');
try f.writeCValue(writer, index);
try writer.writeAll("];\n");
return local;
}
fn airPtrElemPtr(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const ty_pl = f.air.instructions.items(.data)[inst].ty_pl;
const bin_op = f.air.extraData(Air.Bin, ty_pl.payload).data;
const ptr_ty = f.air.typeOf(bin_op.lhs);
const ptr = try f.resolveInst(bin_op.lhs);
const index = try f.resolveInst(bin_op.rhs);
const writer = f.object.writer();
const local = try f.allocLocal(f.air.typeOfIndex(inst), .Const);
try writer.writeAll(" = &(");
if (ptr_ty.ptrSize() == .One) {
// It's a pointer to an array, so we need to de-reference.
try f.writeCValueDeref(writer, ptr);
} else {
try f.writeCValue(writer, ptr);
}
try writer.writeAll(")[");
try f.writeCValue(writer, index);
try writer.writeAll("];\n");
return local;
}
fn airSliceElemVal(f: *Function, inst: Air.Inst.Index) !CValue {
const bin_op = f.air.instructions.items(.data)[inst].bin_op;
const slice_ty = f.air.typeOf(bin_op.lhs);
if (!slice_ty.isVolatilePtr() and f.liveness.isUnused(inst)) return CValue.none;
const slice = try f.resolveInst(bin_op.lhs);
const index = try f.resolveInst(bin_op.rhs);
const writer = f.object.writer();
const local = try f.allocLocal(f.air.typeOfIndex(inst), .Const);
try writer.writeAll(" = ");
try f.writeCValue(writer, slice);
try writer.writeAll(".ptr[");
try f.writeCValue(writer, index);
try writer.writeAll("];\n");
return local;
}
fn airSliceElemPtr(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const ty_pl = f.air.instructions.items(.data)[inst].ty_pl;
const bin_op = f.air.extraData(Air.Bin, ty_pl.payload).data;
const slice = try f.resolveInst(bin_op.lhs);
const index = try f.resolveInst(bin_op.rhs);
const writer = f.object.writer();
const local = try f.allocLocal(f.air.typeOfIndex(inst), .Const);
try writer.writeAll(" = &");
try f.writeCValue(writer, slice);
try writer.writeAll(".ptr[");
try f.writeCValue(writer, index);
try writer.writeAll("];\n");
return local;
}
fn airArrayElemVal(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const bin_op = f.air.instructions.items(.data)[inst].bin_op;
const array = try f.resolveInst(bin_op.lhs);
const index = try f.resolveInst(bin_op.rhs);
const writer = f.object.writer();
const local = try f.allocLocal(f.air.typeOfIndex(inst), .Const);
try writer.writeAll(" = ");
try f.writeCValue(writer, array);
try writer.writeAll("[");
try f.writeCValue(writer, index);
try writer.writeAll("];\n");
return local;
}
fn airAlloc(f: *Function, inst: Air.Inst.Index) !CValue {
const writer = f.object.writer();
const inst_ty = f.air.typeOfIndex(inst);
const elem_type = inst_ty.elemType();
const mutability: Mutability = if (inst_ty.isConstPtr()) .Const else .Mut;
if (!elem_type.isFnOrHasRuntimeBitsIgnoreComptime()) {
return CValue.undefined_ptr;
}
const target = f.object.dg.module.getTarget();
// First line: the variable used as data storage.
const local = try f.allocAlignedLocal(elem_type, mutability, inst_ty.ptrAlignment(target));
try writer.writeAll(";\n");
return CValue{ .local_ref = local.local };
}
fn airRetPtr(f: *Function, inst: Air.Inst.Index) !CValue {
const writer = f.object.writer();
const inst_ty = f.air.typeOfIndex(inst);
// First line: the variable used as data storage.
const elem_type = inst_ty.elemType();
const local = try f.allocLocal(elem_type, .Mut);
try writer.writeAll(";\n");
return CValue{ .local_ref = local.local };
}
fn airArg(f: *Function) CValue {
const i = f.next_arg_index;
f.next_arg_index += 1;
return .{ .arg = i };
}
fn airLoad(f: *Function, inst: Air.Inst.Index) !CValue {
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const is_volatile = f.air.typeOf(ty_op.operand).isVolatilePtr();
if (!is_volatile and f.liveness.isUnused(inst))
return CValue.none;
const inst_ty = f.air.typeOfIndex(inst);
const is_array = inst_ty.zigTypeTag() == .Array;
const operand = try f.resolveInst(ty_op.operand);
const writer = f.object.writer();
// We need to separately initialize arrays with a memcpy so they must be mutable.
const local = try f.allocLocal(inst_ty, if (is_array) .Mut else .Const);
if (is_array) {
// Insert a memcpy to initialize this array. The source operand is always a pointer
// and thus we only need to know size/type information from the local type/dest.
try writer.writeAll(";");
try f.object.indent_writer.insertNewline();
try writer.writeAll("memcpy(");
try f.writeCValue(writer, local);
try writer.writeAll(", ");
try f.writeCValue(writer, operand);
try writer.writeAll(", sizeof(");
try f.writeCValue(writer, local);
try writer.writeAll("));\n");
} else {
try writer.writeAll(" = ");
try f.writeCValueDeref(writer, operand);
try writer.writeAll(";\n");
}
return local;
}
fn airRet(f: *Function, inst: Air.Inst.Index) !CValue {
const un_op = f.air.instructions.items(.data)[inst].un_op;
const writer = f.object.writer();
if (f.air.typeOf(un_op).isFnOrHasRuntimeBitsIgnoreComptime()) {
const operand = try f.resolveInst(un_op);
try writer.writeAll("return ");
try f.writeCValue(writer, operand);
try writer.writeAll(";\n");
} else {
try writer.writeAll("return;\n");
}
return CValue.none;
}
fn airRetLoad(f: *Function, inst: Air.Inst.Index) !CValue {
const un_op = f.air.instructions.items(.data)[inst].un_op;
const writer = f.object.writer();
const ptr_ty = f.air.typeOf(un_op);
const ret_ty = ptr_ty.childType();
if (!ret_ty.isFnOrHasRuntimeBitsIgnoreComptime()) {
try writer.writeAll("return;\n");
}
const ptr = try f.resolveInst(un_op);
try writer.writeAll("return *");
try f.writeCValue(writer, ptr);
try writer.writeAll(";\n");
return CValue.none;
}
fn airIntCast(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst))
return CValue.none;
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const operand = try f.resolveInst(ty_op.operand);
const writer = f.object.writer();
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = (");
try f.renderTypecast(writer, inst_ty);
try writer.writeAll(")");
try f.writeCValue(writer, operand);
try writer.writeAll(";\n");
return local;
}
fn airTrunc(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const writer = f.object.writer();
const operand = try f.resolveInst(ty_op.operand);
const target = f.object.dg.module.getTarget();
const dest_int_info = inst_ty.intInfo(target);
const dest_bits = dest_int_info.bits;
try writer.writeAll(" = ");
if (dest_bits >= 8 and std.math.isPowerOfTwo(dest_bits)) {
try f.writeCValue(writer, operand);
try writer.writeAll(";\n");
return local;
}
switch (dest_int_info.signedness) {
.unsigned => {
try f.writeCValue(writer, operand);
const mask = (@as(u65, 1) << @intCast(u7, dest_bits)) - 1;
try writer.print(" & {d}ULL;\n", .{mask});
return local;
},
.signed => {
const operand_ty = f.air.typeOf(ty_op.operand);
const c_bits = toCIntBits(operand_ty.intInfo(target).bits) orelse
return f.fail("TODO: C backend: implement integer types larger than 128 bits", .{});
const shift_rhs = c_bits - dest_bits;
try writer.print("(int{d}_t)((uint{d}_t)", .{ c_bits, c_bits });
try f.writeCValue(writer, operand);
try writer.print(" << {d}) >> {d};\n", .{ shift_rhs, shift_rhs });
return local;
},
}
}
fn airBoolToInt(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst))
return CValue.none;
const un_op = f.air.instructions.items(.data)[inst].un_op;
const writer = f.object.writer();
const inst_ty = f.air.typeOfIndex(inst);
const operand = try f.resolveInst(un_op);
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = ");
try f.writeCValue(writer, operand);
try writer.writeAll(";\n");
return local;
}
fn airStoreUndefined(f: *Function, dest_ptr: CValue) !CValue {
const is_debug_build = f.object.dg.module.optimizeMode() == .Debug;
if (!is_debug_build)
return CValue.none;
const writer = f.object.writer();
try writer.writeAll("memset(");
try f.writeCValue(writer, dest_ptr);
try writer.writeAll(", 0xaa, sizeof(");
try f.writeCValueDeref(writer, dest_ptr);
try writer.writeAll("));\n");
return CValue.none;
}
fn airStore(f: *Function, inst: Air.Inst.Index) !CValue {
// *a = b;
const bin_op = f.air.instructions.items(.data)[inst].bin_op;
const dest_ptr = try f.resolveInst(bin_op.lhs);
const src_val = try f.resolveInst(bin_op.rhs);
const lhs_child_type = f.air.typeOf(bin_op.lhs).childType();
// TODO Sema should emit a different instruction when the store should
// possibly do the safety 0xaa bytes for undefined.
const src_val_is_undefined =
if (f.air.value(bin_op.rhs)) |v| v.isUndefDeep() else false;
if (src_val_is_undefined)
return try airStoreUndefined(f, dest_ptr);
const writer = f.object.writer();
if (lhs_child_type.zigTypeTag() == .Array) {
// For this memcpy to safely work we need the rhs to have the same
// underlying type as the lhs (i.e. they must both be arrays of the same underlying type).
const rhs_type = f.air.typeOf(bin_op.rhs);
assert(rhs_type.eql(lhs_child_type));
// If the source is a constant, writeCValue will emit a brace initialization
// so work around this by initializing into new local.
// TODO this should be done by manually initializing elements of the dest array
const array_src = if (src_val == .constant) blk: {
const new_local = try f.allocLocal(rhs_type, .Const);
try writer.writeAll(" = ");
try f.writeCValue(writer, src_val);
try writer.writeAll(";");
try f.object.indent_writer.insertNewline();
break :blk new_local;
} else src_val;
try writer.writeAll("memcpy(");
try f.writeCValue(writer, dest_ptr);
try writer.writeAll(", ");
try f.writeCValue(writer, array_src);
try writer.writeAll(", sizeof(");
try f.writeCValue(writer, array_src);
try writer.writeAll("));\n");
} else {
try f.writeCValueDeref(writer, dest_ptr);
try writer.writeAll(" = ");
try f.writeCValue(writer, src_val);
try writer.writeAll(";\n");
}
return CValue.none;
}
fn airWrapOp(
f: *Function,
inst: Air.Inst.Index,
str_op: [*:0]const u8,
fn_op: [*:0]const u8,
) !CValue {
if (f.liveness.isUnused(inst))
return CValue.none;
const bin_op = f.air.instructions.items(.data)[inst].bin_op;
const inst_ty = f.air.typeOfIndex(inst);
const int_info = inst_ty.intInfo(f.object.dg.module.getTarget());
const bits = int_info.bits;
// if it's an unsigned int with non-arbitrary bit size then we can just add
if (int_info.signedness == .unsigned) {
const ok_bits = switch (bits) {
8, 16, 32, 64, 128 => true,
else => false,
};
if (ok_bits or inst_ty.tag() != .int_unsigned) {
return try airBinOp(f, inst, str_op);
}
}
if (bits > 64) {
return f.fail("TODO: C backend: airWrapOp for large integers", .{});
}
var min_buf: [80]u8 = undefined;
const min = switch (int_info.signedness) {
.unsigned => "0",
else => switch (inst_ty.tag()) {
.c_short => "SHRT_MIN",
.c_int => "INT_MIN",
.c_long => "LONG_MIN",
.c_longlong => "LLONG_MIN",
.isize => "INTPTR_MIN",
else => blk: {
const val = -1 * std.math.pow(i64, 2, @intCast(i64, bits - 1));
break :blk std.fmt.bufPrint(&min_buf, "{d}", .{val}) catch |err| switch (err) {
error.NoSpaceLeft => unreachable,
else => |e| return e,
};
},
},
};
var max_buf: [80]u8 = undefined;
const max = switch (inst_ty.tag()) {
.c_short => "SHRT_MAX",
.c_ushort => "USHRT_MAX",
.c_int => "INT_MAX",
.c_uint => "UINT_MAX",
.c_long => "LONG_MAX",
.c_ulong => "ULONG_MAX",
.c_longlong => "LLONG_MAX",
.c_ulonglong => "ULLONG_MAX",
.isize => "INTPTR_MAX",
.usize => "UINTPTR_MAX",
else => blk: {
const pow_bits = switch (int_info.signedness) {
.signed => bits - 1,
.unsigned => bits,
};
const val = std.math.pow(u64, 2, pow_bits) - 1;
break :blk std.fmt.bufPrint(&max_buf, "{}", .{val}) catch |err| switch (err) {
error.NoSpaceLeft => unreachable,
else => |e| return e,
};
},
};
const lhs = try f.resolveInst(bin_op.lhs);
const rhs = try f.resolveInst(bin_op.rhs);
const w = f.object.writer();
const ret = try f.allocLocal(inst_ty, .Mut);
try w.print(" = zig_{s}", .{fn_op});
switch (inst_ty.tag()) {
.isize => try w.writeAll("isize"),
.c_short => try w.writeAll("short"),
.c_int => try w.writeAll("int"),
.c_long => try w.writeAll("long"),
.c_longlong => try w.writeAll("longlong"),
else => {
const prefix_byte: u8 = switch (int_info.signedness) {
.signed => 'i',
.unsigned => 'u',
};
for ([_]u8{ 8, 16, 32, 64 }) |nbits| {
if (bits <= nbits) {
try w.print("{c}{d}", .{ prefix_byte, nbits });
break;
}
} else {
unreachable;
}
},
}
try w.writeByte('(');
try f.writeCValue(w, lhs);
try w.writeAll(", ");
try f.writeCValue(w, rhs);
if (int_info.signedness == .signed) {
try w.print(", {s}", .{min});
}
try w.print(", {s});", .{max});
try f.object.indent_writer.insertNewline();
return ret;
}
fn airSatOp(f: *Function, inst: Air.Inst.Index, fn_op: [*:0]const u8) !CValue {
if (f.liveness.isUnused(inst))
return CValue.none;
const bin_op = f.air.instructions.items(.data)[inst].bin_op;
const inst_ty = f.air.typeOfIndex(inst);
const int_info = inst_ty.intInfo(f.object.dg.module.getTarget());
const bits = int_info.bits;
switch (bits) {
8, 16, 32, 64, 128 => {},
else => return f.object.dg.fail("TODO: C backend: airSatOp for non power of 2 integers", .{}),
}
// if it's an unsigned int with non-arbitrary bit size then we can just add
if (bits > 64) {
return f.object.dg.fail("TODO: C backend: airSatOp for large integers", .{});
}
var min_buf: [80]u8 = undefined;
const min = switch (int_info.signedness) {
.unsigned => "0",
else => switch (inst_ty.tag()) {
.c_short => "SHRT_MIN",
.c_int => "INT_MIN",
.c_long => "LONG_MIN",
.c_longlong => "LLONG_MIN",
.isize => "INTPTR_MIN",
else => blk: {
// compute the type minimum based on the bitcount (bits)
const val = -1 * std.math.pow(i65, 2, @intCast(i65, bits - 1));
break :blk std.fmt.bufPrint(&min_buf, "{d}", .{val}) catch |err| switch (err) {
error.NoSpaceLeft => unreachable,
else => |e| return e,
};
},
},
};
var max_buf: [80]u8 = undefined;
const max = switch (inst_ty.tag()) {
.c_short => "SHRT_MAX",
.c_ushort => "USHRT_MAX",
.c_int => "INT_MAX",
.c_uint => "UINT_MAX",
.c_long => "LONG_MAX",
.c_ulong => "ULONG_MAX",
.c_longlong => "LLONG_MAX",
.c_ulonglong => "ULLONG_MAX",
.isize => "INTPTR_MAX",
.usize => "UINTPTR_MAX",
else => blk: {
const pow_bits = switch (int_info.signedness) {
.signed => bits - 1,
.unsigned => bits,
};
const val = std.math.pow(u65, 2, pow_bits) - 1;
break :blk std.fmt.bufPrint(&max_buf, "{}", .{val}) catch |err| switch (err) {
error.NoSpaceLeft => unreachable,
else => |e| return e,
};
},
};
const lhs = try f.resolveInst(bin_op.lhs);
const rhs = try f.resolveInst(bin_op.rhs);
const w = f.object.writer();
const ret = try f.allocLocal(inst_ty, .Mut);
try w.print(" = zig_{s}", .{fn_op});
switch (inst_ty.tag()) {
.isize => try w.writeAll("isize"),
.c_short => try w.writeAll("short"),
.c_int => try w.writeAll("int"),
.c_long => try w.writeAll("long"),
.c_longlong => try w.writeAll("longlong"),
else => {
const prefix_byte: u8 = switch (int_info.signedness) {
.signed => 'i',
.unsigned => 'u',
};
for ([_]u8{ 8, 16, 32, 64 }) |nbits| {
if (bits <= nbits) {
try w.print("{c}{d}", .{ prefix_byte, nbits });
break;
}
} else {
unreachable;
}
},
}
try w.writeByte('(');
try f.writeCValue(w, lhs);
try w.writeAll(", ");
try f.writeCValue(w, rhs);
if (int_info.signedness == .signed) {
try w.print(", {s}", .{min});
}
try w.print(", {s});", .{max});
try f.object.indent_writer.insertNewline();
return ret;
}
fn airAddWithOverflow(f: *Function, inst: Air.Inst.Index) !CValue {
_ = f;
_ = inst;
return f.fail("TODO add with overflow", .{});
}
fn airSubWithOverflow(f: *Function, inst: Air.Inst.Index) !CValue {
_ = f;
_ = inst;
return f.fail("TODO sub with overflow", .{});
}
fn airMulWithOverflow(f: *Function, inst: Air.Inst.Index) !CValue {
_ = f;
_ = inst;
return f.fail("TODO mul with overflow", .{});
}
fn airShlWithOverflow(f: *Function, inst: Air.Inst.Index) !CValue {
_ = f;
_ = inst;
return f.fail("TODO shl with overflow", .{});
}
fn airNot(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst))
return CValue.none;
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const op = try f.resolveInst(ty_op.operand);
const writer = f.object.writer();
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = ");
if (inst_ty.zigTypeTag() == .Bool)
try writer.writeAll("!")
else
try writer.writeAll("~");
try f.writeCValue(writer, op);
try writer.writeAll(";\n");
return local;
}
fn airBinOp(f: *Function, inst: Air.Inst.Index, operator: [*:0]const u8) !CValue {
if (f.liveness.isUnused(inst))
return CValue.none;
const bin_op = f.air.instructions.items(.data)[inst].bin_op;
const lhs = try f.resolveInst(bin_op.lhs);
const rhs = try f.resolveInst(bin_op.rhs);
const writer = f.object.writer();
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = ");
try f.writeCValue(writer, lhs);
try writer.print("{s}", .{operator});
try f.writeCValue(writer, rhs);
try writer.writeAll(";\n");
return local;
}
fn airEquality(
f: *Function,
inst: Air.Inst.Index,
negate_prefix: []const u8,
eq_op_str: []const u8,
) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const bin_op = f.air.instructions.items(.data)[inst].bin_op;
const lhs = try f.resolveInst(bin_op.lhs);
const rhs = try f.resolveInst(bin_op.rhs);
const writer = f.object.writer();
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = ");
const lhs_ty = f.air.typeOf(bin_op.lhs);
if (lhs_ty.tag() == .optional) {
// (A && B) || (C && (A == B))
// A = lhs.is_null ; B = rhs.is_null ; C = rhs.payload == lhs.payload
try writer.writeAll(negate_prefix);
try f.writeCValue(writer, lhs);
try writer.writeAll(".is_null && ");
try f.writeCValue(writer, rhs);
try writer.writeAll(".is_null) || (");
try f.writeCValue(writer, lhs);
try writer.writeAll(".payload == ");
try f.writeCValue(writer, rhs);
try writer.writeAll(".payload && ");
try f.writeCValue(writer, lhs);
try writer.writeAll(".is_null == ");
try f.writeCValue(writer, rhs);
try writer.writeAll(".is_null));\n");
return local;
}
try f.writeCValue(writer, lhs);
try writer.writeAll(eq_op_str);
try f.writeCValue(writer, rhs);
try writer.writeAll(";\n");
return local;
}
fn airPtrAddSub(f: *Function, inst: Air.Inst.Index, operator: [*:0]const u8) !CValue {
if (f.liveness.isUnused(inst))
return CValue.none;
const bin_op = f.air.instructions.items(.data)[inst].bin_op;
const lhs = try f.resolveInst(bin_op.lhs);
const rhs = try f.resolveInst(bin_op.rhs);
const writer = f.object.writer();
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
const elem_ty = switch (inst_ty.ptrSize()) {
.One => blk: {
const array_ty = inst_ty.childType();
break :blk array_ty.childType();
},
else => inst_ty.childType(),
};
// We must convert to and from integer types to prevent UB if the operation results in a NULL pointer,
// or if LHS is NULL. The operation is only UB if the result is NULL and then dereferenced.
try writer.writeAll(" = (");
try f.renderTypecast(writer, inst_ty);
try writer.writeAll(")(((uintptr_t)");
try f.writeCValue(writer, lhs);
try writer.print("){s}(", .{operator});
try f.writeCValue(writer, rhs);
try writer.writeAll("*sizeof(");
try f.renderTypecast(writer, elem_ty);
try writer.print(")));\n", .{});
return local;
}
fn airMinMax(f: *Function, inst: Air.Inst.Index, operator: [*:0]const u8) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const bin_op = f.air.instructions.items(.data)[inst].bin_op;
const lhs = try f.resolveInst(bin_op.lhs);
const rhs = try f.resolveInst(bin_op.rhs);
const writer = f.object.writer();
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
// (lhs <> rhs) ? lhs : rhs
try writer.writeAll(" = (");
try f.writeCValue(writer, lhs);
try writer.print("{s}", .{operator});
try f.writeCValue(writer, rhs);
try writer.writeAll(") ? ");
try f.writeCValue(writer, lhs);
try writer.writeAll(" : ");
try f.writeCValue(writer, rhs);
try writer.writeAll(";\n");
return local;
}
fn airSlice(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const ty_pl = f.air.instructions.items(.data)[inst].ty_pl;
const bin_op = f.air.extraData(Air.Bin, ty_pl.payload).data;
const ptr = try f.resolveInst(bin_op.lhs);
const len = try f.resolveInst(bin_op.rhs);
const writer = f.object.writer();
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = {");
try f.writeCValue(writer, ptr);
try writer.writeAll(", ");
try f.writeCValue(writer, len);
try writer.writeAll("};\n");
return local;
}
fn airCall(
f: *Function,
inst: Air.Inst.Index,
modifier: std.builtin.CallOptions.Modifier,
) !CValue {
switch (modifier) {
.auto => {},
.always_tail => return f.fail("TODO: C backend: call with always_tail attribute", .{}),
.never_tail => return f.fail("TODO: C backend: call with never_tail attribute", .{}),
.never_inline => return f.fail("TODO: C backend: call with never_inline attribute", .{}),
else => unreachable,
}
const pl_op = f.air.instructions.items(.data)[inst].pl_op;
const extra = f.air.extraData(Air.Call, pl_op.payload);
const args = @bitCast([]const Air.Inst.Ref, f.air.extra[extra.end..][0..extra.data.args_len]);
const callee_ty = f.air.typeOf(pl_op.operand);
const fn_ty = switch (callee_ty.zigTypeTag()) {
.Fn => callee_ty,
.Pointer => callee_ty.childType(),
else => unreachable,
};
const ret_ty = fn_ty.fnReturnType();
const unused_result = f.liveness.isUnused(inst);
const writer = f.object.writer();
var result_local: CValue = .none;
if (unused_result) {
if (ret_ty.hasRuntimeBits()) {
try writer.print("(void)", .{});
}
} else {
result_local = try f.allocLocal(ret_ty, .Const);
try writer.writeAll(" = ");
}
callee: {
known: {
const fn_decl = fn_decl: {
const callee_val = f.air.value(pl_op.operand) orelse break :known;
break :fn_decl switch (callee_val.tag()) {
.extern_fn => callee_val.castTag(.extern_fn).?.data.owner_decl,
.function => callee_val.castTag(.function).?.data.owner_decl,
.decl_ref => callee_val.castTag(.decl_ref).?.data,
else => break :known,
};
};
try f.object.dg.renderDeclName(writer, fn_decl);
break :callee;
}
// Fall back to function pointer call.
const callee = try f.resolveInst(pl_op.operand);
try f.writeCValue(writer, callee);
}
try writer.writeAll("(");
var args_written: usize = 0;
for (args) |arg| {
const ty = f.air.typeOf(arg);
if (!ty.hasRuntimeBitsIgnoreComptime()) continue;
if (args_written != 0) {
try writer.writeAll(", ");
}
if (f.air.value(arg)) |val| {
try f.object.dg.renderValue(writer, f.air.typeOf(arg), val);
} else {
const val = try f.resolveInst(arg);
try f.writeCValue(writer, val);
}
args_written += 1;
}
try writer.writeAll(");\n");
return result_local;
}
fn airDbgStmt(f: *Function, inst: Air.Inst.Index) !CValue {
const dbg_stmt = f.air.instructions.items(.data)[inst].dbg_stmt;
const writer = f.object.writer();
// TODO re-evaluate whether to emit these or not. If we naively emit
// these directives, the output file will report bogus line numbers because
// every newline after the #line directive adds one to the line.
// We also don't print the filename yet, so the output is strictly unhelpful.
// If we wanted to go this route, we would need to go all the way and not output
// newlines until the next dbg_stmt occurs.
// Perhaps an additional compilation option is in order?
//try writer.print("#line {d}\n", .{dbg_stmt.line + 1});
try writer.print("/* file:{d}:{d} */\n", .{ dbg_stmt.line + 1, dbg_stmt.column + 1 });
return CValue.none;
}
fn airDbgInline(f: *Function, inst: Air.Inst.Index) !CValue {
const ty_pl = f.air.instructions.items(.data)[inst].ty_pl;
const writer = f.object.writer();
const function = f.air.values[ty_pl.payload].castTag(.function).?.data;
try writer.print("/* dbg func:{s} */\n", .{function.owner_decl.name});
return CValue.none;
}
fn airDbgVar(f: *Function, inst: Air.Inst.Index) !CValue {
const pl_op = f.air.instructions.items(.data)[inst].pl_op;
const name = f.air.nullTerminatedString(pl_op.payload);
const operand = try f.resolveInst(pl_op.operand);
_ = operand;
const writer = f.object.writer();
try writer.print("/* var:{s} */\n", .{name});
return CValue.none;
}
fn airBlock(f: *Function, inst: Air.Inst.Index) !CValue {
const ty_pl = f.air.instructions.items(.data)[inst].ty_pl;
const extra = f.air.extraData(Air.Block, ty_pl.payload);
const body = f.air.extra[extra.end..][0..extra.data.body_len];
const block_id: usize = f.next_block_index;
f.next_block_index += 1;
const writer = f.object.writer();
const inst_ty = f.air.typeOfIndex(inst);
const result = if (inst_ty.tag() != .void and !f.liveness.isUnused(inst)) blk: {
// allocate a location for the result
const local = try f.allocLocal(inst_ty, .Mut);
try writer.writeAll(";\n");
break :blk local;
} else CValue{ .none = {} };
try f.blocks.putNoClobber(f.object.dg.gpa, inst, .{
.block_id = block_id,
.result = result,
});
try genBody(f, body);
try f.object.indent_writer.insertNewline();
// label must be followed by an expression, add an empty one.
try writer.print("zig_block_{d}:;\n", .{block_id});
return result;
}
fn airBr(f: *Function, inst: Air.Inst.Index) !CValue {
const branch = f.air.instructions.items(.data)[inst].br;
const block = f.blocks.get(branch.block_inst).?;
const result = block.result;
const writer = f.object.writer();
// If result is .none then the value of the block is unused.
if (result != .none) {
const operand = try f.resolveInst(branch.operand);
try f.writeCValue(writer, result);
try writer.writeAll(" = ");
try f.writeCValue(writer, operand);
try writer.writeAll(";\n");
}
try f.object.writer().print("goto zig_block_{d};\n", .{block.block_id});
return CValue.none;
}
fn airBitcast(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst))
return CValue.none;
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const operand = try f.resolveInst(ty_op.operand);
const writer = f.object.writer();
const inst_ty = f.air.typeOfIndex(inst);
if (inst_ty.isPtrAtRuntime() and
f.air.typeOf(ty_op.operand).isPtrAtRuntime())
{
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = (");
try f.renderTypecast(writer, inst_ty);
try writer.writeAll(")");
try f.writeCValue(writer, operand);
try writer.writeAll(";\n");
return local;
}
const local = try f.allocLocal(inst_ty, .Mut);
try writer.writeAll(";\n");
try writer.writeAll("memcpy(&");
try f.writeCValue(writer, local);
try writer.writeAll(", &");
try f.writeCValue(writer, operand);
try writer.writeAll(", sizeof(");
try f.writeCValue(writer, local);
try writer.writeAll("));\n");
return local;
}
fn airBreakpoint(f: *Function) !CValue {
try f.object.writer().writeAll("zig_breakpoint();\n");
return CValue.none;
}
fn airRetAddr(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const local = try f.allocLocal(Type.usize, .Const);
try f.object.writer().writeAll(" = zig_return_address();\n");
return local;
}
fn airFrameAddress(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const local = try f.allocLocal(Type.usize, .Const);
try f.object.writer().writeAll(" = zig_frame_address();\n");
return local;
}
fn airFence(f: *Function, inst: Air.Inst.Index) !CValue {
const atomic_order = f.air.instructions.items(.data)[inst].fence;
const writer = f.object.writer();
try writer.writeAll("zig_fence(");
try writeMemoryOrder(writer, atomic_order);
try writer.writeAll(");\n");
return CValue.none;
}
fn airUnreach(f: *Function) !CValue {
try f.object.writer().writeAll("zig_unreachable();\n");
return CValue.none;
}
fn airLoop(f: *Function, inst: Air.Inst.Index) !CValue {
const ty_pl = f.air.instructions.items(.data)[inst].ty_pl;
const loop = f.air.extraData(Air.Block, ty_pl.payload);
const body = f.air.extra[loop.end..][0..loop.data.body_len];
try f.object.writer().writeAll("while (true) ");
try genBody(f, body);
try f.object.indent_writer.insertNewline();
return CValue.none;
}
fn airCondBr(f: *Function, inst: Air.Inst.Index) !CValue {
const pl_op = f.air.instructions.items(.data)[inst].pl_op;
const cond = try f.resolveInst(pl_op.operand);
const extra = f.air.extraData(Air.CondBr, pl_op.payload);
const then_body = f.air.extra[extra.end..][0..extra.data.then_body_len];
const else_body = f.air.extra[extra.end + then_body.len ..][0..extra.data.else_body_len];
const writer = f.object.writer();
try writer.writeAll("if (");
try f.writeCValue(writer, cond);
try writer.writeAll(") ");
try genBody(f, then_body);
try writer.writeAll(" else ");
try genBody(f, else_body);
try f.object.indent_writer.insertNewline();
return CValue.none;
}
fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue {
const pl_op = f.air.instructions.items(.data)[inst].pl_op;
const condition = try f.resolveInst(pl_op.operand);
const condition_ty = f.air.typeOf(pl_op.operand);
const switch_br = f.air.extraData(Air.SwitchBr, pl_op.payload);
const writer = f.object.writer();
try writer.writeAll("switch (");
try f.writeCValue(writer, condition);
try writer.writeAll(") {");
f.object.indent_writer.pushIndent();
var extra_index: usize = switch_br.end;
var case_i: u32 = 0;
while (case_i < switch_br.data.cases_len) : (case_i += 1) {
const case = f.air.extraData(Air.SwitchBr.Case, extra_index);
const items = @bitCast([]const Air.Inst.Ref, f.air.extra[case.end..][0..case.data.items_len]);
const case_body = f.air.extra[case.end + items.len ..][0..case.data.body_len];
extra_index = case.end + case.data.items_len + case_body.len;
for (items) |item| {
try f.object.indent_writer.insertNewline();
try writer.writeAll("case ");
try f.object.dg.renderValue(writer, condition_ty, f.air.value(item).?);
try writer.writeAll(": ");
}
// The case body must be noreturn so we don't need to insert a break.
try genBody(f, case_body);
}
const else_body = f.air.extra[extra_index..][0..switch_br.data.else_body_len];
try f.object.indent_writer.insertNewline();
try writer.writeAll("default: ");
try genBody(f, else_body);
try f.object.indent_writer.insertNewline();
f.object.indent_writer.popIndent();
try writer.writeAll("}\n");
return CValue.none;
}
fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
const ty_pl = f.air.instructions.items(.data)[inst].ty_pl;
const extra = f.air.extraData(Air.Asm, ty_pl.payload);
const is_volatile = @truncate(u1, extra.data.flags >> 31) != 0;
const clobbers_len = @truncate(u31, extra.data.flags);
var extra_i: usize = extra.end;
const outputs = @bitCast([]const Air.Inst.Ref, f.air.extra[extra_i..][0..extra.data.outputs_len]);
extra_i += outputs.len;
const inputs = @bitCast([]const Air.Inst.Ref, f.air.extra[extra_i..][0..extra.data.inputs_len]);
extra_i += inputs.len;
if (!is_volatile and f.liveness.isUnused(inst)) return CValue.none;
if (outputs.len > 1) {
return f.fail("TODO implement codegen for asm with more than 1 output", .{});
}
const output_constraint: ?[]const u8 = for (outputs) |output| {
if (output != .none) {
return f.fail("TODO implement codegen for non-expr asm", .{});
}
const constraint = std.mem.sliceTo(std.mem.sliceAsBytes(f.air.extra[extra_i..]), 0);
// This equation accounts for the fact that even if we have exactly 4 bytes
// for the string, we still use the next u32 for the null terminator.
extra_i += constraint.len / 4 + 1;
break constraint;
} else null;
const writer = f.object.writer();
const inputs_extra_begin = extra_i;
for (inputs) |input| {
const constraint = std.mem.sliceTo(std.mem.sliceAsBytes(f.air.extra[extra_i..]), 0);
// This equation accounts for the fact that even if we have exactly 4 bytes
// for the string, we still use the next u32 for the null terminator.
extra_i += constraint.len / 4 + 1;
if (constraint[0] == '{' and constraint[constraint.len - 1] == '}') {
const reg = constraint[1 .. constraint.len - 1];
const arg_c_value = try f.resolveInst(input);
try writer.writeAll("register ");
try f.renderType(writer, f.air.typeOf(input));
try writer.print(" {s}_constant __asm__(\"{s}\") = ", .{ reg, reg });
try f.writeCValue(writer, arg_c_value);
try writer.writeAll(";\n");
} else {
return f.fail("TODO non-explicit inline asm regs", .{});
}
}
{
var clobber_i: u32 = 0;
while (clobber_i < clobbers_len) : (clobber_i += 1) {
const clobber = std.mem.sliceTo(std.mem.sliceAsBytes(f.air.extra[extra_i..]), 0);
// This equation accounts for the fact that even if we have exactly 4 bytes
// for the string, we still use the next u32 for the null terminator.
extra_i += clobber.len / 4 + 1;
// TODO honor these
}
}
const asm_source = std.mem.sliceAsBytes(f.air.extra[extra_i..])[0..extra.data.source_len];
const volatile_string: []const u8 = if (is_volatile) "volatile " else "";
try writer.print("__asm {s}(\"{s}\"", .{ volatile_string, asm_source });
if (output_constraint) |_| {
return f.fail("TODO: CBE inline asm output", .{});
}
if (inputs.len > 0) {
if (output_constraint == null) {
try writer.writeAll(" :");
}
try writer.writeAll(": ");
extra_i = inputs_extra_begin;
for (inputs) |_, index| {
const constraint = std.mem.sliceTo(std.mem.sliceAsBytes(f.air.extra[extra_i..]), 0);
// This equation accounts for the fact that even if we have exactly 4 bytes
// for the string, we still use the next u32 for the null terminator.
extra_i += constraint.len / 4 + 1;
if (constraint[0] == '{' and constraint[constraint.len - 1] == '}') {
const reg = constraint[1 .. constraint.len - 1];
if (index > 0) {
try writer.writeAll(", ");
}
try writer.print("\"r\"({s}_constant)", .{reg});
} else {
// This is blocked by the earlier test
unreachable;
}
}
}
try writer.writeAll(");\n");
if (f.liveness.isUnused(inst))
return CValue.none;
return f.fail("TODO: C backend: inline asm expression result used", .{});
}
fn airIsNull(
f: *Function,
inst: Air.Inst.Index,
operator: [*:0]const u8,
deref_suffix: [*:0]const u8,
) !CValue {
if (f.liveness.isUnused(inst))
return CValue.none;
const un_op = f.air.instructions.items(.data)[inst].un_op;
const writer = f.object.writer();
const operand = try f.resolveInst(un_op);
const target = f.object.dg.module.getTarget();
const local = try f.allocLocal(Type.initTag(.bool), .Const);
try writer.writeAll(" = (");
try f.writeCValue(writer, operand);
const ty = f.air.typeOf(un_op);
var opt_buf: Type.Payload.ElemType = undefined;
const payload_type = if (ty.zigTypeTag() == .Pointer)
ty.childType().optionalChild(&opt_buf)
else
ty.optionalChild(&opt_buf);
if (ty.isPtrLikeOptional()) {
// operand is a regular pointer, test `operand !=/== NULL`
try writer.print("){s} {s} NULL;\n", .{ deref_suffix, operator });
} else if (payload_type.abiSize(target) == 0) {
try writer.print("){s} {s} true;\n", .{ deref_suffix, operator });
} else {
try writer.print("){s}.is_null {s} true;\n", .{ deref_suffix, operator });
}
return local;
}
fn airOptionalPayload(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst))
return CValue.none;
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const writer = f.object.writer();
const operand = try f.resolveInst(ty_op.operand);
const operand_ty = f.air.typeOf(ty_op.operand);
const opt_ty = if (operand_ty.zigTypeTag() == .Pointer)
operand_ty.elemType()
else
operand_ty;
if (opt_ty.isPtrLikeOptional()) {
// the operand is just a regular pointer, no need to do anything special.
// *?*T -> **T and ?*T -> *T are **T -> **T and *T -> *T in C
return operand;
}
const inst_ty = f.air.typeOfIndex(inst);
const maybe_deref = if (operand_ty.zigTypeTag() == .Pointer) "->" else ".";
const maybe_addrof = if (inst_ty.zigTypeTag() == .Pointer) "&" else "";
const local = try f.allocLocal(inst_ty, .Const);
try writer.print(" = {s}(", .{maybe_addrof});
try f.writeCValue(writer, operand);
try writer.print("){s}payload;\n", .{maybe_deref});
return local;
}
fn airOptionalPayloadPtrSet(f: *Function, inst: Air.Inst.Index) !CValue {
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const writer = f.object.writer();
const operand = try f.resolveInst(ty_op.operand);
const operand_ty = f.air.typeOf(ty_op.operand);
const opt_ty = operand_ty.elemType();
if (opt_ty.isPtrLikeOptional()) {
// The payload and the optional are the same value.
// Setting to non-null will be done when the payload is set.
return operand;
}
try f.writeCValueDeref(writer, operand);
try writer.writeAll(".is_null = false;\n");
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = &");
try f.writeCValueDeref(writer, operand);
try writer.writeAll(".payload;\n");
return local;
}
fn airStructFieldPtr(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst))
// TODO this @as is needed because of a stage1 bug
return @as(CValue, CValue.none);
const ty_pl = f.air.instructions.items(.data)[inst].ty_pl;
const extra = f.air.extraData(Air.StructField, ty_pl.payload).data;
const struct_ptr = try f.resolveInst(extra.struct_operand);
const struct_ptr_ty = f.air.typeOf(extra.struct_operand);
return structFieldPtr(f, inst, struct_ptr_ty, struct_ptr, extra.field_index);
}
fn airStructFieldPtrIndex(f: *Function, inst: Air.Inst.Index, index: u8) !CValue {
if (f.liveness.isUnused(inst))
// TODO this @as is needed because of a stage1 bug
return @as(CValue, CValue.none);
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const struct_ptr = try f.resolveInst(ty_op.operand);
const struct_ptr_ty = f.air.typeOf(ty_op.operand);
return structFieldPtr(f, inst, struct_ptr_ty, struct_ptr, index);
}
fn airFieldParentPtr(f: *Function, inst: Air.Inst.Index) !CValue {
_ = inst;
return f.fail("TODO: C backend: implement airFieldParentPtr", .{});
}
fn structFieldPtr(f: *Function, inst: Air.Inst.Index, struct_ptr_ty: Type, struct_ptr: CValue, index: u32) !CValue {
const writer = f.object.writer();
const struct_ty = struct_ptr_ty.elemType();
var field_name: []const u8 = undefined;
var field_val_ty: Type = undefined;
var buf = std.ArrayList(u8).init(f.object.dg.gpa);
defer buf.deinit();
switch (struct_ty.tag()) {
.@"struct" => {
const fields = struct_ty.structFields();
field_name = fields.keys()[index];
field_val_ty = fields.values()[index].ty;
},
.@"union", .union_tagged => {
const fields = struct_ty.unionFields();
field_name = fields.keys()[index];
field_val_ty = fields.values()[index].ty;
},
.tuple => {
const tuple = struct_ty.tupleFields();
if (tuple.values[index].tag() != .unreachable_value) return CValue.none;
try buf.writer().print("field_{d}", .{index});
field_name = buf.items;
field_val_ty = tuple.types[index];
},
else => unreachable,
}
const payload = if (struct_ty.tag() == .union_tagged) "payload." else "";
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
try writer.print(" = &", .{});
try f.writeCValueDeref(writer, struct_ptr);
try writer.print(".{s}{ };\n", .{ payload, fmtIdent(field_name) });
return local;
}
fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst))
return CValue.none;
const ty_pl = f.air.instructions.items(.data)[inst].ty_pl;
const extra = f.air.extraData(Air.StructField, ty_pl.payload).data;
const writer = f.object.writer();
const struct_byval = try f.resolveInst(extra.struct_operand);
const struct_ty = f.air.typeOf(extra.struct_operand);
var buf = std.ArrayList(u8).init(f.object.dg.gpa);
defer buf.deinit();
const field_name = switch (struct_ty.tag()) {
.@"struct" => struct_ty.structFields().keys()[extra.field_index],
.@"union", .union_tagged => struct_ty.unionFields().keys()[extra.field_index],
.tuple => blk: {
const tuple = struct_ty.tupleFields();
if (tuple.values[extra.field_index].tag() != .unreachable_value) return CValue.none;
try buf.writer().print("field_{d}", .{extra.field_index});
break :blk buf.items;
},
else => unreachable,
};
const payload = if (struct_ty.tag() == .union_tagged) "payload." else "";
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = ");
try f.writeCValue(writer, struct_byval);
try writer.print(".{s}{ };\n", .{ payload, fmtIdent(field_name) });
return local;
}
// *(E!T) -> E NOT *E
fn airUnwrapErrUnionErr(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst))
return CValue.none;
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const inst_ty = f.air.typeOfIndex(inst);
const writer = f.object.writer();
const operand = try f.resolveInst(ty_op.operand);
const operand_ty = f.air.typeOf(ty_op.operand);
if (operand_ty.zigTypeTag() == .Pointer) {
if (!operand_ty.childType().errorUnionPayload().hasRuntimeBits()) {
return operand;
}
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = *");
try f.writeCValue(writer, operand);
try writer.writeAll(";\n");
return local;
}
if (!operand_ty.errorUnionPayload().hasRuntimeBits()) {
return operand;
}
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = ");
if (operand_ty.zigTypeTag() == .Pointer) {
try f.writeCValueDeref(writer, operand);
} else {
try f.writeCValue(writer, operand);
}
try writer.writeAll(".error;\n");
return local;
}
fn airUnwrapErrUnionPay(f: *Function, inst: Air.Inst.Index, maybe_addrof: []const u8) !CValue {
if (f.liveness.isUnused(inst))
return CValue.none;
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const writer = f.object.writer();
const operand = try f.resolveInst(ty_op.operand);
const operand_ty = f.air.typeOf(ty_op.operand);
const error_union_ty = if (operand_ty.zigTypeTag() == .Pointer)
operand_ty.childType()
else
operand_ty;
if (!error_union_ty.errorUnionPayload().hasRuntimeBits()) {
return CValue.none;
}
const inst_ty = f.air.typeOfIndex(inst);
const maybe_deref = if (operand_ty.zigTypeTag() == .Pointer) "->" else ".";
const local = try f.allocLocal(inst_ty, .Const);
try writer.print(" = {s}(", .{maybe_addrof});
try f.writeCValue(writer, operand);
try writer.print("){s}payload;\n", .{maybe_deref});
return local;
}
fn airWrapOptional(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst))
return CValue.none;
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const writer = f.object.writer();
const operand = try f.resolveInst(ty_op.operand);
const inst_ty = f.air.typeOfIndex(inst);
if (inst_ty.isPtrLikeOptional()) {
// the operand is just a regular pointer, no need to do anything special.
return operand;
}
// .wrap_optional is used to convert non-optionals into optionals so it can never be null.
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = { .is_null = false, .payload =");
try f.writeCValue(writer, operand);
try writer.writeAll("};\n");
return local;
}
fn airWrapErrUnionErr(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const writer = f.object.writer();
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const operand = try f.resolveInst(ty_op.operand);
const err_un_ty = f.air.typeOfIndex(inst);
const payload_ty = err_un_ty.errorUnionPayload();
if (!payload_ty.hasRuntimeBits()) {
return operand;
}
const local = try f.allocLocal(err_un_ty, .Const);
try writer.writeAll(" = { .error = ");
try f.writeCValue(writer, operand);
try writer.writeAll(" };\n");
return local;
}
fn airErrUnionPayloadPtrSet(f: *Function, inst: Air.Inst.Index) !CValue {
_ = inst;
return f.fail("TODO: C backend: implement airErrUnionPayloadPtrSet", .{});
}
fn airWrapErrUnionPay(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst))
return CValue.none;
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const writer = f.object.writer();
const operand = try f.resolveInst(ty_op.operand);
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = { .error = 0, .payload = ");
try f.writeCValue(writer, operand);
try writer.writeAll(" };\n");
return local;
}
fn airIsErr(
f: *Function,
inst: Air.Inst.Index,
is_ptr: bool,
op_str: [*:0]const u8,
) !CValue {
if (f.liveness.isUnused(inst))
return CValue.none;
const un_op = f.air.instructions.items(.data)[inst].un_op;
const writer = f.object.writer();
const operand = try f.resolveInst(un_op);
const operand_ty = f.air.typeOf(un_op);
const local = try f.allocLocal(Type.initTag(.bool), .Const);
const payload_ty = operand_ty.errorUnionPayload();
try writer.writeAll(" = ");
if (is_ptr) {
try f.writeCValueDeref(writer, operand);
} else {
try f.writeCValue(writer, operand);
}
if (payload_ty.hasRuntimeBits()) {
try writer.writeAll(".error");
}
try writer.print(" {s} 0;\n", .{op_str});
return local;
}
fn airArrayToSlice(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst))
return CValue.none;
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const writer = f.object.writer();
const operand = try f.resolveInst(ty_op.operand);
const array_len = f.air.typeOf(ty_op.operand).elemType().arrayLen();
try writer.writeAll(" = { .ptr = ");
if (operand == .undefined_ptr) {
// Unfortunately, C does not support any equivalent to
// &(*(void *)p)[0], although LLVM does via GetElementPtr
try f.writeCValue(writer, CValue.undefined_ptr);
} else {
try writer.writeAll("&(");
try f.writeCValueDeref(writer, operand);
try writer.writeAll(")[0]");
}
try writer.print(", .len = {d} }};\n", .{array_len});
return local;
}
/// Emits a local variable with the result type and initializes it
/// with the operand.
fn airSimpleCast(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const writer = f.object.writer();
const operand = try f.resolveInst(ty_op.operand);
try writer.writeAll(" = ");
try f.writeCValue(writer, operand);
try writer.writeAll(";\n");
return local;
}
fn airPtrToInt(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
const un_op = f.air.instructions.items(.data)[inst].un_op;
const writer = f.object.writer();
const operand = try f.resolveInst(un_op);
try writer.writeAll(" = (");
try f.renderTypecast(writer, inst_ty);
try writer.writeAll(")");
try f.writeCValue(writer, operand);
try writer.writeAll(";\n");
return local;
}
fn airBuiltinCall(f: *Function, inst: Air.Inst.Index, fn_name: [*:0]const u8) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
const operand = f.air.instructions.items(.data)[inst].ty_op.operand;
const operand_ty = f.air.typeOf(operand);
const target = f.object.dg.module.getTarget();
const writer = f.object.writer();
const int_info = operand_ty.intInfo(target);
const c_bits = toCIntBits(int_info.bits) orelse
return f.fail("TODO: C backend: implement integer types larger than 128 bits", .{});
try writer.print(" = zig_{s}_", .{fn_name});
const prefix_byte: u8 = switch (int_info.signedness) {
.signed => 'i',
.unsigned => 'u',
};
try writer.print("{c}{d}(", .{ prefix_byte, c_bits });
try f.writeCValue(writer, try f.resolveInst(operand));
try writer.print(", {d});\n", .{int_info.bits});
return local;
}
fn airBinOpBuiltinCall(f: *Function, inst: Air.Inst.Index, fn_name: [*:0]const u8) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
const bin_op = f.air.instructions.items(.data)[inst].bin_op;
const lhs_ty = f.air.typeOf(bin_op.lhs);
const target = f.object.dg.module.getTarget();
const writer = f.object.writer();
// For binary operations @TypeOf(lhs)==@TypeOf(rhs), so we only check one.
if (lhs_ty.isInt()) {
const int_info = lhs_ty.intInfo(target);
const c_bits = toCIntBits(int_info.bits) orelse
return f.fail("TODO: C backend: implement integer types larger than 128 bits", .{});
const prefix_byte: u8 = switch (int_info.signedness) {
.signed => 'i',
.unsigned => 'u',
};
try writer.print(" = zig_{s}_{c}{d}", .{ fn_name, prefix_byte, c_bits });
} else if (lhs_ty.isRuntimeFloat()) {
const c_bits = lhs_ty.floatBits(target);
try writer.print(" = zig_{s}_f{d}", .{ fn_name, c_bits });
} else {
return f.fail("TODO: C backend: implement airBinOpBuiltinCall for type {s}", .{@tagName(lhs_ty.tag())});
}
try writer.writeByte('(');
try f.writeCValue(writer, try f.resolveInst(bin_op.lhs));
try writer.writeAll(", ");
try f.writeCValue(writer, try f.resolveInst(bin_op.rhs));
try writer.writeAll(");\n");
return local;
}
fn airCmpxchg(f: *Function, inst: Air.Inst.Index, flavor: [*:0]const u8) !CValue {
const ty_pl = f.air.instructions.items(.data)[inst].ty_pl;
const extra = f.air.extraData(Air.Cmpxchg, ty_pl.payload).data;
const inst_ty = f.air.typeOfIndex(inst);
const ptr = try f.resolveInst(extra.ptr);
const expected_value = try f.resolveInst(extra.expected_value);
const new_value = try f.resolveInst(extra.new_value);
const local = try f.allocLocal(inst_ty, .Const);
const writer = f.object.writer();
try writer.print(" = zig_cmpxchg_{s}(", .{flavor});
try f.writeCValue(writer, ptr);
try writer.writeAll(", ");
try f.writeCValue(writer, expected_value);
try writer.writeAll(", ");
try f.writeCValue(writer, new_value);
try writer.writeAll(", ");
try writeMemoryOrder(writer, extra.successOrder());
try writer.writeAll(", ");
try writeMemoryOrder(writer, extra.failureOrder());
try writer.writeAll(");\n");
return local;
}
fn airAtomicRmw(f: *Function, inst: Air.Inst.Index) !CValue {
const pl_op = f.air.instructions.items(.data)[inst].pl_op;
const extra = f.air.extraData(Air.AtomicRmw, pl_op.payload).data;
const inst_ty = f.air.typeOfIndex(inst);
const ptr = try f.resolveInst(pl_op.operand);
const operand = try f.resolveInst(extra.operand);
const local = try f.allocLocal(inst_ty, .Const);
const writer = f.object.writer();
try writer.print(" = zig_atomicrmw_{s}(", .{toAtomicRmwSuffix(extra.op())});
try f.writeCValue(writer, ptr);
try writer.writeAll(", ");
try f.writeCValue(writer, operand);
try writer.writeAll(", ");
try writeMemoryOrder(writer, extra.ordering());
try writer.writeAll(");\n");
return local;
}
fn airAtomicLoad(f: *Function, inst: Air.Inst.Index) !CValue {
const atomic_load = f.air.instructions.items(.data)[inst].atomic_load;
const ptr = try f.resolveInst(atomic_load.ptr);
const ptr_ty = f.air.typeOf(atomic_load.ptr);
if (!ptr_ty.isVolatilePtr() and f.liveness.isUnused(inst))
return CValue.none;
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
const writer = f.object.writer();
try writer.writeAll(" = zig_atomic_load(");
try f.writeCValue(writer, ptr);
try writer.writeAll(", ");
try writeMemoryOrder(writer, atomic_load.order);
try writer.writeAll(");\n");
return local;
}
fn airAtomicStore(f: *Function, inst: Air.Inst.Index, order: [*:0]const u8) !CValue {
const bin_op = f.air.instructions.items(.data)[inst].bin_op;
const ptr = try f.resolveInst(bin_op.lhs);
const element = try f.resolveInst(bin_op.rhs);
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
const writer = f.object.writer();
try writer.writeAll(" = zig_atomic_store(");
try f.writeCValue(writer, ptr);
try writer.writeAll(", ");
try f.writeCValue(writer, element);
try writer.print(", {s});\n", .{order});
return local;
}
fn airMemset(f: *Function, inst: Air.Inst.Index) !CValue {
const pl_op = f.air.instructions.items(.data)[inst].pl_op;
const extra = f.air.extraData(Air.Bin, pl_op.payload).data;
const dest_ptr = try f.resolveInst(pl_op.operand);
const value = try f.resolveInst(extra.lhs);
const len = try f.resolveInst(extra.rhs);
const writer = f.object.writer();
try writer.writeAll("memset(");
try f.writeCValue(writer, dest_ptr);
try writer.writeAll(", ");
try f.writeCValue(writer, value);
try writer.writeAll(", ");
try f.writeCValue(writer, len);
try writer.writeAll(");\n");
return CValue.none;
}
fn airMemcpy(f: *Function, inst: Air.Inst.Index) !CValue {
const pl_op = f.air.instructions.items(.data)[inst].pl_op;
const extra = f.air.extraData(Air.Bin, pl_op.payload).data;
const dest_ptr = try f.resolveInst(pl_op.operand);
const src_ptr = try f.resolveInst(extra.lhs);
const len = try f.resolveInst(extra.rhs);
const writer = f.object.writer();
try writer.writeAll("memcpy(");
try f.writeCValue(writer, dest_ptr);
try writer.writeAll(", ");
try f.writeCValue(writer, src_ptr);
try writer.writeAll(", ");
try f.writeCValue(writer, len);
try writer.writeAll(");\n");
return CValue.none;
}
fn airSetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue {
const bin_op = f.air.instructions.items(.data)[inst].bin_op;
const union_ptr = try f.resolveInst(bin_op.lhs);
const new_tag = try f.resolveInst(bin_op.rhs);
const writer = f.object.writer();
const union_ty = f.air.typeOf(bin_op.lhs).childType();
const target = f.object.dg.module.getTarget();
const layout = union_ty.unionGetLayout(target);
if (layout.tag_size == 0) return CValue.none;
try f.writeCValue(writer, union_ptr);
try writer.writeAll("->tag = ");
try f.writeCValue(writer, new_tag);
try writer.writeAll(";\n");
return CValue.none;
}
fn airGetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst))
return CValue.none;
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const un_ty = f.air.typeOf(ty_op.operand);
const writer = f.object.writer();
const operand = try f.resolveInst(ty_op.operand);
const target = f.object.dg.module.getTarget();
const layout = un_ty.unionGetLayout(target);
if (layout.tag_size == 0) return CValue.none;
try writer.writeAll(" = ");
try f.writeCValue(writer, operand);
try writer.writeAll(".tag;\n");
return local;
}
fn airTagName(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const un_op = f.air.instructions.items(.data)[inst].un_op;
const writer = f.object.writer();
const inst_ty = f.air.typeOfIndex(inst);
const operand = try f.resolveInst(un_op);
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = ");
_ = operand;
_ = local;
return f.fail("TODO: C backend: implement airTagName", .{});
//try writer.writeAll(";\n");
//return local;
}
fn airErrorName(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const un_op = f.air.instructions.items(.data)[inst].un_op;
const writer = f.object.writer();
const inst_ty = f.air.typeOfIndex(inst);
const operand = try f.resolveInst(un_op);
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = ");
_ = operand;
_ = local;
return f.fail("TODO: C backend: implement airErrorName", .{});
}
fn airSplat(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const inst_ty = f.air.typeOfIndex(inst);
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const operand = try f.resolveInst(ty_op.operand);
const writer = f.object.writer();
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = ");
_ = operand;
_ = local;
return f.fail("TODO: C backend: implement airSplat", .{});
}
fn airShuffle(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const inst_ty = f.air.typeOfIndex(inst);
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const operand = try f.resolveInst(ty_op.operand);
const writer = f.object.writer();
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = ");
_ = operand;
_ = local;
return f.fail("TODO: C backend: implement airShuffle", .{});
}
fn airReduce(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const inst_ty = f.air.typeOfIndex(inst);
const reduce = f.air.instructions.items(.data)[inst].reduce;
const operand = try f.resolveInst(reduce.operand);
const writer = f.object.writer();
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = ");
_ = operand;
_ = local;
return f.fail("TODO: C backend: implement airReduce", .{});
}
fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const inst_ty = f.air.typeOfIndex(inst);
const ty_pl = f.air.instructions.items(.data)[inst].ty_pl;
const vector_ty = f.air.getRefType(ty_pl.ty);
const len = vector_ty.vectorLen();
const elements = @bitCast([]const Air.Inst.Ref, f.air.extra[ty_pl.payload..][0..len]);
const writer = f.object.writer();
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = {");
switch (vector_ty.zigTypeTag()) {
.Struct => {
const tuple = vector_ty.tupleFields();
var i: usize = 0;
for (elements) |elem, elem_index| {
if (tuple.values[elem_index].tag() != .unreachable_value) continue;
const value = try f.resolveInst(elem);
if (i != 0) try writer.writeAll(", ");
try f.writeCValue(writer, value);
i += 1;
}
},
else => |tag| return f.fail("TODO: C backend: implement airAggregateInit for type {s}", .{@tagName(tag)}),
}
try writer.writeAll("};\n");
return local;
}
fn airUnionInit(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const inst_ty = f.air.typeOfIndex(inst);
const ty_pl = f.air.instructions.items(.data)[inst].ty_pl;
const writer = f.object.writer();
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = ");
_ = local;
_ = ty_pl;
return f.fail("TODO: C backend: implement airUnionInit", .{});
}
fn airPrefetch(f: *Function, inst: Air.Inst.Index) !CValue {
const prefetch = f.air.instructions.items(.data)[inst].prefetch;
switch (prefetch.cache) {
.data => {},
// The available prefetch intrinsics do not accept a cache argument; only
// address, rw, and locality. So unless the cache is data, we do not lower
// this instruction.
.instruction => return CValue.none,
}
const ptr = try f.resolveInst(prefetch.ptr);
const writer = f.object.writer();
try writer.writeAll("zig_prefetch(");
try f.writeCValue(writer, ptr);
try writer.print(", {d}, {d});\n", .{
@enumToInt(prefetch.rw), prefetch.locality,
});
return CValue.none;
}
fn airWasmMemorySize(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const pl_op = f.air.instructions.items(.data)[inst].pl_op;
const writer = f.object.writer();
const inst_ty = f.air.typeOfIndex(inst);
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = ");
try writer.print("zig_wasm_memory_size({d});\n", .{pl_op.payload});
return local;
}
fn airWasmMemoryGrow(f: *Function, inst: Air.Inst.Index) !CValue {
const pl_op = f.air.instructions.items(.data)[inst].pl_op;
const writer = f.object.writer();
const inst_ty = f.air.typeOfIndex(inst);
const operand = try f.resolveInst(pl_op.operand);
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = ");
try writer.print("zig_wasm_memory_grow({d}, ", .{pl_op.payload});
try f.writeCValue(writer, operand);
try writer.writeAll(");\n");
return local;
}
fn airMulAdd(f: *Function, inst: Air.Inst.Index) !CValue {
if (f.liveness.isUnused(inst)) return CValue.none;
const pl_op = f.air.instructions.items(.data)[inst].pl_op;
const extra = f.air.extraData(Air.Bin, pl_op.payload).data;
const inst_ty = f.air.typeOfIndex(inst);
const mulend1 = try f.resolveInst(extra.lhs);
const mulend2 = try f.resolveInst(extra.rhs);
const addend = try f.resolveInst(pl_op.operand);
const writer = f.object.writer();
const target = f.object.dg.module.getTarget();
const fn_name = switch (inst_ty.floatBits(target)) {
16, 32 => "fmaf",
64 => "fma",
80 => if (CType.longdouble.sizeInBits(target) == 80) "fmal" else "__fmax",
128 => if (CType.longdouble.sizeInBits(target) == 128) "fmal" else "fmaq",
else => unreachable,
};
const local = try f.allocLocal(inst_ty, .Const);
try writer.writeAll(" = ");
try writer.print("{s}(", .{fn_name});
try f.writeCValue(writer, mulend1);
try writer.writeAll(", ");
try f.writeCValue(writer, mulend2);
try writer.writeAll(", ");
try f.writeCValue(writer, addend);
try writer.writeAll(");\n");
return local;
}
fn toMemoryOrder(order: std.builtin.AtomicOrder) [:0]const u8 {
return switch (order) {
.Unordered => "memory_order_relaxed",
.Monotonic => "memory_order_consume",
.Acquire => "memory_order_acquire",
.Release => "memory_order_release",
.AcqRel => "memory_order_acq_rel",
.SeqCst => "memory_order_seq_cst",
};
}
fn writeMemoryOrder(w: anytype, order: std.builtin.AtomicOrder) !void {
return w.writeAll(toMemoryOrder(order));
}
fn toAtomicRmwSuffix(order: std.builtin.AtomicRmwOp) []const u8 {
return switch (order) {
.Xchg => "xchg",
.Add => "add",
.Sub => "sub",
.And => "and",
.Nand => "nand",
.Or => "or",
.Xor => "xor",
.Max => "max",
.Min => "min",
};
}
fn IndentWriter(comptime UnderlyingWriter: type) type {
return struct {
const Self = @This();
pub const Error = UnderlyingWriter.Error;
pub const Writer = std.io.Writer(*Self, Error, write);
pub const indent_delta = 1;
underlying_writer: UnderlyingWriter,
indent_count: usize = 0,
current_line_empty: bool = true,
pub fn writer(self: *Self) Writer {
return .{ .context = self };
}
pub fn write(self: *Self, bytes: []const u8) Error!usize {
if (bytes.len == 0) return @as(usize, 0);
const current_indent = self.indent_count * Self.indent_delta;
if (self.current_line_empty and current_indent > 0) {
try self.underlying_writer.writeByteNTimes(' ', current_indent);
}
self.current_line_empty = false;
return self.writeNoIndent(bytes);
}
pub fn insertNewline(self: *Self) Error!void {
_ = try self.writeNoIndent("\n");
}
pub fn pushIndent(self: *Self) void {
self.indent_count += 1;
}
pub fn popIndent(self: *Self) void {
assert(self.indent_count != 0);
self.indent_count -= 1;
}
fn writeNoIndent(self: *Self, bytes: []const u8) Error!usize {
if (bytes.len == 0) return @as(usize, 0);
try self.underlying_writer.writeAll(bytes);
if (bytes[bytes.len - 1] == '\n') {
self.current_line_empty = true;
}
return bytes.len;
}
};
}
fn toCIntBits(zig_bits: u32) ?u32 {
for (&[_]u8{ 8, 16, 32, 64, 128 }) |c_bits| {
if (zig_bits <= c_bits) {
return c_bits;
}
}
return null;
} | src/codegen/c.zig |
const std = @import("std");
const expect = std.testing.expect;
const expectEqualSlices = std.testing.expectEqualSlices;
const expectEqual = std.testing.expectEqual;
const mem = std.mem;
// comptime array passed as slice argument
comptime {
const S = struct {
fn indexOfScalarPos(comptime T: type, slice: []const T, start_index: usize, value: T) ?usize {
var i: usize = start_index;
while (i < slice.len) : (i += 1) {
if (slice[i] == value) return i;
}
return null;
}
fn indexOfScalar(comptime T: type, slice: []const T, value: T) ?usize {
return indexOfScalarPos(T, slice, 0, value);
}
};
const unsigned = [_]type{ c_uint, c_ulong, c_ulonglong };
const list: []const type = &unsigned;
var pos = S.indexOfScalar(type, list, c_ulong).?;
if (pos != 1) @compileError("bad pos");
}
test "slicing" {
var array: [20]i32 = undefined;
array[5] = 1234;
var slice = array[5..10];
if (slice.len != 5) unreachable;
const ptr = &slice[0];
if (ptr.* != 1234) unreachable;
var slice_rest = array[10..];
if (slice_rest.len != 10) unreachable;
}
test "const slice" {
comptime {
const a = "1234567890";
try expect(a.len == 10);
const b = a[1..2];
try expect(b.len == 1);
try expect(b[0] == '2');
}
}
test "comptime slice of undefined pointer of length 0" {
const slice1 = @as([*]i32, undefined)[0..0];
try expect(slice1.len == 0);
const slice2 = @as([*]i32, undefined)[100..100];
try expect(slice2.len == 0);
}
test "implicitly cast array of size 0 to slice" {
var msg = [_]u8{};
try assertLenIsZero(&msg);
}
fn assertLenIsZero(msg: []const u8) !void {
try expect(msg.len == 0);
}
test "access len index of sentinel-terminated slice" {
const S = struct {
fn doTheTest() !void {
var slice: [:0]const u8 = "hello";
try expect(slice.len == 5);
try expect(slice[5] == 0);
}
};
try S.doTheTest();
comptime try S.doTheTest();
}
test "comptime slice of slice preserves comptime var" {
comptime {
var buff: [10]u8 = undefined;
buff[0..][0..][0] = 1;
try expect(buff[0..][0..][0] == 1);
}
}
test "slice of type" {
comptime {
var types_array = [_]type{ i32, f64, type };
for (types_array) |T, i| {
switch (i) {
0 => try expect(T == i32),
1 => try expect(T == f64),
2 => try expect(T == type),
else => unreachable,
}
}
for (types_array[0..]) |T, i| {
switch (i) {
0 => try expect(T == i32),
1 => try expect(T == f64),
2 => try expect(T == type),
else => unreachable,
}
}
}
} | test/behavior/slice.zig |
const macho = @import("../macho.zig");
extern "c" fn __error() *c_int;
pub extern "c" fn _NSGetExecutablePath(buf: [*]u8, bufsize: *u32) c_int;
pub extern "c" fn _dyld_get_image_header(image_index: u32) ?*mach_header;
pub extern "c" fn __getdirentries64(fd: c_int, buf_ptr: [*]u8, buf_len: usize, basep: *i64) usize;
pub extern "c" fn mach_absolute_time() u64;
pub extern "c" fn mach_timebase_info(tinfo: ?*mach_timebase_info_data) void;
pub extern "c" fn kqueue() c_int;
pub extern "c" fn kevent(
kq: c_int,
changelist: [*]const Kevent,
nchanges: c_int,
eventlist: [*]Kevent,
nevents: c_int,
timeout: ?*const timespec,
) c_int;
pub extern "c" fn kevent64(
kq: c_int,
changelist: [*]const kevent64_s,
nchanges: c_int,
eventlist: [*]kevent64_s,
nevents: c_int,
flags: c_uint,
timeout: ?*const timespec,
) c_int;
pub extern "c" fn sysctl(name: [*]c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
pub extern "c" fn sysctlbyname(name: [*]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
pub extern "c" fn sysctlnametomib(name: [*]const u8, mibp: ?*c_int, sizep: ?*usize) c_int;
pub extern "c" fn bind(socket: c_int, address: ?*const sockaddr, address_len: socklen_t) c_int;
pub extern "c" fn socket(domain: c_int, type: c_int, protocol: c_int) c_int;
/// The value of the link editor defined symbol _MH_EXECUTE_SYM is the address
/// of the mach header in a Mach-O executable file type. It does not appear in
/// any file type other than a MH_EXECUTE file type. The type of the symbol is
/// absolute as the header is not part of any section.
pub extern "c" var _mh_execute_header: if (@sizeOf(usize) == 8) mach_header_64 else mach_header;
pub const mach_header_64 = macho.mach_header_64;
pub const mach_header = macho.mach_header;
pub use @import("../os/darwin/errno.zig");
pub const _errno = __error;
pub const in_port_t = u16;
pub const sa_family_t = u8;
pub const socklen_t = u32;
pub const sockaddr = extern union {
in: sockaddr_in,
in6: sockaddr_in6,
};
pub const sockaddr_in = extern struct {
len: u8,
family: sa_family_t,
port: in_port_t,
addr: u32,
zero: [8]u8,
};
pub const sockaddr_in6 = extern struct {
len: u8,
family: sa_family_t,
port: in_port_t,
flowinfo: u32,
addr: [16]u8,
scope_id: u32,
};
pub const timeval = extern struct {
tv_sec: isize,
tv_usec: isize,
};
pub const timezone = extern struct {
tz_minuteswest: i32,
tz_dsttime: i32,
};
pub const mach_timebase_info_data = extern struct {
numer: u32,
denom: u32,
};
/// Renamed to Stat to not conflict with the stat function.
pub const Stat = extern struct {
dev: i32,
mode: u16,
nlink: u16,
ino: u64,
uid: u32,
gid: u32,
rdev: i32,
atime: usize,
atimensec: usize,
mtime: usize,
mtimensec: usize,
ctime: usize,
ctimensec: usize,
birthtime: usize,
birthtimensec: usize,
size: i64,
blocks: i64,
blksize: i32,
flags: u32,
gen: u32,
lspare: i32,
qspare: [2]i64,
};
pub const timespec = extern struct {
tv_sec: isize,
tv_nsec: isize,
};
pub const sigset_t = u32;
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
pub const Sigaction = extern struct {
handler: extern fn (c_int) void,
sa_mask: sigset_t,
sa_flags: c_int,
};
pub const dirent = extern struct {
d_ino: usize,
d_seekoff: usize,
d_reclen: u16,
d_namlen: u16,
d_type: u8,
d_name: u8, // field address is address of first byte of name
};
pub const pthread_attr_t = extern struct {
__sig: c_long,
__opaque: [56]u8,
};
/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
pub const Kevent = extern struct {
ident: usize,
filter: i16,
flags: u16,
fflags: u32,
data: isize,
udata: usize,
};
// sys/types.h on macos uses #pragma pack(4) so these checks are
// to make sure the struct is laid out the same. These values were
// produced from C code using the offsetof macro.
const std = @import("../index.zig");
const assert = std.debug.assert;
comptime {
assert(@offsetOf(Kevent, "ident") == 0);
assert(@offsetOf(Kevent, "filter") == 8);
assert(@offsetOf(Kevent, "flags") == 10);
assert(@offsetOf(Kevent, "fflags") == 12);
assert(@offsetOf(Kevent, "data") == 16);
assert(@offsetOf(Kevent, "udata") == 24);
}
pub const kevent64_s = extern struct {
ident: u64,
filter: i16,
flags: u16,
fflags: u32,
data: i64,
udata: u64,
ext: [2]u64,
};
// sys/types.h on macos uses #pragma pack() so these checks are
// to make sure the struct is laid out the same. These values were
// produced from C code using the offsetof macro.
comptime {
assert(@offsetOf(kevent64_s, "ident") == 0);
assert(@offsetOf(kevent64_s, "filter") == 8);
assert(@offsetOf(kevent64_s, "flags") == 10);
assert(@offsetOf(kevent64_s, "fflags") == 12);
assert(@offsetOf(kevent64_s, "data") == 16);
assert(@offsetOf(kevent64_s, "udata") == 24);
assert(@offsetOf(kevent64_s, "ext") == 32);
} | std/c/darwin.zig |
const builtin = std.builtin;
const std = @import("std");
const io = std.io;
const meta = std.meta;
pub fn toMagicNumberNative(magic: []const u8) u32 {
var result: u32 = 0;
for (magic) |character, index| {
result |= (@as(u32, character) << @intCast(u5, (index * 8)));
}
return result;
}
pub fn toMagicNumberForeign(magic: []const u8) u32 {
var result: u32 = 0;
for (magic) |character, index| {
result |= (@as(u32, character) << @intCast(u5, (magic.len - 1 - index) * 8));
}
return result;
}
pub const toMagicNumberBig = switch (builtin.endian) {
builtin.Endian.Little => toMagicNumberForeign,
builtin.Endian.Big => toMagicNumberNative,
};
pub const toMagicNumberLittle = switch (builtin.endian) {
builtin.Endian.Little => toMagicNumberNative,
builtin.Endian.Big => toMagicNumberForeign,
};
pub fn readStructNative(reader: io.StreamSource.Reader, comptime T: type) !T {
return try reader.readStruct(T);
}
pub fn readStructForeign(reader: io.StreamSource.Reader, comptime T: type) !T {
comptime std.debug.assert(@typeInfo(T).Struct.layout != builtin.TypeInfo.ContainerLayout.Auto);
var result: T = undefined;
inline for (meta.fields(T)) |entry| {
switch (@typeInfo(entry.field_type)) {
.ComptimeInt, .Int => {
@field(result, entry.name) = try reader.readIntForeign(entry.field_type);
},
.Struct => {
@field(result, entry.name) = try readStructForeign(reader, entry.field_type);
},
.Enum => {
@field(result, entry.name) = try reader.readEnum(entry.field_type, switch (builtin.endian) {
builtin.Endian.Little => builtin.Endian.Big,
builtin.Endian.Big => builtin.Endian.Little,
});
},
else => {
std.debug.panic("Add support for type {} in readStructForeign", .{@typeName(entry.field_type)});
},
}
}
return result;
}
pub const readStructLittle = switch (builtin.endian) {
builtin.Endian.Little => readStructNative,
builtin.Endian.Big => readStructForeign,
};
pub const readStructBig = switch (builtin.endian) {
builtin.Endian.Little => readStructForeign,
builtin.Endian.Big => readStructNative,
}; | src/utils.zig |
const std = @import("std");
const deps = @import("./deps.zig");
pub fn build(b: *std.build.Builder) void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions();
const exe_names_and_files = [2][2][]const u8{
[2][]const u8{ "server", "src/server.zig" },
[2][]const u8{ "benchmark", "src/benchmarks.zig" },
};
for (exe_names_and_files) |e| {
const exe = b.addExecutable(e[0], e[1]);
exe.setTarget(target);
exe.setBuildMode(mode);
deps.addAllTo(exe);
exe.install();
const run_cmd = exe.run();
exe.linkSystemLibrary("soundio");
exe.linkLibC();
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
var buf_name_cmd: [100]u8 = undefined;
var buf_explanation: [100]u8 = undefined;
const name_cmd = std.fmt.bufPrint(&buf_name_cmd, "run_{s}", .{e[0]}) catch {
continue;
};
const explanation = std.fmt.bufPrint(&buf_explanation, "Run {s}", .{e[1]}) catch {
continue;
};
const run_step = b.step(name_cmd, explanation);
run_step.dependOn(&run_cmd.step);
const install_exe = b.addInstallArtifact(exe);
b.getInstallStep().dependOn(&install_exe.step);
}
// const bench_step = b.step("benchmark", "Run benchmarks");
// bench_step.dependOn(&exe_bench.step);
const test_step = b.step("test", "Run unit tests");
const files = [_][]const u8{
"src/server.zig", "src/instruments.zig", "src/network.zig",
};
for (files) |f| {
const exe_tests = b.addTest(f);
exe_tests.setTarget(target);
exe_tests.setBuildMode(mode);
deps.addAllTo(exe_tests);
test_step.dependOn(&exe_tests.step);
}
} | build.zig |
const std = @import("std");
const mem = std.mem;
const unicode = std.unicode;
const ascii = @import("../ascii.zig");
const Context = @import("../Context.zig");
const Letter = @import("../ziglyph.zig").Letter;
pub const CodePointIterator = @import("CodePointIterator.zig");
pub const GraphemeIterator = @import("GraphemeIterator.zig");
pub const Grapheme = GraphemeIterator.Grapheme;
pub const Width = @import("../components/aggregate/Width.zig");
const Self = @This();
/// Factory creates Zigstr instances and manages memory and singleton data structures for them.
pub const Factory = struct {
arena: std.heap.ArenaAllocator,
context: *Context,
letter: Letter,
width: Width,
pub fn init(ctx: *Context) !Factory {
return Factory{
.arena = std.heap.ArenaAllocator.init(ctx.allocator),
.context = ctx,
.letter = Letter.new(ctx),
.width = try Width.new(ctx),
};
}
pub fn deinit(self: *Factory) void {
self.arena.deinit();
}
/// new creates a new Zigstr instance.
pub fn new(factory: *Factory, str: []const u8) !Self {
var zstr = Self{
.allocator = &factory.arena.allocator,
.ascii_only = false,
.bytes = blk: {
var b = try factory.arena.allocator.alloc(u8, str.len);
mem.copy(u8, b, str);
break :blk b;
},
.code_points = null,
.cp_count = 0,
.factory = factory,
.grapheme_clusters = null,
};
// Validates UTF-8, sets cp_count and ascii_only.
try zstr.processCodePoints();
return zstr;
}
};
allocator: *mem.Allocator,
ascii_only: bool,
bytes: []const u8,
code_points: ?[]u21,
cp_count: usize,
factory: *Factory,
grapheme_clusters: ?[]Grapheme,
/// reset this Zigstr with `str` as its new content.
pub fn reset(self: *Self, str: []const u8) !void {
// Copy befor deinit becasue maybe str is a slice of self.bytes.
var bytes = try self.allocator.alloc(u8, str.len);
mem.copy(u8, bytes, str);
// Free and reset old content.
if (self.code_points) |code_points| {
self.allocator.free(code_points);
}
if (self.grapheme_clusters) |gcs| {
self.allocator.free(gcs);
}
self.code_points = null;
self.cp_count = 0;
self.grapheme_clusters = null;
self.allocator.free(self.bytes);
// New content.
self.bytes = bytes;
// Validates UTF-8, sets cp_count and ascii_only.
try self.processCodePoints();
}
/// resetOwned resets this Zigstr with `bytes` as its new content.
pub fn resetOwned(self: *Self, bytes: []const u8) !void {
// Free and reset old content.
if (self.code_points) |code_points| {
self.allocator.free(code_points);
}
if (self.grapheme_clusters) |gcs| {
self.allocator.free(gcs);
}
self.code_points = null;
self.cp_count = 0;
self.grapheme_clusters = null;
self.allocator.free(self.bytes);
// New content.
self.bytes = bytes;
// Validates UTF-8, sets cp_count and ascii_only.
try self.processCodePoints();
}
/// byteCount returns the number of bytes, which can be different from the number of code points and the
/// number of graphemes.
pub fn byteCount(self: Self) usize {
return self.bytes.len;
}
/// codePointIter returns a code point iterator based on the bytes of this Zigstr.
pub fn codePointIter(self: Self) !CodePointIterator {
return CodePointIterator.init(self.bytes);
}
/// codePoints returns the code points that make up this Zigstr.
pub fn codePoints(self: *Self) ![]u21 {
// Check for cached code points.
if (self.code_points) |code_points| return code_points;
// Cache miss, generate.
var cp_iter = try self.codePointIter();
var code_points = std.ArrayList(u21).init(self.allocator);
defer code_points.deinit();
while (cp_iter.next()) |cp| {
try code_points.append(cp);
}
// Cache.
self.code_points = code_points.toOwnedSlice();
return self.code_points.?;
}
/// codePointCount returns the number of code points, which can be different from the number of bytes
/// and the number of graphemes.
pub fn codePointCount(self: *Self) usize {
return self.cp_count;
}
const expectEqual = std.testing.expectEqual;
const expectEqualSlices = std.testing.expectEqualSlices;
test "Zigstr code points" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new("Héllo");
var cp_iter = try str.codePointIter();
var want = [_]u21{ 'H', 0x00E9, 'l', 'l', 'o' };
var i: usize = 0;
while (cp_iter.next()) |cp| : (i += 1) {
expectEqual(want[i], cp);
}
expectEqual(@as(usize, 5), str.codePointCount());
expectEqualSlices(u21, &want, try str.codePoints());
expectEqual(@as(usize, 6), str.byteCount());
expectEqual(@as(usize, 5), str.codePointCount());
}
/// graphemeIter returns a grapheme cluster iterator based on the bytes of this Zigstr. Each grapheme
/// can be composed of multiple code points, so the next method returns a slice of bytes.
pub fn graphemeIter(self: Self) !GraphemeIterator {
return GraphemeIterator.new(self.factory.context, self.bytes);
}
/// graphemes returns the grapheme clusters that make up this Zigstr.
pub fn graphemes(self: *Self) ![]Grapheme {
// Check for cached code points.
if (self.grapheme_clusters) |gcs| return gcs;
// Cache miss, generate.
var giter = try self.graphemeIter();
var gcs = std.ArrayList(Grapheme).init(self.allocator);
defer gcs.deinit();
while (try giter.next()) |gc| {
try gcs.append(gc);
}
// Cache.
self.grapheme_clusters = gcs.toOwnedSlice();
return self.grapheme_clusters.?;
}
/// graphemeCount returns the number of grapheme clusters, which can be different from the number of bytes
/// and the number of code points.
pub fn graphemeCount(self: *Self) !usize {
if (self.grapheme_clusters) |gcs| {
return gcs.len;
} else {
return (try self.graphemes()).len;
}
}
const expectEqualStrings = std.testing.expectEqualStrings;
test "Zigstr graphemes" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new("Héllo");
var giter = try str.graphemeIter();
var want = [_][]const u8{ "H", "é", "l", "l", "o" };
var i: usize = 0;
while (try giter.next()) |gc| : (i += 1) {
expect(gc.eql(want[i]));
}
expectEqual(@as(usize, 5), try str.graphemeCount());
const gcs = try str.graphemes();
for (gcs) |gc, j| {
expect(gc.eql(want[j]));
}
expectEqual(@as(usize, 6), str.byteCount());
expectEqual(@as(usize, 5), try str.graphemeCount());
}
/// copy a Zigstr to a new Zigstr. Don't forget to to `deinit` the returned Zigstr!
pub fn copy(self: Self) !Self {
return self.factory.new(self.bytes);
}
/// sameAs convenience method to test exact byte equality of two Zigstrs.
pub fn sameAs(self: Self, other: Self) bool {
return self.eql(other.bytes);
}
const expect = std.testing.expect;
test "Zigstr copy" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str1 = try zigstr.new("Zig");
var str2 = try str1.copy();
expect(str1.eql(str2.bytes));
expect(str2.eql("Zig"));
expect(str1.sameAs(str2));
}
pub const CmpMode = enum {
ignore_case,
normalize,
norm_ignore,
};
/// eql compares for exact byte per byte equality with `other`.
pub fn eql(self: Self, other: []const u8) bool {
return mem.eql(u8, self.bytes, other);
}
/// eqlBy compares for equality with `other` according to the specified comparison mode.
pub fn eqlBy(self: *Self, other: []const u8, mode: CmpMode) !bool {
// Check for ASCII only comparison.
var ascii_only = self.ascii_only;
if (ascii_only) {
ascii_only = try isAsciiStr(other);
}
// If ASCII only, different lengths mean inequality.
const len_a = self.bytes.len;
const len_b = other.len;
var len_eql = len_a == len_b;
if (ascii_only and !len_eql) return false;
if (mode == .ignore_case and len_eql) {
if (ascii_only) {
// ASCII case insensitive.
for (self.bytes) |c, i| {
if (ascii.toLower(c) != ascii.toLower(other[i])) return false;
}
return true;
}
// Non-ASCII case insensitive.
return self.eqlIgnoreCase(other);
}
if (mode == .normalize) return self.eqlNorm(other);
if (mode == .norm_ignore) return self.eqlNormIgnore(other);
return false;
}
fn eqlIgnoreCase(self: *Self, other: []const u8) !bool {
const fold_map = try self.factory.context.getCaseFoldMap();
const cf_a = try fold_map.caseFoldStr(self.allocator, self.bytes);
defer self.allocator.free(cf_a);
const cf_b = try fold_map.caseFoldStr(self.allocator, other);
defer self.allocator.free(cf_b);
return mem.eql(u8, cf_a, cf_b);
}
fn eqlNorm(self: *Self, other: []const u8) !bool {
var arena = std.heap.ArenaAllocator.init(self.allocator);
defer arena.deinit();
const decomp_map = try self.factory.context.getDecomposeMap();
const norm_a = try decomp_map.normalizeTo(&arena.allocator, .KD, self.bytes);
const norm_b = try decomp_map.normalizeTo(&arena.allocator, .KD, other);
return mem.eql(u8, norm_a, norm_b);
}
fn eqlNormIgnore(self: *Self, other: []const u8) !bool {
var arena = std.heap.ArenaAllocator.init(self.allocator);
defer arena.deinit();
const decomp_map = try self.factory.context.getDecomposeMap();
const fold_map = try self.factory.context.getCaseFoldMap();
// The long winding road of normalized caseless matching...
// NFKD(CaseFold(NFKD(CaseFold(NFD(str)))))
var norm_a = try decomp_map.normalizeTo(&arena.allocator, .D, self.bytes);
var cf_a = try fold_map.caseFoldStr(&arena.allocator, norm_a);
norm_a = try decomp_map.normalizeTo(&arena.allocator, .KD, cf_a);
cf_a = try fold_map.caseFoldStr(&arena.allocator, norm_a);
norm_a = try decomp_map.normalizeTo(&arena.allocator, .KD, cf_a);
var norm_b = try decomp_map.normalizeTo(&arena.allocator, .D, other);
var cf_b = try fold_map.caseFoldStr(&arena.allocator, norm_b);
norm_b = try decomp_map.normalizeTo(&arena.allocator, .KD, cf_b);
cf_b = try fold_map.caseFoldStr(&arena.allocator, norm_b);
norm_b = try decomp_map.normalizeTo(&arena.allocator, .KD, cf_b);
return mem.eql(u8, norm_a, norm_b);
}
test "Zigstr eql" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new("foo");
expect(str.eql("foo")); // exact
expect(!str.eql("fooo")); // lengths
expect(!str.eql("foó")); // combining
expect(!str.eql("Foo")); // letter case
expect(try str.eqlBy("Foo", .ignore_case));
try str.reset("foé");
expect(try str.eqlBy("foe\u{0301}", .normalize));
try str.reset("foϓ");
expect(try str.eqlBy("foΥ\u{0301}", .normalize));
try str.reset("Foϓ");
expect(try str.eqlBy("foΥ\u{0301}", .norm_ignore));
try str.reset("FOÉ");
expect(try str.eqlBy("foe\u{0301}", .norm_ignore)); // foÉ == foé
}
/// isAsciiStr checks if a string (`[]const uu`) is composed solely of ASCII characters.
pub fn isAsciiStr(str: []const u8) !bool {
// Shamelessly stolen from std.unicode.
const N = @sizeOf(usize);
const MASK = 0x80 * (std.math.maxInt(usize) / 0xff);
var i: usize = 0;
while (i < str.len) {
// Fast path for ASCII sequences
while (i + N <= str.len) : (i += N) {
const v = mem.readIntNative(usize, str[i..][0..N]);
if (v & MASK != 0) {
return false;
}
}
if (i < str.len) {
const n = try unicode.utf8ByteSequenceLength(str[i]);
if (i + n > str.len) return error.TruncatedInput;
switch (n) {
1 => {}, // ASCII
else => return false,
}
i += n;
}
}
return true;
}
test "Zigstr isAsciiStr" {
expect(try isAsciiStr("Hello!"));
expect(!try isAsciiStr("Héllo!"));
}
/// trimLeft removes `str` from the left of this Zigstr, mutating it.
pub fn trimLeft(self: *Self, str: []const u8) !void {
const trimmed = mem.trimLeft(u8, self.bytes, str);
try self.reset(trimmed);
}
test "Zigstr trimLeft" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new(" Hello");
try str.trimLeft(" ");
expect(str.eql("Hello"));
}
/// trimRight removes `str` from the right of this Zigstr, mutating it.
pub fn trimRight(self: *Self, str: []const u8) !void {
const trimmed = mem.trimRight(u8, self.bytes, str);
try self.reset(trimmed);
}
test "Zigstr trimRight" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new("Hello ");
try str.trimRight(" ");
expect(str.eql("Hello"));
}
/// trim removes `str` from both the left and right of this Zigstr, mutating it.
pub fn trim(self: *Self, str: []const u8) !void {
const trimmed = mem.trim(u8, self.bytes, str);
try self.reset(trimmed);
}
test "Zigstr trim" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new(" Hello ");
try str.trim(" ");
expect(str.eql("Hello"));
}
/// indexOf returns the index of `needle` in this Zigstr or null if not found.
pub fn indexOf(self: Self, needle: []const u8) ?usize {
return mem.indexOf(u8, self.bytes, needle);
}
/// containes ceonvenience method to check if `str` is a substring of this Zigstr.
pub fn contains(self: Self, str: []const u8) bool {
return self.indexOf(str) != null;
}
test "Zigstr indexOf" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new("Hello");
expectEqual(str.indexOf("l"), 2);
expectEqual(str.indexOf("z"), null);
expect(str.contains("l"));
expect(!str.contains("z"));
}
/// lastIndexOf returns the index of `needle` in this Zigstr starting from the end, or null if not found.
pub fn lastIndexOf(self: Self, needle: []const u8) ?usize {
return mem.lastIndexOf(u8, self.bytes, needle);
}
test "Zigstr lastIndexOf" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new("Hello");
expectEqual(str.lastIndexOf("l"), 3);
expectEqual(str.lastIndexOf("z"), null);
}
/// count returns the number of `needle`s in this Zigstr.
pub fn count(self: Self, needle: []const u8) usize {
return mem.count(u8, self.bytes, needle);
}
test "Zigstr count" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new("Hello");
expectEqual(str.count("l"), 2);
expectEqual(str.count("ll"), 1);
expectEqual(str.count("z"), 0);
}
/// tokenIter returns an iterator on tokens resulting from splitting this Zigstr at every `delim`.
/// Semantics are that of `std.mem.tokenize`.
pub fn tokenIter(self: Self, delim: []const u8) mem.TokenIterator {
return mem.tokenize(self.bytes, delim);
}
/// tokenize returns a slice of tokens resulting from splitting this Zigstr at every `delim`.
pub fn tokenize(self: Self, delim: []const u8) ![][]const u8 {
var ts = std.ArrayList([]const u8).init(self.allocator);
defer ts.deinit();
var iter = self.tokenIter(delim);
while (iter.next()) |t| {
try ts.append(t);
}
return ts.toOwnedSlice();
}
test "Zigstr tokenize" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new(" Hello World ");
var iter = str.tokenIter(" ");
expectEqualStrings("Hello", iter.next().?);
expectEqualStrings("World", iter.next().?);
expect(iter.next() == null);
var ts = try str.tokenize(" ");
expectEqual(@as(usize, 2), ts.len);
expectEqualStrings("Hello", ts[0]);
expectEqualStrings("World", ts[1]);
}
/// splitIter returns an iterator on substrings resulting from splitting this Zigstr at every `delim`.
/// Semantics are that of `std.mem.split`.
pub fn splitIter(self: Self, delim: []const u8) mem.SplitIterator {
return mem.split(self.bytes, delim);
}
/// split returns a slice of substrings resulting from splitting this Zigstr at every `delim`.
pub fn split(self: Self, delim: []const u8) ![][]const u8 {
var ss = std.ArrayList([]const u8).init(self.allocator);
defer ss.deinit();
var iter = self.splitIter(delim);
while (iter.next()) |s| {
try ss.append(s);
}
return ss.toOwnedSlice();
}
test "Zigstr split" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new(" Hello World ");
var iter = str.splitIter(" ");
expectEqualStrings("", iter.next().?);
expectEqualStrings("Hello", iter.next().?);
expectEqualStrings("World", iter.next().?);
expectEqualStrings("", iter.next().?);
expect(iter.next() == null);
var ss = try str.split(" ");
expectEqual(@as(usize, 4), ss.len);
expectEqualStrings("", ss[0]);
expectEqualStrings("Hello", ss[1]);
expectEqualStrings("World", ss[2]);
expectEqualStrings("", ss[3]);
}
/// startsWith returns true if this Zigstr starts with `str`.
pub fn startsWith(self: Self, str: []const u8) bool {
return mem.startsWith(u8, self.bytes, str);
}
test "Zigstr startsWith" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new("Hello World ");
expect(str.startsWith("Hell"));
expect(!str.startsWith("Zig"));
}
/// endsWith returns true if this Zigstr ends with `str`.
pub fn endsWith(self: Self, str: []const u8) bool {
return mem.endsWith(u8, self.bytes, str);
}
test "Zigstr endsWith" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new("Hello World");
expect(str.endsWith("World"));
expect(!str.endsWith("Zig"));
}
/// Refer to the docs for `std.mem.join`.
pub const join = mem.join;
test "Zigstr join" {
var allocator = std.testing.allocator;
const result = try join(allocator, "/", &[_][]const u8{ "this", "is", "a", "path" });
defer allocator.free(result);
expectEqualSlices(u8, "this/is/a/path", result);
}
/// concatAll appends each string in `others` to this Zigstr, mutating it.
pub fn concatAll(self: *Self, others: [][]const u8) !void {
if (others.len == 0) return;
const total_len = blk: {
var sum: usize = 0;
for (others) |slice| {
sum += slice.len;
}
sum += self.bytes.len;
break :blk sum;
};
const buf = try self.allocator.alloc(u8, total_len);
mem.copy(u8, buf, self.bytes);
var buf_index: usize = self.bytes.len;
for (others) |slice| {
mem.copy(u8, buf[buf_index..], slice);
buf_index += slice.len;
}
// No need for shrink since buf is exactly the correct size.
try self.resetOwned(buf);
}
/// concat appends `other` to this Zigstr, mutating it.
pub fn concat(self: *Self, other: []const u8) !void {
try self.concatAll(&[1][]const u8{other});
}
test "Zigstr concat" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new("Hello");
try str.concat(" World");
expectEqualStrings("Hello World", str.bytes);
var others = [_][]const u8{ " is", " the", " tradition!" };
try str.concatAll(&others);
expectEqualStrings("Hello World is the tradition!", str.bytes);
}
/// replace all occurrences of `needle` with `replacement`, mutating this Zigstr. Returns the total
/// replacements made.
pub fn replace(self: *Self, needle: []const u8, replacement: []const u8) !usize {
const len = mem.replacementSize(u8, self.bytes, needle, replacement);
var buf = try self.allocator.alloc(u8, len);
const replacements = mem.replace(u8, self.bytes, needle, replacement, buf);
if (replacement.len == 0) buf = self.allocator.shrink(buf, (len + 1) - needle.len * replacements);
try self.resetOwned(buf);
return replacements;
}
test "Zigstr replace" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new("Hello");
var replacements = try str.replace("l", "z");
expectEqual(@as(usize, 2), replacements);
expect(str.eql("Hezzo"));
replacements = try str.replace("z", "");
expectEqual(@as(usize, 2), replacements);
expect(str.eql("Heo"));
}
/// append adds `cp` to the end of this Zigstr, mutating it.
pub fn append(self: *Self, cp: u21) !void {
var buf: [4]u8 = undefined;
const len = try unicode.utf8Encode(cp, &buf);
try self.concat(buf[0..len]);
}
/// append adds `cp` to the end of this Zigstr, mutating it.
pub fn appendAll(self: *Self, cp_list: []const u21) !void {
var cp_bytes = std.ArrayList(u8).init(self.allocator);
defer cp_bytes.deinit();
var buf: [4]u8 = undefined;
for (cp_list) |cp| {
const len = try unicode.utf8Encode(cp, &buf);
try cp_bytes.appendSlice(buf[0..len]);
}
try self.concat(cp_bytes.items);
}
test "Zigstr append" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new("Hell");
try str.append('o');
expectEqual(@as(usize, 5), str.bytes.len);
expect(str.eql("Hello"));
try str.appendAll(&[_]u21{ ' ', 'W', 'o', 'r', 'l', 'd' });
expectEqual(@as(usize, 11), str.bytes.len);
expect(str.eql("Hello World"));
}
/// empty returns true if this Zigstr has no bytes.
pub fn empty(self: Self) bool {
return self.bytes.len == 0;
}
/// chomp will remove trailing \n or \r\n from this Zigstr, mutating it.
pub fn chomp(self: *Self) !void {
if (self.empty()) return;
const len = self.bytes.len;
const last = self.bytes[len - 1];
if (last == '\r' or last == '\n') {
// CR
var chomp_size: usize = 1;
if (len > 1 and last == '\n' and self.bytes[len - 2] == '\r') chomp_size = 2; // CR+LF
try self.reset(self.bytes[0 .. len - chomp_size]);
}
}
test "Zigstr chomp" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new("Hello\n");
try str.chomp();
expectEqual(@as(usize, 5), str.bytes.len);
expect(str.eql("Hello"));
try str.reset("Hello\r");
try str.chomp();
expectEqual(@as(usize, 5), str.bytes.len);
expect(str.eql("Hello"));
try str.reset("Hello\r\n");
try str.chomp();
expectEqual(@as(usize, 5), str.bytes.len);
expect(str.eql("Hello"));
}
/// byteAt returns the byte at index `i`.
pub fn byteAt(self: Self, i: usize) !u8 {
if (i >= self.bytes.len) return error.IndexOutOfBounds;
return self.bytes[i];
}
/// codePointAt returns the `i`th code point.
pub fn codePointAt(self: *Self, i: usize) !u21 {
if (i >= self.cp_count) return error.IndexOutOfBounds;
return (try self.codePoints())[i];
}
/// graphemeAt returns the `i`th grapheme cluster.
pub fn graphemeAt(self: *Self, i: usize) !Grapheme {
const gcs = try self.graphemes();
if (i >= gcs.len) return error.IndexOutOfBounds;
return gcs[i];
}
const expectError = std.testing.expectError;
test "Zigstr xAt" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new("H\u{0065}\u{0301}llo");
expectEqual(try str.byteAt(2), 0x00CC);
expectError(error.IndexOutOfBounds, str.byteAt(7));
expectEqual(try str.codePointAt(1), 0x0065);
expectError(error.IndexOutOfBounds, str.codePointAt(6));
expect((try str.graphemeAt(1)).eql("\u{0065}\u{0301}"));
expectError(error.IndexOutOfBounds, str.graphemeAt(5));
}
/// byteSlice returnes the bytes from this Zigstr in the specified range from `start` to `end` - 1.
pub fn byteSlice(self: Self, start: usize, end: usize) ![]const u8 {
if (start >= self.bytes.len or end > self.bytes.len) return error.IndexOutOfBounds;
return self.bytes[start..end];
}
/// codePointSlice returnes the code points from this Zigstr in the specified range from `start` to `end` - 1.
pub fn codePointSlice(self: *Self, start: usize, end: usize) ![]const u21 {
if (start >= self.cp_count or end > self.cp_count) return error.IndexOutOfBounds;
return (try self.codePoints())[start..end];
}
/// graphemeSlice returnes the grapheme clusters from this Zigstr in the specified range from `start` to `end` - 1.
pub fn graphemeSlice(self: *Self, start: usize, end: usize) ![]Grapheme {
const gcs = try self.graphemes();
if (start >= gcs.len or end > gcs.len) return error.IndexOutOfBounds;
return gcs[start..end];
}
/// substr returns a new Zigstr composed from the grapheme range starting at `start` grapheme index
/// up to `end` grapheme index - 1. Don't forget to to `deinit` the returned Zigstr!
pub fn substr(self: *Self, start: usize, end: usize) !Self {
if (self.ascii_only) {
if (start >= self.bytes.len or end > self.bytes.len) return error.IndexOutOfBounds;
return self.factory.new(self.bytes[start..end]);
}
const gcs = try self.graphemes();
if (start >= gcs.len or end > gcs.len) return error.IndexOutOfBounds;
var bytes = std.ArrayList(u8).init(self.allocator);
defer bytes.deinit();
var i: usize = start;
while (i < end) : (i += 1) {
try bytes.appendSlice(gcs[i].bytes);
}
return self.factory.new(bytes.items);
}
test "Zigstr extractions" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new("H\u{0065}\u{0301}llo");
// Slices
expectEqualSlices(u8, try str.byteSlice(1, 4), "\u{0065}\u{0301}");
expectEqualSlices(u21, try str.codePointSlice(1, 3), &[_]u21{ '\u{0065}', '\u{0301}' });
const gc1 = try str.graphemeSlice(1, 2);
expect(gc1[0].eql("\u{0065}\u{0301}"));
// Substrings
var str2 = try str.substr(1, 2);
expect(str2.eql("\u{0065}\u{0301}"));
expect(str2.eql(try str.byteSlice(1, 4)));
}
/// processCodePoints performs some house-keeping and accounting on the code points that make up this
/// Zigstr. Asserts that our bytes are valid UTF-8.
pub fn processCodePoints(self: *Self) !void {
// Shamelessly stolen from std.unicode.
var ascii_only = true;
var len: usize = 0;
const N = @sizeOf(usize);
const MASK = 0x80 * (std.math.maxInt(usize) / 0xff);
var i: usize = 0;
while (i < self.bytes.len) {
// Fast path for ASCII sequences
while (i + N <= self.bytes.len) : (i += N) {
const v = mem.readIntNative(usize, self.bytes[i..][0..N]);
if (v & MASK != 0) {
ascii_only = false;
break;
}
len += N;
}
if (i < self.bytes.len) {
const n = try unicode.utf8ByteSequenceLength(self.bytes[i]);
if (i + n > self.bytes.len) return error.TruncatedInput;
switch (n) {
1 => {}, // ASCII, no validation needed
else => {
_ = try unicode.utf8Decode(self.bytes[i .. i + n]);
ascii_only = false;
},
}
i += n;
len += 1;
}
}
self.ascii_only = ascii_only;
self.cp_count = len;
}
/// isLower detects if all the code points in this Zigstr are lowercase.
pub fn isLower(self: *Self) !bool {
for (try self.codePoints()) |cp| {
if (!try self.factory.letter.isLower(cp)) return false;
}
return true;
}
/// toLower converts this Zigstr to lowercase, mutating it.
pub fn toLower(self: *Self) !void {
var bytes = std.ArrayList(u8).init(self.allocator);
defer bytes.deinit();
var buf: [4]u8 = undefined;
for (try self.codePoints()) |cp| {
const lcp = try self.factory.letter.toLower(cp);
const len = try unicode.utf8Encode(lcp, &buf);
try bytes.appendSlice(buf[0..len]);
}
try self.reset(bytes.items);
}
/// isUpper detects if all the code points in this Zigstr are uppercase.
pub fn isUpper(self: *Self) !bool {
for (try self.codePoints()) |cp| {
if (!try self.factory.letter.isUpper(cp)) return false;
}
return true;
}
/// toUpper converts this Zigstr to uppercase, mutating it.
pub fn toUpper(self: *Self) !void {
var bytes = std.ArrayList(u8).init(self.allocator);
defer bytes.deinit();
var buf: [4]u8 = undefined;
for (try self.codePoints()) |cp| {
const lcp = try self.factory.letter.toUpper(cp);
const len = try unicode.utf8Encode(lcp, &buf);
try bytes.appendSlice(buf[0..len]);
}
try self.reset(bytes.items);
}
test "Zigstr casing" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new("Héllo! 123");
expect(!try str.isLower());
expect(!try str.isUpper());
try str.toLower();
expect(try str.isLower());
expect(str.eql("héllo! 123"));
try str.toUpper();
expect(try str.isUpper());
expect(str.eql("HÉLLO! 123"));
}
/// format implements the `std.fmt` format interface for printing types.
pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
_ = try writer.print("{s}", .{self.bytes});
}
test "Zigstr format" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new("Hi, I'm a Zigstr! 😊");
std.debug.print("{}\n", .{str});
}
/// width returns the cells (or columns) this Zigstr would occupy in a fixed-width context.
pub fn width(self: Self) !usize {
return self.factory.width.strWidth(self.bytes, .half);
}
test "Zigstr width" {
var ctx = Context.init(std.testing.allocator);
defer ctx.deinit();
var zigstr = try Factory.init(&ctx);
defer zigstr.deinit();
var str = try zigstr.new("Héllo 😊");
expectEqual(@as(usize, 8), try str.width());
} | src/zigstr/Zigstr.zig |
const w4 = @import("wasm4.zig");
const std = @import("std");
const Snake = @import("snake.zig").Snake;
var snake = Snake.init();
var prev_state1: u8 = 0;
pub const Vec2 = @import("std").meta.Vector(2, i32);
const sin = std.math.sin;
fn sinI(n: anytype, amplitude: f32, wavetime: f32) i32 {
// switch(@TypeOf(n)) {
// i32 => return @floatToInt(i32, std.math.absFloat(sin(@intToFloat(f32, n)))*amplitude),
// u128 => return @floatToInt(i32, std.math.absFloat(sin(@intToFloat(f32, n)))*amplitude),
// else => {
// return 0;
// }
// }
return @floatToInt(i32, std.math.absFloat(sin(@intToFloat(f32, n) * wavetime)) * amplitude);
}
const cos = std.math.cos;
const tan = std.math.tan;
const absI = std.math.absInt;
const abs = std.math.absFloat;
fn distance(a: Vec2, b: Vec2) i32 {
var c: Vec2 = a - b;
var d: i32 = c[0] * c[0] + c[1] * c[1];
var s: f32 = std.math.sqrt(@intToFloat(f32, d));
return @floatToInt(i32, @round(s));
}
var time: i32 = 0;
var mpos: Vec2 = Vec2{ 0, 0 };
var dragstart: Vec2 = Vec2{ -1, -1 };
var dragstartul: Vec2 = Vec2{ 10, 10 };
// var mouse: w4.Mouse = w4.Mouse
// function pointers can grow up size quickly
fn defaultPress(self: *Button) void {
self.state = Button.States.pressed;
w4.tone(w4.ToneFrequency{ .start = 200 }, w4.ToneDuration{ .decay = 4 }, 50, w4.ToneFlags{ .channel = w4.ToneFlags.Channel.pulse1, .mode = w4.ToneFlags.Mode.p12_5 });
dragstart = mpos;
dragstartul = self.*.ul;
}
fn defaultPressed(self: *Button) void {
var prevcolor = w4.DRAW_COLORS.*;
w4.text("some pressed button function", self.*.ul + Vec2{15, 0});
w4.DRAW_COLORS.* = 0x1;
self.*.ul = dragstartul + mpos - dragstart;
w4.oval(self.*.ul, self.*.wh);
w4.DRAW_COLORS.* = prevcolor;
w4.tone(w4.ToneFrequency{ .start = 200 }, w4.ToneDuration{ .decay = 4 }, 50, w4.ToneFlags{ .channel = w4.ToneFlags.Channel.pulse1, .mode = w4.ToneFlags.Mode.p12_5 });
}
fn defaultRelease(self: *Button) void {
self.state = Button.States.idle;
}
fn defaultIdle(self: * Button) void {
w4.oval(self.*.ul, self.*.wh);
w4.text("some text", self.*.ul + Vec2{15, 0});
}
fn defaultHover(self: * Button) void {
var prevcolor = w4.DRAW_COLORS.*;
w4.DRAW_COLORS.* = 0x0043;
w4.oval(self.*.ul, self.*.wh);
w4.DRAW_COLORS.* = prevcolor;
}
const bFn = [_]fn (self: * Button) void{ defaultIdle, defaultHover, defaultPress };
const Button = struct {
const Self = @This(); // how to use this?
pub const States = enum(u2){
idle,
hovered,
pressed,
};
onPress: fn (self: * Button) void = defaultPress, // array of functions that button call when pressed
onPressed: fn (self: * Button) void = defaultPressed,
onRelease: fn (self: * Button) void = defaultRelease,
ul: Vec2 = Vec2{ 10, 10 },
wh: Vec2 = Vec2{ 10, 10 },
color: u2 = 0,
onIdle: u8 = 0, //id of function to call on idle to draw button
onHover: u8 = 1,
state: States = States.idle,
pub fn isInRect(self: Self, point: Vec2) bool {
if ((point[0] > self.ul[0]) and (point[0] < self.ul[0] + self.wh[0]) and (point[1] > self.ul[1]) and (point[1] < self.ul[1] + self.wh[1])) {
return true;
} else {
return false;
}
}
pub fn isInCircle(self: Self, point: Vec2) bool {
if (distance(Vec2{ self.ul[0] + @divFloor(self.wh[0], 2) + 1, self.ul[1] + @divFloor(self.wh[1], 2) + 1 }, point) < @divFloor(self.wh[0], 2)) {
return true;
} else {
return false;
}
}
};
var btns: [100]Button = [1]Button{.{
.color = undefined,
}} ** 100;
// var btnsImg: [160*160]u2 = undefined; //takes much memory
// fn drawBtns() void {
// for (btns) |btn, i| {
// if (btns[i].color != 0) {
// // btn.ul, btn.wh, btn.color);
// var x: u8 = 0;
// var y: u8 = 0;
// while(x < btn.wh[0] and y < btn.wh[1]) {
// x+=1;
// y+=1;
// btnsImg[(x+btn.ul[0])*(y+btn.ul[1])] = btns[i].color;
// }
// } else {
// break;
// }
// }
// }
export fn start() void {
btns[0] = Button{ .color = 3 };
btns[1] = Button{ .color = 3, .ul = Vec2{ 30, 40 } };
// drawBtns();
w4.PALETTE.* = .{
0,
0x333333,
0x090999,
0x00ffff,
};
}
export fn update() void {
time += 1;
input();
// draw GUI
// w4.blit(btnsImg, .{0, 0}, .{160, 160}, w4.BLIT_2BPP); //to draw button framebuffer
// w4.PALETTE.* = .{
// @intCast(u32, time),
// @floatToInt(u32, std.math.absFloat(sin(@intToFloat(f32, time) / 100) * 60)),
// 0xff33ff,
// 0x234567,
// };
w4.oval(.{ 10, 10 }, .{ 10, @floatToInt(i32, abs(sin(@intToFloat(f32, time) / 100) * 60)) });
w4.text("GAEM\n YES", .{ (sinI(time, 160, 1 / 160)), 20 });
for (w4.FRAMEBUFFER.*) |*x| {
x.* = @intCast(u8, sinI(time + @intCast(i32, @ptrToInt(x)), 2, 56)) << 3;
}
if (@intCast(u32, time) % 5 == 0)
snake.update();
snake.draw();
for (btns) |btn, i| {
if (btn.color != 0) {
//
if (btn.isInCircle(mpos)) {
if (w4.MOUSE.*.buttons.left) {
if(btn.state != Button.States.pressed) {
btn.onPress(&btns[i]);
} else {
btn.onPressed(&btns[i]);
}
} else {
bFn[btn.onHover](&btns[i]);
}
} else {
if(btn.state == Button.States.pressed) {
btn.onRelease(&btns[i]);
}
bFn[btn.onIdle](&btns[i]);
}
} else {
break;
}
}
}
inline fn input() void {
const gamepad1 = w4.GAMEPAD1.*;
// const just_pressed1: u8 = @bitCast(u8, gamepad1) & (@bitCast(u8, gamepad1) ^ prev_state1);
// if(just_pressed1 & w4.
// if(gamepad1.button_down and (just_pressed1 == 0)) {
// w4.DRAW_COLORS.* = 0x4;
// w4.trace("down",.{});
// time = 0;
// }
// prev_state1 = @bitCast(u8,gamepad1);
if (gamepad1.button_up) {
snake.up();
// w4.trace("up", .{});
}
if (gamepad1.button_down) {
snake.down();
// w4.trace("down", .{});
}
if (gamepad1.button_left) {
snake.left();
// w4.trace("left", .{});
}
if (gamepad1.button_right) {
// w4.trace("right", .{});
// time = 0;
snake.right();
}
mpos = w4.Mouse.pos(w4.MOUSE.*);
}
fn example() void {
//
var a: i32 = 0;
var b: i32 = 0;
var c: i32 = 0;
var d: i32 = 0;
var s: [10]u8 = undefined;
_ = d + s[0];
a = std.rand.Isaac64.random();
b = std.rand.Isaac64.random();
c = a + b;
}
test "basic test" {
try std.testing.expectEqual(10, 3 + 7);
} | src/main.zig |
// Some of this is ported from cpython's datetime module
const std = @import("std");
const time = std.time;
const math = std.math;
const ascii = std.ascii;
const Allocator = std.mem.Allocator;
const Order = std.math.Order;
pub const timezones = @import("timezones.zig");
const testing = std.testing;
const assert = std.debug.assert;
// Number of days in each month not accounting for leap year
pub const Weekday = enum(u3) {
Monday = 1,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday,
};
pub const Month = enum(u4) {
January = 1,
February,
March,
April,
May,
June,
July,
August,
September,
October,
November,
December,
// Convert an abbreviation, eg Jan to the enum value
pub fn parseAbbr(month: []const u8) !Month {
if (month.len == 3) {
inline for (std.meta.fields(Month)) |f| {
if (ascii.eqlIgnoreCase(f.name[0..3], month)) {
return @intToEnum(Month, f.value);
}
}
}
return error.InvalidFormat;
}
pub fn parseName(month: []const u8) !Month {
inline for (std.meta.fields(Month)) |f| {
if (ascii.eqlIgnoreCase(f.name, month)) {
return @intToEnum(Month, f.value);
}
}
return error.InvalidFormat;
}
};
test "month-parse-abbr" {
try testing.expectEqual(try Month.parseAbbr("Jan"), .January);
try testing.expectEqual(try Month.parseAbbr("Oct"), .October);
try testing.expectEqual(try Month.parseAbbr("sep"), .September);
try testing.expectError(error.InvalidFormat, Month.parseAbbr("cra"));
}
test "month-parse" {
try testing.expectEqual(try Month.parseName("January"), .January);
try testing.expectEqual(try Month.parseName("OCTOBER"), .October);
try testing.expectEqual(try Month.parseName("july"), .July);
try testing.expectError(error.InvalidFormat, Month.parseName("NoShaveNov"));
}
pub const MIN_YEAR: u16 = 1;
pub const MAX_YEAR: u16 = 9999;
pub const MAX_ORDINAL: u32 = 3652059;
const DAYS_IN_MONTH = [12]u8{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
const DAYS_BEFORE_MONTH = [12]u16{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
pub fn isLeapYear(year: u32) bool {
return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0);
}
pub fn isLeapDay(year: u32, month: u32, day: u32) bool {
return isLeapYear(year) and month == 2 and day == 29;
}
test "leapyear" {
try testing.expect(isLeapYear(2019) == false);
try testing.expect(isLeapYear(2018) == false);
try testing.expect(isLeapYear(2017) == false);
try testing.expect(isLeapYear(2016) == true);
try testing.expect(isLeapYear(2000) == true);
try testing.expect(isLeapYear(1900) == false);
}
// Number of days before Jan 1st of year
pub fn daysBeforeYear(year: u32) u32 {
var y: u32 = year - 1;
return y * 365 + @divFloor(y, 4) - @divFloor(y, 100) + @divFloor(y, 400);
}
// Days before 1 Jan 1970
const EPOCH = daysBeforeYear(1970) + 1;
test "daysBeforeYear" {
try testing.expect(daysBeforeYear(1996) == 728658);
try testing.expect(daysBeforeYear(2019) == 737059);
}
// Number of days in that month for the year
pub fn daysInMonth(year: u32, month: u32) u8 {
assert(1 <= month and month <= 12);
if (month == 2 and isLeapYear(year)) return 29;
return DAYS_IN_MONTH[month - 1];
}
test "daysInMonth" {
try testing.expect(daysInMonth(2019, 1) == 31);
try testing.expect(daysInMonth(2019, 2) == 28);
try testing.expect(daysInMonth(2016, 2) == 29);
}
// Number of days in year preceding the first day of month
pub fn daysBeforeMonth(year: u32, month: u32) u32 {
assert(month >= 1 and month <= 12);
var d = DAYS_BEFORE_MONTH[month - 1];
if (month > 2 and isLeapYear(year)) d += 1;
return d;
}
// Return number of days since 01-Jan-0001
fn ymd2ord(year: u16, month: u8, day: u8) u32 {
assert(month >= 1 and month <= 12);
assert(day >= 1 and day <= daysInMonth(year, month));
return daysBeforeYear(year) + daysBeforeMonth(year, month) + day;
}
test "ymd2ord" {
try testing.expect(ymd2ord(1970, 1, 1) == 719163);
try testing.expect(ymd2ord(28, 2, 29) == 9921);
try testing.expect(ymd2ord(2019, 11, 27) == 737390);
try testing.expect(ymd2ord(2019, 11, 28) == 737391);
}
test "days-before-year" {
const DI400Y = daysBeforeYear(401); // Num of days in 400 years
const DI100Y = daysBeforeYear(101); // Num of days in 100 years
const DI4Y = daysBeforeYear(5); // Num of days in 4 years
// A 4-year cycle has an extra leap day over what we'd get from pasting
// together 4 single years.
try testing.expect(DI4Y == 4 * 365 + 1);
// Similarly, a 400-year cycle has an extra leap day over what we'd get from
// pasting together 4 100-year cycles.
try testing.expect(DI400Y == 4 * DI100Y + 1);
// OTOH, a 100-year cycle has one fewer leap day than we'd get from
// pasting together 25 4-year cycles.
try testing.expect(DI100Y == 25 * DI4Y - 1);
}
// Calculate the number of days of the first monday for week 1 iso calendar
// for the given year since 01-Jan-0001
pub fn daysBeforeFirstMonday(year: u16) u32 {
// From cpython/datetime.py _isoweek1monday
const THURSDAY = 3;
const first_day = ymd2ord(year, 1, 1);
const first_weekday = (first_day + 6) % 7;
var week1_monday = first_day - first_weekday;
if (first_weekday > THURSDAY) {
week1_monday += 7;
}
return week1_monday;
}
test "iso-first-monday" {
// Created using python
const years = [20]u16{
1816, 1823, 1839, 1849, 1849, 1870, 1879, 1882, 1909, 1910,
1917, 1934, 1948, 1965, 1989, 2008, 2064, 2072, 2091, 2096
};
const output = [20]u32{
662915, 665470, 671315, 674969, 674969, 682641, 685924, 687023,
696886, 697250, 699805, 706014, 711124, 717340, 726104, 733041,
753495, 756421, 763358, 765185
};
for (years) |year, i| {
try testing.expectEqual(daysBeforeFirstMonday(year), output[i]);
}
}
pub const ISOCalendar = struct {
year: u16,
week: u6, // Week of year 1-53
weekday: u3, // Day of week 1-7
};
pub const Date = struct {
year: u16,
month: u4 = 1, // Month of year
day: u8 = 1, // Day of month
// Create and validate the date
pub fn create(year: u32, month: u32, day: u32) !Date {
if (year < MIN_YEAR or year > MAX_YEAR) return error.InvalidDate;
if (month < 1 or month > 12) return error.InvalidDate;
if (day < 1 or day > daysInMonth(year, month)) return error.InvalidDate;
// Since we just validated the ranges we can now savely cast
return Date{
.year = @intCast(u16, year),
.month = @intCast(u4, month),
.day = @intCast(u8, day),
};
}
// Return a copy of the date
pub fn copy(self: Date) !Date {
return Date.create(self.year, self.month, self.day);
}
// Create a Date from the number of days since 01-Jan-0001
pub fn fromOrdinal(ordinal: u32) Date {
// n is a 1-based index, starting at 1-Jan-1. The pattern of leap years
// repeats exactly every 400 years. The basic strategy is to find the
// closest 400-year boundary at or before n, then work with the offset
// from that boundary to n. Life is much clearer if we subtract 1 from
// n first -- then the values of n at 400-year boundaries are exactly
// those divisible by DI400Y:
//
// D M Y n n-1
// -- --- ---- ---------- ----------------
// 31 Dec -400 -DI400Y -DI400Y -1
// 1 Jan -399 -DI400Y +1 -DI400Y 400-year boundary
// ...
// 30 Dec 000 -1 -2
// 31 Dec 000 0 -1
// 1 Jan 001 1 0 400-year boundary
// 2 Jan 001 2 1
// 3 Jan 001 3 2
// ...
// 31 Dec 400 DI400Y DI400Y -1
// 1 Jan 401 DI400Y +1 DI400Y 400-year boundary
assert(ordinal >= 1 and ordinal <= MAX_ORDINAL);
var n = ordinal - 1;
const DI400Y = comptime daysBeforeYear(401); // Num of days in 400 years
const DI100Y = comptime daysBeforeYear(101); // Num of days in 100 years
const DI4Y = comptime daysBeforeYear(5); // Num of days in 4 years
const n400 = @divFloor(n, DI400Y);
n = @mod(n, DI400Y);
var year = n400 * 400 + 1; // ..., -399, 1, 401, ...
// Now n is the (non-negative) offset, in days, from January 1 of year, to
// the desired date. Now compute how many 100-year cycles precede n.
// Note that it's possible for n100 to equal 4! In that case 4 full
// 100-year cycles precede the desired day, which implies the desired
// day is December 31 at the end of a 400-year cycle.
const n100 = @divFloor(n, DI100Y);
n = @mod(n, DI100Y);
// Now compute how many 4-year cycles precede it.
const n4 = @divFloor(n, DI4Y);
n = @mod(n, DI4Y);
// And now how many single years. Again n1 can be 4, and again meaning
// that the desired day is December 31 at the end of the 4-year cycle.
const n1 = @divFloor(n, 365);
n = @mod(n, 365);
year += n100 * 100 + n4 * 4 + n1;
if (n1 == 4 or n100 == 4) {
assert(n == 0);
return Date.create(year - 1, 12, 31) catch unreachable;
}
// Now the year is correct, and n is the offset from January 1. We find
// the month via an estimate that's either exact or one too large.
var leapyear = (n1 == 3) and (n4 != 24 or n100 == 3);
assert(leapyear == isLeapYear(year));
var month = (n + 50) >> 5;
if (month == 0) month = 12; // Loop around
var preceding = daysBeforeMonth(year, month);
if (preceding > n) { // estimate is too large
month -= 1;
if (month == 0) month = 12; // Loop around
preceding -= daysInMonth(year, month);
}
n -= preceding;
// assert(n > 0 and n < daysInMonth(year, month));
// Now the year and month are correct, and n is the offset from the
// start of that month: we're done!
return Date.create(year, month, n + 1) catch unreachable;
}
// Return proleptic Gregorian ordinal for the year, month and day.
// January 1 of year 1 is day 1. Only the year, month and day values
// contribute to the result.
pub fn toOrdinal(self: Date) u32 {
return ymd2ord(self.year, self.month, self.day);
}
// Returns todays date
pub fn now() Date {
return Date.fromTimestamp(time.milliTimestamp());
}
// Create a date from the number of seconds since 1 Jan 1970
pub fn fromSeconds(seconds: f64) Date {
const r = math.modf(seconds);
const timestamp = @floatToInt(i64, r.ipart); // Seconds
const days = @divFloor(timestamp, time.s_per_day) + @as(i64, EPOCH);
assert(days >= 0 and days <= MAX_ORDINAL);
return Date.fromOrdinal(@intCast(u32, days));
}
// Return the number of seconds since 1 Jan 1970
pub fn toSeconds(self: Date) f64 {
const days = @intCast(i64, self.toOrdinal()) - @as(i64, EPOCH);
return @intToFloat(f64, days * time.s_per_day);
}
// Create a date from a UTC timestamp in milliseconds relative to Jan 1st 1970
pub fn fromTimestamp(timestamp: i64) Date {
const days = @divFloor(timestamp, time.ms_per_day) + @as(i64, EPOCH);
assert(days >= 0 and days <= MAX_ORDINAL);
return Date.fromOrdinal(@intCast(u32, days));
}
// Create a UTC timestamp in milliseconds relative to Jan 1st 1970
pub fn toTimestamp(self: Date) i64 {
const d = @intCast(i64, daysBeforeYear(self.year));
const days = d - @as(i64, EPOCH) + @intCast(i64, self.dayOfYear());
return @intCast(i64, days) * time.ms_per_day;
}
// Convert to an ISOCalendar date containg the year, week number, and
// weekday. First week is 1. Monday is 1, Sunday is 7.
pub fn isoCalendar(self: Date) ISOCalendar {
// Ported from python's isocalendar.
var y = self.year;
var first_monday = daysBeforeFirstMonday(y);
const today = ymd2ord(self.year, self.month, self.day);
if (today < first_monday) {
y -= 1;
first_monday = daysBeforeFirstMonday(y);
}
const days_between = today - first_monday;
var week = @divFloor(days_between, 7);
var day = @mod(days_between, 7);
if (week >= 52 and today >= daysBeforeFirstMonday(y+1)) {
y += 1;
week = 0;
}
assert(week >= 0 and week < 53);
assert(day >= 0 and day < 8);
return ISOCalendar{
.year=y,
.week=@intCast(u6, week+1),
.weekday=@intCast(u3, day+1)
};
}
// ------------------------------------------------------------------------
// Comparisons
// ------------------------------------------------------------------------
pub fn eql(self: Date, other: Date) bool {
return self.cmp(other) == .eq;
}
pub fn cmp(self: Date, other: Date) Order {
if (self.year > other.year) return .gt;
if (self.year < other.year) return .lt;
if (self.month > other.month) return .gt;
if (self.month < other.month) return .lt;
if (self.day > other.day) return .gt;
if (self.day < other.day) return .lt;
return .eq;
}
pub fn gt(self: Date, other: Date) bool {
return self.cmp(other) == .gt;
}
pub fn gte(self: Date, other: Date) bool {
const r = self.cmp(other);
return r == .eq or r == .gt;
}
pub fn lt(self: Date, other: Date) bool {
return self.cmp(other) == .lt;
}
pub fn lte(self: Date, other: Date) bool {
const r = self.cmp(other);
return r == .eq or r == .lt;
}
// ------------------------------------------------------------------------
// Parsing
// ------------------------------------------------------------------------
// Parse date in format YYYY-MM-DD. Numbers must be zero padded.
pub fn parseIso(ymd: []const u8) !Date {
const value = std.mem.trim(u8, ymd, " ");
if (value.len != 10) return error.InvalidFormat;
const year = std.fmt.parseInt(u16, value[0..4], 10) catch return error.InvalidFormat;
const month = std.fmt.parseInt(u8, value[5..7], 10) catch return error.InvalidFormat;
const day = std.fmt.parseInt(u8, value[8..10], 10) catch return error.InvalidFormat;
return Date.create(year, month, day);
}
// TODO: Parsing
// ------------------------------------------------------------------------
// Formatting
// ------------------------------------------------------------------------
// Return date in ISO format YYYY-MM-DD
pub fn formatIso(self: Date, buf: []u8) ![]u8 {
return std.fmt.bufPrint(buf, "{}-{}-{}", .{ self.year, self.month, self.day });
}
// ------------------------------------------------------------------------
// Properties
// ------------------------------------------------------------------------
// Return day of year starting with 1
pub fn dayOfYear(self: Date) u16 {
var d = self.toOrdinal() - daysBeforeYear(self.year);
assert(d >= 1 and d <= 366);
return @intCast(u16, d);
}
// Return day of week starting with Monday = 1 and Sunday = 7
pub fn dayOfWeek(self: Date) Weekday {
const dow = @intCast(u3, self.toOrdinal() % 7);
return @intToEnum(Weekday, if (dow == 0) 7 else dow);
}
// Return the ISO calendar based week of year. With 1 being the first week.
pub fn weekOfYear(self: Date) u8 {
return self.isoCalendar().week;
}
// Return day of week starting with Monday = 0 and Sunday = 6
pub fn weekday(self: Date) u4 {
return @enumToInt(self.dayOfWeek()) - 1;
}
// Return whether the date is a weekend (Saturday or Sunday)
pub fn isWeekend(self: Date) bool {
return self.weekday() >= 5;
}
// Return the name of the day of the week, eg "Sunday"
pub fn weekdayName(self: Date) []const u8 {
return @tagName(self.dayOfWeek());
}
// Return the name of the day of the month, eg "January"
pub fn monthName(self: Date) []const u8 {
assert(self.month >= 1 and self.month <= 12);
return @tagName(@intToEnum(Month, self.month));
}
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
// Return a copy of the date shifted by the given number of days
pub fn shiftDays(self: Date, days: i32) Date {
return self.shift(Delta{ .days = days });
}
// Return a copy of the date shifted by the given number of years
pub fn shiftYears(self: Date, years: i16) Date {
return self.shift(Delta{ .years = years });
}
pub const Delta = struct {
years: i16 = 0,
days: i32 = 0,
};
// Return a copy of the date shifted in time by the delta
pub fn shift(self: Date, delta: Delta) Date {
if (delta.years == 0 and delta.days == 0) {
return self.copy() catch unreachable;
}
// Shift year
var year = self.year;
if (delta.years < 0) {
year -= @intCast(u16, -delta.years);
} else {
year += @intCast(u16, delta.years);
}
var ord = daysBeforeYear(year);
var days = self.dayOfYear();
const from_leap = isLeapYear(self.year);
const to_leap = isLeapYear(year);
if (days == 59 and from_leap and to_leap) {
// No change before leap day
} else if (days < 59) {
// No change when jumping from leap day to leap day
} else if (to_leap and !from_leap) {
// When jumping to a leap year to non-leap year
// we have to add a leap day to the day of year
days += 1;
} else if (from_leap and !to_leap) {
// When jumping from leap year to non-leap year we have to undo
// the leap day added to the day of yearear
days -= 1;
}
ord += days;
// Shift days
if (delta.days < 0) {
ord -= @intCast(u32, -delta.days);
} else {
ord += @intCast(u32, delta.days);
}
return Date.fromOrdinal(ord);
}
};
test "date-now" {
_ = Date.now();
}
test "date-compare" {
var d1 = try Date.create(2019, 7, 3);
var d2 = try Date.create(2019, 7, 3);
var d3 = try Date.create(2019, 6, 3);
var d4 = try Date.create(2020, 7, 3);
try testing.expect(d1.eql(d2));
try testing.expect(d1.gt(d3));
try testing.expect(d3.lt(d2));
try testing.expect(d4.gt(d2));
}
test "date-from-ordinal" {
var date = Date.fromOrdinal(9921);
try testing.expectEqual(date.year, 28);
try testing.expectEqual(date.month, 2);
try testing.expectEqual(date.day, 29);
try testing.expectEqual(date.toOrdinal(), 9921);
date = Date.fromOrdinal(737390);
try testing.expectEqual(date.year, 2019);
try testing.expectEqual(date.month, 11);
try testing.expectEqual(date.day, 27);
try testing.expectEqual(date.toOrdinal(), 737390);
date = Date.fromOrdinal(719163);
try testing.expectEqual(date.year, 1970);
try testing.expectEqual(date.month, 1);
try testing.expectEqual(date.day, 1);
try testing.expectEqual(date.toOrdinal(), 719163);
}
test "date-from-seconds" {
var seconds: f64 = 0;
var date = Date.fromSeconds(seconds);
try testing.expectEqual(date, try Date.create(1970, 1, 1));
try testing.expectEqual(date.toSeconds(), seconds);
seconds = -@as(f64, EPOCH-1)*time.s_per_day;
date = Date.fromSeconds(seconds);
try testing.expectEqual(date, try Date.create(1, 1, 1));
try testing.expectEqual(date.toSeconds(), seconds);
seconds = @as(f64, MAX_ORDINAL-EPOCH)*time.s_per_day;
date = Date.fromSeconds(seconds);
try testing.expectEqual(date, try Date.create(9999, 12, 31));
try testing.expectEqual(date.toSeconds(), seconds);
//
//
// const t = 63710928000.000;
// date = Date.fromSeconds(t);
// try testing.expectEqual(date.year, 2019);
// try testing.expectEqual(date.month, 12);
// try testing.expectEqual(date.day, 3);
// try testing.expectEqual(date.toSeconds(), t);
//
// Max check
// var max_date = try Date.create(9999, 12, 31);
// const tmax: f64 = @intToFloat(f64, MAX_ORDINAL-1) * time.s_per_day;
// date = Date.fromSeconds(tmax);
// try testing.expect(date.eql(max_date));
// try testing.expectEqual(date.toSeconds(), tmax);
}
test "date-day-of-year" {
var date = try Date.create(1970, 1, 1);
try testing.expect(date.dayOfYear() == 1);
}
test "date-day-of-week" {
var date = try Date.create(2019, 11, 27);
try testing.expectEqual(date.weekday(), 2);
try testing.expectEqual(date.dayOfWeek(), .Wednesday);
try testing.expectEqualSlices(u8, date.monthName(), "November");
try testing.expectEqualSlices(u8, date.weekdayName(), "Wednesday");
try testing.expect(!date.isWeekend());
date = try Date.create(1776, 6, 4);
try testing.expectEqual(date.weekday(), 1);
try testing.expectEqual(date.dayOfWeek(), .Tuesday);
try testing.expectEqualSlices(u8, date.monthName(), "June");
try testing.expectEqualSlices(u8, date.weekdayName(), "Tuesday");
try testing.expect(!date.isWeekend());
date = try Date.create(2019, 12, 1);
try testing.expectEqualSlices(u8, date.monthName(), "December");
try testing.expectEqualSlices(u8, date.weekdayName(), "Sunday");
try testing.expect(date.isWeekend());
}
test "date-shift-days" {
var date = try Date.create(2019, 11, 27);
var d = date.shiftDays(-2);
try testing.expectEqual(d.day, 25);
try testing.expectEqualSlices(u8, d.weekdayName(), "Monday");
// Ahead one week
d = date.shiftDays(7);
try testing.expectEqualSlices(u8, d.weekdayName(), date.weekdayName());
try testing.expectEqual(d.month, 12);
try testing.expectEqualSlices(u8, d.monthName(), "December");
try testing.expectEqual(d.day, 4);
d = date.shiftDays(0);
try testing.expect(date.eql(d));
}
test "date-shift-years" {
// Shift including a leap year
var date = try Date.create(2019, 11, 27);
var d = date.shiftYears(-4);
try testing.expect(d.eql(try Date.create(2015, 11, 27)));
d = date.shiftYears(15);
try testing.expect(d.eql(try Date.create(2034, 11, 27)));
// Shifting from leap day
var leap_day = try Date.create(2020, 2, 29);
d = leap_day.shiftYears(1);
try testing.expect(d.eql(try Date.create(2021, 2, 28)));
// Before leap day
date = try Date.create(2020, 2, 2);
d = date.shiftYears(1);
try testing.expect(d.eql(try Date.create(2021, 2, 2)));
// After leap day
date = try Date.create(2020, 3, 1);
d = date.shiftYears(1);
try testing.expect(d.eql(try Date.create(2021, 3, 1)));
// From leap day to leap day
d = leap_day.shiftYears(4);
try testing.expect(d.eql(try Date.create(2024, 2, 29)));
}
test "date-create" {
try testing.expectError(
error.InvalidDate, Date.create(2019, 2, 29));
var date = Date.fromTimestamp(1574908586928);
try testing.expect(date.eql(try Date.create(2019, 11, 28)));
}
test "date-copy" {
var d1 = try Date.create(2020, 1, 1);
var d2 = try d1.copy();
try testing.expect(d1.eql(d2));
}
test "date-parse-iso" {
try testing.expectEqual(
try Date.parseIso("2018-12-15"),
try Date.create(2018, 12, 15));
try testing.expectEqual(
try Date.parseIso("2021-01-07"),
try Date.create(2021, 1, 7));
try testing.expectError(error.InvalidDate,
Date.parseIso("2021-13-01"));
try testing.expectError(error.InvalidFormat,
Date.parseIso("20-01-01"));
try testing.expectError(error.InvalidFormat,
Date.parseIso("2000-1-1"));
}
test "date-isocalendar" {
const today = try Date.create(2021, 8, 12);
try testing.expectEqual(today.isoCalendar(),
ISOCalendar{.year=2021, .week=32, .weekday=4});
// Some random dates and outputs generated with python
const dates = [15][]const u8{
"2018-12-15",
"2019-01-19",
"2019-10-14",
"2020-09-26",
// Border cases
"2020-12-27",
"2020-12-30",
"2020-12-31",
"2021-01-01",
"2021-01-03",
"2021-01-04",
"2021-01-10",
"2021-09-14",
"2022-09-12",
"2023-04-10",
"2024-01-16",
};
const expect = [15]ISOCalendar{
ISOCalendar{.year=2018, .week=50, .weekday=6},
ISOCalendar{.year=2019, .week=3, .weekday=6},
ISOCalendar{.year=2019, .week=42, .weekday=1},
ISOCalendar{.year=2020, .week=39, .weekday=6},
ISOCalendar{.year=2020, .week=52, .weekday=7},
ISOCalendar{.year=2020, .week=53, .weekday=3},
ISOCalendar{.year=2020, .week=53, .weekday=4},
ISOCalendar{.year=2020, .week=53, .weekday=5},
ISOCalendar{.year=2020, .week=53, .weekday=7},
ISOCalendar{.year=2021, .week=1, .weekday=1},
ISOCalendar{.year=2021, .week=1, .weekday=7},
ISOCalendar{.year=2021, .week=37, .weekday=2},
ISOCalendar{.year=2022, .week=37, .weekday=1},
ISOCalendar{.year=2023, .week=15, .weekday=1},
ISOCalendar{.year=2024, .week=3, .weekday=2},
};
for (dates) |d, i| {
const date = try Date.parseIso(d);
const cal = date.isoCalendar();
try testing.expectEqual(cal, expect[i]);
try testing.expectEqual(date.weekOfYear(), expect[i].week);
}
}
pub const Timezone = struct {
offset: i16, // In minutes
name: []const u8,
// Auto register timezones
pub fn create(name: []const u8, offset: i16) Timezone {
const self = Timezone{.offset=offset, .name=name};
return self;
}
pub fn offsetSeconds(self: Timezone) i32 {
return @as(i32, self.offset) * time.s_per_min;
}
};
pub const Time = struct {
hour: u8 = 0, // 0 to 23
minute: u8 = 0, // 0 to 59
second: u8 = 0, // 0 to 59
nanosecond: u32 = 0, // 0 to 999999999 TODO: Should this be u20?
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
pub fn now() Time {
return Time.fromTimestamp(time.milliTimestamp());
}
// Create a Time struct and validate that all fields are in range
pub fn create(hour: u32, minute: u32, second: u32, nanosecond: u32) !Time {
if (hour > 23 or minute > 59 or second > 59 or nanosecond > 999999999) {
return error.InvalidTime;
}
return Time{
.hour = @intCast(u8, hour),
.minute = @intCast(u8, minute),
.second = @intCast(u8, second),
.nanosecond = nanosecond,
};
}
// Create a copy of the Time
pub fn copy(self: Time) !Time {
return Time.create(self.hour, self.minute, self.second, self.nanosecond);
}
// Create Time from a UTC Timestamp in milliseconds
pub fn fromTimestamp(timestamp: i64) Time {
const remainder = @mod(timestamp, time.ms_per_day);
var t = @intCast(u64, math.absInt(remainder) catch unreachable);
// t is now only the time part of the day
const h = @intCast(u32, @divFloor(t, time.ms_per_hour));
t -= h * time.ms_per_hour;
const m = @intCast(u32, @divFloor(t, time.ms_per_min));
t -= m * time.ms_per_min;
const s = @intCast(u32, @divFloor(t, time.ms_per_s));
t -= s * time.ms_per_s;
const ns = @intCast(u32, t * time.ns_per_ms);
return Time.create(h, m, s, ns) catch unreachable;
}
// From seconds since the start of the day
pub fn fromSeconds(seconds: f64) Time {
assert(seconds >= 0);
// Convert to s and us
const r = math.modf(seconds);
var s = @floatToInt(u32, @mod(r.ipart, time.s_per_day)); // s
const h = @divFloor(s, time.s_per_hour);
s -= h * time.s_per_hour;
const m = @divFloor(s, time.s_per_min);
s -= m * time.s_per_min;
// Rounding seems to only be accurate to within 100ns
// for normal timestamps
var frac = math.round(r.fpart * time.ns_per_s/100)*100;
if (frac >= time.ns_per_s) {
s += 1;
frac -= time.ns_per_s;
} else if (frac < 0) {
s -= 1;
frac += time.ns_per_s;
}
const ns = @floatToInt(u32, frac);
return Time.create(h, m, s, ns) catch unreachable; // If this fails it's a bug
}
// Convert to a time in seconds relative to the UTC timezones
// including the nanosecond component
pub fn toSeconds(self: Time) f64 {
const s = @intToFloat(f64, self.totalSeconds());
const ns = @intToFloat(f64, self.nanosecond) / time.ns_per_s;
return s + ns;
}
// Convert to a timestamp in milliseconds from UTC
pub fn toTimestamp(self: Time) i64 {
const h = @intCast(i64, self.hour) * time.ms_per_hour;
const m = @intCast(i64, self.minute) * time.ms_per_min;
const s = @intCast(i64, self.second) * time.ms_per_s;
const ms = @intCast(i64, self.nanosecond / time.ns_per_ms);
return h + m + s + ms;
}
// Total seconds from the start of day
pub fn totalSeconds(self: Time) i32 {
const h = @intCast(i32, self.hour) * time.s_per_hour;
const m = @intCast(i32, self.minute) * time.s_per_min;
const s = @intCast(i32, self.second);
return h + m + s;
}
// -----------------------------------------------------------------------
// Comparisons
// -----------------------------------------------------------------------
pub fn eql(self: Time, other: Time) bool {
return self.cmp(other) == .eq;
}
pub fn cmp(self: Time, other: Time) Order {
const t1 = self.totalSeconds();
const t2 = other.totalSeconds();
if (t1 > t2) return .gt;
if (t1 < t2) return .lt;
if (self.nanosecond > other.nanosecond) return .gt;
if (self.nanosecond < other.nanosecond) return .lt;
return .eq;
}
pub fn gt(self: Time, other: Time) bool {
return self.cmp(other) == .gt;
}
pub fn gte(self: Time, other: Time) bool {
const r = self.cmp(other);
return r == .eq or r == .gt;
}
pub fn lt(self: Time, other: Time) bool {
return self.cmp(other) == .lt;
}
pub fn lte(self: Time, other: Time) bool {
const r = self.cmp(other);
return r == .eq or r == .lt;
}
// -----------------------------------------------------------------------
// Methods
// -----------------------------------------------------------------------
pub fn amOrPm(self: Time) []const u8 {
return if (self.hour > 12) return "PM" else "AM";
}
};
test "time-create" {
var t = Time.fromTimestamp(1574908586928);
try testing.expect(t.hour == 2);
try testing.expect(t.minute == 36);
try testing.expect(t.second == 26);
try testing.expect(t.nanosecond == 928000000);
try testing.expectError(error.InvalidTime, Time.create(25, 1, 1, 0));
try testing.expectError(error.InvalidTime, Time.create(1, 60, 1, 0));
try testing.expectError(error.InvalidTime, Time.create(12, 30, 281, 0));
try testing.expectError(error.InvalidTime, Time.create(12, 30, 28, 1000000000));
}
test "time-now" {
_ = Time.now();
}
test "time-from-seconds" {
var seconds: f64 = 15.12;
var t = Time.fromSeconds(seconds);
try testing.expect(t.hour == 0);
try testing.expect(t.minute == 0);
try testing.expect(t.second == 15);
try testing.expect(t.nanosecond == 120000000);
try testing.expect(t.toSeconds() == seconds);
seconds = 315.12; // + 5 min
t = Time.fromSeconds(seconds);
try testing.expect(t.hour == 0);
try testing.expect(t.minute == 5);
try testing.expect(t.second == 15);
try testing.expect(t.nanosecond == 120000000);
try testing.expect(t.toSeconds() == seconds);
seconds = 36000 + 315.12; // + 10 hr
t = Time.fromSeconds(seconds);
try testing.expect(t.hour == 10);
try testing.expect(t.minute == 5);
try testing.expect(t.second == 15);
try testing.expect(t.nanosecond == 120000000);
try testing.expect(t.toSeconds() == seconds);
seconds = 108000 + 315.12; // + 30 hr
t = Time.fromSeconds(seconds);
try testing.expect(t.hour == 6);
try testing.expect(t.minute == 5);
try testing.expect(t.second == 15);
try testing.expect(t.nanosecond == 120000000);
try testing.expectEqual(t.totalSeconds(), 6*3600+315);
//testing.expectAlmostEqual(t.toSeconds(), seconds-time.s_per_day);
}
test "time-copy" {
var t1 = try Time.create(8, 30, 0, 0);
var t2 = try t1.copy();
try testing.expect(t1.eql(t2));
}
test "time-compare" {
var t1 = try Time.create(8, 30, 0, 0);
var t2 = try Time.create(9, 30, 0, 0);
var t3 = try Time.create(8, 00, 0, 0);
var t4 = try Time.create(9, 30, 17, 0);
try testing.expect(t1.lt(t2));
try testing.expect(t1.gt(t3));
try testing.expect(t2.lt(t4));
try testing.expect(t3.lt(t4));
}
pub const Datetime = struct {
date: Date,
time: Time,
zone: *const Timezone,
// An absolute or relative delta
// if years is defined a date is date
// TODO: Validate years before allowing it to be created
pub const Delta = struct {
years: i16 = 0,
days: i32 = 0,
seconds: i64 = 0,
nanoseconds: i32 = 0,
relative_to: ?Datetime = null,
pub fn sub(self: *Delta, other: *Delta) Delta {
return Delta{
.years = self.years - other.years,
.days = self.days - other.days,
.seconds = self.seconds - other.seconds,
.nanoseconds = self.nanoseconds - other.nanoseconds,
.relative_to = self.relative_to,
};
}
pub fn add(self: *Delta, other: *Delta) Delta {
return Delta{
.years = self.years + other.years,
.days = self.days + other.days,
.seconds = self.seconds + other.seconds,
.nanoseconds = self.nanoseconds + other.nanoseconds,
.relative_to = self.relative_to,
};
}
// Total seconds in the duration ignoring the nanoseconds fraction
pub fn totalSeconds(self: *Delta) i64 {
// Calculate the total number of days we're shifting
var days = self.days;
if (self.relative_to) |dt| {
if (self.years != 0) {
const a = daysBeforeYear(dt.date.year);
// Must always subtract greater of the two
if (self.years > 0) {
const y = @intCast(u32, self.years);
const b = daysBeforeYear(dt.date.year + y);
days += @intCast(i32, b - a);
} else {
const y = @intCast(u32, -self.years);
assert(y < dt.date.year); // Does not work below year 1
const b = daysBeforeYear(dt.date.year - y);
days -= @intCast(i32, a - b);
}
}
} else {
// Cannot use years without a relative to date
// otherwise any leap days will screw up results
assert(self.years == 0);
}
var s = self.seconds;
var ns = self.nanoseconds;
if (ns >= time.ns_per_s) {
const ds = @divFloor(ns, time.ns_per_s);
ns -= ds * time.ns_per_s;
s += ds;
} else if (ns <= -time.ns_per_s) {
const ds = @divFloor(ns, -time.ns_per_s);
ns += ds * time.us_per_s;
s -= ds;
}
return (days * time.s_per_day + s);
}
};
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
pub fn now() Datetime {
return Datetime.fromTimestamp(time.milliTimestamp());
}
pub fn create(year: u32, month: u32, day: u32, hour: u32, minute: u32,
second: u32, nanosecond: u32, zone: ?*const Timezone) !Datetime {
return Datetime{
.date = try Date.create(year, month, day),
.time = try Time.create(hour, minute, second, nanosecond),
.zone = zone orelse &timezones.UTC,
};
}
// Return a copy
pub fn copy(self: Datetime) !Datetime {
return Datetime{
.date = try self.date.copy(),
.time = try self.time.copy(),
.zone = self.zone,
};
}
pub fn fromDate(year: u16, month: u8, day: u8) !Datetime {
return Datetime{
.date = try Date.create(year, month, day),
.time = try Time.create(0, 0, 0, 0),
.zone = &timezones.UTC,
};
}
// From seconds since 1 Jan 1970
pub fn fromSeconds(seconds: f64) Datetime {
return Datetime{
.date = Date.fromSeconds(seconds),
.time = Time.fromSeconds(seconds),
.zone = &timezones.UTC,
};
}
// Seconds since 1 Jan 0001 including nanoseconds
pub fn toSeconds(self: Datetime) f64 {
return self.date.toSeconds() + self.time.toSeconds();
}
// From POSIX timestamp in milliseconds relative to 1 Jan 1970
pub fn fromTimestamp(timestamp: i64) Datetime {
const t = @divFloor(timestamp, time.ms_per_day);
const d = @intCast(u64, math.absInt(t) catch unreachable);
const days = if (timestamp >= 0) d + EPOCH else EPOCH - d;
assert(days >= 0 and days <= MAX_ORDINAL);
return Datetime{
.date = Date.fromOrdinal(@intCast(u32, days)),
.time = Time.fromTimestamp(timestamp - @intCast(i64, d) * time.ns_per_day),
.zone = &timezones.UTC,
};
}
// From a file modified time in ns
pub fn fromModifiedTime(mtime: i128) Datetime {
const ts = @intCast(i64, @divFloor(mtime, time.ns_per_ms));
return Datetime.fromTimestamp(ts);
}
// To a UTC POSIX timestamp in milliseconds relative to 1 Jan 1970
pub fn toTimestamp(self: Datetime) i128 {
const ds = self.date.toTimestamp();
const ts = self.time.toTimestamp();
const zs = self.zone.offsetSeconds() * time.ms_per_s;
return ds + ts - zs;
}
// -----------------------------------------------------------------------
// Comparisons
// -----------------------------------------------------------------------
pub fn eql(self: Datetime, other: Datetime) bool {
return self.cmp(other) == .eq;
}
pub fn cmpSameTimezone(self: Datetime, other: Datetime) Order {
assert(self.zone.offset == other.zone.offset);
const r = self.date.cmp(other.date);
if (r != .eq) return r;
return self.time.cmp(other.time);
}
pub fn cmp(self: Datetime, other: Datetime) Order {
if (self.zone.offset == other.zone.offset) {
return self.cmpSameTimezone(other);
}
// Shift both to utc
const a = self.shiftTimezone(&timezones.UTC);
const b = other.shiftTimezone(&timezones.UTC);
return a.cmpSameTimezone(b);
}
pub fn gt(self: Datetime, other: Datetime) bool {
return self.cmp(other) == .gt;
}
pub fn gte(self: Datetime, other: Datetime) bool {
const r = self.cmp(other);
return r == .eq or r == .gt;
}
pub fn lt(self: Datetime, other: Datetime) bool {
return self.cmp(other) == .lt;
}
pub fn lte(self: Datetime, other: Datetime) bool {
const r = self.cmp(other);
return r == .eq or r == .lt;
}
// -----------------------------------------------------------------------
// Methods
// -----------------------------------------------------------------------
// Return a Datetime.Delta relative to this date
pub fn sub(self: Datetime, other: Datetime) Delta {
const days = @intCast(i32, self.date.toOrdinal()) - @intCast(i32, other.date.toOrdinal());
var seconds = self.time.totalSeconds() - other.time.totalSeconds();
if (self.zone.offset != other.zone.offset) {
const mins = (self.zone.offset - other.zone.offset);
seconds += mins * time.s_per_min;
}
const ns = @intCast(i32, self.time.nanosecond) - @intCast(i32, other.time.nanosecond);
return Delta{.days=days, .seconds=seconds, .nanoseconds=ns};
}
// Create a Datetime shifted by the given number of years
pub fn shiftYears(self: Datetime, years: i16) Datetime {
return self.shift(Delta{.years=years});
}
// Create a Datetime shifted by the given number of days
pub fn shiftDays(self: Datetime, days: i32) Datetime {
return self.shift(Delta{.days=days});
}
// Create a Datetime shifted by the given number of hours
pub fn shiftHours(self: Datetime, hours: i32) Datetime {
return self.shift(Delta{.seconds=hours*time.s_per_hour});
}
// Create a Datetime shifted by the given number of minutes
pub fn shiftMinutes(self: Datetime, minutes: i32) Datetime {
return self.shift(Delta{.seconds=minutes*time.s_per_min});
}
// Convert to the given timeszone
pub fn shiftTimezone(self: Datetime, zone: *const Timezone) Datetime {
var dt =
if (self.zone.offset == zone.offset)
(self.copy() catch unreachable)
else
self.shiftMinutes(zone.offset-self.zone.offset);
dt.zone = zone;
return dt;
}
// Create a Datetime shifted by the given number of seconds
pub fn shiftSeconds(self: Datetime, seconds: i64) Datetime {
return self.shift(Delta{.seconds=seconds});
}
// Create a Datetime shifted by the given Delta
pub fn shift(self: Datetime, delta: Delta) Datetime {
var days = delta.days;
var s = delta.seconds + self.time.totalSeconds();
// Rollover ns to s
var ns = delta.nanoseconds + @intCast(i32, self.time.nanosecond);
if (ns >= time.ns_per_s) {
s += 1;
ns -= time.ns_per_s;
} else if (ns < -time.ns_per_s) {
s -= 1;
ns += time.ns_per_s;
}
assert(ns >= 0 and ns < time.ns_per_s);
const nanosecond = @intCast(u32, ns);
// Rollover s to days
if (s >= time.s_per_day) {
const d = @divFloor(s, time.s_per_day);
days += @intCast(i32, d);
s -= d * time.s_per_day;
} else if (s < 0) {
if (s < -time.s_per_day) { // Wrap multiple
const d = @divFloor(s, -time.s_per_day);
days -= @intCast(i32, d);
s += d * time.s_per_day;
}
days -= 1;
s = time.s_per_day + s;
}
assert(s >= 0 and s < time.s_per_day);
var second = @intCast(u32, s);
const hour = @divFloor(second, time.s_per_hour);
second -= hour * time.s_per_hour;
const minute = @divFloor(second, time.s_per_min);
second -= minute * time.s_per_min;
return Datetime{
.date=self.date.shift(Date.Delta{.years=delta.years, .days=days}),
.time=Time.create(hour, minute, second, nanosecond)
catch unreachable, // Error here would mean a bug
.zone=self.zone,
};
}
// ------------------------------------------------------------------------
// Formatting methods
// ------------------------------------------------------------------------
// Formats a timestamp in the format used by HTTP.
// eg "Tue, 15 Nov 1994 08:12:31 GMT"
pub fn formatHttp(self: *Datetime, allocator: *Allocator) ![]const u8 {
return try std.fmt.allocPrint(allocator, "{s}, {d} {s} {d} {d:0>2}:{d:0>2}:{d:0>2} {s}", .{
self.date.weekdayName()[0..3],
self.date.day,
self.date.monthName()[0..3],
self.date.year,
self.time.hour,
self.time.minute,
self.time.second,
self.zone.name // TODO: Should be GMT
});
}
pub fn formatHttpBuf(self: *Datetime, buf: []u8) ![]const u8 {
return try std.fmt.bufPrint(buf, "{s}, {d} {s} {d} {d:0>2}:{d:0>2}:{d:0>2} {s}", .{
self.date.weekdayName()[0..3],
self.date.day,
self.date.monthName()[0..3],
self.date.year,
self.time.hour,
self.time.minute,
self.time.second,
self.zone.name // TODO: Should be GMT
});
}
// Formats a timestamp in the format used by HTTP.
// eg "Tue, 15 Nov 1994 08:12:31 GMT"
pub fn formatHttpFromTimestamp(buf: []u8, timestamp: i64) ![]const u8 {
return Datetime.fromTimestamp(timestamp).formatHttpBuf(buf);
}
// From time in nanoseconds
pub fn formatHttpFromModifiedDate(buf: []u8, mtime: i128) ![]const u8 {
const ts = @intCast(i64, @divFloor(mtime, time.ns_per_ms));
return Datetime.formatHttpFromTimestamp(buf, ts);
}
// ------------------------------------------------------------------------
// Parsing methods
// ------------------------------------------------------------------------
// Parse a HTTP If-Modified-Since header
// in the format "<day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT"
// eg, "Wed, 21 Oct 2015 07:28:00 GMT"
pub fn parseModifiedSince(ims: []const u8) !Datetime {
const value = std.mem.trim(u8, ims, " ");
if (value.len < 29) return error.InvalidFormat;
const day = std.fmt.parseInt(u8, value[5..7], 10) catch return error.InvalidFormat;
const month = @enumToInt(try Month.parseAbbr(value[8..11]));
const year = std.fmt.parseInt(u16, value[12..16], 10) catch return error.InvalidFormat;
const hour = std.fmt.parseInt(u8, value[17..19], 10) catch return error.InvalidFormat;
const minute = std.fmt.parseInt(u8, value[20..22], 10) catch return error.InvalidFormat;
const second = std.fmt.parseInt(u8, value[23..25], 10) catch return error.InvalidFormat;
return Datetime.create(year, month, day, hour, minute, second, 0, &timezones.GMT);
}
};
test "datetime-now" {
_ = Datetime.now();
}
test "datetime-create-timestamp" {
//var t = Datetime.now();
const ts = 1574908586928;
var t = Datetime.fromTimestamp(ts);
try testing.expect(t.date.eql(try Date.create(2019, 11, 28)));
try testing.expect(t.time.eql(try Time.create(2, 36, 26, 928000000)));
try testing.expectEqualSlices(u8, t.zone.name, "UTC");
try testing.expectEqual(t.toTimestamp(), ts);
}
test "datetime-from-seconds" {
// datetime.utcfromtimestamp(1592417521.9326444)
// datetime.datetime(2020, 6, 17, 18, 12, 1, 932644)
const ts: f64 = 1592417521.9326444;
var t = Datetime.fromSeconds(ts);
try testing.expect(t.date.year == 2020);
try testing.expectEqual(t.date, try Date.create(2020, 6, 17));
try testing.expectEqual(t.time, try Time.create(18, 12, 1, 932644400));
try testing.expectEqual(t.toSeconds(), ts);
}
test "datetime-shift-timezones" {
const ts = 1574908586928;
const utc = Datetime.fromTimestamp(ts);
var t = utc.shiftTimezone(&timezones.America.New_York);
try testing.expect(t.date.eql(try Date.create(2019, 11, 27)));
try testing.expectEqual(t.time.hour, 21);
try testing.expectEqual(t.time.minute, 36);
try testing.expectEqual(t.time.second, 26);
try testing.expectEqual(t.time.nanosecond, 928000000);
try testing.expectEqualSlices(u8, t.zone.name, "America/New_York");
try testing.expectEqual(t.toTimestamp(), ts);
// Shifting to same timezone has no effect
const same = t.shiftTimezone(&timezones.America.New_York);
try testing.expectEqual(t, same);
// Shift back works
const original = t.shiftTimezone(&timezones.UTC);
//std.debug.warn("\nutc={}\n", .{utc});
//std.debug.warn("original={}\n", .{original});
try testing.expect(utc.date.eql(original.date));
try testing.expect(utc.time.eql(original.time));
try testing.expect(utc.eql(original));
}
test "datetime-shift" {
var dt = try Datetime.create(2019, 12, 2, 11, 51, 13, 466545, null);
try testing.expect(dt.shiftYears(0).eql(dt));
try testing.expect(dt.shiftDays(0).eql(dt));
try testing.expect(dt.shiftHours(0).eql(dt));
var t = dt.shiftDays(7);
try testing.expect(t.date.eql(try Date.create(2019, 12, 9)));
try testing.expect(t.time.eql(dt.time));
t = dt.shiftDays(-3);
try testing.expect(t.date.eql(try Date.create(2019, 11, 29)));
try testing.expect(t.time.eql(dt.time));
t = dt.shiftHours(18);
try testing.expect(t.date.eql(try Date.create(2019, 12, 3)));
try testing.expect(t.time.eql(try Time.create(5, 51, 13, 466545)));
t = dt.shiftHours(-36);
try testing.expect(t.date.eql(try Date.create(2019, 11, 30)));
try testing.expect(t.time.eql(try Time.create(23, 51, 13, 466545)));
t = dt.shiftYears(1);
try testing.expect(t.date.eql(try Date.create(2020, 12, 2)));
try testing.expect(t.time.eql(dt.time));
t = dt.shiftYears(-3);
try testing.expect(t.date.eql(try Date.create(2016, 12, 2)));
try testing.expect(t.time.eql(dt.time));
}
test "datetime-shift-seconds" {
// Issue 1
const midnight_utc = try Datetime.create(2020, 12, 17, 0, 0, 0, 0, null);
const midnight_copenhagen = try Datetime.create(
2020, 12, 17, 1, 0, 0, 0, &timezones.Europe.Copenhagen);
try testing.expect(midnight_utc.eql(midnight_copenhagen));
// Check rollover issues
var hour: u8 = 0;
while (hour < 24) : (hour += 1) {
var minute: u8 = 0;
while (minute < 60) : (minute += 1) {
var sec: u8 = 0;
while (sec < 60) : (sec += 1) {
const dt_utc = try Datetime.create(2020, 12, 17, hour, minute, sec, 0, null);
const dt_cop = dt_utc.shiftTimezone(&timezones.Europe.Copenhagen);
const dt_nyc = dt_utc.shiftTimezone(&timezones.America.New_York);
try testing.expect(dt_utc.eql(dt_cop));
try testing.expect(dt_utc.eql(dt_nyc));
try testing.expect(dt_nyc.eql(dt_cop));
}
}
}
}
test "datetime-compare" {
var dt1 = try Datetime.create(2019, 12, 2, 11, 51, 13, 466545, null);
var dt2 = try Datetime.fromDate(2016, 12, 2);
try testing.expect(dt2.lt(dt1));
var dt3 = Datetime.now();
try testing.expect(dt3.gt(dt2));
var dt4 = try dt3.copy();
try testing.expect(dt3.eql(dt4));
var dt5 = dt1.shiftTimezone(&timezones.America.Louisville);
try testing.expect(dt5.eql(dt1));
}
test "datetime-subtract" {
var a = try Datetime.create(2019, 12, 2, 11, 51, 13, 466545, null);
var b = try Datetime.create(2019, 12, 5, 11, 51, 13, 466545, null);
var delta = a.sub(b);
try testing.expectEqual(delta.days, -3);
try testing.expectEqual(delta.totalSeconds(), -3 * time.s_per_day);
delta = b.sub(a);
try testing.expectEqual(delta.days, 3);
try testing.expectEqual(delta.totalSeconds(), 3 * time.s_per_day);
b = try Datetime.create(2019, 12, 2, 11, 0, 0, 466545, null);
delta = a.sub(b);
try testing.expectEqual(delta.totalSeconds(), 13 + 51* time.s_per_min);
}
test "datetime-parse-modified-since" {
const str = " Wed, 21 Oct 2015 07:28:00 GMT ";
try testing.expectEqual(
try Datetime.parseModifiedSince(str),
try Datetime.create(2015, 10, 21, 7, 28, 0, 0, &timezones.GMT));
try testing.expectError(error.InvalidFormat,
Datetime.parseModifiedSince("21/10/2015"));
}
test "file-modified-date" {
var f = try std.fs.cwd().openFile("README.md", .{});
var stat = try f.stat();
var buf: [32]u8 = undefined;
var str = try Datetime.formatHttpFromModifiedDate(&buf, stat.mtime);
std.debug.warn("Modtime: {s}\n", .{str});
}
test "readme-example" {
const allocator = std.testing.allocator;
var date = try Date.create(2019, 12, 25);
var next_year = date.shiftDays(7);
assert(next_year.year == 2020);
assert(next_year.month == 1);
assert(next_year.day == 1);
// In UTC
var now = Datetime.now();
var now_str = try now.formatHttp(allocator);
defer allocator.free(now_str);
std.debug.warn("The time is now: {s}\n", .{now_str});
// The time is now: Fri, 20 Dec 2019 22:03:02 UTC
} | src/datetime.zig |
const std = @import("std");
const helper = @import("helper.zig");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const input = @embedFile("../inputs/day10.txt");
pub fn run(alloc: Allocator, stdout_: anytype) !void {
var lines = tokenize(u8, input, "\r\n");
var corrupted_sum: i64 = 0;
var incomplete_scores = ArrayList(i64).init(alloc);
var leftover_list = ArrayList(BraceKind).init(alloc);
defer incomplete_scores.deinit();
defer leftover_list.deinit();
while (lines.next()) |line| {
var corruption_score: ?i64 = null;
var incomplete_score: ?i64 = null;
try calculateScores(&leftover_list, line, &corruption_score, &incomplete_score);
if (corruption_score) |score| {
corrupted_sum += score;
} else if (incomplete_score) |score| {
try incomplete_scores.append(score);
} else unreachable;
}
var items = incomplete_scores.items;
sort(i64, items, {}, comptime std.sort.asc(i64));
const incomplete_score = items[items.len / 2];
if (stdout_) |stdout| {
try stdout.print("Part 1: {}\n", .{corrupted_sum});
try stdout.print("Part 2: {}\n", .{incomplete_score});
}
}
fn calculateScores(
leftover_list: *ArrayList(BraceKind),
line: []const u8,
corruption_score: *?i64,
incomplete_score: *?i64,
) !void {
var idx: usize = 0;
leftover_list.clearRetainingCapacity();
const maybe_corruption = try recursiveVerifier(line, &idx, leftover_list);
if (maybe_corruption) |score| {
corruption_score.* = score;
} else {
incomplete_score.* = calculateIncompleteScore(leftover_list.items);
}
}
fn recursiveVerifier(
line: []const u8,
idx: *usize,
leftover_list: *ArrayList(BraceKind),
) Allocator.Error!?i64 {
if (isClosingBrace(line[idx.*])) unreachable;
const kind = getBraceKind(line[idx.*]);
idx.* += 1;
if (idx.* >= line.len) {
try leftover_list.append(kind);
return null;
}
while (!isClosingBrace(line[idx.*])) {
if (try recursiveVerifier(line, idx, leftover_list)) |score| {
return score;
}
if (idx.* >= line.len) {
try leftover_list.append(kind);
return null;
}
}
const new_kind = getBraceKind(line[idx.*]);
if (new_kind != kind) {
return getCorruptionScore(new_kind);
} else {
idx.* += 1;
return null;
}
}
fn isClosingBrace(char: u8) bool {
return char == ')' or char == ']' or char == '}' or char == '>';
}
fn getBraceKind(char: u8) BraceKind {
return switch (char) {
'(', ')' => .round,
'[', ']' => .square,
'{', '}' => .curly,
'<', '>' => .angle,
else => unreachable,
};
}
fn getCorruptionScore(kind: BraceKind) i64 {
return switch (kind) {
.round => 3,
.square => 57,
.curly => 1197,
.angle => 25137,
};
}
fn calculateIncompleteScore(items: []const BraceKind) i64 {
var sum: i64 = 0;
for (items) |item| {
sum *= 5;
sum += getIncompleteCoefficient(item);
}
return sum;
}
fn getIncompleteCoefficient(kind: BraceKind) i64 {
return switch (kind) {
.round => 1,
.square => 2,
.curly => 3,
.angle => 4,
};
}
const BraceKind = enum { round, square, curly, angle };
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;
test "calculate incomplete score" {
const items: [4]BraceKind = .{ .square, .round, .curly, .angle };
const score = calculateIncompleteScore(&items);
try std.testing.expect(score == 294);
} | src/day10.zig |
const std = @import("std");
const math = std.math;
const testing = std.testing;
const utils = @import("utils.zig");
const Vec3 = @import("vec3.zig").Vec3;
/// A Mat4 identity matrix
pub const mat4_identity = Mat4{
.data = .{
.{ 1, 0, 0, 0 },
.{ 0, 1, 0, 0 },
.{ 0, 0, 1, 0 },
.{ 0, 0, 0, 1 },
},
};
pub const Mat4 = struct {
data: [4][4]f32,
pub const identity = mat4_identity;
pub fn create(
m00: f32,
m01: f32,
m02: f32,
m03: f32,
m10: f32,
m11: f32,
m12: f32,
m13: f32,
m20: f32,
m21: f32,
m22: f32,
m23: f32,
m30: f32,
m31: f32,
m32: f32,
m33: f32,
) Mat4 {
return Mat4{
.data = .{
.{ m00, m01, m02, m03 },
.{ m10, m11, m12, m13 },
.{ m20, m21, m22, m23 },
.{ m30, m31, m32, m33 },
},
};
}
/// Transpose the values of a mat4
pub fn transpose(m: Mat4) Mat4 {
// 0 1 2 3
// 4 5 6 7
// 8 9 10 11
// 12 13 14 15
return Mat4{
.data = .{
.{ m.data[0][0], m.data[1][0], m.data[2][0], m.data[3][0] },
.{ m.data[0][1], m.data[1][1], m.data[2][1], m.data[3][1] },
.{ m.data[0][2], m.data[1][2], m.data[2][2], m.data[3][2] },
.{ m.data[0][3], m.data[1][3], m.data[2][3], m.data[3][3] },
},
};
}
test "transpose" {
const matA = Mat4.create(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 2, 3, 1);
const out = Mat4.transpose(matA);
const expected = Mat4.create(1, 0, 0, 1, 0, 1, 0, 2, 0, 0, 1, 3, 0, 0, 0, 1);
try expectEqual(expected, out);
}
/// Inverts a mat4
pub fn invert(m: Mat4) ?Mat4 {
const b00 = m.data[0][0] * m.data[1][1] - m.data[0][1] * m.data[1][0];
const b01 = m.data[0][0] * m.data[1][2] - m.data[0][2] * m.data[1][0];
const b02 = m.data[0][0] * m.data[1][3] - m.data[0][3] * m.data[1][0];
const b03 = m.data[0][1] * m.data[1][2] - m.data[0][2] * m.data[1][1];
const b04 = m.data[0][1] * m.data[1][3] - m.data[0][3] * m.data[1][1];
const b05 = m.data[0][2] * m.data[1][3] - m.data[0][3] * m.data[1][2];
const b06 = m.data[2][0] * m.data[3][1] - m.data[2][1] * m.data[3][0];
const b07 = m.data[2][0] * m.data[3][2] - m.data[2][2] * m.data[3][0];
const b08 = m.data[2][0] * m.data[3][3] - m.data[2][3] * m.data[3][0];
const b09 = m.data[2][1] * m.data[3][2] - m.data[2][2] * m.data[3][1];
const b10 = m.data[2][1] * m.data[3][3] - m.data[2][3] * m.data[3][1];
const b11 = m.data[2][2] * m.data[3][3] - m.data[2][3] * m.data[3][2];
// Calculate the determinant
var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
if (det == 0) {
return null;
}
det = 1 / det;
return Mat4{
.data = .{
.{
(m.data[1][1] * b11 - m.data[1][2] * b10 + m.data[1][3] * b09) * det,
(m.data[0][2] * b10 - m.data[0][1] * b11 - m.data[0][3] * b09) * det,
(m.data[3][1] * b05 - m.data[3][2] * b04 + m.data[3][3] * b03) * det,
(m.data[2][2] * b04 - m.data[2][1] * b05 - m.data[2][3] * b03) * det,
},
.{
(m.data[1][2] * b08 - m.data[1][0] * b11 - m.data[1][3] * b07) * det,
(m.data[0][0] * b11 - m.data[0][2] * b08 + m.data[0][3] * b07) * det,
(m.data[3][2] * b02 - m.data[3][0] * b05 - m.data[3][3] * b01) * det,
(m.data[2][0] * b05 - m.data[2][2] * b02 + m.data[2][3] * b01) * det,
},
.{
(m.data[1][0] * b10 - m.data[1][1] * b08 + m.data[1][3] * b06) * det,
(m.data[0][1] * b08 - m.data[0][0] * b10 - m.data[0][3] * b06) * det,
(m.data[3][0] * b04 - m.data[3][1] * b02 + m.data[3][3] * b00) * det,
(m.data[2][1] * b02 - m.data[2][0] * b04 - m.data[2][3] * b00) * det,
},
.{
(m.data[1][1] * b07 - m.data[1][0] * b09 - m.data[1][2] * b06) * det,
(m.data[0][0] * b09 - m.data[0][1] * b07 + m.data[0][2] * b06) * det,
(m.data[3][1] * b01 - m.data[3][0] * b03 - m.data[3][2] * b00) * det,
(m.data[2][0] * b03 - m.data[2][1] * b01 + m.data[2][2] * b00) * det,
},
},
};
}
test "invert" {
const matA = Mat4.create(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 2, 3, 1);
const out = Mat4.invert(matA) orelse @panic("test failed");
const expected = Mat4.create(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1, -2, -3, 1);
try expectEqual(expected, out);
}
/// Calculates the adjugate
pub fn adjoint(m: Mat4) Mat4 {
return Mat4{
.data = .{
.{
(m.data[1][1] * (m.data[2][2] * m.data[3][3] - m.data[2][3] * m.data[3][2]) - m.data[2][1] * (m.data[1][2] * m.data[3][3] - m.data[1][3] * m.data[3][2]) + m.data[3][1] * (m.data[1][2] * m.data[2][3] - m.data[1][3] * m.data[2][2])),
-(m.data[0][1] * (m.data[2][2] * m.data[3][3] - m.data[2][3] * m.data[3][2]) - m.data[2][1] * (m.data[0][2] * m.data[3][3] - m.data[0][3] * m.data[3][2]) + m.data[3][1] * (m.data[0][2] * m.data[2][3] - m.data[0][3] * m.data[2][2])),
(m.data[0][1] * (m.data[1][2] * m.data[3][3] - m.data[1][3] * m.data[3][2]) - m.data[1][1] * (m.data[0][2] * m.data[3][3] - m.data[0][3] * m.data[3][2]) + m.data[3][1] * (m.data[0][2] * m.data[1][3] - m.data[0][3] * m.data[1][2])),
-(m.data[0][1] * (m.data[1][2] * m.data[2][3] - m.data[1][3] * m.data[2][2]) - m.data[1][1] * (m.data[0][2] * m.data[2][3] - m.data[0][3] * m.data[2][2]) + m.data[2][1] * (m.data[0][2] * m.data[1][3] - m.data[0][3] * m.data[1][2])),
},
.{
-(m.data[1][0] * (m.data[2][2] * m.data[3][3] - m.data[2][3] * m.data[3][2]) - m.data[2][0] * (m.data[1][2] * m.data[3][3] - m.data[1][3] * m.data[3][2]) + m.data[3][0] * (m.data[1][2] * m.data[2][3] - m.data[1][3] * m.data[2][2])),
(m.data[0][0] * (m.data[2][2] * m.data[3][3] - m.data[2][3] * m.data[3][2]) - m.data[2][0] * (m.data[0][2] * m.data[3][3] - m.data[0][3] * m.data[3][2]) + m.data[3][0] * (m.data[0][2] * m.data[2][3] - m.data[0][3] * m.data[2][2])),
-(m.data[0][0] * (m.data[1][2] * m.data[3][3] - m.data[1][3] * m.data[3][2]) - m.data[1][0] * (m.data[0][2] * m.data[3][3] - m.data[0][3] * m.data[3][2]) + m.data[3][0] * (m.data[0][2] * m.data[1][3] - m.data[0][3] * m.data[1][2])),
(m.data[0][0] * (m.data[1][2] * m.data[2][3] - m.data[1][3] * m.data[2][2]) - m.data[1][0] * (m.data[0][2] * m.data[2][3] - m.data[0][3] * m.data[2][2]) + m.data[2][0] * (m.data[0][2] * m.data[1][3] - m.data[0][3] * m.data[1][2])),
},
.{
(m.data[1][0] * (m.data[2][1] * m.data[3][3] - m.data[2][3] * m.data[3][1]) - m.data[2][0] * (m.data[1][1] * m.data[3][3] - m.data[1][3] * m.data[3][1]) + m.data[3][0] * (m.data[1][1] * m.data[2][3] - m.data[1][3] * m.data[2][1])),
-(m.data[0][0] * (m.data[2][1] * m.data[3][3] - m.data[2][3] * m.data[3][1]) - m.data[2][0] * (m.data[0][1] * m.data[3][3] - m.data[0][3] * m.data[3][1]) + m.data[3][0] * (m.data[0][1] * m.data[2][3] - m.data[0][3] * m.data[2][1])),
(m.data[0][0] * (m.data[1][1] * m.data[3][3] - m.data[1][3] * m.data[3][1]) - m.data[1][0] * (m.data[0][1] * m.data[3][3] - m.data[0][3] * m.data[3][1]) + m.data[3][0] * (m.data[0][1] * m.data[1][3] - m.data[0][3] * m.data[1][1])),
-(m.data[0][0] * (m.data[1][1] * m.data[2][3] - m.data[1][3] * m.data[2][1]) - m.data[1][0] * (m.data[0][1] * m.data[2][3] - m.data[0][3] * m.data[2][1]) + m.data[2][0] * (m.data[0][1] * m.data[1][3] - m.data[0][3] * m.data[1][1])),
},
.{
-(m.data[1][0] * (m.data[2][1] * m.data[3][2] - m.data[2][2] * m.data[3][1]) - m.data[2][0] * (m.data[1][1] * m.data[3][2] - m.data[1][2] * m.data[3][1]) + m.data[3][0] * (m.data[1][1] * m.data[2][2] - m.data[1][2] * m.data[2][1])),
(m.data[0][0] * (m.data[2][1] * m.data[3][2] - m.data[2][2] * m.data[3][1]) - m.data[2][0] * (m.data[0][1] * m.data[3][2] - m.data[0][2] * m.data[3][1]) + m.data[3][0] * (m.data[0][1] * m.data[2][2] - m.data[0][2] * m.data[2][1])),
-(m.data[0][0] * (m.data[1][1] * m.data[3][2] - m.data[1][2] * m.data[3][1]) - m.data[1][0] * (m.data[0][1] * m.data[3][2] - m.data[0][2] * m.data[3][1]) + m.data[3][0] * (m.data[0][1] * m.data[1][2] - m.data[0][2] * m.data[1][1])),
(m.data[0][0] * (m.data[1][1] * m.data[2][2] - m.data[1][2] * m.data[2][1]) - m.data[1][0] * (m.data[0][1] * m.data[2][2] - m.data[0][2] * m.data[2][1]) + m.data[2][0] * (m.data[0][1] * m.data[1][2] - m.data[0][2] * m.data[1][1])),
},
},
};
}
test "adjoint" {
const matA = Mat4.create(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 2, 3, 1);
const out = Mat4.adjoint(matA);
const expected = Mat4.create(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1, -2, -3, 1);
try expectEqual(expected, out);
}
///Calculates the determinant
pub fn determinant(m: Mat4) f32 {
const b00 = m.data[0][0] * m.data[1][1] - m.data[0][1] * m.data[1][0];
const b01 = m.data[0][0] * m.data[1][2] - m.data[0][2] * m.data[1][0];
const b02 = m.data[0][0] * m.data[1][3] - m.data[0][3] * m.data[1][0];
const b03 = m.data[0][1] * m.data[1][2] - m.data[0][2] * m.data[1][1];
const b04 = m.data[0][1] * m.data[1][3] - m.data[0][3] * m.data[1][1];
const b05 = m.data[0][2] * m.data[1][3] - m.data[0][3] * m.data[1][2];
const b06 = m.data[2][0] * m.data[3][1] - m.data[2][1] * m.data[3][0];
const b07 = m.data[2][0] * m.data[3][2] - m.data[2][2] * m.data[3][0];
const b08 = m.data[2][0] * m.data[3][3] - m.data[2][3] * m.data[3][0];
const b09 = m.data[2][1] * m.data[3][2] - m.data[2][2] * m.data[3][1];
const b10 = m.data[2][1] * m.data[3][3] - m.data[2][3] * m.data[3][1];
const b11 = m.data[2][2] * m.data[3][3] - m.data[2][3] * m.data[3][2];
// Calculate the determinant
return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
}
test "determinant" {
const matA = Mat4.create(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 2, 3, 1);
const out = Mat4.determinant(matA);
const expected = 1;
try testing.expect(utils.f_eq(out, expected));
}
/// Adds two mat4's
pub fn add(a: Mat4, b: Mat4) Mat4 {
return Mat4{
.data = .{
.{
a.data[0][0] + b.data[0][0],
a.data[0][1] + b.data[0][1],
a.data[0][2] + b.data[0][2],
a.data[0][3] + b.data[0][3],
},
.{
a.data[1][0] + b.data[1][0],
a.data[1][1] + b.data[1][1],
a.data[1][2] + b.data[1][2],
a.data[1][3] + b.data[1][3],
},
.{
a.data[2][0] + b.data[2][0],
a.data[2][1] + b.data[2][1],
a.data[2][2] + b.data[2][2],
a.data[2][3] + b.data[2][3],
},
.{
a.data[3][0] + b.data[3][0],
a.data[3][1] + b.data[3][1],
a.data[3][2] + b.data[3][2],
a.data[3][3] + b.data[3][3],
},
},
};
}
test "add" {
const matA = Mat4.create(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
const matB = Mat4.create(17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32);
const out = Mat4.add(matA, matB);
const expected = Mat4.create(18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48);
try expectEqual(expected, out);
}
/// Subtracts matrix b from matrix a
pub fn subtract(a: Mat4, b: Mat4) Mat4 {
return Mat4{
.data = .{
.{
a.data[0][0] - b.data[0][0],
a.data[0][1] - b.data[0][1],
a.data[0][2] - b.data[0][2],
a.data[0][3] - b.data[0][3],
},
.{
a.data[1][0] - b.data[1][0],
a.data[1][1] - b.data[1][1],
a.data[1][2] - b.data[1][2],
a.data[1][3] - b.data[1][3],
},
.{
a.data[2][0] - b.data[2][0],
a.data[2][1] - b.data[2][1],
a.data[2][2] - b.data[2][2],
a.data[2][3] - b.data[2][3],
},
.{
a.data[3][0] - b.data[3][0],
a.data[3][1] - b.data[3][1],
a.data[3][2] - b.data[3][2],
a.data[3][3] - b.data[3][3],
},
},
};
}
pub const sub = subtract;
test "substract" {
const matA = Mat4.create(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
const matB = Mat4.create(17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32);
const out = Mat4.sub(matA, matB);
const expected = Mat4.create(-16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16);
try expectEqual(expected, out);
}
///Multiplies two Mat4
pub fn multiply(a: Mat4, b: Mat4) Mat4 {
return Mat4{
.data = .{
.{
b.data[0][0] * a.data[0][0] + b.data[0][1] * a.data[1][0] + b.data[0][2] * a.data[2][0] + b.data[0][3] * a.data[3][0],
b.data[0][0] * a.data[0][1] + b.data[0][1] * a.data[1][1] + b.data[0][2] * a.data[2][1] + b.data[0][3] * a.data[3][1],
b.data[0][0] * a.data[0][2] + b.data[0][1] * a.data[1][2] + b.data[0][2] * a.data[2][2] + b.data[0][3] * a.data[3][2],
b.data[0][0] * a.data[0][3] + b.data[0][1] * a.data[1][3] + b.data[0][2] * a.data[2][3] + b.data[0][3] * a.data[3][3],
},
.{
b.data[1][0] * a.data[0][0] + b.data[1][1] * a.data[1][0] + b.data[1][2] * a.data[2][0] + b.data[1][3] * a.data[3][0],
b.data[1][0] * a.data[0][1] + b.data[1][1] * a.data[1][1] + b.data[1][2] * a.data[2][1] + b.data[1][3] * a.data[3][1],
b.data[1][0] * a.data[0][2] + b.data[1][1] * a.data[1][2] + b.data[1][2] * a.data[2][2] + b.data[1][3] * a.data[3][2],
b.data[1][0] * a.data[0][3] + b.data[1][1] * a.data[1][3] + b.data[1][2] * a.data[2][3] + b.data[1][3] * a.data[3][3],
},
.{
b.data[2][0] * a.data[0][0] + b.data[2][1] * a.data[1][0] + b.data[2][2] * a.data[2][0] + b.data[2][3] * a.data[3][0],
b.data[2][0] * a.data[0][1] + b.data[2][1] * a.data[1][1] + b.data[2][2] * a.data[2][1] + b.data[2][3] * a.data[3][1],
b.data[2][0] * a.data[0][2] + b.data[2][1] * a.data[1][2] + b.data[2][2] * a.data[2][2] + b.data[2][3] * a.data[3][2],
b.data[2][0] * a.data[0][3] + b.data[2][1] * a.data[1][3] + b.data[2][2] * a.data[2][3] + b.data[2][3] * a.data[3][3],
},
.{
b.data[3][0] * a.data[0][0] + b.data[3][1] * a.data[1][0] + b.data[3][2] * a.data[2][0] + b.data[3][3] * a.data[3][0],
b.data[3][0] * a.data[0][1] + b.data[3][1] * a.data[1][1] + b.data[3][2] * a.data[2][1] + b.data[3][3] * a.data[3][1],
b.data[3][0] * a.data[0][2] + b.data[3][1] * a.data[1][2] + b.data[3][2] * a.data[2][2] + b.data[3][3] * a.data[3][2],
b.data[3][0] * a.data[0][3] + b.data[3][1] * a.data[1][3] + b.data[3][2] * a.data[2][3] + b.data[3][3] * a.data[3][3],
},
},
};
}
pub const mul = multiply;
test "multiply" {
const matA = Mat4.create(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 2, 3, 1);
const matB = Mat4.create(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4, 5, 6, 1);
const out = Mat4.mul(matA, matB);
const expected = Mat4.create(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5, 7, 9, 1);
try expectEqual(expected, out);
}
pub fn multiplyScalar(a: Mat4, s: f32) Mat4 {
return Mat4{
.data = .{
.{
a.data[0][0] * s,
a.data[0][1] * s,
a.data[0][2] * s,
a.data[0][3] * s,
},
.{
a.data[1][0] * s,
a.data[1][1] * s,
a.data[1][2] * s,
a.data[1][3] * s,
},
.{
a.data[2][0] * s,
a.data[2][1] * s,
a.data[2][2] * s,
a.data[2][3] * s,
},
.{
a.data[3][0] * s,
a.data[3][1] * s,
a.data[3][2] * s,
a.data[3][3] * s,
},
},
};
}
test "multiplyScalar" {
const matA = Mat4.create(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
const out = Mat4.multiplyScalar(matA, 2.0);
const expected = Mat4.create(2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32);
try expectEqual(expected, out);
}
pub fn multiplyScalarAndAdd(a: Mat4, b: Mat4, s: f32) Mat4 {
return Mat4{
.data = .{
.{
@mulAdd(f32, b.data[0][0], s, a.data[0][0]),
@mulAdd(f32, b.data[0][1], s, a.data[0][1]),
@mulAdd(f32, b.data[0][2], s, a.data[0][2]),
@mulAdd(f32, b.data[0][3], s, a.data[0][3]),
},
.{
@mulAdd(f32, b.data[1][0], s, a.data[1][0]),
@mulAdd(f32, b.data[1][1], s, a.data[1][1]),
@mulAdd(f32, b.data[1][2], s, a.data[1][2]),
@mulAdd(f32, b.data[1][3], s, a.data[1][3]),
},
.{
@mulAdd(f32, b.data[2][0], s, a.data[2][0]),
@mulAdd(f32, b.data[2][1], s, a.data[2][1]),
@mulAdd(f32, b.data[2][2], s, a.data[2][2]),
@mulAdd(f32, b.data[2][3], s, a.data[2][3]),
},
.{
@mulAdd(f32, b.data[3][0], s, a.data[3][0]),
@mulAdd(f32, b.data[3][1], s, a.data[3][1]),
@mulAdd(f32, b.data[3][2], s, a.data[3][2]),
@mulAdd(f32, b.data[3][3], s, a.data[3][3]),
},
},
};
}
test "multiplyScalarAndAdd" {}
/// Translate a mat4 by the given vector
pub fn translate(a: Mat4, v: Vec3) Mat4 {
return Mat4{
.data = .{
.{
a.data[0][0],
a.data[0][1],
a.data[0][2],
a.data[0][3],
},
.{
a.data[1][0],
a.data[1][1],
a.data[1][2],
a.data[1][3],
},
.{
a.data[2][0],
a.data[2][1],
a.data[2][2],
a.data[2][3],
},
.{
v.x * a.data[0][0] + v.y * a.data[1][0] + a.data[2][0] * v.z + a.data[3][0],
v.x * a.data[0][1] + v.y * a.data[1][1] + a.data[2][1] * v.z + a.data[3][1],
v.x * a.data[0][2] + v.y * a.data[1][2] + a.data[2][2] * v.z + a.data[3][2],
v.x * a.data[0][3] + v.y * a.data[1][3] + a.data[2][3] * v.z + a.data[3][3],
},
},
};
}
test "translate" {
const matA = Mat4.create(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 2, 3, 1);
const out = Mat4.translate(matA, Vec3.create(4, 5, 6));
const expected = Mat4.create(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5, 7, 9, 1);
try expectEqual(expected, out);
}
///Rotates a mat4 by the given angle around the given axis
pub fn rotate(a: Mat4, rad: f32, axis: Vec3) ?Mat4 {
var x = axis.x;
var y = axis.y;
var z = axis.z;
var l = @sqrt(x * x + y * y + z * z); //len
if (l < utils.epsilon) return null;
l = 1 / l;
x *= l;
y *= l;
z *= l;
const s = @sin(rad);
const c = @cos(rad);
const t = 1 - c;
const b00 = x * x * t + c;
const b01 = y * x * t + z * s;
const b02 = z * x * t - y * s;
const b10 = x * y * t - z * s;
const b11 = y * y * t + c;
const b12 = z * y * t + x * s;
const b20 = x * z * t + y * s;
const b21 = y * z * t - x * s;
const b22 = z * z * t + c;
return Mat4{
.data = .{
.{
a.data[0][0] * b00 + a.data[1][0] * b01 + a.data[2][0] * b02,
a.data[0][1] * b00 + a.data[1][1] * b01 + a.data[2][1] * b02,
a.data[0][2] * b00 + a.data[1][2] * b01 + a.data[2][2] * b02,
a.data[0][3] * b00 + a.data[1][3] * b01 + a.data[2][3] * b02,
},
.{
a.data[0][0] * b10 + a.data[1][0] * b11 + a.data[2][0] * b12,
a.data[0][1] * b10 + a.data[1][1] * b11 + a.data[2][1] * b12,
a.data[0][2] * b10 + a.data[1][2] * b11 + a.data[2][2] * b12,
a.data[0][3] * b10 + a.data[1][3] * b11 + a.data[2][3] * b12,
},
.{
a.data[0][0] * b20 + a.data[1][0] * b21 + a.data[2][0] * b22,
a.data[0][1] * b20 + a.data[1][1] * b21 + a.data[2][1] * b22,
a.data[0][2] * b20 + a.data[1][2] * b21 + a.data[2][2] * b22,
a.data[0][3] * b20 + a.data[1][3] * b21 + a.data[2][3] * b22,
},
.{
a.data[3][0],
a.data[3][1],
a.data[3][2],
a.data[3][3],
},
},
};
}
test "rotate" {
const rad: f32 = math.pi * 0.5;
const axis = Vec3.create(1, 0, 0);
const matA = Mat4.create(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 2, 3, 1);
const out = Mat4.rotate(matA, rad, axis) orelse @panic("test failed");
const expected = Mat4.create(1, 0, 0, 0, 0, @cos(rad), @sin(rad), 0, 0, -@sin(rad), @cos(rad), 0, 1, 2, 3, 1);
try expectEqual(expected, out);
}
pub fn scale(a: Mat4, v: Vec3) Mat4 {
return Mat4{
.data = .{
.{
v.x * a.data[0][0],
v.x * a.data[0][1],
v.x * a.data[0][2],
v.x * a.data[0][3],
},
.{
v.y * a.data[1][0],
v.y * a.data[1][1],
v.y * a.data[1][2],
v.y * a.data[1][3],
},
.{
v.z * a.data[2][0],
v.z * a.data[2][1],
v.z * a.data[2][2],
v.z * a.data[2][3],
},
.{
a.data[3][0],
a.data[3][1],
a.data[3][2],
a.data[3][3],
},
},
};
}
test "scale" {
const matA = Mat4.create(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 2, 3, 1);
const out = Mat4.scale(matA, Vec3.create(4, 5, 6));
const expected = Mat4.create(4, 0, 0, 0, 0, 5, 0, 0, 0, 0, 6, 0, 1, 2, 3, 1);
try expectEqual(expected, out);
}
///Creates a matrix from a vector translation
pub fn fromTranslation(v: Vec3) Mat4 {
return Mat4{
.data = .{
.{
1, 0, 0, 0,
},
.{
0, 1, 0, 0,
},
.{
0, 0, 1, 0,
},
.{
v.x, v.y, v.z, 1,
},
},
};
}
pub fn fromRotation(rad: f32, axis: Vec3) ?Mat4 {
var x = axis.x;
var y = axis.y;
var z = axis.z;
var l = @sqrt(x * x + y * y + z * z);
if (l < utils.epsilon) return null;
l = 1 / l;
x *= l;
y *= l;
z *= l;
const s = @sin(rad);
const c = @cos(rad);
const t = 1 - c;
return Mat4{
.data = .{
.{
x * x * t + c,
y * x * t + z * s,
z * x * t - y * s,
0,
},
.{
x * y * t - z * s,
y * y * t + c,
z * y * t + x * s,
0,
},
.{
x * z * t + y * s,
y * z * t - x * s,
z * z * t + c,
0,
},
.{
0, 0, 0, 1,
},
},
};
}
pub fn fromXRotation(rad: f32) Mat4 {
const s = @sin(rad);
const c = @cos(rad);
return Mat4{
.data = .{
.{
1, 0, 0, 0,
},
.{
0, c, s, 0,
},
.{
0, -s, c, 0,
},
.{
0, 0, 0, 1,
},
},
};
}
/// Creates a matrix from the given angle around the Y axis
pub fn fromYRotation(rad: f32) Mat4 {
const s = @sin(rad);
const c = @cos(rad);
return Mat4{
.data = .{
.{
c, 0, -s, 0,
},
.{
0, 1, 0, 0,
},
.{
s, 0, c, 0,
},
.{
0, 0, 0, 1,
},
},
};
}
/// Creates a matrix from the given angle around the Z axis
pub fn fromZRotation(rad: f32) Mat4 {
const s = @sin(rad);
const c = @cos(rad);
return Mat4{
.data = .{
.{
c, s, 0, 0,
},
.{
-s, c, 0, 0,
},
.{
0, 0, 1, 0,
},
.{
0, 0, 0, 1,
},
},
};
}
/// Creates a matrix from a vector scaling
pub fn fromScaling(v: Vec3) Mat4 {
return Mat4{
.data = .{
.{
v.x, 0, 0, 0,
},
.{
0, v.y, 0, 0,
},
.{
0, 0, v.z, 0,
},
.{
0, 0, 0, 1,
},
},
};
}
/// Returns the translation vector component of a transformation
/// matrix. If a matrix is built with fromRotationTranslation,
/// the returned vector will be the same as the translation vector
/// originally supplied.
pub fn getTranslation(m: Mat4) Vec3 {
return Vec3.create(m.data[3][0], m.data[3][1], m.data[3][2]);
}
test "getTranslation - identity" {
var out = Mat4.getTranslation(mat4_identity);
const expected = Vec3.create(0, 0, 0);
try Vec3.expectEqual(expected, out);
}
test "getTranslation - translation-only" {
const matB = Mat4.create(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4, 5, 6, 1);
var out = Mat4.getTranslation(matB);
const expected = Vec3.create(4, 5, 6);
try Vec3.expectEqual(expected, out);
}
/// Returns the scaling factor component of a transformation
/// matrix. If a matrix is built with fromRotationTranslationScale
/// with a normalized Quaternion paramter, the returned vector will be
/// the same as the scaling vector
/// originally supplied.
pub fn getScaling(m: Mat4) Vec3 {
const m11 = m.data[0][0];
const m12 = m.data[0][1];
const m13 = m.data[0][2];
const m21 = m.data[1][0];
const m22 = m.data[1][1];
const m23 = m.data[1][2];
const m31 = m.data[2][0];
const m32 = m.data[2][1];
const m33 = m.data[2][2];
return Vec3.create(
@sqrt(m11 * m11 + m12 * m12 + m13 * m13),
@sqrt(m21 * m21 + m22 * m22 + m23 * m23),
@sqrt(m31 * m31 + m32 * m32 + m33 * m33),
);
}
test "getScaling" {
const matA = Mat4.targetTo(Vec3.create(0, 1, 0), Vec3.create(0, 0, 1), Vec3.create(0, 0, -1));
const out = Mat4.getScaling(matA);
const expected = Vec3.create(1, 1, 1);
try Vec3.expectEqual(expected, out);
}
pub fn frustum(left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32) Mat4 {
const rl = 1 / (right - left);
const tb = 1 / (top - bottom);
const nf = 1 / (near - far);
return Mat4{
.data = .{
.{
(near * 2) * rl,
0,
0,
0,
},
.{
0,
(near * 2) * tb,
0,
0,
},
.{
(right + left) * rl,
(top + bottom) * tb,
(far + near) * nf,
-1,
},
.{
0,
0,
(far * near * 2) * nf,
0,
},
},
};
}
test "frustum" {
const out = Mat4.frustum(-1, 1, -1, 1, -1, 1);
const expected = Mat4.create(-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0);
try expectEqual(expected, out);
}
/// Generates a perspective projection matrix with the given bounds.
/// Passing infinite for far will generate infinite projection matrix.
pub fn perspective(fovy: f32, aspect: f32, near: f32, far: f32) Mat4 {
const f = (1.0 / math.tan(fovy / 2));
const fasp = f / aspect;
const nf = 1 / (near - far);
const m22 = if (!math.isInf(far)) ((far + near) * nf) else -1.0;
const m32 = if (!math.isInf(far)) ((2 * far * near) * nf) else (-2.0 * near);
return Mat4{
.data = .{
.{
fasp,
0,
0,
0,
},
.{
0,
f,
0,
0,
},
.{
0,
0,
m22,
-1,
},
.{
0,
0,
m32,
0,
},
},
};
}
test "perspective" {
const out = Mat4.perspective(math.pi * 0.5, 1, 0, 1);
const expected = Mat4.create(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0);
try expectEqual(expected, out);
}
test "perspective, 45deg fovy, realistic aspect ratio" {
const out = Mat4.perspective(45 * math.pi / 180.0, 640.0 / 480.0, 0.1, 200);
const expected = Mat4.create(1.81066, 0, 0, 0, 0, 2.414213, 0, 0, 0, 0, -1.001, -1, 0, 0, -0.2001, 0);
try expectEqual(expected, out);
}
test "perspective, 45deg fovy, realistic aspect ratio, no far plane" {
const out = Mat4.perspective(45 * math.pi / 180.0, 640.0 / 480.0, 0.1, math.inf_f32);
const expected = Mat4.create(1.81066, 0, 0, 0, 0, 2.414213, 0, 0, 0, 0, -1, -1, 0, 0, -0.2, 0);
try expectEqual(expected, out);
}
/// Generates a orthogonal projection matrix with the given bounds
pub fn ortho(left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32) Mat4 {
const lr = 1 / (left - right);
const bt = 1 / (bottom - top);
const nf = 1 / (near - far);
return Mat4{
.data = .{
.{
-2 * lr,
0,
0,
0,
},
.{
0,
-2 * bt,
0,
0,
},
.{
0,
0,
2 * nf,
0,
},
.{
(left + right) * lr,
(top + bottom) * bt,
(far + near) * nf,
1,
},
},
};
}
test "ortho" {
const out = Mat4.ortho(-1, 1, -1, 1, -1, 1);
const expected = Mat4.create(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1);
try expectEqual(expected, out);
}
/// Generates a look-at matrix with the given eye position, focal point, and up axis.
/// If you want a matrix that actually makes an object look at another object, you should use targetTo instead.
pub fn lookat(eye: Vec3, center: Vec3, up: Vec3) Mat4 {
const eyex = eye.x;
const eyey = eye.y;
const eyez = eye.z;
const upx = up.x;
const upy = up.y;
const upz = up.z;
const centerx = center.x;
const centery = center.y;
const centerz = center.z;
if (@fabs(eyex - centerx) < utils.epsilon and
@fabs(eyey - centery) < utils.epsilon and
@fabs(eyez - centerz) < utils.epsilon)
return mat4_identity;
var z0 = eyex - centerx;
var z1 = eyey - centery;
var z2 = eyez - centerz;
var l = 1 / @sqrt(z0 * z0 + z1 * z1 + z2 * z2);
z0 *= l;
z1 *= l;
z2 *= l;
var x0 = upy * z2 - upz * z1;
var x1 = upz * z0 - upx * z2;
var x2 = upx * z1 - upy * z0;
l = @sqrt(x0 * x0 + x1 * x1 + x2 * x2);
if (l == 0) {
x0 = 0;
x1 = 0;
x2 = 0;
} else {
l = 1 / l;
x0 *= l;
x1 *= l;
x2 *= l;
}
var y0 = z1 * x2 - z2 * x1;
var y1 = z2 * x0 - z0 * x2;
var y2 = z0 * x1 - z1 * x0;
l = @sqrt(y0 * y0 + y1 * y1 + y2 * y2);
if (l == 0) {
y0 = 0;
y1 = 0;
y2 = 0;
} else {
l = 1 / l;
y0 *= l;
y1 *= l;
y2 *= l;
}
return Mat4{
.data = .{
.{
x0, y0, z0, 0,
},
.{
x1, y1, z1, 0,
},
.{
x2, y2, z2, 0,
},
.{
-(x0 * eyex + x1 * eyey + x2 * eyez),
-(y0 * eyex + y1 * eyey + y2 * eyez),
-(z0 * eyex + z1 * eyey + z2 * eyez),
1,
},
},
};
}
test "lookat (down)" {
const view = Vec3.create(0, -1, 0);
const up = Vec3.create(0, 0, -1);
const right = Vec3.create(1, 0, 0);
const out = Mat4.lookat(Vec3.create(0, 0, 0), view, up);
var result = Vec3.transformMat4(view, out);
try Vec3.expectEqual(result, Vec3.create(0, 0, -1));
result = Vec3.transformMat4(up, out);
try Vec3.expectEqual(result, Vec3.create(0, 1, 0));
result = Vec3.transformMat4(right, out);
try Vec3.expectEqual(result, Vec3.create(1, 0, 0));
}
/// Generates a matrix that makes something look at something else.
pub fn targetTo(eye: Vec3, target: Vec3, up: Vec3) Mat4 {
const eyex = eye.x;
const eyey = eye.y;
const eyez = eye.z;
const upx = up.x;
const upy = up.y;
const upz = up.z;
var z0 = eyex - target.x;
var z1 = eyey - target.y;
var z2 = eyez - target.z;
var l = z0 * z0 + z1 * z1 + z2 * z2;
if (l > 0) {
l = 1 / @sqrt(l);
z0 *= l;
z1 *= l;
z2 *= l;
}
var x0 = upy * z2 - upz * z1;
var x1 = upz * z0 - upx * z2;
var x2 = upx * z1 - upy * z0;
l = x0 * x0 + x1 * x1 + x2 * x2;
if (l > 0) {
l = 1 / @sqrt(l);
x0 *= l;
x1 *= l;
x2 *= l;
}
return Mat4{
.data = .{
.{
x0, x1, x2, 0,
},
.{
z1 * x2 - z2 * x1,
z2 * x0 - z0 * x2,
z0 * x1 - z1 * x0,
0,
},
.{
z0, z1, z2, 0,
},
.{
eyex, eyey, eyez, 1,
},
},
};
}
test "targetTo (looking down)" {
const view = Vec3.create(0, -1, 0);
const up = Vec3.create(0, 0, -1);
const right = Vec3.create(1, 0, 0);
const out = Mat4.targetTo(Vec3.create(0, 0, 0), view, up);
var result = Vec3.transformMat4(view, out);
try Vec3.expectEqual(result, Vec3.create(0, 0, 1));
result = Vec3.transformMat4(up, out);
try Vec3.expectEqual(result, Vec3.create(0, -1, 0));
result = Vec3.transformMat4(right, out);
try Vec3.expectEqual(result, Vec3.create(1, 0, 0));
}
pub fn equals(a: Mat4, b: Mat4) bool {
const epsilon = utils.epsilon;
const a0 = a.data[0][0];
const a1 = a.data[0][1];
const a2 = a.data[0][2];
const a3 = a.data[0][3];
const a4 = a.data[1][0];
const a5 = a.data[1][1];
const a6 = a.data[1][2];
const a7 = a.data[1][3];
const a8 = a.data[2][0];
const a9 = a.data[2][1];
const a10 = a.data[2][2];
const a11 = a.data[2][3];
const a12 = a.data[3][0];
const a13 = a.data[3][1];
const a14 = a.data[3][2];
const a15 = a.data[3][3];
const b0 = b.data[0][0];
const b1 = b.data[0][1];
const b2 = b.data[0][2];
const b3 = b.data[0][3];
const b4 = b.data[1][0];
const b5 = b.data[1][1];
const b6 = b.data[1][2];
const b7 = b.data[1][3];
const b8 = b.data[2][0];
const b9 = b.data[2][1];
const b10 = b.data[2][2];
const b11 = b.data[2][3];
const b12 = b.data[3][0];
const b13 = b.data[3][1];
const b14 = b.data[3][2];
const b15 = b.data[3][3];
return (@fabs(a0 - b0) <= epsilon * math.max(1, math.max(@fabs(a0), @fabs(b0))) and
@fabs(a1 - b1) <= epsilon * math.max(1, math.max(@fabs(a1), @fabs(b1))) and
@fabs(a2 - b2) <= epsilon * math.max(1, math.max(@fabs(a2), @fabs(b2))) and
@fabs(a3 - b3) <= epsilon * math.max(1, math.max(@fabs(a3), @fabs(b3))) and
@fabs(a4 - b4) <= epsilon * math.max(1, math.max(@fabs(a4), @fabs(b4))) and
@fabs(a5 - b5) <= epsilon * math.max(1, math.max(@fabs(a5), @fabs(b5))) and
@fabs(a6 - b6) <= epsilon * math.max(1, math.max(@fabs(a6), @fabs(b6))) and
@fabs(a7 - b7) <= epsilon * math.max(1, math.max(@fabs(a7), @fabs(b7))) and
@fabs(a8 - b8) <= epsilon * math.max(1, math.max(@fabs(a8), @fabs(b8))) and
@fabs(a9 - b9) <= epsilon * math.max(1, math.max(@fabs(a9), @fabs(b9))) and
@fabs(a10 - b10) <= epsilon * math.max(1, math.max(@fabs(a10), @fabs(b10))) and
@fabs(a11 - b11) <= epsilon * math.max(1, math.max(@fabs(a11), @fabs(b11))) and
@fabs(a12 - b12) <= epsilon * math.max(1, math.max(@fabs(a12), @fabs(b12))) and
@fabs(a13 - b13) <= epsilon * math.max(1, math.max(@fabs(a13), @fabs(b13))) and
@fabs(a14 - b14) <= epsilon * math.max(1, math.max(@fabs(a14), @fabs(b14))) and
@fabs(a15 - b15) <= epsilon * math.max(1, math.max(@fabs(a15), @fabs(b15))));
}
pub fn exactEquals(a: Mat4, b: Mat4) bool {
return a.data[0][0] == b.data[0][0] and
a.data[0][1] == b.data[0][1] and
a.data[0][2] == b.data[0][2] and
a.data[0][3] == b.data[0][3] and
a.data[1][0] == b.data[1][0] and
a.data[1][1] == b.data[1][1] and
a.data[1][2] == b.data[1][2] and
a.data[1][3] == b.data[1][3] and
a.data[2][0] == b.data[2][0] and
a.data[2][1] == b.data[2][1] and
a.data[2][2] == b.data[2][2] and
a.data[2][3] == b.data[2][3] and
a.data[3][0] == b.data[3][0] and
a.data[3][1] == b.data[3][1] and
a.data[3][2] == b.data[3][2] and
a.data[3][3] == b.data[3][3];
}
pub fn format(
value: @This(),
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
writer: anytype,
) !void {
_ = options;
_ = fmt;
const str = "Mat4({d:.7}, {d:.7}, {d:.7}, {d:.7}, {d:.7}, {d:.7}, {d:.7}, {d:.7}, {d:.7}, {d:.7}, {d:.7}, {d:.7}, {d:.7}, {d:.7}, {d:.7}, {d:.7}, )";
return std.fmt.format(
writer,
str,
.{
value.data[0][0],
value.data[0][1],
value.data[0][2],
value.data[0][3],
value.data[1][0],
value.data[1][1],
value.data[1][2],
value.data[1][3],
value.data[2][0],
value.data[2][1],
value.data[2][2],
value.data[2][3],
value.data[3][0],
value.data[3][1],
value.data[3][2],
value.data[3][3],
},
);
}
fn expectEqual(a: Mat4, b: Mat4) !void {
if (!a.equals(b)) {
std.debug.warn("Expected:\n{}, found\n{}\n", .{ a, b });
return error.NotEqual;
}
}
}; | src/mat4.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const Imgui = @import("imgui.zig");
const warn = std.debug.warn;
const fmt = std.fmt;
const assert = std.debug.assert;
usingnamespace @cImport({
@cInclude("vulkan/vulkan.h");
});
const DVULKAN_DEBUG_REPORT = (std.builtin.mode == .Debug);
const SwapchainFrame = struct {
command_pool: VkCommandPool = null,
command_buffer: VkCommandBuffer = null,
fence: VkFence = null,
backbuffer: VkImage = null,
backbuffer_view: VkImageView = null,
framebuffer: VkFramebuffer = null,
};
const SwapchainSemaphores = struct {
image_acquired_semaphore: VkSemaphore = null,
render_complete_semaphore: VkSemaphore = null,
};
const FrameRenderData = struct {
const RenderData = struct { // données pour un drawcall primitive
vertex_memory: VkDeviceMemory = null,
index_memory: VkDeviceMemory = null,
vertex_size: VkDeviceSize = 0,
index_size: VkDeviceSize = 0,
vertex: VkBuffer = null,
index: VkBuffer = null,
descriptor_set: VkDescriptorSet = null,
};
data: ArrayList(RenderData), // 0 = imgui data
// mm devrait pas être là pour le multiwindow?
active_texture_uploads: ArrayList(TextureUpload),
active_transcient_texture: ArrayList(*Texture),
};
const VulkanWindow = struct {
width: u32 = 0,
height: u32 = 0,
swapchain: VkSwapchainKHR = null,
surface: VkSurfaceKHR = null,
surface_format: VkSurfaceFormatKHR = undefined,
present_mode: VkPresentModeKHR = undefined,
render_pass: VkRenderPass = null,
clear_enable: bool = false,
clear_value: VkClearValue = undefined,
frame_index: u32 = 0,
frames: []SwapchainFrame = &[0]SwapchainFrame{},
semaphore_index: u32 = 0,
frame_semaphores: []SwapchainSemaphores = &[0]SwapchainSemaphores{},
render_data_index: u32 = 0,
frame_render_data: []FrameRenderData = &[0]FrameRenderData{},
};
const Context = struct {
instance: VkInstance = null,
physical_device: VkPhysicalDevice = null,
device: VkDevice = null,
debug_report: VkDebugReportCallbackEXT = null,
vk_allocator: ?*const VkAllocationCallbacks = null,
allocator: *Allocator,
descriptor_pool: VkDescriptorPool = null,
descriptor_set_layout: VkDescriptorSetLayout = null,
pipeline_layout: VkPipelineLayout = null,
pipeline: VkPipeline = null,
pipeline_cache: VkPipelineCache = null,
queue: VkQueue = null,
main_window_data: VulkanWindow = VulkanWindow{},
MSAA_samples: VkSampleCountFlagBits = VK_SAMPLE_COUNT_1_BIT,
buffer_memory_alignment: VkDeviceSize = 256,
pipeline_create_flags: VkPipelineCreateFlags = 0x00,
min_image_count: u32 = 2,
queue_family: u32 = 0xFFFFFFFF,
tiling_sampler: VkSampler = null,
font_texture: Texture = Texture{},
// things queued to render, in addition to imgui
frame_texture_uploads: ArrayList(TextureUpload),
frame_draw_quads: ArrayList(Quad),
};
pub const Vec2 = Imgui.Vec2;
const Quad = struct {
corners: [4]Vec2,
texture: *Texture,
};
const Texture = struct {
memory: VkDeviceMemory = null,
image: VkImage = null,
view: VkImageView = null,
extent: VkExtent3D = undefined,
};
const TextureUpload = struct {
memory: VkDeviceMemory = null,
buffer: VkBuffer = null,
texture: *const Texture = undefined,
};
fn checkVkResult(err: VkResult) !void {
if (err == VK_SUCCESS) return;
warn("VkResult: {}\n", .{err});
if (err < 0)
return error.VulkanError;
}
// ---------------------------------------
//-----------------------------------------------------------------------------
// SHADERS
//-----------------------------------------------------------------------------
// glsl_shader.vert, compiled with:
// # glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert
//
// #version 450 core
// layout(location = 0) in vec2 aPos;
// layout(location = 1) in vec2 aUV;
// layout(location = 2) in vec4 aColor;
// layout(push_constant) uniform uPushConstant { vec2 uScale; vec2 uTranslate; } pc;
//
// out gl_PerVertex { vec4 gl_Position; };
// layout(location = 0) out struct { vec4 Color; vec2 UV; } Out;
//
// void main()
// {
// Out.Color = aColor;
// Out.UV = aUV;
// gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
// }
const __glsl_shader_vert_spv = [_]u32{
0x07230203, 0x00010000, 0x00080001, 0x0000002e, 0x00000000, 0x00020011, 0x00000001, 0x0006000b,
0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 0x00000000, 0x00000001,
0x000a000f, 0x00000000, 0x00000004, 0x6e69616d, 0x00000000, 0x0000000b, 0x0000000f, 0x00000015,
0x0000001b, 0x0000001c, 0x00030003, 0x00000002, 0x000001c2, 0x00040005, 0x00000004, 0x6e69616d,
0x00000000, 0x00030005, 0x00000009, 0x00000000, 0x00050006, 0x00000009, 0x00000000, 0x6f6c6f43,
0x00000072, 0x00040006, 0x00000009, 0x00000001, 0x00005655, 0x00030005, 0x0000000b, 0x0074754f,
0x00040005, 0x0000000f, 0x6c6f4361, 0x0000726f, 0x00030005, 0x00000015, 0x00565561, 0x00060005,
0x00000019, 0x505f6c67, 0x65567265, 0x78657472, 0x00000000, 0x00060006, 0x00000019, 0x00000000,
0x505f6c67, 0x7469736f, 0x006e6f69, 0x00030005, 0x0000001b, 0x00000000, 0x00040005, 0x0000001c,
0x736f5061, 0x00000000, 0x00060005, 0x0000001e, 0x73755075, 0x6e6f4368, 0x6e617473, 0x00000074,
0x00050006, 0x0000001e, 0x00000000, 0x61635375, 0x0000656c, 0x00060006, 0x0000001e, 0x00000001,
0x61725475, 0x616c736e, 0x00006574, 0x00030005, 0x00000020, 0x00006370, 0x00040047, 0x0000000b,
0x0000001e, 0x00000000, 0x00040047, 0x0000000f, 0x0000001e, 0x00000002, 0x00040047, 0x00000015,
0x0000001e, 0x00000001, 0x00050048, 0x00000019, 0x00000000, 0x0000000b, 0x00000000, 0x00030047,
0x00000019, 0x00000002, 0x00040047, 0x0000001c, 0x0000001e, 0x00000000, 0x00050048, 0x0000001e,
0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x0000001e, 0x00000001, 0x00000023, 0x00000008,
0x00030047, 0x0000001e, 0x00000002, 0x00020013, 0x00000002, 0x00030021, 0x00000003, 0x00000002,
0x00030016, 0x00000006, 0x00000020, 0x00040017, 0x00000007, 0x00000006, 0x00000004, 0x00040017,
0x00000008, 0x00000006, 0x00000002, 0x0004001e, 0x00000009, 0x00000007, 0x00000008, 0x00040020,
0x0000000a, 0x00000003, 0x00000009, 0x0004003b, 0x0000000a, 0x0000000b, 0x00000003, 0x00040015,
0x0000000c, 0x00000020, 0x00000001, 0x0004002b, 0x0000000c, 0x0000000d, 0x00000000, 0x00040020,
0x0000000e, 0x00000001, 0x00000007, 0x0004003b, 0x0000000e, 0x0000000f, 0x00000001, 0x00040020,
0x00000011, 0x00000003, 0x00000007, 0x0004002b, 0x0000000c, 0x00000013, 0x00000001, 0x00040020,
0x00000014, 0x00000001, 0x00000008, 0x0004003b, 0x00000014, 0x00000015, 0x00000001, 0x00040020,
0x00000017, 0x00000003, 0x00000008, 0x0003001e, 0x00000019, 0x00000007, 0x00040020, 0x0000001a,
0x00000003, 0x00000019, 0x0004003b, 0x0000001a, 0x0000001b, 0x00000003, 0x0004003b, 0x00000014,
0x0000001c, 0x00000001, 0x0004001e, 0x0000001e, 0x00000008, 0x00000008, 0x00040020, 0x0000001f,
0x00000009, 0x0000001e, 0x0004003b, 0x0000001f, 0x00000020, 0x00000009, 0x00040020, 0x00000021,
0x00000009, 0x00000008, 0x0004002b, 0x00000006, 0x00000028, 0x00000000, 0x0004002b, 0x00000006,
0x00000029, 0x3f800000, 0x00050036, 0x00000002, 0x00000004, 0x00000000, 0x00000003, 0x000200f8,
0x00000005, 0x0004003d, 0x00000007, 0x00000010, 0x0000000f, 0x00050041, 0x00000011, 0x00000012,
0x0000000b, 0x0000000d, 0x0003003e, 0x00000012, 0x00000010, 0x0004003d, 0x00000008, 0x00000016,
0x00000015, 0x00050041, 0x00000017, 0x00000018, 0x0000000b, 0x00000013, 0x0003003e, 0x00000018,
0x00000016, 0x0004003d, 0x00000008, 0x0000001d, 0x0000001c, 0x00050041, 0x00000021, 0x00000022,
0x00000020, 0x0000000d, 0x0004003d, 0x00000008, 0x00000023, 0x00000022, 0x00050085, 0x00000008,
0x00000024, 0x0000001d, 0x00000023, 0x00050041, 0x00000021, 0x00000025, 0x00000020, 0x00000013,
0x0004003d, 0x00000008, 0x00000026, 0x00000025, 0x00050081, 0x00000008, 0x00000027, 0x00000024,
0x00000026, 0x00050051, 0x00000006, 0x0000002a, 0x00000027, 0x00000000, 0x00050051, 0x00000006,
0x0000002b, 0x00000027, 0x00000001, 0x00070050, 0x00000007, 0x0000002c, 0x0000002a, 0x0000002b,
0x00000028, 0x00000029, 0x00050041, 0x00000011, 0x0000002d, 0x0000001b, 0x0000000d, 0x0003003e,
0x0000002d, 0x0000002c, 0x000100fd, 0x00010038,
};
// glsl_shader.frag, compiled with:
// # glslangValidator -V -x -o glsl_shader.frag.u32 glsl_shader.frag
//
// #version 450 core
// layout(location = 0) out vec4 fColor;
// layout(set=0, binding=0) uniform sampler2D sTexture;
// layout(location = 0) in struct { vec4 Color; vec2 UV; } In;
// void main()
// {
// fColor = In.Color * texture(sTexture, In.UV.st);
// }
const __glsl_shader_frag_spv = [_]u32{
0x07230203, 0x00010000, 0x00080001, 0x0000001e, 0x00000000, 0x00020011, 0x00000001, 0x0006000b,
0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 0x00000000, 0x00000001,
0x0007000f, 0x00000004, 0x00000004, 0x6e69616d, 0x00000000, 0x00000009, 0x0000000d, 0x00030010,
0x00000004, 0x00000007, 0x00030003, 0x00000002, 0x000001c2, 0x00040005, 0x00000004, 0x6e69616d,
0x00000000, 0x00040005, 0x00000009, 0x6c6f4366, 0x0000726f, 0x00030005, 0x0000000b, 0x00000000,
0x00050006, 0x0000000b, 0x00000000, 0x6f6c6f43, 0x00000072, 0x00040006, 0x0000000b, 0x00000001,
0x00005655, 0x00030005, 0x0000000d, 0x00006e49, 0x00050005, 0x00000016, 0x78655473, 0x65727574,
0x00000000, 0x00040047, 0x00000009, 0x0000001e, 0x00000000, 0x00040047, 0x0000000d, 0x0000001e,
0x00000000, 0x00040047, 0x00000016, 0x00000022, 0x00000000, 0x00040047, 0x00000016, 0x00000021,
0x00000000, 0x00020013, 0x00000002, 0x00030021, 0x00000003, 0x00000002, 0x00030016, 0x00000006,
0x00000020, 0x00040017, 0x00000007, 0x00000006, 0x00000004, 0x00040020, 0x00000008, 0x00000003,
0x00000007, 0x0004003b, 0x00000008, 0x00000009, 0x00000003, 0x00040017, 0x0000000a, 0x00000006,
0x00000002, 0x0004001e, 0x0000000b, 0x00000007, 0x0000000a, 0x00040020, 0x0000000c, 0x00000001,
0x0000000b, 0x0004003b, 0x0000000c, 0x0000000d, 0x00000001, 0x00040015, 0x0000000e, 0x00000020,
0x00000001, 0x0004002b, 0x0000000e, 0x0000000f, 0x00000000, 0x00040020, 0x00000010, 0x00000001,
0x00000007, 0x00090019, 0x00000013, 0x00000006, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
0x00000001, 0x00000000, 0x0003001b, 0x00000014, 0x00000013, 0x00040020, 0x00000015, 0x00000000,
0x00000014, 0x0004003b, 0x00000015, 0x00000016, 0x00000000, 0x0004002b, 0x0000000e, 0x00000018,
0x00000001, 0x00040020, 0x00000019, 0x00000001, 0x0000000a, 0x00050036, 0x00000002, 0x00000004,
0x00000000, 0x00000003, 0x000200f8, 0x00000005, 0x00050041, 0x00000010, 0x00000011, 0x0000000d,
0x0000000f, 0x0004003d, 0x00000007, 0x00000012, 0x00000011, 0x0004003d, 0x00000014, 0x00000017,
0x00000016, 0x00050041, 0x00000019, 0x0000001a, 0x0000000d, 0x00000018, 0x0004003d, 0x0000000a,
0x0000001b, 0x0000001a, 0x00050057, 0x00000007, 0x0000001c, 0x00000017, 0x0000001b, 0x00050085,
0x00000007, 0x0000001d, 0x00000012, 0x0000001c, 0x0003003e, 0x00000009, 0x0000001d, 0x000100fd,
0x00010038,
};
//-----------------------------------------------------------------------------
// FUNCTIONS
//-----------------------------------------------------------------------------
fn getMemoryType(ctx: *Context, properties: VkMemoryPropertyFlags, type_bits: u32) u32 {
var prop: VkPhysicalDeviceMemoryProperties = undefined;
vkGetPhysicalDeviceMemoryProperties(ctx.physical_device, &prop);
var i: u32 = 0;
while (i < prop.memoryTypeCount) : (i += 1) {
const mask: u32 = @as(u32, 1) << @intCast(u5, i);
if ((prop.memoryTypes[i].propertyFlags & properties) == properties and (type_bits & mask) != 0)
return i;
}
return 0xFFFFFFFF; // Unable to find memoryType
}
fn alignSize(size: usize, alignment: usize) usize {
return ((size - 1) / alignment + 1) * alignment;
}
fn createOrResizeBuffer(ctx: *Context, buffer: *VkBuffer, buffer_memory: *VkDeviceMemory, p_buffer_size: *VkDeviceSize, new_size: usize, usage: VkBufferUsageFlagBits) !void {
var err: VkResult = undefined;
if (buffer.* != null)
vkDestroyBuffer(ctx.device, buffer.*, ctx.vk_allocator);
if (buffer_memory.* != null)
vkFreeMemory(ctx.device, buffer_memory.*, ctx.vk_allocator);
const size_aligned: VkDeviceSize = alignSize(new_size, ctx.buffer_memory_alignment);
const buffer_info = VkBufferCreateInfo{
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.pNext = null,
.flags = 0,
.size = size_aligned,
.usage = @intCast(u32, usage),
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
.queueFamilyIndexCount = 0,
.pQueueFamilyIndices = null,
};
err = vkCreateBuffer(ctx.device, &buffer_info, ctx.vk_allocator, buffer);
try checkVkResult(err);
var req: VkMemoryRequirements = undefined;
vkGetBufferMemoryRequirements(ctx.device, buffer.*, &req);
ctx.buffer_memory_alignment = if (ctx.buffer_memory_alignment > req.alignment) ctx.buffer_memory_alignment else req.alignment;
const alloc_info = VkMemoryAllocateInfo{
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
.pNext = null,
.allocationSize = req.size,
.memoryTypeIndex = getMemoryType(ctx, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits),
};
err = vkAllocateMemory(ctx.device, &alloc_info, ctx.vk_allocator, buffer_memory);
try checkVkResult(err);
err = vkBindBufferMemory(ctx.device, buffer.*, buffer_memory.*, 0);
try checkVkResult(err);
p_buffer_size.* = size_aligned;
}
const DisplayTransfo = struct {
scale: [2]f32,
translate: [2]f32,
fb_width: u32,
fb_height: u32,
};
const PrimitiveDrawData = struct {
vertices: []const Imgui.DrawVert,
indices: []const Imgui.DrawIdx,
};
fn setupRenderState(ctx: *Context, command_buffer: VkCommandBuffer, frd: *FrameRenderData.RenderData, primitives_data: []const PrimitiveDrawData, imageView: VkImageView, displayTransfo: DisplayTransfo) !void {
var err: VkResult = undefined;
// Upload vertex/index data into a single contiguous GPU buffer
{
var vertex_size: usize = undefined;
var index_size: usize = undefined;
{
var total_vertex_count: usize = 0;
var total_index_count: usize = 0;
for (primitives_data) |prim| {
total_vertex_count += prim.vertices.len;
total_index_count += prim.indices.len;
}
vertex_size = total_vertex_count * @sizeOf(Imgui.DrawVert);
index_size = total_index_count * @sizeOf(Imgui.DrawIdx);
}
if (frd.vertex == null or frd.vertex_size < vertex_size)
try createOrResizeBuffer(ctx, &frd.vertex, &frd.vertex_memory, &frd.vertex_size, vertex_size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
if (frd.index == null or frd.index_size < index_size)
try createOrResizeBuffer(ctx, &frd.index, &frd.index_memory, &frd.index_size, index_size, VK_BUFFER_USAGE_INDEX_BUFFER_BIT);
{
var vtx_dst: [*]Imgui.DrawVert = undefined;
var idx_dst: [*]Imgui.DrawIdx = undefined;
err = vkMapMemory(ctx.device, frd.vertex_memory, 0, alignSize(vertex_size, ctx.buffer_memory_alignment), 0, @ptrCast([*c]?*c_void, &vtx_dst));
try checkVkResult(err);
err = vkMapMemory(ctx.device, frd.index_memory, 0, alignSize(index_size, ctx.buffer_memory_alignment), 0, @ptrCast([*c]?*c_void, &idx_dst));
try checkVkResult(err);
for (primitives_data) |prim| {
std.mem.copy(Imgui.DrawVert, vtx_dst[0..prim.vertices.len], prim.vertices);
std.mem.copy(Imgui.DrawIdx, idx_dst[0..prim.indices.len], prim.indices);
vtx_dst += prim.vertices.len;
idx_dst += prim.indices.len;
}
const ranges = [_]VkMappedMemoryRange{
VkMappedMemoryRange{
.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
.pNext = null,
.memory = frd.vertex_memory,
.size = VK_WHOLE_SIZE,
.offset = 0,
},
VkMappedMemoryRange{
.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
.pNext = null,
.memory = frd.index_memory,
.size = VK_WHOLE_SIZE,
.offset = 0,
},
};
err = vkFlushMappedMemoryRanges(ctx.device, ranges.len, &ranges);
try checkVkResult(err);
vkUnmapMemory(ctx.device, frd.vertex_memory);
vkUnmapMemory(ctx.device, frd.index_memory);
}
}
// Create and Update the Descriptor Set:
{
if (frd.descriptor_set == null) {
const alloc_info = VkDescriptorSetAllocateInfo{
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
.pNext = null,
.descriptorPool = ctx.descriptor_pool,
.descriptorSetCount = 1,
.pSetLayouts = &ctx.descriptor_set_layout,
};
err = vkAllocateDescriptorSets(ctx.device, &alloc_info, &frd.descriptor_set);
try checkVkResult(err);
}
const desc_image = [_]VkDescriptorImageInfo{
.{
.sampler = ctx.tiling_sampler,
.imageView = imageView,
.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
},
};
const write_desc = [_]VkWriteDescriptorSet{
.{
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
.pNext = null,
.dstSet = frd.descriptor_set,
.dstBinding = 0,
.dstArrayElement = 0,
.descriptorCount = 1,
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
.pImageInfo = &desc_image,
.pBufferInfo = null,
.pTexelBufferView = null,
},
};
vkUpdateDescriptorSets(ctx.device, write_desc.len, &write_desc, 0, null);
}
// Bind pipeline and descriptor sets:
{
vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx.pipeline);
const desc_set = [_]VkDescriptorSet{frd.descriptor_set};
vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx.pipeline_layout, 0, desc_set.len, &desc_set, 0, null);
}
// Bind Vertex And index Buffer:
{
const vertex_buffers = [_]VkBuffer{frd.vertex};
const vertex_offset = [_]VkDeviceSize{0};
vkCmdBindVertexBuffers(command_buffer, 0, 1, &vertex_buffers, &vertex_offset);
assert(@sizeOf(Imgui.DrawIdx) == 2);
vkCmdBindIndexBuffer(command_buffer, frd.index, 0, VK_INDEX_TYPE_UINT16);
}
// Setup scale and translation:
{
vkCmdPushConstants(command_buffer, ctx.pipeline_layout, VK_SHADER_STAGE_VERTEX_BIT, @sizeOf(f32) * 0, @sizeOf(f32) * 2, &displayTransfo.scale);
vkCmdPushConstants(command_buffer, ctx.pipeline_layout, VK_SHADER_STAGE_VERTEX_BIT, @sizeOf(f32) * 2, @sizeOf(f32) * 2, &displayTransfo.translate);
}
// Setup viewport:
{
const viewport = VkViewport{
.x = 0,
.y = 0,
.width = @intToFloat(f32, displayTransfo.fb_width),
.height = @intToFloat(f32, displayTransfo.fb_height),
.minDepth = 0.0,
.maxDepth = 1.0,
};
vkCmdSetViewport(command_buffer, 0, 1, &viewport);
}
}
fn renderDrawData(ctx: *Context, frd: *FrameRenderData.RenderData, displayTransfo: DisplayTransfo, draw_data: *const Imgui.DrawData, command_buffer: VkCommandBuffer) !void {
const lists = if (draw_data.CmdListsCount > 0) draw_data.CmdLists.?[0..@intCast(u32, draw_data.CmdListsCount)] else &[0]*Imgui.DrawList{};
var primitive_storage: [1000]PrimitiveDrawData = undefined;
const primitives = primitive_storage[0..@intCast(usize, draw_data.CmdListsCount)];
for (lists) |cmd_list, i| {
primitives[i].vertices = cmd_list.VtxBuffer.items[0..@intCast(usize, cmd_list.VtxBuffer.len)];
primitives[i].indices = cmd_list.IdxBuffer.items[0..@intCast(usize, cmd_list.IdxBuffer.len)];
}
// Setup desired Vulkan state
try setupRenderState(ctx, command_buffer, frd, primitives, ctx.font_texture.view, displayTransfo);
// Will project scissor/clipping rectangles into framebuffer space
const clip_off = draw_data.DisplayPos; // (0,0) unless using multi-viewports
const clip_scale = draw_data.FramebufferScale; // (1,1) unless using retina display which are often (2,2)
// Render command lists
// (Because we merged all buffers into a single one, we maintain our own offset into them)
var global_vtx_offset: u32 = 0;
var global_idx_offset: u32 = 0;
for (lists) |cmd_list| {
for (cmd_list.CmdBuffer.items[0..@intCast(usize, cmd_list.CmdBuffer.len)]) |*pcmd| {
assert(pcmd.UserCallback == null);
// Project scissor/clipping rectangles into framebuffer space
var clip_rect = Imgui.Vec4{
.x = (pcmd.ClipRect.x - clip_off.x) * clip_scale.x,
.y = (pcmd.ClipRect.y - clip_off.y) * clip_scale.y,
.z = (pcmd.ClipRect.z - clip_off.x) * clip_scale.x,
.w = (pcmd.ClipRect.w - clip_off.y) * clip_scale.y,
};
if (clip_rect.x < @intToFloat(f32, displayTransfo.fb_width) and clip_rect.y < @intToFloat(f32, displayTransfo.fb_height) and clip_rect.z >= 0.0 and clip_rect.w >= 0.0) {
// Negative offsets are illegal for vkCmdSetScissor
if (clip_rect.x < 0.0)
clip_rect.x = 0.0;
if (clip_rect.y < 0.0)
clip_rect.y = 0.0;
// Apply scissor/clipping rectangle
const scissor = VkRect2D{
.offset = VkOffset2D{
.x = @floatToInt(i32, clip_rect.x),
.y = @floatToInt(i32, clip_rect.y),
},
.extent = VkExtent2D{
.width = @floatToInt(u32, clip_rect.z - clip_rect.x),
.height = @floatToInt(u32, clip_rect.w - clip_rect.y),
},
};
vkCmdSetScissor(command_buffer, 0, 1, &scissor);
// Draw
vkCmdDrawIndexed(command_buffer, pcmd.ElemCount, 1, pcmd.IdxOffset + global_idx_offset, @intCast(i32, pcmd.VtxOffset + global_vtx_offset), 0);
}
}
global_idx_offset += @intCast(u32, cmd_list.IdxBuffer.len);
global_vtx_offset += @intCast(u32, cmd_list.VtxBuffer.len);
}
}
fn renderQuad(ctx: *Context, frd: *FrameRenderData.RenderData, displayTransfo: DisplayTransfo, quad: Quad, command_buffer: VkCommandBuffer) !void {
const primitives = [_]PrimitiveDrawData{
.{
.vertices = &[_]Imgui.DrawVert{
.{ .pos = quad.corners[0], .uv = Imgui.Vec2{ .x = 0, .y = 0 }, .col = 0xFFFFFFFF },
.{ .pos = quad.corners[1], .uv = Imgui.Vec2{ .x = 1, .y = 0 }, .col = 0xFFFFFFFF },
.{ .pos = quad.corners[2], .uv = Imgui.Vec2{ .x = 1, .y = 1 }, .col = 0xFFFFFFFF },
.{ .pos = quad.corners[3], .uv = Imgui.Vec2{ .x = 0, .y = 1 }, .col = 0xFFFFFFFF },
},
.indices = &[_]Imgui.DrawIdx{ 0, 1, 3, 1, 2, 3 },
},
};
// Setup desired Vulkan state
try setupRenderState(ctx, command_buffer, frd, &primitives, quad.texture.view, displayTransfo);
{
const scissor = VkRect2D{
.offset = VkOffset2D{
.x = 0,
.y = 0,
},
.extent = VkExtent2D{
.width = @intCast(u32, displayTransfo.fb_width),
.height = @intCast(u32, displayTransfo.fb_height),
},
};
vkCmdSetScissor(command_buffer, 0, 1, &scissor);
// Draw
const idx_count = @intCast(u32, primitives[0].indices.len);
const idx_offset: i32 = 0;
const vtx_offset: i32 = 0;
vkCmdDrawIndexed(command_buffer, idx_count, 1, idx_offset, vtx_offset, 0);
}
}
fn initTexture(ctx: *Context, texture: *Texture, width: u32, height: u32) !void {
var err: VkResult = undefined;
texture.extent = VkExtent3D{ .width = width, .height = height, .depth = 1 };
// Create the image:
{
const info = VkImageCreateInfo{
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
.pNext = null,
.flags = 0,
.imageType = VK_IMAGE_TYPE_2D,
.format = VK_FORMAT_R8G8B8A8_UNORM,
.extent = texture.extent,
.mipLevels = 1,
.arrayLayers = 1,
.samples = VK_SAMPLE_COUNT_1_BIT,
.tiling = VK_IMAGE_TILING_OPTIMAL,
.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.queueFamilyIndexCount = 0,
.pQueueFamilyIndices = null,
};
err = vkCreateImage(ctx.device, &info, ctx.vk_allocator, &texture.image);
try checkVkResult(err);
var req: VkMemoryRequirements = undefined;
vkGetImageMemoryRequirements(ctx.device, texture.image, &req);
const alloc_info = VkMemoryAllocateInfo{
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
.pNext = null,
.allocationSize = req.size,
.memoryTypeIndex = getMemoryType(ctx, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, req.memoryTypeBits),
};
err = vkAllocateMemory(ctx.device, &alloc_info, ctx.vk_allocator, &texture.memory);
try checkVkResult(err);
err = vkBindImageMemory(ctx.device, texture.image, texture.memory, 0);
try checkVkResult(err);
}
// Create the image view:
{
const info = VkImageViewCreateInfo{
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
.pNext = null,
.flags = 0,
.image = texture.image,
.viewType = VK_IMAGE_VIEW_TYPE_2D,
.format = VK_FORMAT_R8G8B8A8_UNORM,
.components = VkComponentMapping{ .r = VK_COMPONENT_SWIZZLE_R, .g = VK_COMPONENT_SWIZZLE_G, .b = VK_COMPONENT_SWIZZLE_B, .a = VK_COMPONENT_SWIZZLE_A },
.subresourceRange = VkImageSubresourceRange{
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
.levelCount = 1,
.layerCount = 1,
.baseMipLevel = 0,
.baseArrayLayer = 0,
},
};
err = vkCreateImageView(ctx.device, &info, ctx.vk_allocator, &texture.view);
try checkVkResult(err);
}
}
fn destroyTexture(device: VkDevice, texture: *Texture, vk_allocator: ?*const VkAllocationCallbacks) void {
if (texture.view != null) {
vkDestroyImageView(device, texture.view, vk_allocator);
texture.view = null;
}
if (texture.image != null) {
vkDestroyImage(device, texture.image, vk_allocator);
texture.image = null;
}
if (texture.memory != null) {
vkFreeMemory(device, texture.memory, vk_allocator);
texture.memory = null;
}
}
fn initTextureUpload(ctx: *Context, textureUpload: *TextureUpload, pixels: []const u8, texture: *const Texture) !void {
var err: VkResult = undefined;
// Create the Upload Buffer:
const offsetInMemory = 0;
{
const buffer_info = VkBufferCreateInfo{
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.pNext = null,
.flags = 0,
.size = pixels.len,
.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
.queueFamilyIndexCount = 0,
.pQueueFamilyIndices = null,
};
err = vkCreateBuffer(ctx.device, &buffer_info, ctx.vk_allocator, &textureUpload.buffer);
try checkVkResult(err);
var req: VkMemoryRequirements = undefined;
vkGetBufferMemoryRequirements(ctx.device, textureUpload.buffer, &req);
ctx.buffer_memory_alignment = if (ctx.buffer_memory_alignment > req.alignment) ctx.buffer_memory_alignment else req.alignment;
const alloc_info = VkMemoryAllocateInfo{
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
.pNext = null,
.allocationSize = req.size,
.memoryTypeIndex = getMemoryType(ctx, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits),
};
err = vkAllocateMemory(ctx.device, &alloc_info, ctx.vk_allocator, &textureUpload.memory);
try checkVkResult(err);
err = vkBindBufferMemory(ctx.device, textureUpload.buffer, textureUpload.memory, offsetInMemory);
try checkVkResult(err);
}
// Upload to Buffer:
{
var map: [*]u8 = undefined;
err = vkMapMemory(ctx.device, textureUpload.memory, offsetInMemory, alignSize(pixels.len, ctx.buffer_memory_alignment), 0, @ptrCast([*c]?*c_void, &map));
try checkVkResult(err);
@memcpy(map, pixels.ptr, pixels.len);
//std.mem.copy(u8, map[0..pixels.len], pixels); 2x slower in release-fast... (performance restored if using noalias + no change with aligned ptrs)
const ranges = [_]VkMappedMemoryRange{
VkMappedMemoryRange{
.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
.pNext = null,
.memory = textureUpload.memory,
.size = VK_WHOLE_SIZE,
.offset = offsetInMemory,
},
};
err = vkFlushMappedMemoryRanges(ctx.device, ranges.len, &ranges);
try checkVkResult(err);
vkUnmapMemory(ctx.device, textureUpload.memory);
}
textureUpload.texture = texture;
}
fn flushTextureUpload(_: *Context, command_buffer: VkCommandBuffer, textureUpload: *const TextureUpload) void {
// Copy to image:
{
const copy_barrier = [_]VkImageMemoryBarrier{
VkImageMemoryBarrier{
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
.pNext = null,
.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
.srcAccessMask = 0,
.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.image = textureUpload.texture.image,
.subresourceRange = VkImageSubresourceRange{ .layerCount = 1, .baseArrayLayer = 0, .levelCount = 1, .baseMipLevel = 0, .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT },
},
};
vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, null, 0, null, copy_barrier.len, ©_barrier);
const region = VkBufferImageCopy{
.imageSubresource = VkImageSubresourceLayers{ .mipLevel = 0, .layerCount = 1, .baseArrayLayer = 0, .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT },
.imageExtent = textureUpload.texture.extent,
.imageOffset = VkOffset3D{ .x = 0, .y = 0, .z = 0 },
.bufferOffset = 0,
.bufferRowLength = 0,
.bufferImageHeight = 0,
};
vkCmdCopyBufferToImage(command_buffer, textureUpload.buffer, textureUpload.texture.image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion);
const use_barrier = [_]VkImageMemoryBarrier{VkImageMemoryBarrier{
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
.pNext = null,
.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
.dstAccessMask = VK_ACCESS_SHADER_READ_BIT,
.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
.newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.image = textureUpload.texture.image,
.subresourceRange = VkImageSubresourceRange{
.levelCount = 1,
.baseMipLevel = 0,
.layerCount = 1,
.baseArrayLayer = 0,
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
},
}};
vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, 0, null, 0, null, use_barrier.len, &use_barrier);
}
}
fn destroyTextureUpload(device: VkDevice, textureUpload: *TextureUpload, vk_allocator: ?*const VkAllocationCallbacks) void {
if (textureUpload.buffer != null) {
vkDestroyBuffer(device, textureUpload.buffer, vk_allocator);
textureUpload.buffer = null;
}
if (textureUpload.memory != null) {
vkFreeMemory(device, textureUpload.memory, vk_allocator);
textureUpload.memory = null;
}
}
//-------------------------------------------------------------------------
fn createDeviceObjects(ctx: *Context) !void {
var err: VkResult = undefined;
var vert_module: VkShaderModule = undefined;
var frag_module: VkShaderModule = undefined;
// Create The Shader Modules:
{
const vert_info = VkShaderModuleCreateInfo{
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
.pNext = null,
.flags = 0,
.codeSize = __glsl_shader_vert_spv.len * 4,
.pCode = &__glsl_shader_vert_spv,
};
err = vkCreateShaderModule(ctx.device, &vert_info, ctx.vk_allocator, &vert_module);
try checkVkResult(err);
const frag_info = VkShaderModuleCreateInfo{
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
.pNext = null,
.flags = 0,
.codeSize = __glsl_shader_frag_spv.len * 4,
.pCode = &__glsl_shader_frag_spv,
};
err = vkCreateShaderModule(ctx.device, &frag_info, ctx.vk_allocator, &frag_module);
try checkVkResult(err);
}
// Create the image sampler:
{
const info = VkSamplerCreateInfo{
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
.pNext = null,
.flags = 0,
.magFilter = VK_FILTER_LINEAR,
.minFilter = VK_FILTER_LINEAR,
.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR,
.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT,
.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT,
.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT,
.minLod = -1000,
.maxLod = 1000,
.mipLodBias = 0,
.maxAnisotropy = 1.0,
.anisotropyEnable = 0,
.compareEnable = 0,
.compareOp = VK_COMPARE_OP_NEVER,
.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK,
.unnormalizedCoordinates = 0,
};
err = vkCreateSampler(ctx.device, &info, ctx.vk_allocator, &ctx.tiling_sampler);
try checkVkResult(err);
}
{
const sampler = [_]VkSampler{ctx.tiling_sampler};
const binding = [_]VkDescriptorSetLayoutBinding{
VkDescriptorSetLayoutBinding{
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
.descriptorCount = 1,
.binding = 0,
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT,
.pImmutableSamplers = &sampler,
},
};
const info = VkDescriptorSetLayoutCreateInfo{
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
.pNext = null,
.flags = 0,
.bindingCount = binding.len,
.pBindings = &binding,
};
err = vkCreateDescriptorSetLayout(ctx.device, &info, ctx.vk_allocator, &ctx.descriptor_set_layout);
try checkVkResult(err);
}
if (ctx.pipeline_layout == null) {
// Constants: we are using 'vec2 offset' and 'vec2 scale' instead of a full 3d projection matrix
const push_constants = [_]VkPushConstantRange{
VkPushConstantRange{
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT,
.offset = @sizeOf(f32) * 0,
.size = @sizeOf(f32) * 4,
},
};
const set_layout = [_]VkDescriptorSetLayout{ctx.descriptor_set_layout};
const layout_info = VkPipelineLayoutCreateInfo{
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
.pNext = null,
.flags = 0,
.setLayoutCount = set_layout.len,
.pSetLayouts = &set_layout,
.pushConstantRangeCount = push_constants.len,
.pPushConstantRanges = &push_constants,
};
err = vkCreatePipelineLayout(ctx.device, &layout_info, ctx.vk_allocator, &ctx.pipeline_layout);
try checkVkResult(err);
}
const stages = [_]VkPipelineShaderStageCreateInfo{
VkPipelineShaderStageCreateInfo{
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
.pNext = null,
.flags = 0,
.stage = VK_SHADER_STAGE_VERTEX_BIT,
.module = vert_module,
.pName = "main",
.pSpecializationInfo = null,
},
VkPipelineShaderStageCreateInfo{
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
.pNext = null,
.flags = 0,
.stage = VK_SHADER_STAGE_FRAGMENT_BIT,
.module = frag_module,
.pName = "main",
.pSpecializationInfo = null,
},
};
const binding_desc = [_]VkVertexInputBindingDescription{
VkVertexInputBindingDescription{ .binding = 0, .stride = @sizeOf(Imgui.DrawVert), .inputRate = VK_VERTEX_INPUT_RATE_VERTEX },
};
const attribute_desc = [_]VkVertexInputAttributeDescription{
VkVertexInputAttributeDescription{ .location = 0, .binding = binding_desc[0].binding, .format = VK_FORMAT_R32G32_SFLOAT, .offset = @offsetOf(Imgui.DrawVert, "pos") },
VkVertexInputAttributeDescription{ .location = 1, .binding = binding_desc[0].binding, .format = VK_FORMAT_R32G32_SFLOAT, .offset = @offsetOf(Imgui.DrawVert, "uv") },
VkVertexInputAttributeDescription{ .location = 2, .binding = binding_desc[0].binding, .format = VK_FORMAT_R8G8B8A8_UNORM, .offset = @offsetOf(Imgui.DrawVert, "col") },
};
const vertex_info = VkPipelineVertexInputStateCreateInfo{
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
.pNext = null,
.flags = 0,
.vertexBindingDescriptionCount = binding_desc.len,
.pVertexBindingDescriptions = &binding_desc,
.vertexAttributeDescriptionCount = attribute_desc.len,
.pVertexAttributeDescriptions = &attribute_desc,
};
const ia_info = VkPipelineInputAssemblyStateCreateInfo{
.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
.pNext = null,
.flags = 0,
.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
.primitiveRestartEnable = 0,
};
const viewport_info = VkPipelineViewportStateCreateInfo{
.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
.pNext = null,
.flags = 0,
.viewportCount = 1,
.scissorCount = 1,
.pViewports = null,
.pScissors = null,
};
const raster_info = VkPipelineRasterizationStateCreateInfo{
.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
.pNext = null,
.flags = 0,
.polygonMode = VK_POLYGON_MODE_FILL,
.cullMode = VK_CULL_MODE_NONE,
.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE,
.lineWidth = 1.0,
.rasterizerDiscardEnable = 0,
.depthBiasEnable = 0,
.depthBiasConstantFactor = 0,
.depthBiasClamp = 0,
.depthBiasSlopeFactor = 0,
.depthClampEnable = 0,
};
const ms_info = VkPipelineMultisampleStateCreateInfo{
.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
.pNext = null,
.flags = 0,
.rasterizationSamples = if (ctx.MSAA_samples != 0) ctx.MSAA_samples else VK_SAMPLE_COUNT_1_BIT,
.sampleShadingEnable = 0,
.minSampleShading = 0,
.pSampleMask = 0,
.alphaToCoverageEnable = 0,
.alphaToOneEnable = 0,
};
const color_attachment = [_]VkPipelineColorBlendAttachmentState{
VkPipelineColorBlendAttachmentState{
.blendEnable = VK_TRUE,
.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA,
.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
.colorBlendOp = VK_BLEND_OP_ADD,
.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO,
.alphaBlendOp = VK_BLEND_OP_ADD,
.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT,
},
};
const depth_info = VkPipelineDepthStencilStateCreateInfo{
.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
.pNext = null,
.flags = 0,
.depthTestEnable = 0,
.depthWriteEnable = 0,
.depthCompareOp = VK_COMPARE_OP_NEVER,
.depthBoundsTestEnable = 0,
.stencilTestEnable = 0,
.front = VkStencilOpState{
.failOp = VK_STENCIL_OP_KEEP,
.passOp = VK_STENCIL_OP_KEEP,
.depthFailOp = VK_STENCIL_OP_KEEP,
.compareOp = VK_COMPARE_OP_NEVER,
.compareMask = 0,
.writeMask = 0,
.reference = 0,
},
.back = VkStencilOpState{
.failOp = VK_STENCIL_OP_KEEP,
.passOp = VK_STENCIL_OP_KEEP,
.depthFailOp = VK_STENCIL_OP_KEEP,
.compareOp = VK_COMPARE_OP_NEVER,
.compareMask = 0,
.writeMask = 0,
.reference = 0,
},
.minDepthBounds = 0,
.maxDepthBounds = 0,
};
const blend_info = VkPipelineColorBlendStateCreateInfo{
.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
.pNext = null,
.flags = 0,
.attachmentCount = color_attachment.len,
.pAttachments = &color_attachment,
.logicOpEnable = 0,
.logicOp = VK_LOGIC_OP_CLEAR,
.blendConstants = [_]f32{ 0, 0, 0, 0 },
};
const dynamic_states = [_]VkDynamicState{ VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
const dynamic_state = VkPipelineDynamicStateCreateInfo{
.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
.pNext = null,
.flags = 0,
.dynamicStateCount = dynamic_states.len,
.pDynamicStates = &dynamic_states,
};
const info = VkGraphicsPipelineCreateInfo{
.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
.pNext = null,
.flags = ctx.pipeline_create_flags,
.stageCount = stages.len,
.pStages = &stages,
.pVertexInputState = &vertex_info,
.pInputAssemblyState = &ia_info,
.pViewportState = &viewport_info,
.pRasterizationState = &raster_info,
.pMultisampleState = &ms_info,
.pDepthStencilState = &depth_info,
.pColorBlendState = &blend_info,
.pDynamicState = &dynamic_state,
.layout = ctx.pipeline_layout,
.renderPass = ctx.main_window_data.render_pass,
.pTessellationState = null,
.subpass = 0,
.basePipelineHandle = null,
.basePipelineIndex = 0,
};
err = vkCreateGraphicsPipelines(ctx.device, ctx.pipeline_cache, 1, &info, ctx.vk_allocator, &ctx.pipeline);
try checkVkResult(err);
vkDestroyShaderModule(ctx.device, vert_module, ctx.vk_allocator);
vkDestroyShaderModule(ctx.device, frag_module, ctx.vk_allocator);
}
fn destroyDeviceObjects(ctx: *Context) void {
for (ctx.frame_texture_uploads.items) |*texupload| {
destroyTextureUpload(ctx.device, texupload, ctx.vk_allocator);
}
ctx.frame_texture_uploads.resize(0) catch unreachable;
ctx.frame_draw_quads.resize(0) catch unreachable;
destroyTexture(ctx.device, &ctx.font_texture, ctx.vk_allocator);
if (ctx.descriptor_set_layout != null) {
vkDestroyDescriptorSetLayout(ctx.device, ctx.descriptor_set_layout, ctx.vk_allocator);
ctx.descriptor_set_layout = null;
}
if (ctx.tiling_sampler != null) {
vkDestroySampler(ctx.device, ctx.tiling_sampler, ctx.vk_allocator);
ctx.tiling_sampler = null;
}
if (ctx.pipeline_layout != null) {
vkDestroyPipelineLayout(ctx.device, ctx.pipeline_layout, ctx.vk_allocator);
ctx.pipeline_layout = null;
}
if (ctx.pipeline != null) {
vkDestroyPipeline(ctx.device, ctx.pipeline, ctx.vk_allocator);
ctx.pipeline = null;
}
}
//-------------------------------------------------------------------------
export fn ImGui_ImplVulkan_Init(ctx: *Context) bool {
return imguiImplVulkanInit(ctx) catch return false;
}
fn imguiImplVulkanInit(ctx: *Context) !bool {
// Setup back-end capabilities flags
const io = Imgui.GetIO();
io.BackendRendererName = "imgui_impl_vulkan";
io.BackendFlags.RendererHasVtxOffset = true; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
assert(ctx.instance != null);
assert(ctx.physical_device != null);
assert(ctx.device != null);
assert(ctx.queue != null);
assert(ctx.descriptor_pool != null);
assert(ctx.min_image_count >= 2);
assert(ctx.main_window_data.frames.len >= ctx.min_image_count);
assert(ctx.main_window_data.render_pass != null);
try createDeviceObjects(ctx);
// Upload Fonts
{
var pixels: [*c]u8 = undefined;
var width: c_int = undefined;
var height: c_int = undefined;
var bpp: c_int = undefined;
Imgui.FontAtlas.GetTexDataAsRGBA32Ext(io.Fonts.?, &pixels, &width, &height, &bpp);
assert(bpp == 4);
const upload_size: usize = @intCast(usize, width * height * bpp) * @sizeOf(u8);
try initTexture(ctx, &ctx.font_texture, @intCast(u32, width), @intCast(u32, height));
Imgui.FontAtlas.SetTexID(io.Fonts.?, @ptrCast(Imgui.TextureID, ctx.font_texture.image));
const texupload = try ctx.frame_texture_uploads.addOne();
try initTextureUpload(ctx, texupload, pixels[0..upload_size], &ctx.font_texture);
}
return true;
}
export fn ImGui_ImplVulkan_Shutdown(ctx: *Context) void {
imguiImplVulkanShutdown(ctx) catch unreachable;
}
fn imguiImplVulkanShutdown(ctx: *Context) !void {
var err: VkResult = undefined;
err = vkDeviceWaitIdle(ctx.device);
try checkVkResult(err);
destroyDeviceObjects(ctx);
}
pub fn blitPixels(ctx: *Context, corners: [4]Vec2, pixels: []const u8, width: u32, height: u32) !void {
const t = try ctx.allocator.create(Texture);
try initTexture(ctx, t, width, height);
const texupload = try ctx.frame_texture_uploads.addOne();
try initTextureUpload(ctx, texupload, pixels, t);
const q = try ctx.frame_draw_quads.addOne();
q.corners = corners;
q.texture = t;
}
//-------------------------------------------------------------------------
fn selectSurfaceFormat(physical_device: VkPhysicalDevice, surface: VkSurfaceKHR, request_formats: []const VkFormat, request_color_space: VkColorSpaceKHR) VkSurfaceFormatKHR {
assert(request_formats.len != 0);
var err: VkResult = undefined;
// Per Spec Format and view Format are expected to be the same unless VK_IMAGE_CREATE_MUTABLE_BIT was set at image creation
// Assuming that the default behavior is without setting this bit, there is no need for separate swapchain image and image view format
// Additionally several new color spaces were introduced with Vulkan Spec v1.0.40,
// hence we must make sure that a format with the mostly available color space, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR, is found and used.
var storage: [100]VkSurfaceFormatKHR = undefined;
var avail_count: u32 = undefined;
err = vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device, surface, &avail_count, null);
const avail_format = storage[0..avail_count];
err = vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device, surface, &avail_count, avail_format.ptr);
// First check if only one format, VK_FORMAT_UNDEFINED, is available, which would imply that any format is available
if (avail_count == 1) {
if (avail_format[0].format == VK_FORMAT_UNDEFINED) {
const ret = VkSurfaceFormatKHR{
.format = request_formats[0],
.colorSpace = request_color_space,
};
return ret;
} else {
// No point in searching another format
return avail_format[0];
}
} else {
// Request several formats, the first found will be used
for (request_formats) |req| {
for (avail_format) |avail| {
if (avail.format == req and avail.colorSpace == request_color_space)
return avail;
}
}
// If none of the requested image formats could be found, use the first available
return avail_format[0];
}
}
fn selectPresentMode(physical_device: VkPhysicalDevice, surface: VkSurfaceKHR, request_modes: []const VkPresentModeKHR) VkPresentModeKHR {
assert(request_modes.len != 0);
var err: VkResult = undefined;
// Request a certain mode and confirm that it is available. If not use VK_PRESENT_MODE_FIFO_KHR which is mandatory
var avail_count: u32 = 0;
var storage: [100]VkPresentModeKHR = undefined;
err = vkGetPhysicalDeviceSurfacePresentModesKHR(physical_device, surface, &avail_count, null);
assert(avail_count < 100);
const avail_modes = storage[0..avail_count];
err = vkGetPhysicalDeviceSurfacePresentModesKHR(physical_device, surface, &avail_count, avail_modes.ptr);
for (request_modes) |req| {
for (avail_modes) |avail| {
if (req == avail)
return req;
}
}
return VK_PRESENT_MODE_FIFO_KHR; // Always available
}
fn createWindowCommandBuffers(physical_device: VkPhysicalDevice, device: VkDevice, wd: *VulkanWindow, queue_family: u32, vk_allocator: ?*const VkAllocationCallbacks) !void {
assert(physical_device != null and device != null);
var err: VkResult = undefined;
// Create Command Buffers
for (wd.frames) |*fd| {
{
const info = VkCommandPoolCreateInfo{
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
.pNext = null,
.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
.queueFamilyIndex = queue_family,
};
err = vkCreateCommandPool(device, &info, vk_allocator, &fd.command_pool);
try checkVkResult(err);
}
{
const info = VkCommandBufferAllocateInfo{
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
.pNext = null,
.commandPool = fd.command_pool,
.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
.commandBufferCount = 1,
};
err = vkAllocateCommandBuffers(device, &info, &fd.command_buffer);
try checkVkResult(err);
}
{
const info = VkFenceCreateInfo{
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
.pNext = null,
.flags = VK_FENCE_CREATE_SIGNALED_BIT,
};
err = vkCreateFence(device, &info, vk_allocator, &fd.fence);
try checkVkResult(err);
}
}
for (wd.frame_semaphores) |*fsd| {
{
const info = VkSemaphoreCreateInfo{
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
.pNext = null,
.flags = 0,
};
err = vkCreateSemaphore(device, &info, vk_allocator, &fsd.image_acquired_semaphore);
try checkVkResult(err);
err = vkCreateSemaphore(device, &info, vk_allocator, &fsd.render_complete_semaphore);
try checkVkResult(err);
}
}
}
// Also destroy old swap chain and in-flight frames data, if any.
fn createWindowSwapChain(physical_device: VkPhysicalDevice, device: VkDevice, wd: *VulkanWindow, descriptor_pool: VkDescriptorPool, allocator: *Allocator, vk_allocator: ?*const VkAllocationCallbacks, w: u32, h: u32, min_image_count: u32) !void {
var err: VkResult = undefined;
const old_swapchain = wd.swapchain;
wd.swapchain = null;
err = vkDeviceWaitIdle(device);
try checkVkResult(err);
// We don't use destroyWindow() because we want to preserve the old swapchain to create the new one.
// Destroy old framebuffer
for (wd.frame_semaphores) |*frameSemaphore| {
destroySwapchainSemaphores(device, frameSemaphore, vk_allocator);
}
for (wd.frames) |*frame| {
destroyFrame(device, frame, vk_allocator);
}
for (wd.frame_render_data) |*frd| {
destroyFrameRenderData(device, frd, descriptor_pool, vk_allocator);
}
allocator.free(wd.frame_render_data);
allocator.free(wd.frames);
allocator.free(wd.frame_semaphores);
wd.frames = &[0]SwapchainFrame{};
wd.frame_semaphores = &[0]SwapchainSemaphores{};
wd.frame_render_data = &[0]FrameRenderData{};
if (wd.render_pass != null)
vkDestroyRenderPass(device, wd.render_pass, vk_allocator);
// If min image count was not specified, request different count of images dependent on selected present mode
var image_count = min_image_count;
if (image_count == 0) {
image_count = mincount: {
if (wd.present_mode == VK_PRESENT_MODE_MAILBOX_KHR) break :mincount 3;
if (wd.present_mode == VK_PRESENT_MODE_FIFO_KHR or wd.present_mode == VK_PRESENT_MODE_FIFO_RELAXED_KHR) break :mincount 2;
if (wd.present_mode == VK_PRESENT_MODE_IMMEDIATE_KHR) break :mincount 1;
unreachable;
};
}
// Create swapchain
var swapchainImageCount: u32 = undefined;
var backbuffers = [_]VkImage{null} ** 16;
{
var cap: VkSurfaceCapabilitiesKHR = undefined;
err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_device, wd.surface, &cap);
try checkVkResult(err);
wd.width = if (cap.currentExtent.width == 0xffffffff) w else cap.currentExtent.width;
wd.height = if (cap.currentExtent.height == 0xffffffff) h else cap.currentExtent.height;
const info = VkSwapchainCreateInfoKHR{
.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
.pNext = null,
.flags = 0,
.queueFamilyIndexCount = 0,
.pQueueFamilyIndices = null,
.surface = wd.surface,
.minImageCount = if (image_count < cap.minImageCount) cap.minImageCount else if (cap.maxImageCount != 0 and image_count > cap.maxImageCount) cap.maxImageCount else image_count,
.imageFormat = wd.surface_format.format,
.imageColorSpace = wd.surface_format.colorSpace,
.imageArrayLayers = 1,
.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE, // Assume that graphics family == present famil,
.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR,
.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR,
.presentMode = wd.present_mode,
.clipped = VK_TRUE,
.oldSwapchain = old_swapchain,
.imageExtent = VkExtent2D{ .width = wd.width, .height = wd.height },
};
err = vkCreateSwapchainKHR(device, &info, vk_allocator, &wd.swapchain);
try checkVkResult(err);
err = vkGetSwapchainImagesKHR(device, wd.swapchain, &swapchainImageCount, null);
try checkVkResult(err);
assert(swapchainImageCount >= image_count);
assert(swapchainImageCount < backbuffers.len);
err = vkGetSwapchainImagesKHR(device, wd.swapchain, &swapchainImageCount, &backbuffers);
try checkVkResult(err);
}
{
assert(wd.frames.len == 0 and wd.frame_semaphores.len == 0 and wd.frame_render_data.len == 0);
wd.frames = try allocator.alloc(SwapchainFrame, swapchainImageCount);
wd.frame_semaphores = try allocator.alloc(SwapchainSemaphores, swapchainImageCount);
std.mem.set(SwapchainSemaphores, wd.frame_semaphores, SwapchainSemaphores{});
for (wd.frames) |*frame, i| {
frame.* = SwapchainFrame{ .backbuffer = backbuffers[i] };
}
wd.render_data_index = 0;
wd.frame_render_data = try allocator.alloc(FrameRenderData, swapchainImageCount);
for (wd.frame_render_data) |*frd| {
frd.* = FrameRenderData{
.active_transcient_texture = ArrayList(*Texture).init(allocator),
.active_texture_uploads = ArrayList(TextureUpload).init(allocator),
.data = ArrayList(FrameRenderData.RenderData).init(allocator),
};
}
}
if (old_swapchain != null)
vkDestroySwapchainKHR(device, old_swapchain, vk_allocator);
// Create the Render Pass
{
const attachment = VkAttachmentDescription{
.format = wd.surface_format.format,
.flags = 0,
.samples = VK_SAMPLE_COUNT_1_BIT,
.loadOp = if (wd.clear_enable) VK_ATTACHMENT_LOAD_OP_CLEAR else VK_ATTACHMENT_LOAD_OP_DONT_CARE,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE,
.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE,
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
};
const color_attachment = VkAttachmentReference{
.attachment = 0,
.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
};
const subpass = VkSubpassDescription{
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
.colorAttachmentCount = 1,
.pColorAttachments = &color_attachment,
.flags = 0,
.inputAttachmentCount = 0,
.pInputAttachments = null,
.pResolveAttachments = null,
.pDepthStencilAttachment = null,
.preserveAttachmentCount = 0,
.pPreserveAttachments = null,
};
const dependency = VkSubpassDependency{
.srcSubpass = VK_SUBPASS_EXTERNAL,
.dstSubpass = 0,
.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
.srcAccessMask = 0,
.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
.dependencyFlags = 0,
};
const info = VkRenderPassCreateInfo{
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
.pNext = null,
.flags = 0,
.attachmentCount = 1,
.pAttachments = &attachment,
.subpassCount = 1,
.pSubpasses = &subpass,
.dependencyCount = 1,
.pDependencies = &dependency,
};
err = vkCreateRenderPass(device, &info, vk_allocator, &wd.render_pass);
try checkVkResult(err);
}
// Create The image Views
{
var info = VkImageViewCreateInfo{
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
.pNext = null,
.flags = 0,
.viewType = VK_IMAGE_VIEW_TYPE_2D,
.format = wd.surface_format.format,
.components = VkComponentMapping{ .r = VK_COMPONENT_SWIZZLE_R, .g = VK_COMPONENT_SWIZZLE_G, .b = VK_COMPONENT_SWIZZLE_B, .a = VK_COMPONENT_SWIZZLE_A },
.subresourceRange = VkImageSubresourceRange{ .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, .baseMipLevel = 0, .levelCount = 1, .baseArrayLayer = 0, .layerCount = 1 },
.image = undefined,
};
for (wd.frames) |*fd| {
info.image = fd.backbuffer;
err = vkCreateImageView(device, &info, vk_allocator, &fd.backbuffer_view);
try checkVkResult(err);
}
}
// Create framebuffer
{
var attachment: [1]VkImageView = undefined;
const info = VkFramebufferCreateInfo{
.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
.pNext = null,
.flags = 0,
.renderPass = wd.render_pass,
.attachmentCount = attachment.len,
.pAttachments = &attachment,
.width = wd.width,
.height = wd.height,
.layers = 1,
};
for (wd.frames) |*fd| {
attachment[0] = fd.backbuffer_view;
err = vkCreateFramebuffer(device, &info, vk_allocator, &fd.framebuffer);
try checkVkResult(err);
}
}
}
fn createWindow(_: VkInstance, physical_device: VkPhysicalDevice, device: VkDevice, wd: *VulkanWindow, queue_family: u32, descriptor_pool: VkDescriptorPool, allocator: *Allocator, vk_allocator: ?*const VkAllocationCallbacks, width: u32, height: u32, min_image_count: u32) !void {
try createWindowSwapChain(physical_device, device, wd, descriptor_pool, allocator, vk_allocator, width, height, min_image_count);
try createWindowCommandBuffers(physical_device, device, wd, queue_family, vk_allocator);
}
fn destroyWindow(instance: VkInstance, device: VkDevice, wd: *VulkanWindow, descriptor_pool: VkDescriptorPool, allocator: *Allocator, vk_allocator: ?*const VkAllocationCallbacks) void {
var err: VkResult = undefined;
err = vkDeviceWaitIdle(device); // FIXME: We could wait on the queue if we had the queue in wd. (otherwise VulkanH functions can't use globals)
//vkQueueWaitIdle(g_Queue);
for (wd.frame_render_data) |*frd| {
destroyFrameRenderData(device, frd, descriptor_pool, vk_allocator);
}
for (wd.frame_semaphores) |*frameSemaphore| {
destroySwapchainSemaphores(device, frameSemaphore, vk_allocator);
}
for (wd.frames) |*frame| {
destroyFrame(device, frame, vk_allocator);
}
allocator.free(wd.frame_render_data);
allocator.free(wd.frames);
allocator.free(wd.frame_semaphores);
wd.frames = &[0]SwapchainFrame{};
wd.frame_semaphores = &[0]SwapchainSemaphores{};
wd.frame_render_data = &[0]FrameRenderData{};
vkDestroyRenderPass(device, wd.render_pass, vk_allocator);
vkDestroySwapchainKHR(device, wd.swapchain, vk_allocator);
vkDestroySurfaceKHR(instance, wd.surface, vk_allocator);
}
fn destroyFrame(device: VkDevice, fd: *SwapchainFrame, vk_allocator: ?*const VkAllocationCallbacks) void {
vkDestroyFence(device, fd.fence, vk_allocator);
vkFreeCommandBuffers(device, fd.command_pool, 1, &fd.command_buffer);
vkDestroyCommandPool(device, fd.command_pool, vk_allocator);
fd.fence = null;
fd.command_buffer = null;
fd.command_pool = null;
vkDestroyImageView(device, fd.backbuffer_view, vk_allocator);
vkDestroyFramebuffer(device, fd.framebuffer, vk_allocator);
}
fn destroySwapchainSemaphores(device: VkDevice, fsd: *SwapchainSemaphores, vk_allocator: ?*const VkAllocationCallbacks) void {
vkDestroySemaphore(device, fsd.image_acquired_semaphore, vk_allocator);
vkDestroySemaphore(device, fsd.render_complete_semaphore, vk_allocator);
fsd.image_acquired_semaphore = null;
fsd.render_complete_semaphore = null;
}
fn destroyFrameRenderData(device: VkDevice, frd: *FrameRenderData, descriptor_pool: VkDescriptorPool, vk_allocator: ?*const VkAllocationCallbacks) void {
for (frd.data.items) |*data| {
if (data.descriptor_set != null) {
_ = vkFreeDescriptorSets(device, descriptor_pool, 1, &data.descriptor_set);
data.descriptor_set = null;
}
if (data.vertex != null) {
vkDestroyBuffer(device, data.vertex, vk_allocator);
data.vertex = null;
}
if (data.vertex_memory != null) {
vkFreeMemory(device, data.vertex_memory, vk_allocator);
data.vertex_memory = null;
}
if (data.index != null) {
vkDestroyBuffer(device, data.index, vk_allocator);
data.index = null;
}
if (data.index_memory != null) {
vkFreeMemory(device, data.index_memory, vk_allocator);
data.index_memory = null;
}
data.vertex_size = 0;
data.index_size = 0;
}
frd.data.deinit();
for (frd.active_texture_uploads.items) |*texupload| {
destroyTextureUpload(device, texupload, vk_allocator);
}
frd.active_texture_uploads.deinit();
for (frd.active_transcient_texture.items) |tex| {
destroyTexture(device, tex, vk_allocator);
}
frd.active_transcient_texture.deinit();
}
//---------------------------------
extern fn imguiImpl_Init(title: [*:0]const u8, width: c_int, height: c_int, ctx: *Context) bool;
extern fn imguiImpl_Destroy(ctx: *Context) void;
extern fn imguiImpl_GetWindowSize(ctx: *Context, width: *u32, height: *u32) void;
extern fn imguiImpl_NewFrameSDL(ctx: *Context) void;
pub fn init(title: [*:0]const u8, width: c_int, height: c_int, allocator: *Allocator) !*Context {
const ctx = try allocator.create(Context);
errdefer allocator.destroy(ctx);
ctx.* = Context{
.allocator = allocator,
.frame_texture_uploads = ArrayList(TextureUpload).init(allocator),
.frame_draw_quads = ArrayList(Quad).init(allocator),
};
const ok = imguiImpl_Init(title, width, height, ctx);
if (!ok)
return error.SDLInitializationFailed;
return ctx;
}
pub fn destroy(ctx: *Context) void {
imguiImpl_Destroy(ctx);
ctx.frame_texture_uploads.deinit();
ctx.frame_draw_quads.deinit();
ctx.allocator.destroy(ctx);
}
pub const getWindowSize = imguiImpl_GetWindowSize;
pub fn beginFrame(ctx: *Context) void {
imguiImpl_NewFrameSDL(ctx);
Imgui.NewFrame();
}
fn frameRender(ctx: *Context, wd: *VulkanWindow, draw_data: *const Imgui.DrawData) !void {
const u64max = std.math.maxInt(u64);
const image_acquired_semaphore = wd.frame_semaphores[wd.semaphore_index].image_acquired_semaphore;
const render_complete_semaphore = wd.frame_semaphores[wd.semaphore_index].render_complete_semaphore;
var err = vkAcquireNextImageKHR(ctx.device, wd.swapchain, u64max, image_acquired_semaphore, null, &wd.frame_index);
if (err == VK_ERROR_OUT_OF_DATE_KHR or err == VK_SUBOPTIMAL_KHR) {
return error.SwapchainOutOfDate;
}
try checkVkResult(err);
const fd = &wd.frames[wd.frame_index];
{
err = vkWaitForFences(ctx.device, 1, &fd.fence, VK_TRUE, u64max); // wait indefinitely instead of periodically checking
try checkVkResult(err);
err = vkResetFences(ctx.device, 1, &fd.fence);
try checkVkResult(err);
}
{
err = vkResetCommandPool(ctx.device, fd.command_pool, 0);
try checkVkResult(err);
const info = VkCommandBufferBeginInfo{
.pNext = null,
.pInheritanceInfo = null,
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
};
err = vkBeginCommandBuffer(fd.command_buffer, &info);
try checkVkResult(err);
}
wd.render_data_index = @intCast(u32, (wd.render_data_index + 1) % wd.frame_render_data.len);
const frd = &wd.frame_render_data[wd.render_data_index];
// clean previous texture uploads form the previousb use of frd + flush new ones
{
for (frd.active_texture_uploads.items) |*texupload| {
destroyTextureUpload(ctx.device, texupload, ctx.vk_allocator);
}
frd.active_texture_uploads.resize(0) catch unreachable;
for (frd.active_transcient_texture.items) |t| {
destroyTexture(ctx.device, t, ctx.vk_allocator);
ctx.allocator.destroy(t);
}
frd.active_transcient_texture.resize(0) catch unreachable;
for (ctx.frame_texture_uploads.items) |*texupload| {
flushTextureUpload(ctx, fd.command_buffer, texupload);
try frd.active_texture_uploads.append(texupload.*);
}
ctx.frame_texture_uploads.resize(0) catch unreachable;
}
{
const info = VkRenderPassBeginInfo{
.pNext = null,
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
.renderPass = wd.render_pass,
.framebuffer = fd.framebuffer,
.renderArea = VkRect2D{ .offset = VkOffset2D{ .x = 0, .y = 0 }, .extent = VkExtent2D{ .width = wd.width, .height = wd.height } },
.clearValueCount = 1,
.pClearValues = &wd.clear_value,
};
vkCmdBeginRenderPass(fd.command_buffer, &info, VK_SUBPASS_CONTENTS_INLINE);
}
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
if (wd.width > 0 and wd.height > 0 and draw_data.TotalVtxCount > 0) {
// Our visible imgui space lies from draw_data.DisplayPps (top left) to draw_data.DisplayPos+data_data.DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
const scale = [2]f32{
2.0 / draw_data.DisplaySize.x,
2.0 / draw_data.DisplaySize.y,
};
const displayTransfo = DisplayTransfo{
.scale = scale,
.translate = [2]f32{
-1.0 - draw_data.DisplayPos.x * scale[0],
-1.0 - draw_data.DisplayPos.y * scale[1],
},
.fb_width = wd.width,
.fb_height = wd.height,
};
// make room for render data:
const len_for_frame = 1 + ctx.frame_draw_quads.items.len;
if (len_for_frame > frd.data.items.len) {
const cur_len = frd.data.items.len;
try frd.data.appendNTimes(.{}, (len_for_frame - cur_len));
}
for (ctx.frame_draw_quads.items) |quad, i| {
try renderQuad(ctx, &frd.data.items[1 + i], displayTransfo, quad, fd.command_buffer);
}
try renderDrawData(ctx, &frd.data.items[0], displayTransfo, draw_data, fd.command_buffer);
}
vkCmdEndRenderPass(fd.command_buffer);
{
for (ctx.frame_draw_quads.items) |*quad| {
try frd.active_transcient_texture.append(quad.texture);
}
ctx.frame_draw_quads.resize(0) catch unreachable;
}
{
err = vkEndCommandBuffer(fd.command_buffer);
try checkVkResult(err);
const wait_stage = [_]u32{VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT};
const info = VkSubmitInfo{
.pNext = null,
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
.waitSemaphoreCount = 1,
.pWaitSemaphores = &image_acquired_semaphore,
.pWaitDstStageMask = &wait_stage,
.commandBufferCount = 1,
.pCommandBuffers = &fd.command_buffer,
.signalSemaphoreCount = 1,
.pSignalSemaphores = &render_complete_semaphore,
};
err = vkQueueSubmit(ctx.queue, 1, &info, fd.fence);
try checkVkResult(err);
}
}
fn framePresent(queue: VkQueue, wd: *VulkanWindow) !void {
var render_complete_semaphore = wd.frame_semaphores[wd.semaphore_index].render_complete_semaphore;
const info = VkPresentInfoKHR{
.pNext = null,
.pResults = null,
.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
.waitSemaphoreCount = 1,
.pWaitSemaphores = &render_complete_semaphore,
.swapchainCount = 1,
.pSwapchains = &wd.swapchain,
.pImageIndices = &wd.frame_index,
};
var err = vkQueuePresentKHR(queue, &info);
if (err == VK_ERROR_OUT_OF_DATE_KHR or err == VK_SUBOPTIMAL_KHR)
return error.SwapchainOutOfDate;
try checkVkResult(err);
wd.semaphore_index = (wd.semaphore_index + 1) % @intCast(u32, wd.frame_semaphores.len); // Now we can use the next set of semaphores
}
fn frameRebuildSwapchain(ctx: *Context) !void {
var w: u32 = undefined;
var h: u32 = undefined;
getWindowSize(ctx, &w, &h);
assert(w > 0 and h > 0); // assert == draw_data.DisplaySize
try createWindow(ctx.instance, ctx.physical_device, ctx.device, &ctx.main_window_data, ctx.queue_family, ctx.descriptor_pool, ctx.allocator, ctx.vk_allocator, w, h, ctx.min_image_count);
ctx.main_window_data.frame_index = 0;
}
pub fn endFrame(ctx: *Context) !void {
Imgui.Render();
const draw_data = Imgui.GetDrawData();
const is_minimized = (draw_data.DisplaySize.x <= 0 or draw_data.DisplaySize.y <= 0);
const force_render = true; // TODO BUG: still need to flush the textureuploads even if no present
if (!is_minimized or force_render) {
while (true) {
frameRender(ctx, &ctx.main_window_data, draw_data) catch |err| switch (err) {
error.SwapchainOutOfDate => {
try frameRebuildSwapchain(ctx);
continue;
}, // try again
error.VulkanError => return error.VulkanError,
error.OutOfMemory => return error.OutOfMemory,
};
framePresent(ctx.queue, &ctx.main_window_data) catch |err| switch (err) {
error.SwapchainOutOfDate => {
try frameRebuildSwapchain(ctx);
continue;
}, // try again
error.VulkanError => return error.VulkanError,
};
break; // success
}
}
}
// -------------------------------------------------------------------------------------------
export fn debug_report(flags: VkDebugReportFlagsEXT, objectType: VkDebugReportObjectTypeEXT, object: u64, location: usize, messageCode: i32, pLayerPrefix: [*c]const u8, pMessage: [*c]const u8, pUserData: ?*c_void) u32 {
_ = pUserData;
_ = pLayerPrefix;
_ = messageCode;
_ = location;
_ = object;
_ = flags;
warn("[vulkan] ObjectType: {}\nMessage: {s}\n\n", .{ objectType, pMessage });
return 0;
}
pub export fn Viewport_SetupVulkan(ctx: *Context, extensions: [*][*]const u8, extensions_count: u32) VkInstance {
return setupVulkan(ctx, extensions[0..extensions_count]) catch unreachable;
}
fn setupVulkan(ctx: *Context, extensions: [][*]const u8) !VkInstance {
var err: VkResult = undefined;
// Create Vulkan instance
{
if (DVULKAN_DEBUG_REPORT) {
// Enabling multiple validation layers grouped as LunarG standard validation
const layers = [_][*]const u8{"VK_LAYER_KHRONOS_validation"};
// Enable debug report extension (we need additional storage, so we duplicate the user array to add our new extension to it)
var storage: [100][*]const u8 = undefined;
var extensions_ext = storage[0 .. extensions.len + 1];
std.mem.copy([*]const u8, extensions_ext[0..extensions.len], extensions[0..extensions.len]);
extensions_ext[extensions.len] = "VK_EXT_debug_report";
const create_info = VkInstanceCreateInfo{
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
.pNext = null,
.flags = 0,
.enabledExtensionCount = @intCast(u32, extensions_ext.len),
.ppEnabledExtensionNames = extensions_ext.ptr,
.enabledLayerCount = @intCast(u32, layers.len),
.ppEnabledLayerNames = &layers,
.pApplicationInfo = null,
};
// Create Vulkan instance
err = vkCreateInstance(&create_info, ctx.vk_allocator, &ctx.instance);
try checkVkResult(err);
// Get the function pointer (required for any extensions)
const _vkCreateDebugReportCallbackEXT = @ptrCast(PFN_vkCreateDebugReportCallbackEXT, vkGetInstanceProcAddr(ctx.instance, "vkCreateDebugReportCallbackEXT"));
// Setup the debug report callback
const debug_report_ci = VkDebugReportCallbackCreateInfoEXT{
.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT,
.pNext = null,
.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT,
.pfnCallback = debug_report,
.pUserData = null,
};
err = _vkCreateDebugReportCallbackEXT.?(ctx.instance, &debug_report_ci, ctx.vk_allocator, &ctx.debug_report);
try checkVkResult(err);
warn("Vulkan: debug layers enabled\n", .{});
} else {
const create_info = VkInstanceCreateInfo{
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
.pNext = null,
.flags = 0,
.enabledExtensionCount = @intCast(u32, extensions.len),
.ppEnabledExtensionNames = extensions.ptr,
.enabledLayerCount = 0,
.ppEnabledLayerNames = null,
.pApplicationInfo = null,
};
// Create Vulkan instance without any debug feature
err = vkCreateInstance(&create_info, ctx.vk_allocator, &ctx.instance);
try checkVkResult(err);
}
}
// Select GPU
{
var gpu_count: u32 = undefined;
err = vkEnumeratePhysicalDevices(ctx.instance, &gpu_count, null);
try checkVkResult(err);
assert(gpu_count > 0);
var gpus: [100]VkPhysicalDevice = undefined;
err = vkEnumeratePhysicalDevices(ctx.instance, &gpu_count, &gpus);
try checkVkResult(err);
// If a number >1 of GPUs got reported, you should find the best fit GPU for your purpose
// e.g. VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU if available, or with the greatest memory available, etc.
// for sake of simplicity we'll just take the first one, assuming it has a graphics queue family.
ctx.physical_device = gpus[0];
}
// Select graphics queue family
{
var count: u32 = undefined;
vkGetPhysicalDeviceQueueFamilyProperties(ctx.physical_device, &count, null);
var queues: [100]VkQueueFamilyProperties = undefined;
vkGetPhysicalDeviceQueueFamilyProperties(ctx.physical_device, &count, &queues);
var i: u32 = 0;
while (i < count) : (i += 1) {
if (queues[i].queueFlags & @intCast(u32, VK_QUEUE_GRAPHICS_BIT) != 0) {
ctx.queue_family = i;
break;
}
}
assert(ctx.queue_family != 0xFFFFFFFF);
}
// Create Logical device (with 1 queue)
{
const device_extensions = [_][*]const u8{"VK_KHR_swapchain"};
const queue_priority = [_]f32{1.0};
const queue_info = [_]VkDeviceQueueCreateInfo{
VkDeviceQueueCreateInfo{
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
.pNext = null,
.flags = 0,
.queueFamilyIndex = ctx.queue_family,
.queueCount = 1,
.pQueuePriorities = &queue_priority,
},
};
const create_info = VkDeviceCreateInfo{
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
.pNext = null,
.flags = 0,
.queueCreateInfoCount = queue_info.len,
.pQueueCreateInfos = &queue_info,
.enabledExtensionCount = device_extensions.len,
.ppEnabledExtensionNames = &device_extensions,
.enabledLayerCount = 0,
.ppEnabledLayerNames = null,
.pEnabledFeatures = null,
};
err = vkCreateDevice(ctx.physical_device, &create_info, ctx.vk_allocator, &ctx.device);
try checkVkResult(err);
vkGetDeviceQueue(ctx.device, ctx.queue_family, 0, &ctx.queue);
}
// Create Descriptor Pool
{
const pool_sizes = [_]VkDescriptorPoolSize{
VkDescriptorPoolSize{ .type = VK_DESCRIPTOR_TYPE_SAMPLER, .descriptorCount = 1000 },
VkDescriptorPoolSize{ .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, .descriptorCount = 1000 },
VkDescriptorPoolSize{ .type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, .descriptorCount = 1000 },
VkDescriptorPoolSize{ .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, .descriptorCount = 1000 },
VkDescriptorPoolSize{ .type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, .descriptorCount = 1000 },
VkDescriptorPoolSize{ .type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, .descriptorCount = 1000 },
VkDescriptorPoolSize{ .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, .descriptorCount = 1000 },
VkDescriptorPoolSize{ .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, .descriptorCount = 1000 },
VkDescriptorPoolSize{ .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, .descriptorCount = 1000 },
VkDescriptorPoolSize{ .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, .descriptorCount = 1000 },
VkDescriptorPoolSize{ .type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, .descriptorCount = 1000 },
};
const pool_info = VkDescriptorPoolCreateInfo{
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
.pNext = null,
.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
.maxSets = 1000 * pool_sizes.len,
.poolSizeCount = pool_sizes.len,
.pPoolSizes = &pool_sizes,
};
err = vkCreateDescriptorPool(ctx.device, &pool_info, ctx.vk_allocator, &ctx.descriptor_pool);
try checkVkResult(err);
}
return ctx.instance;
}
pub export fn Viewport_CleanupVulkan(ctx: *Context) void {
vkDestroyDescriptorPool(ctx.device, ctx.descriptor_pool, ctx.vk_allocator);
if (DVULKAN_DEBUG_REPORT) {
// Remove the debug report callback
const _vkDestroyDebugReportCallbackEXT = @ptrCast(PFN_vkDestroyDebugReportCallbackEXT, vkGetInstanceProcAddr(ctx.instance, "vkDestroyDebugReportCallbackEXT"));
_vkDestroyDebugReportCallbackEXT.?(ctx.instance, ctx.debug_report, ctx.vk_allocator);
}
vkDestroyDevice(ctx.device, ctx.vk_allocator);
vkDestroyInstance(ctx.instance, ctx.vk_allocator);
}
pub export fn Viewport_SetupWindow(ctx: *Context, surface: VkSurfaceKHR, width: u32, height: u32, ms: VkSampleCountFlagBits, min_image_count: u32, clear_enable: bool) void {
setupWindow(ctx, surface, width, height, ms, min_image_count, clear_enable) catch unreachable;
}
fn setupWindow(ctx: *Context, surface: VkSurfaceKHR, width: u32, height: u32, ms: VkSampleCountFlagBits, min_image_count: u32, clear_enable: bool) !void {
var err: VkResult = undefined;
ctx.MSAA_samples = ms;
const wd = &ctx.main_window_data;
wd.surface = surface;
wd.clear_enable = clear_enable;
// Check for WSI support
var res: u32 = undefined;
err = vkGetPhysicalDeviceSurfaceSupportKHR(ctx.physical_device, ctx.queue_family, wd.surface, &res);
try checkVkResult(err);
if (res == 0) {
warn("Error no WSI support on physical device 0\n", .{});
unreachable;
}
// Select surface Format
const requestSurfaceImageFormat = [_]VkFormat{ VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM };
wd.surface_format = selectSurfaceFormat(ctx.physical_device, wd.surface, &requestSurfaceImageFormat, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR);
// Select Present Mode
//const present_modes = [_]VkPresentModeKHR{ VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_FIFO_KHR };
const present_modes = [_]VkPresentModeKHR{VK_PRESENT_MODE_FIFO_KHR}; //v-sync
wd.present_mode = selectPresentMode(ctx.physical_device, wd.surface, &present_modes);
// Create SwapChain, renderPass, framebuffer, etc.
try createWindow(ctx.instance, ctx.physical_device, ctx.device, wd, ctx.queue_family, ctx.descriptor_pool, ctx.allocator, ctx.vk_allocator, width, height, min_image_count);
}
pub export fn Viewport_CleanupWindow(ctx: *Context) void {
destroyWindow(ctx.instance, ctx.device, &ctx.main_window_data, ctx.descriptor_pool, ctx.allocator, ctx.vk_allocator);
} | src/viewport.zig |
const std = @import("std");
const term = @import("ansi-term");
usingnamespace @import("ast.zig");
usingnamespace @import("code_formatter.zig");
usingnamespace @import("common.zig");
usingnamespace @import("compiler.zig");
usingnamespace @import("dot_printer.zig");
usingnamespace @import("error_handler.zig");
usingnamespace @import("job.zig");
usingnamespace @import("lexer.zig");
usingnamespace @import("location.zig");
usingnamespace @import("native_function.zig");
usingnamespace @import("parser.zig");
usingnamespace @import("symbol.zig");
usingnamespace @import("types.zig");
const DEBUG_LOG_STACK = false;
const log = std.log.scoped(.CodeRunner);
const NativeOrAstFunction = struct {
ptr: usize,
const Self = @This();
const mask: usize = 1 << 63;
pub fn get(self: Self) union(enum) {
Ast: *Ast,
Native: *NativeFunctionWrapper,
} {
// Check if leftmost bit is set.
if ((self.ptr & mask) != 0) {
return .{ .Ast = @intToPtr(*Ast, self.ptr & (~mask)) };
} else {
return .{ .Native = @intToPtr(*NativeFunctionWrapper, self.ptr) };
}
}
pub fn fromAst(ast: *Ast) Self {
std.debug.assert(@ptrToInt(ast) & mask == 0);
return .{ .ptr = @ptrToInt(ast) | mask };
}
pub fn fromNative(nfw: *NativeFunctionWrapper) Self {
std.debug.assert(@ptrToInt(nfw) & mask == 0);
return .{ .ptr = @ptrToInt(nfw) };
}
};
pub const CodeRunner = struct {
allocator: *std.mem.Allocator,
errorReporter: *ErrorReporter,
errorMsgBuffer: std.ArrayList(u8),
printBuffer: std.ArrayList(u8),
// execution
globalVariables: *std.mem.Allocator,
stack: std.ArrayListAligned(u8, 16),
stackPointer: usize = 0,
basePointer: usize = 0,
const Self = @This();
pub fn init(compiler: *Compiler) !Self {
var stack = std.ArrayListAligned(u8, 16).init(&compiler.stackAllocator.allocator);
try stack.resize(4 * 1024 * 1024);
return Self{
.allocator = compiler.allocator,
.errorReporter = compiler.errorReporter,
.stack = stack,
.globalVariables = &compiler.constantsAllocator.allocator,
.errorMsgBuffer = std.ArrayList(u8).init(&compiler.stackAllocator.allocator),
.printBuffer = std.ArrayList(u8).init(&compiler.stackAllocator.allocator),
};
}
pub fn deinit(self: *Self) void {
self.stack.deinit();
self.errorMsgBuffer.deinit();
self.printBuffer.deinit();
}
fn reportError(self: *Self, location: ?*const Location, comptime format: []const u8, args: anytype) void {
self.errorMsgBuffer.resize(0) catch unreachable;
std.fmt.format(self.errorMsgBuffer.writer(), format, args) catch {};
self.errorReporter.report(self.errorMsgBuffer.items, location);
}
pub fn printStack(self: *Self) !void {
if (DEBUG_LOG_STACK) {
var stdOut = std.io.getStdOut().writer();
const style = term.Style{ .foreground = .{ .RGB = .{ .r = 0xd6, .g = 0x9a, .b = 0x9a } } };
term.updateStyle(stdOut, style, null) catch {};
defer term.updateStyle(stdOut, .{}, style) catch {};
var i: usize = 0;
try stdOut.writeAll("stack: [");
while (i < self.stackPointer) : (i += 8) {
if (i > 0) {
try stdOut.writeAll(", ");
}
try std.fmt.format(stdOut, "{}", .{bytesAsValue(u64, self.stack.items[i..(i + 8)])});
}
try stdOut.writeAll("]\n");
}
}
pub fn push(self: *Self, value: anytype) !void {
const size = @sizeOf(@TypeOf(value));
std.mem.copy(u8, self.stack.items[self.stackPointer..], std.mem.asBytes(&value));
self.stackPointer += size;
}
pub fn pushArg(self: *Self, offset: usize, size: usize) !void {
const src = self.basePointer + offset;
std.mem.copy(u8, self.stack.items[self.stackPointer..], self.stack.items[src..(src + size)]);
self.stackPointer += size;
}
pub fn pushSlice(self: *Self, value: []u8) !void {
std.mem.copy(u8, self.stack.items[self.stackPointer..], value);
self.stackPointer += value.len;
}
pub fn pop(self: *Self, comptime T: type) !T {
const size = @sizeOf(T);
if (self.stackPointer < size) {
return error.StackUnderflow;
}
self.stackPointer -= size;
var value: T = undefined;
std.mem.copy(u8, std.mem.asBytes(&value), self.stack.items[self.stackPointer..(self.stackPointer + size)]);
return value;
}
pub fn copyArgInto(self: *Self, offset: usize, dest: []u8) !void {
const src = self.basePointer + offset;
std.mem.copy(u8, dest, self.stack.items[src..(src + dest.len)]);
}
pub fn popInto(self: *Self, dest: []u8) !void {
const size = dest.len;
if (self.stackPointer < size) {
return error.StackUnderflow;
}
self.stackPointer -= size;
std.mem.copy(u8, dest, self.stack.items[self.stackPointer..(self.stackPointer + size)]);
}
pub fn popBytes(self: *Self, size: usize) !void {
if (self.stackPointer < size) {
return error.StackUnderflow;
}
self.stackPointer -= size;
}
pub fn runAst(self: *Self, ast: *Ast) anyerror!void {
//if (self.stackPointer > 50) {
// self.reportError(null, "Max stack size reached", .{});
// return error.StackOverflow;
//}
switch (ast.spec) {
.Block => try self.runBlock(ast),
.Call => try self.runCall(ast),
.ConstDecl => {},
.Identifier => try self.runIdentifier(ast),
.Int => try self.runInt(ast),
.Function => try self.runFunction(ast),
.Pipe => try self.runPipe(ast),
.Return => try self.runReturn(ast),
.VarDecl => try self.runVarDecl(ast),
else => {
const UnionTagType = @typeInfo(AstSpec).Union.tag_type.?;
std.log.debug("runAst({s}) Not implemented", .{@tagName(@as(UnionTagType, ast.spec))});
return error.NotImplemented;
},
}
}
fn runBlock(self: *Self, ast: *Ast) anyerror!void {
const block = &ast.spec.Block;
for (block.body.items) |expr, i| {
try self.runAst(expr);
if (i < block.body.items.len - 1) {
try self.popBytes(expr.typ.size);
}
}
}
fn runCall(self: *Self, ast: *Ast) anyerror!void {
const call = &ast.spec.Call;
switch (call.func.spec) {
.Identifier => |*id| {
if (id.name[0] == '@') {
if (std.mem.eql(u8, id.name, "@print")) {
try self.runCallPrint(ast);
return;
} else if (std.mem.eql(u8, id.name, "@then")) {
try self.runCallThen(ast);
return;
} else if (std.mem.eql(u8, id.name, "@repeat")) {
try self.runCallRepeat(ast);
return;
} else if (id.name[0] == '@') {
std.log.debug("runCall({s}) Not implemented", .{id.name});
return error.NotImplemented;
}
}
},
else => {},
}
const returnType = call.func.typ.kind.Function.returnType;
var returnValuePointer: usize = undefined;
{
// Align stack to 8 bytes.
const oldStackPointer = self.stackPointer;
defer self.stackPointer = oldStackPointer;
self.stackPointer = std.mem.alignForward(self.stackPointer, 8);
std.log.debug("Align stack pointer from {} to {}.", .{ oldStackPointer, self.stackPointer });
// Get the function ast.
std.log.debug("Get the function.", .{});
try self.runAst(call.func);
const nativeOrAstFunction = try self.pop(NativeOrAstFunction);
// Stack frame
try self.push(self.basePointer);
if (call.args.items.len > 0) {
self.stackPointer = std.mem.alignForward(self.stackPointer, call.args.items[0].typ.alignment);
}
self.basePointer = self.stackPointer;
std.log.debug("Stack frame. BasePointer = {}, StackPointer = {}", .{self.basePointer, self.stackPointer});
// Arguments.
std.log.debug("Arguments.", .{});
for (call.args.items) |arg, i| {
self.stackPointer = std.mem.alignForward(self.stackPointer, arg.typ.alignment);
std.log.debug("Running argument {} at {}", .{ i, self.stackPointer });
try self.runAst(arg);
}
if (returnType.alignment > 0) {
self.stackPointer = std.mem.alignForward(self.stackPointer, returnType.alignment);
}
switch (nativeOrAstFunction.get()) {
.Ast => |func| {
std.debug.assert(func.is(.Function));
self.runAst(func.spec.Function.body) catch |err| switch (err) {
error.Return => {
log.debug("Function returned with @return().", .{});
},
else => return err,
};
},
.Native => |func| {
func.invoke(self, call.func.typ) catch |err| switch (err) {
error.Return => {
log.debug("Function returned with @return().", .{});
},
else => return err,
};
},
}
returnValuePointer = self.stackPointer - returnType.size;
std.log.debug("After call, restore base pointer.", .{});
self.basePointer = try self.pop(@TypeOf(self.basePointer));
std.log.debug("Resetting base pointer: {}", .{self.basePointer});
}
if (returnType.size > 0) {
std.log.debug("Copying return value from {} to {}", .{ returnValuePointer, self.stackPointer });
try self.pushSlice(self.stack.items[returnValuePointer..(returnValuePointer + returnType.size)]);
}
}
fn runCallThen(self: *Self, ast: *Ast) anyerror!void {
//std.log.debug("runCallThen()", .{});
const call = &ast.spec.Call;
const condition = call.args.items[0];
const body = call.args.items[1];
try self.runAst(condition);
if (try self.pop(bool)) {
try self.runAst(body);
}
}
fn runCallRepeat(self: *Self, ast: *Ast) anyerror!void {
//std.log.debug("runCallRepeat()", .{});
const call = &ast.spec.Call;
const condition = call.args.items[1];
const body = call.args.items[0];
if (condition.typ.is(.Int)) {
var i: u128 = 0;
try self.runAst(condition);
const count = try self.pop(u128);
while (i < count) : (i += 1) {
try self.runAst(body);
}
} else if (condition.typ.is(.Bool)) {
while (true) {
try self.runAst(condition);
if (!(try self.pop(bool))) {
break;
}
try self.runAst(body);
}
} else {
@panic("Not implemented");
}
}
fn runReturn(self: *Self, ast: *Ast) anyerror!void {
//log.debug("runReturn()", .{});
const ret = &ast.spec.Return;
if (ret.value) |value| {
try self.runAst(value);
}
return error.Return;
}
fn runFunction(self: *Self, ast: *Ast) anyerror!void {
//std.log.debug("runFunction()", .{});
const call = &ast.spec.Function;
try self.push(NativeOrAstFunction.fromAst(ast));
}
fn bytesAsValue(comptime T: type, bytes: []const u8) T {
std.log.debug("bytesAsValue {}, {x}, {}", .{ @alignOf(T), @ptrToInt(bytes.ptr), @ptrToInt(bytes.ptr) % @alignOf(T) });
return @ptrCast(*const T, @alignCast(@alignOf(T), bytes.ptr)).*;
}
fn printGenericValue(writer: anytype, memory: []const u8, typ: *const Type) anyerror!void {
switch (typ.kind) {
.Int => |*int| {
if (typ.kind.Int.signed) {
switch (typ.size) {
1 => try std.fmt.format(writer, "{}", .{bytesAsValue(i8, memory)}),
2 => try std.fmt.format(writer, "{}", .{bytesAsValue(i16, memory)}),
4 => try std.fmt.format(writer, "{}", .{bytesAsValue(i32, memory)}),
8 => try std.fmt.format(writer, "{}", .{bytesAsValue(i64, memory)}),
16 => try std.fmt.format(writer, "{}", .{bytesAsValue(i128, memory)}),
else => unreachable,
}
} else {
switch (typ.size) {
1 => try std.fmt.format(writer, "{}", .{bytesAsValue(u8, memory)}),
2 => try std.fmt.format(writer, "{}", .{bytesAsValue(u16, memory)}),
4 => try std.fmt.format(writer, "{}", .{bytesAsValue(u32, memory)}),
8 => try std.fmt.format(writer, "{}", .{bytesAsValue(u64, memory)}),
16 => try std.fmt.format(writer, "{}", .{bytesAsValue(u128, memory)}),
else => unreachable,
}
}
},
.Bool => {
try writer.print("{}", .{bytesAsValue(bool, memory)});
},
else => {
try writer.print("<unknown>", .{});
},
}
}
fn runCallPrint(self: *Self, ast: *Ast) anyerror!void {
//std.log.debug("runCallPrint()", .{});
const call = &ast.spec.Call;
// Align stack pointer.
const oldStackPointer = self.stackPointer;
defer self.stackPointer = oldStackPointer;
//self.stackPointer = std.mem.alignForward(self.stackPointer, 8);
//std.log.debug("Align stack pointer from {} to {}.", .{ oldStackPointer, self.stackPointer });
try self.printBuffer.resize(0);
for (call.args.items) |arg, i| {
if (i > 0) {
try self.printBuffer.writer().print(" ", .{});
}
self.stackPointer = std.mem.alignForward(self.stackPointer, arg.typ.alignment);
try self.runAst(arg);
std.log.debug("sp: {}, size: {}", .{ self.stackPointer, arg.typ.size });
try printGenericValue(self.printBuffer.writer(), self.stack.items[(self.stackPointer - arg.typ.size)..(self.stackPointer)], arg.typ);
try self.popBytes(arg.typ.size);
}
try self.printBuffer.writer().print("\n", .{});
// Print stuff in different color.
var stdOut = std.io.getStdOut().writer();
const style = term.Style{ .foreground = .{ .RGB = .{ .r = 0x9a, .g = 0xd6, .b = 0xd6 } } };
term.updateStyle(stdOut, style, null) catch {};
defer term.updateStyle(stdOut, .{}, style) catch {};
try stdOut.writeAll(self.printBuffer.items);
}
fn runIdentifier(self: *Self, ast: *Ast) anyerror!void {
const id = &ast.spec.Identifier;
std.log.debug("runIdentifier({s})", .{id.name});
if (std.mem.eql(u8, id.name, "true")) {
try self.push(true);
} else if (std.mem.eql(u8, id.name, "false")) {
try self.push(false);
} else {
std.debug.assert(id.symbol != null);
switch (id.symbol.?.kind) {
.Argument => |*arg| {
const offset = arg.offset;
std.log.debug("Loading argument at index {} to {}", .{ offset, self.stackPointer });
//try self.pushSlice(gv.value.?);
try self.pushArg(offset, arg.typ.size);
try self.printStack();
},
.Constant => |*constant| {
// Wait until value is known.
{
var condition = struct {
condition: FiberWaitCondition = .{
.evalFn = eval,
.reportErrorFn = reportError,
},
symbol: *Symbol,
location: *Location,
pub fn eval(condition: *FiberWaitCondition) bool {
const s = @fieldParentPtr(@This(), "condition", condition);
return s.symbol.kind.Constant.value != null;
}
pub fn reportError(condition: *FiberWaitCondition, compiler: *Compiler) void {
const s = @fieldParentPtr(@This(), "condition", condition);
compiler.reportError(s.location, "Value of symbol not known yet: {s}", .{s.symbol.name});
}
}{
.symbol = id.symbol.?,
.location = &ast.location,
};
try Coroutine.current().getUserData().?.waitUntil(&condition.condition);
}
try self.pushSlice(constant.value.?);
},
.GlobalVariable => |*gv| {
if (gv.value == null) {
// @todo: wait
self.reportError(&ast.location, "Trying to evaluate an identifier at compile time but the value is not known yet.", .{});
self.reportError(&gv.decl.location, "Variable defined here.", .{});
return error.FailedToRunCode;
}
try self.pushSlice(gv.value.?);
},
.NativeFunction => |*func| {
std.log.debug("Push native function. {}", .{func.wrapper});
try self.push(NativeOrAstFunction.fromNative(func.wrapper));
},
.Type => |*typ| {
try self.push(typ.typ);
},
else => return error.NotImplemented,
}
}
}
fn runInt(self: *Self, ast: *Ast) anyerror!void {
//std.log.debug("runInt()", .{});
const int = &ast.spec.Int;
const size = ast.typ.size;
const sign = ast.typ.kind.Int.signed;
if (sign) {
const value = @bitCast(i128, int.value);
switch (size) {
1 => try self.push(@intCast(i8, value)),
2 => try self.push(@intCast(i16, value)),
4 => try self.push(@intCast(i32, value)),
8 => try self.push(@intCast(i64, value)),
16 => try self.push(@intCast(i128, value)),
else => unreachable,
}
} else {
switch (size) {
1 => try self.push(@intCast(u8, int.value)),
2 => try self.push(@intCast(u16, int.value)),
4 => try self.push(@intCast(u32, int.value)),
8 => try self.push(@intCast(u64, int.value)),
16 => try self.push(@intCast(u128, int.value)),
else => unreachable,
}
}
}
fn runPipe(self: *Self, ast: *Ast) anyerror!void {
//std.log.debug("runPipe()", .{});
const pipe = &ast.spec.Pipe;
try self.runAst(pipe.right);
}
fn runVarDecl(self: *Self, ast: *Ast) anyerror!void {
//std.log.debug("runVarDecl()", .{});
const decl = &ast.spec.VarDecl;
std.debug.assert(decl.symbol != null);
const symbol = decl.symbol.?;
const globalVariable = &symbol.kind.GlobalVariable;
// @todo: alignment
globalVariable.value = try self.globalVariables.alloc(u8, globalVariable.typ.size);
if (decl.value) |value| {
try self.runAst(value);
try self.popInto(globalVariable.value.?);
}
}
}; | src/code_runner.zig |
const builtin = @import("builtin");
const std = @import("std");
const debug = std.debug;
const testing = std.testing;
const TypeInfo = builtin.TypeInfo;
const TypeId = builtin.TypeId;
pub fn Reify(comptime info: TypeInfo) type {
switch (info) {
.Type => return type,
.Void => return void,
.Bool => return bool,
.Null => return @TypeOf(null),
.Undefined => return @TypeOf(undefined),
.NoReturn => return noreturn,
.ComptimeInt => return comptime_int,
.ComptimeFloat => return comptime_float,
// TODO: Implement without using @Type
.Int => |int| unreachable,
.Float => |float| switch (float.bits) {
16 => return f16,
32 => return f32,
64 => return f64,
128 => return f128,
else => @compileError("Float cannot be Reified with {TODO bits in error} bits"),
},
.Pointer => |ptr| switch (ptr.size) {
.One => {
if (ptr.is_const and ptr.is_volatile)
return *align(ptr.alignment) const volatile ptr.child;
if (ptr.is_const)
return *align(ptr.alignment) const ptr.child;
if (ptr.is_volatile)
return *align(ptr.alignment) volatile ptr.child;
return *align(ptr.alignment) ptr.child;
},
.Many => {
if (ptr.is_const and ptr.is_volatile)
return [*]align(ptr.alignment) const volatile ptr.child;
if (ptr.is_const)
return [*]align(ptr.alignment) const ptr.child;
if (ptr.is_volatile)
return [*]align(ptr.alignment) volatile ptr.child;
return [*]align(ptr.alignment) ptr.child;
},
.Slice => {
if (ptr.is_const and ptr.is_volatile)
return []align(ptr.alignment) const volatile ptr.child;
if (ptr.is_const)
return []align(ptr.alignment) const ptr.child;
if (ptr.is_volatile)
return []align(ptr.alignment) volatile ptr.child;
return []align(ptr.alignment) ptr.child;
},
.C => {
if (ptr.is_const and ptr.is_volatile)
return [*c]align(ptr.alignment) const volatile ptr.child;
if (ptr.is_const)
return [*c]align(ptr.alignment) const ptr.child;
if (ptr.is_volatile)
return [*c]align(ptr.alignment) volatile ptr.child;
return [*c]align(ptr.alignment) ptr.child;
},
},
.Array => |arr| return [arr.len]arr.child,
.Struct => |str| @compileError("TODO"),
.Optional => |opt| return ?opt.child,
.ErrorUnion => |err_union| return err_union.error_set!err_union.payload,
.ErrorSet => |err_set| {
var Res = error{};
inline for (err_set.errors) |err| {
Res = Res || @field(anyerror, err.name);
}
return Res;
},
.Opaque => return @OpaqueType(),
.AnyFrame => return anyframe,
.Enum => |enu| @compileError("TODO"),
.Union => |unio| @compileError("TODO"),
.Fn => |func| @compileError("TODO"),
.BoundFn => |func| @compileError("TODO"),
.Frame => @compileError("TODO"),
.Vector => @compileError("TODO"),
.EnumLiteral => @compileError("TODO"),
}
}
test "reify: type" {
const T = Reify(@typeInfo(type));
testing.expectEqual(T, type);
}
test "reify: void" {
const T = Reify(@typeInfo(void));
testing.expectEqual(T, void);
}
test "reify: bool" {
const T = Reify(@typeInfo(bool));
testing.expectEqual(T, bool);
}
test "reify: noreturn" {
const T = Reify(@typeInfo(noreturn));
testing.expectEqual(T, noreturn);
}
test "reify: ix/ux" {
//@setEvalBranchQuota(10000);
//inline for ([_]bool{ true, false }) |signed| {
// comptime var i = 0;
// inline while (i < 256) : (i += 1) {
// const T1 = @IntType(signed, i);
// const T2 = Reify(@typeInfo(T1));
// comptime testing.expectEqual(T1, T2);
// }
//}
}
test "reify: fx" {
testing.expectEqual(Reify(@typeInfo(f16)), f16);
// TODO: All these fail for some reason
//testing.expectEqual(Reify(@typeInfo(f32)), f32);
//testing.expectEqual(Reify(@typeInfo(f64)), f64);
//testing.expectEqual(Reify(@typeInfo(f128)), f128);
}
test "reify: *X" {
const types = [_]type{
*u8,
*const u8,
*volatile u8,
*align(4) u8,
*const volatile u8,
*align(4) volatile u8,
*align(4) const u8,
*align(4) const volatile u8,
};
inline for (types) |P| {
const T = Reify(@typeInfo(P));
testing.expectEqual(T, P);
}
}
test "reify: [*]X" {
const types = [_]type{
[*]u8,
[*]const u8,
[*]volatile u8,
[*]align(4) u8,
[*]const volatile u8,
[*]align(4) volatile u8,
[*]align(4) const u8,
[*]align(4) const volatile u8,
};
inline for (types) |P| {
const T = Reify(@typeInfo(P));
testing.expectEqual(T, P);
}
}
test "reify: []X" {
const types = [_]type{
[]u8,
[]const u8,
[]volatile u8,
[]align(4) u8,
[]const volatile u8,
[]align(4) volatile u8,
[]align(4) const u8,
[]align(4) const volatile u8,
};
inline for (types) |P| {
const T = comptime Reify(@typeInfo(P));
testing.expectEqual(T, P);
}
}
test "reify: [n]X" {
testing.expectEqual([1]u8, Reify(@typeInfo([1]u8)));
// TODO: This fails for some reason
//testing.expectEqual([10]u8, Reify(@typeInfo([10]u8)));
}
test "reify: struct" {
return error.SkipZigTest;
}
test "reify: ?X" {
const T = Reify(@typeInfo(?u8));
testing.expectEqual(T, ?u8);
}
test "reify: X!Y" {
const Set = error{};
const T = Reify(@typeInfo(Set!u8));
testing.expectEqual(T, Set!u8);
}
test "reify: error sets" {
return error.SkipZigTest;
}
test "reify: enum" {
return error.SkipZigTest;
}
test "reify: union" {
return error.SkipZigTest;
}
test "reify: fn" {
return error.SkipZigTest;
}
test "reify: boundfn" {
return error.SkipZigTest;
}
test "reify: ..." {
return error.SkipZigTest;
}
test "reify: @OpaqueType()" {
const T = Reify(@typeInfo(@OpaqueType()));
testing.expectEqual(@as(TypeId, @typeInfo(T)), .Opaque);
}
test "reify: anyframe" {
const T = Reify(@typeInfo(anyframe));
testing.expectEqual(T, anyframe);
}
test "reify: @Frame" {
return error.SkipZigTest;
} | fun/reify.zig |
const mem = @import("std").mem;
const copy = mem.copy;
const Allocator = mem.Allocator;
const Stack = @import("std").atomic.Stack;
var alloc = @import("std").heap.wasm_allocator;
const fmt = @import("std").fmt;
const olin = @import("./olin/olin.zig");
const Resource = olin.resource.Resource;
const words = @embedFile("./Vocab.DD");
const numWordsInFile = 7570;
export fn cwa_main() i32 {
main() catch unreachable;
return 0;
}
fn main() !void {
var god = try God.init();
var written: usize = 0;
const stdout = try Resource.stdout();
const space = " ";
const nl = "\n";
god.add_bits(32, olin.random.int32());
god.add_bits(32, olin.random.int32());
god.add_bits(32, olin.random.int32());
god.add_bits(32, olin.random.int32());
god.add_bits(32, olin.random.int32());
god.add_bits(32, olin.random.int32());
god.add_bits(32, olin.random.int32());
god.add_bits(32, olin.random.int32());
god.add_bits(32, olin.random.int32());
god.add_bits(32, olin.random.int32());
god.add_bits(32, olin.random.int32());
god.add_bits(32, olin.random.int32());
god.add_bits(32, olin.random.int32());
god.add_bits(32, olin.random.int32());
god.add_bits(32, olin.random.int32());
god.add_bits(32, olin.random.int32());
var i: usize = 0;
while (i < 15) : (i += 1) {
const w = god.get_word();
written += (w.len + 1);
const ignored = stdout.write(w.ptr, w.len);
const ignored_also = stdout.write(&space, space.len);
if (written >= 70) {
const ignored_again = stdout.write(&nl, nl.len);
written = 0;
}
}
const ignored_again = stdout.write(&nl, nl.len);
}
fn putInt(val: usize) !void {
var thing: []u8 = try alloc.alloc(u8, 16);
const leng = fmt.formatIntBuf(thing, val, 10, false, 0);
olin.log.info(thing[0..leng]);
}
const God = struct {
words: [][]const u8,
bits: *Stack(u8),
fn init() !*God {
var result: *God = undefined;
var stack = Stack(u8).init();
result = try alloc.create(God);
result.words = try splitWords(words[0..words.len], numWordsInFile);
result.bits = &stack;
return result;
}
fn add_bits(self: *God, num_bits: i64, n: i64) void {
var i: i64 = 0;
var nn = n;
while (i < num_bits) : (i += 1) {
var node = alloc.create(Stack(u8).Node) catch unreachable;
node.* = Stack(u8).Node {
.next = undefined,
.data = @intCast(u8, nn & 1),
};
self.bits.push(node);
nn = nn >> 1;
}
}
fn get_word(self: *God) []const u8 {
const gotten = @mod(self.get_bits(14), numWordsInFile);
const word = self.words[@intCast(usize, gotten)];
return word;
}
fn get_bits(self: *God, num_bits: i64) i64 {
var i: i64 = 0;
var result: i64 = 0;
while (i < num_bits) : (i += 1) {
const n = self.bits.pop();
if (n) |nn| {
result = result + @intCast(i64, nn.data);
result = result << 1;
} else {
break;
}
}
return result;
}
};
fn splitWords(data: []const u8, numWords: u32) ![][]const u8 {
var result: [][]const u8 = try alloc.alloc([]const u8, numWords);
var ctr: usize = 0;
var itr = mem.separate(data, "\n");
var done = false;
while (!done) {
var val = itr.next();
if (val) |str| {
if (str.len == 0) {
done = true;
continue;
}
result[ctr] = str;
ctr += 1;
} else {
done = true;
break;
}
}
return result;
} | god/god.zig |
const std = @import("std");
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");
const LinuxUserGroupDescription = @import("../config/LinuxUserGroupDescription.zig");
const FileSystem = @import("FileSystem.zig").FileSystem;
const LinuxUserGroup = @import("LinuxUserGroup.zig").LinuxUserGroup;
const host_backend = @import("host_backend.zig");
pub fn Backend(comptime config: Config) type {
return struct {
allocator: std.mem.Allocator,
file_system: *FileSystem(config),
linux_user_group: LinuxUserGroup(config),
const log = std.log.scoped(config.logging_scope);
const Self = @This();
/// For information regarding the `description` argument see `Config`
pub fn init(allocator: std.mem.Allocator, description: anytype) !Self {
const DescriptionType = @TypeOf(description);
const file_system: *FileSystem(config) = if (config.file_system) blk: {
comptime {
const err = "file system capability requested without `file_system` field in `description` with type `FileSystemDescription`";
if (!@hasField(DescriptionType, "file_system")) {
@compileError(err);
}
if (@TypeOf(description.file_system) != *FileSystemDescription and
@TypeOf(description.file_system) != *const FileSystemDescription)
{
@compileError(err);
}
}
break :blk try FileSystem(config).init(allocator, description.file_system);
} else undefined;
const linux_user_group: LinuxUserGroup(config) = if (config.linux_user_group) blk: {
comptime {
const err = "linux user group capability requested without `linux_user_group` field in `description` with type `LinuxUserGroupDescription`";
if (!@hasField(DescriptionType, "linux_user_group")) {
@compileError(err);
}
if (@TypeOf(description.linux_user_group) != LinuxUserGroupDescription) {
@compileError(err);
}
}
const linux_user_group_desc: *const LinuxUserGroupDescription = &description.linux_user_group;
log.info("\n\n{}\n\n", .{linux_user_group_desc});
break :blk LinuxUserGroup(config){
.euid = linux_user_group_desc.initial_euid,
};
} else .{};
return Self{
.allocator = allocator,
.file_system = file_system,
.linux_user_group = linux_user_group,
};
}
pub fn deinit(self: *Self) void {
if (config.file_system) {
self.file_system.deinit();
}
self.* = undefined;
}
pub inline fn system(self: *Self) System {
return .{
.ptr = self,
.vtable = &vtable,
};
}
fn cwd(interface: System) Dir {
if (!config.file_system) {
if (config.fallback_to_host) {
return host_backend.cwd(interface);
}
@panic("cwd requires file_system capability");
}
return .{
.system = interface,
.data = .{ .custom = getSelf(interface).file_system.cwd() },
};
}
fn openFileFromDir(interface: System, dir: Dir, sub_path: []const u8, flags: File.OpenFlags) File.OpenError!File {
if (!config.file_system) {
if (config.fallback_to_host) {
return host_backend.openFileFromDir(interface, dir, sub_path, flags);
}
@panic("openFileFromDir requires file_system capability");
}
return File{
.system = interface,
.data = .{ .custom = try getSelf(interface).file_system.openFileFromDir(dir.data.custom, sub_path, flags) },
};
}
fn readFile(interface: System, file: File, buffer: []u8) std.os.ReadError!usize {
if (!config.file_system) {
if (config.fallback_to_host) {
return host_backend.readFile(interface, file, buffer);
}
@panic("readFile requires file_system capability");
}
return try getSelf(interface).file_system.readFile(file.data.custom, buffer);
}
fn closeFile(interface: System, file: File) void {
if (!config.file_system) {
if (config.fallback_to_host) {
return host_backend.closeFile(interface, file);
}
@panic("closeFile requires file_system capability");
}
getSelf(interface).file_system.closeFile(file.data.custom);
}
fn osLinuxGeteuid(interface: System) std.os.uid_t {
if (!config.linux_user_group) {
if (config.fallback_to_host) {
return host_backend.osLinuxGeteuid(interface);
}
@panic("osLinuxGeteuid requires file_system capability");
}
return getSelf(interface).linux_user_group.osLinuxGeteuid();
}
const vtable: System.VTable = .{
.cwd = cwd,
.openFileFromDir = openFileFromDir,
.readFile = readFile,
.closeFile = closeFile,
.osLinuxGeteuid = osLinuxGeteuid,
};
inline fn getSelf(interface: System) *Self {
return @ptrCast(*Self, @alignCast(@alignOf(Self), interface.ptr));
}
comptime {
@import("../internal.zig").referenceAllIterations(Backend);
}
comptime {
std.testing.refAllDecls(@This());
}
};
}
comptime {
std.testing.refAllDecls(@This());
} | src/backend/Backend.zig |
const std = @import("std");
pub const ascii = enum(u8) {
NUL,
SOH,
STX,
ETX,
EOT,
ENQ,
ACK,
BEL,
BS,
TAB,
LF,
VT,
FF,
CR,
SO,
SI,
DLE,
DC1,
DC2,
DC3,
DC4,
NAK,
SYN,
ETB,
CAN,
EM,
SUB,
ESC,
FS,
GS,
RS,
US,
pub fn s(self: ascii) []const u8 {
return &[_]u8{@enumToInt(self)};
}
};
pub const escape = struct {
pub const SS2 = ascii.ESC.s() ++ "N";
pub const SS3 = ascii.ESC.s() ++ "O";
pub const DCS = ascii.ESC.s() ++ "P";
pub const CSI = ascii.ESC.s() ++ "[";
pub const ST = ascii.ESC.s() ++ "\\";
pub const OSC = ascii.ESC.s() ++ "]";
pub const SOS = ascii.ESC.s() ++ "X";
pub const PM = ascii.ESC.s() ++ "^";
pub const APC = ascii.ESC.s() ++ "_";
pub const RIS = ascii.ESC.s() ++ "c";
};
fn make_csi_sequence(comptime c: []const u8, comptime x: anytype) []const u8 {
return escape.CSI ++ _join(";", arr_i_to_s(x)) ++ c;
}
fn arr_i_to_s(x: anytype) [][]const u8 {
var res: [x.len][]const u8 = undefined;
for (x) |item, i| {
res[i] = std.fmt.comptimePrint("{}", .{item});
}
return &res;
}
pub const csi = struct {
pub fn CursorUp(comptime n: i32) []const u8 {
return make_csi_sequence("A", .{n});
}
pub fn CursorDown(comptime n: i32) []const u8 {
return make_csi_sequence("B", .{n});
}
pub fn CursorForward(comptime n: i32) []const u8 {
return make_csi_sequence("C", .{n});
}
pub fn CursorBack(comptime n: i32) []const u8 {
return make_csi_sequence("D", .{n});
}
pub fn CursorNextLine(comptime n: i32) []const u8 {
return make_csi_sequence("E", .{n});
}
pub fn CursorPrevLine(comptime n: i32) []const u8 {
return make_csi_sequence("F", .{n});
}
pub fn CursorHorzAbs(comptime n: i32) []const u8 {
return make_csi_sequence("G", .{n});
}
pub fn CursorPos(comptime n: i32, m: i32) []const u8 {
return make_csi_sequence("H", .{ n, m });
}
pub fn EraseInDisplay(comptime n: i32) []const u8 {
return make_csi_sequence("J", .{n});
}
pub fn EraseInLine(comptime n: i32) []const u8 {
return make_csi_sequence("K", .{n});
}
pub fn ScrollUp(comptime n: i32) []const u8 {
return make_csi_sequence("S", .{n});
}
pub fn ScrollDown(comptime n: i32) []const u8 {
return make_csi_sequence("T", .{n});
}
pub fn HorzVertPos(comptime n: i32, m: i32) []const u8 {
return make_csi_sequence("f", .{ n, m });
}
pub fn SGR(comptime ns: anytype) []const u8 {
return make_csi_sequence("m", ns);
}
};
pub const style = struct {
pub const ResetAll = csi.SGR(.{0});
pub const Bold = csi.SGR(.{1});
pub const Faint = csi.SGR(.{2});
pub const Italic = csi.SGR(.{3});
pub const Underline = csi.SGR(.{4});
pub const BlinkSlow = csi.SGR(.{5});
pub const BlinkFast = csi.SGR(.{6});
pub const ResetFont = csi.SGR(.{10});
pub const Font1 = csi.SGR(.{11});
pub const Font2 = csi.SGR(.{12});
pub const Font3 = csi.SGR(.{13});
pub const Font4 = csi.SGR(.{14});
pub const Font5 = csi.SGR(.{15});
pub const Font6 = csi.SGR(.{16});
pub const Font7 = csi.SGR(.{17});
pub const Font8 = csi.SGR(.{18});
pub const Font9 = csi.SGR(.{19});
pub const UnderlineDouble = csi.SGR(.{21});
pub const ResetIntensity = csi.SGR(.{22});
pub const ResetItalic = csi.SGR(.{23});
pub const ResetUnderline = csi.SGR(.{24});
pub const ResetBlink = csi.SGR(.{25});
pub const FgBlack = csi.SGR(.{30});
pub const FgRed = csi.SGR(.{31});
pub const FgGreen = csi.SGR(.{32});
pub const FgYellow = csi.SGR(.{33});
pub const FgBlue = csi.SGR(.{34});
pub const FgMagenta = csi.SGR(.{35});
pub const FgCyan = csi.SGR(.{36});
pub const FgWhite = csi.SGR(.{37});
// Fg8bit = func(n int) string { return csi.SGR(38, 5, n) }
// Fg24bit = func(r, g, b int) string { return csi.SGR(38, 2, r, g, b) }
pub const ResetFgColor = csi.SGR(.{39});
pub const BgBlack = csi.SGR(.{40});
pub const BgRed = csi.SGR(.{41});
pub const BgGreen = csi.SGR(.{42});
pub const BgYellow = csi.SGR(.{43});
pub const BgBlue = csi.SGR(.{44});
pub const BgMagenta = csi.SGR(.{45});
pub const BgCyan = csi.SGR(.{46});
pub const BgWhite = csi.SGR(.{47});
// Bg8bit = func(n int) string { return csi.SGR(48, 5, n) }
// Bg24bit = func(r, g, b int) string { return csi.SGR(48, 2, r, g, b) }
pub const ResetBgColor = csi.SGR(.{49});
pub const Framed = csi.SGR(.{51});
pub const Encircled = csi.SGR(.{52});
pub const Overlined = csi.SGR(.{53});
pub const ResetFrameEnci = csi.SGR(.{54});
pub const ResetOverlined = csi.SGR(.{55});
};
pub const color = struct {
pub const Color = enum(u8) {
Black,
Red,
Green,
Yellow,
Blue,
Magenta,
Cyan,
White,
};
pub fn Fg(s: Color, comptime m: []const u8) []const u8 {
return csi.SGR(.{30 + @enumToInt(s)}) ++ m ++ style.ResetFgColor;
}
pub fn Bg(s: Color, comptime m: []const u8) []const u8 {
return csi.SGR(.{40 + @enumToInt(s)}) ++ m ++ style.ResetBgColor;
}
pub fn Bold(comptime m: []const u8) []const u8 {
return style.Bold ++ m ++ style.ResetIntensity;
}
pub fn Faint(comptime m: []const u8) []const u8 {
return style.Faint ++ m ++ style.ResetIntensity;
}
pub fn Italic(comptime m: []const u8) []const u8 {
return style.Italic ++ m ++ style.ResetItalic;
}
pub fn Underline(comptime m: []const u8) []const u8 {
return style.Underline ++ m ++ style.ResetUnderline;
}
};
//
// private
//
fn _join(comptime delim: []const u8, comptime xs: [][]const u8) []const u8 {
var buf: []const u8 = "";
for (xs) |x, i| {
buf = buf ++ x;
if (i < xs.len - 1) buf = buf ++ delim;
}
return buf;
} | src/lib.zig |
const std = @import("std");
const testing = std.testing;
const c = @import("c.zig");
/// Map an M3Result to the matching Error value.
fn mapError(result: c.M3Result) Error!void {
@setEvalBranchQuota(50000);
const match_list = comptime get_results: {
const Declaration = std.builtin.TypeInfo.Declaration;
var result_values: []const [2][]const u8 = &[0][2][]const u8{};
for (std.meta.declarations(c)) |decl| {
const d: Declaration = decl;
if (std.mem.startsWith(u8, d.name, "m3Err_")) {
if (!std.mem.eql(u8, d.name, "m3Err_none")) {
var error_name = d.name[("m3Err_").len..];
error_name = get: for (std.meta.fieldNames(Error)) |f| {
if (std.ascii.eqlIgnoreCase(error_name, f)) {
break :get f;
}
} else {
@compileError("Failed to find matching error for code " ++ d.name);
};
result_values = result_values ++ [1][2][]const u8{[2][]const u8{ d.name, error_name }};
}
}
}
break :get_results result_values;
};
if (result == c.m3Err_none) return;
inline for (match_list) |pair| {
if (result == @field(c, pair[0])) return @field(Error, pair[1]);
}
unreachable;
}
pub const Error = error{
// general errors
MallocFailed,
// parse errors
IncompatibleWasmVersion,
WasmMalformed,
MisorderedWasmSection,
WasmUnderrun,
WasmOverrun,
WasmMissingInitExpr,
LebOverflow,
MissingUTF8,
WasmSectionUnderrun,
WasmSectionOverrun,
InvalidTypeId,
TooManyMemorySections,
TooManyArgsRets,
// link errors
ModuleAlreadyLinked,
FunctionLookupFailed,
FunctionImportMissing,
MalformedFunctionSignature,
// compilation errors
NoCompiler,
UnknownOpcode,
RestictedOpcode,
FunctionStackOverflow,
FunctionStackUnderrun,
MallocFailedCodePage,
SettingImmutableGlobal,
TypeMismatch,
TypeCountMismatch,
// runtime errors
MissingCompiledCode,
WasmMemoryOverflow,
GlobalMemoryNotAllocated,
GlobaIndexOutOfBounds,
ArgumentCountMismatch,
ArgumentTypeMismatch,
GlobalLookupFailed,
GlobalTypeMismatch,
GlobalNotMutable,
// traps
TrapOutOfBoundsMemoryAccess,
TrapDivisionByZero,
TrapIntegerOverflow,
TrapIntegerConversion,
TrapIndirectCallTypeMismatch,
TrapTableIndexOutOfRange,
TrapTableElementIsNull,
TrapExit,
TrapAbort,
TrapUnreachable,
TrapStackOverflow,
};
pub const Runtime = struct {
impl: c.IM3Runtime,
pub fn deinit(this: Runtime) callconv(.Inline) void {
c.m3_FreeRuntime(this.impl);
}
pub fn getMemory(this: Runtime, memory_index: u32) callconv(.Inline) ?[]u8 {
var size: u32 = 0;
var mem = c.m3_GetMemory(this.impl, &size, memory_index);
if (mem) |valid| {
return valid[0..@intCast(usize, size)];
}
return null;
}
pub fn getUserData(this: Runtime) callconv(.Inline) ?*c_void {
return c.m3_GetUserData(this.impl);
}
pub fn loadModule(this: Runtime, module: Module) callconv(.Inline) !void {
try mapError(c.m3_LoadModule(this.impl, module.impl));
}
pub fn findFunction(this: Runtime, function_name: [:0]const u8) callconv(.Inline) !Function {
var func = Function{ .impl = undefined };
try mapError(c.m3_FindFunction(&func.impl, this.impl, function_name.ptr));
return func;
}
pub fn printRuntimeInfo(this: Runtime) callconv(.Inline) void {
c.m3_PrintRuntimeInfo(this.impl);
}
pub const ErrorInfo = c.M3ErrorInfo;
pub fn getErrorInfo(this: Runtime) callconv(.Inline) ErrorInfo {
var info: ErrorInfo = undefined;
c.m3_GetErrorInfo(this.impl, &info);
return info;
}
fn span(strz: ?[*:0]const u8) callconv(.Inline) []const u8 {
if (strz) |s| return std.mem.span(s);
return "nullptr";
}
pub fn printError(this: Runtime) callconv(.Inline) void {
var info = this.getErrorInfo();
this.resetErrorInfo();
std.log.err("Wasm3 error: {s} @ {s}:{d}\n", .{ span(info.message), span(info.file), info.line });
}
pub fn resetErrorInfo(this: Runtime) callconv(.Inline) void {
c.m3_ResetErrorInfo(this.impl);
}
};
pub const Function = struct {
impl: c.IM3Function,
pub fn getArgCount(this: Function) callconv(.Inline) u32 {
return c.m3_GetArgCount(this.impl);
}
pub fn getRetCount(this: Function) callconv(.Inline) u32 {
return c.m3_GetRetCount(this.impl);
}
pub fn getArgType(this: Function, idx: u32) callconv(.Inline) c.M3ValueType {
return c.m3_GetArgType(this.impl, idx);
}
pub fn getRetType(this: Function, idx: u32) callconv(.Inline) c.M3ValueType {
return c.m3_GetRetType(this.impl, idx);
}
/// Call a function, using a provided tuple for arguments.
/// TYPES ARE NOT VALIDATED. Be careful
/// TDOO: Test this! Zig has weird symbol export issues with wasm right now,
/// so I can't verify that arguments or return values are properly passes!
pub fn call(this: Function, comptime RetType: type, args: anytype) callconv(.Inline) !RetType {
if (this.getRetCount() > 1) {
return error.TooManyReturnValues;
}
const ArgsType = @TypeOf(args);
if (@typeInfo(ArgsType) != .Struct) {
@compileError("Expected tuple or struct argument, found " ++ @typeName(ArgsType));
}
const fields_info = std.meta.fields(ArgsType);
const count = fields_info.len;
comptime var ptr_i: comptime_int = 0;
const num_pointers = comptime ptr_count: {
var num_ptrs: comptime_int = 0;
var i: comptime_int = 0;
inline while (i < count) : (i += 1) {
const ArgType = @TypeOf(args[i]);
if (comptime isSandboxPtr(ArgType) or comptime isOptSandboxPtr(ArgType)) {
num_ptrs += 1;
}
}
break :ptr_count num_ptrs;
};
var pointer_values: [num_pointers]u32 = undefined;
var arg_arr: [count]?*const c_void = undefined;
comptime var i: comptime_int = 0;
inline while (i < count) : (i += 1) {
const ArgType = @TypeOf(args[i]);
if (comptime isSandboxPtr(ArgType) or comptime isOptSandboxPtr(ArgType)) {
pointer_values[ptr_i] = toLocalPtr(args[i]);
arg_arr[i] = @ptrCast(?*const c_void, &pointer_values[ptr_i]);
ptr_i += 1;
} else {
arg_arr[i] = @ptrCast(?*const c_void, &args[i]);
}
}
try mapError(c.m3_Call(this.impl, @intCast(u32, count), if (count == 0) null else &arg_arr));
if (RetType == void) return;
const Extensions = struct {
pub extern fn wasm3_addon_get_runtime_mem_ptr(rt: c.IM3Runtime) [*c]u8;
pub extern fn wasm3_addon_get_fn_rt(func: c.IM3Function) c.IM3Runtime;
};
const runtime_ptr = Extensions.wasm3_addon_get_fn_rt(this.impl);
var return_data_buffer: u64 = undefined;
var return_ptr: *c_void = @ptrCast(*c_void, &return_data_buffer);
try mapError(c.m3_GetResults(this.impl, 1, &[1]?*c_void{return_ptr}));
if (comptime isSandboxPtr(RetType) or comptime isOptSandboxPtr(RetType)) {
const mem_ptr = Extensions.wasm3_addon_get_runtime_mem_ptr(runtime_ptr);
return fromLocalPtr(
RetType,
@ptrCast(*u32, @alignCast(@alignOf(u32), return_ptr)).*,
@ptrToInt(mem_ptr),
);
}
switch (RetType) {
i8, i16, i32, i64, u8, u16, u32, u64, f32, f64 => {
return @ptrCast(*RetType, @alignCast(@alignOf(RetType), return_ptr)).*;
},
else => {},
}
@compileError("Invalid WebAssembly return type " ++ @typeName(RetType) ++ "!");
}
/// Don't free this, it's a member of the Function.
/// Returns a generic name if the module is unnamed, such as "<unnamed>"
pub fn getName(this: Function) callconv(.Inline) ![:0]const u8 {
const name = try mapError(c.m3_GetFunctionName(this.impl));
return std.mem.spanZ(name);
}
pub fn getModule(this: Function) callconv(.Inline) Module {
return .{.impl = c.m3_GetFunctionModule(this.impl)};
}
};
fn isSandboxPtr(comptime T: type) bool {
return switch (@typeInfo(T)) {
.Struct => @hasDecl(T, "_is_wasm3_local_ptr"),
else => false,
};
}
fn isOptSandboxPtr(comptime T: type) bool {
return switch (@typeInfo(T)) {
.Optional => |opt| isSandboxPtr(opt.child),
else => false,
};
}
pub fn SandboxPtr(comptime T: type) type {
comptime {
switch (T) {
i8, i16, i32, i64 => {},
u8, u16, u32, u64 => {},
else => @compileError("Invalid type for a SandboxPtr. Must be an integer!"),
}
}
return struct {
const _is_wasm3_local_ptr = true;
pub const Base = T;
local_heap: usize,
host_ptr: *T,
const Self = @This();
pub fn localPtr(this: Self) callconv(.Inline) u32 {
return @intCast(u32, @ptrToInt(this.host_ptr) - this.local_heap);
}
pub fn write(this: Self, val: T) callconv(.Inline) void {
std.mem.writeIntLittle(T, std.mem.asBytes(this.host_ptr), val);
}
pub fn read(this: Self) callconv(.Inline) T {
return std.mem.readIntLittle(T, std.mem.asBytes(this.host_ptr));
}
fn offsetBy(this: Self, offset: i64) callconv(.Inline) *T {
return @intToPtr(*T, get_ptr: {
if (offset > 0) {
break :get_ptr @ptrToInt(this.host_ptr) + @intCast(usize, offset);
} else {
break :get_ptr @ptrToInt(this.host_ptr) - @intCast(usize, -offset);
}
});
}
/// Offset is in bytes, NOT SAFETY CHECKED.
pub fn writeOffset(this: Self, offset: i64, val: T) callconv(.Inline) void {
std.mem.writeIntLittle(T, std.mem.asBytes(this.offsetBy(offset)), val);
}
/// Offset is in bytes, NOT SAFETY CHECKED.
pub fn readOffset(this: Self, offset: i64) callconv(.Inline) T {
std.mem.readIntLittle(T, std.mem.asBytes(this.offsetBy(offset)));
}
pub usingnamespace if (T == u8)
struct {
/// NOT SAFETY CHECKED.
pub fn slice(this: Self, len: u32) callconv(.Inline) []T {
return @ptrCast([*]u8, this.host_ptr)[0..@intCast(usize, len)];
}
}
else
struct {};
};
}
fn fromLocalPtr(comptime T: type, localptr: u32, local_heap: usize) T {
if (comptime isOptSandboxPtr(T)) {
const Child = std.meta.Child(T);
if (localptr == 0) return null;
return Child{
.local_heap = local_heap,
.host_ptr = @intToPtr(*Child.Base, local_heap + @intCast(usize, localptr)),
};
} else if (comptime isSandboxPtr(T)) {
std.debug.assert(localptr != 0);
return T{
.local_heap = local_heap,
.host_ptr = @intToPtr(*T.Base, local_heap + @intCast(usize, localptr)),
};
} else {
@compileError("Expected a SandboxPtr or a ?SandboxPtr");
}
}
fn toLocalPtr(sandbox_ptr: anytype) u32 {
const T = @TypeOf(sandbox_ptr);
if (comptime isOptSandboxPtr(T)) {
if (sandbox_ptr) |np| {
const lp = np.localPtr();
std.debug.assert(lp != 0);
return lp;
} else return 0;
} else if (comptime isSandboxPtr(T)) {
const lp = sandbox_ptr.localPtr();
std.debug.assert(lp != 0);
return lp;
} else {
@compileError("Expected a SandboxPtr or a ?SandboxPtr");
}
}
pub const Module = struct {
impl: c.IM3Module,
pub fn deinit(this: Module) void {
c.m3_FreeModule(this.impl);
}
fn mapTypeToChar(comptime T: type) u8 {
switch (T) {
void => return 'v',
u32, i32 => return 'i',
u64, i64 => return 'I',
f32 => return 'f',
f64 => return 'F',
else => {},
}
if (comptime isSandboxPtr(T) or comptime isOptSandboxPtr(T)) {
return '*';
}
switch (@typeInfo(T)) {
.Pointer => |ptrti| {
if (ptrti.size == .One) {
@compileError("Please use a wasm3.SandboxPtr instead of raw pointers!");
}
},
}
@compileError("Invalid type " ++ @typeName(T) ++ " for WASM interop!");
}
pub fn linkWasi(this: Module) !void {
return mapError(c.m3_LinkWASI(this.impl));
}
/// Links all functions in a struct to the module.
/// library_name: the name of the library this function should belong to.
/// library: a struct containing functions that should be added to the module.
/// See linkRawFunction(...) for information about valid function signatures.
/// userdata: A single-item pointer passed to the function as the first argument when called.
/// Not accessible from within wasm, handled by the interpreter.
/// If you don't want userdata, pass a void literal {}.
pub fn linkLibrary(this: Module, library_name: [:0]const u8, comptime library: type, userdata: anytype) !void {
comptime const decls = std.meta.declarations(library);
inline for (decls) |decl| {
if (decl.is_pub) {
switch (decl.data) {
.Fn => |fninfo| {
const fn_name_z = comptime get_name: {
var name_buf: [decl.name.len:0]u8 = undefined;
std.mem.copy(u8, &name_buf, decl.name);
break :get_name name_buf;
};
try this.linkRawFunction(library_name, &fn_name_z, @field(library, decl.name), userdata);
},
else => continue,
}
}
}
}
/// Links a native function into the module.
/// library_name: the name of the library this function should belong to.
/// function_name: the name the function should have in module-space.
/// function: a zig function (not function pointer!).
/// Valid argument and return types are:
/// i32, u32, i64, u64, f32, f64, void, and pointers to basic types.
/// Userdata, if provided, is the first argument to the function.
/// userdata: A single-item pointer passed to the function as the first argument when called.
/// Not accessible from within wasm, handled by the interpreter.
/// If you don't want userdata, pass a void literal {}.
pub fn linkRawFunction(this: Module, library_name: [:0]const u8, function_name: [:0]const u8, comptime function: anytype, userdata: anytype) !void {
errdefer {
std.log.err("Failed to link proc {s}.{s}!\n", .{ library_name, function_name });
}
comptime const has_userdata = @TypeOf(userdata) != void;
comptime validate_userdata: {
if (has_userdata) {
switch (@typeInfo(@TypeOf(userdata))) {
.Pointer => |ptrti| {
if (ptrti.size == .One) {
break :validate_userdata;
}
},
else => {},
}
@compileError("Expected a single-item pointer for the userdata, got " ++ @typeName(@TypeOf(userdata)));
}
}
const UserdataType = @TypeOf(userdata);
const sig = comptime generate_signature: {
switch (@typeInfo(@TypeOf(function))) {
.Fn => |fnti| {
const sub_data = if (has_userdata) 1 else 0;
var arg_str: [fnti.args.len + 3 - sub_data:0]u8 = undefined;
arg_str[0] = mapTypeToChar(fnti.return_type orelse void);
arg_str[1] = '(';
arg_str[arg_str.len - 1] = ')';
for (fnti.args[sub_data..]) |arg, i| {
if (arg.is_generic) {
@compileError("WASM does not support generic arguments to native functions!");
}
arg_str[2 + i] = mapTypeToChar(arg.arg_type.?);
}
break :generate_signature arg_str;
},
else => @compileError("Expected a function, got " ++ @typeName(@TypeOf(function))),
}
unreachable;
};
const lambda = struct {
pub fn l(rt: c.IM3Runtime, import_ctx: *c.M3ImportContext, sp: [*c]u64, _mem: ?*c_void) callconv(.C) ?*const c_void {
comptime var type_arr: []const type = &[0]type{};
if (has_userdata) {
type_arr = type_arr ++ @as([]const type, &[1]type{UserdataType});
}
std.debug.assert(_mem != null);
var mem = @ptrToInt(_mem);
var stack = @ptrToInt(sp);
const stride = @sizeOf(u64) / @sizeOf(u8);
switch (@typeInfo(@TypeOf(function))) {
.Fn => |fnti| {
const RetT = fnti.return_type orelse void;
const return_pointer = comptime isSandboxPtr(RetT) or comptime isOptSandboxPtr(RetT);
const RetPtr = if (RetT == void) void else if (return_pointer) *u32 else *RetT;
var ret_val: RetPtr = undefined;
if (RetT != void) {
ret_val = @intToPtr(RetPtr, stack);
stack += stride;
}
const sub_data = if (has_userdata) 1 else 0;
inline for (fnti.args[sub_data..]) |arg, i| {
if (arg.is_generic) unreachable;
type_arr = type_arr ++ @as([]const type, &[1]type{arg.arg_type.?});
}
var args: std.meta.Tuple(type_arr) = undefined;
comptime var idx: usize = 0;
if (has_userdata) {
args[idx] = @ptrCast(UserdataType, @alignCast(@alignOf(std.meta.Child(UserdataType)), import_ctx.userdata));
idx += 1;
}
inline for (fnti.args[sub_data..]) |arg, i| {
if (arg.is_generic) unreachable;
const ArgT = arg.arg_type.?;
if (comptime isSandboxPtr(ArgT) or comptime isOptSandboxPtr(ArgT)) {
const vm_arg_addr: u32 = @intToPtr(*u32, stack).*;
args[idx] = fromLocalPtr(ArgT, vm_arg_addr, mem);
} else {
args[idx] = @intToPtr(*ArgT, stack).*;
}
idx += 1;
stack += stride;
}
if (RetT == void) {
@call(.{ .modifier = .always_inline }, function, args);
} else {
const returned_value = @call(.{ .modifier = .always_inline }, function, args);
if (return_pointer) {
ret_val.* = toLocalPtr(returned_value);
} else {
ret_val.* = returned_value;
}
}
return c.m3Err_none;
},
else => unreachable,
}
}
}.l;
try mapError(c.m3_LinkRawFunctionEx(this.impl, library_name, function_name, @as([*]const u8, &sig), lambda, if (has_userdata) userdata else null));
}
/// This is optional.
pub fn runStart(this: Module) callconv(.Inline) !void {
return mapError(c.m3_RunStart(this.impl));
}
/// Don't free this, it's a member of the Module.
/// Returns a generic name if the module is unnamed, such as "<unknown>"
pub fn getName(this: Module) callconv(.Inline) ![:0]const u8 {
const name = try mapError(c.m3_GetModuleName(this.impl));
return std.mem.spanZ(name);
}
pub fn getRuntime(this: Module) callconv(.Inline) Runtime {
return .{.impl = c.m3_GetModuleRuntime(this.impl)};
}
pub fn findGlobal(this: Module, global_name: [:0]const u8) callconv(.Inline) ?Global {
if(c.m3_FindGlobal(this.impl, global_name)) |global_ptr| {
return Global {.impl = global_ptr};
}
return null;
}
};
pub const Global = struct {
pub const Value = union(enum) {
Int32: i32,
Int64: i64,
Float32: f32,
Float64: f64,
};
pub const Type = c.M3ValueType;
impl: c.IM3Global,
pub fn getType(this: Global) callconv(.Inline) Type {
return c.m3_GetGlobalType(this.impl);
}
pub fn get(this: Global) !Value {
var tagged_union: c.M3TaggedValue = undefined;
tagged_union.kind = .None;
try mapError(c.m3_GetGlobal(this.impl, &tagged_union));
return switch(tagged_union.kind) {
.None => Error.GlobalTypeMismatch,
.Unknown => Error.GlobalTypeMismatch,
.Int32 => Value {.Int32 = tagged_union.value.int32},
.Int64 => Value {.Int64 = tagged_union.value.int64},
.Float32 => Value {.Float32 = tagged_union.value.float32},
.Float64 => Value {.Float64 = tagged_union.value.float64},
};
}
pub fn set(this: Global, value_union: Value) !void {
var tagged_union: c.M3TaggedValue = switch(value_union) {
.Int32 => |value| .{.kind = .Int32, .value = .{.int32 = value}},
.Int64 => |value| .{.kind = .Int64, .value = .{.int64 = value}},
.Float32 => |value| .{.kind = .Float32, .value = .{.float32 = value}},
.Float64 => |value| .{.kind = .Float64, .value = .{.float64 = value}},
};
return mapError(c.m3_SetGlobal(this.impl, &tagged_union));
}
};
pub const Environment = struct {
impl: c.IM3Environment,
pub fn init() callconv(.Inline) Environment {
return .{ .impl = c.m3_NewEnvironment() };
}
pub fn deinit(this: Environment) callconv(.Inline) void {
c.m3_FreeEnvironment(this.impl);
}
pub fn createRuntime(this: Environment, stack_size: u32, userdata: ?*c_void) callconv(.Inline) Runtime {
return .{ .impl = c.m3_NewRuntime(this.impl, stack_size, userdata) };
}
pub fn parseModule(this: Environment, wasm: []const u8) callconv(.Inline) !Module {
var mod = Module{ .impl = undefined };
var res = c.m3_ParseModule(this.impl, &mod.impl, wasm.ptr, @intCast(u32, wasm.len));
try mapError(res);
return mod;
}
};
pub fn yield() callconv(.Inline) !void {
return mapError(c.m3_Yield());
}
pub fn printM3Info() callconv(.Inline) void {
c.m3_PrintM3Info();
}
pub fn printProfilerInfo() callconv(.Inline) void {
c.m3_PrintProfilerInfo();
}
// HACK: Even though we're linking with libc, there's some disconnect between what wasm3 wants to link to
// and what the platform's libc provides.
// These functions stll exist, but for various reason, the C code in wasm3 expects functions with
// different symbol names than the ones the system provides.
// This isn't wasm3's fault, but I don't really know *where* blame lies, so we'll just work around it.
// We can just reexport these functions. It's a bit hacky, but it gets things running.
pub usingnamespace if (std.Target.current.abi.isGnu() and std.Target.current.os.tag != .windows)
struct {
export fn getrandom(buf: [*c]u8, len: usize, flags: c_uint) i64 {
std.os.getrandom(buf[0..len]) catch return 0;
return @intCast(i64, len);
}
}
else
struct {}; | src/main.zig |
const std = @import("std");
const StateMachine = @import("StateMachine.zig");
// Standing state
pub const Standing = struct
{
pub fn OnStart(context: *StateMachine.CombatStateContext) void
{
_ = context;
std.debug.print("Standing.OnStart()\n", .{});
}
pub fn OnUpdate(context: *StateMachine.CombatStateContext) void
{
_ = context;
// Stop character movement on standing.
if(context.PhysicsComponent) | physicsComponent |
{
physicsComponent.velocity.x = 0;
}
if(context.InputCommand.Right)
{
context.bTransition = true;
context.NextState = StateMachine.CombatStateID.WalkingForward;
}
}
pub fn OnEnd(context: *StateMachine.CombatStateContext) void
{
_ = context;
std.debug.print("Standing.OnEnd()\n", .{});
}
};
pub const WalkingForward = struct
{
pub fn OnStart(context: *StateMachine.CombatStateContext) void
{
_ = context;
std.debug.print("WalkingForward.OnStart()\n", .{});
}
pub fn OnUpdate(context: *StateMachine.CombatStateContext) void
{
_ = context;
// Move the character right when the player presses right on the controller.
if(context.PhysicsComponent) | physicsComponent |
{
physicsComponent.velocity.x = 2000;
}
if(!context.InputCommand.Right)
{
context.bTransition = true;
context.NextState = StateMachine.CombatStateID.Standing;
}
}
pub fn OnEnd(context: *StateMachine.CombatStateContext) void
{
_ = context;
std.debug.print("WalkingForward.OnEnd()\n", .{});
}
};
const Crouching = struct
{
pub fn OnStart(context: *StateMachine.CombatStateContext) void
{
_ = context;
std.debug.print("Crouching.OnStart()\n", .{});
}
pub fn OnUpdate(context: *StateMachine.CombatStateContext) void
{
_ = context;
std.debug.print("Crouching.OnUpdate()\n", .{});
}
pub fn OnEnd(context: *StateMachine.CombatStateContext) void
{
_ = context;
std.debug.print("Crouching.OnEnd()\n", .{});
}
}; | src/ActionStates/CommonStates.zig |
const combn = @import("../combn/combn.zig");
const Result = combn.gllparser.Result;
const Parser = combn.gllparser.Parser;
const Error = combn.gllparser.Error;
const Context = combn.gllparser.Context;
const PosKey = combn.gllparser.PosKey;
const ParserPath = combn.gllparser.ParserPath;
const MapTo = combn.combinator.MapTo;
const Repeated = combn.combinator.Repeated;
const RepeatedValue = combn.combinator.repeated.Value;
const ByteRange = combn.parser.ByteRange;
const ByteRangeValue = combn.parser.byte_range.Value;
const Compilation = @import("Compilation.zig");
const CompilerContext = @import("CompilerContext.zig");
const std = @import("std");
const mem = std.mem;
pub fn init(allocator: mem.Allocator) !*Parser(*CompilerContext, ?Compilation) {
// Pattern matching grammar
//
// ```ebnf
// Pattern = TBD ;
// ```
//
const any_byte = try ByteRange(*CompilerContext).init(allocator, .{.from = 0, .to = 255});
const any_bytes = try Repeated(*CompilerContext, ByteRangeValue).init(allocator, .{
.parser = any_byte.ref(),
.min = 0,
.max = 1, // TODO(slimsag): make this parse more byte literals
});
const literal_any_bytes = try MapTo(*CompilerContext,combn.combinator.repeated.Value(ByteRangeValue), ?Compilation).init(allocator, .{
.parser = any_bytes.ref(),
.mapTo = struct {
fn mapTo(in: Result(RepeatedValue(ByteRangeValue)), compiler_context: *CompilerContext, _allocator: mem.Allocator, key: PosKey, path: ParserPath) callconv(.Async) Error!?Result(?Compilation) {
_ = compiler_context;
_ = _allocator;
_ = key;
_ = path;
switch (in.result) {
.err => return Result(?Compilation).initError(in.offset, in.result.err),
else => {
// optimization: newline and space parsers produce no compilations, so no
// need for us to pay any attention to repeated results.
return Result(?Compilation).init(in.offset, null);
},
}
}
}.mapTo,
});
return literal_any_bytes;
} | src/dsl/pattern_grammar.zig |
const std = @import("std");
const root = @import("root");
const builtin = @import("builtin");
const liu = @import("./lib.zig");
const SchemaParseError =
std.fmt.ParseIntError ||
std.fmt.ParseFloatError ||
std.mem.Allocator.Error ||
error{
MissingField,
ExpectedStruct,
ExpectedPrimitive,
ExpectedString,
ExpectedArray,
InvalidBoolValue,
InvalidArrayLength,
};
const SchemaSerializeError = error{
OutOfMemory,
};
const formatFloatValue = if (@hasDecl(root, "gon_formatFloatValue")) root.formatFloatValue else struct {
fn formatFloatValue(value: f64, writer: anytype) !void {
return std.fmt.format(writer, "{e}", .{value});
}
}.formatFloatValue;
const parseFloat = if (@hasDecl(root, "gon_parseFloat")) root.parseFloat else struct {
fn parseFloat(bytes: []const u8) !f64 {
return std.fmt.parseFloat(f64, bytes);
}
}.parseFloat;
pub const Value = union(enum) {
map: Map,
array: Array,
value: []const u8,
const Map = std.StringArrayHashMapUnmanaged(Self);
const Array = std.ArrayListUnmanaged(Self);
const Self = @This();
pub fn init(val: anytype) SchemaSerializeError!Self {
const T = @TypeOf(val);
if (T == Self) {
return val;
}
switch (@typeInfo(T)) {
.Struct => |info| {
var map: Map = .{};
try map.ensureTotalCapacity(liu.Temp, info.fields.len);
inline for (info.fields) |field| {
const field_val = @field(val, field.name);
if (@typeInfo(@TypeOf(field_val)) != .Optional) {
const field_gon = try Value.init(field_val);
map.putAssumeCapacity(field.name, field_gon);
} else {
if (field_val) |f| {
const field_gon = try Value.init(f);
map.putAssumeCapacity(field.name, field_gon);
}
}
}
return Self{ .map = map };
},
.Int => |_| {
var bytes = std.ArrayList(u8).init(liu.Temp);
try std.fmt.format(bytes.writer(), "{}", .{val});
return Self{ .value = bytes.items };
},
.Float => |info| {
if (info.bits > 64) @compileError("Only support floats up to f64");
var bytes = std.ArrayList(u8).init(liu.Temp);
try formatFloatValue(val, bytes.writer());
return Self{ .value = bytes.items };
},
.Bool => {
return if (val)
Self{ .value = "true" }
else
Self{ .value = "false" };
},
.Pointer => |info| {
if (info.size != .Slice) @compileError("We only support slices right now");
if (info.child == u8) {
return Self{ .value = val };
}
var array = Array{};
try array.ensureTotalCapacity(liu.Temp, val.len);
for (val) |v| {
array.appendAssumeCapacity(try Value.init(v));
}
return Self{ .array = array };
},
.Array => |info| {
var array = Array{};
try array.ensureTotalCapacity(liu.Temp, info.len);
for (val) |v| {
array.appendAssumeCapacity(try Value.init(v));
}
return Self{ .array = array };
},
.Vector => |info| {
var array = Array{};
try array.ensureTotalCapacity(liu.Temp, info.len);
const elements: [info.len]info.child = val;
for (elements) |v| {
array.appendAssumeCapacity(try Value.init(v));
}
return Self{ .array = array };
},
else => @compileError("unsupported type '" ++ @typeName(T) ++ "' for GON"),
}
}
pub fn expect(self: *const Self, comptime T: type) SchemaParseError!T {
if (T == Self) {
return self.*;
}
switch (@typeInfo(T)) {
.Struct => |info| {
if (self.* != .map) return error.ExpectedStruct;
var t: T = undefined;
const map = &self.map;
inline for (info.fields) |field| {
const map_value = map.get(field.name);
const field_info = @typeInfo(field.field_type);
if (field_info == .Optional) {
if (map_value) |value| {
const field_type = field_info.Optional.child;
@field(t, field.name) = try value.expect(field_type);
} else {
@field(t, field.name) = null;
}
} else {
const value = map_value orelse return error.MissingField;
@field(t, field.name) = try value.expect(field.field_type);
}
}
return t;
},
.Bool => {
if (self.* != .value) return error.ExpectedString;
const value = self.value;
if (std.mem.eql(u8, value, "true")) return true;
if (std.mem.eql(u8, value, "false")) return false;
return error.InvalidBoolValue;
},
.Int => |_| {
if (self.* != .value) return error.ExpectedString;
const out = try std.fmt.parseInt(T, self.value, 10);
return out;
},
.Float => |info| {
if (info.bits > 64) @compileError("Only support floats up to f64");
if (self.* != .value) return error.ExpectedString;
const out = try parseFloat(self.value);
return @floatCast(T, out);
},
.Vector => |info| {
if (self.* != .array) return error.ExpectedArray;
const values = self.array;
if (values.items.len != info.len)
return error.InvalidArrayLength;
var out: [info.len]info.child = undefined;
for (values.items) |v, i| {
out[i] = try v.expect(info.child);
}
return out;
},
.Pointer => |info| {
if (info.size != .Slice) @compileError("We only support strings ([]const u8)");
if (info.child == u8) {
if (self.* != .value) return error.ExpectedString;
return self.value;
}
if (self.* != .array) return error.ExpectedArray;
const vals = self.array;
const out = try liu.Temp.alloc(info.child, vals.items.len);
for (vals.items) |v, i| {
out[i] = try v.expect(info.child);
}
return out;
},
else => @compileError("unsupported type '" ++ @typeName(T) ++ "' for GON"),
}
}
pub fn write(self: *const Self, writer: anytype, is_root: bool) @TypeOf(writer).Error!void {
const indent: u32 = if (is_root) 0 else 2;
try self.writeRecursive(writer, indent, is_root);
}
fn writeRecursive(
self: *const Self,
writer: anytype,
indent: u32,
is_root: bool,
) @TypeOf(writer).Error!void {
switch (self.*) {
.map => |map| {
if (!is_root) {
try writer.writeByte('{');
try writer.writeByte('\n');
}
var iter = map.iterator();
while (iter.next()) |i| {
try writer.writeByteNTimes(' ', indent);
try std.fmt.format(writer, "{s} ", .{i.key_ptr.*});
try i.value_ptr.writeRecursive(writer, indent + 2, false);
try writer.writeByte('\n');
}
if (!is_root) {
try writer.writeByteNTimes(' ', indent - 2);
try writer.writeByte('}');
}
},
.array => |array| {
try writer.writeByte('[');
try writer.writeByte('\n');
for (array.items) |i| {
try writer.writeByteNTimes(' ', indent);
try i.writeRecursive(writer, indent + 2, false);
try writer.writeByte('\n');
}
try writer.writeByteNTimes(' ', indent - 2);
try writer.writeByte(']');
},
.value => |value| {
try std.fmt.format(writer, "{s}", .{value});
},
}
}
};
pub const Token = union(enum) {
string: []const u8,
lbrace,
rbrace,
lbracket,
rbracket,
};
fn tokenize(bytes: []const u8) !std.ArrayList(Token) {
var tokens = std.ArrayList(Token).init(liu.Pages);
errdefer tokens.deinit();
var i: u32 = 0;
var word_begin: ?u32 = null;
while (i < bytes.len) : (i += 1) {
const b = bytes[i];
const tok_opt: ?Token = switch (b) {
' ', '\t', '\n' => null,
'{' => .lbrace,
'}' => .rbrace,
'[' => .lbracket,
']' => .rbracket,
else => {
if (word_begin == null)
word_begin = i;
continue;
},
};
if (word_begin) |begin| {
try tokens.append(.{ .string = bytes[begin..i] });
}
word_begin = null;
if (tok_opt) |tok| {
try tokens.append(tok);
}
}
if (word_begin) |begin| {
try tokens.append(.{ .string = bytes[begin..i] });
}
return tokens;
}
const ParseError = error{
OutOfMemory,
UnexpectedToken,
};
const Parser = struct {
tokens: []const Token,
index: u32 = 0,
fn parseGonRecursive(self: *@This(), is_root: bool) ParseError!Value {
const mark = liu.TempMark;
errdefer liu.TempMark = mark;
while (self.index < self.tokens.len) {
if (self.tokens[self.index] == .lbracket) {
self.index += 1;
var values: std.ArrayListUnmanaged(Value) = .{};
while (self.index < self.tokens.len) {
if (self.tokens[self.index] == .rbracket) {
self.index += 1;
break;
}
const value = try self.parseGonRecursive(false);
try values.append(liu.Temp, value);
}
return Value{ .array = values };
}
const parse_as_object = if (self.tokens[self.index] != .lbrace) is_root else object: {
self.index += 1;
break :object true;
};
if (parse_as_object) {
var values: Value.Map = .{};
while (self.index < self.tokens.len) {
const tok = self.tokens[self.index];
self.index += 1;
switch (tok) {
.string => |s| {
const value = try self.parseGonRecursive(false);
try values.put(liu.Temp, s, value);
},
.rbrace => break,
else => return error.UnexpectedToken,
}
}
return Value{ .map = values };
}
const tok = self.tokens[self.index];
self.index += 1;
switch (tok) {
.string => |s| return Value{ .value = s },
else => return error.UnexpectedToken,
}
}
return Value{ .value = "" };
}
};
pub fn parseGon(bytes: []const u8) ParseError!Value {
const tokens = try tokenize(bytes);
defer tokens.deinit();
var parser = Parser{ .tokens = tokens.items };
return parser.parseGonRecursive(true);
}
test "GON: parse" {
const mark = liu.TempMark;
defer liu.TempMark = mark;
const output = try parseGon("Hello { blarg werp }\nKerrz [ helo blarg\n ]fasd 13\n merp farg\nwatta 1.0");
var writer_out = std.ArrayList(u8).init(liu.Pages);
defer writer_out.deinit();
try output.write(writer_out.writer(), true);
const expected = "Hello {\n blarg werp\n}\nKerrz [\n helo\n blarg\n]\nfasd 13\nmerp farg\nwatta 1.0\n";
try std.testing.expectEqualSlices(u8, expected, writer_out.items);
const parsed = try output.expect(struct {
Hello: Value,
Kerrz: Value,
fasd: u32,
merp: []const u8,
zarg: ?[]const u8,
watta: f32,
});
try std.testing.expectEqualSlices(u8, "farg", parsed.merp);
try std.testing.expect(parsed.zarg == null);
try std.testing.expect(parsed.watta == 1.0);
}
test "GON: serialize" {
const mark = liu.TempMark;
defer liu.TempMark = mark;
const Test = struct {
merp: []const u8 = "hello",
zarg: []const u8 = "world",
forts: u64 = 1231243,
lerk: f64 = 13.0,
};
const a = Test{};
const value = try Value.init(a);
var writer_out = std.ArrayList(u8).init(liu.Pages);
defer writer_out.deinit();
try value.write(writer_out.writer(), true);
const expected = "merp hello\nzarg world\nforts 1231243\nlerk 1.3e+01\n";
// std.debug.print("{s}\n{s}\n", .{ expected, writer_out.items });
try std.testing.expectEqualSlices(u8, expected, writer_out.items);
}
test "GON: tokenize" {
const mark = liu.TempMark;
defer liu.TempMark = mark;
const tokens = try tokenize("Hello { blarg werp } Mark\n");
const expected = [_]Token{
.{ .string = "Hello" },
.lbrace,
.{ .string = "blarg" },
.{ .string = "werp" },
.rbrace,
.{ .string = "Mark" },
};
for (tokens.items) |t, i| {
const s = switch (t) {
.string => |s| s,
else => {
try std.testing.expectEqual(expected[i], t);
continue;
},
};
const e = switch (expected[i]) {
.string => |e| e,
else => return error.Failed,
};
try std.testing.expectEqualSlices(u8, e, s);
}
} | src/liu/gon.zig |
const std = @import("std");
const aoc = @import("aoc-lib.zig");
const X1: usize = 0;
const Y1: usize = 1;
const X2: usize = 2;
const Y2: usize = 3;
pub fn parts(inp: anytype) ![2]usize {
var b = try std.BoundedArray(u16, 2048).init(0);
var lines = try aoc.BoundedInts(u16, &b, inp);
var m1: [1048576]u2 = undefined;
std.mem.set(u2, m1[0..], 0);
var c1: usize = 0;
var m2: [1048576]u2 = undefined;
std.mem.set(u2, m2[0..], 0);
var c2: usize = 0;
var i: usize = 0;
while (i < lines.len) : (i += 4) {
var x1 = lines[i + X1];
var y1 = lines[i + Y1];
var x2 = lines[i + X2];
var y2 = lines[i + Y2];
var x = x1;
var y = y1;
var p1 = x1 == x2 or y1 == y2;
while (true) {
const k = @as(u32, x) + (@as(u32, y) * 1024);
switch (m2[k]) {
0 => {
m2[k] = 1;
},
1 => {
m2[k] = 2;
c2 += 1;
},
else => {},
}
if (p1) {
switch (m1[k]) {
0 => {
m1[k] = 1;
},
1 => {
m1[k] = 2;
c1 += 1;
},
else => {},
}
}
if (x == x2 and y == y2) {
break;
}
if (x1 < x2) {
x += 1;
} else if (x1 > x2) {
x -= 1;
}
if (y1 < y2) {
y += 1;
} else if (y1 > y2) {
y -= 1;
}
}
}
return [2]usize{ c1, c2 };
}
test "examples" {
var p = parts(aoc.test1file) catch unreachable;
try aoc.assertEq(@as(usize, 5), p[0]);
try aoc.assertEq(@as(usize, 12), p[1]);
var pi = parts(aoc.inputfile) catch unreachable;
try aoc.assertEq(@as(usize, 6005), pi[0]);
try aoc.assertEq(@as(usize, 23864), pi[1]);
}
fn day05(inp: []const u8, bench: bool) anyerror!void {
var p = parts(inp) catch unreachable;
if (!bench) {
try aoc.print("Part 1: {}\nPart 2: {}\n", .{ p[0], p[1] });
}
}
pub fn main() anyerror!void {
try aoc.benchme(aoc.input(), day05);
} | 2021/05/aoc.zig |
pub const E = enum {
@"0",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",
@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23",
@"24",@"25",@"26",@"27",@"28",@"29",@"30",@"31",@"32",@"33",@"34",
@"35",@"36",@"37",@"38",@"39",@"40",@"41",@"42",@"43",@"44",@"45",
@"46",@"47",@"48",@"49",@"50",@"51",@"52",@"53",@"54",@"55",@"56",
@"57",@"58",@"59",@"60",@"61",@"62",@"63",@"64",@"65",@"66",@"67",
@"68",@"69",@"70",@"71",@"72",@"73",@"74",@"75",@"76",@"77",@"78",
@"79",@"80",@"81",@"82",@"83",@"84",@"85",@"86",@"87",@"88",@"89",
@"90",@"91",@"92",@"93",@"94",@"95",@"96",@"97",@"98",@"99",@"100",
@"101",@"102",@"103",@"104",@"105",@"106",@"107",@"108",@"109",
@"110",@"111",@"112",@"113",@"114",@"115",@"116",@"117",@"118",
@"119",@"120",@"121",@"122",@"123",@"124",@"125",@"126",@"127",
@"128",@"129",@"130",@"131",@"132",@"133",@"134",@"135",@"136",
@"137",@"138",@"139",@"140",@"141",@"142",@"143",@"144",@"145",
@"146",@"147",@"148",@"149",@"150",@"151",@"152",@"153",@"154",
@"155",@"156",@"157",@"158",@"159",@"160",@"161",@"162",@"163",
@"164",@"165",@"166",@"167",@"168",@"169",@"170",@"171",@"172",
@"173",@"174",@"175",@"176",@"177",@"178",@"179",@"180",@"181",
@"182",@"183",@"184",@"185",@"186",@"187",@"188",@"189",@"190",
@"191",@"192",@"193",@"194",@"195",@"196",@"197",@"198",@"199",
@"200",@"201",@"202",@"203",@"204",@"205",@"206",@"207",@"208",
@"209",@"210",@"211",@"212",@"213",@"214",@"215",@"216",@"217",
@"218",@"219",@"220",@"221",@"222",@"223",@"224",@"225",@"226",
@"227",@"228",@"229",@"230",@"231",@"232",@"233",@"234",@"235",
@"236",@"237",@"238",@"239",@"240",@"241",@"242",@"243",@"244",
@"245",@"246",@"247",@"248",@"249",@"250",@"251",@"252",@"253",
@"254",@"255"
};
pub const S = extern struct {
e: E,
};
export fn entry() void {
if (@typeInfo(E).Enum.tag_type != u8) @compileError("did not infer u8 tag type");
const s: S = undefined;
_ = s;
}
// extern struct with extern-compatible but inferred integer tag type
//
// tmp.zig:31:5: error: extern structs cannot contain fields of type 'E' | test/compile_errors/stage1/obj/extern_struct_with_extern-compatible_but_inferred_integer_tag_type.zig |
pub const GUID_DEVINTERFACE_ENHANCED_STORAGE_SILO = Guid.initString("3897f6a4-fd35-4bc8-a0b7-5dbba36adafa");
pub const WPD_CATEGORY_ENHANCED_STORAGE = Guid.initString("91248166-b832-4ad4-baa4-7ca0b6b2798c");
pub const ENHANCED_STORAGE_AUTHN_STATE_UNKNOWN = @as(u32, 0);
pub const ENHANCED_STORAGE_AUTHN_STATE_NO_AUTHENTICATION_REQUIRED = @as(u32, 1);
pub const ENHANCED_STORAGE_AUTHN_STATE_NOT_AUTHENTICATED = @as(u32, 2);
pub const ENHANCED_STORAGE_AUTHN_STATE_AUTHENTICATED = @as(u32, 3);
pub const ENHANCED_STORAGE_AUTHN_STATE_AUTHENTICATION_DENIED = @as(u32, 2147483649);
pub const ENHANCED_STORAGE_AUTHN_STATE_DEVICE_ERROR = @as(u32, 2147483650);
pub const CERT_TYPE_EMPTY = @as(u32, 0);
pub const CERT_TYPE_ASCm = @as(u32, 1);
pub const CERT_TYPE_PCp = @as(u32, 2);
pub const CERT_TYPE_ASCh = @as(u32, 3);
pub const CERT_TYPE_HCh = @as(u32, 4);
pub const CERT_TYPE_SIGNER = @as(u32, 6);
pub const CERT_VALIDATION_POLICY_RESERVED = @as(u32, 0);
pub const CERT_VALIDATION_POLICY_NONE = @as(u32, 1);
pub const CERT_VALIDATION_POLICY_BASIC = @as(u32, 2);
pub const CERT_VALIDATION_POLICY_EXTENDED = @as(u32, 3);
pub const CERT_CAPABILITY_HASH_ALG = @as(u32, 1);
pub const CERT_CAPABILITY_ASYMMETRIC_KEY_CRYPTOGRAPHY = @as(u32, 2);
pub const CERT_CAPABILITY_SIGNATURE_ALG = @as(u32, 3);
pub const CERT_CAPABILITY_CERTIFICATE_SUPPORT = @as(u32, 4);
pub const CERT_CAPABILITY_OPTIONAL_FEATURES = @as(u32, 5);
pub const CERT_MAX_CAPABILITY = @as(u32, 255);
pub const AUDIO_CHANNELCOUNT_MONO = @as(u32, 1);
pub const AUDIO_CHANNELCOUNT_STEREO = @as(u32, 2);
pub const CREATOROPENWITHUIOPTION_HIDDEN = @as(u32, 0);
pub const CREATOROPENWITHUIOPTION_VISIBLE = @as(u32, 1);
pub const ISDEFAULTSAVE_NONE = @as(u32, 0);
pub const ISDEFAULTSAVE_OWNER = @as(u32, 1);
pub const ISDEFAULTSAVE_NONOWNER = @as(u32, 2);
pub const ISDEFAULTSAVE_BOTH = @as(u32, 3);
pub const FILEOFFLINEAVAILABILITYSTATUS_NOTAVAILABLEOFFLINE = @as(u32, 0);
pub const FILEOFFLINEAVAILABILITYSTATUS_PARTIAL = @as(u32, 1);
pub const FILEOFFLINEAVAILABILITYSTATUS_COMPLETE = @as(u32, 2);
pub const FILEOFFLINEAVAILABILITYSTATUS_COMPLETE_PINNED = @as(u32, 3);
pub const FILEOFFLINEAVAILABILITYSTATUS_EXCLUDED = @as(u32, 4);
pub const FILEOFFLINEAVAILABILITYSTATUS_FOLDER_EMPTY = @as(u32, 5);
pub const FLAGSTATUS_NOTFLAGGED = @as(i32, 0);
pub const FLAGSTATUS_COMPLETED = @as(i32, 1);
pub const FLAGSTATUS_FOLLOWUP = @as(i32, 2);
pub const IMPORTANCE_LOW_MIN = @as(i32, 0);
pub const IMPORTANCE_LOW_SET = @as(i32, 1);
pub const IMPORTANCE_LOW_MAX = @as(i32, 1);
pub const IMPORTANCE_NORMAL_MIN = @as(i32, 2);
pub const IMPORTANCE_NORMAL_SET = @as(i32, 3);
pub const IMPORTANCE_NORMAL_MAX = @as(i32, 4);
pub const IMPORTANCE_HIGH_MIN = @as(i32, 5);
pub const IMPORTANCE_HIGH_SET = @as(i32, 5);
pub const IMPORTANCE_HIGH_MAX = @as(i32, 5);
pub const OFFLINEAVAILABILITY_NOT_AVAILABLE = @as(u32, 0);
pub const OFFLINEAVAILABILITY_AVAILABLE = @as(u32, 1);
pub const OFFLINEAVAILABILITY_ALWAYS_AVAILABLE = @as(u32, 2);
pub const OFFLINESTATUS_ONLINE = @as(u32, 0);
pub const OFFLINESTATUS_OFFLINE = @as(u32, 1);
pub const OFFLINESTATUS_OFFLINE_FORCED = @as(u32, 2);
pub const OFFLINESTATUS_OFFLINE_SLOW = @as(u32, 3);
pub const OFFLINESTATUS_OFFLINE_ERROR = @as(u32, 4);
pub const OFFLINESTATUS_OFFLINE_ITEM_VERSION_CONFLICT = @as(u32, 5);
pub const OFFLINESTATUS_OFFLINE_SUSPENDED = @as(u32, 6);
pub const RATING_ONE_STAR_MIN = @as(u32, 1);
pub const RATING_ONE_STAR_SET = @as(u32, 1);
pub const RATING_ONE_STAR_MAX = @as(u32, 12);
pub const RATING_TWO_STARS_MIN = @as(u32, 13);
pub const RATING_TWO_STARS_SET = @as(u32, 25);
pub const RATING_TWO_STARS_MAX = @as(u32, 37);
pub const RATING_THREE_STARS_MIN = @as(u32, 38);
pub const RATING_THREE_STARS_SET = @as(u32, 50);
pub const RATING_THREE_STARS_MAX = @as(u32, 62);
pub const RATING_FOUR_STARS_MIN = @as(u32, 63);
pub const RATING_FOUR_STARS_SET = @as(u32, 75);
pub const RATING_FOUR_STARS_MAX = @as(u32, 87);
pub const RATING_FIVE_STARS_MIN = @as(u32, 88);
pub const RATING_FIVE_STARS_SET = @as(u32, 99);
pub const RATING_FIVE_STARS_MAX = @as(u32, 99);
pub const SHARINGSTATUS_NOTSHARED = @as(u32, 0);
pub const SHARINGSTATUS_SHARED = @as(u32, 1);
pub const SHARINGSTATUS_PRIVATE = @as(u32, 2);
pub const STORAGE_PROVIDER_SHARINGSTATUS_NOTSHARED = @as(u32, 0);
pub const STORAGE_PROVIDER_SHARINGSTATUS_SHARED = @as(u32, 1);
pub const STORAGE_PROVIDER_SHARINGSTATUS_PRIVATE = @as(u32, 2);
pub const STORAGE_PROVIDER_SHARINGSTATUS_PUBLIC = @as(u32, 3);
pub const STORAGE_PROVIDER_SHARINGSTATUS_SHARED_OWNED = @as(u32, 4);
pub const STORAGE_PROVIDER_SHARINGSTATUS_SHARED_COOWNED = @as(u32, 5);
pub const STORAGE_PROVIDER_SHARINGSTATUS_PUBLIC_OWNED = @as(u32, 6);
pub const STORAGE_PROVIDER_SHARINGSTATUS_PUBLIC_COOWNED = @as(u32, 7);
pub const BLUETOOTH_ADDRESS_TYPE_PUBLIC = @as(u32, 0);
pub const BLUETOOTH_ADDRESS_TYPE_RANDOM = @as(u32, 1);
pub const BLUETOOTH_CACHE_MODE_CACHED = @as(u32, 0);
pub const BLUETOOTH_CACHED_MODE_UNCACHED = @as(u32, 1);
pub const PLAYBACKSTATE_UNKNOWN = @as(u32, 0);
pub const PLAYBACKSTATE_STOPPED = @as(u32, 1);
pub const PLAYBACKSTATE_PLAYING = @as(u32, 2);
pub const PLAYBACKSTATE_TRANSITIONING = @as(u32, 3);
pub const PLAYBACKSTATE_PAUSED = @as(u32, 4);
pub const PLAYBACKSTATE_RECORDINGPAUSED = @as(u32, 5);
pub const PLAYBACKSTATE_RECORDING = @as(u32, 6);
pub const PLAYBACKSTATE_NOMEDIA = @as(u32, 7);
pub const LINK_STATUS_RESOLVED = @as(i32, 1);
pub const LINK_STATUS_BROKEN = @as(i32, 2);
pub const PHOTO_CONTRAST_NORMAL = @as(u32, 0);
pub const PHOTO_CONTRAST_SOFT = @as(u32, 1);
pub const PHOTO_CONTRAST_HARD = @as(u32, 2);
pub const PHOTO_EXPOSUREPROGRAM_UNKNOWN = @as(u32, 0);
pub const PHOTO_EXPOSUREPROGRAM_MANUAL = @as(u32, 1);
pub const PHOTO_EXPOSUREPROGRAM_NORMAL = @as(u32, 2);
pub const PHOTO_EXPOSUREPROGRAM_APERTURE = @as(u32, 3);
pub const PHOTO_EXPOSUREPROGRAM_SHUTTER = @as(u32, 4);
pub const PHOTO_EXPOSUREPROGRAM_CREATIVE = @as(u32, 5);
pub const PHOTO_EXPOSUREPROGRAM_ACTION = @as(u32, 6);
pub const PHOTO_EXPOSUREPROGRAM_PORTRAIT = @as(u32, 7);
pub const PHOTO_EXPOSUREPROGRAM_LANDSCAPE = @as(u32, 8);
pub const PHOTO_FLASH_NONE = @as(u32, 0);
pub const PHOTO_FLASH_FLASH = @as(u32, 1);
pub const PHOTO_FLASH_WITHOUTSTROBE = @as(u32, 5);
pub const PHOTO_FLASH_WITHSTROBE = @as(u32, 7);
pub const PHOTO_FLASH_FLASH_COMPULSORY = @as(u32, 9);
pub const PHOTO_FLASH_FLASH_COMPULSORY_NORETURNLIGHT = @as(u32, 13);
pub const PHOTO_FLASH_FLASH_COMPULSORY_RETURNLIGHT = @as(u32, 15);
pub const PHOTO_FLASH_NONE_COMPULSORY = @as(u32, 16);
pub const PHOTO_FLASH_NONE_AUTO = @as(u32, 24);
pub const PHOTO_FLASH_FLASH_AUTO = @as(u32, 25);
pub const PHOTO_FLASH_FLASH_AUTO_NORETURNLIGHT = @as(u32, 29);
pub const PHOTO_FLASH_FLASH_AUTO_RETURNLIGHT = @as(u32, 31);
pub const PHOTO_FLASH_NOFUNCTION = @as(u32, 32);
pub const PHOTO_FLASH_FLASH_REDEYE = @as(u32, 65);
pub const PHOTO_FLASH_FLASH_REDEYE_NORETURNLIGHT = @as(u32, 69);
pub const PHOTO_FLASH_FLASH_REDEYE_RETURNLIGHT = @as(u32, 71);
pub const PHOTO_FLASH_FLASH_COMPULSORY_REDEYE = @as(u32, 73);
pub const PHOTO_FLASH_FLASH_COMPULSORY_REDEYE_NORETURNLIGHT = @as(u32, 77);
pub const PHOTO_FLASH_FLASH_COMPULSORY_REDEYE_RETURNLIGHT = @as(u32, 79);
pub const PHOTO_FLASH_FLASH_AUTO_REDEYE = @as(u32, 89);
pub const PHOTO_FLASH_FLASH_AUTO_REDEYE_NORETURNLIGHT = @as(u32, 93);
pub const PHOTO_FLASH_FLASH_AUTO_REDEYE_RETURNLIGHT = @as(u32, 95);
pub const PHOTO_GAINCONTROL_NONE = @as(f64, 0);
pub const PHOTO_GAINCONTROL_LOWGAINUP = @as(f64, 1);
pub const PHOTO_GAINCONTROL_HIGHGAINUP = @as(f64, 2);
pub const PHOTO_GAINCONTROL_LOWGAINDOWN = @as(f64, 3);
pub const PHOTO_GAINCONTROL_HIGHGAINDOWN = @as(f64, 4);
pub const PHOTO_LIGHTSOURCE_UNKNOWN = @as(u32, 0);
pub const PHOTO_LIGHTSOURCE_DAYLIGHT = @as(u32, 1);
pub const PHOTO_LIGHTSOURCE_FLUORESCENT = @as(u32, 2);
pub const PHOTO_LIGHTSOURCE_TUNGSTEN = @as(u32, 3);
pub const PHOTO_LIGHTSOURCE_STANDARD_A = @as(u32, 17);
pub const PHOTO_LIGHTSOURCE_STANDARD_B = @as(u32, 18);
pub const PHOTO_LIGHTSOURCE_STANDARD_C = @as(u32, 19);
pub const PHOTO_LIGHTSOURCE_D55 = @as(u32, 20);
pub const PHOTO_LIGHTSOURCE_D65 = @as(u32, 21);
pub const PHOTO_LIGHTSOURCE_D75 = @as(u32, 22);
pub const PHOTO_PROGRAMMODE_NOTDEFINED = @as(u32, 0);
pub const PHOTO_PROGRAMMODE_MANUAL = @as(u32, 1);
pub const PHOTO_PROGRAMMODE_NORMAL = @as(u32, 2);
pub const PHOTO_PROGRAMMODE_APERTURE = @as(u32, 3);
pub const PHOTO_PROGRAMMODE_SHUTTER = @as(u32, 4);
pub const PHOTO_PROGRAMMODE_CREATIVE = @as(u32, 5);
pub const PHOTO_PROGRAMMODE_ACTION = @as(u32, 6);
pub const PHOTO_PROGRAMMODE_PORTRAIT = @as(u32, 7);
pub const PHOTO_PROGRAMMODE_LANDSCAPE = @as(u32, 8);
pub const PHOTO_SATURATION_NORMAL = @as(u32, 0);
pub const PHOTO_SATURATION_LOW = @as(u32, 1);
pub const PHOTO_SATURATION_HIGH = @as(u32, 2);
pub const PHOTO_SHARPNESS_NORMAL = @as(u32, 0);
pub const PHOTO_SHARPNESS_SOFT = @as(u32, 1);
pub const PHOTO_SHARPNESS_HARD = @as(u32, 2);
pub const PHOTO_WHITEBALANCE_AUTO = @as(u32, 0);
pub const PHOTO_WHITEBALANCE_MANUAL = @as(u32, 1);
pub const APPUSERMODEL_STARTPINOPTION_DEFAULT = @as(u32, 0);
pub const APPUSERMODEL_STARTPINOPTION_NOPINONINSTALL = @as(u32, 1);
pub const APPUSERMODEL_STARTPINOPTION_USERPINNED = @as(u32, 2);
pub const SYNC_HANDLERTYPE_OTHER = @as(u32, 0);
pub const SYNC_HANDLERTYPE_PROGRAMS = @as(u32, 1);
pub const SYNC_HANDLERTYPE_DEVICES = @as(u32, 2);
pub const SYNC_HANDLERTYPE_FOLDERS = @as(u32, 3);
pub const SYNC_HANDLERTYPE_WEBSERVICES = @as(u32, 4);
pub const SYNC_HANDLERTYPE_COMPUTERS = @as(u32, 5);
pub const SYNC_STATE_NOTSETUP = @as(u32, 0);
pub const SYNC_STATE_SYNCNOTRUN = @as(u32, 1);
pub const SYNC_STATE_IDLE = @as(u32, 2);
pub const SYNC_STATE_ERROR = @as(u32, 3);
pub const SYNC_STATE_PENDING = @as(u32, 4);
pub const SYNC_STATE_SYNCING = @as(u32, 5);
pub const ACT_AUTHORIZE_ON_RESUME = @as(u32, 1);
pub const ACT_AUTHORIZE_ON_SESSION_UNLOCK = @as(u32, 2);
pub const ACT_UNAUTHORIZE_ON_SUSPEND = @as(u32, 1);
pub const ACT_UNAUTHORIZE_ON_SESSION_LOCK = @as(u32, 2);
pub const ES_RESERVED_COM_ERROR_START = @as(u32, 0);
pub const ES_RESERVED_COM_ERROR_END = @as(u32, 511);
pub const ES_GENERAL_ERROR_START = @as(u32, 512);
pub const ES_GENERAL_ERROR_END = @as(u32, 1023);
pub const ES_AUTHN_ERROR_START = @as(u32, 1024);
pub const ES_AUTHN_ERROR_END = @as(u32, 1279);
pub const ES_RESERVED_SILO_ERROR_START = @as(u32, 1280);
pub const ES_RESERVED_SILO_ERROR_END = @as(u32, 4095);
pub const ES_PW_SILO_ERROR_START = @as(u32, 4352);
pub const ES_PW_SILO_ERROR_END = @as(u32, 4607);
pub const ES_RESERVED_SILO_SPECIFIC_ERROR_START = @as(u32, 4608);
pub const ES_RESERVED_SILO_SPECIFIC_ERROR_END = @as(u32, 49151);
pub const ES_VENDOR_ERROR_START = @as(u32, 49152);
pub const ES_VENDOR_ERROR_END = @as(u32, 65535);
pub const FACILITY_ENHANCED_STORAGE = @as(u32, 4);
//--------------------------------------------------------------------------------
// Section: Types (14)
//--------------------------------------------------------------------------------
pub const ENHANCED_STORAGE_PASSWORD_SILO_INFORMATION = extern struct {
CurrentAdminFailures: u8,
CurrentUserFailures: u8,
TotalUserAuthenticationCount: u32,
TotalAdminAuthenticationCount: u32,
FipsCompliant: BOOL,
SecurityIDAvailable: BOOL,
InitializeInProgress: BOOL,
ITMSArmed: BOOL,
ITMSArmable: BOOL,
UserCreated: BOOL,
ResetOnPORDefault: BOOL,
ResetOnPORCurrent: BOOL,
MaxAdminFailures: u8,
MaxUserFailures: u8,
TimeToCompleteInitialization: u32,
TimeRemainingToCompleteInitialization: u32,
MinTimeToAuthenticate: u32,
MaxAdminPasswordSize: u8,
MinAdminPasswordSize: u8,
MaxAdminHintSize: u8,
MaxUserPasswordSize: u8,
MinUserPasswordSize: u8,
MaxUserHintSize: u8,
MaxUserNameSize: u8,
MaxSiloNameSize: u8,
MaxChallengeSize: u16,
};
const CLSID_EnumEnhancedStorageACT_Value = Guid.initString("fe841493-835c-4fa3-b6cc-b4b2d4719848");
pub const CLSID_EnumEnhancedStorageACT = &CLSID_EnumEnhancedStorageACT_Value;
const CLSID_EnhancedStorageACT_Value = Guid.initString("af076a15-2ece-4ad4-bb21-29f040e176d8");
pub const CLSID_EnhancedStorageACT = &CLSID_EnhancedStorageACT_Value;
const CLSID_EnhancedStorageSilo_Value = Guid.initString("cb25220c-76c7-4fee-842b-f3383cd022bc");
pub const CLSID_EnhancedStorageSilo = &CLSID_EnhancedStorageSilo_Value;
const CLSID_EnhancedStorageSiloAction_Value = Guid.initString("886d29dd-b506-466b-9fbf-b44ff383fb3f");
pub const CLSID_EnhancedStorageSiloAction = &CLSID_EnhancedStorageSiloAction_Value;
pub const ACT_AUTHORIZATION_STATE = extern struct {
ulState: u32,
};
pub const SILO_INFO = extern struct {
ulSTID: u32,
SpecificationMajor: u8,
SpecificationMinor: u8,
ImplementationMajor: u8,
ImplementationMinor: u8,
type: u8,
capabilities: u8,
};
pub const ACT_AUTHORIZATION_STATE_VALUE = enum(i32) {
UNAUTHORIZED = 0,
AUTHORIZED = 1,
};
pub const ACT_UNAUTHORIZED = ACT_AUTHORIZATION_STATE_VALUE.UNAUTHORIZED;
pub const ACT_AUTHORIZED = ACT_AUTHORIZATION_STATE_VALUE.AUTHORIZED;
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IEnumEnhancedStorageACT_Value = Guid.initString("09b224bd-1335-4631-a7ff-cfd3a92646d7");
pub const IID_IEnumEnhancedStorageACT = &IID_IEnumEnhancedStorageACT_Value;
pub const IEnumEnhancedStorageACT = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetACTs: fn(
self: *const IEnumEnhancedStorageACT,
pppIEnhancedStorageACTs: [*]?*?*IEnhancedStorageACT,
pcEnhancedStorageACTs: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetMatchingACT: fn(
self: *const IEnumEnhancedStorageACT,
szVolume: ?[*:0]const u16,
ppIEnhancedStorageACT: ?*?*IEnhancedStorageACT,
) 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 IEnumEnhancedStorageACT_GetACTs(self: *const T, pppIEnhancedStorageACTs: [*]?*?*IEnhancedStorageACT, pcEnhancedStorageACTs: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumEnhancedStorageACT.VTable, self.vtable).GetACTs(@ptrCast(*const IEnumEnhancedStorageACT, self), pppIEnhancedStorageACTs, pcEnhancedStorageACTs);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumEnhancedStorageACT_GetMatchingACT(self: *const T, szVolume: ?[*:0]const u16, ppIEnhancedStorageACT: ?*?*IEnhancedStorageACT) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumEnhancedStorageACT.VTable, self.vtable).GetMatchingACT(@ptrCast(*const IEnumEnhancedStorageACT, self), szVolume, ppIEnhancedStorageACT);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IEnhancedStorageACT_Value = Guid.initString("6e7781f4-e0f2-4239-b976-a01abab52930");
pub const IID_IEnhancedStorageACT = &IID_IEnhancedStorageACT_Value;
pub const IEnhancedStorageACT = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Authorize: fn(
self: *const IEnhancedStorageACT,
hwndParent: u32,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Unauthorize: fn(
self: *const IEnhancedStorageACT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetAuthorizationState: fn(
self: *const IEnhancedStorageACT,
pState: ?*ACT_AUTHORIZATION_STATE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetMatchingVolume: fn(
self: *const IEnhancedStorageACT,
ppwszVolume: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetUniqueIdentity: fn(
self: *const IEnhancedStorageACT,
ppwszIdentity: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetSilos: fn(
self: *const IEnhancedStorageACT,
pppIEnhancedStorageSilos: [*]?*?*IEnhancedStorageSilo,
pcEnhancedStorageSilos: ?*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 IEnhancedStorageACT_Authorize(self: *const T, hwndParent: u32, dwFlags: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnhancedStorageACT.VTable, self.vtable).Authorize(@ptrCast(*const IEnhancedStorageACT, self), hwndParent, dwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnhancedStorageACT_Unauthorize(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnhancedStorageACT.VTable, self.vtable).Unauthorize(@ptrCast(*const IEnhancedStorageACT, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnhancedStorageACT_GetAuthorizationState(self: *const T, pState: ?*ACT_AUTHORIZATION_STATE) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnhancedStorageACT.VTable, self.vtable).GetAuthorizationState(@ptrCast(*const IEnhancedStorageACT, self), pState);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnhancedStorageACT_GetMatchingVolume(self: *const T, ppwszVolume: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnhancedStorageACT.VTable, self.vtable).GetMatchingVolume(@ptrCast(*const IEnhancedStorageACT, self), ppwszVolume);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnhancedStorageACT_GetUniqueIdentity(self: *const T, ppwszIdentity: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnhancedStorageACT.VTable, self.vtable).GetUniqueIdentity(@ptrCast(*const IEnhancedStorageACT, self), ppwszIdentity);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnhancedStorageACT_GetSilos(self: *const T, pppIEnhancedStorageSilos: [*]?*?*IEnhancedStorageSilo, pcEnhancedStorageSilos: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnhancedStorageACT.VTable, self.vtable).GetSilos(@ptrCast(*const IEnhancedStorageACT, self), pppIEnhancedStorageSilos, pcEnhancedStorageSilos);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.1'
const IID_IEnhancedStorageACT2_Value = Guid.initString("4da57d2e-8eb3-41f6-a07e-98b52b88242b");
pub const IID_IEnhancedStorageACT2 = &IID_IEnhancedStorageACT2_Value;
pub const IEnhancedStorageACT2 = extern struct {
pub const VTable = extern struct {
base: IEnhancedStorageACT.VTable,
GetDeviceName: fn(
self: *const IEnhancedStorageACT2,
ppwszDeviceName: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
IsDeviceRemovable: fn(
self: *const IEnhancedStorageACT2,
pIsDeviceRemovable: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IEnhancedStorageACT.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnhancedStorageACT2_GetDeviceName(self: *const T, ppwszDeviceName: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnhancedStorageACT2.VTable, self.vtable).GetDeviceName(@ptrCast(*const IEnhancedStorageACT2, self), ppwszDeviceName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnhancedStorageACT2_IsDeviceRemovable(self: *const T, pIsDeviceRemovable: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnhancedStorageACT2.VTable, self.vtable).IsDeviceRemovable(@ptrCast(*const IEnhancedStorageACT2, self), pIsDeviceRemovable);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IEnhancedStorageACT3_Value = Guid.initString("022150a1-113d-11df-bb61-001aa01bbc58");
pub const IID_IEnhancedStorageACT3 = &IID_IEnhancedStorageACT3_Value;
pub const IEnhancedStorageACT3 = extern struct {
pub const VTable = extern struct {
base: IEnhancedStorageACT2.VTable,
UnauthorizeEx: fn(
self: *const IEnhancedStorageACT3,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
IsQueueFrozen: fn(
self: *const IEnhancedStorageACT3,
pIsQueueFrozen: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetShellExtSupport: fn(
self: *const IEnhancedStorageACT3,
pShellExtSupport: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IEnhancedStorageACT2.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnhancedStorageACT3_UnauthorizeEx(self: *const T, dwFlags: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnhancedStorageACT3.VTable, self.vtable).UnauthorizeEx(@ptrCast(*const IEnhancedStorageACT3, self), dwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnhancedStorageACT3_IsQueueFrozen(self: *const T, pIsQueueFrozen: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnhancedStorageACT3.VTable, self.vtable).IsQueueFrozen(@ptrCast(*const IEnhancedStorageACT3, self), pIsQueueFrozen);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnhancedStorageACT3_GetShellExtSupport(self: *const T, pShellExtSupport: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnhancedStorageACT3.VTable, self.vtable).GetShellExtSupport(@ptrCast(*const IEnhancedStorageACT3, self), pShellExtSupport);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IEnhancedStorageSilo_Value = Guid.initString("5aef78c6-2242-4703-bf49-44b29357a359");
pub const IID_IEnhancedStorageSilo = &IID_IEnhancedStorageSilo_Value;
pub const IEnhancedStorageSilo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetInfo: fn(
self: *const IEnhancedStorageSilo,
pSiloInfo: ?*SILO_INFO,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetActions: fn(
self: *const IEnhancedStorageSilo,
pppIEnhancedStorageSiloActions: [*]?*?*IEnhancedStorageSiloAction,
pcEnhancedStorageSiloActions: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SendCommand: fn(
self: *const IEnhancedStorageSilo,
Command: u8,
pbCommandBuffer: [*:0]u8,
cbCommandBuffer: u32,
pbResponseBuffer: [*:0]u8,
pcbResponseBuffer: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetPortableDevice: fn(
self: *const IEnhancedStorageSilo,
ppIPortableDevice: ?*?*IPortableDevice,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDevicePath: fn(
self: *const IEnhancedStorageSilo,
ppwszSiloDevicePath: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnhancedStorageSilo_GetInfo(self: *const T, pSiloInfo: ?*SILO_INFO) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnhancedStorageSilo.VTable, self.vtable).GetInfo(@ptrCast(*const IEnhancedStorageSilo, self), pSiloInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnhancedStorageSilo_GetActions(self: *const T, pppIEnhancedStorageSiloActions: [*]?*?*IEnhancedStorageSiloAction, pcEnhancedStorageSiloActions: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnhancedStorageSilo.VTable, self.vtable).GetActions(@ptrCast(*const IEnhancedStorageSilo, self), pppIEnhancedStorageSiloActions, pcEnhancedStorageSiloActions);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnhancedStorageSilo_SendCommand(self: *const T, Command: u8, pbCommandBuffer: [*:0]u8, cbCommandBuffer: u32, pbResponseBuffer: [*:0]u8, pcbResponseBuffer: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnhancedStorageSilo.VTable, self.vtable).SendCommand(@ptrCast(*const IEnhancedStorageSilo, self), Command, pbCommandBuffer, cbCommandBuffer, pbResponseBuffer, pcbResponseBuffer);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnhancedStorageSilo_GetPortableDevice(self: *const T, ppIPortableDevice: ?*?*IPortableDevice) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnhancedStorageSilo.VTable, self.vtable).GetPortableDevice(@ptrCast(*const IEnhancedStorageSilo, self), ppIPortableDevice);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnhancedStorageSilo_GetDevicePath(self: *const T, ppwszSiloDevicePath: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnhancedStorageSilo.VTable, self.vtable).GetDevicePath(@ptrCast(*const IEnhancedStorageSilo, self), ppwszSiloDevicePath);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IEnhancedStorageSiloAction_Value = Guid.initString("b6f7f311-206f-4ff8-9c4b-27efee77a86f");
pub const IID_IEnhancedStorageSiloAction = &IID_IEnhancedStorageSiloAction_Value;
pub const IEnhancedStorageSiloAction = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetName: fn(
self: *const IEnhancedStorageSiloAction,
ppwszActionName: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDescription: fn(
self: *const IEnhancedStorageSiloAction,
ppwszActionDescription: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Invoke: fn(
self: *const IEnhancedStorageSiloAction,
) 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 IEnhancedStorageSiloAction_GetName(self: *const T, ppwszActionName: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnhancedStorageSiloAction.VTable, self.vtable).GetName(@ptrCast(*const IEnhancedStorageSiloAction, self), ppwszActionName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnhancedStorageSiloAction_GetDescription(self: *const T, ppwszActionDescription: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnhancedStorageSiloAction.VTable, self.vtable).GetDescription(@ptrCast(*const IEnhancedStorageSiloAction, self), ppwszActionDescription);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnhancedStorageSiloAction_Invoke(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnhancedStorageSiloAction.VTable, self.vtable).Invoke(@ptrCast(*const IEnhancedStorageSiloAction, self));
}
};}
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 (6)
//--------------------------------------------------------------------------------
const Guid = @import("../zig.zig").Guid;
const BOOL = @import("../foundation.zig").BOOL;
const HRESULT = @import("../foundation.zig").HRESULT;
const IPortableDevice = @import("../devices/portable_devices.zig").IPortableDevice;
const IUnknown = @import("../system/com.zig").IUnknown;
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/enhanced_storage.zig |
const std = @import("std");
const c = @import("internal/c.zig");
const internal = @import("internal/internal.zig");
const log = std.log.scoped(.git);
const git = @import("git.zig");
/// A refspec specifies the mapping between remote and local reference names when fetch or pushing.
pub const Refspec = opaque {
/// Get the refspec's string.
pub fn string(self: *const Refspec) [:0]const u8 {
return std.mem.span(c.git_refspec_string(@ptrCast(*const c.git_refspec, self)));
}
/// Get the source specifier.
pub fn src(self: *const Refspec) [:0]const u8 {
return std.mem.span(c.git_refspec_src(@ptrCast(*const c.git_refspec, self)));
}
/// Get the destination specifier.
pub fn dest(self: *const Refspec) [:0]const u8 {
return std.mem.span(c.git_refspec_dest(@ptrCast(*const c.git_refspec, self)));
}
/// Get the force update setting.
pub fn force(refspec: *const Refspec) bool {
return c.git_refspec_force(@ptrCast(*const c.git_refspec, refspec)) != 0;
}
/// Get the refspec's direction.
pub fn direction(refspec: *const Refspec) git.Direction {
return @intToEnum(git.Direction, c.git_refspec_direction(@ptrCast(*const c.git_refspec, refspec)));
}
/// Parse a given refspec string.
///
/// ## Parameters
/// * `input` the refspec string
/// * `is_fetch` is this a refspec for a fetch
pub fn parse(input: [:0]const u8, is_fetch: bool) !*Refspec {
log.debug("Refspec.parse called, input: {s}, is_fetch={}", .{ input, is_fetch });
var ret: *Refspec = undefined;
try internal.wrapCall("git_refspec_parse", .{
@ptrCast(**c.git_refspec, &ret),
input.ptr,
@boolToInt(is_fetch),
});
log.debug("refspec parsed");
return ret;
}
/// Free a refspec object which has been created by Refspec.parse.
pub fn deinit(self: *const Refspec) void {
c.git_refspec_free(@ptrCast(*c.git_refspec, self));
}
/// Check if a refspec's source descriptor matches a reference
pub fn srcMatches(refspec: *const Refspec, refname: [:0]const u8) bool {
return c.git_refspec_src_matches(@ptrCast(*const c.git_refspec, refspec), refname.ptr) != 0;
}
/// Check if a refspec's destination descriptor matches a reference
pub fn destMatches(refspec: *const Refspec, refname: [:0]const u8) bool {
return c.git_refspec_dst_matches(@ptrCast(*const c.git_refspec, refspec), refname.ptr) != 0;
}
/// Transform a reference to its target following the refspec's rules
///
/// # Parameters
/// * `name` - The name of the reference to transform.
pub fn transform(refspec: *const Refspec, name: [:0]const u8) !git.Buf {
log.debug("Refspec.transform called, name={s}", .{name});
var ret: git.Buf = undefined;
try internal.wrapCall("git_refspec_transform", .{
@ptrCast(*git.Buf, &ret),
@ptrCast(*const c.git_refspec, refspec),
name.ptr,
});
log.debug("refspec transform completed, out={s}", .{ret.toSlice()});
return ret;
}
/// Transform a target reference to its source reference following the refspec's rules
///
/// # Parameters
/// * `name` - The name of the reference to transform.
pub fn rtransform(refspec: *const Refspec, name: [:0]const u8) !git.Buf {
log.debug("Refspec.rtransform called, name={s}", .{name});
var ret: git.Buf = undefined;
try internal.wrapCall("git_refspec_rtransform", .{
@ptrCast(*git.Buf, &ret),
@ptrCast(*const c.git_refspec, refspec),
name.ptr,
});
log.debug("refspec rtransform completed, out={s}", .{ret.toSlice()});
return ret;
}
}; | src/types.zig |
const c = @import("../../c_global.zig").c_imp;
const std = @import("std");
// dross-zig
const Vertex = @import("../vertex.zig").Vertex;
// -------------------------------------------------
/// Describes how the data is used over its lifetime.
pub const BufferUsageGl = enum(c_uint) {
/// The data is set only once, and used by the GPU at
/// most a few times.
StreamDraw = c.GL_STREAM_DRAW,
/// The data is set only once, and used many times.
StaticDraw = c.GL_STATIC_DRAW,
/// The data is changes frequently, and used many times.
DynamicDraw = c.GL_DYNAMIC_DRAW,
};
// -----------------------------------------
// - VertexBufferGl -
// -----------------------------------------
/// Container for storing a large number of vertices in the GPU's memory.
pub const VertexBufferGl = struct {
/// OpenGL generated ID
handle: c_uint,
const Self = @This();
/// Allocates and builds a new VertexBufferGl
/// Comments: The caller will own the allocated memory.
pub fn new(allocator: *std.mem.Allocator) !*Self {
var self = try allocator.create(VertexBufferGl);
c.glGenBuffers(1, &self.handle);
return self;
}
/// Cleans up and de-allocates the Vertex Buffer
pub fn free(allocator: *std.mem.Allocator, self: *Self) void {
c.glDeleteBuffers(1, &self.handle);
allocator.destroy(self);
}
/// Returns the id OpenGL-generated id
pub fn id(self: *Self) c_uint {
return self.handle;
}
/// Binds the Vertex Buffer to the current buffer target.
pub fn bind(self: *Self) void {
c.glBindBuffer(c.GL_ARRAY_BUFFER, self.handle);
}
/// Allocates memory and stores data within the currently bound buffer object.
pub fn data(self: Self, vertices: []const f32, usage: BufferUsageGl) void {
const vertices_ptr = @ptrCast(*const c_void, vertices.ptr);
const vertices_size = @intCast(c_longlong, @sizeOf(f32) * vertices.len);
c.glBufferData(c.GL_ARRAY_BUFFER, vertices_size, vertices_ptr, @enumToInt(usage));
}
/// Allocates memory and stores data within the currently bound buffer object.
pub fn dataV(self: Self, vertices: []Vertex, usage: BufferUsageGl) void {
const vertices_ptr = @ptrCast(*const c_void, vertices.ptr);
const vertices_size = @intCast(c_longlong, @sizeOf(Vertex) * vertices.len);
c.glBufferData(c.GL_ARRAY_BUFFER, vertices_size, vertices_ptr, @enumToInt(usage));
}
///
/// Allocates memory and stores data within the currently bound buffer object.
pub fn dataSize(self: Self, vertices: []Vertex, size: u32, usage: BufferUsageGl) void {
const vertices_ptr = @ptrCast(*const c_void, vertices.ptr);
//const vertices_size = @intCast(c_longlong, @sizeOf(Vertex) * vertices.len);
const size = @intCast(c_longlong, size);
c.glBufferData(c.GL_ARRAY_BUFFER, vertices_size, vertices_ptr, @enumToInt(usage));
}
/// Allocates memory within the the currently bound buffer object.
/// `length` is the amount of floats to reserve.
pub fn dataless(self: Self, length: f32, usage: BufferUsageGl) void {
const size = @floatToInt(c_longlong, @sizeOf(f32) * length);
c.glBufferData(c.GL_ARRAY_BUFFER, size, null, @enumToInt(usage));
}
/// Overwrites previously allocated data within the currently bound buffer object.
pub fn subdata(self: Self, vertices: []const f32) void {
const size = @intCast(c_longlong, @sizeOf(f32) * vertices.len);
const ptr = @ptrCast(*const c_void, vertices.ptr);
c.glBufferSubData(c.GL_ARRAY_BUFFER, 0, size, ptr);
}
/// Overwrites previously allocated data within the currently bound buffer object.
pub fn subdataV(self: Self, vertices: []Vertex) void {
const size = @intCast(c_longlong, @sizeOf(Vertex) * vertices.len);
const ptr = @ptrCast(*const c_void, vertices.ptr);
c.glBufferSubData(c.GL_ARRAY_BUFFER, 0, size, ptr);
}
/// Overwrites previously allocated data within the currently bound buffer object.
pub fn subdataSize(self: Self, vertices: []Vertex, size: u32) void {
//const size = @intCast(c_longlong, @sizeOf(Vertex) * vertices.len);
const vertices_size = @intCast(c_longlong, size);
const ptr = @ptrCast(*const c_void, vertices.ptr);
c.glBufferSubData(c.GL_ARRAY_BUFFER, 0, vertices_size, ptr);
}
/// Clears out the currently bound Vertex Buffer
pub fn clearBoundVertexBuffer() void {
c.glBindBuffer(c.GL_ARRAY_BUFFER, 0);
}
}; | src/renderer/backend/vertex_buffer_opengl.zig |
const std = @import("std");
const stdout = std.io.getStdOut().writer();
const Tty = @import("Tty.zig");
const Choices = @import("Choices.zig");
const Options = @import("Options.zig");
const match = @import("match.zig");
const config = @cImport({
@cDefine("COLOR_BLACK", std.fmt.comptimePrint("{d}", .{Tty.COLOR_BLACK}));
@cDefine("COLOR_RED", std.fmt.comptimePrint("{d}", .{Tty.COLOR_RED}));
@cDefine("COLOR_GREEN", std.fmt.comptimePrint("{d}", .{Tty.COLOR_GREEN}));
@cDefine("COLOR_YELLOW", std.fmt.comptimePrint("{d}", .{Tty.COLOR_YELLOW}));
@cDefine("COLOR_BLUE", std.fmt.comptimePrint("{d}", .{Tty.COLOR_BLUE}));
@cDefine("COLOR_MAGENTA", std.fmt.comptimePrint("{d}", .{Tty.COLOR_MAGENTA}));
@cDefine("COLOR_CYAN", std.fmt.comptimePrint("{d}", .{Tty.COLOR_CYAN}));
@cDefine("COLOR_WHITE", std.fmt.comptimePrint("{d}", .{Tty.COLOR_WHITE}));
@cInclude("config.h");
});
const TtyInterface = @This();
const SEARCH_SIZE_MAX = 4096;
allocator: std.mem.Allocator,
tty: *Tty,
choices: *Choices,
options: Options,
search: std.BoundedArray(u8, SEARCH_SIZE_MAX) = .{ .buffer = undefined },
last_search: std.BoundedArray(u8, SEARCH_SIZE_MAX) = .{ .buffer = undefined },
cursor: usize = 0,
ambiguous_key_pending: bool = false,
input: std.BoundedArray(u8, 32) = .{ .buffer = undefined },
exit: ?u8 = null,
pub fn init(allocator: std.mem.Allocator, tty: *Tty, choices: *Choices, options: Options) !TtyInterface {
var self = TtyInterface{
.allocator = allocator,
.tty = tty,
.choices = choices,
.options = options,
};
if (options.init_search) |q| {
try self.search.appendSlice(q);
}
self.cursor = self.search.len;
try self.updateSearch();
return self;
}
pub fn deinit(self: *TtyInterface) void {
self.tty.deinit();
}
pub fn run(self: *TtyInterface) !u8 {
try self.draw();
while (true) {
while (true) {
while (!(try self.tty.inputReady(null, true))) {
try self.draw();
}
var s = try self.tty.getChar();
try self.handleInput(&[_]u8{s}, false);
if (self.exit) |rc| {
return rc;
}
try self.draw();
if (!(try self.tty.inputReady(if (self.ambiguous_key_pending) config.KEYTIMEOUT else 0, false))) {
break;
}
}
if (self.ambiguous_key_pending) {
try self.handleInput("", true);
if (self.exit) |rc| {
return rc;
}
}
try self.update();
}
return self.exit orelse unreachable;
}
fn update(self: *TtyInterface) !void {
if (!std.mem.eql(u8, self.last_search.slice(), self.search.slice())) {
try self.updateSearch();
try self.draw();
}
}
fn updateSearch(self: *TtyInterface) !void {
try self.choices.search(self.search.constSlice());
try self.last_search.replaceRange(0, self.last_search.len, self.search.constSlice());
}
fn draw(self: *TtyInterface) !void {
const tty = self.tty;
const choices = self.choices;
const options = self.options;
const num_lines = options.num_lines;
var start: usize = 0;
const available = choices.numResults();
const current_selection = choices.selection;
if (current_selection + options.scrolloff >= num_lines) {
start = current_selection + options.scrolloff - num_lines + 1;
if (start + num_lines >= available and available > 0) {
start = available - num_lines;
}
}
tty.setCol(0);
tty.printf("{s}{s}", .{ options.prompt, self.search.constSlice() });
tty.clearLine();
if (options.show_info) {
tty.printf("\n[{d}/{d}]", .{ available, choices.numChoices() });
tty.clearLine();
}
var i: usize = start;
while (i < start + num_lines) : (i += 1) {
tty.printf("\n", .{});
tty.clearLine();
if (choices.getResult(i)) |result| {
self.drawMatch(result.str, i == current_selection);
}
}
if (num_lines > 0 or options.show_info) {
tty.moveUp(num_lines + @boolToInt(options.show_info));
}
tty.setCol(0);
_ = try tty.buffered_writer.writer().write(options.prompt);
_ = try tty.buffered_writer.writer().write(self.search.slice()[0..self.cursor]);
tty.flush();
}
fn drawMatch(self: *TtyInterface, choice: []const u8, selected: bool) void {
const tty = self.tty;
const options = self.options;
const search = self.search;
const n = search.len;
var positions: [match.MAX_LEN]usize = undefined;
var i: usize = 0;
while (i < n + 1 and i < match.MAX_LEN) : (i += 1) {
positions[i] = std.math.maxInt(usize);
}
var score = match.matchPositions(self.allocator, search.constSlice(), choice, &positions);
if (options.show_scores) {
if (score == match.SCORE_MIN) {
tty.printf("( ) ", .{});
} else if (score == match.SCORE_MAX) {
tty.printf("(exact) ", .{});
} else {
tty.printf("({d:5.2}) ", .{score});
}
}
if (self.choices.selections.contains(choice)) {
tty.setBold();
}
if (selected) {
if (config.TTY_SELECTION_UNDERLINE != 0) {
tty.setUnderline();
} else {
tty.setInvert();
}
}
tty.setWrap(false);
var p: usize = 0;
for (choice) |c, k| {
if (positions[p] == k) {
tty.setFg(config.TTY_COLOR_HIGHLIGHT);
p += 1;
} else {
tty.setFg(Tty.COLOR_NORMAL);
}
if (c == '\n') {
tty.putc(' ');
} else {
tty.putc(c);
}
}
tty.setWrap(true);
tty.setNormal();
}
fn clear(self: *TtyInterface) void {
var tty = self.tty;
tty.setCol(0);
var line: usize = 0;
while (line < self.options.num_lines + @as(usize, if (self.options.show_info) 1 else 0)) : (line += 1) {
tty.newline();
}
tty.clearLine();
if (self.options.num_lines > 0) {
tty.moveUp(line);
}
tty.flush();
}
const Action = struct {
fn exit(tty_interface: *TtyInterface) !void {
tty_interface.clear();
tty_interface.exit = 1;
}
fn delChar(tty_interface: *TtyInterface) !void {
if (tty_interface.cursor == 0) {
return;
}
var search = tty_interface.search.slice();
while (tty_interface.cursor > 0) {
tty_interface.cursor -= 1;
_ = tty_interface.search.orderedRemove(tty_interface.cursor);
if (isBoundary(search[tty_interface.cursor])) break;
}
}
fn delCharOrExit(tty_interface: *TtyInterface) !void {
if (tty_interface.cursor < tty_interface.search.len) {
_ = tty_interface.search.orderedRemove(tty_interface.cursor);
} else if (tty_interface.search.len == 0) {
try exit(tty_interface);
}
}
fn delWord(tty_interface: *TtyInterface) !void {
var search = tty_interface.search.constSlice();
var i: usize = tty_interface.cursor;
while (i > 0 and std.ascii.isSpace(search[i - 1])) : (i -= 1) {}
while (i > 0 and !std.ascii.isSpace(search[i - 1])) : (i -= 1) {}
tty_interface.search.len = i;
tty_interface.cursor = i;
}
fn delAll(tty_interface: *TtyInterface) !void {
tty_interface.search.len = 0;
tty_interface.cursor = 0;
}
fn emit(tty_interface: *TtyInterface) !void {
try tty_interface.update();
tty_interface.clear();
const choices = tty_interface.choices;
if (choices.selections.count() == 0) {
if (choices.getResult(choices.selection)) |selection| {
try stdout.print("{s}\n", .{selection.str});
} else {
// No match, output the query instead
try stdout.print("{s}\n", .{tty_interface.search.slice()});
}
} else {
var it = choices.selections.keyIterator();
while (it.next()) |selection| {
try stdout.print("{s}\n", .{selection.*});
}
}
tty_interface.exit = 0;
}
fn next(tty_interface: *TtyInterface) !void {
try tty_interface.update();
tty_interface.choices.next();
}
fn prev(tty_interface: *TtyInterface) !void {
try tty_interface.update();
tty_interface.choices.prev();
}
fn beginning(tty_interface: *TtyInterface) !void {
tty_interface.cursor = 0;
}
fn end(tty_interface: *TtyInterface) !void {
tty_interface.cursor = tty_interface.search.len;
}
fn left(tty_interface: *TtyInterface) !void {
if (tty_interface.cursor > 0) {
tty_interface.cursor -= 1;
}
}
fn right(tty_interface: *TtyInterface) !void {
if (tty_interface.cursor < tty_interface.search.len) {
tty_interface.cursor += 1;
}
}
fn pageUp(tty_interface: *TtyInterface) !void {
try tty_interface.update();
var choices = tty_interface.choices;
var i: usize = 0;
while (i < tty_interface.options.num_lines and choices.selection > 0) : (i += 1) {
choices.next();
}
}
fn pageDown(tty_interface: *TtyInterface) !void {
try tty_interface.update();
var choices = tty_interface.choices;
const available = choices.numResults();
var i: usize = 0;
while (i < tty_interface.options.num_lines and choices.selection < available - 1) : (i += 1) {
choices.next();
}
}
fn select(tty_interface: *TtyInterface) !void {
try tty_interface.update();
const choices = tty_interface.choices;
if (choices.getResult(choices.selection)) |selection| {
if (choices.selections.contains(selection.str)) {
choices.deselect(selection.str);
} else {
try choices.select(selection.str);
}
choices.next();
}
}
fn ignore(_: *TtyInterface) !void {}
};
const KeyBinding = struct {
key: []const u8,
action: fn (tty_interface: *TtyInterface) anyerror!void,
};
fn keyCtrl(key: u8) []const u8 {
return &[_]u8{key - '@'};
}
const keybindings = [_]KeyBinding{
.{ .key = "\x1b", .action = Action.exit }, // ESC
.{ .key = "\x7f", .action = Action.delChar }, // DEL
.{ .key = keyCtrl('C'), .action = Action.exit },
.{ .key = keyCtrl('D'), .action = Action.delCharOrExit },
.{ .key = keyCtrl('G'), .action = Action.exit },
.{ .key = keyCtrl('M'), .action = Action.emit },
.{ .key = keyCtrl('N'), .action = Action.next },
.{ .key = keyCtrl('T'), .action = Action.select },
.{ .key = keyCtrl('P'), .action = Action.prev },
.{ .key = keyCtrl('J'), .action = Action.next },
.{ .key = keyCtrl('K'), .action = Action.prev },
.{ .key = keyCtrl('H'), .action = Action.delChar }, // Backspace
.{ .key = keyCtrl('U'), .action = Action.delAll },
.{ .key = keyCtrl('W'), .action = Action.delWord },
.{ .key = keyCtrl('A'), .action = Action.beginning },
.{ .key = keyCtrl('E'), .action = Action.end },
.{ .key = keyCtrl('B'), .action = Action.left },
.{ .key = keyCtrl('F'), .action = Action.right },
.{ .key = "\x1bOD", .action = Action.left },
.{ .key = "\x1b[D", .action = Action.left },
.{ .key = "\x1bOC", .action = Action.right },
.{ .key = "\x1b[C", .action = Action.right },
.{ .key = "\x1b[1~", .action = Action.beginning }, // HOME
.{ .key = "\x1b[H", .action = Action.beginning }, // HOME
.{ .key = "\x1b[4~", .action = Action.end }, // END
.{ .key = "\x1b[F", .action = Action.end }, // END
.{ .key = "\x1bOA", .action = Action.prev }, // UP
.{ .key = "\x1b[A", .action = Action.prev }, // UP
.{ .key = "\x1bOB", .action = Action.next }, // DOWN
.{ .key = "\x1b[B", .action = Action.next }, // DOWN
.{ .key = <KEY>", .action = Action.pageUp },
.{ .key = <KEY>", .action = Action.pageDown },
.{ .key = <KEY>", .action = Action.ignore },
.{ .key = <KEY>", .action = Action.ignore },
};
fn isPrintOrUnicode(c: u8) bool {
return std.ascii.isPrint(c) or (c & (1 << 7)) != 0;
}
fn isBoundary(c: u8) bool {
return (~c & (1 << 7)) != 0 or (c & (1 << 6)) != 0;
}
fn handleInput(self: *TtyInterface, s: []const u8, handle_ambiguous_key: bool) !void {
self.ambiguous_key_pending = false;
try self.input.appendSlice(s);
// Figure out if we have completed a keybinding and whether we're in
// the middle of one (both can happen, because of Esc)
var found_keybinding: ?KeyBinding = null;
var in_middle = false;
for (keybindings) |k| {
if (std.mem.eql(u8, self.input.slice(), k.key)) {
found_keybinding = k;
} else if (std.mem.startsWith(u8, k.key, self.input.slice())) {
in_middle = true;
}
}
// If we have an unambiguous keybinding, run it.
if (found_keybinding) |keybinding| {
if (!in_middle or handle_ambiguous_key) {
try keybinding.action(self);
self.input.len = 0;
return;
}
}
// We could have a complete keybinding, or could be in the middle of
// one. We'll need to wait a few milliseconds to find out.
if (found_keybinding != null and in_middle) {
self.ambiguous_key_pending = true;
return;
}
// Wait for more if we are in the middle of a keybinding
if (in_middle) {
return;
}
// No matching keybinding, add to search
for (self.input.constSlice()) |c| {
if (isPrintOrUnicode(c)) {
try self.search.insertSlice(self.cursor, &[_]u8{c});
self.cursor += 1;
}
}
self.input.len = 0;
} | src/TtyInterface.zig |
const std = @import("std");
usingnamespace @import("kira").log;
const kira_utils = @import("kira").utils;
const kira_glfw = @import("kira").glfw;
const kira_gl = @import("kira").gl;
const kira_window = @import("kira").window;
const kira_input = @import("kira").input;
var window_running = false;
var targetfps: f64 = 1.0 / 60.0;
var input = kira_input.Info{};
fn closeCallback(handle: ?*c_void) void {
window_running = false;
}
fn resizeCallback(handle: ?*c_void, w: i32, h: i32) void {
kira_gl.viewport(0, 0, w, h);
}
fn keyboardCallback(handle: ?*c_void, key: i32, sc: i32, ac: i32, mods: i32) void {
input.handleKeyboard(key, ac) catch unreachable;
}
pub fn main() !void {
try kira_glfw.init();
defer kira_glfw.deinit();
kira_glfw.resizable(false);
kira_glfw.initGLProfile();
var window = kira_window.Info{};
var frametime = kira_window.FrameTime{};
var fps = kira_window.FpsDirect{};
window.title = "Primitive window creation and I/O Example";
window.callbacks.close = closeCallback;
window.callbacks.resize = resizeCallback;
window.callbacks.keyinp = keyboardCallback;
const sw = kira_glfw.getScreenWidth();
const sh = kira_glfw.getScreenHeight();
window.position.x = @divTrunc((sw - window.size.width), 2);
window.position.y = @divTrunc((sh - window.size.height), 2);
try window.create(false);
defer window.destroy() catch unreachable;
input.bindKey('A') catch |err| {
if (err == kira_input.Error.NoEmptyBinding) {
input.clearAllBindings();
try input.bindKey('A');
} else return err;
};
const keyA = try input.keyStatePtr('A');
kira_glfw.makeContext(window.handle);
kira_glfw.vsync(true);
kira_gl.init();
defer kira_gl.deinit();
window_running = true;
while (window_running) {
frametime.start();
std.log.debug("Key A: {}", .{keyA});
input.handle();
kira_gl.clearColour(0.1, 0.1, 0.1, 1.0);
kira_gl.clearBuffers(kira_gl.BufferBit.colour);
defer {
kira_glfw.sync(window.handle);
kira_glfw.processEvents();
frametime.stop();
frametime.sleep(targetfps);
fps = fps.calculate(frametime);
std.log.notice("FPS: {}", .{fps.fps});
}
}
} | examples/primitive-window.zig |
const macro = @import("pspmacros.zig");
comptime {
asm (macro.import_module_start("sceUtility", "0x40010000", "56"));
asm (macro.import_function("sceUtility", "0xC492F751", "sceUtilityGameSharingInitStart"));
asm (macro.import_function("sceUtility", "0xEFC6F80F", "sceUtilityGameSharingShutdownStart"));
asm (macro.import_function("sceUtility", "0x7853182D", "sceUtilityGameSharingUpdate"));
asm (macro.import_function("sceUtility", "0x946963F3", "sceUtilityGameSharingGetStatus"));
asm (macro.import_function("sceUtility", "0x3AD50AE7", "sceNetplayDialogInitStart"));
asm (macro.import_function("sceUtility", "0xBC6B6296", "sceNetplayDialogShutdownStart"));
asm (macro.import_function("sceUtility", "0x417BED54", "sceNetplayDialogUpdate"));
asm (macro.import_function("sceUtility", "0xB6CEE597", "sceNetplayDialogGetStatus"));
asm (macro.import_function("sceUtility", "0x4DB1E739", "sceUtilityNetconfInitStart"));
asm (macro.import_function("sceUtility", "0xF88155F6", "sceUtilityNetconfShutdownStart"));
asm (macro.import_function("sceUtility", "0x91E70E35", "sceUtilityNetconfUpdate"));
asm (macro.import_function("sceUtility", "0x6332AA39", "sceUtilityNetconfGetStatus"));
asm (macro.import_function("sceUtility", "0x50C4CD57", "sceUtilitySavedataInitStart"));
asm (macro.import_function("sceUtility", "0x9790B33C", "sceUtilitySavedataShutdownStart"));
asm (macro.import_function("sceUtility", "0xD4B95FFB", "sceUtilitySavedataUpdate"));
asm (macro.import_function("sceUtility", "0x8874DBE0", "sceUtilitySavedataGetStatus"));
asm (macro.import_function("sceUtility", "0x2995D020", "sceUtility_2995D020"));
asm (macro.import_function("sceUtility", "0xB62A4061", "sceUtility_B62A4061"));
asm (macro.import_function("sceUtility", "0xED0FAD38", "sceUtility_ED0FAD38"));
asm (macro.import_function("sceUtility", "0x88BC7406", "sceUtility_88BC7406"));
asm (macro.import_function("sceUtility", "0x2AD8E239", "sceUtilityMsgDialogInitStart"));
asm (macro.import_function("sceUtility", "0x67AF3428", "sceUtilityMsgDialogShutdownStart"));
asm (macro.import_function("sceUtility", "0x95FC253B", "sceUtilityMsgDialogUpdate"));
asm (macro.import_function("sceUtility", "0x9A1C91D7", "sceUtilityMsgDialogGetStatus"));
asm (macro.import_function("sceUtility", "0xF6269B82", "sceUtilityOskInitStart"));
asm (macro.import_function("sceUtility", "0x3DFAEBA9", "sceUtilityOskShutdownStart"));
asm (macro.import_function("sceUtility", "0x4B85C861", "sceUtilityOskUpdate"));
asm (macro.import_function("sceUtility", "0xF3F76017", "sceUtilityOskGetStatus"));
asm (macro.import_function("sceUtility", "0x45C18506", "sceUtilitySetSystemParamInt"));
asm (macro.import_function("sceUtility", "0x41E30674", "sceUtilitySetSystemParamString"));
asm (macro.import_function("sceUtility", "0xA5DA2406", "sceUtilityGetSystemParamInt"));
asm (macro.import_function("sceUtility", "0x34B78343", "sceUtilityGetSystemParamString"));
asm (macro.import_function("sceUtility", "0x5EEE6548", "sceUtilityCheckNetParam"));
asm (macro.import_function("sceUtility", "0x434D4B3A", "sceUtilityGetNetParam"));
asm (macro.import_function("sceUtility", "0x1579a159", "sceUtilityLoadNetModule"));
asm (macro.import_function("sceUtility", "0x64d50c56", "sceUtilityUnloadNetModule"));
asm (macro.import_function("sceUtility", "0xC629AF26", "sceUtilityLoadAvModule"));
asm (macro.import_function("sceUtility", "0xF7D8D092", "sceUtilityUnloadAvModule"));
asm (macro.import_function("sceUtility", "0x0D5BC6D2", "sceUtilityLoadUsbModule"));
asm (macro.import_function("sceUtility", "0x4928BD96", "sceUtilityMsgDialogAbort"));
asm (macro.import_function("sceUtility", "0x05AFB9E4", "sceUtilityHtmlViewerUpdate"));
asm (macro.import_function("sceUtility", "0xBDA7D894", "sceUtilityHtmlViewerGetStatus"));
asm (macro.import_function("sceUtility", "0xCDC3AA41", "sceUtilityHtmlViewerInitStart"));
asm (macro.import_function("sceUtility", "0xF5CE1134", "sceUtilityHtmlViewerShutdownStart"));
asm (macro.import_function("sceUtility", "0x2A2B3DE0", "sceUtilityLoadModule"));
asm (macro.import_function("sceUtility", "0xE49BFE92", "sceUtilityUnloadModule"));
asm (macro.import_function("sceUtility", "0x0251B134", "sceUtilityScreenshotInitStart"));
asm (macro.import_function("sceUtility", "0xF9E0008C", "sceUtilityScreenshotShutdownStart"));
asm (macro.import_function("sceUtility", "0xAB083EA9", "sceUtilityScreenshotUpdate"));
asm (macro.import_function("sceUtility", "0xD81957B7", "sceUtilityScreenshotGetStatus"));
asm (macro.import_function("sceUtility", "0x86A03A27", "sceUtilityScreenshotContStart"));
asm (macro.import_function("sceUtility", "0x16D02AF0", "sceUtilityNpSigninInitStart"));
asm (macro.import_function("sceUtility", "0xE19C97D6", "sceUtilityNpSigninShutdownStart"));
asm (macro.import_function("sceUtility", "0xF3FBC572", "sceUtilityNpSigninUpdate"));
asm (macro.import_function("sceUtility", "0x86ABDB1B", "sceUtilityNpSigninGetStatus"));
} | src/psp/nids/psputility.zig |
const std = @import("std");
const nvg = @import("nanovg");
pub const geometry = @import("geometry.zig");
const Rect = geometry.Rect;
const Point = geometry.Point;
usingnamespace @import("event.zig");
pub const Timer = @import("Timer.zig");
pub const Application = @import("Application.zig");
pub const Window = @import("Window.zig");
pub const Widget = @import("Widget.zig");
pub const Panel = @import("widgets/Panel.zig");
pub const Label = @import("widgets/Label.zig");
pub const Button = @import("widgets/Button.zig");
pub const RadioButton = @import("widgets/RadioButton.zig");
pub const TextBox = @import("widgets/TextBox.zig");
pub const Toolbar = @import("widgets/Toolbar.zig");
pub const Slider = @import("widgets/Slider.zig").Slider;
pub const Spinner = @import("widgets/Spinner.zig").Spinner;
pub const ListView = @import("widgets/ListView.zig");
pub const Scrollbar = @import("widgets/Scrollbar.zig");
const ThemeColors = struct {
background: nvg.Color,
shadow: nvg.Color,
light: nvg.Color,
border: nvg.Color,
select: nvg.Color,
focus: nvg.Color,
};
pub var theme_colors: ThemeColors = undefined;
pub var grid_image: nvg.Image = undefined;
fn defaultColorTheme() ThemeColors {
return .{
.background = nvg.rgb(224, 224, 224),
.shadow = nvg.rgb(170, 170, 170),
.light = nvg.rgb(255, 255, 255),
.border = nvg.rgb(85, 85, 85),
.select = nvg.rgba(0, 120, 247, 102),
.focus = nvg.rgb(85, 160, 230),
};
}
pub fn init(vg: nvg) void {
theme_colors = defaultColorTheme();
grid_image = vg.createImageRGBA(2, 2, .{ .repeat_x = true, .repeat_y = true, .nearest = true }, &.{
0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
});
}
pub fn deinit(vg: nvg) void {
vg.deleteImage(grid_image);
}
pub fn pixelsToPoints(pixel_size: f32) f32 {
return pixel_size * 96.0 / 72.0;
}
pub fn drawPanel(vg: nvg, x: f32, y: f32, w: f32, h: f32, depth: f32, hovered: bool, pressed: bool) void {
if (w <= 0 or h <= 0) return;
var color_bg = theme_colors.background;
var color_shadow = theme_colors.shadow;
var color_light = theme_colors.light;
if (pressed) {
color_bg = nvg.rgb(204, 204, 204);
color_shadow = theme_colors.background;
color_light = theme_colors.shadow;
} else if (hovered) {
color_bg = nvg.rgb(240, 240, 240);
}
// background
vg.beginPath();
vg.rect(x, y, w, h);
vg.fillColor(color_bg);
vg.fill();
// shadow
vg.beginPath();
vg.moveTo(x, y + h);
vg.lineTo(x + w, y + h);
vg.lineTo(x + w, y);
vg.lineTo(x + w - depth, y + depth);
vg.lineTo(x + w - depth, y + h - depth);
vg.lineTo(x + depth, y + h - depth);
vg.closePath();
vg.fillColor(color_shadow);
vg.fill();
// light
vg.beginPath();
vg.moveTo(x + w, y);
vg.lineTo(x, y);
vg.lineTo(x, y + h);
vg.lineTo(x + depth, y + h - depth);
vg.lineTo(x + depth, y + depth);
vg.lineTo(x + w - depth, y + depth);
vg.closePath();
vg.fillColor(color_light);
vg.fill();
}
pub fn drawPanelInset(vg: nvg, x: f32, y: f32, w: f32, h: f32, depth: f32) void {
if (w <= 0 or h <= 0) return;
var color_shadow = theme_colors.shadow;
var color_light = theme_colors.light;
// light
vg.beginPath();
vg.moveTo(x, y + h);
vg.lineTo(x + w, y + h);
vg.lineTo(x + w, y);
vg.lineTo(x + w - depth, y + depth);
vg.lineTo(x + w - depth, y + h - depth);
vg.lineTo(x + depth, y + h - depth);
vg.closePath();
vg.fillColor(color_light);
vg.fill();
// shadow
vg.beginPath();
vg.moveTo(x + w, y);
vg.lineTo(x, y);
vg.lineTo(x, y + h);
vg.lineTo(x + depth, y + h - depth);
vg.lineTo(x + depth, y + depth);
vg.lineTo(x + w - depth, y + depth);
vg.closePath();
vg.fillColor(color_shadow);
vg.fill();
}
pub fn drawSmallArrowUp(vg: nvg) void { // size: 6x6
vg.beginPath();
vg.moveTo(3, 1);
vg.lineTo(0, 4);
vg.lineTo(6, 4);
vg.closePath();
vg.fillColor(nvg.rgb(0, 0, 0));
vg.fill();
}
pub fn drawSmallArrowDown(vg: nvg) void { // size: 6x6
vg.beginPath();
vg.moveTo(3, 5);
vg.lineTo(0, 2);
vg.lineTo(6, 2);
vg.closePath();
vg.fillColor(nvg.rgb(0, 0, 0));
vg.fill();
}
pub fn drawSmallArrowLeft(vg: nvg) void {
vg.beginPath();
vg.moveTo(1, 3);
vg.lineTo(4, 0);
vg.lineTo(4, 6);
vg.closePath();
vg.fillColor(nvg.rgb(0, 0, 0));
vg.fill();
}
pub fn drawSmallArrowRight(vg: nvg) void {
vg.beginPath();
vg.moveTo(5, 3);
vg.lineTo(2, 0);
vg.lineTo(2, 6);
vg.closePath();
vg.fillColor(nvg.rgb(0, 0, 0));
vg.fill();
}
pub const Orientation = enum(u1) {
horizontal,
vertical,
};
pub const TextAlignment = enum(u8) {
left,
center,
right,
}; | src/gui/gui.zig |
const prot = @import("protocols.zig");
const Window = @import("window.zig").Window;
const XdgConfiguration = @import("window.zig").XdgConfiguration;
const edge = prot.xdg_toplevel_resize_edge;
pub const Resize = struct {
window: *Window,
window_x: i32,
window_y: i32,
pointer_x: f64,
pointer_y: f64,
width: i32,
height: i32,
direction: u32,
pub fn resize(self: Resize, pointer_x: f64, pointer_y: f64) !void {
const window = self.window;
const client = window.client;
const xdg_surface_id = window.xdg_surface_id orelse return;
const xdg_surface = client.context.get(xdg_surface_id) orelse return;
const xdg_toplevel_id = window.xdg_toplevel_id orelse return;
const xdg_toplevel = client.context.get(xdg_toplevel_id) orelse return;
var state: [2]u32 = [_]u32{
@enumToInt(prot.xdg_toplevel_state.activated),
@enumToInt(prot.xdg_toplevel_state.resizing),
};
try prot.xdg_toplevel_send_configure(xdg_toplevel, self.newWidth(pointer_x), self.newHeight(pointer_y), &state);
try prot.xdg_surface_send_configure(xdg_surface, client.nextSerial());
}
fn newWidth(self: Resize, pointer_x: f64) i32 {
var direction = @intToEnum(edge, self.direction);
var dx = switch (direction) {
edge.bottom_right => pointer_x - self.pointer_x,
edge.right => pointer_x - self.pointer_x,
edge.top_right => pointer_x - self.pointer_x,
edge.bottom_left => self.pointer_x - pointer_x,
edge.left => self.pointer_x - pointer_x,
edge.top_left => self.pointer_x - pointer_x,
else => 0,
};
return self.width + @floatToInt(i32, dx);
}
fn newHeight(self: Resize, pointer_y: f64) i32 {
var direction = @intToEnum(edge, self.direction);
var dy = switch (direction) {
edge.bottom_right => pointer_y - self.pointer_y,
edge.bottom => pointer_y - self.pointer_y,
edge.bottom_left => pointer_y - self.pointer_y,
edge.top_right => self.pointer_y - pointer_y,
edge.top => self.pointer_y - pointer_y,
edge.top_left => self.pointer_y - pointer_y,
else => 0,
};
return self.height + @floatToInt(i32, dy);
}
pub fn offsetX(self: Resize, old_buffer_width: i32, new_buffer_width: i32) i32 {
var direction = @intToEnum(edge, self.direction);
return switch (direction) {
edge.bottom_left => old_buffer_width - new_buffer_width,
edge.left => old_buffer_width - new_buffer_width,
edge.top_left => old_buffer_width - new_buffer_width,
else => 0,
};
}
pub fn offsetY(self: Resize, old_buffer_height: i32, new_buffer_height: i32) i32 {
var direction = @intToEnum(edge, self.direction);
return switch (direction) {
edge.top_right => old_buffer_height - new_buffer_height,
edge.top => old_buffer_height - new_buffer_height,
edge.top_left => old_buffer_height - new_buffer_height,
else => 0,
};
}
}; | src/resize.zig |
const std = @import("std");
const os = std.os;
const linux = std.os.linux;
// const file = std.file;
const AutoHashMap = std.AutoHashMap;
const c = @cImport({
@cInclude("sys/types.h");
@cInclude("sys/stat.h");
@cInclude("fcntl.h");
@cInclude("stdlib.h");
@cInclude("unistd.h");
@cInclude("systemd/sd-bus.h");
@cInclude("systemd/sd-login.h");
});
pub const Logind = struct {
fd: c_int,
bus: *c.struct_sd_bus,
session_path: [256]u8,
session_id: [*c]u8,
devices: AutoHashMap(c_int, []u8),
pub fn init(self: *Logind) !void {
var session_path = try getSessionPath(self.bus, self.session_id);
std.mem.copy(u8, self.session_path[0..std.mem.len(session_path)], std.mem.span(session_path));
try activate(self.bus, self.session_path);
try takeControl(self.bus, self.session_path);
}
pub fn deinit(self: *Logind) void {
releaseControl(self.bus, self.session_path) catch |e| {};
c.free(self.session_id);
// var it = self.devices.iterator();
// while(it.next()) |device| {
// std.heap.c_allocator.free(device.value);
// }
// self.devices.deinit();
}
pub fn open(self: *Logind, path: [*:0]const u8) !i32 {
var path_copy = try std.heap.c_allocator.alloc(u8, 256);
std.mem.copy(u8, path_copy[0..], std.mem.span(path));
var fd = try takeDevice(self.bus, self.session_path, path);
_ = try self.devices.put(fd, path_copy);
return fd;
}
pub fn close(self: *Logind, fd: i32) !void {
var x = try releaseDevice(self.bus, self.session_path, fd);
var y = linux.close(fd);
if (self.devices.fetchRemove(fd)) |path| {
std.heap.c_allocator.free(path.value);
}
}
};
pub fn create() !Logind {
var session_id = try pidGetSession();
var bus = try busDefaultSystem();
var fd = try busGetFd(bus);
return Logind{
.fd = fd,
.bus = bus,
.session_id = session_id,
.session_path = [_]u8{0} ** 256,
.devices = AutoHashMap(c_int, []u8).init(std.heap.c_allocator),
};
}
fn pidGetSession() ![*c]u8 {
var pid = linux.getpid();
var session: [*c]u8 = undefined;
var err = c.sd_pid_get_session(pid, &session);
if (err < 0) {
return error.NotPartOfLoginSession;
}
return session;
}
fn busDefaultSystem() !*c.struct_sd_bus {
var b: *c.struct_sd_bus = undefined;
var err = c.sd_bus_default_system(@ptrCast([*c]?*c.struct_sd_bus, &b));
if (err < 0) {
return error.GetDefaultSystemBusFailed;
}
return b;
}
fn busGetFd(bus: *c.struct_sd_bus) !i32 {
var fd = c.sd_bus_get_fd(bus);
if (fd < 0) {
return error.GetBusFDFailed;
}
return fd;
}
fn getSessionPath(bus: *c.struct_sd_bus, session_id: [*c]u8) ![*c]u8 {
var msg: *c.sd_bus_message = undefined;
var err: c.sd_bus_error = c.sd_bus_error{
.name = undefined,
.message = undefined,
._need_free = 0,
};
var res = c.sd_bus_call_method(bus, "org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", "GetSession", &err, @ptrCast([*c]?*c.struct_sd_bus_message, &msg), "s", &session_id[0]);
defer {
c.sd_bus_error_free(&err);
var x = c.sd_bus_message_unref(msg);
}
if (res < 0) {
return error.GetSessionFailed;
}
var session_path: [*c]u8 = undefined;
res = c.sd_bus_message_read(msg, "o", &session_path);
if (res < 0) {
return error.MessageReadFailed;
}
return session_path;
}
fn activate(bus: *c.struct_sd_bus, session_path: [256]u8) !void {
var msg: ?*c.sd_bus_message = null;
var err: c.sd_bus_error = c.sd_bus_error{
.name = undefined,
.message = undefined,
._need_free = 0,
};
var res = c.sd_bus_call_method(
bus,
"org.freedesktop.login1",
session_path[0..],
"org.freedesktop.login1.Session",
"Activate",
&err,
@ptrCast([*c]?*c.struct_sd_bus_message, &msg),
"",
);
defer {
c.sd_bus_error_free(&err);
_ = c.sd_bus_message_unref(msg);
}
if (res < 0) {
return error.ActivateFailed;
}
return;
}
fn takeControl(bus: *c.struct_sd_bus, session_path: [256]u8) !void {
var msg: ?*c.sd_bus_message = null;
var err: c.sd_bus_error = c.sd_bus_error{
.name = undefined,
.message = undefined,
._need_free = 0,
};
var res = c.sd_bus_call_method(
bus,
"org.freedesktop.login1",
session_path[0..],
"org.freedesktop.login1.Session",
"TakeControl",
&err,
@ptrCast([*c]?*c.struct_sd_bus_message, &msg),
"b",
false,
);
defer {
c.sd_bus_error_free(&err);
_ = c.sd_bus_message_unref(msg);
}
if (res < 0) {
return error.TakeControlFailed;
}
return;
}
fn releaseControl(bus: *c.struct_sd_bus, session_path: [256]u8) !void {
var msg: *c.sd_bus_message = undefined;
var err: c.sd_bus_error = c.sd_bus_error{
.name = undefined,
.message = undefined,
._need_free = 0,
};
var res = c.sd_bus_call_method(
bus,
"org.freedesktop.login1",
session_path[0..],
"org.freedesktop.login1.Session",
"ReleaseControl",
&err,
@ptrCast([*c]?*c.struct_sd_bus_message, &msg),
"",
);
defer {
c.sd_bus_error_free(&err);
_ = c.sd_bus_message_unref(msg);
}
if (res < 0) {
return error.ReleaseControlFailed;
}
return;
}
fn takeDevice(bus: *c.struct_sd_bus, session_path: [256]u8, path: [*:0]const u8) !i32 {
var msg: *c.sd_bus_message = undefined;
var err: c.sd_bus_error = c.sd_bus_error{
.name = undefined,
.message = undefined,
._need_free = 0,
};
var st: os.Stat = undefined;
var res = linux.stat(path, &st);
if (res < 0) {
return error.StatFailed;
}
var rs = c.sd_bus_call_method(
bus,
"org.freedesktop.login1",
session_path[0..session_path.len],
"org.freedesktop.login1.Session",
"TakeDevice",
&err,
@ptrCast([*c]?*c.struct_sd_bus_message, &msg),
"uu",
dev_major(st.rdev),
dev_minor(st.rdev),
);
defer {
c.sd_bus_error_free(&err);
_ = c.sd_bus_message_unref(msg);
}
if (rs < 0) {
return error.TakeDeviceFailed;
}
var fd: c_int = -1;
var paused: c_int = 0;
rs = c.sd_bus_message_read(msg, "hb", &fd, &paused);
if (rs < 0) {
return error.MessageReadFailed;
}
// fd = c.fcntl(fd, c.F_DUPFD_CLOEXEC, 0);
fd = c.dup(fd);
if (fd < 0) {
return error.FcntlFailed;
}
return fd;
}
fn releaseDevice(bus: *c.struct_sd_bus, session_path: [256]u8, fd: i32) !i32 {
var msg: *c.sd_bus_message = undefined;
var err: c.sd_bus_error = c.sd_bus_error{
.name = undefined,
.message = undefined,
._need_free = 0,
};
var st: os.Stat = undefined;
var res = linux.fstat(fd, &st);
if (res < 0) {
return error.StatFailed;
}
var rs = c.sd_bus_call_method(
bus,
"org.freedesktop.login1",
session_path[0..session_path.len],
"org.freedesktop.login1.Session",
"ReleaseDevice",
&err,
@ptrCast([*c]?*c.struct_sd_bus_message, &msg),
"uu",
dev_major(st.rdev),
dev_minor(st.rdev),
);
defer {
c.sd_bus_error_free(&err);
// _ = c.sd_bus_message_unref(msg);
}
if (rs < 0) {
return error.ReleaseDeviceFailed;
}
return fd;
}
pub fn changeVt(bus: *c.struct_sd_bus, vt: i32) !void {
var msg: *c.sd_bus_message = undefined;
var err: c.sd_bus_error = c.sd_bus_error{
.name = undefined,
.message = undefined,
._need_free = 0,
};
var res = c.sd_bus_call_method(
bus,
"org.freedesktop.login1",
"/org/freedesktop/login1/seat/self",
"org.freedesktop.login1.Seat",
"SwitchTo",
&err,
@ptrCast([*c]?*c.struct_sd_bus_message, &msg),
"u",
vt,
);
defer {
c.sd_bus_error_free(&err);
_ = c.sd_bus_message_unref(msg);
}
if (res < 0) {
return error.ChangeVTFailed;
}
return;
}
fn dev_major(arg___dev: c.dev_t) callconv(.C) c_ulong {
var __dev = arg___dev;
var __major: c_ulong = undefined;
__major = @bitCast(c_uint, @truncate(c_uint, ((__dev & @bitCast(c.dev_t, @as(c_ulong, @as(c_uint, 1048320)))) >> @intCast(@import("std").math.Log2Int(c_ulong), 8))));
__major |= ((__dev & @bitCast(c.dev_t, @as(c_ulong, 18446726481523507200))) >> @intCast(@import("std").math.Log2Int(c_ulong), 32));
return __major;
}
fn dev_minor(arg___dev: c.dev_t) callconv(.C) c_ulong {
var __dev = arg___dev;
var __minor: c_ulong = undefined;
__minor = @bitCast(c_uint, @truncate(c_uint, ((__dev & @bitCast(c.dev_t, @as(c_ulong, @as(c_uint, 255)))) >> @intCast(@import("std").math.Log2Int(c_ulong), 0))));
__minor |= ((__dev & @bitCast(c.dev_t, @as(c_ulong, 17592184995840))) >> @intCast(@import("std").math.Log2Int(c_ulong), 12));
return __minor;
} | src/backend/drm/systemd.zig |
const String = @import("String.zig");
const std = @import("std");
const mem = std.mem;
const Node = @This();
name: String,
value: ?String,
refs: usize,
children: ?[]*Node,
pub const Error = error{OutOfMemory};
pub fn init(allocator: mem.Allocator, name: String, value: ?String) !*Node {
var self = try allocator.create(Node);
self.* = .{
.name = name,
.value = value,
.refs = 1,
.children = null,
};
return self;
}
pub fn ref(self: *Node) *Node {
self.refs += 1;
return self;
}
pub fn deinit(self: *Node, allocator: mem.Allocator) void {
self.refs -= 1;
if (self.refs == 0) {
self.name.deinit(allocator);
if (self.value) |v| v.deinit(allocator);
if (self.children) |children| {
for (children) |child| child.deinit(allocator);
allocator.free(children);
}
allocator.destroy(self);
}
if (self.refs < 0) unreachable;
}
pub fn writeJSON(self: *const Node, allocator: mem.Allocator, out_stream: anytype) Error!void {
var w = std.json.WriteStream(@TypeOf(out_stream), 5).init(out_stream);
var ptrToID = std.AutoHashMap(*const Node, i32).init(allocator);
defer ptrToID.deinit();
try w.beginArray();
try self._writeJSON(&w, &ptrToID);
try w.endArray();
}
fn _writeJSON(self: *const Node, w: anytype, ptrToID: *std.AutoHashMap(*const Node, i32)) Error!void {
if (self.children) |children| for (children) |child| try child._writeJSON(w, ptrToID);
var v = try ptrToID.getOrPut(self);
if (v.found_existing) return; // visited already
v.value_ptr.* = @intCast(i32, ptrToID.count() - 1);
try w.arrayElem();
try w.beginObject();
try w.objectField("name");
try w.emitString(self.name.value);
if (self.value) |value| {
try w.objectField("value");
try w.emitString(value.value);
}
if (self.children) |children| {
try w.objectField("children");
try w.beginArray();
for (children) |child| {
try w.arrayElem();
try w.emitNumber(ptrToID.get(child).?);
}
try w.endArray();
}
try w.endObject();
} | src/dsl/Node.zig |
const std = @import("std");
const stdx = @import("stdx");
const t = stdx.testing;
const stbtt = @import("stbtt");
const ttf = @import("ttf.zig");
const log = stdx.log.scoped(.ttf_test);
test "NotoColorEmoji.ttf" {
const file = std.fs.cwd().openFile("./deps/fonts/NotoColorEmoji.ttf", .{}) catch unreachable;
defer file.close();
const data = file.readToEndAlloc(t.alloc, 1024 * 1024 * 10) catch unreachable;
defer t.alloc.free(data);
var font = ttf.TTF_Font.init(t.alloc, data, 0) catch unreachable;
defer font.deinit();
// font.print_tables();
try t.expect(font.hasColorBitmap());
try t.eq(font.glyph_map_format, 12);
try t.eq(font.num_glyphs, 3378);
try t.eq(font.units_per_em, 2048);
{
const cp = std.unicode.utf8Decode("⚡") catch unreachable;
const glyph_id = font.getGlyphId(cp) catch unreachable;
try t.eq(glyph_id, 113);
const h_metrics = font.getGlyphHMetrics(glyph_id.?);
try t.eq(h_metrics.advance_width, 2550);
try t.eq(h_metrics.left_side_bearing, 0);
const bitmap = font.getGlyphColorBitmap(glyph_id.?) catch unreachable orelse unreachable;
try t.eq(bitmap.width, 136);
try t.eq(bitmap.height, 128);
try t.eq(bitmap.advance_width, 101);
try t.eq(bitmap.left_side_bearing, 0);
try t.eq(bitmap.png_data.len, 1465);
}
{
const glyph_id = font.getGlyphId(10052) catch unreachable;
try t.eq(glyph_id, 158);
}
// var cp: u21 = 1;
// while (cp < 9889) : (cp += 1) {
// if (font.get_glyph_id(cp) catch unreachable) |glyph_id| {
// const bitmap = font.get_glyph_color_bitmap(glyph_id) catch unreachable orelse continue;
// std.log.warn("{} - {}x{} {} {}", .{cp, bitmap.width, bitmap.height, bitmap.advance_width, bitmap.left_side_bearing});
// }
// }
}
test "NunitoSans-Regular.ttf" {
const file = std.fs.cwd().openFile("./deps/fonts/NunitoSans-Regular.ttf", .{}) catch unreachable;
defer file.close();
const data = file.readToEndAlloc(t.alloc, 1024 * 1024 * 10) catch unreachable;
defer t.alloc.free(data);
var font = ttf.TTF_Font.init(t.alloc, data, 0) catch unreachable;
defer font.deinit();
// font.print_tables();
try t.expect(!font.hasColorBitmap());
try t.eq(font.glyph_map_format, 4);
{
const cp = std.unicode.utf8Decode("⚡") catch unreachable;
try t.eq(font.getGlyphId(cp) catch unreachable, null);
}
{
const cp = std.unicode.utf8Decode("a") catch unreachable;
// const idx = font.get_glyph_id(cp) catch unreachable;
try t.eq(font.getGlyphId(cp) catch unreachable, 238);
}
}
test "Ubuntu-R.ttf" {
const file = std.fs.cwd().openFile("./deps/fonts/Ubuntu-R.ttf", .{}) catch unreachable;
defer file.close();
const data = file.readToEndAlloc(t.alloc, 1024 * 1024 * 10) catch unreachable;
defer t.alloc.free(data);
var font = ttf.TTF_Font.init(t.alloc, data, 0) catch unreachable;
defer font.deinit();
// font.print_tables();
try t.expect(!font.hasColorBitmap());
try t.eq(font.glyph_map_format, 4);
try t.eq(font.num_glyphs, 1264);
}
test "stbtt glyph sizing" {
// Use this test to understand how stbtt sizes glyphs.
const file = std.fs.cwd().openFile("./deps/fonts/NunitoSans-Regular.ttf", .{}) catch unreachable;
defer file.close();
const data = file.readToEndAlloc(t.alloc, 1024 * 1024 * 10) catch unreachable;
defer t.alloc.free(data);
var font = try ttf.TTF_Font.init(t.alloc, data, 0);
defer font.deinit();
var stbtt_font: stbtt.fontinfo = undefined;
stbtt.InitFont(&stbtt_font, data, 0) catch @panic("failed to load font");
var x0: c_int = 0;
var y0: c_int = 0;
var x1: c_int = 0;
var y1: c_int = 0;
var cp = std.unicode.utf8Decode("h") catch unreachable;
var glyph_id = (try font.getGlyphId(cp)).?;
stbtt.stbtt_GetGlyphBitmapBox(&stbtt_font, glyph_id, 1, 1, &x0, &y0, &x1, &y1);
log.warn("h {},{} {},{}", .{ x0, y0, x1, y1 });
cp = std.unicode.utf8Decode("Č") catch unreachable;
glyph_id = (try font.getGlyphId(cp)).?;
stbtt.stbtt_GetGlyphBitmapBox(&stbtt_font, glyph_id, 1, 1, &x0, &y0, &x1, &y1);
log.warn("Č {},{} {},{}", .{ x0, y0, x1, y1 });
const scale = font.getScaleToUserFontSize(32);
cp = std.unicode.utf8Decode("|") catch unreachable;
glyph_id = (try font.getGlyphId(cp)).?;
stbtt.stbtt_GetGlyphBitmapBox(&stbtt_font, glyph_id, scale, scale, &x0, &y0, &x1, &y1);
log.warn("{},{} {},{}", .{ x0, y0, x1, y1 });
} | graphics/src/ttf.test.zig |
const std = @import("std");
const builtin = @import("builtin");
const atoi = @import("parse.zig");
const io = std.io;
const File = std.os.File;
const Buffer = std.Buffer;
const mem = std.mem;
const warn = std.debug.warn;
const Value = struct {
question: []const u8,
value: f32
};
const QUESTIONS: []const Value = []const Value {
Value { .question = "Voer het aantal 1 centen in:\n", .value = 0.01 },
Value { .question = "Voer het aantal 2 centen in: \n", .value = 0.02 },
Value { .question = "Voer het aantal 5 centen in: \n", .value = 0.05 },
Value { .question = "Voer het aantal 10 centen in: \n", .value = 0.10 },
Value { .question = "Voer het aantal 20 centen in: \n", .value = 0.20 },
Value { .question = "Voer het aantal 50 centen in: \n", .value = 0.50 },
Value { .question = "Voer het aantal 1 euro's in: \n", .value = 1.00 },
Value { .question = "Voer het aantal 2 euro's in: \n", .value = 2.00 },
};
pub fn main() !void {
var da = std.heap.DirectAllocator.init();
const alloc = &da.allocator;
errdefer da.deinit();
const stdout: File = try io.getStdOut();
defer stdout.close();
const stdin = try io.getStdIn();
defer stdin.close();
var adapter = io.FileInStream.init(stdin);
var stream = &adapter.stream;
var buf = try Buffer.initSize(alloc, 24);
defer buf.deinit();
var ncoins: usize = 0;
var total_value: f32 = 0.0;
for(QUESTIONS) |question| {
try stdout.write(question.question);
try stream.readUntilDelimiterBuffer(&buf, '\r', 20);
var slice = buf.toSlice();
var n = try atoi.atoi(u64, slice[0..slice.len - 1]);
ncoins += n;
total_value += @intToFloat(f32, n) * question.value;
}
var ndigits = atoi.digits10(usize, ncoins);
var buffer: [8]u8 = undefined;
_ = atoi.itoa(usize, ncoins, buffer[0..ndigits]);
warn("You entered a total of {} coins\n", buffer[0..ndigits]);
warn("You entered a total value of {.2}\n", total_value);
} | zig/week1/euro.zig |
const util = @import("../sdf_util.zig");
pub const info: util.SdfInfo = .{
.name = "Symmetry",
.data_size = @sizeOf(Data),
.function_definition = "",
.enter_command_fn = enterCommand,
.exit_command_fn = exitCommand,
.sphere_bound_fn = sphereBound,
};
pub const Data = struct {
axis: i32,
};
fn enterCommand(ctxt: *util.IterationContext, iter: usize, mat_offset: usize, buffer: *[]u8) []const u8 {
_ = mat_offset;
const data: *Data = @ptrCast(*Data, @alignCast(@alignOf(Data), buffer.ptr));
if (data.axis == 0)
return util.std.fmt.allocPrint(ctxt.allocator, "", .{}) catch unreachable;
const next_point: []const u8 = util.std.fmt.allocPrint(ctxt.allocator, "p{d}", .{iter}) catch unreachable;
const letters: [3][]const u8 = .{
if (data.axis & (1 << 0) != 0) "x" else "",
if (data.axis & (1 << 1) != 0) "y" else "",
if (data.axis & (1 << 2) != 0) "z" else "",
};
const temp: []const u8 = util.std.mem.concat(ctxt.allocator, u8, letters[0..]) catch unreachable;
const format: []const u8 = "vec3 {s} = {s}; {s}.{s} = abs({s}.{s});";
const res: []const u8 = util.std.fmt.allocPrint(ctxt.allocator, format, .{
next_point,
ctxt.cur_point_name,
next_point,
temp,
ctxt.cur_point_name,
temp,
}) catch unreachable;
ctxt.pushPointName(next_point);
ctxt.allocator.free(temp);
return res;
}
fn exitCommand(ctxt: *util.IterationContext, iter: usize, buffer: *[]u8) []const u8 {
_ = iter;
const data: *Data = @ptrCast(*Data, @alignCast(@alignOf(Data), buffer.ptr));
if (data.axis == 0)
ctxt.popPointName();
return util.std.fmt.allocPrint(ctxt.allocator, "", .{}) catch unreachable;
}
fn sphereBound(buffer: *[]u8, bound: *util.math.sphereBound, children: []util.math.sphereBound) void {
const data: *Data = @ptrCast(*Data, @alignCast(@alignOf(Data), buffer.ptr));
var sym_bound: util.math.sphereBound = children[0];
var i: usize = 0;
while (i < 3) : (i += 1)
sym_bound.pos[i] *= @intToFloat(f32, (data.axis & (@as(i32, 1) << @intCast(u5, i)))) * -1.0;
bound.* = util.math.SphereBound.merge(children[0], sym_bound);
} | src/sdf/modifiers/symmetry.zig |
const std = @import("std");
const assert = std.debug.assert;
const tools = @import("tools");
// inutilement complexe, mais avec un peu de chance servira pour des instructions plus riches...
const Insn = union(enum) {
nop: struct { arg: i32 },
acc: struct { arg: i32 },
jmp: struct { arg: i32 },
};
fn runProg(prog: []const Insn, mutation: ?usize, allocator: std.mem.Allocator) !isize {
const visited = try allocator.alloc(bool, prog.len);
defer allocator.free(visited);
std.mem.set(bool, visited, false);
var accu: isize = 0;
var pc: usize = 0;
while (pc < prog.len) {
if (visited[pc]) {
if (mutation != null)
return error.infiniteLoop;
return accu;
}
visited[pc] = true;
const insn = if (pc != mutation) prog[pc] else switch (prog[pc]) {
.nop => |arg| Insn{ .jmp = .{ .arg = arg.arg } },
.acc => |arg| Insn{ .acc = .{ .arg = arg.arg } },
.jmp => |arg| Insn{ .nop = .{ .arg = arg.arg } },
};
switch (insn) {
.nop => {
pc += 1;
},
.acc => |arg| {
accu += arg.arg;
pc += 1;
},
.jmp => |arg| {
pc = @intCast(usize, @intCast(isize, pc) + arg.arg);
},
}
}
return accu;
}
pub fn run(input: []const u8, allocator: std.mem.Allocator) ![2][]const u8 {
// index by color_id
var prog = try allocator.alloc(Insn, input.len / 6);
defer allocator.free(prog);
var prog_len: usize = 0;
{
var it = std.mem.tokenize(u8, input, "\n\r");
while (it.next()) |line| {
const fields = tools.match_pattern("{} {}", line) orelse unreachable;
const opcode = fields[0].lit;
const arg = @intCast(i32, fields[1].imm);
if (std.mem.eql(u8, opcode, "nop")) {
prog[prog_len] = .{ .nop = .{ .arg = arg } };
} else if (std.mem.eql(u8, opcode, "acc")) {
prog[prog_len] = .{ .acc = .{ .arg = arg } };
} else if (std.mem.eql(u8, opcode, "jmp")) {
prog[prog_len] = .{ .jmp = .{ .arg = arg } };
} else {
unreachable;
}
prog_len += 1;
}
}
const ans1 = runProg(prog[0..prog_len], null, allocator) catch unreachable;
const ans2 = ans: {
var mutation: usize = 0;
while (mutation < prog.len) : (mutation += 1) {
break :ans runProg(prog[0..prog_len], mutation, allocator) catch continue;
}
unreachable;
};
return [_][]const u8{
try std.fmt.allocPrint(allocator, "{}", .{ans1}),
try std.fmt.allocPrint(allocator, "{}", .{ans2}),
};
}
pub const main = tools.defaultMain("2020/input_day08.txt", run); | 2020/day08.zig |
const std = @import("std");
const assert = std.debug.assert;
const mem = std.mem;
const Queue = std.atomic.Queue;
/// Message with a header and body. Header
/// has information common to all Messages
/// and body is a comptime type with information
/// unique to each Message.
///
/// Using packed struct guarantees field ordering
/// and no padding. I'd also like to guarantee
/// endianness so messages can have a consistent
/// external representation.
fn Message(comptime BodyType: type) type {
return packed struct {
const Self = @This();
pub header: MessageHeader,
pub body: BodyType,
pub fn init(cmd: u64) Self {
var self: Self = undefined;
self.header.init(cmd, &self);
BodyType.init(&self.body);
return self;
}
};
}
/// MessageHeader is the common information for
/// all Messages and is the type that is used
/// to place a message on a Queue.
const MessageHeader = packed struct {
const Self = @This();
pub message_offset: usize,
pub cmd: u64,
/// Initialize the header
pub fn init(self: *Self, cmd: u64, message_ptr: var) void {
self.cmd = cmd;
self.message_offset = @ptrToInt(&self.message_offset) - @ptrToInt(message_ptr);
}
/// Get the address of the message associated with the header
pub fn getMessagePtrAs(self: *const Self, comptime T: type) T {
var message_ptr = @intToPtr(T, @ptrToInt(&self.message_offset) - self.message_offset);
return @ptrCast(T, message_ptr);
}
};
const MyMsgBody = packed struct {
const Self = @This();
data: [3]u8,
fn init(self: *Self) void {
mem.set(u8, self.data[0..], 'Z');
}
};
test "Message" {
// Create a message
const MyMsg = Message(MyMsgBody);
var myMsg = MyMsg.init(123);
assert(myMsg.header.message_offset == @ptrToInt(&myMsg.header.message_offset) - @ptrToInt(&myMsg));
assert(myMsg.header.message_offset == 0);
assert(myMsg.header.cmd == 123);
assert(mem.eql(u8, myMsg.body.data[0..], "ZZZ"));
// Modify message body data
myMsg.body.data[0] = 'a';
assert(mem.eql(u8, myMsg.body.data[0..], "aZZ"));
// Create a queue of MessageHeader pointers
const MyQueue = Queue(*MessageHeader);
var q = MyQueue.init();
// Create a node with a pointer to a message header
var node_0 = MyQueue.Node {
.data = &myMsg.header,
.next = undefined,
.prev = undefined,
};
// Add and remove it from the queue
q.put(&node_0);
var n = q.get() orelse { return error.QGetFailed; };
// Get the Message and validate
var pMsg = n.data.getMessagePtrAs(*MyMsg);
assert(pMsg.header.cmd == 123);
assert(mem.eql(u8, pMsg.body.data[0..], "aZZ"));
} | message.zig |
const std = @import("std");
const os = std.os;
const common = @import("common.zig");
pub const Object = common.Object;
pub const Message = common.Message;
pub const Interface = common.Interface;
pub const Array = common.Array;
pub const Fixed = common.Fixed;
pub const Argument = common.Argument;
/// This is wayland-server's wl_display. It has been renamed as zig-wayland has
/// decided to hide wl_resources with opaque pointers in the same way that
/// wayland-client does with wl_proxys. This of course creates a name conflict.
pub const Server = opaque {
extern fn wl_display_create() ?*Server;
pub fn create() !*Server {
return wl_display_create() orelse error.ServerCreateFailed;
}
extern fn wl_display_destroy(server: *Server) void;
pub const destroy = wl_display_destroy;
extern fn wl_display_get_event_loop(server: *Server) *EventLoop;
pub const getEventLoop = wl_display_get_event_loop;
extern fn wl_display_add_socket(server: *Server, name: [*:0]const u8) c_int;
pub fn addSocket(server: *Server, name: [*:0]const u8) !void {
if (wl_display_add_socket(server, name) == -1)
return error.AddSocketFailed;
}
// wayland-client will connect to wayland-0 even if WAYLAND_DISPLAY is
// unset due to an unfortunate piece of code that was not removed before
// the library was stabilized. Because of this, it is a good idea to never
// call the socket wayland-0. So, instead of binding to wayland-server's
// wl_display_add_socket_auto we implement a version which skips wayland-0.
pub fn addSocketAuto(server: *Server, buf: *[11]u8) ![:0]const u8 {
// Don't use wayland-0
var i: u32 = 1;
while (i <= 32) : (i += 1) {
const name = std.fmt.bufPrintZ(buf, "wayland-{}", .{i}) catch unreachable;
server.addSocket(name.ptr) catch continue;
return name;
}
return error.AddSocketFailed;
}
extern fn wl_display_add_socket_fd(server: *Server, sock_fd: c_int) c_int;
pub fn addSocketFd(server: *Server, sock_fd: os.fd_t) !void {
if (wl_display_add_socket_fd(server, sock_fd) == -1)
return error.AddSocketFailed;
}
extern fn wl_display_terminate(server: *Server) void;
pub const terminate = wl_display_terminate;
extern fn wl_display_run(server: *Server) void;
pub const run = wl_display_run;
extern fn wl_display_flush_clients(server: *Server) void;
pub const flushClients = wl_display_flush_clients;
extern fn wl_display_destroy_clients(server: *Server) void;
pub const destroyClients = wl_display_destroy_clients;
extern fn wl_display_get_serial(server: *Server) u32;
pub const getSerial = wl_display_get_serial;
extern fn wl_display_next_serial(server: *Server) u32;
pub const nextSerial = wl_display_next_serial;
extern fn wl_display_add_destroy_listener(server: *Server, listener: *Listener(*Server)) void;
pub const addDestroyListener = wl_display_add_destroy_listener;
extern fn wl_display_add_client_created_listener(server: *Server, listener: *Listener(*Client)) void;
pub const addClientCreatedListener = wl_display_add_client_created_listener;
extern fn wl_display_get_destroy_listener(server: *Server, notify: @TypeOf(Listener(*Server).notify)) ?*Listener(*Server);
pub const getDestroyListener = wl_display_get_destroy_listener;
extern fn wl_display_set_global_filter(
server: *Server,
filter: fn (client: *const Client, global: *const Global, data: ?*c_void) bool,
data: ?*c_void,
) void;
pub fn setGlobalFilter(
server: *Server,
comptime T: type,
filter: fn (client: *const Client, global: *const Global, data: T) callconv(.C) bool,
data: T,
) void {
wl_display_set_global_filter(display, filter, data);
}
extern fn wl_display_get_client_list(server: *Server) *List;
pub const getClientList = wl_display_get_client_list;
extern fn wl_display_init_shm(server: *Server) c_int;
pub fn initShm(server: *Server) !void {
if (wl_display_init_shm(display) == -1)
return error.GlobalCreateFailed;
}
extern fn wl_display_add_shm_format(server: *Server, format: u32) ?*u32;
pub fn addShmFormat(server: *Server, format: u32) !*u32 {
return wl_display_add_shm_format(display, format) orelse error.OutOfMemory;
}
extern fn wl_display_add_protocol_logger(
server: *Server,
func: fn (data: ?*c_void, direction: ProtocolLogger.Type, message: *const ProtocolLogger.Message) void,
data: ?*c_void,
) void;
pub fn addProtocolLogger(
server: *Server,
comptime T: type,
func: fn (data: T, direction: ProtocolLogger.Type, message: *const ProtocolLogger.Message) callconv(.C) void,
data: T,
) void {
wl_display_add_protocol_logger(display, func, data);
}
};
pub const Client = opaque {
extern fn wl_client_create(server: *Server, fd: os.fd_t) ?*Client;
pub const create = wl_client_create;
extern fn wl_client_destroy(client: *Client) void;
pub const destroy = wl_client_destroy;
extern fn wl_client_flush(client: *Client) void;
pub const flush = wl_client_flush;
extern fn wl_client_get_link(client: *Client) *List;
pub const getLink = wl_client_get_link;
extern fn wl_client_from_link(link: *List) *Client;
pub const fromLink = wl_client_from_link;
const Credentials = struct {
pid: os.pid_t,
gid: os.gid_t,
uid: os.uid_t,
};
extern fn wl_client_get_credentials(client: *Client, pid: *os.pid_t, uid: *os.uid_t, gid: *os.gid_t) void;
pub fn getCredentials(client: *Client) Credentials {
var credentials: Credentials = undefined;
wl_client_get_credentials(client, &credentials.pid, &credentials.uid, &credentials.gid);
return credentials;
}
extern fn wl_client_add_destroy_listener(client: *Client, listener: *Listener(*Client)) void;
pub const addDestroyListener = wl_client_add_destroy_listener;
extern fn wl_client_get_destroy_listener(client: *Client, notify: @TypeOf(Listener(*Client).notify)) ?*Listener(*Client);
pub const getDestroyListener = wl_client_get_destroy_listener;
extern fn wl_client_get_object(client: *Client, id: u32) ?*Resource;
pub const getObject = wl_client_get_object;
extern fn wl_client_post_no_memory(client: *Client) void;
pub const postNoMemory = wl_client_post_no_memory;
extern fn wl_client_post_implementation_error(client: *Client, msg: [*:0]const u8, ...) void;
pub const postImplementationError = wl_client_post_implementation_error;
extern fn wl_client_add_resource_created_listener(client: *Client, listener: *Listener(*Resource)) void;
pub const addResourceCreatedListener = wl_client_add_resource_created_listener;
const IteratorResult = extern enum { stop, cont };
extern fn wl_client_for_each_resource(
client: *Client,
iterator: fn (resource: *Resource, data: ?*c_void) IteratorResult,
data: ?*c_void,
) void;
pub fn forEachResource(
client: *Client,
comptime T: type,
iterator: fn (resource: *Resource, data: T) callconv(.C) IteratorResult,
data: T,
) void {
wl_client_for_each_resource(client, iterator, data);
}
extern fn wl_client_get_fd(client: *Client) os.fd_t;
pub const getFd = wl_client_get_fd;
extern fn wl_client_get_display(client: *Client) *Server;
pub const getDisplay = wl_client_get_display;
};
pub const Global = opaque {
extern fn wl_global_create(
server: *Server,
interface: *const Interface,
version: c_int,
data: ?*c_void,
bind: fn (client: *Client, data: ?*c_void, version: u32, id: u32) callconv(.C) void,
) ?*Global;
pub fn create(
server: *Server,
comptime Object: type,
version: u32,
comptime T: type,
data: T,
bind: fn (client: *Client, data: T, version: u32, id: u32) callconv(.C) void,
) !*Global {
return wl_global_create(display, Object.interface, version, data, bind) orelse
error.GlobalCreateFailed;
}
extern fn wl_global_remove(global: *Global) void;
pub const remove = wl_global_remove;
extern fn wl_global_destroy(global: *Global) void;
pub const destroy = wl_global_destroy;
extern fn wl_global_get_interface(global: *const Global) *const Interface;
pub const getInterface = wl_global_get_interface;
extern fn wl_global_get_user_data(global: *const Global) ?*c_void;
pub const getUserData = wl_global_get_user_data;
// TODO: should we expose this making the signature of create unsafe?
extern fn wl_global_set_user_data(global: *Global, data: ?*c_void) void;
};
pub const Resource = opaque {
extern fn wl_resource_create(client: *Client, interface: *const Interface, version: c_int, id: u32) ?*Resource;
pub fn create(client: *Client, comptime Object: type, version: u32, id: u32) !*Resource {
// This is only a c_int because of legacy libwayland reasons. Negative versions are invalid.
// Version is a u32 on the wire and for wl_global, wl_proxy, etc.
return wl_resource_create(client, Object.interface, @intCast(c_int, version), id) orelse error.ResourceCreateFailed;
}
extern fn wl_resource_destroy(resource: *Resource) void;
pub const destroy = wl_resource_destroy;
extern fn wl_resource_post_event_array(resource: *Resource, opcode: u32, args: [*]Argument) void;
pub const postEvent = wl_resource_post_event_array;
extern fn wl_resource_queue_event_array(resource: *Resource, opcode: u32, args: [*]Argument) void;
pub const queueEvent = wl_resource_queue_event_array;
extern fn wl_resource_post_error(resource: *Resource, code: u32, message: [*:0]const u8, ...) void;
pub const postError = wl_resource_post_error;
extern fn wl_resource_post_no_memory(resource: *Resource) void;
pub const postNoMemory = wl_resource_post_no_memory;
const DispatcherFn = fn (
implementation: ?*const c_void,
resource: *Resource,
opcode: u32,
message: *const Message,
args: [*]Argument,
) callconv(.C) c_int;
pub const DestroyFn = fn (resource: *Resource) callconv(.C) void;
extern fn wl_resource_set_dispatcher(
resource: *Resource,
dispatcher: DispatcherFn,
implementation: ?*const c_void,
data: ?*c_void,
destroy: DestroyFn,
) void;
pub fn setDispatcher(
resource: *Resource,
dispatcher: DispatcherFn,
implementation: ?*const c_void,
data: ?*c_void,
destroy: DestroyFn,
) void {
wl_resource_set_dispatcher(resource, dispatcher, implementation, data, destroy);
}
extern fn wl_resource_get_user_data(resource: *Resource) ?*c_void;
pub const getUserData = wl_resource_get_user_data;
// TODO: should we expose this and lose type safety of the setDispatcher API?
extern fn wl_resource_set_user_data(resource: *Resource, data: ?*c_void) void;
extern fn wl_resource_get_id(resource: *Resource) u32;
pub const getId = wl_resource_get_id;
extern fn wl_resource_get_link(resource: *Resource) *List;
pub const getLink = wl_resource_get_link;
extern fn wl_resource_from_link(link: *List) *Resource;
pub const fromLink = wl_resource_from_link;
extern fn wl_resource_find_for_client(list: *List, client: *Client) ?*Resource;
pub const findForClient = wl_resource_find_for_client;
extern fn wl_resource_get_client(resource: *Resource) *Client;
pub const getClient = wl_resource_get_client;
extern fn wl_resource_get_version(resource: *Resource) c_int;
pub fn getVersion(resource: *Resource) u32 {
// The fact that wl_resource.version is a int in libwayland is
// a mistake. Negative versions are impossible and u32 is used
// everywhere else in libwayland
return @intCast(u32, wl_resource_get_version(resource));
}
extern fn wl_resource_set_destructor(resource: *Resource, destroy: DestroyFn) void;
pub const setDestructor = wl_resource_set_destructor;
extern fn wl_resource_get_class(resource: *Resource) [*:0]const u8;
pub const getClass = wl_resource_get_class;
extern fn wl_resource_add_destroy_listener(resource: *Resource, listener: *Listener(*Resource)) void;
pub const addDestroyListener = wl_resource_add_destroy_listener;
extern fn wl_resource_get_destroy_listener(resource: *Resource, notify: @TypeOf(Listener(*Resource).notify)) ?*Listener(*Resource);
pub const getDestroyListener = wl_resource_get_destroy_listener;
};
pub const ProtocolLogger = opaque {
pub const Type = extern enum {
request,
event,
};
pub const Message = extern struct {
resource: *Resource,
message_opcode: c_int,
message: *Message,
arguments_count: c_int,
arguments: ?[*]Argument,
};
extern fn wl_protocol_logger_destroy(logger: *ProtocolLogger) void;
pub const destroy = wl_protocol_logger_destroy;
};
pub const List = extern struct {
prev: ?*List,
next: ?*List,
pub fn init(list: *List) void {
list.* = .{ .prev = list, .next = list };
}
pub fn prepend(list: *List, elm: *List) void {
elm.prev = list;
elm.next = list.next;
list.next = elm;
elm.next.?.prev = elm;
}
pub fn append(list: *List, elm: *List) void {
list.prev.?.prepend(elm);
}
pub fn remove(elm: *elm) void {
elm.prev.?.next = elm.next;
elm.next.?.prev = elm.prev;
elm.* = .{ .prev = null, .next = null };
}
pub fn length(list: *const List) usize {
var count: usize = 0;
var current = list.next;
while (current != list) : (current = current.next) {
count += 1;
}
return count;
}
pub fn empty(list: *const List) bool {
return list.next == list;
}
pub fn insertList(list: *List, other: *List) void {
if (other.empty()) return;
other.next.?.prev = list;
other.prev.?.next = list.next;
list.next.?.prev = other.prev;
list.next = other.next;
}
};
pub fn Listener(comptime T: type) type {
return extern struct {
const Self = @This();
pub const NotifyFn = if (T == void)
fn (listener: *Self) void
else
fn (listener: *Self, data: T) void;
link: List,
notify: fn (listener: *Self, data: ?*c_void) callconv(.C) void,
pub fn setNotify(self: *Self, comptime notify: NotifyFn) void {
self.notify = if (T == void)
struct {
fn wrapper(listener: *Self, _: ?*c_void) callconv(.C) void {
@call(.{ .modifier = .always_inline }, notify, .{listener});
}
}.wrapper
else
struct {
fn wrapper(listener: *Self, data: ?*c_void) callconv(.C) void {
@call(.{ .modifier = .always_inline }, notify, .{ listener, @intToPtr(T, @ptrToInt(data)) });
}
}.wrapper;
}
};
}
pub fn Signal(comptime T: type) type {
return extern struct {
const Self = @This();
listener_list: List,
pub fn init(signal: *Self) void {
signal.listener_list.init();
}
pub fn add(signal: *Self, listener: *Listener(T)) void {
signal.listener_list.append(&listener.link);
}
pub fn get(signal: *Self, notify: @TypeOf(Listener(T).notify)) ?*Listener(T) {
var it = signal.listener_list.next;
return while (it != &signal.listener_list) : (it = it.next) {
const listener = @fieldParentPtr(Listener(T), it, "link");
if (listener.notify == notify) break listener;
} else null;
}
pub const emit = if (T == void)
struct {
pub fn emit(signal: *Self) void {
var it = signal.listener_list.next.?;
while (it != &signal.listener_list) {
const listener = @fieldParentPtr(Listener(T), "link", it);
// Must happen before notify is called in case it removes the current link
it = it.next.?;
listener.notify(listener, null);
}
}
}.emit
else
struct {
pub fn emit(signal: *Self, data: T) void {
var it = signal.listener_list.next.?;
while (it != &signal.listener_list) {
const listener = @fieldParentPtr(Listener(T), "link", it);
// Must happen before notify is called in case it removes the current link
it = it.next.?;
listener.notify(listener, data);
}
}
}.emit;
};
}
pub const EventLoop = opaque {
extern fn wl_event_loop_create() ?*EventLoop;
pub fn create() *EventLoop {
return wl_event_loop_create() orelse error.EventLoopCreateFailed;
}
extern fn wl_event_loop_destroy(loop: *EventLoop) void;
pub const destroy = wl_event_loop_destroy;
extern fn wl_event_loop_add_fd(
loop: *EventLoop,
fd: os.fd_t,
mask: u32,
func: fn (fd: os.fd_t, mask: u32, data: ?*c_void) c_int,
data: ?*c_void,
) ?*EventSource;
pub fn addFd(
loop: *EventLoop,
comptime T: type,
fd: os.fd_t,
mask: u32,
func: fn (fd: os.fd_t, mask: u32, data: T) callconv(.C) c_int,
data: T,
) ?*EventSource {
return wl_event_loop_add_fd(loop, fd, mask, func, data);
}
extern fn wl_event_loop_add_timer(
loop: *EventLoop,
func: fn (data: ?*c_void) c_int,
data: ?*c_void,
) ?*EventSource;
pub fn addTimer(
loop: *EventLoop,
comptime T: type,
func: fn (data: T) callconv(.C) c_int,
data: T,
) ?*EventSource {
return wl_event_loop_add_timer(loop, func, data);
}
extern fn wl_event_loop_add_signal(
loop: *EventLoop,
signal_number: c_int,
func: fn (c_int, ?*c_void) c_int,
data: ?*c_void,
) ?*EventSource;
pub fn addSignal(
loop: *EventLoop,
comptime T: type,
signal_number: c_int,
func: fn (signal_number: c_int, data: T) callconv(.C) c_int,
data: T,
) ?*EventSource {
return wl_event_loop_add_signal(loop, signal_number, func, data);
}
extern fn wl_event_loop_add_idle(
loop: *EventLoop,
func: fn (data: ?*c_void) c_int,
data: ?*c_void,
) ?*EventSource;
pub fn addIdle(
loop: *EventLoop,
comptime T: type,
func: fn (data: T) callconv(.C) c_int,
data: T,
) error{OutOfMemory}!*EventSource {
return wl_event_loop_add_idle(loop, func, data) orelse error.OutOfMemory;
}
extern fn wl_event_loop_dispatch(loop: *EventLoop, timeout: c_int) c_int;
pub fn dispatch(loop: *EventLoop, timeout: c_int) !void {
const rc = wl_event_loop_dispatch(loop, timeout);
switch (os.errno(rc)) {
0 => return,
// TODO
else => |err| os.unexpectedErrno(err),
}
}
extern fn wl_event_loop_dispatch_idle(loop: *EventLoop) void;
pub const dispatchIdle = wl_event_loop_dispatch_idle;
extern fn wl_event_loop_get_fd(loop: *EventLoop) os.fd_t;
pub const getFd = wl_event_loop_get_fd;
extern fn wl_event_loop_add_destroy_listener(loop: *EventLoop, listener: *Listener(*EventLoop)) void;
pub const addDestroyListener = wl_event_loop_add_destroy_listener;
extern fn wl_event_loop_get_destroy_listener(loop: *EventLoop, notify: @TypeOf(Listener(*EventLoop).notify)) ?*Listener;
pub const getDestroyListener = wl_event_loop_get_destroy_listener;
};
pub const EventSource = opaque {
extern fn wl_event_source_remove(source: *EventSource) c_int;
pub fn remove(source: *EventSource) void {
if (wl_event_source_remove(source) != 0) unreachable;
}
extern fn wl_event_source_check(source: *EventSource) void;
pub const check = wl_event_source_check;
extern fn wl_event_source_fd_update(source: *EventSource, mask: u32) c_int;
pub fn fdUpdate(source: *EventSource, mask: u32) !void {
const rc = wl_event_source_fd_update(source, mask);
switch (os.errno(rc)) {
0 => return,
// TODO
else => |err| os.unexpectedErrno(err),
}
}
extern fn wl_event_source_timer_update(source: *EventSource, ms_delay: c_int) c_int;
pub fn timerUpdate(source: *EventSource, ms_delay: u31) !void {
const rc = wl_event_source_timer_update(source, ms_delay);
switch (os.errno(rc)) {
0 => return,
// TODO
else => |err| os.unexpectedErrno(err),
}
}
};
pub const shm = struct {
pub const Buffer = opaque {
extern fn wl_shm_buffer_get(resource: *Resource) ?*Buffer;
pub const get = wl_shm_buffer_get;
extern fn wl_shm_buffer_begin_access(buffer: *Buffer) void;
pub const beginAccess = wl_shm_buffer_begin_access;
extern fn wl_shm_buffer_end_access(buffer: *Buffer) void;
pub const endAccess = wl_shm_buffer_end_access;
extern fn wl_shm_buffer_get_data(buffer: *Buffer) ?*c_void;
pub const getData = wl_shm_buffer_get_data;
extern fn wl_shm_buffer_get_format(buffer: *Buffer) u32;
pub const getFormat = wl_shm_buffer_get_format;
extern fn wl_shm_buffer_get_height(buffer: *Buffer) i32;
pub const getHeight = wl_shm_buffer_get_height;
extern fn wl_shm_buffer_get_width(buffer: *Buffer) i32;
pub const getWidth = wl_shm_buffer_get_width;
extern fn wl_shm_buffer_get_stride(buffer: *Buffer) i32;
pub const getStride = wl_shm_buffer_get_stride;
extern fn wl_shm_buffer_ref_pool(buffer: *Buffer) *Pool;
pub const refPool = wl_shm_buffer_ref_pool;
};
pub const Pool = opaque {
extern fn wl_shm_pool_unref(pool: *Pool) void;
pub const unref = wl_shm_pool_unref;
};
}; | wayland_server_core.zig |
const c = @import("../../c_global.zig").c_imp;
const std = @import("std");
// dross-zig
const vbgl = @import("vertex_buffer_opengl.zig");
const VertexBufferGl = vbgl.VertexBufferGl;
const BufferUsageGl = vbgl.BufferUsageGl;
// --------------------------------------------------
// -----------------------------------------
// - IndexBufferGl -
// -----------------------------------------
/// Stores indices that will be used to decide what vertices to draw.
pub const IndexBufferGl = struct {
/// OpenGL generated ID
handle: c_uint,
/// Number of indices
index_count: c_uint,
const Self = @This();
/// Allocates and sets up a new IndexBufferGl instance.
/// Comments: The caller will own the allocated data.
pub fn new(allocator: *std.mem.Allocator) !*Self {
var self = try allocator.create(IndexBufferGl);
c.glGenBuffers(1, &self.handle);
return self;
}
/// Cleans up and de-allocates the Index Buffer
pub fn free(allocator: *std.mem.Allocator, self: *Self) void {
c.glDeleteBuffers(1, &self.handle);
allocator.destroy(self);
}
/// Returns the id OpenGL-generated id
pub fn id(self: *Self) c_uint {
return self.handle;
}
/// Returns the count of the Index Buffer
pub fn count(self: *Self) c_int {
return self.index_count;
}
/// Binds the Index Buffer
pub fn bind(self: *Self) void {
c.glBindBuffer(c.GL_ELEMENT_ARRAY_BUFFER, self.handle);
}
/// Allocates memory and stores data within the the currently bound buffer object.
pub fn data(self: *Self, indices: []const c_uint, usage: BufferUsageGl) void {
self.index_count = @intCast(c_uint, indices.len);
const indices_ptr = @ptrCast(*const c_void, indices.ptr);
const indices_size = @intCast(c_longlong, @sizeOf(c_uint) * indices.len);
c.glBufferData(c.GL_ELEMENT_ARRAY_BUFFER, indices_size, indices_ptr, @enumToInt(usage));
}
}; | src/renderer/backend/index_buffer_opengl.zig |
const std = @import("std");
const fsnode = @import("fsnode.zig");
const cache = @import("cache.zig");
const FSTreeConfig = struct {
InodeRefType: type,
MutexType: type,
CredentialsType: type,
separator: []const u8 = "/",
parent_link: []const u8 = "..",
current_link: []const u8 = ".",
root: []const u8 = "/",
max_name_length: usize = 255,
ignore_empty: bool = true,
};
/// FSTree structure represents the entirety of the filesystem tree
/// cfg.MutexType should confirm to std.Mutex interface
/// cfg.InodeRefType should implement
///
/// - drop(self: @This()) void - drops this reference to the inode
/// - lookup(self: @This(), name: []const u8) !@This() - load inode ref for child
/// - resolveHook(self: @This(), credentials: cfg.CredentialsType) !void - hook that is called
/// on directory resolution
///
/// On each of those operations, tree lock is released and acquired back after the operation
/// InodeRefType and MutexType should be initializable to a valid state with .{}v
/// cfg.separator, cfg.parent_linkk, cfg.current_link, cfg.root are used in path resolution.
/// max_name_length is maximum length of component name
pub fn FSTree(comptime cfg: FSTreeConfig) type {
return struct {
const Node = fsnode.FSNode(cfg.InodeRefType, cfg.max_name_length);
const NodeCache = cache.QueueCache(.{ .T = Node, .Owner = @This() }, cacheDisposeFn);
/// Allocator used for tree operations
allocator: *std.mem.Allocator,
/// Root node
root: *Node,
/// Tree mutex
mutex: cfg.MutexType = .{},
/// Held mutex structure
held: cfg.MutexType.Held = undefined,
/// Node cache
cache: NodeCache,
/// Check credentials while doing path resolution
fn checkResolveCredentials(
self: *@This(),
ref: cfg.InodeRefType,
credentials: cfg.CredentialsType,
) !void {
self.releaseLock();
defer self.acquireLock();
return ref.resolveHook(credentials);
}
/// Look up child inode ref using lookup method
fn loadChild(self: *@This(), current: *Node, component: []const u8) !cfg.InodeRefType {
self.releaseLock();
defer self.acquireLock();
return current.ref.lookup(component);
}
/// Link child using link() inode ref method
fn linkChild(
self: *@This(),
current: *Node,
component: []const u8,
child: cfg.InodeRefType,
credentials: cfg.CredentialsType,
) !void {
self.releaseLock();
defer self.acquireLock();
return current.ref.linkHook(child, component, credentials);
}
/// Unlink child using unlink() inode ref method
fn unlinkChild(
self: *@This(),
current: *Node,
component: []const u8,
child: cfg.InodeRefType,
credentials: cfg.CredentialsType,
) !void {
self.releaseLock();
defer self.acquireLock();
return current.ref.unlinkHook(child, component, credentials);
}
/// Drop reference to Inode using its drop method
fn dropInodeRef(self: *@This(), ref: cfg.InodeRefType) void {
self.releaseLock();
ref.drop();
self.acquireLock();
}
/// Flush cache
pub fn flushCache(self: *@This()) void {
self.acquireLock();
self.cache.flush(self);
self.releaseLock();
}
/// Release tree lock
fn releaseLock(self: *@This()) void {
self.held.release();
}
/// Acquire tree lock
fn acquireLock(self: *@This()) void {
self.held = self.mutex.acquire();
}
/// Dispose node from cache
fn cacheDisposeFn(self: *@This(), node: *Node) void {
// Disposal of the current node may also trigger disposal of the parent, grandparent,
// etc. Hence the need for the loop
var current = node;
std.debug.assert(current.ref_count == 0); // node in cache should have ref_count = 0
while (current.ref_count == 0) {
if (current.parent) |parent| {
// Unlink from the parent
parent.removeChild(current);
parent.ref_count -= 1;
// Drop lock for a moment
self.releaseLock();
// Dispose node ref
current.ref.drop();
current.destroy(self.allocator);
// Take lock back
self.acquireLock();
// Move on
current = parent;
} else {
// ref_counts of mounted FSes are always at least one
@panic("libvfs: Reference count of FS root is zero!");
}
}
}
/// Increment node's reference count. Load from cache if needed
fn incRefCount(self: *@This(), node: *Node) void {
node.ref_count += 1;
// If node is in the cache, load it back
if (node.ref_count == 1) {
self.cache.cut(node);
}
}
/// Drop reference to the node. Load to cache if needed
fn decRefCount(self: *@This(), node: *Node) void {
node.ref_count -= 1;
// If node reference count is 0, put it in the cache
if (node.ref_count == 0) {
self.cache.enqueue(self, node);
}
}
/// Go to loaded child or return null
fn resolveLoadedChildComponent(
self: *@This(),
current: *Node,
component: []const u8,
credentials: cfg.CredentialsType,
) !?*Node {
const child = current.getChild(component) orelse return null;
try self.checkResolveCredentials(child.ref, credentials);
self.incRefCount(child);
current.ref_count -= 1;
return child;
}
/// Go to child
fn resolveChildComponent(
self: *@This(),
current: *Node,
component: []const u8,
credentials: cfg.CredentialsType,
) !*Node {
// First, check if node is already there
return (try self.resolveLoadedChildComponent(current, component, credentials)) orelse {
// If not, try to lookup child ref
const new_ref = try self.loadChild(current, component);
errdefer self.dropInodeRef(new_ref);
// While we were loading this node, it could have been that someone else loaded it,
// so we check again
if (try self.resolveLoadedChildComponent(current, component, credentials)) |res| {
// errdefer won't execute, since result is not error.
self.dropInodeRef(new_ref);
return res;
}
// Verify credentials
try self.checkResolveCredentials(new_ref, credentials);
// Alright, let's create a new node
const child = try Node.create(self.allocator, component);
errdefer child.destroy(self.allocator);
child.ref = new_ref;
try current.addChild(child, self.allocator);
return child;
};
}
/// Go to parent. If there is no parent, current is returned
fn resolveParentComponent(
self: *@This(),
current: *Node,
credentials: cfg.CredentialsType,
root: ?*Node,
) !*Node {
if (current == root) {
return current;
}
if (current.getParent()) |parent| {
try self.checkResolveCredentials(parent.ref, credentials);
parent.ref_count += 1;
self.decRefCount(current);
return parent;
}
return current;
}
/// Resolve one component
fn resolveComponent(
self: *@This(),
current: *Node,
component: []const u8,
credentials: cfg.CredentialsType,
root: ?*Node,
) !*Node {
errdefer self.decRefCount(current);
if (std.mem.eql(u8, component, cfg.current_link)) {
return current;
} else if (component.len == 0 and cfg.ignore_empty) {
return current;
} else if (std.mem.eql(u8, component, cfg.parent_link)) {
return self.resolveParentComponent(current, credentials, root);
} else {
return self.resolveChildComponent(current, component, credentials);
}
}
/// Walk from a given node. If consume_last is set to false, all elements except last
/// will be ignored
fn walkImpl(
self: *@This(),
node: ?*Node,
root: ?*Node,
path: []const u8,
last: ?*[]const u8,
consume_last: bool,
credentials: cfg.CredentialsType,
) !*Node {
const is_root_path = std.mem.startsWith(u8, path, cfg.root);
const real_root = if (root) |r| r else self.root;
const start = if (is_root_path) real_root else (node orelse real_root);
const real_path = if (is_root_path) path[cfg.root.len..] else path;
self.acquireLock();
defer self.releaseLock();
var current = start.traceMounts();
self.incRefCount(current);
var iterator = std.mem.split(real_path, cfg.separator);
var prev_component = iterator.next() orelse return current;
var current_component = iterator.next();
while (current_component) |component| {
current = try self.resolveComponent(current, prev_component, credentials, root);
prev_component = component;
current_component = iterator.next();
}
if (last) |nonnull| {
nonnull.* = prev_component;
}
if (consume_last) {
current = try self.resolveComponent(current, prev_component, credentials, root);
}
return current;
}
/// Print filesystem tree with a given root
fn dumpFromNode(self: *@This(), node: *Node, tab_level: usize, writer: anytype) void {
switch (tab_level) {
0 => {},
else => {
writer.writeByteNTimes(' ', 2 * (tab_level - 1)) catch {};
_ = writer.write("- ") catch {};
},
}
writer.print("{s} (rc={})\n", .{ node.name, node.ref_count }) catch {};
var iterator = node.children.iterator();
while (iterator.next()) |child| {
self.dumpFromNode(Node.fromKey(child.value), tab_level + 1, writer);
}
}
/// Duplicate reference to the tree node
pub fn dupeRef(self: *@This(), node: *Node) *Node {
self.acquireLock();
node.ref_count += 1;
self.releaseLock();
}
/// Drop reference to the tree node
pub fn dropRef(self: *@This(), node: *Node) void {
self.acquireLock();
self.decRefCount(node);
self.releaseLock();
}
/// Walk from a given node by a given path
/// node is a pointer to the CWD. If null, walk() starts walking from root
/// chroot is a pointer to chrooted root. If null, walk() starts walking from real FS root
/// path is actual path to file
/// credentials are passed to resolveHook to verify if resolution of a given path is
/// allowed
/// NOTE: if chroot is not null, method assumes that node is in subtree of chroot
pub fn walk(
self: *@This(),
node: ?*Node,
chroot: ?*Node,
path: []const u8,
credentials: cfg.CredentialsType,
) !*Node {
return self.walkImpl(node, chroot, path, null, true, credentials);
}
/// Walk from a given node by a given path, ignoring the last path component
/// Fat pointer to the last path component is stored in the buffer provided by last
/// This fat pointer would point inside the path
/// node is a pointer to the CWD. If null, walk() starts walking from root
/// chroot is a pointer to chrooted root. If null, walk() starts walking from real FS root
/// path is actual path to file
/// credentials are passed to resolveHook to verify if resolution of a given path is
/// allowed
/// NOTE: if chroot is not null, method assumes that node is in subtree of chroot
pub fn walkIgnoreLast(
self: *@This(),
node: ?*Node,
chroot: ?*Node,
path: []const u8,
last: *[]const u8,
credentials: cfg.CredentialsType,
) !*Node {
return self.walkImpl(node, chroot, path, last, false, credentials);
}
/// Creates tree instance.
pub fn init(
allocator: *std.mem.Allocator,
max_cache_size: ?usize,
root: cfg.InodeRefType,
) !@This() {
// Make root node
const child = try Node.create(allocator, "");
child.ref = root;
return @This(){
.allocator = allocator,
.cache = .{ .max_count = max_cache_size },
.root = child,
};
}
/// Dump tree state to stderr
pub fn dump(self: *@This()) void {
self.acquireLock();
const writer = std.io.getStdErr().writer();
writer.print("TREE DUMP\n", .{}) catch {};
self.dumpFromNode(self.root, 0, writer);
writer.print("CACHE DUMP\n", .{}) catch {};
var current = self.cache.tail;
while (current) |node| {
writer.print("- {s} (rc={})\n", .{ node.name, node.ref_count }) catch {};
current = node.next_in_cache;
}
self.releaseLock();
}
/// Dispose filesystem tree. Requires that all references to the objects in tree are lost
pub fn deinit(self: *@This()) void {
self.flushCache();
std.debug.assert(self.root.ref_count == 1);
self.root.destroy(self.allocator);
}
/// Errors that can be returned from path function
const PathError = error{
/// buffer is not big enough to store the name
OutOfRange,
/// node can't be reached from filesystem root
UnreachableFromRoot,
};
/// Render path to file in a buffer.
/// NOTE: Do not use directly on shared memory, otherwise sensitive data can be leaked
/// NOTE: if chroot is not null, node is assumed to be in subtree of chroot
pub fn emitPath(
self: *@This(),
node: *Node,
chroot: ?*Node,
buf: []u8,
) PathError![]const u8 {
self.acquireLock();
defer self.releaseLock();
const prepend = struct {
fn prepend(storage: []u8, curent: []const u8, new: []const u8) ![]const u8 {
const new_length = new.len + curent.len;
if (new_length > storage.len) {
return error.OutOfRange;
}
const new_index = storage.len - new_length;
std.mem.copy(u8, storage[new_index..(new_index + new.len)], new);
return storage[new_index..];
}
}.prepend;
var current = node;
var last = false;
var result: []const u8 = buf[buf.len..];
while (!last) {
const parent = current.getParent();
if (parent) |par| {
last = (par == chroot) or (par.getParent() == null);
}
result = try prepend(buf, result, current.name);
if (!last) {
result = try prepend(buf, result, cfg.separator);
}
if (parent) |par| current = par;
}
result = try prepend(buf, result, cfg.root);
return result;
}
};
}
test "walking" {
// Dummy mutex type
const Mutex = struct {
const Self = @This();
const Held = struct {
owner: *Self,
fn release(self: *@This()) void {
std.debug.assert(self.owner.acquired);
self.owner.acquired = false;
}
};
acquired: bool = false,
fn acquire(self: *@This()) Held {
std.debug.assert(!self.acquired);
self.acquired = true;
return .{ .owner = self };
}
};
// Dummy inode ref type.
const InodeRef = struct {
allow_pass: bool = true,
fn drop(self: @This()) void {}
fn lookup(self: @This(), name: []const u8) !@This() {
if (std.mem.eql(u8, name, "invisible")) {
return error.NotFound;
} else if (std.mem.eql(u8, name, "nopass")) {
return @This(){ .allow_pass = false };
}
return @This(){};
}
fn resolveHook(self: @This(), superuser: bool) !void {
if (superuser or self.allow_pass) {
return;
}
return error.PermissionDenied;
}
};
// Buffer for rendering paths
var path_buf: [1024]u8 = undefined;
const MyTree = FSTree(.{ .InodeRefType = InodeRef, .MutexType = Mutex, .CredentialsType = bool });
var tree = try MyTree.init(std.testing.allocator, null, .{});
const usrbin = try tree.walk(null, null, "/usr/bin", true);
// All paths starting from / resolve from root, even if cwd is supplied
const relativeUsrBin = try tree.walk(usrbin, null, "/usr/bin", true);
try std.testing.expectEqual(usrbin, relativeUsrBin);
tree.dropRef(relativeUsrBin);
// Try to open /usr/bin/posixsrv in two possible ways
const posix = try tree.walk(usrbin, null, "posixsrv", true);
const posixFromAbsolute = try tree.walk(null, null, "/../usr/bin/posixsrv", false);
try std.testing.expectEqual(posix, posixFromAbsolute);
// Test path function
const emitted = try tree.emitPath(posix, null, &path_buf);
try std.testing.expect(std.mem.eql(u8, emitted, "/usr/bin/posixsrv"));
// Drop nodes
tree.dropRef(posix);
tree.dropRef(posixFromAbsolute);
tree.dropRef(usrbin);
// Load posixsrv back to test loading from cache
const posixFromAbsolute2 = try tree.walk(null, null, "/usr/bin/posixsrv", true);
try std.testing.expectEqual(posixFromAbsolute, posixFromAbsolute2);
tree.dropRef(posixFromAbsolute2);
// Try resolving file that does not exist
if (tree.walk(null, null, "/home/invisible/???", false)) {
@panic("/home/invisible/??? file should not exist");
} else |err| {
try std.testing.expectEqual(err, error.NotFound);
}
// Let's make chroot jail!
const jail = try tree.walk(null, null, "/jail", true);
// Now let's try to escape it
const escape_attempt = try tree.walk(null, jail, "/../../../", false);
// We shall not pass
try std.testing.expectEqual(jail, escape_attempt);
tree.dropRef(escape_attempt);
// Test path rendering in chrooted environment
const test_node = try tree.walk(null, jail, "/nopass/test_node", true);
const emitted2 = try tree.emitPath(test_node, jail, &path_buf);
try std.testing.expect(std.mem.eql(u8, emitted2, "/nopass/test_node"));
tree.dropRef(test_node);
tree.dropRef(jail);
// Test credentials verification
const init = try tree.walk(null, null, "/etc/nopass/init", true);
tree.dropRef(init);
if (tree.walk(null, null, "/etc/nopass/init", false)) {
@panic("We should not be allowed to access /etc/nopass/init");
} else |err| {
try std.testing.expectEqual(err, error.PermissionDenied);
}
tree.deinit();
} | fstree.zig |
const std = @import("std");
const assert = std.debug.assert;
const meta = std.meta;
const builtin = std.builtin;
usingnamespace @cImport({
@cInclude("stdio.h");
@cInclude("string.h");
@cInclude("unistd.h");
@cInclude("time.h");
@cInclude("errno.h");
@cInclude("stdintfix.h"); // NB: Required as zig is unable to process some macros
@cInclude("SDL2/SDL.h");
@cInclude("SDL2/SDL_syswm.h");
@cInclude("GL/gl.h");
@cInclude("GL/glx.h");
@cInclude("GL/glext.h");
@cInclude("bgfx/c99/bgfx.h");
});
fn sdlSetWindow(window: *SDL_Window) !void {
var wmi: SDL_SysWMinfo = undefined;
wmi.version.major = SDL_MAJOR_VERSION;
wmi.version.minor = SDL_MINOR_VERSION;
wmi.version.patch = SDL_PATCHLEVEL;
if (SDL_GetWindowWMInfo(window, &wmi) == .SDL_FALSE) {
return error.SDL_FAILED_INIT;
}
var pd = std.mem.zeroes(bgfx_platform_data_t);
if (builtin.os.tag == .linux) {
pd.ndt = wmi.info.x11.display;
pd.nwh = meta.cast(*c_void, wmi.info.x11.window);
}
if (builtin.os.tag == .freebsd) {
pd.ndt = wmi.info.x11.display;
pd.nwh = meta.cast(*c_void, wmi.info.x11.window);
}
if (builtin.os.tag == .macosx) {
pd.ndt = NULL;
pd.nwh = wmi.info.cocoa.window;
}
if (builtin.os.tag == .windows) {
pd.ndt = NULL;
pd.nwh = wmi.info.win.window;
}
//if (builtin.os.tag == .steamlink) {
// pd.ndt = wmi.info.vivante.display;
// pd.nwh = wmi.info.vivante.window;
//}
pd.context = NULL;
pd.backBuffer = NULL;
pd.backBufferDS = NULL;
bgfx_set_platform_data(&pd);
}
pub fn main() !void {
_ = SDL_Init(0);
defer SDL_Quit();
const window = SDL_CreateWindow("bgfx", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE).?;
defer SDL_DestroyWindow(window);
try sdlSetWindow(window);
var in = std.mem.zeroes(bgfx_init_t);
in.type = bgfx_renderer_type.BGFX_RENDERER_TYPE_COUNT; // Automatically choose a renderer.
in.resolution.width = 800;
in.resolution.height = 600;
in.resolution.reset = BGFX_RESET_VSYNC;
var success = bgfx_init(&in);
defer bgfx_shutdown();
assert(success);
bgfx_set_debug(BGFX_DEBUG_TEXT);
bgfx_set_view_clear(0, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x443355FF, 1.0, 0);
bgfx_set_view_rect(0, 0, 0, 800, 600);
var frame_number: u64 = 0;
gameloop: while (true) {
var event: SDL_Event = undefined;
var should_exit = false;
while (SDL_PollEvent(&event) == 1) {
switch (event.type) {
SDL_QUIT => should_exit = true,
SDL_WINDOWEVENT => {
const wev = &event.window;
switch (wev.event) {
SDL_WINDOWEVENT_RESIZED, SDL_WINDOWEVENT_SIZE_CHANGED => {},
SDL_WINDOWEVENT_CLOSE => should_exit = true,
else => {},
}
},
else => {},
}
}
if (should_exit) break :gameloop;
bgfx_set_view_rect(0, 0, 0, 800, 600);
bgfx_touch(0);
bgfx_dbg_text_clear(0, false);
bgfx_dbg_text_printf(0, 1, 0x4f, "Frame#:%d", frame_number);
frame_number = bgfx_frame(false);
}
} | src/main.zig |
const std = @import("std");
pub const uint = u32;
pub const sizei = i32;
pub const int = i32;
pub const Enum = c_uint;
pub const char = u8;
pub const boolean = u8;
pub const float = f32;
pub const byte = i8;
pub const FALSE = 0x0;
pub const TRUE = 0x1;
pub const COLOR_BUFFER_BIT = 0x00004000;
pub const DEPTH_BUFFER_BIT = 0x00000100;
pub const FRAGMENT_SHADER = 0x8B30;
pub const VERTEX_SHADER = 0x8B31;
pub const GEOMETRY_SHADER = 0x8DD9;
pub const COMPILE_STATUS = 0x8B81;
pub const INFO_LOG_LENGTH = 0x8B84;
pub const STATIC_DRAW = 0x88E4;
pub const LINK_STATUS = 0x8B82;
pub const ARRAY_BUFFER = 0x8892;
pub const FLOAT = 0x1406;
pub const UNSIGNED_BYTE = 0x1401;
pub const POINTS = 0x0000;
pub const TRIANGLES = 0x0004;
pub const TRIANGLE_STRIP = 0x0005;
pub const TRIANGLE_FAN = 0x0006;
pub const LINE_STRIP = 0x0003;
pub const DYNAMIC_DRAW = 0x88E8;
pub const DEPTH_TEST = 0x0B71;
pub const CULL_FACE = 0x0B44;
pub const FRONT = 0x0405;
pub const BACK = 0x0404;
pub const EXTENSIONS = 0x1F03;
pub const BLEND = 0x0BE2;
pub const ZERO = 0;
pub const ONE = 1;
pub const SRC_COLOR = 0x0300;
pub const ONE_MINUS_SRC_COLOR = 0x0301;
pub const SRC_ALPHA = 0x0302;
pub const ONE_MINUS_SRC_ALPHA = 0x0303;
pub const DST_ALPHA = 0x0304;
pub const ONE_MINUS_DST_ALPHA = 0x0305;
pub const FRAMEBUFFER = 0x8D40;
pub const TEXTURE_2D = 0x0DE1;
pub const TEXTURE_MAG_FILTER = 0x2800;
pub const TEXTURE_MIN_FILTER = 0x2801;
pub const TEXTURE_WRAP_S = 0x2802;
pub const TEXTURE_WRAP_T = 0x2803;
pub const NEAREST = 0x2600;
pub const LINEAR = 0x2601;
pub const CLAMP_TO_EDGE = 0x812F;
pub const RGBA = 0x1908;
pub const COLOR_ATTACHMENT0 = 0x8CE0;
pub const READ_FRAMEBUFFER = 0x8CA8;
pub const DRAW_FRAMEBUFFER = 0x8CA9;
pub const TEXTURE0 = 0x84C0;
pub const TEXTURE1 = 0x84C1;
pub const TEXTURE2 = 0x84C2;
pub const VIEWPORT = 0x0BA2;
glClear: fn (c_uint) void,
glClearColor: fn (f32, f32, f32, f32) void,
glUseProgram: fn (c_uint) void,
glCreateProgram: fn () uint,
glCreateShader: fn (Enum) uint,
glAttachShader: fn (uint, uint) void,
glShaderSource: fn (uint, sizei, [*]const [*]const char, ?[*]const int) void,
glCompileShader: fn (uint) void,
glGetShaderiv: fn (uint, Enum, *int) void,
glGetShaderInfoLog: fn (uint, sizei, *sizei, [*]char) void,
glGenBuffers: fn (sizei, [*]uint) void,
glBindBuffer: fn (Enum, uint) void,
glGenTextures: fn (sizei, [*]uint) void,
glBufferData: fn (Enum, sizei, ?*const c_void, Enum) void,
glLinkProgram: fn (uint) void,
glGetProgramiv: fn (uint, Enum, *int) void,
glGetProgramInfoLog: fn (uint, sizei, *sizei, [*]char) void,
glEnableVertexAttribArray: fn (uint) void,
glVertexAttribPointer: fn (uint, int, Enum, boolean, sizei, ?*c_void) void,
glDrawArrays: fn (Enum, int, sizei) void,
glGetError: fn () Enum,
glGenVertexArrays: fn (sizei, [*]uint) void,
glBindVertexArray: fn (uint) void,
glDrawArraysInstanced: fn (Enum, int, sizei, sizei) void,
glVertexAttribDivisor: fn (uint, uint) void,
glGetUniformLocation: fn (uint, [*:0]const char) int,
glUniform1f: fn (int, float) void,
glUniform1i: fn (int, int) void,
glUniform3f: fn (int, float, float, float) void,
glUniform4f: fn (int, float, float, float, float) void,
glBufferSubData: fn (Enum, int, sizei, ?*const c_void) void,
glEnable: fn (Enum) void,
glDisable: fn (Enum) void,
glCullFace: fn (Enum) void,
glBlendFunc: fn (Enum, Enum) void,
glUniformMatrix4fv: fn (int, sizei, boolean, [*]const f32) void,
glGenFramebuffers: fn (sizei, [*]uint) void,
glBindFramebuffer: fn (Enum, uint) void,
glBindTexture: fn (Enum, uint) void,
glTexParameteri: fn (Enum, Enum, int) void,
glTexImage2D: fn (Enum, int, int, sizei, sizei, int, Enum, Enum, ?*const c_void) void,
glFramebufferTexture2D: fn (Enum, Enum, Enum, uint, int) void,
glViewport: fn (int, int, sizei, sizei) void,
glActiveTexture: fn (Enum) void,
glGetIntegerv: fn (Enum, [*]int) void,
glReadPixels: fn (int, int, sizei, sizei, Enum, Enum, *c_void) void,
glDeleteVertexArrays: fn (sizei, [*]uint) void,
glDeleteBuffers: fn (sizei, [*]uint) void,
glDeleteFramebuffers: fn (sizei, [*]uint) void,
glDeleteTextures: fn (sizei, [*]uint) void,
pub fn callCheckError(self: @This(), comptime name: []const u8, args: anytype) ReturnT: {
@setEvalBranchQuota(10000);
const idx = std.meta.fieldIndex(@This(), name).?;
const info = @typeInfo(std.meta.fields(@This())[idx].field_type);
break :ReturnT info.Fn.return_type.?;
} {
const result = @call(.{}, @field(self, name), args);
if (comptime std.debug.runtime_safety) {
const err = self.glGetError();
if (err != 0) {
std.log.err("Calling '{s}' resulted in an error: {}", .{ name, err });
}
}
return result;
} | src/util/opengl.zig |
const std = @import("std");
const float = @import("float.zig");
const type_fields = std.meta.fields;
pub const LinearAlgebraConfig = struct {
/// should functions expect angles to be given in degrees?
use_degrees: bool = false, // TODO: split into separate functions instead?
/// how should integers be divided?
integer_division_behavior: enum {
truncate,
floor,
exact,
} = .truncate,
/// automatically ensure quaternions are normalized for slerp functions and vector rotation
auto_normalize_quaternions: bool = true,
/// ensure types have a guaranteed memory layout
extern_types: bool = true,
};
pub fn WithType(comptime Number: type, comptime settings: LinearAlgebraConfig) type {
const number_typeinfo = @typeInfo(Number);
// zig fmt: off
const number_is_signed = if (number_typeinfo == .Int)
number_typeinfo.Int.signedness == .signed
else if (number_typeinfo == .Float)
true
else
@compileError("Number type must be an integer or float!");
// zig fmt: on
const number_is_float = number_typeinfo == .Float;
const epsilon = if (number_is_float) std.math.epsilon(Number) else 0;
const divide = struct {
pub fn execute(a: Number, b: Number) callconv(.Inline) Number {
return if (number_is_float)
return a / b
else
comptime switch (settings.integer_division_behavior) {
.truncate => @divTrunc(a, b),
.floor => @divFloor(a, b),
.exact => @divExact(a, b),
};
}
}.execute;
return struct {
const Alg = @This();
fn VectorMixin(comptime Vec: type) type {
return struct {
const VecRhsInfo = enum {
array,
struct_field,
};
fn GetVecArithRhsInfo(comptime T: type) VecRhsInfo {
const vector_len = type_fields(Vec).len;
var result: VecRhsInfo = undefined;
switch (@typeInfo(T)) {
.Array => |a| {
if (a.len != vector_len)
@compileError("Array length does not match vector length!");
switch (@typeInfo(a.child)) {
.Int, .Float => {
result = .array;
},
else => @compileError("Invalid type for vector arithmetic!"),
}
},
.Struct => |s| {
if (s.fields.len != vector_len)
@compileError("Struct field count does not match vector length!");
result = .struct_field;
},
else => @compileError("Invalid type for vector arithmetic!"),
}
return result;
}
pub usingnamespace if (number_is_signed)
struct {
/// returns vector where every field is it's negative value
/// does not account for overflow
pub fn negative(self: Vec) Vec {
var result: Vec = undefined;
inline for (type_fields(Vec)) |field| {
@field(result, field.name) = -@field(self, field.name);
}
return result;
}
/// returns vector where every field is it's absolute value
/// does not account for overflow
pub fn abs(self: Vec) Vec {
var result: Vec = self;
inline for (type_fields(Vec)) |field| {
if (number_is_float)
@field(result, field.name) = @fabs(@field(self, field.name))
else
@field(result, field.name) = if (@field(self, field.name) < 0)
-@field(self, field.name)
else
@field(self, field.name);
}
return result;
}
}
else
struct {};
/// check equality between every field in `a` and `b`
pub fn equals(a: Vec, b: anytype) bool {
inline for (type_fields(Vec)) |field, i| {
const field_a = @field(a, field.name);
const field_b = comptime switch (GetVecArithRhsInfo(@TypeOf(b))) {
.struct_field => @field(b, type_fields(@TypeOf(b))[i].name),
.array => b[i],
};
if (number_is_float)
if (!std.math.approxEqAbs(Number, field_a, field_b, epsilon))
return false
else if (field_a != field_b)
return false;
}
return true;
}
/// add the fields of `a` and `b`
pub fn add(a: Vec, b: anytype) Vec {
var result: Vec = undefined;
inline for (type_fields(Vec)) |field, i| {
@field(result, field.name) = @field(a, field.name) + comptime switch (GetVecArithRhsInfo(@TypeOf(b))) {
.struct_field => @field(b, type_fields(@TypeOf(b))[i].name),
.array => b[i],
};
}
return result;
}
/// subtract the fields of `b` from `a`
pub fn sub(a: Vec, b: anytype) Vec {
var result: Vec = undefined;
inline for (type_fields(Vec)) |field, i| {
@field(result, field.name) = @field(a, field.name) - comptime switch (GetVecArithRhsInfo(@TypeOf(b))) {
.struct_field => @field(b, type_fields(@TypeOf(b))[i].name),
.array => b[i],
};
}
return result;
}
/// multiply all the fields of `a` by `b`
pub fn mul(a: Vec, b: anytype) Vec {
var result: Vec = undefined;
inline for (type_fields(Vec)) |field, i| {
@field(result, field.name) = @field(a, field.name) * comptime switch (GetVecArithRhsInfo(@TypeOf(b))) {
.struct_field => @field(b, type_fields(@TypeOf(b))[i].name),
.array => b[i],
};
}
return result;
}
/// divide all the fields of `a` by `b`
pub fn div(a: Vec, b: anytype) Vec {
var result: Vec = undefined;
inline for (type_fields(Vec)) |field, i| {
const field_a = @field(a, field.name);
const field_b = comptime switch (GetVecArithRhsInfo(@TypeOf(b))) {
.struct_field => @field(b, type_fields(@TypeOf(b))[i].name),
.array => b[i],
};
@field(result, field.name) = divide(field_a, field_b);
}
return result;
}
/// multiply all the fields of `vec` by `scalar`
pub fn scale(vec: Vec, scalar: Number) Vec {
var result = vec;
inline for (type_fields(Vec)) |field| {
@field(result, field.name) *= scalar;
}
return result;
}
/// divide all the fields of `vec` by `scalar`
pub fn divScale(vec: Vec, scalar: Number) Vec {
var result: Vec = undefined;
inline for (type_fields(Vec)) |field| {
@field(result, field.name) = divide(@field(vec, field.name), scalar);
}
return result;
}
/// returns the sum of the products of each field
pub fn dot(a: Vec, b: anytype) Number {
var result: Number = 0;
inline for (type_fields(Vec)) |field, i| {
result += @field(a, field.name) * comptime switch (GetVecArithRhsInfo(@TypeOf(b))) {
.struct_field => @field(b, type_fields(@TypeOf(b))[i].name),
.array => b[i],
};
}
return result;
}
/// returns the squared length of the vector
pub fn lengthSq(self: Vec) Number {
return self.dot(self);
}
pub usingnamespace if (number_is_float)
struct {
/// returns the length of the vector
pub fn length(self: Vec) Number {
return std.math.sqrt(self.lengthSq());
}
/// returns the vector scaled to have a length of 1, or a zero vector if length is 0
pub fn normalized(self: Vec) Vec {
const len = self.length();
var result = Vec.zero;
if (len != 0)
result = self.divScale(len);
return result;
}
/// ensure length of `self` is no less than `min`
pub fn clampMin(self: Vec, min: Number) Vec {
return if (self.lengthSq() < min * min)
self.normalized().scale(min)
else
self;
}
/// ensure length of `self` is no greater than `min`
pub fn clampMax(self: Vec, max: Number) Vec {
return if (self.lengthSq() > max * max)
self.normalized().scale(max)
else
self;
}
/// ensure length of `self` is no less than `min` or greater than `max`
pub fn clamp(self: Vec, min: Number, max: Number) Vec {
const length_sq = self.lengthSq();
return if (length_sq < min * min)
self.normalized().scale(min)
else if (length_sq > max * max)
self.normalized().scale(max)
else
self;
}
/// returns the angle between `a` and `b`
pub fn angleTo(a: Vec, b: Vec) Number {
var angle = std.math.acos(divide(a.dot(b), a.length() * b.length()));
if (settings.use_degrees)
return float.toDegrees(angle)
else
return angle;
}
/// returns linear interpolation between `a` and `b`
pub fn lerp(a: Vec, b: Vec, t: Number) Vec {
return a.add(b.sub(a).scale(t));
}
pub fn slide(vec: Vec, normal: Vec) Vec {
return vec.sub(normal.scale(vec.dot(normal)));
}
}
else
struct {};
fn SwizzleTypeByElements(comptime i: usize) type {
return switch (i) {
1 => Number,
2 => Vec2,
3 => Vec3,
4 => Vec4,
else => @compileError("Swizzle takes between 1 and 4 fields!"),
};
}
/// swizzle vector fields into a new vector or scalar value
/// rgba can be used as an alternative to xyzw
/// 0 and 1 are also valid values
pub fn swizzle(self: Vec, comptime fields: []const u8) SwizzleTypeByElements(fields.len) {
const T = SwizzleTypeByElements(fields.len);
var result: T = undefined;
if (fields.len > 1) {
inline for (fields) |field, i| {
@field(result, switch (i) {
0 => "x",
1 => "y",
2 => "z",
3 => "w",
else => unreachable,
}) = switch (field) {
'0' => 0,
'1' => 1,
'x', 'r' => @field(self, "x"),
'y', 'g' => @field(self, "y"),
'z', 'b' => @field(self, "z"),
'w', 'a' => @field(self, "w"),
else => @compileError("Invalid swizzle field `" ++ field ++ "`!"),
};
}
} else if (fields.len == 1) {
result = @field(self, fields);
} else {
@compileError("Swizzle must contain at least one field!");
}
return result;
}
};
}
const Vec2Mixin = struct {
pub usingnamespace VectorMixin(Vec2);
pub const zero = Vec2.new(0, 0);
pub const one = Vec2.new(1, 1);
pub const unitX = Vec2.new(1, 0);
pub const unitY = Vec2.new(0, 1);
pub usingnamespace if (number_is_signed)
struct {
pub const right = unitX;
pub const left = right.negative();
pub const up = unitY;
pub const down = up.negative();
}
else
struct {};
pub fn new(x: Number, y: Number) Vec2 {
return Vec2{
.x = x,
.y = y,
};
}
pub fn toAngle(self: Vec2) Number {
if (settings.use_degrees)
return float.toDegrees(std.math.atan2(Number, self.y, self.x))
else
return std.math.atan2(Number, self.y, self.x);
}
pub fn rotate(self: Vec2, angle: Number) Vec2 {
const _angle = if (settings.use_degrees) float.toRadians(angle) else angle;
const sin = @sin(_angle);
const cos = @sin(_angle);
return Vec2.new(
(self.x * cos) - (self.y * sin),
(self.x * sin) + (self.y * cos),
);
}
pub fn perpendicularClockwise(self: Vec2) Vec2 {
return Vec2.new(self.y, -self.x);
}
pub fn perpendicularCounterClockwise(self: Vec2) Vec2 {
return Vec2.new(-self.y, self.x);
}
pub fn format(self: Vec2, comptime fmt: []const u8, options: std.fmt.FormatOptions, stream: anytype) !void {
_ = fmt;
_ = options;
try stream.print("Vec2({d:.2}, {d:.2})", .{ self.x, self.y });
}
};
pub const Vec2 = if (settings.extern_types)
extern struct {
x: Number,
y: Number,
usingnamespace Vec2Mixin;
}
else
struct {
x: Number,
y: Number,
usingnamespace Vec2Mixin;
};
pub const Vec3Mixin = struct {
pub usingnamespace VectorMixin(Vec3);
pub const zero = Vec3.new(0, 0, 0);
pub const one = Vec3.new(1, 1, 1);
pub const unitX = Vec3.new(1, 0, 0);
pub const unitY = Vec3.new(0, 1, 0);
pub const unitZ = Vec3.new(0, 0, 1);
pub usingnamespace if (number_is_signed)
struct {
pub const right = unitX;
pub const left = right.negative();
pub const up = unitY;
pub const down = up.negative();
pub const forward = unitZ;
pub const backward = forward.negative();
}
else
struct {};
/// calculate a vector perpendicular to `a` and `b`
pub fn cross(a: Vec3, b: Vec3) Vec3 {
return Vec3.new(
(a.y * b.z) - (a.z * b.y),
(a.z * b.x) - (a.x * b.z),
(a.x * b.y) - (a.y * b.x),
);
}
pub usingnamespace if (number_is_float)
struct {
/// return `self` rotated by `quat`
pub fn rotate(self: Vec3, quaternion: Alg.Quaternion) Vec3 {
return quaternion.rotateVector(self);
}
}
else
struct {};
pub fn new(x: Number, y: Number, z: Number) Vec3 {
return Vec3{
.x = x,
.y = y,
.z = z,
};
}
pub fn format(self: Vec3, comptime fmt: []const u8, options: std.fmt.FormatOptions, stream: anytype) !void {
_ = fmt;
_ = options;
try stream.print("Vec3({d:.2}, {d:.2}, {d:.2})", .{ self.x, self.y, self.z });
}
};
pub const Vec3 = if (settings.extern_types)
extern struct {
x: Number,
y: Number,
z: Number,
usingnamespace Vec3Mixin;
}
else
struct {
x: Number,
y: Number,
z: Number,
usingnamespace Vec3Mixin;
};
pub const Vec4Mixin = struct {
pub usingnamespace VectorMixin(Vec4);
pub const zero = Vec4.new(0, 0, 0, 0);
pub const one = Vec4.new(1, 1, 1, 1);
pub const unitX = Vec4.new(1, 0, 0, 0);
pub const unitY = Vec4.new(0, 1, 0, 0);
pub const unitZ = Vec4.new(0, 0, 1, 0);
pub const unitW = Vec4.new(0, 0, 0, 1);
pub usingnamespace if (number_is_signed)
struct {
pub const right = unitX;
pub const left = right.negative();
pub const up = unitY;
pub const down = up.negative();
pub const forward = unitZ;
pub const backward = forward.negative();
}
else
struct {};
pub fn new(x: Number, y: Number, z: Number, w: Number) Vec4 {
return Vec4{
.x = x,
.y = y,
.z = z,
.w = w,
};
}
pub fn format(self: Vec4, comptime fmt: []const u8, options: std.fmt.FormatOptions, stream: anytype) !void {
_ = fmt;
_ = options;
try stream.print("Vec4({d:.2}, {d:.2}, {d:.2}, {d:.2})", .{ self.x, self.y, self.z, self.w });
}
};
pub const Vec4 = if (settings.extern_types)
extern struct {
x: Number,
y: Number,
z: Number,
w: Number,
usingnamespace Vec4Mixin;
}
else
struct {
x: Number,
y: Number,
z: Number,
w: Number,
usingnamespace Vec4Mixin;
};
pub fn vec2(x: Number, y: Number) Vec2 {
return Vec2.new(x, y);
}
pub fn vec3(x: Number, y: Number, z: Number) Vec3 {
return Vec3.new(x, y, z);
}
pub fn vec4(x: Number, y: Number, z: Number, w: Number) Vec4 {
return Vec4.new(x, y, z, w);
}
usingnamespace if (number_is_float)
struct {
pub fn quat(s: Number, x: Number, y: Number, z: Number) Quaternion {
return Quaternion.new(s, x, y, z);
}
pub const QuaternionMixin = struct {
pub const zero = quat(0, 0, 0, 0);
pub const identity = quat(1, 0, 0, 0);
pub const add = VectorMixin(Quaternion).add;
pub const sub = VectorMixin(Quaternion).sub;
pub const scale = VectorMixin(Quaternion).scale;
pub const divScale = VectorMixin(Quaternion).divScale;
pub const lengthSq = VectorMixin(Quaternion).lengthSq;
pub const length = VectorMixin(Quaternion).length;
pub const dot = VectorMixin(Quaternion).dot;
pub const normalized = VectorMixin(Quaternion).normalized;
pub const angleTo = VectorMixin(Quaternion).angleTo;
pub const lerp = VectorMixin(Quaternion).lerp;
pub const negative = VectorMixin(Quaternion).negative;
pub const equals = VectorMixin(Quaternion).equals;
pub fn mul(a: Quaternion, b: Quaternion) Quaternion {
var vector_a = vec3(a.x, a.y, a.z);
var vector_b = vec3(b.x, b.y, b.z);
var scalar_c = (a.s * b.s) - vector_a.dot(vector_b);
var vector_c = vector_b.scale(a.s)
.add(vector_a.scale(b.s))
.add(vector_a.cross(vector_b));
return quat(scalar_c, vector_c.x, vector_c.y, vector_c.z);
}
pub fn conjugate(self: Quaternion) Quaternion {
return quat(self.s, -self.x, -self.y, -self.z);
}
pub fn inverse(self: Quaternion) Quaternion {
return self.conjugate().divScale(self.lengthSq());
}
pub fn rotateVector(self: Quaternion, vector: Vec3) Vec3 {
const q = if (settings.auto_normalize_quaternions) self.normalized() else self;
var qv = vec3(q.x, q.y, q.z);
return vector.add(
qv.cross(
qv.cross(vector).add(vector.scale(q.s)),
).scale(2.0),
);
}
pub fn lerpShortestPath(a: Quaternion, b: Quaternion, t: Number) Quaternion {
if (a.dot(b) < 0)
return a.lerp(b.negative(), t)
else
return a.lerp(b, t);
}
/// returns spherical linear interpolation between `a` and `b`
pub fn slerp(a: Quaternion, b: Quaternion, t: Number) Quaternion {
const qa = if (settings.auto_normalize_quaternions) a.normalized() else a;
const qb = if (settings.auto_normalize_quaternions) b.normalized() else b;
var dp = qa.dot(qb);
// if quaternions are similar enough, fall back to lerp
// apparently this can cause shaking at the ends of long bone chains?
if (dp > 1 - epsilon) {
return qa.lerpShortestPath(qb, t);
}
const theta = std.math.acos(dp);
return qa
.scale(@sin(theta * (1 - t)))
.add(qb.scale(theta * t))
.divScale(@sin(theta));
}
/// returns spherical linear interpolation on the shortest path between `a` and `b`
pub fn slerpShortestPath(a: Quaternion, b: Quaternion, t: Number) Quaternion {
const qa = if (settings.auto_normalize_quaternions) a.normalized() else a;
var qb = if (settings.auto_normalize_quaternions) b.normalized() else b;
var dp = qa.dot(qb);
// take shortest path
if (dp < 0) {
qb = qb.negative();
dp = -dp;
}
// if quaternions are similar enough, fall back to lerp
// apparently this can cause shaking at the ends of long bone chains?
if (dp > 1 - epsilon) {
return qa.lerp(qb, t);
}
const theta = std.math.acos(dp);
return qa
.scale(@sin(theta * (1 - t)))
.add(qb.scale(theta * t))
.divScale(@sin(theta));
}
pub fn right(self: Quaternion) Vec3 {
return vec3(
1 - (2 * (self.y * self.y + self.z * self.z)),
2 * (self.x * self.y - self.s * self.z),
2 * (self.s * self.y + self.x * self.z),
);
}
pub fn up(self: Quaternion) Vec3 {
return vec3(
2 * (self.x * self.y + self.s * self.z),
1 - (2 * (self.x * self.x + self.z * self.z)),
2 * (self.y * self.z - self.s * self.x),
);
}
pub fn forward(self: Quaternion) Vec3 {
return vec3(
2 * (self.x * self.z - self.s * self.y),
2 * (self.s * self.x + self.y * self.z),
1 - (2 * (self.x * self.x + self.y * self.y)),
);
}
pub fn new(s: Number, x: Number, y: Number, z: Number) Quaternion {
return Quaternion{
.s = s,
.x = x,
.y = y,
.z = z,
};
}
pub fn fromEulerXYZ(x: Number, y: Number, z: Number) Quaternion {
const _x = if (settings.use_degrees) float.toRadians(x) else x;
const _y = if (settings.use_degrees) float.toRadians(y) else y;
const _z = if (settings.use_degrees) float.toRadians(z) else z;
const half_x = _x * 0.5;
const half_y = _y * 0.5;
const half_z = _z * 0.5;
const sin1 = @sin(half_x);
const sin2 = @sin(half_y);
const sin3 = @sin(half_z);
const cos1 = @cos(half_x);
const cos2 = @cos(half_y);
const cos3 = @cos(half_z);
// zig fmt: off
return quat(
-sin1 * sin2 * sin3 + cos1 * cos2 * cos3,
sin1 * cos2 * cos3 + sin2 * sin3 * cos1,
-sin1 * sin3 * cos2 + sin2 * cos1 * cos3,
sin1 * sin2 * cos3 + sin3 * cos1 * cos2,
);
// zig fmt: on
}
pub fn fromEuler(euler: Vec3) Quaternion {
return fromEulerXYZ(euler.x, euler.y, euler.z);
}
pub fn fromAxisAngle(axis: Vec3, angle: Number) Quaternion {
const _angle = if (settings.use_degrees) float.toRadians(angle) else angle;
const sin_angle = @sin(_angle * 0.5);
const cos_angle = @cos(_angle * 0.5);
const vector = axis.scale(sin_angle);
return quat(cos_angle, vector.x, vector.y, vector.z);
}
pub fn format(self: Quaternion, comptime fmt: []const u8, options: std.fmt.FormatOptions, stream: anytype) !void {
_ = fmt;
_ = options;
try stream.print("quat({d:.2}, {d:.2}i, {d:.2}j, {d:.2}k)", .{ self.s, self.x, self.y, self.z });
}
};
pub const Quaternion = if (settings.extern_types)
extern struct {
s: Number,
x: Number,
y: Number,
z: Number,
usingnamespace QuaternionMixin;
}
else
struct {
s: Number,
x: Number,
y: Number,
z: Number,
usingnamespace QuaternionMixin;
};
}
else
struct {};
fn MatrixMixin(comptime rows: usize, comptime columns: usize) type {
return struct {
const Self = Matrix(rows, columns);
pub const row_len = rows;
pub const col_len = columns;
pub const zero = Self{
.fields = [1][columns]Number{[1]Number{0} ** columns} ** rows,
};
pub usingnamespace if (rows == columns)
struct {
pub const identity = mat: {
var matrix = zero;
@setEvalBranchQuota(10000);
for (matrix.fields) |*row, y| {
for (row) |*col, x| {
var i = x + (y * rows);
if (i % (rows + 1) == 0)
col.* = 1;
}
}
break :mat matrix;
};
}
else
struct {};
pub usingnamespace if (rows == 4 and columns == 4)
Mat4x4Mixin
else
struct {};
pub fn new(fields: [rows][columns]Number) Self {
return Self{
.fields = fields,
};
}
const MatrixRhsInfo = struct {
rows: usize,
cols: usize,
access: enum {
matrix,
array_1d,
array_2d,
struct_field,
},
};
fn GetMatRhsInfo(comptime T: type) MatrixRhsInfo {
comptime var result: MatrixRhsInfo = undefined;
comptime switch (@typeInfo(T)) {
.Array => |a| {
result.rows = a.len;
result.access = .array_1d;
switch (@typeInfo(a.child)) {
.Array => |b| {
switch (@typeInfo(b.child)) {
.Int, .Float => {
result.cols = b.len;
result.access = .array_2d;
},
else => @compileError("Invalid array type for matrix rhs!"),
}
},
.Int, .Float => result.cols = 1,
else => @compileError("Invalid array type for matrix rhs!"),
}
},
.Struct => |s| {
if (@hasDecl(T, "row_len") and @hasDecl(T, "col_len") and @hasField(T, "fields")) {
result.rows = T.row_len;
result.cols = T.col_len;
result.access = .matrix;
} else {
for (s.fields) |field| {
switch (@typeInfo(field.field_type)) {
.Int, .Float => {},
else => @compileError("Invalid struct type for matrix rhs!"),
}
}
result.rows = s.fields.len;
result.cols = 1;
result.access = .struct_field;
}
},
else => @compileError("Invalid type for matrix rhs!"),
};
return result;
}
/// multiply `a` with `b`
/// number of columns in `a` must equal number of rows in `b`
/// `b` can be a 1d array (len == rows), a 2d array, or a struct (field count == rows)
pub fn mul(a: Self, b: anytype) @TypeOf(b) {
const BType = @TypeOf(b);
const rhs_info = comptime GetMatRhsInfo(BType);
if (columns != rhs_info.rows) {
comptime switch (rhs_info.access) {
.matrix => @compileError("Number of columns in matrix a must equal number of rows in matrix b!"),
.array_1d => @compileError("Number of columns in matrix a must equal length of array b!"),
.array_2d => @compileError("Number of columns in matrix a must equal number of rows of array b!"),
.struct_field => @compileError("Number of columns in matrix a must equal number of fields in struct b!"),
};
}
var result: BType = undefined;
// zig fmt: off
{comptime var row = 0; inline while (row < rhs_info.rows) : (row += 1) {
{comptime var col = 0; inline while (col < rhs_info.cols) : (col += 1) {
var sum: Number = 0;
{comptime var i = 0; inline while (i < Self.col_len) : (i += 1) {
switch (rhs_info.access) {
.matrix => sum += a.fields[row][i] * b.fields[i][col],
.array_1d => sum += a.fields[i][row] * b[i],
.array_2d => sum += a.fields[row][i] * b[i][col],
.struct_field => sum += a.fields[i][row] * @field(b, type_fields(BType)[i].name),
}
}}
switch (rhs_info.access) {
.matrix => result.fields[row][col] = sum,
.array_1d => result[row] = sum,
.array_2d => result[row][col] = sum,
.struct_field => @field(result, type_fields(BType)[row].name) = sum,
}
}}
}}
// zig fmt: on
return result;
}
/// return matrix with rows and columns swapped
pub fn transpose(self: Self) Matrix(col_len, row_len) {
var result: Self = undefined;
for (result.fields) |*row, x| {
for (row) |*cell, y| {
cell.* = self.fields[y][x];
}
}
return result;
}
pub fn equals(a: Self, b: anytype) bool {
const rhs_info = comptime GetMatRhsInfo(@TypeOf(b));
if (columns != rhs_info.cols or rows != rhs_info.rows) {
@compileError("Number of columns and rows must be the same between `a` and `b`!");
}
// zig fmt: off
{comptime var row = 0; inline while (row < rhs_info.rows) : (row += 1) {
{comptime var col = 0; inline while (col < rhs_info.cols) : (col += 1) {
const field_a = a.fields[row][col];
const field_b = comptime switch (rhs_info.access) {
.matrix => b.fields[row][col],
.array_2d => b[row][col],
.array_1d => b[row],
.struct_field => @field(b, type_fields(@TypeOf(b))[row].name),
};
if (number_is_float)
if (!std.math.approxEqAbs(Number, field_a, field_b, epsilon))
return false
else if (field_a != field_b)
return false;
}}
}}
// zig fmt: on
return true;
}
pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, stream: anytype) !void {
_ = fmt;
_ = options;
try stream.print("Mat{d}x{d}{{\n", .{ rows, columns });
// zig fmt: off
{comptime var row = 0; inline while (row < rows) : (row += 1) {
{comptime var col = 0; inline while (col < columns) : (col += 1) {
try stream.print("{d:>6.2}, ", .{self.fields[row][col]});
}}
try stream.writeAll("\n");
}}
// zig fmt: on
try stream.writeAll("}");
}
};
}
pub fn Matrix(comptime rows: usize, comptime columns: usize) type {
if (rows == 0 or columns == 0)
@compileError("Matrix rows and columns must both be at least 1!");
return if (settings.extern_types)
extern struct {
fields: [rows][columns]Number,
usingnamespace MatrixMixin(rows, columns);
}
else
struct {
fields: [rows][columns]Number,
usingnamespace MatrixMixin(rows, columns);
};
}
pub const Mat4x4 = Matrix(4, 4);
const Mat4x4Mixin = struct {
pub fn translate(self: Mat4x4, v: Vec3) Mat4x4 {
return self.mul(createTranslation(v));
}
pub fn scale(self: Mat4x4, v: Vec3) Mat4x4 {
return self.mul(createScale(v));
}
pub fn rotate(self: Mat4x4, q: Alg.Quaternion) Mat4x4 {
return self.mul(createRotation(q));
}
pub fn createTranslationXYZ(x: Number, y: Number, z: Number) Mat4x4 {
var result = Mat4x4.identity;
result.fields[3][0] = x;
result.fields[3][1] = y;
result.fields[3][2] = z;
return result;
}
pub fn createTranslation(v: Vec3) Mat4x4 {
return createTranslationXYZ(v.x, v.y, v.z);
}
pub fn createScaleXYZ(x: Number, y: Number, z: Number) Mat4x4 {
var result = Mat4x4.identity;
result.fields[0][0] = x;
result.fields[1][1] = y;
result.fields[2][2] = z;
return result;
}
pub fn createScale(v: Vec3) Mat4x4 {
return createScaleXYZ(v.x, v.y, v.z);
}
pub fn createUniformScale(s: Number) Mat4x4 {
return createScaleXYZ(s, s, s);
}
pub fn createAxisAngle(axis: Vec3, angle: Number) Mat4x4 {
return createRotation(Alg.Quaternion.fromAxisAngle(axis, angle));
}
pub fn createRotation(q: Alg.Quaternion) Mat4x4 {
const x2 = q.x * q.x;
const y2 = q.y * q.y;
const z2 = q.z * q.z;
const xy = q.x * q.y;
const xz = q.x * q.z;
const yz = q.y * q.z;
const sx = q.s * q.x;
const sy = q.s * q.y;
const sz = q.s * q.z;
return Mat4x4.new(.{
.{
1 - (2 * (y2 + z2)),
2 * (xy - sz),
2 * (sy + xz),
0,
},
.{
2 * (xy + sz),
1 - (2 * (x2 + z2)),
2 * (yz - sx),
0,
},
.{
2 * (xz - sy),
2 * (sx + yz),
1 - (2 * (x2 + y2)),
0,
},
.{ 0, 0, 0, 1 },
});
}
/// creates an orthographic projection matrix
pub fn createOrthographic(left: Number, right: Number, bottom: Number, top: Number, near: Number, far: Number) Mat4x4 {
var result = Mat4x4.identity;
result.fields[0][0] = 2 / (right - left);
result.fields[1][1] = 2 / (top - bottom);
result.fields[2][2] = -2 / (far - near);
result.fields[3][0] = -((right + left) / (right - left));
result.fields[3][1] = -((top + bottom) / (top - bottom));
result.fields[3][2] = -((far + near) / (far - near));
return result;
}
/// creates a perspective projection matrix
pub fn createPerspective(fov: Number, aspect: Number, near: Number, far: Number) Mat4x4 {
const _fov = if (settings.use_degrees) float.toRadians(fov) else fov;
std.debug.assert(@fabs(aspect) > epsilon);
std.debug.assert(!std.math.approxEqAbs(Number, near, far, epsilon));
const tan_half_fov = std.math.tan(_fov / 2);
var result = Mat4x4.zero;
result.fields[0][0] = 1.0 / (aspect * tan_half_fov);
result.fields[1][1] = 1.0 / (tan_half_fov);
result.fields[2][2] = far / (far - near);
result.fields[2][3] = 1;
result.fields[3][2] = -(far * near) / (far - near);
return result;
}
};
};
}
// TODO: add a lot more tests
test "vec2 arithmetic" {
const expect = std.testing.expect;
const lm = WithType(f32, .{});
const a = lm.vec2(1, 2);
const b = lm.vec2(3, 4);
try expect(a.add([2]f32{ 3, 4 }).equals(lm.vec2(4, 6)));
try expect(a.add(b).equals(lm.vec2(4, 6)));
try expect(a.sub(b).equals(lm.vec2(-2, -2)));
try expect(a.mul(b).equals(lm.vec2(3, 8)));
try expect(a.div(b).equals(lm.vec2(1.0 / 3.0, 0.5)));
try expect(a.scale(2).equals(lm.vec2(2, 4)));
try expect(a.divScale(2).equals(lm.vec2(0.5, 1)));
try expect(a.negative().equals(lm.vec2(-1, -2)));
try expect(a.negative().abs().equals(a));
try expect(std.math.approxEqAbs(
f32,
lm.vec2(0, 1).angleTo(lm.vec2(0, -1)),
std.math.pi,
0.001,
));
try expect(a.dot(b) == 11.0);
try expect(a.lengthSq() == 5.0);
try expect(b.lengthSq() == 25.0);
}
test "vec3 arithmetic" {
const expect = std.testing.expect;
const lm = WithType(f32, .{});
const a = lm.vec3(1, 2, 3);
const b = lm.vec3(4, 5, 6);
try expect(a.add([3]f32{ 4, 5, 6 }).equals(lm.vec3(5, 7, 9)));
try expect(a.add(b).equals(lm.vec3(5, 7, 9)));
try expect(a.sub(b).equals(lm.vec3(-3, -3, -3)));
try expect(a.mul(b).equals(lm.vec3(4, 10, 18)));
try expect(a.div(b).equals(lm.vec3(0.25, 0.4, 0.5)));
try expect(a.scale(2).equals(lm.vec3(2, 4, 6)));
try expect(a.divScale(2).equals(lm.vec3(0.5, 1, 1.5)));
try expect(a.negative().equals(lm.vec3(-1, -2, -3)));
try expect(a.negative().abs().equals(a));
try expect(a.cross(b).equals(lm.vec3(-3, 6, -3)));
try expect(std.math.approxEqAbs(
f32,
lm.vec3(0, 1, 0).angleTo(lm.vec3(0, -1, 0)),
std.math.pi,
0.001,
));
try expect(a.dot(b) == 32.0);
try expect(a.lengthSq() == 14.0);
try expect(b.lengthSq() == 77.0);
}
test "i32 vec3 arithmetic" {
const expect = std.testing.expect;
const lm = WithType(i32, .{});
const a = lm.vec3(2, 4, 6);
const b = lm.vec3(8, 10, 12);
try expect(a.add([3]i32{ 8, 10, 12 }).equals(lm.vec3(10, 14, 18)));
try expect(a.add(b).equals(lm.vec3(10, 14, 18)));
try expect(a.sub(b).equals(lm.vec3(-6, -6, -6)));
try expect(a.mul(b).equals(lm.vec3(16, 40, 72)));
try expect(b.div(a).equals(lm.vec3(4, 2, 2)));
try expect(a.scale(2).equals(lm.vec3(4, 8, 12)));
try expect(b.divScale(2).equals(lm.vec3(4, 5, 6)));
try expect(a.negative().equals(lm.vec3(-2, -4, -6)));
try expect(a.negative().abs().equals(a));
try expect(a.cross(b).equals(lm.vec3(-12, 24, -12)));
try expect(a.dot(b) == 128);
try expect(a.lengthSq() == 56);
try expect(b.lengthSq() == 308);
}
test "vec4 arithmetic" {
const expect = std.testing.expect;
const lm = WithType(f32, .{});
const a = lm.vec4(1, 2, 3, 4);
const b = lm.vec4(5, 6, 7, 8);
try expect(a.add([4]f32{ 5, 6, 7, 8 }).equals(lm.vec4(6, 8, 10, 12)));
try expect(a.add(b).equals(lm.vec4(6, 8, 10, 12)));
try expect(a.sub(b).equals(lm.vec4(-4, -4, -4, -4)));
try expect(a.mul(b).equals(lm.vec4(5, 12, 21, 32)));
try expect(a.div(b).equals(lm.vec4(0.2, 1.0 / 3.0, 3.0 / 7.0, 0.5)));
try expect(a.scale(2).equals(lm.vec4(2, 4, 6, 8)));
try expect(a.divScale(2).equals(lm.vec4(0.5, 1, 1.5, 2)));
try expect(a.negative().equals(lm.vec4(-1, -2, -3, -4)));
try expect(a.negative().abs().equals(a));
try expect(std.math.approxEqAbs(
f32,
lm.vec4(0, 1, 0, 0).angleTo(lm.vec4(0, -1, 0, 0)),
std.math.pi,
0.001,
));
try expect(a.dot(b) == 70.0);
try expect(a.lengthSq() == 30.0);
try expect(b.lengthSq() == 174.0);
} | src/linear_algebra.zig |
const std = @import("std");
const testing = std.testing;
const io = @import("io.zig");
const utils = @import("utils.zig");
pub const MAX_KV_KEY_LEN = 128;
pub const MAX_KV_VALUE_LEN = 8 * 1024;
/// TODO: Can make more generic, especially with regards to capacity and entry-lengths
/// pub fn KvStore(comptime KeyType: type, comptime )
/// Possible parameters: max key size, max value size, max num variables
/// Current characteristics: ordered, write-once-pr-key store - you can't update existing entries.
/// New name suggestion: OrderedWoKvStore?
/// Att! Highly inefficient as of now
pub const KvStore = struct {
const Self = @This();
/// Strategy for when key already exists for insertion-actions
pub const CollisionStrategy = enum { KeepFirst, Fail };
pub const KvStoreEntry = struct {
key: std.BoundedArray(u8, MAX_KV_KEY_LEN) = utils.initBoundedArray(u8, MAX_KV_KEY_LEN),
value: std.BoundedArray(u8, MAX_KV_VALUE_LEN) = utils.initBoundedArray(u8, MAX_KV_VALUE_LEN),
pub fn create(key: []const u8, value: []const u8) !KvStoreEntry {
return KvStoreEntry{
.key = try std.BoundedArray(u8, MAX_KV_KEY_LEN).fromSlice(key),
.value = try std.BoundedArray(u8, MAX_KV_VALUE_LEN).fromSlice(value),
};
}
};
store: std.BoundedArray(KvStoreEntry, 32) = utils.initBoundedArray(KvStoreEntry, 32),
/// Insert new key/value. Key must not pre-exist.
pub fn add(self: *Self, key: []const u8, value: []const u8) !void {
if (try self.getIndexFor(key)) |i| {
try self.store.insert(i, try KvStoreEntry.create(key, value));
} else {
// Got null -- append
return self.store.append(try KvStoreEntry.create(key, value));
}
}
/// Find point to insert new key to keep list sorted, or null if it must be appended to end.
/// Returns error if key is already used.
fn getIndexFor(self: *Self, key: []const u8) !?usize {
// Will find point to insert new key to keep list sorted
if (self.count() == 0) return null;
// TODO: can binary search, current solution will be expensive for later entries in large list
for (self.store.slice()) |entry, i| {
switch (std.mem.order(u8, entry.key.constSlice(), key)) {
.gt => {
return i;
},
.lt => {}, // keep going
.eq => {
return error.KeyAlreadyUsed;
},
}
}
return null; // This means end, and thus an append must be done
}
/// Retrieve value for a given key, or null if key not used.
pub fn get(self: *Self, key: []const u8) ?[]const u8 {
// TODO: binary search
for (self.store.slice()) |entry| {
if (std.mem.eql(u8, entry.key.constSlice(), key)) {
return entry.value.constSlice();
}
}
return null;
}
/// Returns number of entries in store
pub fn count(self: *Self) usize {
return self.store.slice().len;
}
/// Returns the slice of keyvalue-entries
pub fn slice(self: *Self) []KvStoreEntry {
return self.store.slice();
}
/// Creates a kvstored based on buffer with lines of 'key=value'-pairs
pub fn fromBuffer(buf: []const u8) !KvStore {
var store = KvStore{};
var line_it = std.mem.split(u8, buf, io.getLineEnding(buf));
while (line_it.next()) |line| {
if (line.len == 0) continue;
if (line[0] == '#') continue;
if (std.mem.indexOf(u8, line, "=")) |eqpos| {
try store.add(line[0..eqpos], line[eqpos + 1 ..]);
} else {
return error.InvalidEntry;
}
}
return store;
}
/// Adds entries to current kvstore based on buffer with lines of 'key=value'-pairs
pub fn addFromBuffer(self: *Self, buf: []const u8, collision_handling: CollisionStrategy) !void {
var line_it = std.mem.split(u8, buf, io.getLineEnding(buf));
while (line_it.next()) |line| {
if (line.len == 0) continue;
if (line[0] == '#') continue;
if (std.mem.indexOf(u8, line, "=")) |eqpos| {
self.add(line[0..eqpos], line[eqpos + 1 ..]) catch |e| switch (e) {
error.KeyAlreadyUsed => switch (collision_handling) {
.KeepFirst => {},
.Fail => return e,
},
else => return e,
};
} else {
return error.InvalidEntry;
}
}
}
/// Add all entries from another kvstore into this
pub fn addFromOther(self: *Self, other: KvStore, collision_handling: CollisionStrategy) !void {
for (other.store.constSlice()) |entry| {
self.add(entry.key.constSlice(), entry.value.constSlice()) catch |e| switch (e) {
error.KeyAlreadyUsed => switch (collision_handling) {
.KeepFirst => {},
.Fail => return e,
},
else => return e,
};
}
}
};
test "KvStore" {
var store = KvStore{};
try testing.expect(store.count() == 0);
try store.add("key", "value");
try testing.expect(store.count() == 1);
try testing.expectEqualStrings("value", store.get("key").?);
}
test "KvStore shall stay ordered" {
var store = KvStore{};
try testing.expect((try store.getIndexFor("bkey")) == null);
try store.add("bkey", "value");
try testing.expect((try store.getIndexFor("akey")).? == 0);
try testing.expect((try store.getIndexFor("ckey")) == null);
try testing.expectError(error.KeyAlreadyUsed, store.getIndexFor("bkey"));
// insert early entry. Add shall fail, and checking for the key shall also fail
try testing.expect((try store.getIndexFor("akey")).? == 0);
try store.add("akey", "value");
try testing.expectError(error.KeyAlreadyUsed, store.add("akey", "value"));
try testing.expect((try store.getIndexFor("ckey")) == null);
}
test "KvFromBuffer" {
{
var store = try KvStore.fromBuffer(
\\
);
try testing.expect(store.count() == 0);
}
{
var store = try KvStore.fromBuffer(
\\# Some comment
);
try testing.expect(store.count() == 0);
}
{
var store = try KvStore.fromBuffer(
\\key=value
);
try testing.expect(store.count() == 1);
try testing.expectEqualStrings("value", store.get("key").?);
}
{
var store = try KvStore.fromBuffer(
\\key=value
\\abba=babba
);
try testing.expect(store.count() == 2);
try testing.expectEqualStrings("babba", store.get("abba").?);
}
{
try testing.expectError(error.InvalidEntry, KvStore.fromBuffer(
\\keyvalue
));
}
} | src/kvstore.zig |
const std = @import("std");
const getty = @import("../../../lib.zig");
pub fn Visitor(comptime Slice: type) type {
return struct {
allocator: std.mem.Allocator,
const Self = @This();
const impl = @"impl Visitor"(Slice);
pub usingnamespace getty.de.Visitor(
Self,
impl.visitor.Value,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
impl.visitor.visitSequence,
impl.visitor.visitString,
undefined,
undefined,
);
};
}
fn @"impl Visitor"(comptime Slice: type) type {
const Self = Visitor(Slice);
return struct {
pub const visitor = struct {
pub const Value = Slice;
pub fn visitSequence(self: Self, seqAccess: anytype) @TypeOf(seqAccess).Error!Value {
var list = std.ArrayList(Child).init(self.allocator);
errdefer getty.de.free(self.allocator, list);
while (try seqAccess.nextElement(Child)) |elem| {
try list.append(elem);
}
return list.toOwnedSlice();
}
pub fn visitString(self: Self, comptime Error: type, input: anytype) Error!Value {
errdefer getty.de.free(self.allocator, input);
// TODO: This type check (and InvalidType error) is a temporary
// workaround for the case where the child type of `Value` isn't a
// u8. In that situation, the compiler keeps both the .ArrayBegin
// and the .String branches, which results in a compiler error since
// `TokenStream.slice` returns a `[]const u8` and we can't `dupe` into,
// say, a `[]const u32` from that.
//
// Maybe what we could do is use `visitSequence` and in the JSON
// deserializer figure out what to do in the SequenceAccess based
// on whether the input is an Array or a String. If this works, do we
// even need a `visitString` method?
return if (Child == u8) input else error.InvalidType;
}
const Child = std.meta.Child(Value);
};
};
} | src/de/impl/visitor/slice.zig |
const builtin = @import("builtin");
const std = @import("std");
const testing = std.testing;
const alsa = @import("main.zig");
test "pcm playback" {
var device: ?*alsa.snd_pcm_t = null;
_ = try alsa.checkError(alsa.snd_pcm_open(
&device,
"default",
alsa.snd_pcm_stream_t.PLAYBACK,
0,
));
var hw_params: ?*alsa.snd_pcm_hw_params_t = null;
_ = try alsa.checkError(alsa.snd_pcm_hw_params_malloc(&hw_params));
defer alsa.snd_pcm_hw_params_free(hw_params);
_ = try alsa.checkError(alsa.snd_pcm_hw_params_any(device, hw_params));
_ = try alsa.checkError(alsa.snd_pcm_hw_params_set_rate_resample(
device,
hw_params,
1,
));
_ = try alsa.checkError(alsa.snd_pcm_hw_params_set_access(
device,
hw_params,
alsa.snd_pcm_access_t.RW_INTERLEAVED,
));
_ = try alsa.checkError(alsa.snd_pcm_hw_params_set_format(
device,
hw_params,
switch (builtin.target.cpu.arch.endian()) {
.Little => alsa.snd_pcm_format_t.FLOAT_LE,
.Big => alsa.snd_pcm_format_t.FLOAT_BE,
},
));
const num_channels = 2;
_ = try alsa.checkError(alsa.snd_pcm_hw_params_set_channels(
device,
hw_params,
num_channels,
));
var sample_rate: c_uint = 44100;
_ = try alsa.checkError(alsa.snd_pcm_hw_params_set_rate_near(
device,
hw_params,
&sample_rate,
null,
));
_ = try alsa.checkError(alsa.snd_pcm_hw_params(device, hw_params));
var buffer_frames: alsa.snd_pcm_uframes_t = undefined;
_ = try alsa.checkError(alsa.snd_pcm_hw_params_get_buffer_size(
hw_params,
&buffer_frames,
));
var buffer = try std.testing.allocator.alloc(f32, buffer_frames * num_channels);
defer std.testing.allocator.free(buffer);
const pitch: f32 = 261.63;
const radians_per_sec = pitch * 2 * std.math.pi;
const sec_per_frame = 1 / @intToFloat(f32, sample_rate);
_ = try alsa.checkError(alsa.snd_pcm_prepare(device));
var frame: usize = 0;
while (frame < buffer_frames) : (frame += 1) {
const s = std.math.sin((@intToFloat(f32, frame) * sec_per_frame) * radians_per_sec);
var channel: usize = 0;
while (channel < num_channels) : (channel += 1) {
buffer[frame * num_channels + channel] = s;
}
}
std.log.warn(
"playing {} seconds of samples...",
.{buffer_frames / sample_rate},
);
if (alsa.snd_pcm_writei(
device,
@ptrCast(*anyopaque, buffer),
buffer_frames,
) < 0) {
_ = try alsa.checkError(alsa.snd_pcm_prepare(device));
}
_ = try alsa.checkError(alsa.snd_pcm_drain(device));
_ = try alsa.checkError(alsa.snd_pcm_close(device));
} | modules/platform/vendored/zig-alsa/src/test.zig |
const std = @import("std");
const stderr = std.debug.warn;
const stdout = &std.io.getStdOut().outStream();
const assert = @import("std").debug.assert;
const c = @import("c.zig");
const c_stdlib = c.c_stdlib;
const gw = c.gw;
const gmp = c.gmp;
const glue = @import("glue.zig");
const u_zero = @import("u_zero.zig");
const helper = @import("helper.zig");
const llr = @import("llr.zig");
const fermat = @import("fermat.zig");
const selftest = @import("selftest.zig");
const argparser = @import("argparser.zig");
const VERSION = "0.2.0";
pub fn main() !void {
// let's be really nice
const err = c_stdlib.setpriority(c_stdlib.PRIO_PROCESS, 0, 19);
try stdout.print("=== RPT - Riesel Prime Tester v{} [GWNUM: {} GMP: {}.{}.{}] ===\n", .{ VERSION, gw.GWNUM_VERSION, gmp.__GNU_MP_VERSION, gmp.__GNU_MP_VERSION_MINOR, gmp.__GNU_MP_VERSION_PATCHLEVEL });
// the only malloc I make is for cmd args
const args = try std.process.argsAlloc(std.heap.page_allocator);
defer std.process.argsFree(std.heap.page_allocator, args);
// parse the few args we take
const parsed_args: argparser.ParsedArgs = try argparser.ParsedArgs.parse(args);
const mode = parsed_args.mode;
switch (mode) {
argparser.RunMode.LLR => {
const threads = parsed_args.threads;
const k = parsed_args.k;
const n = parsed_args.n;
const b: u32 = 2;
const c_: i32 = -1;
const is_prime = try llr.full_llr_run(k, b, n, c_, threads);
},
argparser.RunMode.Fermat => {
const threads = parsed_args.threads;
const k = parsed_args.k;
const n = parsed_args.n;
const b: u32 = 2;
const c_: i32 = -1;
const is_prime = try fermat.full_fermat_run(k, b, n, c_, threads);
},
argparser.RunMode.Selftest => {
const n = parsed_args.n;
const success = selftest.run(n);
},
argparser.RunMode.Help => {
try stdout.print("./rpt --llr <k> <n> [--threads <t>]\n", .{});
try stdout.print("./rpt --fermat <k> <n> [--threads <t>]\n", .{});
try stdout.print("./rpt --selftest [max_n]\n", .{});
},
}
}
export fn llr_ext(k: u32, b: u32, n: u32, c_: i32, threads_: u8) bool {
return llr.full_llr_run(k, b, n, c_, threads_) catch false;
} | rpt.zig |
const std = @import("../../std.zig");
const os = std.os;
const fmt = std.fmt;
const mem = std.mem;
const math = std.math;
const builtin = std.builtin;
const testing = std.testing;
/// Resolves a network interface name into a scope/zone ID. It returns
/// an error if either resolution fails, or if the interface name is
/// too long.
pub fn resolveScopeID(name: []const u8) !u32 {
if (comptime @hasDecl(os, "IFNAMESIZE")) {
if (name.len >= os.IFNAMESIZE - 1) return error.NameTooLong;
const fd = try os.socket(os.AF_UNIX, os.SOCK_DGRAM, 0);
defer os.closeSocket(fd);
var f: os.ifreq = undefined;
mem.copy(u8, &f.ifrn.name, name);
f.ifrn.name[name.len] = 0;
try os.ioctl_SIOCGIFINDEX(fd, &f);
return @bitCast(u32, f.ifru.ivalue);
}
return error.Unsupported;
}
/// An IPv4 address comprised of 4 bytes.
pub const IPv4 = extern struct {
/// A IPv4 host-port pair.
pub const Address = extern struct {
host: IPv4,
port: u16,
};
/// Octets of a IPv4 address designating the local host.
pub const localhost_octets = [_]u8{ 127, 0, 0, 1 };
/// The IPv4 address of the local host.
pub const localhost: IPv4 = .{ .octets = localhost_octets };
/// Octets of an unspecified IPv4 address.
pub const unspecified_octets = [_]u8{0} ** 4;
/// An unspecified IPv4 address.
pub const unspecified: IPv4 = .{ .octets = unspecified_octets };
/// Octets of a broadcast IPv4 address.
pub const broadcast_octets = [_]u8{255} ** 4;
/// An IPv4 broadcast address.
pub const broadcast: IPv4 = .{ .octets = broadcast_octets };
/// The prefix octet pattern of a link-local IPv4 address.
pub const link_local_prefix = [_]u8{ 169, 254 };
/// The prefix octet patterns of IPv4 addresses intended for
/// documentation.
pub const documentation_prefixes = [_][]const u8{
&[_]u8{ 192, 0, 2 },
&[_]u8{ 198, 51, 100 },
&[_]u8{ 203, 0, 113 },
};
octets: [4]u8,
/// Returns whether or not the two addresses are equal to, less than, or
/// greater than each other.
pub fn cmp(self: IPv4, other: IPv4) math.Order {
return mem.order(u8, &self.octets, &other.octets);
}
/// Returns true if both addresses are semantically equivalent.
pub fn eql(self: IPv4, other: IPv4) bool {
return mem.eql(u8, &self.octets, &other.octets);
}
/// Returns true if the address is a loopback address.
pub fn isLoopback(self: IPv4) bool {
return self.octets[0] == 127;
}
/// Returns true if the address is an unspecified IPv4 address.
pub fn isUnspecified(self: IPv4) bool {
return mem.eql(u8, &self.octets, &unspecified_octets);
}
/// Returns true if the address is a private IPv4 address.
pub fn isPrivate(self: IPv4) bool {
return self.octets[0] == 10 or
(self.octets[0] == 172 and self.octets[1] >= 16 and self.octets[1] <= 31) or
(self.octets[0] == 192 and self.octets[1] == 168);
}
/// Returns true if the address is a link-local IPv4 address.
pub fn isLinkLocal(self: IPv4) bool {
return mem.startsWith(u8, &self.octets, &link_local_prefix);
}
/// Returns true if the address is a multicast IPv4 address.
pub fn isMulticast(self: IPv4) bool {
return self.octets[0] >= 224 and self.octets[0] <= 239;
}
/// Returns true if the address is a IPv4 broadcast address.
pub fn isBroadcast(self: IPv4) bool {
return mem.eql(u8, &self.octets, &broadcast_octets);
}
/// Returns true if the address is in a range designated for documentation. Refer
/// to IETF RFC 5737 for more details.
pub fn isDocumentation(self: IPv4) bool {
inline for (documentation_prefixes) |prefix| {
if (mem.startsWith(u8, &self.octets, prefix)) {
return true;
}
}
return false;
}
/// Implements the `std.fmt.format` API.
pub fn format(
self: IPv4,
comptime layout: []const u8,
opts: fmt.FormatOptions,
writer: anytype,
) !void {
if (comptime layout.len != 0 and layout[0] != 's') {
@compileError("Unsupported format specifier for IPv4 type '" ++ layout ++ "'.");
}
try fmt.format(writer, "{}.{}.{}.{}", .{
self.octets[0],
self.octets[1],
self.octets[2],
self.octets[3],
});
}
/// Set of possible errors that may encountered when parsing an IPv4
/// address.
pub const ParseError = error{
UnexpectedEndOfOctet,
TooManyOctets,
OctetOverflow,
UnexpectedToken,
IncompleteAddress,
};
/// Parses an arbitrary IPv4 address.
pub fn parse(buf: []const u8) ParseError!IPv4 {
var octets: [4]u8 = undefined;
var octet: u8 = 0;
var index: u8 = 0;
var saw_any_digits: bool = false;
for (buf) |c| {
switch (c) {
'.' => {
if (!saw_any_digits) return error.UnexpectedEndOfOctet;
if (index == 3) return error.TooManyOctets;
octets[index] = octet;
index += 1;
octet = 0;
saw_any_digits = false;
},
'0'...'9' => {
saw_any_digits = true;
octet = math.mul(u8, octet, 10) catch return error.OctetOverflow;
octet = math.add(u8, octet, c - '0') catch return error.OctetOverflow;
},
else => return error.UnexpectedToken,
}
}
if (index == 3 and saw_any_digits) {
octets[index] = octet;
return IPv4{ .octets = octets };
}
return error.IncompleteAddress;
}
/// Maps the address to its IPv6 equivalent. In most cases, you would
/// want to map the address to its IPv6 equivalent rather than directly
/// re-interpreting the address.
pub fn mapToIPv6(self: IPv4) IPv6 {
var octets: [16]u8 = undefined;
mem.copy(u8, octets[0..12], &IPv6.v4_mapped_prefix);
mem.copy(u8, octets[12..], &self.octets);
return IPv6{ .octets = octets, .scope_id = IPv6.no_scope_id };
}
/// Directly re-interprets the address to its IPv6 equivalent. In most
/// cases, you would want to map the address to its IPv6 equivalent rather
/// than directly re-interpreting the address.
pub fn toIPv6(self: IPv4) IPv6 {
var octets: [16]u8 = undefined;
mem.set(u8, octets[0..12], 0);
mem.copy(u8, octets[12..], &self.octets);
return IPv6{ .octets = octets, .scope_id = IPv6.no_scope_id };
}
};
/// An IPv6 address comprised of 16 bytes for an address, and 4 bytes
/// for a scope ID; cumulatively summing to 20 bytes in total.
pub const IPv6 = extern struct {
/// A IPv6 host-port pair.
pub const Address = extern struct {
host: IPv6,
port: u16,
};
/// Octets of a IPv6 address designating the local host.
pub const localhost_octets = [_]u8{0} ** 15 ++ [_]u8{0x01};
/// The IPv6 address of the local host.
pub const localhost: IPv6 = .{
.octets = localhost_octets,
.scope_id = no_scope_id,
};
/// Octets of an unspecified IPv6 address.
pub const unspecified_octets = [_]u8{0} ** 16;
/// An unspecified IPv6 address.
pub const unspecified: IPv6 = .{
.octets = unspecified_octets,
.scope_id = no_scope_id,
};
/// The prefix of a IPv6 address that is mapped to a IPv4 address.
pub const v4_mapped_prefix = [_]u8{0} ** 10 ++ [_]u8{0xFF} ** 2;
/// A marker value used to designate an IPv6 address with no
/// associated scope ID.
pub const no_scope_id = math.maxInt(u32);
octets: [16]u8,
scope_id: u32,
/// Returns whether or not the two addresses are equal to, less than, or
/// greater than each other.
pub fn cmp(self: IPv6, other: IPv6) math.Order {
return switch (mem.order(u8, self.octets, other.octets)) {
.eq => math.order(self.scope_id, other.scope_id),
else => |order| order,
};
}
/// Returns true if both addresses are semantically equivalent.
pub fn eql(self: IPv6, other: IPv6) bool {
return self.scope_id == other.scope_id and mem.eql(u8, &self.octets, &other.octets);
}
/// Returns true if the address is an unspecified IPv6 address.
pub fn isUnspecified(self: IPv6) bool {
return mem.eql(u8, &self.octets, &unspecified_octets);
}
/// Returns true if the address is a loopback address.
pub fn isLoopback(self: IPv6) bool {
return mem.eql(u8, self.octets[0..3], &[_]u8{ 0, 0, 0 }) and
mem.eql(u8, self.octets[12..], &[_]u8{ 0, 0, 0, 1 });
}
/// Returns true if the address maps to an IPv4 address.
pub fn mapsToIPv4(self: IPv6) bool {
return mem.startsWith(u8, &self.octets, &v4_mapped_prefix);
}
/// Returns an IPv4 address representative of the address should
/// it the address be mapped to an IPv4 address. It returns null
/// otherwise.
pub fn toIPv4(self: IPv6) ?IPv4 {
if (!self.mapsToIPv4()) return null;
return IPv4{ .octets = self.octets[12..][0..4].* };
}
/// Returns true if the address is a multicast IPv6 address.
pub fn isMulticast(self: IPv6) bool {
return self.octets[0] == 0xFF;
}
/// Returns true if the address is a unicast link local IPv6 address.
pub fn isLinkLocal(self: IPv6) bool {
return self.octets[0] == 0xFE and self.octets[1] & 0xC0 == 0x80;
}
/// Returns true if the address is a deprecated unicast site local
/// IPv6 address. Refer to IETF RFC 3879 for more details as to
/// why they are deprecated.
pub fn isSiteLocal(self: IPv6) bool {
return self.octets[0] == 0xFE and self.octets[1] & 0xC0 == 0xC0;
}
/// IPv6 multicast address scopes.
pub const Scope = enum(u8) {
interface = 1,
link = 2,
realm = 3,
admin = 4,
site = 5,
organization = 8,
global = 14,
unknown = 0xFF,
};
/// Returns the multicast scope of the address.
pub fn scope(self: IPv6) Scope {
if (!self.isMulticast()) return .unknown;
return switch (self.octets[0] & 0x0F) {
1 => .interface,
2 => .link,
3 => .realm,
4 => .admin,
5 => .site,
8 => .organization,
14 => .global,
else => .unknown,
};
}
/// Implements the `std.fmt.format` API. Specifying 'x' or 's' formats the
/// address lower-cased octets, while specifying 'X' or 'S' formats the
/// address using upper-cased ASCII octets.
///
/// The default specifier is 'x'.
pub fn format(
self: IPv6,
comptime layout: []const u8,
opts: fmt.FormatOptions,
writer: anytype,
) !void {
comptime const specifier = &[_]u8{if (layout.len == 0) 'x' else switch (layout[0]) {
'x', 'X' => |specifier| specifier,
's' => 'x',
'S' => 'X',
else => @compileError("Unsupported format specifier for IPv6 type '" ++ layout ++ "'."),
}};
if (mem.startsWith(u8, &self.octets, &v4_mapped_prefix)) {
return fmt.format(writer, "::{" ++ specifier ++ "}{" ++ specifier ++ "}:{}.{}.{}.{}", .{
0xFF,
0xFF,
self.octets[12],
self.octets[13],
self.octets[14],
self.octets[15],
});
}
const zero_span = span: {
var i: usize = 0;
while (i < self.octets.len) : (i += 2) {
if (self.octets[i] == 0 and self.octets[i + 1] == 0) break;
} else break :span .{ .from = 0, .to = 0 };
const from = i;
while (i < self.octets.len) : (i += 2) {
if (self.octets[i] != 0 or self.octets[i + 1] != 0) break;
}
break :span .{ .from = from, .to = i };
};
var i: usize = 0;
while (i != 16) : (i += 2) {
if (zero_span.from != zero_span.to and i == zero_span.from) {
try writer.writeAll("::");
} else if (i >= zero_span.from and i < zero_span.to) {} else {
if (i != 0 and i != zero_span.to) try writer.writeAll(":");
const val = @as(u16, self.octets[i]) << 8 | self.octets[i + 1];
try fmt.formatIntValue(val, specifier, .{}, writer);
}
}
if (self.scope_id != no_scope_id and self.scope_id != 0) {
try fmt.format(writer, "%{d}", .{self.scope_id});
}
}
/// Set of possible errors that may encountered when parsing an IPv6
/// address.
pub const ParseError = error{
MalformedV4Mapping,
BadScopeID,
} || IPv4.ParseError;
/// Parses an arbitrary IPv6 address, including link-local addresses.
pub fn parse(buf: []const u8) ParseError!IPv6 {
if (mem.lastIndexOfScalar(u8, buf, '%')) |index| {
const ip_slice = buf[0..index];
const scope_id_slice = buf[index + 1 ..];
if (scope_id_slice.len == 0) return error.BadScopeID;
const scope_id: u32 = switch (scope_id_slice[0]) {
'0'...'9' => fmt.parseInt(u32, scope_id_slice, 10),
else => resolveScopeID(scope_id_slice),
} catch return error.BadScopeID;
return parseWithScopeID(ip_slice, scope_id);
}
return parseWithScopeID(buf, no_scope_id);
}
/// Parses an IPv6 address with a pre-specified scope ID. Presumes
/// that the address is not a link-local address.
pub fn parseWithScopeID(buf: []const u8, scope_id: u32) ParseError!IPv6 {
var octets: [16]u8 = undefined;
var octet: u16 = 0;
var tail: [16]u8 = undefined;
var out: []u8 = &octets;
var index: u8 = 0;
var saw_any_digits: bool = false;
var abbrv: bool = false;
for (buf) |c, i| {
switch (c) {
':' => {
if (!saw_any_digits) {
if (abbrv) return error.UnexpectedToken;
if (i != 0) abbrv = true;
mem.set(u8, out[index..], 0);
out = &tail;
index = 0;
continue;
}
if (index == 14) return error.TooManyOctets;
out[index] = @truncate(u8, octet >> 8);
index += 1;
out[index] = @truncate(u8, octet);
index += 1;
octet = 0;
saw_any_digits = false;
},
'.' => {
if (!abbrv or out[0] != 0xFF and out[1] != 0xFF) {
return error.MalformedV4Mapping;
}
const start_index = mem.lastIndexOfScalar(u8, buf[0..i], ':').? + 1;
const v4 = try IPv4.parse(buf[start_index..]);
octets[10] = 0xFF;
octets[11] = 0xFF;
mem.copy(u8, octets[12..], &v4.octets);
return IPv6{ .octets = octets, .scope_id = scope_id };
},
else => {
saw_any_digits = true;
const digit = fmt.charToDigit(c, 16) catch return error.UnexpectedToken;
octet = math.mul(u16, octet, 16) catch return error.OctetOverflow;
octet = math.add(u16, octet, digit) catch return error.OctetOverflow;
},
}
}
if (!saw_any_digits and !abbrv) {
return error.IncompleteAddress;
}
if (index == 14) {
out[14] = @truncate(u8, octet >> 8);
out[15] = @truncate(u8, octet);
} else {
out[index] = @truncate(u8, octet >> 8);
index += 1;
out[index] = @truncate(u8, octet);
index += 1;
mem.copy(u8, octets[16 - index ..], out[0..index]);
}
return IPv6{ .octets = octets, .scope_id = scope_id };
}
};
test {
testing.refAllDecls(@This());
}
test "ip: convert to and from ipv6" {
try testing.expectFmt("::7f00:1", "{}", .{IPv4.localhost.toIPv6()});
testing.expect(!IPv4.localhost.toIPv6().mapsToIPv4());
try testing.expectFmt("::ffff:127.0.0.1", "{}", .{IPv4.localhost.mapToIPv6()});
testing.expect(IPv4.localhost.mapToIPv6().mapsToIPv4());
testing.expect(IPv4.localhost.toIPv6().toIPv4() == null);
try testing.expectFmt("127.0.0.1", "{}", .{IPv4.localhost.mapToIPv6().toIPv4()});
}
test "ipv4: parse & format" {
const cases = [_][]const u8{
"0.0.0.0",
"255.255.255.255",
"1.2.3.4",
"192.168.127.12",
"127.0.0.1",
};
for (cases) |case| {
try testing.expectFmt(case, "{}", .{try IPv4.parse(case)});
}
}
test "ipv6: parse & format" {
const inputs = [_][]const u8{
"fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b",
"fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b",
"::1",
"::",
"2001:db8::",
"::1234:5678",
"2001:db8::1234:5678",
"::ffff:172.16.31.10",
};
const outputs = [_][]const u8{
"fc00:db20:35b:7399::5",
"fc00:db20:35b:7399::5",
"::1",
"::",
"2001:db8::",
"::1234:5678",
"2001:db8::1234:5678",
"::ffff:172.16.31.10",
};
for (inputs) |input, i| {
try testing.expectFmt(outputs[i], "{}", .{try IPv6.parse(input)});
}
}
test "ipv6: parse & format addresses with scope ids" {
if (!@hasDecl(os, "IFNAMESIZE")) return error.SkipZigTest;
const inputs = [_][]const u8{
"FF01::FB%lo",
};
const outputs = [_][]const u8{
"ff01::fb%1",
};
for (inputs) |input, i| {
try testing.expectFmt(outputs[i], "{}", .{try IPv6.parse(input)});
}
} | lib/std/x/os/net.zig |
const std = @import("../std.zig");
const math = std.math;
const expect = std.testing.expect;
const maxInt = std.math.maxInt;
/// Returns the hyperbolic arc-tangent of x.
///
/// Special Cases:
/// - atanh(+-1) = +-inf with signal
/// - atanh(x) = nan if |x| > 1 with signal
/// - atanh(nan) = nan
pub fn atanh(x: var) @typeOf(x) {
const T = @typeOf(x);
return switch (T) {
f32 => atanh_32(x),
f64 => atanh_64(x),
else => @compileError("atanh not implemented for " ++ @typeName(T)),
};
}
// atanh(x) = log((1 + x) / (1 - x)) / 2 = log1p(2x / (1 - x)) / 2 ~= x + x^3 / 3 + o(x^5)
fn atanh_32(x: f32) f32 {
const u = @bitCast(u32, x);
const i = u & 0x7FFFFFFF;
const s = u >> 31;
var y = @bitCast(f32, i); // |x|
if (y == 1.0) {
return math.copysign(f32, math.inf(f32), x);
}
if (u < 0x3F800000 - (1 << 23)) {
if (u < 0x3F800000 - (32 << 23)) {
// underflow
if (u < (1 << 23)) {
math.forceEval(y * y);
}
}
// |x| < 0.5
else {
y = 0.5 * math.log1p(2 * y + 2 * y * y / (1 - y));
}
} else {
y = 0.5 * math.log1p(2 * (y / (1 - y)));
}
return if (s != 0) -y else y;
}
fn atanh_64(x: f64) f64 {
const u = @bitCast(u64, x);
const e = (u >> 52) & 0x7FF;
const s = u >> 63;
var y = @bitCast(f64, u & (maxInt(u64) >> 1)); // |x|
if (y == 1.0) {
return math.copysign(f64, math.inf(f64), x);
}
if (e < 0x3FF - 1) {
if (e < 0x3FF - 32) {
// underflow
if (e == 0) {
math.forceEval(@floatCast(f32, y));
}
}
// |x| < 0.5
else {
y = 0.5 * math.log1p(2 * y + 2 * y * y / (1 - y));
}
} else {
y = 0.5 * math.log1p(2 * (y / (1 - y)));
}
return if (s != 0) -y else y;
}
test "math.atanh" {
expect(atanh(@as(f32, 0.0)) == atanh_32(0.0));
expect(atanh(@as(f64, 0.0)) == atanh_64(0.0));
}
test "math.atanh_32" {
const epsilon = 0.000001;
expect(math.approxEq(f32, atanh_32(0.0), 0.0, epsilon));
expect(math.approxEq(f32, atanh_32(0.2), 0.202733, epsilon));
expect(math.approxEq(f32, atanh_32(0.8923), 1.433099, epsilon));
}
test "math.atanh_64" {
const epsilon = 0.000001;
expect(math.approxEq(f64, atanh_64(0.0), 0.0, epsilon));
expect(math.approxEq(f64, atanh_64(0.2), 0.202733, epsilon));
expect(math.approxEq(f64, atanh_64(0.8923), 1.433099, epsilon));
}
test "math.atanh32.special" {
expect(math.isPositiveInf(atanh_32(1)));
expect(math.isNegativeInf(atanh_32(-1)));
expect(math.isSignalNan(atanh_32(1.5)));
expect(math.isSignalNan(atanh_32(-1.5)));
expect(math.isNan(atanh_32(math.nan(f32))));
}
test "math.atanh64.special" {
expect(math.isPositiveInf(atanh_64(1)));
expect(math.isNegativeInf(atanh_64(-1)));
expect(math.isSignalNan(atanh_64(1.5)));
expect(math.isSignalNan(atanh_64(-1.5)));
expect(math.isNan(atanh_64(math.nan(f64))));
} | lib/std/math/atanh.zig |
const std = @import("std");
const allocators = @import("allocators.zig");
pub const LangTokens = struct {
opener: []const u8,
closer: []const u8,
line_prefix: []const u8,
fn init(opener: []const u8, closer: []const u8, line_prefix: []const u8) LangTokens {
return LangTokens{
.opener = opener,
.closer = closer,
.line_prefix = line_prefix,
};
}
};
pub var langs = std.StringHashMap(LangTokens).init(allocators.global_arena.allocator());
pub fn getLimp() LangTokens {
return langs.get("!!") orelse LangTokens.init("!!", "!!", "");
}
pub fn get(extension: []const u8) LangTokens {
return langs.get(extension) orelse langs.get("") orelse LangTokens.init("/*", "*/", "");
}
pub fn initDefaults() !void {
try langs.ensureTotalCapacity(64);
const c_tokens = LangTokens.init("/*", "*/", "");
try langs.put("", c_tokens);
try langs.put("c", c_tokens);
try langs.put("h", c_tokens);
try langs.put("cc", c_tokens);
try langs.put("hh", c_tokens);
try langs.put("cpp", c_tokens);
try langs.put("hpp", c_tokens);
try langs.put("jai", c_tokens);
try langs.put("java", c_tokens);
try langs.put("kt", c_tokens);
try langs.put("cs", c_tokens);
const sgml_tokens = LangTokens.init("<!--", "-->", "");
try langs.put("xml", sgml_tokens);
try langs.put("htm", sgml_tokens);
try langs.put("html", sgml_tokens);
try langs.put("zig", LangTokens.init("//[[", "]]", "//"));
try langs.put("bat", LangTokens.init(":::", ":::", "::"));
try langs.put("cmd", LangTokens.init(":::", ":::", "::"));
try langs.put("sh", LangTokens.init("##", "##", "#"));
try langs.put("ninja", LangTokens.init("##", "##", "#"));
try langs.put("lua", LangTokens.init("--[==[", "]==]", ""));
try langs.put("sql", LangTokens.init("---", "---", "--"));
try langs.put("!!", LangTokens.init("!!", "!!", ""));
}
pub fn add(extension: []const u8, opener: []const u8, closer: []const u8, line_prefix: []const u8) !void {
if (opener.len == 0 or closer.len == 0) return error.InvalidToken;
var alloc = allocators.global_arena.allocator();
var extension_copy = try alloc.dupe(u8, extension);
var opener_copy = try alloc.dupe(u8, opener);
var closer_copy = try alloc.dupe(u8, closer);
var line_prefix_copy = try alloc.dupe(u8, line_prefix);
try langs.put(extension_copy, .{
.opener = opener_copy,
.closer = closer_copy,
.line_prefix = line_prefix_copy,
});
}
const Parser = struct {
allocator: std.mem.Allocator,
extension: std.ArrayListUnmanaged(u8),
opener: std.ArrayListUnmanaged(u8),
closer: std.ArrayListUnmanaged(u8),
prefix: std.ArrayListUnmanaged(u8),
line: std.ArrayListUnmanaged(u8),
state: State = State.extension,
error_on_line: bool = false,
verbose: bool = false,
line_num: u32 = 1,
fn init(temp_arena: *std.heap.ArenaAllocator, verbose: bool) !Parser {
var allocator = temp_arena.allocator();
return Parser{
.allocator = allocator,
.extension = try std.ArrayListUnmanaged(u8).initCapacity(allocator, 16),
.opener = try std.ArrayListUnmanaged(u8).initCapacity(allocator, 16),
.closer = try std.ArrayListUnmanaged(u8).initCapacity(allocator, 16),
.prefix = try std.ArrayListUnmanaged(u8).initCapacity(allocator, 16),
.line = try std.ArrayListUnmanaged(u8).initCapacity(allocator, 256),
.verbose = verbose,
};
}
const State = enum(u8) {
extension,
whitespace_before_opener,
opener,
whitespace_before_closer,
closer,
whitespace_before_prefix,
prefix,
whitespace_trailing,
comment_or_error,
};
fn accept(self: *Parser, c: u8) !void {
if (c == '\n') {
try self.checkAndAdd();
self.extension.clearRetainingCapacity();
self.opener.clearRetainingCapacity();
self.closer.clearRetainingCapacity();
self.prefix.clearRetainingCapacity();
self.line.clearRetainingCapacity();
self.state = State.extension;
self.error_on_line = false;
self.line_num += 1;
} else {
try self.line.append(self.allocator, c);
while (true) {
switch (self.state) {
State.whitespace_before_opener => {
if (c <= ' ') break;
self.state = State.opener;
continue;
},
State.whitespace_before_closer => {
if (c <= ' ') break;
self.state = State.closer;
continue;
},
State.whitespace_before_prefix => {
if (c <= ' ') break;
self.state = State.prefix;
continue;
},
State.whitespace_trailing => {
if (c <= ' ') break;
self.state = State.comment_or_error;
self.error_on_line = true;
try std.io.getStdErr().writer().print(".limplangs:{d}: Too many tokens; expected <extension> <opener> <closer>: ", .{self.line_num});
break;
},
State.extension => {
if (c <= ' ') {
self.state = State.whitespace_before_opener;
break;
} else if (c == '#' and self.isStartOfLine()) {
self.state = State.comment_or_error;
break;
}
try self.extension.append(self.allocator, c);
break;
},
State.opener => {
if (c <= ' ') {
self.state = State.whitespace_before_closer;
break;
}
try self.opener.append(self.allocator, c);
break;
},
State.closer => {
if (c <= ' ') {
self.state = State.whitespace_before_prefix;
break;
}
try self.closer.append(self.allocator, c);
break;
},
State.prefix => {
if (c <= ' ') {
self.state = State.whitespace_trailing;
break;
}
try self.prefix.append(self.allocator, c);
break;
},
State.comment_or_error => {
break;
},
}
unreachable;
}
}
}
fn checkAndAdd(self: *Parser) !void {
if (self.isStartOfLine()) {
return;
}
if (!self.error_on_line) {
if (self.closer.items.len == 0) {
try std.io.getStdErr().writer().print(".limplangs:{d}: Too few tokens; expected <extension> <opener> <closer> [line-prefix]: ", .{self.line_num});
self.error_on_line = true;
}
}
if (self.error_on_line) {
try std.io.getStdErr().writer().print("{s}\n", .{self.line.items});
} else {
if (self.verbose) {
try std.io.getStdOut().writer().print("Loaded language tokens for .{s} files: {s} {s}\n", .{ self.extension.items, self.opener.items, self.closer.items });
}
try add(self.extension.items, self.opener.items, self.closer.items, self.prefix.items);
}
}
inline fn isStartOfLine(self: *Parser) bool {
return self.state == State.extension and self.extension.items.len == 0;
}
};
pub fn load(verbose: bool) !void {
var temp_arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer temp_arena.deinit();
const exe_dir_path = try std.fs.selfExeDirPathAlloc(temp_arena.allocator());
var exe_dir = try std.fs.cwd().openDir(exe_dir_path, .{});
defer exe_dir.close();
var limplangs_contents = exe_dir.readFileAlloc(temp_arena.allocator(), ".limplangs", 1 << 30) catch |err| switch (err) {
error.FileNotFound => return,
else => return err,
};
var parser = try Parser.init(&temp_arena, verbose);
for (limplangs_contents) |b| try parser.accept(b);
try parser.checkAndAdd();
} | limp/languages.zig |
const std = @import("../std.zig");
const io = std.io;
const testing = std.testing;
/// Provides `io.Reader`, `io.Writer`, and `io.SeekableStream` for in-memory buffers as
/// well as files.
/// For memory sources, if the supplied byte buffer is const, then `io.OutStream` is not available.
/// The error set of the stream functions is the error set of the corresponding file functions.
pub const StreamSource = union(enum) {
buffer: io.FixedBufferStream([]u8),
const_buffer: io.FixedBufferStream([]const u8),
file: std.fs.File,
pub const ReadError = std.fs.File.ReadError;
pub const WriteError = std.fs.File.WriteError;
pub const SeekError = std.fs.File.SeekError;
pub const GetSeekPosError = std.fs.File.GetPosError;
pub const Reader = io.Reader(*StreamSource, ReadError, read);
/// Deprecated: use `Reader`
pub const InStream = Reader;
pub const Writer = io.Writer(*StreamSource, WriteError, write);
/// Deprecated: use `Writer`
pub const OutStream = Writer;
pub const SeekableStream = io.SeekableStream(
*StreamSource,
SeekError,
GetSeekPosError,
seekTo,
seekBy,
getPos,
getEndPos,
);
pub fn read(self: *StreamSource, dest: []u8) ReadError!usize {
switch (self.*) {
.buffer => |*x| return x.read(dest),
.const_buffer => |*x| return x.read(dest),
.file => |x| return x.read(dest),
}
}
pub fn write(self: *StreamSource, bytes: []const u8) WriteError!usize {
switch (self.*) {
.buffer => |*x| return x.write(bytes),
.const_buffer => return error.AccessDenied,
.file => |x| return x.write(bytes),
}
}
pub fn seekTo(self: *StreamSource, pos: u64) SeekError!void {
switch (self.*) {
.buffer => |*x| return x.seekTo(pos),
.const_buffer => |*x| return x.seekTo(pos),
.file => |x| return x.seekTo(pos),
}
}
pub fn seekBy(self: *StreamSource, amt: i64) SeekError!void {
switch (self.*) {
.buffer => |*x| return x.seekBy(amt),
.const_buffer => |*x| return x.seekBy(amt),
.file => |x| return x.seekBy(amt),
}
}
pub fn getEndPos(self: *StreamSource) GetSeekPosError!u64 {
switch (self.*) {
.buffer => |*x| return x.getEndPos(),
.const_buffer => |*x| return x.getEndPos(),
.file => |x| return x.getEndPos(),
}
}
pub fn getPos(self: *StreamSource) GetSeekPosError!u64 {
switch (self.*) {
.buffer => |*x| return x.getPos(),
.const_buffer => |*x| return x.getPos(),
.file => |x| return x.getPos(),
}
}
pub fn reader(self: *StreamSource) Reader {
return .{ .context = self };
}
/// Deprecated: use `reader`
pub fn inStream(self: *StreamSource) InStream {
return .{ .context = self };
}
pub fn writer(self: *StreamSource) Writer {
return .{ .context = self };
}
/// Deprecated: use `writer`
pub fn outStream(self: *StreamSource) OutStream {
return .{ .context = self };
}
pub fn seekableStream(self: *StreamSource) SeekableStream {
return .{ .context = self };
}
}; | lib/std/io/stream_source.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const AutoComptimeLookup = @import("comptime_lookup.zig").AutoComptimeLookup;
const zua = @import("zua.zig");
// Notes:
//
// In Lua's lexer, all single char tokens use their own ASCII value as their ID, and
// every other multi-character token uses ID >= 257 (see FIRST_RESERVED in llex.h).
// For now, this implementation uses a 'single_char' token as a catch-all for
// such single char tokens
//
// Lua's lexer uses a lua_State and parses strings/numbers while lexing, allocating
// strings and adding them to the lua_State's string table. This lexer, instead,
// does no allocation or parsing of strings/numbers (that will be done later). However,
// it maintains 1:1 compatibility with when Lua's lexer errors by validating
// strings/numbers at lex-time in the same way that Lua's lexer parses them.
//
// Lua's lexer skips over all comments (doesn't store them as tokens). This functionality is
// kept in this implementation.
//
// Lua's number lexing allows for using locale-specific decimal points
// TODO: ?
//
// Zua's lexer error messages are almost entirely identical to Lua's, except in a few cases:
// - malformed number in Lua prints more than where a number stops being valid, whereas Zua
// only prints up to the first malformed char (e.g. Zua will stop at 3.. whereas Lua will
// print 3.................)
// - string token context in Lua prints the parsed string rather than the source of the string
// since Lua parses and lexes at the same time. Zua will print the source of the string instead.
// (e.g. for "\v Zua will print "\v whereas Lua would print an actual vertical tab character)
// - escape sequence too large in Lua doesn't include the actual escape sequence that is too large,
// while Zua does include it (e.g. "\444" in Lua would error with: near '"', while Zua gives:
// near '"\444')
// Debug/test output
const dumpTokensDuringTests = false;
const veryVerboseLexing = false;
pub const Token = struct {
id: Id,
start: usize,
end: usize,
line_number: usize,
// for single-char tokens
// TODO: figure out something better for this (it's only used for nameForDisplay)
char: ?u8,
/// Helper for .single_char tokens
pub fn isChar(self: *const Token, expected_char: u8) bool {
return self.id == .single_char and self.char.? == expected_char;
}
pub const Keyword = struct {
pub fn idFromName(name: []const u8) ?Id {
return keywords.get(name);
}
};
const keywordMapping = .{
.{ "and", .keyword_and },
.{ "break", .keyword_break },
.{ "do", .keyword_do },
.{ "else", .keyword_else },
.{ "elseif", .keyword_elseif },
.{ "end", .keyword_end },
.{ "false", .keyword_false },
.{ "for", .keyword_for },
.{ "function", .keyword_function },
.{ "if", .keyword_if },
.{ "in", .keyword_in },
.{ "local", .keyword_local },
.{ "nil", .keyword_nil },
.{ "not", .keyword_not },
.{ "or", .keyword_or },
.{ "repeat", .keyword_repeat },
.{ "return", .keyword_return },
.{ "then", .keyword_then },
.{ "true", .keyword_true },
.{ "until", .keyword_until },
.{ "while", .keyword_while },
};
pub const keywords = std.ComptimeStringMap(Id, keywordMapping);
pub const Id = enum {
// terminal symbols denoted by reserved words
keyword_and,
keyword_break,
keyword_do,
keyword_else,
keyword_elseif,
keyword_end,
keyword_false,
keyword_for,
keyword_function,
keyword_if,
keyword_in,
keyword_local,
keyword_nil,
keyword_not,
keyword_or,
keyword_repeat,
keyword_return,
keyword_then,
keyword_true,
keyword_until,
keyword_while,
// any normal byte
single_char,
// other terminal symbols
concat,
ellipsis,
eq,
ge,
le,
ne,
number,
name,
string,
eof,
};
// A mapping of id -> name pairs as an array
const keywordNames = blk: {
// FIXME: This relies on the keyword enums starting at 0 and being contiguous
var array: [keywordMapping.len][]const u8 = undefined;
for (keywordMapping) |mapping| {
const name = mapping[0];
const id = @enumToInt(@as(Id, mapping[1]));
array[id] = name;
}
break :blk array;
};
// buffer for nameForDisplay
var token_name_buf: [10]u8 = undefined;
/// Intended to be equivalent to Lua's luaX_token2str function
///
/// NOTE: To avoid allocation, this function uses a static buffer for the
/// name of control characters (which display as `char(15)`, etc).
/// This means that this function only works correctly if you immediately
/// print/copy the result before calling it again, as the returned
/// slice can potentially be overwritten on subsequent calls.
/// TODO: is this ok? ^
pub fn nameForDisplay(self: *const Token) []const u8 {
return switch (self.id) {
.keyword_and,
.keyword_break,
.keyword_do,
.keyword_else,
.keyword_elseif,
.keyword_end,
.keyword_false,
.keyword_for,
.keyword_function,
.keyword_if,
.keyword_in,
.keyword_local,
.keyword_nil,
.keyword_not,
.keyword_or,
.keyword_repeat,
.keyword_return,
.keyword_then,
.keyword_true,
.keyword_until,
.keyword_while,
=> keywordNames[@enumToInt(self.id)],
.concat => "..",
.ellipsis => "...",
.eq => "==",
.ge => ">=",
.le => "<=",
.ne => "~=",
.number => "<number>",
.name => "<name>",
.string => "<string>",
.eof => "<eof>",
.single_char => blk: {
if (std.ascii.isCntrl(self.char.?)) {
break :blk std.fmt.bufPrint(&token_name_buf, "char({d})", .{self.char.?}) catch unreachable;
} else {
break :blk std.mem.span(@as(*const [1]u8, &self.char.?));
}
},
};
}
/// Intended to be equivalent to Lua's txtToken (llex.c) function
///
/// NOTE: The slice returned should be considered temporary, and either copied
/// or otherwise used immediately. See also nameForDisplay, which this function
/// can call.
pub fn nameForErrorDisplay(self: *const Token, source: []const u8) []const u8 {
return switch (self.id) {
.name, .string, .number => source[self.start..self.end],
else => self.nameForDisplay(),
};
}
};
pub const LexError = error{
UnfinishedString,
UnfinishedLongComment,
UnfinishedLongString,
InvalidLongStringDelimiter,
MalformedNumber,
EscapeSequenceTooLarge,
ChunkHasTooManyLines,
LexicalElementTooLong,
};
/// error -> msg lookup for lex errors
pub const lex_error_strings = AutoComptimeLookup(LexError, []const u8, .{
.{ LexError.UnfinishedString, "unfinished string" },
.{ LexError.UnfinishedLongComment, "unfinished long comment" },
.{ LexError.UnfinishedLongString, "unfinished long string" },
.{ LexError.InvalidLongStringDelimiter, "invalid long string delimiter" },
.{ LexError.MalformedNumber, "malformed number" },
.{ LexError.EscapeSequenceTooLarge, "escape sequence too large" },
.{ LexError.ChunkHasTooManyLines, "chunk has too many lines" },
.{ LexError.LexicalElementTooLong, "lexical element too long" },
});
pub const LexErrorContext = struct {
token: Token,
// TODO this is kinda weird, doesn't seem like it needs to be stored (maybe passed to render instead?)
err: LexError,
pub fn renderAlloc(self: *LexErrorContext, allocator: Allocator, lexer: *Lexer) ![]const u8 {
var buffer = std.ArrayList(u8).init(allocator);
errdefer buffer.deinit();
const looked_up_msg = lex_error_strings.get(self.err).?;
const error_writer = buffer.writer();
const MAXSRC = 80; // see MAXSRC in llex.c
var chunk_id_buf: [MAXSRC]u8 = undefined;
const chunk_id = zua.object.getChunkId(lexer.chunk_name, &chunk_id_buf);
try error_writer.print("{s}:{d}: {s}", .{ chunk_id, self.token.line_number, looked_up_msg });
// special case errors that shouldn't be printed with context
if (self.err != LexError.ChunkHasTooManyLines and self.err != LexError.LexicalElementTooLong) {
try error_writer.print(" near '{s}'", .{self.token.nameForErrorDisplay(lexer.buffer)});
}
return buffer.toOwnedSlice();
}
};
pub const Lexer = struct {
const Self = @This();
chunk_name: []const u8,
buffer: []const u8,
index: usize,
line_number: usize = 1,
// TODO this still feels slightly sloppy, could probably be cleaned up still.
// Would be good to revisit when adding parse error rendering
error_context: ?LexErrorContext = null,
/// In Lua 5.1 there is a bug in the lexer where check_next() accepts \0
/// since \0 is technically in the string literal passed to check_next representing
/// the set of characters to check for (since the string is null-terminated)
///
/// This affects a few things:
/// ".\0" gets lexed as ..
/// ".\0\0" and "..\0" get lexed as ...
/// the e/E in numeral exponents can be '\0'
/// the +- sign for numeral exponents can be '\0'
///
/// Note that these last two affect how numbers are ultimately parsed, since something like
/// 1\0 gets lexed as the equiv of 1e but gets parsed into 1 (since the str2d func treats it as
/// a null-terminated string). For this reason, "1\0\0" will succesfully parse into 1
/// while "1e\0002" will fail to parse (since it will treat it as "1e").
check_next_bug_compat: bool = true,
// TODO: implement or ignore this (options for handling nesting of [[]] in multiline strings)
// for now we simply allow [[ (Lua 5.1 errors by default on [[ saying that nesting is deprecated)
long_str_nesting_compat: bool = false,
/// maximum number of allowable lines in a chunk
/// Lua uses MAX_INT from llimits.h which is set to INT_MAX-2
/// This is the equivalent of that.
max_lines: usize = std.math.maxInt(i32) - 2,
/// maximum size of a lexical element
/// Lua uses MAX_SIZET/2 where MAX_SIZET is from llimits.h and is set to (~(size_t)0)-2)
/// This is the equivalent of that.
max_lexical_element_size: usize = (std.math.maxInt(usize) - 2) / 2,
pub const Error = LexError;
pub fn init(buffer: []const u8, chunk_name: []const u8) Self {
return Self{
.buffer = buffer,
.index = 0,
.chunk_name = chunk_name,
};
}
pub fn dump(self: *Self, token: *const Token) void {
std.debug.print("{s} {s}:{d}: \"{s}\"\n", .{ @tagName(token.id), token.nameForDisplay(), token.line_number, std.fmt.fmtSliceEscapeLower(self.buffer[token.start..token.end]) });
}
const State = enum {
start,
identifier,
string_literal,
string_literal_backslash,
string_literal_backslash_line_endings,
dash,
dot,
concat,
comment_start,
short_comment,
long_comment_start,
long_comment,
long_comment_possible_end,
long_string_start,
long_string,
long_string_possible_end,
number,
number_exponent_start,
number_exponent,
number_hex_start,
number_hex,
compound_equal,
};
pub fn next(self: *Self) Error!Token {
const start_index = self.index;
if (veryVerboseLexing) {
if (self.index < self.buffer.len) {
std.debug.print("{d}:'{c}'", .{ self.index, self.buffer[self.index] });
} else {
std.debug.print("eof", .{});
}
}
var result = Token{
.id = Token.Id.eof,
.start = start_index,
.end = undefined,
.char = null,
.line_number = self.line_number,
};
var state = State.start;
var string_delim: u8 = undefined;
var string_level: usize = 0;
var expected_string_level: usize = 0;
var string_escape_n: std.math.IntFittingRange(0, 999) = 0;
var string_escape_i: std.math.IntFittingRange(0, 3) = 0;
var string_escape_line_ending: u8 = undefined;
var last_line_ending_index: ?usize = null;
var number_is_float: bool = false;
var number_starting_char: u8 = undefined;
var number_exponent_signed_char: ?u8 = null;
var number_is_null_terminated: bool = false;
while (self.index < self.buffer.len) : (self.index += 1) {
const c = self.buffer[self.index];
if (veryVerboseLexing) std.debug.print(":{s}", .{@tagName(state)});
// Check for tokens that are over the size limit here as a catch-all
if (self.index - result.start >= self.max_lexical_element_size) {
return self.reportLexError(LexError.LexicalElementTooLong, result, Token.Id.eof);
}
switch (state) {
State.start => switch (c) {
'\n', '\r' => {
result.start = self.index + 1;
result.line_number = try self.incrementLineNumber(&last_line_ending_index);
},
// space, tab, vertical tab, form feed
' ', '\t', '\x0b', '\x0c' => {
// skip whitespace
result.start = self.index + 1;
},
'-' => {
// this could be the start of a comment, a long comment, or a single -
state = State.dash;
},
'a'...'z', 'A'...'Z', '_' => {
state = State.identifier;
result.id = Token.Id.name;
},
'0'...'9' => {
state = State.number;
number_starting_char = c;
if (self.check_next_bug_compat) {
number_is_null_terminated = false;
}
},
'"', '\'' => {
state = State.string_literal;
string_delim = c;
result.id = Token.Id.string;
},
'.' => {
// this could be the start of .., ..., or a single .
state = State.dot;
},
'>', '<', '~', '=' => {
state = State.compound_equal;
},
'[' => {
state = State.long_string_start;
expected_string_level = 0;
},
else => {
result.id = Token.Id.single_char;
self.index += 1;
break;
},
},
State.identifier => switch (c) {
'a'...'z', 'A'...'Z', '_', '0'...'9' => {},
else => {
const name = self.buffer[result.start..self.index];
if (Token.Keyword.idFromName(name)) |id| {
result.id = id;
}
break;
},
},
State.string_literal => switch (c) {
'\\' => {
state = State.string_literal_backslash;
string_escape_i = 0;
string_escape_n = 0;
},
'"', '\'' => {
if (c == string_delim) {
self.index += 1;
break;
}
},
'\n', '\r' => {
return self.reportLexError(LexError.UnfinishedString, result, Token.Id.string);
},
else => {},
},
State.string_literal_backslash => switch (c) {
'0'...'9' => {
// Validate that any \ddd escape sequences can actually fit
// in a byte
string_escape_n = 10 * string_escape_n + (c - '0');
string_escape_i += 1;
if (string_escape_i == 3) {
if (string_escape_n > std.math.maxInt(u8)) {
return self.reportLexErrorInc(LexError.EscapeSequenceTooLarge, result, Token.Id.string);
}
state = State.string_literal;
}
},
'\r', '\n' => {
if (string_escape_i > 0) {
return self.reportLexError(LexError.UnfinishedString, result, Token.Id.string);
}
state = State.string_literal_backslash_line_endings;
string_escape_line_ending = c;
result.line_number = try self.incrementLineNumber(&last_line_ending_index);
},
else => {
// if the escape sequence had any digits, then
// we need to backtrack so as not to escape the current
// character (since the digits are the things being escaped)
if (string_escape_i > 0) {
self.index -= 1;
}
state = State.string_literal;
},
},
State.string_literal_backslash_line_endings => switch (c) {
'\r', '\n' => {
// can only escape \r\n or \n\r pairs, not \r\r or \n\n
if (c == string_escape_line_ending) {
return self.reportLexError(LexError.UnfinishedString, result, Token.Id.string);
} else {
state = State.string_literal;
}
result.line_number = try self.incrementLineNumber(&last_line_ending_index);
},
else => {
// backtrack so that we don't escape the current char
self.index -= 1;
state = State.string_literal;
},
},
State.dash => switch (c) {
'-' => {
state = State.comment_start;
},
else => {
result.id = Token.Id.single_char;
break;
},
},
State.comment_start => switch (c) {
'[' => {
state = State.long_comment_start;
expected_string_level = 0;
},
'\r', '\n' => {
// comment immediately ends
result.start = self.index + 1;
state = State.start;
result.line_number = try self.incrementLineNumber(&last_line_ending_index);
},
else => {
state = State.short_comment;
},
},
State.long_string_start,
State.long_comment_start,
=> switch (c) {
'=' => {
expected_string_level += 1;
},
'[' => {
state = if (state == State.long_comment_start) State.long_comment else State.long_string;
},
else => {
if (state == State.long_comment_start) {
if (c == '\n' or c == '\r') {
// not a long comment, but the short comment ends immediately
result.start = self.index + 1;
state = State.start;
result.line_number = try self.incrementLineNumber(&last_line_ending_index);
} else {
state = State.short_comment;
}
} else {
// Lua makes the pattern [=X where X is anything but [ or = an explicit
// 'invalid long string delimiter' error instead of discarding
// its long-string-ness and parsing the tokens as normal
//
// - This is only true of long strings: long comments handle --[==X just fine
// since it falls back to -- (short comment)
// - The end of long strings is unaffected: [=[str]=X does not give this error
// (instead the string will just not be finished)
// - Long strings with no sep chars is unaffected: [X does not give this error
// (instead it will an give unexpected symbol error while parsing)
if (expected_string_level > 0) {
return self.reportLexError(LexError.InvalidLongStringDelimiter, result, Token.Id.string);
} else {
result.id = Token.Id.single_char;
break;
}
}
},
},
State.long_string,
State.long_comment,
=> switch (c) {
']' => {
state = if (state == State.long_comment) State.long_comment_possible_end else State.long_string_possible_end;
string_level = 0;
},
else => {
result.line_number = try self.maybeIncrementLineNumber(&last_line_ending_index);
},
},
State.long_string_possible_end,
State.long_comment_possible_end,
=> switch (c) {
']' => {
if (string_level == expected_string_level) {
if (state == State.long_comment_possible_end) {
result.start = self.index + 1;
state = State.start;
} else {
self.index += 1;
result.id = Token.Id.string;
break;
}
} else {
// don't change state, since this char could be the start of a new end sequence
// but reset the level back to 0
string_level = 0;
}
},
'=' => {
string_level += 1;
},
else => {
result.line_number = try self.maybeIncrementLineNumber(&last_line_ending_index);
state = if (state == State.long_comment_possible_end) State.long_comment else State.long_string;
},
},
State.short_comment => switch (c) {
'\n', '\r' => {
result.start = self.index + 1;
state = State.start;
result.line_number = try self.incrementLineNumber(&last_line_ending_index);
},
else => {},
},
State.dot => switch (c) {
'.' => {
state = State.concat;
},
'0'...'9' => {
state = State.number;
number_starting_char = '.';
number_is_float = true;
if (self.check_next_bug_compat) {
number_is_null_terminated = false;
}
},
else => {
if (self.check_next_bug_compat and c == '\x00') {
state = State.concat;
} else {
result.id = Token.Id.single_char;
break;
}
},
},
State.concat => switch (c) {
'.' => {
result.id = Token.Id.ellipsis;
// include this .
self.index += 1;
break;
},
else => {
if (self.check_next_bug_compat and c == '\x00') {
result.id = Token.Id.ellipsis;
// include this .
self.index += 1;
break;
} else {
result.id = Token.Id.concat;
break;
}
},
},
State.number => switch (c) {
'0'...'9' => {},
'.' => {
// multiple decimal points not allowed
if (number_is_float) {
return self.reportLexErrorInc(LexError.MalformedNumber, result, Token.Id.number);
}
number_is_float = true;
},
'x', 'X' => {
// only 0x is allowed
if (number_starting_char != '0') {
return self.reportLexErrorInc(LexError.MalformedNumber, result, Token.Id.number);
}
state = State.number_hex_start;
},
'e', 'E' => {
state = State.number_exponent_start;
number_exponent_signed_char = null;
},
// 'a'...'z' minus e and x
'a'...'d', 'A'...'D', 'f'...'w', 'F'...'W', 'y'...'z', 'Y'...'Z' => {
return self.reportLexErrorInc(LexError.MalformedNumber, result, Token.Id.number);
},
'_' => return self.reportLexErrorInc(LexError.MalformedNumber, result, Token.Id.number),
else => {
if (self.check_next_bug_compat and c == '\x00') {
state = State.number_exponent_start;
number_exponent_signed_char = null;
number_is_null_terminated = true;
} else {
result.id = Token.Id.number;
break;
}
},
},
State.number_hex_start, State.number_hex => switch (c) {
'0'...'9', 'a'...'f', 'A'...'F' => {
state = State.number_hex;
},
'g'...'z', 'G'...'Z' => {
return self.reportLexErrorInc(LexError.MalformedNumber, result, Token.Id.number);
},
'_' => return self.reportLexErrorInc(LexError.MalformedNumber, result, Token.Id.number),
else => {
result.id = Token.Id.number;
break;
},
},
State.number_exponent_start => {
const should_consume_anything = self.check_next_bug_compat and number_is_null_terminated;
if (should_consume_anything) {
switch (c) {
'\x00', '-', '+', '0'...'9', 'a'...'z', 'A'...'Z', '_' => {
state = State.number_exponent;
},
else => {
result.id = Token.Id.number;
break;
},
}
} else {
switch (c) {
'0'...'9' => state = State.number_exponent,
'-', '+' => {
if (number_exponent_signed_char) |_| {
// this is an error because e.g. "1e--" would lex as "1e-" and "-"
// and "1e-" is always invalid
return self.reportLexErrorInc(LexError.MalformedNumber, result, Token.Id.number);
}
number_exponent_signed_char = c;
},
else => {
// if we get here, then the token up to this point has to be
// either 1e, 1e-, 1e+ which *must* be followed by a digit, and
// we already know c is not a digit
return self.reportLexErrorInc(LexError.MalformedNumber, result, Token.Id.number);
},
}
}
},
State.number_exponent => {
const should_consume_anything = self.check_next_bug_compat and number_is_null_terminated;
if (should_consume_anything) {
switch (c) {
'0'...'9', 'a'...'z', 'A'...'Z', '_' => {},
else => {
result.id = Token.Id.number;
break;
},
}
} else {
switch (c) {
'0'...'9' => {},
'a'...'z', 'A'...'Z', '_' => return self.reportLexError(LexError.MalformedNumber, result, Token.Id.number),
else => {
result.id = Token.Id.number;
break;
},
}
}
},
State.compound_equal => switch (c) {
'=' => {
switch (self.buffer[self.index - 1]) {
'>' => result.id = Token.Id.ge,
'<' => result.id = Token.Id.le,
'~' => result.id = Token.Id.ne,
'=' => result.id = Token.Id.eq,
else => unreachable,
}
self.index += 1;
break;
},
else => {
result.id = Token.Id.single_char;
break;
},
},
}
} else {
// this will always be true due to the while loop condition as the
// else block is not evaluated after a break; in the while loop, but
// rather only when the loop condition fails
std.debug.assert(self.index == self.buffer.len);
switch (state) {
State.start => {},
State.identifier => {
const name = self.buffer[result.start..self.index];
if (Token.Keyword.idFromName(name)) |id| {
result.id = id;
}
},
State.dot,
State.dash,
State.compound_equal,
=> {
result.id = Token.Id.single_char;
},
State.concat => {
result.id = Token.Id.concat;
},
State.number_exponent,
State.number_hex,
State.number,
=> {
result.id = Token.Id.number;
},
State.comment_start,
State.short_comment,
State.long_comment_start,
=> {
result.start = self.index;
},
State.long_string_start => {
if (expected_string_level > 0) {
return self.reportLexError(LexError.InvalidLongStringDelimiter, result, Token.Id.string);
} else {
result.id = Token.Id.single_char;
}
},
// .eof is reported as the error context to conform with how PUC Lua reports unfinished <x> errors
// when the end of the buffer is reached before the string is closed. Not totally sure why .string
// isn't used for the unfinished string errors in this case, though--the error message seems nicer
// that way
// TODO revisit?
State.long_comment_possible_end,
State.long_comment,
=> return self.reportLexError(LexError.UnfinishedLongComment, result, Token.Id.eof),
State.long_string_possible_end,
State.long_string,
=> return self.reportLexError(LexError.UnfinishedLongString, result, Token.Id.eof),
State.string_literal,
State.string_literal_backslash,
State.string_literal_backslash_line_endings,
=> return self.reportLexError(LexError.UnfinishedString, result, Token.Id.eof),
State.number_hex_start,
State.number_exponent_start,
=> {
if (self.check_next_bug_compat and number_is_null_terminated) {
result.id = Token.Id.number;
} else {
return self.reportLexError(LexError.MalformedNumber, result, Token.Id.number);
}
},
}
}
if (veryVerboseLexing) {
if (self.index < self.buffer.len) {
std.debug.print(":{d}:'{c}'=\"{s}\"\n", .{ self.index, self.buffer[self.index], self.buffer[result.start..self.index] });
} else {
std.debug.print(":eof=\"{s}\"\n", .{self.buffer[result.start..self.index]});
}
}
if (result.id == Token.Id.single_char) {
result.char = self.buffer[result.start];
}
result.end = self.index;
return result;
}
pub fn lookahead(self: *Self) Error!Token {
var lookaheadLexer = Lexer{
.buffer = self.buffer,
.index = self.index,
.line_number = self.line_number,
.chunk_name = self.chunk_name,
.check_next_bug_compat = self.check_next_bug_compat,
.long_str_nesting_compat = self.long_str_nesting_compat,
};
return lookaheadLexer.next();
}
fn reportLexError(self: *Self, err: LexError, unfinished_token: Token, id: Token.Id) Error {
self.error_context = .{
.token = .{
.id = id,
.start = unfinished_token.start,
.end = self.index,
.line_number = self.line_number,
.char = null, // TODO double check that this is always true (single char token can't cause a lex error, right?)
},
.err = err,
};
return err;
}
fn reportLexErrorInc(self: *Self, err: LexError, unfinished_token: Token, id: Token.Id) Error {
self.index += 1;
return self.reportLexError(err, unfinished_token, id);
}
pub fn renderErrorAlloc(self: *Self, allocator: Allocator) ![]const u8 {
if (self.error_context) |*ctx| {
return ctx.renderAlloc(allocator, self);
} else {
return error.NoError;
}
}
/// Like incrementLineNumber but checks that the current char is a line ending first
fn maybeIncrementLineNumber(self: *Self, last_line_ending_index: *?usize) !usize {
const c = self.buffer[self.index];
if (c == '\r' or c == '\n') {
return try self.incrementLineNumber(last_line_ending_index);
}
return self.line_number;
}
/// Increments line_number appropriately (handling line ending pairs)
/// and returns the new line number.
/// note: mutates last_line_ending_index.*
fn incrementLineNumber(self: *Self, last_line_ending_index: *?usize) !usize {
if (self.currentIndexFormsLineEndingPair(last_line_ending_index.*)) {
last_line_ending_index.* = null;
} else {
self.line_number += 1;
last_line_ending_index.* = self.index;
}
if (self.line_number >= self.max_lines) {
// TODO using a dummy token here is pretty janky
return self.reportLexError(LexError.ChunkHasTooManyLines, .{
.id = undefined,
.start = self.index,
.end = self.index,
.line_number = self.line_number,
.char = null,
}, Token.Id.eof);
}
return self.line_number;
}
/// \r\n and \n\r pairs are treated as a single line ending (but not \r\r \n\n)
/// expects self.index and last_line_ending_index (if non-null) to contain line endings
fn currentIndexFormsLineEndingPair(self: *Self, last_line_ending_index: ?usize) bool {
if (last_line_ending_index == null) return false;
// must immediately precede the current index
if (last_line_ending_index.? != self.index - 1) return false;
const cur_line_ending = self.buffer[self.index];
const last_line_ending = self.buffer[last_line_ending_index.?];
// sanity check
std.debug.assert(cur_line_ending == '\r' or cur_line_ending == '\n');
std.debug.assert(last_line_ending == '\r' or last_line_ending == '\n');
// can't be \n\n or \r\r
if (last_line_ending == cur_line_ending) return false;
return true;
}
};
test "hello \"world\"" {
try testLex("local hello = \"wor\\\"ld\"", &[_]Token.Id{
Token.Id.keyword_local,
Token.Id.name,
Token.Id.single_char,
Token.Id.string,
});
}
test "hello 'world'" {
try testLex("local hello = 'wor\\'ld'", &[_]Token.Id{
Token.Id.keyword_local,
Token.Id.name,
Token.Id.single_char,
Token.Id.string,
});
}
test "strings" {
// none of these escaped chars have any meaning, but Lua allows
// any character to be escaped so this should lex just fine
try testLex("'\\e\\s\\c\\ any char'", &[_]Token.Id{Token.Id.string});
try testLex("'\\1'", &[_]Token.Id{Token.Id.string});
try testLex("'\\12'", &[_]Token.Id{Token.Id.string});
try testLex("'\\123'", &[_]Token.Id{Token.Id.string});
try testLex("'\\1234'", &[_]Token.Id{Token.Id.string});
// carriage returns and newlines can be escaped with \
try testLex("'\\\n\\\r'", &[_]Token.Id{Token.Id.string});
try testLex("\".\\\x0d\\\\\\\".\\\x0d\xa5[\\ArA\"", &[_]Token.Id{Token.Id.string});
// a pair of CR/LF can be escaped with a single \ (either CRLF or LFCR)
try testLex("'\\\r\n'", &[_]Token.Id{Token.Id.string});
try testLex("'\\\n\r'", &[_]Token.Id{Token.Id.string});
}
test "long strings" {
try testLex("[[]]", &[_]Token.Id{Token.Id.string});
try testLex("[===[\nhello\nworld\n]===]", &[_]Token.Id{Token.Id.string});
try testLex("[]", &[_]Token.Id{ Token.Id.single_char, Token.Id.single_char });
// TODO: this depends on LUA_COMPAT_LSTR
try testLex("[[ [[ ]]", &[_]Token.Id{Token.Id.string});
// this is always allowed
try testLex("[=[ [[ ]] ]=]", &[_]Token.Id{Token.Id.string});
// unfinished end directly into real end
try testLex("[==[]=]==]", &[_]Token.Id{Token.Id.string});
}
test "comments and dashes" {
try testLex("-", &[_]Token.Id{Token.Id.single_char});
try testLex("a-b", &[_]Token.Id{ Token.Id.name, Token.Id.single_char, Token.Id.name });
try testLex("--", &[_]Token.Id{});
try testLex("--local hello = 'wor\\'ld'", &[_]Token.Id{});
try testLex("--[this is a short comment\nreturn", &[_]Token.Id{Token.Id.keyword_return});
try testLex("--\rreturn", &[_]Token.Id{Token.Id.keyword_return});
try testLex("--[[local hello = 'wor\\'ld']]", &[_]Token.Id{});
try testLex("--[==[\nlocal\nhello\n=\n'world'\n]==]", &[_]Token.Id{});
try testLex("--[==", &[_]Token.Id{});
try testLex("--[\n]]", &[_]Token.Id{ Token.Id.single_char, Token.Id.single_char });
// unfinished end directly into real end
try testLex("--[===[]=]===]", &[_]Token.Id{});
}
test "whitespace" {
// form feed
try testLex("_\x0c_W_", &[_]Token.Id{ Token.Id.name, Token.Id.name });
// vertical tab
try testLex("_\x0b_W_", &[_]Token.Id{ Token.Id.name, Token.Id.name });
}
test "dots, concat, ellipsis" {
try testLex(".", &[_]Token.Id{Token.Id.single_char});
try testLex("a.b", &[_]Token.Id{ Token.Id.name, Token.Id.single_char, Token.Id.name });
try testLex("..", &[_]Token.Id{Token.Id.concat});
try testLex("a..b.c", &[_]Token.Id{
Token.Id.name,
Token.Id.concat,
Token.Id.name,
Token.Id.single_char,
Token.Id.name,
});
// this is valid Lua, apparently (abc will be true, test will be the first value in ...)
try testLex("test=...abc=true", &[_]Token.Id{
Token.Id.name,
Token.Id.single_char,
Token.Id.ellipsis,
Token.Id.name,
Token.Id.single_char,
Token.Id.keyword_true,
});
}
test "= and compound = operators" {
try testLex("=", &[_]Token.Id{Token.Id.single_char});
try testLex("a=b", &[_]Token.Id{ Token.Id.name, Token.Id.single_char, Token.Id.name });
try testLex("a==b", &[_]Token.Id{ Token.Id.name, Token.Id.eq, Token.Id.name });
try testLex(">=", &[_]Token.Id{Token.Id.ge});
try testLex("if a~=b and a<=b and b<a then end", &[_]Token.Id{
Token.Id.keyword_if,
Token.Id.name,
Token.Id.ne,
Token.Id.name,
Token.Id.keyword_and,
Token.Id.name,
Token.Id.le,
Token.Id.name,
Token.Id.keyword_and,
Token.Id.name,
Token.Id.single_char,
Token.Id.name,
Token.Id.keyword_then,
Token.Id.keyword_end,
});
}
test "numbers" {
// from the Lua 5.1 manual
try testLex("3", &[_]Token.Id{Token.Id.number});
try testLex("3.0", &[_]Token.Id{Token.Id.number});
try testLex("3.1416", &[_]Token.Id{Token.Id.number});
try testLex("314.16e-2", &[_]Token.Id{Token.Id.number});
try testLex("0.31416E1", &[_]Token.Id{Token.Id.number});
try testLex("0xff", &[_]Token.Id{Token.Id.number});
try testLex("0x56", &[_]Token.Id{Token.Id.number});
// other cases
try testLex(".1", &[_]Token.Id{Token.Id.number});
try testLex("0xFF", &[_]Token.Id{Token.Id.number});
try testLex("0XeF", &[_]Token.Id{Token.Id.number});
try testLex("1e+3", &[_]Token.Id{Token.Id.number});
// 3e2 and .52 should lex as separate tokens
try testLex("3e2.52", &[_]Token.Id{ Token.Id.number, Token.Id.number });
}
test "LexError.MalformedNumber" {
try expectLexError(LexError.MalformedNumber, testLex("1e", &[_]Token.Id{Token.Id.number}));
try expectLexError(LexError.MalformedNumber, testLex("0z", &[_]Token.Id{Token.Id.number}));
try expectLexError(LexError.MalformedNumber, testLex("0x", &[_]Token.Id{Token.Id.number}));
try expectLexError(LexError.MalformedNumber, testLex("0xabcz", &[_]Token.Id{Token.Id.number}));
try expectLexError(LexError.MalformedNumber, testLex("1xabc", &[_]Token.Id{Token.Id.number}));
try expectLexError(LexError.MalformedNumber, testLex("0.1.e2", &[_]Token.Id{Token.Id.number}));
try expectLexError(LexError.MalformedNumber, testLex("0.1.", &[_]Token.Id{Token.Id.number}));
try expectLexError(LexError.MalformedNumber, testLex("0.1.2", &[_]Token.Id{Token.Id.number}));
try expectLexError(LexError.MalformedNumber, testLex("0.1e3a", &[_]Token.Id{Token.Id.number}));
try expectLexError(LexError.MalformedNumber, testLex("0.1e-", &[_]Token.Id{Token.Id.number}));
try expectLexError(LexError.MalformedNumber, testLex("0.1e-a", &[_]Token.Id{Token.Id.number}));
try expectLexError(LexError.MalformedNumber, testLex("0.1e+", &[_]Token.Id{Token.Id.number}));
try expectLexError(LexError.MalformedNumber, testLex("0.1e--2", &[_]Token.Id{Token.Id.number}));
try expectLexError(LexError.MalformedNumber, testLex("0.1e-)2", &[_]Token.Id{Token.Id.number}));
try expectLexError(LexError.MalformedNumber, testLex("0.1e+-2", &[_]Token.Id{Token.Id.number}));
// Lua's lexer weirdly 'allows'/consumes _ when lexing numbers (see llex.c:201 in 5.1.5),
// but as far as I can tell there are no valid ways to define a number with a _ in it.
// Either way, we should fail with MalformedNumber in the same ways that Lua does,
// so we need to handle _ similarly to the Lua lexer.
try expectLexError(LexError.MalformedNumber, testLex("1_2", &[_]Token.Id{Token.Id.number}));
try expectLexError(LexError.MalformedNumber, testLex("0x2__", &[_]Token.Id{Token.Id.number}));
try expectLexError(LexError.MalformedNumber, testLex("0x__", &[_]Token.Id{Token.Id.number}));
try expectLexError(LexError.MalformedNumber, testLex("1e__", &[_]Token.Id{Token.Id.number}));
try expectLexError(LexError.MalformedNumber, testLex("1e-1_", &[_]Token.Id{Token.Id.number}));
try expectLexError(LexError.MalformedNumber, testLex(".1_", &[_]Token.Id{Token.Id.number}));
}
test "LexError.InvalidLongStringDelimiter" {
// see comment in Lexer.next near the return of LexError.InvalidLongStringDelimiter
const simple = testLex("[==]", &[_]Token.Id{Token.Id.string});
try expectLexError(LexError.InvalidLongStringDelimiter, simple);
const number = testLex("[=======4", &[_]Token.Id{Token.Id.string});
try expectLexError(LexError.InvalidLongStringDelimiter, number);
const eof = testLex("[==", &[_]Token.Id{Token.Id.string});
try expectLexError(LexError.InvalidLongStringDelimiter, eof);
}
test "LexError.EscapeSequenceTooLarge" {
try expectLexError(LexError.EscapeSequenceTooLarge, testLex("'\\256'", &[_]Token.Id{Token.Id.string}));
}
test "LexError.UnfinishedLongComment" {
const simple = testLex("--[[", &[_]Token.Id{});
try expectLexError(LexError.UnfinishedLongComment, simple);
const mismatchedSep = testLex("--[==[ ]=]", &[_]Token.Id{});
try expectLexError(LexError.UnfinishedLongComment, mismatchedSep);
}
test "LexError.UnfinishedString" {
const missingQuoteResult = testLex("local hello = \"wor\\\"ld", &[_]Token.Id{
Token.Id.keyword_local,
Token.Id.name,
Token.Id.single_char,
Token.Id.string,
});
try expectLexError(LexError.UnfinishedString, missingQuoteResult);
const newlineResult = testLex("local hello = \"wor\\\"ld\n\"", &[_]Token.Id{
Token.Id.keyword_local,
Token.Id.name,
Token.Id.single_char,
Token.Id.string,
});
try expectLexError(LexError.UnfinishedString, newlineResult);
}
test "5.1 check_next bug compat on" {
try testLexCheckNextBugCompat(".\x00", &[_]Token.Id{Token.Id.concat});
try testLexCheckNextBugCompat(".\x00\x00", &[_]Token.Id{Token.Id.ellipsis});
try testLexCheckNextBugCompat("..\x00", &[_]Token.Id{Token.Id.ellipsis});
try testLexCheckNextBugCompat("1\x00", &[_]Token.Id{Token.Id.number});
try testLexCheckNextBugCompat("1\x00-5", &[_]Token.Id{Token.Id.number});
try testLexCheckNextBugCompat("1\x00\x005", &[_]Token.Id{Token.Id.number});
try testLexCheckNextBugCompat("1\x00\x00anythingcangoherenow", &[_]Token.Id{Token.Id.number});
try testLexCheckNextBugCompat(".0\x00", &[_]Token.Id{Token.Id.number});
try testLexCheckNextBugCompat(".0\x00)", &[_]Token.Id{ Token.Id.number, Token.Id.single_char });
// should lex as: 5\x00z5 ; \x00 ; 9\x00\x00 ; \x00
try testLexCheckNextBugCompat("5\x00z5\x009\x00\x00\x00", &[_]Token.Id{
Token.Id.number,
Token.Id.single_char,
Token.Id.number,
Token.Id.single_char,
});
try testLexCheckNextBugCompat("5\x00--z5", &[_]Token.Id{
Token.Id.number,
Token.Id.single_char,
Token.Id.name,
});
try expectLexError(LexError.MalformedNumber, testLexCheckNextBugCompat("1e\x005", &[_]Token.Id{Token.Id.number}));
}
test "5.1 check_next bug compat off" {
try testLexNoCheckNextBugCompat(".\x00", &[_]Token.Id{ Token.Id.single_char, Token.Id.single_char });
try testLexNoCheckNextBugCompat("1\x00", &[_]Token.Id{ Token.Id.number, Token.Id.single_char });
try testLexNoCheckNextBugCompat("1\x00-5", &[_]Token.Id{ Token.Id.number, Token.Id.single_char, Token.Id.single_char, Token.Id.number });
// should lex as: 5 ; \x00 ; z5 ; \x00 ; 9 ; \x00 ; \x00 ; \x00
try testLexNoCheckNextBugCompat("5\x00z5\x009\x00\x00\x00", &[_]Token.Id{
Token.Id.number,
Token.Id.single_char,
Token.Id.name,
Token.Id.single_char,
Token.Id.number,
Token.Id.single_char,
Token.Id.single_char,
Token.Id.single_char,
});
try expectLexError(LexError.MalformedNumber, testLexNoCheckNextBugCompat("1e\x005", &[_]Token.Id{Token.Id.number}));
}
fn expectLexError(expected: LexError, actual: anytype) !void {
if (veryVerboseLexing) std.debug.print("\n", .{});
try std.testing.expectError(expected, actual);
if (dumpTokensDuringTests) std.debug.print("{}\n", .{actual});
}
fn testLex(source: []const u8, expected_tokens: []const Token.Id) !void {
var lexer = Lexer.init(source, source);
return testLexInitialized(&lexer, expected_tokens);
}
fn testLexCheckNextBugCompat(source: []const u8, expected_tokens: []const Token.Id) !void {
var lexer = Lexer.init(source, source);
lexer.check_next_bug_compat = true;
return testLexInitialized(&lexer, expected_tokens);
}
fn testLexNoCheckNextBugCompat(source: []const u8, expected_tokens: []const Token.Id) !void {
var lexer = Lexer.init(source, source);
lexer.check_next_bug_compat = false;
return testLexInitialized(&lexer, expected_tokens);
}
fn testLexInitialized(lexer: *Lexer, expected_tokens: []const Token.Id) !void {
if (dumpTokensDuringTests) std.debug.print("\n----------------------\n{s}\n----------------------\n", .{lexer.buffer});
for (expected_tokens) |expected_token_id| {
const token = try lexer.next();
if (dumpTokensDuringTests) lexer.dump(&token);
try std.testing.expectEqual(expected_token_id, token.id);
}
const last_token = try lexer.next();
try std.testing.expectEqual(Token.Id.eof, last_token.id);
}
test "line numbers" {
try testLexLineNumbers(
\\a
\\b
\\c
,
&[_]TokenAndLineNumber{
.{ .id = Token.Id.name, .line_number = 1 },
.{ .id = Token.Id.name, .line_number = 2 },
.{ .id = Token.Id.name, .line_number = 3 },
.{ .id = Token.Id.eof, .line_number = 3 },
},
);
try testLexLineNumbers("\n\n\na", &[_]TokenAndLineNumber{
.{ .id = Token.Id.name, .line_number = 4 },
.{ .id = Token.Id.eof, .line_number = 4 },
});
// \r\n pair separated by a comment
try testLexLineNumbers("\r--comment\na", &[_]TokenAndLineNumber{
.{ .id = Token.Id.name, .line_number = 3 },
.{ .id = Token.Id.eof, .line_number = 3 },
});
// line endings in comments should affect the line numbers of the tokens afterwards
try testLexLineNumbers(
"n--[[\n]]",
&[_]TokenAndLineNumber{
.{ .id = Token.Id.name, .line_number = 1 },
.{ .id = Token.Id.eof, .line_number = 2 },
},
);
}
const TokenAndLineNumber = struct {
id: Token.Id,
line_number: usize,
};
fn testLexLineNumbers(source: []const u8, expected_tokens: []const TokenAndLineNumber) !void {
var lexer = Lexer.init(source, source);
if (dumpTokensDuringTests) std.debug.print("\n----------------------\n{s}\n----------------------\n", .{lexer.buffer});
for (expected_tokens) |expected_token| {
const token = try lexer.next();
if (dumpTokensDuringTests) lexer.dump(&token);
try std.testing.expectEqual(expected_token.id, token.id);
try std.testing.expectEqual(expected_token.line_number, token.line_number);
if (token.id == Token.Id.eof) {
return;
}
}
unreachable; // never hit EOF
}
test "chunk has too many lines" {
var max_lines_lexer = Lexer.init("\n\n\n\n\n", "max_lines");
// reduce the limit to something manageable so we don't have to test with a giant file
max_lines_lexer.max_lines = 4;
while (true) {
const token = max_lines_lexer.next() catch |err| {
try std.testing.expectEqual(LexError.ChunkHasTooManyLines, err);
const err_msg = try max_lines_lexer.renderErrorAlloc(std.testing.allocator);
defer std.testing.allocator.free(err_msg);
try std.testing.expectEqualStrings(
"[string \"max_lines\"]:4: chunk has too many lines",
err_msg,
);
break;
};
if (token.id == Token.Id.eof) {
unreachable;
}
}
}
test "lexical element too long" {
var max_size_lexer = Lexer.init(
\\this.is.ok.since.each.is.sep.token
\\"but next" .. "line is"
\\one_too_many
\\
, "max_size");
// reduce the limit to something manageable so we don't have to test with a giant file
max_size_lexer.max_lexical_element_size = 11;
while (true) {
const token = max_size_lexer.next() catch |err| {
try std.testing.expectEqual(LexError.LexicalElementTooLong, err);
const err_msg = try max_size_lexer.renderErrorAlloc(std.testing.allocator);
defer std.testing.allocator.free(err_msg);
try std.testing.expectEqualStrings(
"[string \"max_size\"]:3: lexical element too long",
err_msg,
);
break;
};
if (token.id == Token.Id.eof) {
unreachable;
}
}
} | src/lex.zig |
const c = @cImport({
@cInclude("soundio/soundio.h");
});
const std = @import("std");
const print = std.debug.print;
const panic = std.debug.panic;
const Allocator = std.mem.Allocator;
const sio_err = @import("sio_errors.zig").sio_err;
const I = @import("instruments.zig");
const Instrument = I.Instrument;
const Signal = I.Signal;
const FF = I.FF;
const G = @import("global_config.zig");
const network = @import("network.zig");
const expect = std.testing.expect;
const GlobalState = struct {
bufL: []f32,
bufR: []f32,
// (constant) number of frames written at once is a multiple of n_frames
// this creates time quantization
n_frames: u32,
// number of frames that are ready to read in bufL, bufR
n_frames_ready: u32 = 0,
// for now, the way latency / frequency of writes is dealt with:
// 1. write_callback "requests" a certain number of frames, frame_count_max
// it is written in n_frames_requested
// 2. play() then prepares as much frames as requested.
n_frames_requested: u32 = 0,
// seconds of audio actually written to audio buffer by write_callback
// crucial to know where to start again to play new sounds
global_t: f32 = 0,
// /// mimicks what happens in write_callback
// fn test_consume_ready(g_state: *GlobalState, n_max: u32) void {
// if (n_max > g_state.n_frames_ready)
// g_state.n_frames_requested += n_max - g_state.n_frames_ready;
// // copy buffer
// g_state.n_frames_ready = 0;
// }
};
pub fn main() !u8 {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = arena.allocator();
var noteQueue = I.NoteQueue.init(allocator, undefined);
var instr1 = try I.createOsc(allocator, 0.0, 0.1, 440.0, -1);
var instr2 = try I.createOsc(allocator, 1.0, 0.05, 440.0 * (4.0 / 3.0), -1);
var instr3 = try I.createOsc(allocator, 1.0, 0.025, 440.0 * (5.0 / 3.0), -1);
try expect(instr1 != instr2);
_ = instr1;
_ = instr2;
_ = instr3;
// try noteQueue.add(instr1);
// try noteQueue.add(instr2);
// try noteQueue.add(instr3);
// try noteQueue.add(&instr2.instrument);
// try noteQueue.add(&instr3.instrument);
// try noteQueue.add(&instr4.instrument);
// try noteQueue.add(&instr5.instrument);
// try noteQueue.add(&instr6.instrument);
var kick_i = try I.createKick(allocator, 0.0, 0.5, 100, 0.45, true);
// try noteQueue.add(kick_i);
_ = kick_i;
const n_frames: u32 = 1000;
const latency: f32 = @intToFloat(f32, n_frames) * 4 / @intToFloat(f32, G.sample_rate);
// NETWORK
const thread = try std.Thread.spawn(
.{},
network.listenToEvents,
.{ allocator, ¬eQueue },
);
thread.detach();
try startServer(allocator, n_frames, latency, ¬eQueue);
return 0;
}
inline fn print_vb(comptime fmt: []const u8, args: anytype, comptime verbose_level: u8) void {
if (G.verbose >= verbose_level) {
print(fmt, args);
}
}
pub fn play(
alloc: Allocator,
g_state: *GlobalState,
noteQueue: *I.NoteQueue,
) !void {
if (g_state.n_frames_ready > 0) { // data hasn't been read yet!
print_vb("NOT READ DATA!\n", .{}, 3);
return;
}
// @setRuntimeSafety(true);
// only play multiples of g_state.n_frame. Necessary? sounds like a good idea for quantization purposes?
const additional = (g_state.n_frames_requested) / g_state.n_frames;
const frames_to_play = g_state.n_frames * (additional + 1);
print_vb("play(): #frames={} \n", .{frames_to_play}, 3);
// const frames_to_play = g_state.n_frames * additional;
const frames_left = g_state.n_frames_requested % g_state.n_frames;
// play instruments, mix, etc.
// first, zero out the buffers
// print("PLAY!!! {} {}\n", .{ g_state.bufL.len, frames_to_play });
std.mem.set(f32, g_state.bufL[0..frames_to_play], 0);
std.mem.set(f32, g_state.bufR[0..frames_to_play], 0);
// there are 2 cases when we don't play anything
// - if there is no note in the queue
// - if the closest note in time is still to far in time
var dont_play: bool = false;
// tol: tolerance to decide if we can play the note or not
const tol = G.sec_per_frame * @intToFloat(f32, g_state.n_frames);
while (noteQueue.peek()) |elem| {
print_vb("Time {}, ftp {}\n", .{ g_state.global_t, frames_to_play }, 3);
if (elem.over) {
// remove notes that are over
alloc.destroy(noteQueue.remove());
print_vb("Stop playing instrument={} at time t={}\n", .{ elem, g_state.global_t }, 1);
} else {
// check that the next note to play is not too far in time
var time_delta = elem.approx_start_time - g_state.global_t;
if (time_delta > tol) {
// if it is too far in time, don't play anything
dont_play = true;
}
break;
}
}
if (!dont_play) {
// it'd be nice to iterate in the order of priority, but idk how to do
// that
var maybe_it = noteQueue.iterator();
while (maybe_it.next()) |it| {
const time_delta = g_state.global_t - it.approx_start_time;
if (time_delta > tol) {
if (!it.started) {
it.real_start_time = g_state.global_t;
}
const real_time_delta = g_state.global_t - it.real_start_time;
const instr_buf = it.play(real_time_delta, frames_to_play);
for (instr_buf) |*b, i| {
g_state.bufL[i] += b.* * it.volume;
g_state.bufR[i] += b.* * it.volume;
}
print_vb("Play {p} at time {}\n", .{ it, g_state.global_t }, 4);
}
}
}
// print("MAX {}\n", .{std.mem.max(f32, g_state.bufL[0..frames_to_play])});
// update global state
g_state.n_frames_ready = frames_to_play;
g_state.global_t += @intToFloat(f32, frames_to_play) / @intToFloat(f32, G.sample_rate);
g_state.n_frames_requested = frames_left;
print_vb("End play: preped {}, left {}\n", .{ g_state.n_frames_ready, g_state.n_frames_requested }, 3);
}
// test "play" {
// var alloc = std.testing.allocator;
// var bufL = [_]f32{0.0} ** (10 * 5);
// var bufR = [_]f32{0.0} ** (10 * 5);
// var g_state = GlobalState{
// .bufL = &bufL,
// .bufR = &bufR,
// .n_frames = 10,
// };
// g_state.test_consume_ready(14);
// // nothing prepared, requests 14; play() prepares 20
// // print("1a {} {}\n", .{ g_state.n_frames_ready, g_state.n_frames_requested });
// try play(alloc, &g_state);
// print("1b {} {}\n", .{ g_state.n_frames_ready, g_state.n_frames_requested });
// // try expect(g_state.n_frames_ready == 20);
// g_state.test_consume_ready(18);
// // only plays 10
// // print("2a {} {}\n", .{ g_state.n_frames_ready, g_state.n_frames_requested });
// try play(alloc, &g_state);
// print("2b {} {}\n", .{ g_state.n_frames_ready, g_state.n_frames_requested });
// // try expect(g_state.n_frames_ready == 10);
// g_state.test_consume_ready(40);
// // print("3a {} {}\n", .{ g_state.n_frames_ready, g_state.n_frames_requested });
// try play(alloc, &g_state);
// print("3b {} {}\n", .{ g_state.n_frames_ready, g_state.n_frames_requested });
// // try expect(g_state.n_frames_ready == 20);
// }
/// For now, only create soundio context and pass callback
/// (Taken from https://ziglang.org/learn/overview/ mostly)
pub fn startServer(
alloc: Allocator,
n_min_frames: u32,
latency: f32,
noteQueue: *I.NoteQueue,
) !void {
const soundio: *c.SoundIo = c.soundio_create();
defer c.soundio_destroy(soundio);
const frame_size = n_min_frames;
var bufL = try alloc.alloc(f32, G.buf_size);
var bufR = try alloc.alloc(f32, G.buf_size);
var g_state = GlobalState{
.bufL = bufL,
.bufR = bufR,
.n_frames = frame_size,
};
// const backend = c.SoundIoBackendAlsa;
// default is "PulseAudio", but it is slow!
// print("{}\n", .{@typeInfo(c.enum_SoundIoBackend)});
const backend = c.SoundIoBackendPulseAudio;
try sio_err(c.soundio_connect_backend(soundio, backend));
const backend_name = c.soundio_backend_name(soundio.current_backend);
print_vb("Backend={s}\n", .{backend_name}, 1);
c.soundio_flush_events(soundio);
const device_index = c.soundio_default_output_device_index(soundio);
if (device_index < 0) {
panic("No output device found\n", .{});
}
print_vb("Device index={}\n", .{device_index}, 1);
const device: *c.SoundIoDevice = c.soundio_get_output_device(soundio, device_index);
defer c.soundio_device_unref(device);
print("Modify start TS {}\n", .{G.start_timestamp});
G.start_timestamp = std.time.nanoTimestamp();
print("Modify after start TS {}\n", .{G.start_timestamp});
const outstream: *c.SoundIoOutStream = c.soundio_outstream_create(device) orelse
return error.OutOfMemory;
defer c.soundio_outstream_destroy(outstream);
outstream.userdata = @ptrCast(?*anyopaque, &g_state);
outstream.sample_rate = G.sample_rate;
// the smallest I can get seems to be 0.01 on my machine.
// this gives frame_count_max=112 most of the time, with occasionally
// higher values up to 216
outstream.software_latency = latency;
outstream.format = c.SoundIoFormatFloat32LE; // c.SoundIoFormatFloat32NE
if (!c.soundio_device_supports_format(device, outstream.format)) {
print("Format {s} not supported!\n", .{c.soundio_format_string(outstream.format)});
}
outstream.write_callback = write_callback;
try sio_err(c.soundio_outstream_open(outstream));
var total_latency: f64 = 0.0;
_ = c.soundio_outstream_get_latency(outstream, &total_latency);
print_vb("Software latency={}\n", .{outstream.software_latency}, 1);
print_vb("Latency={}\n", .{total_latency}, 1);
if (outstream.layout_error > 0) {
print("unable to set channel layout\n", .{});
}
try sio_err(c.soundio_outstream_start(outstream));
// the loop
const period_time = @intToFloat(f32, frame_size) / @intToFloat(f32, G.sample_rate);
var t: u64 = 0;
const begin = std.time.nanoTimestamp();
while (true) {
print_vb("Loop\n", .{}, 3);
t += 1;
try play(alloc, &g_state, noteQueue);
const now = std.time.nanoTimestamp();
const elapsed_ns = now - begin;
const remaining = @intToFloat(f32, t) * period_time;
const elapsed = @intToFloat(f32, elapsed_ns) / 1e9;
print("Remaining time {}, request {}, queue={}\n", .{ remaining - elapsed, g_state.n_frames_requested, noteQueue.count() });
if ((remaining - elapsed) < 0) {
print_vb("Running late! {}\n", .{remaining - elapsed}, 1);
} else {
var sleep_ns = @floatToInt(u64, @maximum(remaining - elapsed, 0) * 1e9 * 0.90);
std.time.sleep(sleep_ns);
print_vb("Sleep {}ns\n", .{sleep_ns}, 3);
}
}
}
fn write_callback(
maybe_ostream: ?*c.SoundIoOutStream,
frame_count_min: c_int,
frame_count_max: c_int,
) callconv(.C) void {
const ostream = maybe_ostream.?;
// @setRuntimeSafety(true);
var g_state = @ptrCast(*GlobalState, @alignCast(@alignOf(*GlobalState), ostream.userdata));
print_vb("BEGIN write_callback(): frame_count_min={}, max={}\n", .{ frame_count_min, frame_count_max }, 3);
var opt_areas: ?[*]c.SoundIoChannelArea = null;
const fframe_count_max = @intCast(u32, frame_count_max);
var frames_to_write = @minimum(fframe_count_max, g_state.n_frames_ready);
var total_written: u32 = frames_to_write;
if (fframe_count_max > frames_to_write) {
// in this case, since we write less data than is the maximum
// possible, we request play() to write more data at the next timestep
g_state.n_frames_requested += fframe_count_max - frames_to_write;
}
var err: c_int = 0;
const bufs = [2][]f32{ g_state.bufL, g_state.bufR };
var offset: u32 = 0;
while (frames_to_write > 0) {
var frame_count: c_int = @intCast(c_int, frames_to_write);
err = c.soundio_outstream_begin_write(ostream, &opt_areas, &frame_count);
if (err > 0) {
panic("Error begin_write \n", .{});
}
if (opt_areas) |areas| {
var i: u32 = 0;
const layout = ostream.layout;
while (i < frame_count) : (i += 1) {
var ch: u8 = 0;
while (ch < layout.channel_count) : (ch += 1) {
const step = @intCast(u32, areas[ch].step);
// [*]T supports pointer arithmetic (but not *T), hence 1st cast
const ptr = @ptrCast([*]u8, areas[ch].ptr) + @intCast(usize, step * i);
// we use Float32LE here
@ptrCast(*f32, @alignCast(@alignOf(f32), ptr)).* = bufs[ch][offset + i];
}
}
}
err = c.soundio_outstream_end_write(ostream);
if (err > 0) {
panic("Error end_write \n", .{});
}
print_vb("write_cb() end loop here, {} {} {}\n", .{ frame_count_max, frame_count, frames_to_write }, 3);
frames_to_write -= @intCast(u32, frame_count);
}
g_state.n_frames_ready -= total_written;
if (g_state.n_frames_ready > 0) {
// correct offset, since we generated data too much in advance
// a bit wasteful, but probably necessary for real time
g_state.global_t -= @intToFloat(f32, g_state.n_frames_ready) / @intToFloat(f32, G.sample_rate);
g_state.n_frames_ready = 0;
}
_ = c.soundio_outstream_pause(ostream, false);
print_vb("END write_callback()\n", .{}, 3);
} | src/server.zig |
const std = @import("std");
const Arch = std.Target.Cpu.Arch;
const Abi = std.Target.Abi;
const assert = std.debug.assert;
const Blake3 = std.crypto.hash.Blake3;
const LibCTarget = struct {
name: []const u8,
arch: MultiArch,
};
const MultiArch = union(enum) {
arm,
arm64,
mips,
powerpc,
riscv,
sparc,
x86,
specific: Arch,
fn eql(a: MultiArch, b: MultiArch) bool {
if (@enumToInt(a) != @enumToInt(b))
return false;
if (a != .specific)
return true;
return a.specific == b.specific;
}
};
const linux_targets = [_]LibCTarget{
LibCTarget{
.name = "arc",
.arch = MultiArch{ .specific = Arch.arc },
},
LibCTarget{
.name = "arm",
.arch = .arm,
},
LibCTarget{
.name = "arm64",
.arch = .{ .specific = .aarch64 },
},
LibCTarget{
.name = "csky",
.arch = .{ .specific = .csky },
},
LibCTarget{
.name = "hexagon",
.arch = .{ .specific = .hexagon },
},
LibCTarget{
.name = "m68k",
.arch = .{ .specific = .m68k },
},
LibCTarget{
.name = "mips",
.arch = .mips,
},
LibCTarget{
.name = "powerpc",
.arch = .powerpc,
},
LibCTarget{
.name = "riscv",
.arch = .riscv,
},
LibCTarget{
.name = "s390",
.arch = .{ .specific = .s390x },
},
LibCTarget{
.name = "sparc",
.arch = .{ .specific = .sparc },
},
LibCTarget{
.name = "x86",
.arch = .x86,
},
};
const DestTarget = struct {
arch: MultiArch,
const HashContext = struct {
pub fn hash(self: @This(), a: DestTarget) u32 {
_ = self;
var hasher = std.hash.Wyhash.init(0);
std.hash.autoHash(&hasher, a.arch);
return @truncate(u32, hasher.final());
}
pub fn eql(self: @This(), a: DestTarget, b: DestTarget, b_index: usize) bool {
_ = self;
_ = b_index;
return a.arch.eql(b.arch);
}
};
};
const Contents = struct {
bytes: []const u8,
hit_count: usize,
hash: []const u8,
is_generic: bool,
fn hitCountLessThan(context: void, lhs: *const Contents, rhs: *const Contents) bool {
_ = context;
return lhs.hit_count < rhs.hit_count;
}
};
const HashToContents = std.StringHashMap(Contents);
const TargetToHash = std.ArrayHashMap(DestTarget, []const u8, DestTarget.HashContext, true);
const PathTable = std.StringHashMap(*TargetToHash);
pub fn main() !void {
var arena_state = std.heap.ArenaAllocator.init(std.heap.page_allocator);
const arena = arena_state.allocator();
const args = try std.process.argsAlloc(arena);
var search_paths = std.ArrayList([]const u8).init(arena);
var opt_out_dir: ?[]const u8 = null;
var arg_i: usize = 1;
while (arg_i < args.len) : (arg_i += 1) {
if (std.mem.eql(u8, args[arg_i], "--help"))
usageAndExit(args[0]);
if (arg_i + 1 >= args.len) {
std.debug.print("expected argument after '{s}'\n", .{args[arg_i]});
usageAndExit(args[0]);
}
if (std.mem.eql(u8, args[arg_i], "--search-path")) {
try search_paths.append(args[arg_i + 1]);
} else if (std.mem.eql(u8, args[arg_i], "--out")) {
assert(opt_out_dir == null);
opt_out_dir = args[arg_i + 1];
} else {
std.debug.print("unrecognized argument: {s}\n", .{args[arg_i]});
usageAndExit(args[0]);
}
arg_i += 1;
}
const out_dir = opt_out_dir orelse usageAndExit(args[0]);
const generic_name = "any-linux-any";
var path_table = PathTable.init(arena);
var hash_to_contents = HashToContents.init(arena);
var max_bytes_saved: usize = 0;
var total_bytes: usize = 0;
var hasher = Blake3.init(.{});
for (linux_targets) |linux_target| {
const dest_target = DestTarget{
.arch = linux_target.arch,
};
search: for (search_paths.items) |search_path| {
const target_include_dir = try std.fs.path.join(arena, &.{
search_path, linux_target.name, "include",
});
var dir_stack = std.ArrayList([]const u8).init(arena);
try dir_stack.append(target_include_dir);
while (dir_stack.popOrNull()) |full_dir_name| {
var dir = std.fs.cwd().openDir(full_dir_name, .{ .iterate = true }) catch |err| switch (err) {
error.FileNotFound => continue :search,
error.AccessDenied => continue :search,
else => return err,
};
defer dir.close();
var dir_it = dir.iterate();
while (try dir_it.next()) |entry| {
const full_path = try std.fs.path.join(arena, &[_][]const u8{ full_dir_name, entry.name });
switch (entry.kind) {
.Directory => try dir_stack.append(full_path),
.File => {
const rel_path = try std.fs.path.relative(arena, target_include_dir, full_path);
const max_size = 2 * 1024 * 1024 * 1024;
const raw_bytes = try std.fs.cwd().readFileAlloc(arena, full_path, max_size);
const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");
total_bytes += raw_bytes.len;
const hash = try arena.alloc(u8, 32);
hasher = Blake3.init(.{});
hasher.update(rel_path);
hasher.update(trimmed);
hasher.final(hash);
const gop = try hash_to_contents.getOrPut(hash);
if (gop.found_existing) {
max_bytes_saved += raw_bytes.len;
gop.value_ptr.hit_count += 1;
std.debug.print("duplicate: {s} {s} ({:2})\n", .{
linux_target.name,
rel_path,
std.fmt.fmtIntSizeDec(raw_bytes.len),
});
} else {
gop.value_ptr.* = Contents{
.bytes = trimmed,
.hit_count = 1,
.hash = hash,
.is_generic = false,
};
}
const path_gop = try path_table.getOrPut(rel_path);
const target_to_hash = if (path_gop.found_existing) path_gop.value_ptr.* else blk: {
const ptr = try arena.create(TargetToHash);
ptr.* = TargetToHash.init(arena);
path_gop.value_ptr.* = ptr;
break :blk ptr;
};
try target_to_hash.putNoClobber(dest_target, hash);
},
else => std.debug.print("warning: weird file: {s}\n", .{full_path}),
}
}
}
break;
} else {
std.debug.print("warning: libc target not found: {s}\n", .{linux_target.name});
}
}
std.debug.print("summary: {:2} could be reduced to {:2}\n", .{
std.fmt.fmtIntSizeDec(total_bytes),
std.fmt.fmtIntSizeDec(total_bytes - max_bytes_saved),
});
try std.fs.cwd().makePath(out_dir);
var missed_opportunity_bytes: usize = 0;
// iterate path_table. for each path, put all the hashes into a list. sort by hit_count.
// the hash with the highest hit_count gets to be the "generic" one. everybody else
// gets their header in a separate arch directory.
var path_it = path_table.iterator();
while (path_it.next()) |path_kv| {
var contents_list = std.ArrayList(*Contents).init(arena);
{
var hash_it = path_kv.value_ptr.*.iterator();
while (hash_it.next()) |hash_kv| {
const contents = hash_to_contents.getPtr(hash_kv.value_ptr.*).?;
try contents_list.append(contents);
}
}
std.sort.sort(*Contents, contents_list.items, {}, Contents.hitCountLessThan);
const best_contents = contents_list.popOrNull().?;
if (best_contents.hit_count > 1) {
// worth it to make it generic
const full_path = try std.fs.path.join(arena, &[_][]const u8{ out_dir, generic_name, path_kv.key_ptr.* });
try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?);
try std.fs.cwd().writeFile(full_path, best_contents.bytes);
best_contents.is_generic = true;
while (contents_list.popOrNull()) |contender| {
if (contender.hit_count > 1) {
const this_missed_bytes = contender.hit_count * contender.bytes.len;
missed_opportunity_bytes += this_missed_bytes;
std.debug.print("Missed opportunity ({:2}): {s}\n", .{
std.fmt.fmtIntSizeDec(this_missed_bytes),
path_kv.key_ptr.*,
});
} else break;
}
}
var hash_it = path_kv.value_ptr.*.iterator();
while (hash_it.next()) |hash_kv| {
const contents = hash_to_contents.get(hash_kv.value_ptr.*).?;
if (contents.is_generic) continue;
const dest_target = hash_kv.key_ptr.*;
const arch_name = switch (dest_target.arch) {
.specific => |a| @tagName(a),
else => @tagName(dest_target.arch),
};
const out_subpath = try std.fmt.allocPrint(arena, "{s}-linux-any", .{arch_name});
const full_path = try std.fs.path.join(arena, &[_][]const u8{ out_dir, out_subpath, path_kv.key_ptr.* });
try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?);
try std.fs.cwd().writeFile(full_path, contents.bytes);
}
}
const bad_files = [_][]const u8{
"any-linux-any/linux/netfilter/xt_CONNMARK.h",
"any-linux-any/linux/netfilter/xt_DSCP.h",
"any-linux-any/linux/netfilter/xt_MARK.h",
"any-linux-any/linux/netfilter/xt_RATEEST.h",
"any-linux-any/linux/netfilter/xt_TCPMSS.h",
"any-linux-any/linux/netfilter_ipv4/ipt_ECN.h",
"any-linux-any/linux/netfilter_ipv4/ipt_TTL.h",
"any-linux-any/linux/netfilter_ipv6/ip6t_HL.h",
};
for (bad_files) |bad_file| {
const full_path = try std.fs.path.join(arena, &[_][]const u8{ out_dir, bad_file });
try std.fs.cwd().deleteFile(full_path);
}
}
fn usageAndExit(arg0: []const u8) noreturn {
std.debug.print("Usage: {s} [--search-path <dir>] --out <dir> --abi <name>\n", .{arg0});
std.debug.print("--search-path can be used any number of times.\n", .{});
std.debug.print(" subdirectories of search paths look like, e.g. x86_64-linux-gnu\n", .{});
std.debug.print("--out is a dir that will be created, and populated with the results\n", .{});
std.process.exit(1);
} | tools/update-linux-headers.zig |
const std = @import("std");
const lines_lib = @import("lines.zig");
const Lines = lines_lib.Lines;
const Allocator = std.mem.Allocator;
pub fn hack_url_decode(allocator : Allocator, input : []const u8) ![]const u8 {
return std.mem.replaceOwned(u8, allocator, input, "%3A", ":");
}
pub fn parse_path(allocator : Allocator, path: []const u8) ![]const u8 {
var no_prefix = try std.mem.replaceOwned(u8, allocator, path, "file:///", "");
var no_url_encode = try hack_url_decode(allocator, no_prefix);
var parsed_path = try std.mem.replaceOwned(u8, allocator, no_url_encode, "/", "\\");
return parsed_path;
}
pub fn zig_build(allocator : Allocator, path: []const u8) !std.ArrayList(ParsedError) {
var res = std.ArrayList(ParsedError).init(allocator);
var file = try std.fs.createFileAbsolute("C:\\users\\dan\\tmp\\zls_build.log", .{.truncate = false});
defer(file.close());
try file.writer().print("GEGGG", .{});
const parsed_path = try parse_path(allocator, path);
try file.writer().print("Running zig build in '{s}'", .{parsed_path});
var result = try std.ChildProcess.exec(.{.allocator = allocator, .argv = &.{"zig", "build"}, .cwd = parsed_path});
try file.writer().print("stdout {s} \n stderr '{s}'", .{result.stdout, result.stderr});
var lines = try Lines.init(allocator, result.stderr);
var cursor : usize = 0;
while (parse_error(allocator, lines, &cursor)) |parsed| {
try res.append(parsed);
}
return res;
}
pub fn ast_check(allocator : Allocator, path : []const u8) !std.ArrayList(ParsedError) {
const parsed_path = try parse_path(allocator, path);
//var file = try std.fs.createFileAbsolute("C:\\users\\dan\\tmp\\zls.log", .{.truncate = false});
//try file.writer().print("Parsed path as '{s}'", .{parsed_path});
//defer(file.close());
var result = try std.ChildProcess.exec(.{.allocator = allocator, .argv = &.{"zig", "ast-check", parsed_path}});
var lines = try Lines.init(allocator, result.stderr);
var res = std.ArrayList(ParsedError).init(allocator);
//try file.writer().print("stderr '{s}'", .{result.stderr});
//std.log.info("{s}\n", .{result.stderr});
var cursor : usize = 0;
while (parse_error(allocator, lines, &cursor)) |parsed| {
try res.append(parsed);
}
//try file.writer().print("Parsed '{d}' errors", .{res.items.len});
return res;
}
pub const ParsedError = struct {
line_number : u32,
char_number : u32,
error_str : []const u8,
helper_str : []const u8,
};
fn parse_error(allocator : Allocator, lines : Lines, cursor : *usize) ?ParsedError {
std.mem.doNotOptimizeAway(allocator);
while (true)
{
var cur_line = lines.get(cursor.*);
if (cur_line == null) {
return null;
}
cursor.* += 1;
// HACKY
if (std.mem.startsWith(u8, cur_line.?, "c:\\") or std.mem.startsWith(u8, cur_line.?, "C:\\")) {
var splits = std.mem.split(u8, cur_line.?, " ");
var path = splits.next();
var typetype = splits.next();
var text_start_index = splits.index;
var text = splits.next();
if (path == null or typetype == null or text == null)
{
continue;
}
if (!std.mem.startsWith(u8, typetype.?, "error")) {
continue;
}
const pos = parse_position_from_path(path.?);
if (pos == null) {
continue;
}
const full_text = cur_line.?[text_start_index.?..];
return ParsedError {
.line_number = pos.?.line,
.char_number = pos.?.char,
.error_str = full_text,
.helper_str = "",
};
}
else {
continue;
}
}
}
const Pos = struct {line : u32, char: u32};
// Expect path to be of the form C:\aowifjawoifja\main.zig:5:9:
fn parse_position_from_path(path : [] const u8) ?Pos {
var splits = std.mem.split(u8, path, ":");
var line_pos : ?[]const u8 = null;
var char_pos : ?[]const u8 = null;
while (splits.next()) |str| {
if (str.len > 0) {
line_pos = char_pos;
char_pos = str;
}
}
if (line_pos == null or char_pos == null) {
return null;
}
const line = std.fmt.parseUnsigned(u32, line_pos.?, 10) catch { return null; };
const char = std.fmt.parseUnsigned(u32, char_pos.?, 10) catch { return null; };
return Pos{.line = line-1, .char = char-1 };
} | src/dan/runner.zig |
const std = @import("std");
const math = std.math;
const util = @import("util.zig");
const Map = struct {
data: std.AutoHashMap(Point, i32),
const Self = @This();
const Point = struct { x: i32, y: i32 };
fn init() Self {
return .{
.data = std.AutoHashMap(Point, i32).init(std.heap.page_allocator),
};
}
fn deinit(self: *Self) void {
self.data.deinit();
}
fn mark(self: *Self, x: i32, y: i32) !void {
const res = try self.data.getOrPut(Point{ .x = x, .y = y });
if (res.found_existing) {
res.value_ptr.* += 1;
} else {
res.value_ptr.* = 1;
}
}
fn get(self: *const Self, x: i32, y: i32) ?i32 {
return self.data.get(Point{ .x = x, .y = y });
}
fn count(self: *const Self) u64 {
var total: u64 = 0;
var values = self.data.valueIterator();
while (values.next()) |v| {
if (v.* >= 2) total += 1;
}
return total;
}
};
pub fn part1(input: []const u8) !u64 {
var map = Map.init();
defer map.deinit();
var lines = std.mem.tokenize(u8, input, "\n");
while (lines.next()) |line| {
var parts = std.mem.tokenize(u8, line, " -> ");
var start = std.mem.tokenize(u8, parts.next().?, ",");
var end = std.mem.tokenize(u8, parts.next().?, ",");
const x1 = util.parseInt(i32, start.next().?);
const y1 = util.parseInt(i32, start.next().?);
const x2 = util.parseInt(i32, end.next().?);
const y2 = util.parseInt(i32, end.next().?);
if (x1 == x2) {
const min = std.math.min(y1, y2);
const max = std.math.max(y1, y2);
var y = min;
while (y <= max) : (y += 1) {
try map.mark(x1, y);
}
} else if (y1 == y2) {
const min = math.min(x1, x2);
const max = math.max(x1, x2);
var x = min;
while (x <= max) : (x += 1) {
try map.mark(x, y1);
}
}
}
//var y: i32 = 0;
//while (y < 10) : (y += 1) {
// var x: i32 = 0;
// while (x < 10) : (x += 1) {
// if (map.get(x, y)) |v| {
// std.debug.print("{}", .{v});
// } else {
// std.debug.print(".", .{});
// }
// }
// std.debug.print("\n", .{});
//}
return map.count();
}
fn signum(n: i32) i32 {
if (n < 0) {
return -1;
} else if (n == 0) {
return 0;
} else {
return 1;
}
}
fn abs(n: i32) i32 {
if (n < 0) {
return -n;
} else {
return n;
}
}
pub fn part2(input: []const u8) !u64 {
var map = Map.init();
defer map.deinit();
var lines = std.mem.tokenize(u8, input, "\n");
while (lines.next()) |line| {
var parts = std.mem.tokenize(u8, line, " -> ");
var start = std.mem.tokenize(u8, parts.next().?, ",");
var end = std.mem.tokenize(u8, parts.next().?, ",");
const x1 = util.parseInt(i32, start.next().?);
const y1 = util.parseInt(i32, start.next().?);
const x2 = util.parseInt(i32, end.next().?);
const y2 = util.parseInt(i32, end.next().?);
const d = math.max(abs(x2 - x1), abs(y2 - y1));
const mx = signum(x2 - x1);
const my = signum(y2 - y1);
var c: i32 = 0;
while (c <= d) : (c += 1) {
const cx = x1 + c * mx;
const cy = y1 + c * my;
try map.mark(cx, cy);
}
}
return map.count();
}
test "day 5 part 1" {
const test_input =
\\0,9 -> 5,9
\\8,0 -> 0,8
\\9,4 -> 3,4
\\2,2 -> 2,1
\\7,0 -> 7,4
\\6,4 -> 2,0
\\0,9 -> 2,9
\\3,4 -> 1,4
\\0,0 -> 8,8
\\5,5 -> 8,2
;
try std.testing.expectEqual(part1(test_input), 5);
}
test "day 5 part 2" {
const test_input =
\\0,9 -> 5,9
\\8,0 -> 0,8
\\9,4 -> 3,4
\\2,2 -> 2,1
\\7,0 -> 7,4
\\6,4 -> 2,0
\\0,9 -> 2,9
\\3,4 -> 1,4
\\0,0 -> 8,8
\\5,5 -> 8,2
;
try std.testing.expectEqual(part2(test_input), 12);
} | zig/src/day5.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 type MontgomeryDomainFieldElement is a field element in the Montgomery domain.
// Bounds: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
pub const MontgomeryDomainFieldElement = [8]u32;
// The type NonMontgomeryDomainFieldElement is a field element NOT in the Montgomery domain.
// Bounds: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
pub const NonMontgomeryDomainFieldElement = [8]u32;
/// The function addcarryxU32 is an addition with carry.
///
/// Postconditions:
/// out1 = (arg1 + arg2 + arg3) mod 2^32
/// out2 = ⌊(arg1 + arg2 + arg3) / 2^32⌋
///
/// Input Bounds:
/// arg1: [0x0 ~> 0x1]
/// arg2: [0x0 ~> 0xffffffff]
/// arg3: [0x0 ~> 0xffffffff]
/// Output Bounds:
/// out1: [0x0 ~> 0xffffffff]
/// out2: [0x0 ~> 0x1]
inline fn addcarryxU32(out1: *u32, out2: *u1, arg1: u1, arg2: u32, arg3: u32) void {
@setRuntimeSafety(mode == .Debug);
const x1 = ((cast(u64, arg1) + cast(u64, arg2)) + cast(u64, arg3));
const x2 = cast(u32, (x1 & cast(u64, 0xffffffff)));
const x3 = cast(u1, (x1 >> 32));
out1.* = x2;
out2.* = x3;
}
/// The function subborrowxU32 is a subtraction with borrow.
///
/// Postconditions:
/// out1 = (-arg1 + arg2 + -arg3) mod 2^32
/// out2 = -⌊(-arg1 + arg2 + -arg3) / 2^32⌋
///
/// Input Bounds:
/// arg1: [0x0 ~> 0x1]
/// arg2: [0x0 ~> 0xffffffff]
/// arg3: [0x0 ~> 0xffffffff]
/// Output Bounds:
/// out1: [0x0 ~> 0xffffffff]
/// out2: [0x0 ~> 0x1]
inline fn subborrowxU32(out1: *u32, out2: *u1, arg1: u1, arg2: u32, arg3: u32) void {
@setRuntimeSafety(mode == .Debug);
const x1 = ((cast(i64, arg2) - cast(i64, arg1)) - cast(i64, arg3));
const x2 = cast(i1, (x1 >> 32));
const x3 = cast(u32, (x1 & cast(i64, 0xffffffff)));
out1.* = x3;
out2.* = cast(u1, (cast(i2, 0x0) - cast(i2, x2)));
}
/// The function mulxU32 is a multiplication, returning the full double-width result.
///
/// Postconditions:
/// out1 = (arg1 * arg2) mod 2^32
/// out2 = ⌊arg1 * arg2 / 2^32⌋
///
/// Input Bounds:
/// arg1: [0x0 ~> 0xffffffff]
/// arg2: [0x0 ~> 0xffffffff]
/// Output Bounds:
/// out1: [0x0 ~> 0xffffffff]
/// out2: [0x0 ~> 0xffffffff]
inline fn mulxU32(out1: *u32, out2: *u32, arg1: u32, arg2: u32) void {
@setRuntimeSafety(mode == .Debug);
const x1 = (cast(u64, arg1) * cast(u64, arg2));
const x2 = cast(u32, (x1 & cast(u64, 0xffffffff)));
const x3 = cast(u32, (x1 >> 32));
out1.* = x2;
out2.* = x3;
}
/// The function cmovznzU32 is a single-word conditional move.
///
/// Postconditions:
/// out1 = (if arg1 = 0 then arg2 else arg3)
///
/// Input Bounds:
/// arg1: [0x0 ~> 0x1]
/// arg2: [0x0 ~> 0xffffffff]
/// arg3: [0x0 ~> 0xffffffff]
/// Output Bounds:
/// out1: [0x0 ~> 0xffffffff]
inline fn cmovznzU32(out1: *u32, arg1: u1, arg2: u32, arg3: u32) void {
@setRuntimeSafety(mode == .Debug);
const x1 = (~(~arg1));
const x2 = cast(u32, (cast(i64, cast(i1, (cast(i2, 0x0) - cast(i2, x1)))) & cast(i64, 0xffffffff)));
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[6]);
const x7 = (arg1[7]);
const x8 = (arg1[0]);
var x9: u32 = undefined;
var x10: u32 = undefined;
mulxU32(&x9, &x10, x8, (arg2[7]));
var x11: u32 = undefined;
var x12: u32 = undefined;
mulxU32(&x11, &x12, x8, (arg2[6]));
var x13: u32 = undefined;
var x14: u32 = undefined;
mulxU32(&x13, &x14, x8, (arg2[5]));
var x15: u32 = undefined;
var x16: u32 = undefined;
mulxU32(&x15, &x16, x8, (arg2[4]));
var x17: u32 = undefined;
var x18: u32 = undefined;
mulxU32(&x17, &x18, x8, (arg2[3]));
var x19: u32 = undefined;
var x20: u32 = undefined;
mulxU32(&x19, &x20, x8, (arg2[2]));
var x21: u32 = undefined;
var x22: u32 = undefined;
mulxU32(&x21, &x22, x8, (arg2[1]));
var x23: u32 = undefined;
var x24: u32 = undefined;
mulxU32(&x23, &x24, x8, (arg2[0]));
var x25: u32 = undefined;
var x26: u1 = undefined;
addcarryxU32(&x25, &x26, 0x0, x24, x21);
var x27: u32 = undefined;
var x28: u1 = undefined;
addcarryxU32(&x27, &x28, x26, x22, x19);
var x29: u32 = undefined;
var x30: u1 = undefined;
addcarryxU32(&x29, &x30, x28, x20, x17);
var x31: u32 = undefined;
var x32: u1 = undefined;
addcarryxU32(&x31, &x32, x30, x18, x15);
var x33: u32 = undefined;
var x34: u1 = undefined;
addcarryxU32(&x33, &x34, x32, x16, x13);
var x35: u32 = undefined;
var x36: u1 = undefined;
addcarryxU32(&x35, &x36, x34, x14, x11);
var x37: u32 = undefined;
var x38: u1 = undefined;
addcarryxU32(&x37, &x38, x36, x12, x9);
const x39 = (cast(u32, x38) + x10);
var x40: u32 = undefined;
var x41: u32 = undefined;
mulxU32(&x40, &x41, x23, 0xd2253531);
var x42: u32 = undefined;
var x43: u32 = undefined;
mulxU32(&x42, &x43, x40, 0xffffffff);
var x44: u32 = undefined;
var x45: u32 = undefined;
mulxU32(&x44, &x45, x40, 0xffffffff);
var x46: u32 = undefined;
var x47: u32 = undefined;
mulxU32(&x46, &x47, x40, 0xffffffff);
var x48: u32 = undefined;
var x49: u32 = undefined;
mulxU32(&x48, &x49, x40, 0xffffffff);
var x50: u32 = undefined;
var x51: u32 = undefined;
mulxU32(&x50, &x51, x40, 0xffffffff);
var x52: u32 = undefined;
var x53: u32 = undefined;
mulxU32(&x52, &x53, x40, 0xffffffff);
var x54: u32 = undefined;
var x55: u32 = undefined;
mulxU32(&x54, &x55, x40, 0xfffffffe);
var x56: u32 = undefined;
var x57: u32 = undefined;
mulxU32(&x56, &x57, x40, 0xfffffc2f);
var x58: u32 = undefined;
var x59: u1 = undefined;
addcarryxU32(&x58, &x59, 0x0, x57, x54);
var x60: u32 = undefined;
var x61: u1 = undefined;
addcarryxU32(&x60, &x61, x59, x55, x52);
var x62: u32 = undefined;
var x63: u1 = undefined;
addcarryxU32(&x62, &x63, x61, x53, x50);
var x64: u32 = undefined;
var x65: u1 = undefined;
addcarryxU32(&x64, &x65, x63, x51, x48);
var x66: u32 = undefined;
var x67: u1 = undefined;
addcarryxU32(&x66, &x67, x65, x49, x46);
var x68: u32 = undefined;
var x69: u1 = undefined;
addcarryxU32(&x68, &x69, x67, x47, x44);
var x70: u32 = undefined;
var x71: u1 = undefined;
addcarryxU32(&x70, &x71, x69, x45, x42);
const x72 = (cast(u32, x71) + x43);
var x73: u32 = undefined;
var x74: u1 = undefined;
addcarryxU32(&x73, &x74, 0x0, x23, x56);
var x75: u32 = undefined;
var x76: u1 = undefined;
addcarryxU32(&x75, &x76, x74, x25, x58);
var x77: u32 = undefined;
var x78: u1 = undefined;
addcarryxU32(&x77, &x78, x76, x27, x60);
var x79: u32 = undefined;
var x80: u1 = undefined;
addcarryxU32(&x79, &x80, x78, x29, x62);
var x81: u32 = undefined;
var x82: u1 = undefined;
addcarryxU32(&x81, &x82, x80, x31, x64);
var x83: u32 = undefined;
var x84: u1 = undefined;
addcarryxU32(&x83, &x84, x82, x33, x66);
var x85: u32 = undefined;
var x86: u1 = undefined;
addcarryxU32(&x85, &x86, x84, x35, x68);
var x87: u32 = undefined;
var x88: u1 = undefined;
addcarryxU32(&x87, &x88, x86, x37, x70);
var x89: u32 = undefined;
var x90: u1 = undefined;
addcarryxU32(&x89, &x90, x88, x39, x72);
var x91: u32 = undefined;
var x92: u32 = undefined;
mulxU32(&x91, &x92, x1, (arg2[7]));
var x93: u32 = undefined;
var x94: u32 = undefined;
mulxU32(&x93, &x94, x1, (arg2[6]));
var x95: u32 = undefined;
var x96: u32 = undefined;
mulxU32(&x95, &x96, x1, (arg2[5]));
var x97: u32 = undefined;
var x98: u32 = undefined;
mulxU32(&x97, &x98, x1, (arg2[4]));
var x99: u32 = undefined;
var x100: u32 = undefined;
mulxU32(&x99, &x100, x1, (arg2[3]));
var x101: u32 = undefined;
var x102: u32 = undefined;
mulxU32(&x101, &x102, x1, (arg2[2]));
var x103: u32 = undefined;
var x104: u32 = undefined;
mulxU32(&x103, &x104, x1, (arg2[1]));
var x105: u32 = undefined;
var x106: u32 = undefined;
mulxU32(&x105, &x106, x1, (arg2[0]));
var x107: u32 = undefined;
var x108: u1 = undefined;
addcarryxU32(&x107, &x108, 0x0, x106, x103);
var x109: u32 = undefined;
var x110: u1 = undefined;
addcarryxU32(&x109, &x110, x108, x104, x101);
var x111: u32 = undefined;
var x112: u1 = undefined;
addcarryxU32(&x111, &x112, x110, x102, x99);
var x113: u32 = undefined;
var x114: u1 = undefined;
addcarryxU32(&x113, &x114, x112, x100, x97);
var x115: u32 = undefined;
var x116: u1 = undefined;
addcarryxU32(&x115, &x116, x114, x98, x95);
var x117: u32 = undefined;
var x118: u1 = undefined;
addcarryxU32(&x117, &x118, x116, x96, x93);
var x119: u32 = undefined;
var x120: u1 = undefined;
addcarryxU32(&x119, &x120, x118, x94, x91);
const x121 = (cast(u32, x120) + x92);
var x122: u32 = undefined;
var x123: u1 = undefined;
addcarryxU32(&x122, &x123, 0x0, x75, x105);
var x124: u32 = undefined;
var x125: u1 = undefined;
addcarryxU32(&x124, &x125, x123, x77, x107);
var x126: u32 = undefined;
var x127: u1 = undefined;
addcarryxU32(&x126, &x127, x125, x79, x109);
var x128: u32 = undefined;
var x129: u1 = undefined;
addcarryxU32(&x128, &x129, x127, x81, x111);
var x130: u32 = undefined;
var x131: u1 = undefined;
addcarryxU32(&x130, &x131, x129, x83, x113);
var x132: u32 = undefined;
var x133: u1 = undefined;
addcarryxU32(&x132, &x133, x131, x85, x115);
var x134: u32 = undefined;
var x135: u1 = undefined;
addcarryxU32(&x134, &x135, x133, x87, x117);
var x136: u32 = undefined;
var x137: u1 = undefined;
addcarryxU32(&x136, &x137, x135, x89, x119);
var x138: u32 = undefined;
var x139: u1 = undefined;
addcarryxU32(&x138, &x139, x137, cast(u32, x90), x121);
var x140: u32 = undefined;
var x141: u32 = undefined;
mulxU32(&x140, &x141, x122, 0xd2253531);
var x142: u32 = undefined;
var x143: u32 = undefined;
mulxU32(&x142, &x143, x140, 0xffffffff);
var x144: u32 = undefined;
var x145: u32 = undefined;
mulxU32(&x144, &x145, x140, 0xffffffff);
var x146: u32 = undefined;
var x147: u32 = undefined;
mulxU32(&x146, &x147, x140, 0xffffffff);
var x148: u32 = undefined;
var x149: u32 = undefined;
mulxU32(&x148, &x149, x140, 0xffffffff);
var x150: u32 = undefined;
var x151: u32 = undefined;
mulxU32(&x150, &x151, x140, 0xffffffff);
var x152: u32 = undefined;
var x153: u32 = undefined;
mulxU32(&x152, &x153, x140, 0xffffffff);
var x154: u32 = undefined;
var x155: u32 = undefined;
mulxU32(&x154, &x155, x140, 0xfffffffe);
var x156: u32 = undefined;
var x157: u32 = undefined;
mulxU32(&x156, &x157, x140, 0xfffffc2f);
var x158: u32 = undefined;
var x159: u1 = undefined;
addcarryxU32(&x158, &x159, 0x0, x157, x154);
var x160: u32 = undefined;
var x161: u1 = undefined;
addcarryxU32(&x160, &x161, x159, x155, x152);
var x162: u32 = undefined;
var x163: u1 = undefined;
addcarryxU32(&x162, &x163, x161, x153, x150);
var x164: u32 = undefined;
var x165: u1 = undefined;
addcarryxU32(&x164, &x165, x163, x151, x148);
var x166: u32 = undefined;
var x167: u1 = undefined;
addcarryxU32(&x166, &x167, x165, x149, x146);
var x168: u32 = undefined;
var x169: u1 = undefined;
addcarryxU32(&x168, &x169, x167, x147, x144);
var x170: u32 = undefined;
var x171: u1 = undefined;
addcarryxU32(&x170, &x171, x169, x145, x142);
const x172 = (cast(u32, x171) + x143);
var x173: u32 = undefined;
var x174: u1 = undefined;
addcarryxU32(&x173, &x174, 0x0, x122, x156);
var x175: u32 = undefined;
var x176: u1 = undefined;
addcarryxU32(&x175, &x176, x174, x124, x158);
var x177: u32 = undefined;
var x178: u1 = undefined;
addcarryxU32(&x177, &x178, x176, x126, x160);
var x179: u32 = undefined;
var x180: u1 = undefined;
addcarryxU32(&x179, &x180, x178, x128, x162);
var x181: u32 = undefined;
var x182: u1 = undefined;
addcarryxU32(&x181, &x182, x180, x130, x164);
var x183: u32 = undefined;
var x184: u1 = undefined;
addcarryxU32(&x183, &x184, x182, x132, x166);
var x185: u32 = undefined;
var x186: u1 = undefined;
addcarryxU32(&x185, &x186, x184, x134, x168);
var x187: u32 = undefined;
var x188: u1 = undefined;
addcarryxU32(&x187, &x188, x186, x136, x170);
var x189: u32 = undefined;
var x190: u1 = undefined;
addcarryxU32(&x189, &x190, x188, x138, x172);
const x191 = (cast(u32, x190) + cast(u32, x139));
var x192: u32 = undefined;
var x193: u32 = undefined;
mulxU32(&x192, &x193, x2, (arg2[7]));
var x194: u32 = undefined;
var x195: u32 = undefined;
mulxU32(&x194, &x195, x2, (arg2[6]));
var x196: u32 = undefined;
var x197: u32 = undefined;
mulxU32(&x196, &x197, x2, (arg2[5]));
var x198: u32 = undefined;
var x199: u32 = undefined;
mulxU32(&x198, &x199, x2, (arg2[4]));
var x200: u32 = undefined;
var x201: u32 = undefined;
mulxU32(&x200, &x201, x2, (arg2[3]));
var x202: u32 = undefined;
var x203: u32 = undefined;
mulxU32(&x202, &x203, x2, (arg2[2]));
var x204: u32 = undefined;
var x205: u32 = undefined;
mulxU32(&x204, &x205, x2, (arg2[1]));
var x206: u32 = undefined;
var x207: u32 = undefined;
mulxU32(&x206, &x207, x2, (arg2[0]));
var x208: u32 = undefined;
var x209: u1 = undefined;
addcarryxU32(&x208, &x209, 0x0, x207, x204);
var x210: u32 = undefined;
var x211: u1 = undefined;
addcarryxU32(&x210, &x211, x209, x205, x202);
var x212: u32 = undefined;
var x213: u1 = undefined;
addcarryxU32(&x212, &x213, x211, x203, x200);
var x214: u32 = undefined;
var x215: u1 = undefined;
addcarryxU32(&x214, &x215, x213, x201, x198);
var x216: u32 = undefined;
var x217: u1 = undefined;
addcarryxU32(&x216, &x217, x215, x199, x196);
var x218: u32 = undefined;
var x219: u1 = undefined;
addcarryxU32(&x218, &x219, x217, x197, x194);
var x220: u32 = undefined;
var x221: u1 = undefined;
addcarryxU32(&x220, &x221, x219, x195, x192);
const x222 = (cast(u32, x221) + x193);
var x223: u32 = undefined;
var x224: u1 = undefined;
addcarryxU32(&x223, &x224, 0x0, x175, x206);
var x225: u32 = undefined;
var x226: u1 = undefined;
addcarryxU32(&x225, &x226, x224, x177, x208);
var x227: u32 = undefined;
var x228: u1 = undefined;
addcarryxU32(&x227, &x228, x226, x179, x210);
var x229: u32 = undefined;
var x230: u1 = undefined;
addcarryxU32(&x229, &x230, x228, x181, x212);
var x231: u32 = undefined;
var x232: u1 = undefined;
addcarryxU32(&x231, &x232, x230, x183, x214);
var x233: u32 = undefined;
var x234: u1 = undefined;
addcarryxU32(&x233, &x234, x232, x185, x216);
var x235: u32 = undefined;
var x236: u1 = undefined;
addcarryxU32(&x235, &x236, x234, x187, x218);
var x237: u32 = undefined;
var x238: u1 = undefined;
addcarryxU32(&x237, &x238, x236, x189, x220);
var x239: u32 = undefined;
var x240: u1 = undefined;
addcarryxU32(&x239, &x240, x238, x191, x222);
var x241: u32 = undefined;
var x242: u32 = undefined;
mulxU32(&x241, &x242, x223, 0xd2253531);
var x243: u32 = undefined;
var x244: u32 = undefined;
mulxU32(&x243, &x244, x241, 0xffffffff);
var x245: u32 = undefined;
var x246: u32 = undefined;
mulxU32(&x245, &x246, x241, 0xffffffff);
var x247: u32 = undefined;
var x248: u32 = undefined;
mulxU32(&x247, &x248, x241, 0xffffffff);
var x249: u32 = undefined;
var x250: u32 = undefined;
mulxU32(&x249, &x250, x241, 0xffffffff);
var x251: u32 = undefined;
var x252: u32 = undefined;
mulxU32(&x251, &x252, x241, 0xffffffff);
var x253: u32 = undefined;
var x254: u32 = undefined;
mulxU32(&x253, &x254, x241, 0xffffffff);
var x255: u32 = undefined;
var x256: u32 = undefined;
mulxU32(&x255, &x256, x241, 0xfffffffe);
var x257: u32 = undefined;
var x258: u32 = undefined;
mulxU32(&x257, &x258, x241, 0xfffffc2f);
var x259: u32 = undefined;
var x260: u1 = undefined;
addcarryxU32(&x259, &x260, 0x0, x258, x255);
var x261: u32 = undefined;
var x262: u1 = undefined;
addcarryxU32(&x261, &x262, x260, x256, x253);
var x263: u32 = undefined;
var x264: u1 = undefined;
addcarryxU32(&x263, &x264, x262, x254, x251);
var x265: u32 = undefined;
var x266: u1 = undefined;
addcarryxU32(&x265, &x266, x264, x252, x249);
var x267: u32 = undefined;
var x268: u1 = undefined;
addcarryxU32(&x267, &x268, x266, x250, x247);
var x269: u32 = undefined;
var x270: u1 = undefined;
addcarryxU32(&x269, &x270, x268, x248, x245);
var x271: u32 = undefined;
var x272: u1 = undefined;
addcarryxU32(&x271, &x272, x270, x246, x243);
const x273 = (cast(u32, x272) + x244);
var x274: u32 = undefined;
var x275: u1 = undefined;
addcarryxU32(&x274, &x275, 0x0, x223, x257);
var x276: u32 = undefined;
var x277: u1 = undefined;
addcarryxU32(&x276, &x277, x275, x225, x259);
var x278: u32 = undefined;
var x279: u1 = undefined;
addcarryxU32(&x278, &x279, x277, x227, x261);
var x280: u32 = undefined;
var x281: u1 = undefined;
addcarryxU32(&x280, &x281, x279, x229, x263);
var x282: u32 = undefined;
var x283: u1 = undefined;
addcarryxU32(&x282, &x283, x281, x231, x265);
var x284: u32 = undefined;
var x285: u1 = undefined;
addcarryxU32(&x284, &x285, x283, x233, x267);
var x286: u32 = undefined;
var x287: u1 = undefined;
addcarryxU32(&x286, &x287, x285, x235, x269);
var x288: u32 = undefined;
var x289: u1 = undefined;
addcarryxU32(&x288, &x289, x287, x237, x271);
var x290: u32 = undefined;
var x291: u1 = undefined;
addcarryxU32(&x290, &x291, x289, x239, x273);
const x292 = (cast(u32, x291) + cast(u32, x240));
var x293: u32 = undefined;
var x294: u32 = undefined;
mulxU32(&x293, &x294, x3, (arg2[7]));
var x295: u32 = undefined;
var x296: u32 = undefined;
mulxU32(&x295, &x296, x3, (arg2[6]));
var x297: u32 = undefined;
var x298: u32 = undefined;
mulxU32(&x297, &x298, x3, (arg2[5]));
var x299: u32 = undefined;
var x300: u32 = undefined;
mulxU32(&x299, &x300, x3, (arg2[4]));
var x301: u32 = undefined;
var x302: u32 = undefined;
mulxU32(&x301, &x302, x3, (arg2[3]));
var x303: u32 = undefined;
var x304: u32 = undefined;
mulxU32(&x303, &x304, x3, (arg2[2]));
var x305: u32 = undefined;
var x306: u32 = undefined;
mulxU32(&x305, &x306, x3, (arg2[1]));
var x307: u32 = undefined;
var x308: u32 = undefined;
mulxU32(&x307, &x308, x3, (arg2[0]));
var x309: u32 = undefined;
var x310: u1 = undefined;
addcarryxU32(&x309, &x310, 0x0, x308, x305);
var x311: u32 = undefined;
var x312: u1 = undefined;
addcarryxU32(&x311, &x312, x310, x306, x303);
var x313: u32 = undefined;
var x314: u1 = undefined;
addcarryxU32(&x313, &x314, x312, x304, x301);
var x315: u32 = undefined;
var x316: u1 = undefined;
addcarryxU32(&x315, &x316, x314, x302, x299);
var x317: u32 = undefined;
var x318: u1 = undefined;
addcarryxU32(&x317, &x318, x316, x300, x297);
var x319: u32 = undefined;
var x320: u1 = undefined;
addcarryxU32(&x319, &x320, x318, x298, x295);
var x321: u32 = undefined;
var x322: u1 = undefined;
addcarryxU32(&x321, &x322, x320, x296, x293);
const x323 = (cast(u32, x322) + x294);
var x324: u32 = undefined;
var x325: u1 = undefined;
addcarryxU32(&x324, &x325, 0x0, x276, x307);
var x326: u32 = undefined;
var x327: u1 = undefined;
addcarryxU32(&x326, &x327, x325, x278, x309);
var x328: u32 = undefined;
var x329: u1 = undefined;
addcarryxU32(&x328, &x329, x327, x280, x311);
var x330: u32 = undefined;
var x331: u1 = undefined;
addcarryxU32(&x330, &x331, x329, x282, x313);
var x332: u32 = undefined;
var x333: u1 = undefined;
addcarryxU32(&x332, &x333, x331, x284, x315);
var x334: u32 = undefined;
var x335: u1 = undefined;
addcarryxU32(&x334, &x335, x333, x286, x317);
var x336: u32 = undefined;
var x337: u1 = undefined;
addcarryxU32(&x336, &x337, x335, x288, x319);
var x338: u32 = undefined;
var x339: u1 = undefined;
addcarryxU32(&x338, &x339, x337, x290, x321);
var x340: u32 = undefined;
var x341: u1 = undefined;
addcarryxU32(&x340, &x341, x339, x292, x323);
var x342: u32 = undefined;
var x343: u32 = undefined;
mulxU32(&x342, &x343, x324, 0xd2253531);
var x344: u32 = undefined;
var x345: u32 = undefined;
mulxU32(&x344, &x345, x342, 0xffffffff);
var x346: u32 = undefined;
var x347: u32 = undefined;
mulxU32(&x346, &x347, x342, 0xffffffff);
var x348: u32 = undefined;
var x349: u32 = undefined;
mulxU32(&x348, &x349, x342, 0xffffffff);
var x350: u32 = undefined;
var x351: u32 = undefined;
mulxU32(&x350, &x351, x342, 0xffffffff);
var x352: u32 = undefined;
var x353: u32 = undefined;
mulxU32(&x352, &x353, x342, 0xffffffff);
var x354: u32 = undefined;
var x355: u32 = undefined;
mulxU32(&x354, &x355, x342, 0xffffffff);
var x356: u32 = undefined;
var x357: u32 = undefined;
mulxU32(&x356, &x357, x342, 0xfffffffe);
var x358: u32 = undefined;
var x359: u32 = undefined;
mulxU32(&x358, &x359, x342, 0xfffffc2f);
var x360: u32 = undefined;
var x361: u1 = undefined;
addcarryxU32(&x360, &x361, 0x0, x359, x356);
var x362: u32 = undefined;
var x363: u1 = undefined;
addcarryxU32(&x362, &x363, x361, x357, x354);
var x364: u32 = undefined;
var x365: u1 = undefined;
addcarryxU32(&x364, &x365, x363, x355, x352);
var x366: u32 = undefined;
var x367: u1 = undefined;
addcarryxU32(&x366, &x367, x365, x353, x350);
var x368: u32 = undefined;
var x369: u1 = undefined;
addcarryxU32(&x368, &x369, x367, x351, x348);
var x370: u32 = undefined;
var x371: u1 = undefined;
addcarryxU32(&x370, &x371, x369, x349, x346);
var x372: u32 = undefined;
var x373: u1 = undefined;
addcarryxU32(&x372, &x373, x371, x347, x344);
const x374 = (cast(u32, x373) + x345);
var x375: u32 = undefined;
var x376: u1 = undefined;
addcarryxU32(&x375, &x376, 0x0, x324, x358);
var x377: u32 = undefined;
var x378: u1 = undefined;
addcarryxU32(&x377, &x378, x376, x326, x360);
var x379: u32 = undefined;
var x380: u1 = undefined;
addcarryxU32(&x379, &x380, x378, x328, x362);
var x381: u32 = undefined;
var x382: u1 = undefined;
addcarryxU32(&x381, &x382, x380, x330, x364);
var x383: u32 = undefined;
var x384: u1 = undefined;
addcarryxU32(&x383, &x384, x382, x332, x366);
var x385: u32 = undefined;
var x386: u1 = undefined;
addcarryxU32(&x385, &x386, x384, x334, x368);
var x387: u32 = undefined;
var x388: u1 = undefined;
addcarryxU32(&x387, &x388, x386, x336, x370);
var x389: u32 = undefined;
var x390: u1 = undefined;
addcarryxU32(&x389, &x390, x388, x338, x372);
var x391: u32 = undefined;
var x392: u1 = undefined;
addcarryxU32(&x391, &x392, x390, x340, x374);
const x393 = (cast(u32, x392) + cast(u32, x341));
var x394: u32 = undefined;
var x395: u32 = undefined;
mulxU32(&x394, &x395, x4, (arg2[7]));
var x396: u32 = undefined;
var x397: u32 = undefined;
mulxU32(&x396, &x397, x4, (arg2[6]));
var x398: u32 = undefined;
var x399: u32 = undefined;
mulxU32(&x398, &x399, x4, (arg2[5]));
var x400: u32 = undefined;
var x401: u32 = undefined;
mulxU32(&x400, &x401, x4, (arg2[4]));
var x402: u32 = undefined;
var x403: u32 = undefined;
mulxU32(&x402, &x403, x4, (arg2[3]));
var x404: u32 = undefined;
var x405: u32 = undefined;
mulxU32(&x404, &x405, x4, (arg2[2]));
var x406: u32 = undefined;
var x407: u32 = undefined;
mulxU32(&x406, &x407, x4, (arg2[1]));
var x408: u32 = undefined;
var x409: u32 = undefined;
mulxU32(&x408, &x409, x4, (arg2[0]));
var x410: u32 = undefined;
var x411: u1 = undefined;
addcarryxU32(&x410, &x411, 0x0, x409, x406);
var x412: u32 = undefined;
var x413: u1 = undefined;
addcarryxU32(&x412, &x413, x411, x407, x404);
var x414: u32 = undefined;
var x415: u1 = undefined;
addcarryxU32(&x414, &x415, x413, x405, x402);
var x416: u32 = undefined;
var x417: u1 = undefined;
addcarryxU32(&x416, &x417, x415, x403, x400);
var x418: u32 = undefined;
var x419: u1 = undefined;
addcarryxU32(&x418, &x419, x417, x401, x398);
var x420: u32 = undefined;
var x421: u1 = undefined;
addcarryxU32(&x420, &x421, x419, x399, x396);
var x422: u32 = undefined;
var x423: u1 = undefined;
addcarryxU32(&x422, &x423, x421, x397, x394);
const x424 = (cast(u32, x423) + x395);
var x425: u32 = undefined;
var x426: u1 = undefined;
addcarryxU32(&x425, &x426, 0x0, x377, x408);
var x427: u32 = undefined;
var x428: u1 = undefined;
addcarryxU32(&x427, &x428, x426, x379, x410);
var x429: u32 = undefined;
var x430: u1 = undefined;
addcarryxU32(&x429, &x430, x428, x381, x412);
var x431: u32 = undefined;
var x432: u1 = undefined;
addcarryxU32(&x431, &x432, x430, x383, x414);
var x433: u32 = undefined;
var x434: u1 = undefined;
addcarryxU32(&x433, &x434, x432, x385, x416);
var x435: u32 = undefined;
var x436: u1 = undefined;
addcarryxU32(&x435, &x436, x434, x387, x418);
var x437: u32 = undefined;
var x438: u1 = undefined;
addcarryxU32(&x437, &x438, x436, x389, x420);
var x439: u32 = undefined;
var x440: u1 = undefined;
addcarryxU32(&x439, &x440, x438, x391, x422);
var x441: u32 = undefined;
var x442: u1 = undefined;
addcarryxU32(&x441, &x442, x440, x393, x424);
var x443: u32 = undefined;
var x444: u32 = undefined;
mulxU32(&x443, &x444, x425, 0xd2253531);
var x445: u32 = undefined;
var x446: u32 = undefined;
mulxU32(&x445, &x446, x443, 0xffffffff);
var x447: u32 = undefined;
var x448: u32 = undefined;
mulxU32(&x447, &x448, x443, 0xffffffff);
var x449: u32 = undefined;
var x450: u32 = undefined;
mulxU32(&x449, &x450, x443, 0xffffffff);
var x451: u32 = undefined;
var x452: u32 = undefined;
mulxU32(&x451, &x452, x443, 0xffffffff);
var x453: u32 = undefined;
var x454: u32 = undefined;
mulxU32(&x453, &x454, x443, 0xffffffff);
var x455: u32 = undefined;
var x456: u32 = undefined;
mulxU32(&x455, &x456, x443, 0xffffffff);
var x457: u32 = undefined;
var x458: u32 = undefined;
mulxU32(&x457, &x458, x443, 0xfffffffe);
var x459: u32 = undefined;
var x460: u32 = undefined;
mulxU32(&x459, &x460, x443, 0xfffffc2f);
var x461: u32 = undefined;
var x462: u1 = undefined;
addcarryxU32(&x461, &x462, 0x0, x460, x457);
var x463: u32 = undefined;
var x464: u1 = undefined;
addcarryxU32(&x463, &x464, x462, x458, x455);
var x465: u32 = undefined;
var x466: u1 = undefined;
addcarryxU32(&x465, &x466, x464, x456, x453);
var x467: u32 = undefined;
var x468: u1 = undefined;
addcarryxU32(&x467, &x468, x466, x454, x451);
var x469: u32 = undefined;
var x470: u1 = undefined;
addcarryxU32(&x469, &x470, x468, x452, x449);
var x471: u32 = undefined;
var x472: u1 = undefined;
addcarryxU32(&x471, &x472, x470, x450, x447);
var x473: u32 = undefined;
var x474: u1 = undefined;
addcarryxU32(&x473, &x474, x472, x448, x445);
const x475 = (cast(u32, x474) + x446);
var x476: u32 = undefined;
var x477: u1 = undefined;
addcarryxU32(&x476, &x477, 0x0, x425, x459);
var x478: u32 = undefined;
var x479: u1 = undefined;
addcarryxU32(&x478, &x479, x477, x427, x461);
var x480: u32 = undefined;
var x481: u1 = undefined;
addcarryxU32(&x480, &x481, x479, x429, x463);
var x482: u32 = undefined;
var x483: u1 = undefined;
addcarryxU32(&x482, &x483, x481, x431, x465);
var x484: u32 = undefined;
var x485: u1 = undefined;
addcarryxU32(&x484, &x485, x483, x433, x467);
var x486: u32 = undefined;
var x487: u1 = undefined;
addcarryxU32(&x486, &x487, x485, x435, x469);
var x488: u32 = undefined;
var x489: u1 = undefined;
addcarryxU32(&x488, &x489, x487, x437, x471);
var x490: u32 = undefined;
var x491: u1 = undefined;
addcarryxU32(&x490, &x491, x489, x439, x473);
var x492: u32 = undefined;
var x493: u1 = undefined;
addcarryxU32(&x492, &x493, x491, x441, x475);
const x494 = (cast(u32, x493) + cast(u32, x442));
var x495: u32 = undefined;
var x496: u32 = undefined;
mulxU32(&x495, &x496, x5, (arg2[7]));
var x497: u32 = undefined;
var x498: u32 = undefined;
mulxU32(&x497, &x498, x5, (arg2[6]));
var x499: u32 = undefined;
var x500: u32 = undefined;
mulxU32(&x499, &x500, x5, (arg2[5]));
var x501: u32 = undefined;
var x502: u32 = undefined;
mulxU32(&x501, &x502, x5, (arg2[4]));
var x503: u32 = undefined;
var x504: u32 = undefined;
mulxU32(&x503, &x504, x5, (arg2[3]));
var x505: u32 = undefined;
var x506: u32 = undefined;
mulxU32(&x505, &x506, x5, (arg2[2]));
var x507: u32 = undefined;
var x508: u32 = undefined;
mulxU32(&x507, &x508, x5, (arg2[1]));
var x509: u32 = undefined;
var x510: u32 = undefined;
mulxU32(&x509, &x510, x5, (arg2[0]));
var x511: u32 = undefined;
var x512: u1 = undefined;
addcarryxU32(&x511, &x512, 0x0, x510, x507);
var x513: u32 = undefined;
var x514: u1 = undefined;
addcarryxU32(&x513, &x514, x512, x508, x505);
var x515: u32 = undefined;
var x516: u1 = undefined;
addcarryxU32(&x515, &x516, x514, x506, x503);
var x517: u32 = undefined;
var x518: u1 = undefined;
addcarryxU32(&x517, &x518, x516, x504, x501);
var x519: u32 = undefined;
var x520: u1 = undefined;
addcarryxU32(&x519, &x520, x518, x502, x499);
var x521: u32 = undefined;
var x522: u1 = undefined;
addcarryxU32(&x521, &x522, x520, x500, x497);
var x523: u32 = undefined;
var x524: u1 = undefined;
addcarryxU32(&x523, &x524, x522, x498, x495);
const x525 = (cast(u32, x524) + x496);
var x526: u32 = undefined;
var x527: u1 = undefined;
addcarryxU32(&x526, &x527, 0x0, x478, x509);
var x528: u32 = undefined;
var x529: u1 = undefined;
addcarryxU32(&x528, &x529, x527, x480, x511);
var x530: u32 = undefined;
var x531: u1 = undefined;
addcarryxU32(&x530, &x531, x529, x482, x513);
var x532: u32 = undefined;
var x533: u1 = undefined;
addcarryxU32(&x532, &x533, x531, x484, x515);
var x534: u32 = undefined;
var x535: u1 = undefined;
addcarryxU32(&x534, &x535, x533, x486, x517);
var x536: u32 = undefined;
var x537: u1 = undefined;
addcarryxU32(&x536, &x537, x535, x488, x519);
var x538: u32 = undefined;
var x539: u1 = undefined;
addcarryxU32(&x538, &x539, x537, x490, x521);
var x540: u32 = undefined;
var x541: u1 = undefined;
addcarryxU32(&x540, &x541, x539, x492, x523);
var x542: u32 = undefined;
var x543: u1 = undefined;
addcarryxU32(&x542, &x543, x541, x494, x525);
var x544: u32 = undefined;
var x545: u32 = undefined;
mulxU32(&x544, &x545, x526, 0xd2253531);
var x546: u32 = undefined;
var x547: u32 = undefined;
mulxU32(&x546, &x547, x544, 0xffffffff);
var x548: u32 = undefined;
var x549: u32 = undefined;
mulxU32(&x548, &x549, x544, 0xffffffff);
var x550: u32 = undefined;
var x551: u32 = undefined;
mulxU32(&x550, &x551, x544, 0xffffffff);
var x552: u32 = undefined;
var x553: u32 = undefined;
mulxU32(&x552, &x553, x544, 0xffffffff);
var x554: u32 = undefined;
var x555: u32 = undefined;
mulxU32(&x554, &x555, x544, 0xffffffff);
var x556: u32 = undefined;
var x557: u32 = undefined;
mulxU32(&x556, &x557, x544, 0xffffffff);
var x558: u32 = undefined;
var x559: u32 = undefined;
mulxU32(&x558, &x559, x544, 0xfffffffe);
var x560: u32 = undefined;
var x561: u32 = undefined;
mulxU32(&x560, &x561, x544, 0xfffffc2f);
var x562: u32 = undefined;
var x563: u1 = undefined;
addcarryxU32(&x562, &x563, 0x0, x561, x558);
var x564: u32 = undefined;
var x565: u1 = undefined;
addcarryxU32(&x564, &x565, x563, x559, x556);
var x566: u32 = undefined;
var x567: u1 = undefined;
addcarryxU32(&x566, &x567, x565, x557, x554);
var x568: u32 = undefined;
var x569: u1 = undefined;
addcarryxU32(&x568, &x569, x567, x555, x552);
var x570: u32 = undefined;
var x571: u1 = undefined;
addcarryxU32(&x570, &x571, x569, x553, x550);
var x572: u32 = undefined;
var x573: u1 = undefined;
addcarryxU32(&x572, &x573, x571, x551, x548);
var x574: u32 = undefined;
var x575: u1 = undefined;
addcarryxU32(&x574, &x575, x573, x549, x546);
const x576 = (cast(u32, x575) + x547);
var x577: u32 = undefined;
var x578: u1 = undefined;
addcarryxU32(&x577, &x578, 0x0, x526, x560);
var x579: u32 = undefined;
var x580: u1 = undefined;
addcarryxU32(&x579, &x580, x578, x528, x562);
var x581: u32 = undefined;
var x582: u1 = undefined;
addcarryxU32(&x581, &x582, x580, x530, x564);
var x583: u32 = undefined;
var x584: u1 = undefined;
addcarryxU32(&x583, &x584, x582, x532, x566);
var x585: u32 = undefined;
var x586: u1 = undefined;
addcarryxU32(&x585, &x586, x584, x534, x568);
var x587: u32 = undefined;
var x588: u1 = undefined;
addcarryxU32(&x587, &x588, x586, x536, x570);
var x589: u32 = undefined;
var x590: u1 = undefined;
addcarryxU32(&x589, &x590, x588, x538, x572);
var x591: u32 = undefined;
var x592: u1 = undefined;
addcarryxU32(&x591, &x592, x590, x540, x574);
var x593: u32 = undefined;
var x594: u1 = undefined;
addcarryxU32(&x593, &x594, x592, x542, x576);
const x595 = (cast(u32, x594) + cast(u32, x543));
var x596: u32 = undefined;
var x597: u32 = undefined;
mulxU32(&x596, &x597, x6, (arg2[7]));
var x598: u32 = undefined;
var x599: u32 = undefined;
mulxU32(&x598, &x599, x6, (arg2[6]));
var x600: u32 = undefined;
var x601: u32 = undefined;
mulxU32(&x600, &x601, x6, (arg2[5]));
var x602: u32 = undefined;
var x603: u32 = undefined;
mulxU32(&x602, &x603, x6, (arg2[4]));
var x604: u32 = undefined;
var x605: u32 = undefined;
mulxU32(&x604, &x605, x6, (arg2[3]));
var x606: u32 = undefined;
var x607: u32 = undefined;
mulxU32(&x606, &x607, x6, (arg2[2]));
var x608: u32 = undefined;
var x609: u32 = undefined;
mulxU32(&x608, &x609, x6, (arg2[1]));
var x610: u32 = undefined;
var x611: u32 = undefined;
mulxU32(&x610, &x611, x6, (arg2[0]));
var x612: u32 = undefined;
var x613: u1 = undefined;
addcarryxU32(&x612, &x613, 0x0, x611, x608);
var x614: u32 = undefined;
var x615: u1 = undefined;
addcarryxU32(&x614, &x615, x613, x609, x606);
var x616: u32 = undefined;
var x617: u1 = undefined;
addcarryxU32(&x616, &x617, x615, x607, x604);
var x618: u32 = undefined;
var x619: u1 = undefined;
addcarryxU32(&x618, &x619, x617, x605, x602);
var x620: u32 = undefined;
var x621: u1 = undefined;
addcarryxU32(&x620, &x621, x619, x603, x600);
var x622: u32 = undefined;
var x623: u1 = undefined;
addcarryxU32(&x622, &x623, x621, x601, x598);
var x624: u32 = undefined;
var x625: u1 = undefined;
addcarryxU32(&x624, &x625, x623, x599, x596);
const x626 = (cast(u32, x625) + x597);
var x627: u32 = undefined;
var x628: u1 = undefined;
addcarryxU32(&x627, &x628, 0x0, x579, x610);
var x629: u32 = undefined;
var x630: u1 = undefined;
addcarryxU32(&x629, &x630, x628, x581, x612);
var x631: u32 = undefined;
var x632: u1 = undefined;
addcarryxU32(&x631, &x632, x630, x583, x614);
var x633: u32 = undefined;
var x634: u1 = undefined;
addcarryxU32(&x633, &x634, x632, x585, x616);
var x635: u32 = undefined;
var x636: u1 = undefined;
addcarryxU32(&x635, &x636, x634, x587, x618);
var x637: u32 = undefined;
var x638: u1 = undefined;
addcarryxU32(&x637, &x638, x636, x589, x620);
var x639: u32 = undefined;
var x640: u1 = undefined;
addcarryxU32(&x639, &x640, x638, x591, x622);
var x641: u32 = undefined;
var x642: u1 = undefined;
addcarryxU32(&x641, &x642, x640, x593, x624);
var x643: u32 = undefined;
var x644: u1 = undefined;
addcarryxU32(&x643, &x644, x642, x595, x626);
var x645: u32 = undefined;
var x646: u32 = undefined;
mulxU32(&x645, &x646, x627, 0xd2253531);
var x647: u32 = undefined;
var x648: u32 = undefined;
mulxU32(&x647, &x648, x645, 0xffffffff);
var x649: u32 = undefined;
var x650: u32 = undefined;
mulxU32(&x649, &x650, x645, 0xffffffff);
var x651: u32 = undefined;
var x652: u32 = undefined;
mulxU32(&x651, &x652, x645, 0xffffffff);
var x653: u32 = undefined;
var x654: u32 = undefined;
mulxU32(&x653, &x654, x645, 0xffffffff);
var x655: u32 = undefined;
var x656: u32 = undefined;
mulxU32(&x655, &x656, x645, 0xffffffff);
var x657: u32 = undefined;
var x658: u32 = undefined;
mulxU32(&x657, &x658, x645, 0xffffffff);
var x659: u32 = undefined;
var x660: u32 = undefined;
mulxU32(&x659, &x660, x645, 0xfffffffe);
var x661: u32 = undefined;
var x662: u32 = undefined;
mulxU32(&x661, &x662, x645, 0xfffffc2f);
var x663: u32 = undefined;
var x664: u1 = undefined;
addcarryxU32(&x663, &x664, 0x0, x662, x659);
var x665: u32 = undefined;
var x666: u1 = undefined;
addcarryxU32(&x665, &x666, x664, x660, x657);
var x667: u32 = undefined;
var x668: u1 = undefined;
addcarryxU32(&x667, &x668, x666, x658, x655);
var x669: u32 = undefined;
var x670: u1 = undefined;
addcarryxU32(&x669, &x670, x668, x656, x653);
var x671: u32 = undefined;
var x672: u1 = undefined;
addcarryxU32(&x671, &x672, x670, x654, x651);
var x673: u32 = undefined;
var x674: u1 = undefined;
addcarryxU32(&x673, &x674, x672, x652, x649);
var x675: u32 = undefined;
var x676: u1 = undefined;
addcarryxU32(&x675, &x676, x674, x650, x647);
const x677 = (cast(u32, x676) + x648);
var x678: u32 = undefined;
var x679: u1 = undefined;
addcarryxU32(&x678, &x679, 0x0, x627, x661);
var x680: u32 = undefined;
var x681: u1 = undefined;
addcarryxU32(&x680, &x681, x679, x629, x663);
var x682: u32 = undefined;
var x683: u1 = undefined;
addcarryxU32(&x682, &x683, x681, x631, x665);
var x684: u32 = undefined;
var x685: u1 = undefined;
addcarryxU32(&x684, &x685, x683, x633, x667);
var x686: u32 = undefined;
var x687: u1 = undefined;
addcarryxU32(&x686, &x687, x685, x635, x669);
var x688: u32 = undefined;
var x689: u1 = undefined;
addcarryxU32(&x688, &x689, x687, x637, x671);
var x690: u32 = undefined;
var x691: u1 = undefined;
addcarryxU32(&x690, &x691, x689, x639, x673);
var x692: u32 = undefined;
var x693: u1 = undefined;
addcarryxU32(&x692, &x693, x691, x641, x675);
var x694: u32 = undefined;
var x695: u1 = undefined;
addcarryxU32(&x694, &x695, x693, x643, x677);
const x696 = (cast(u32, x695) + cast(u32, x644));
var x697: u32 = undefined;
var x698: u32 = undefined;
mulxU32(&x697, &x698, x7, (arg2[7]));
var x699: u32 = undefined;
var x700: u32 = undefined;
mulxU32(&x699, &x700, x7, (arg2[6]));
var x701: u32 = undefined;
var x702: u32 = undefined;
mulxU32(&x701, &x702, x7, (arg2[5]));
var x703: u32 = undefined;
var x704: u32 = undefined;
mulxU32(&x703, &x704, x7, (arg2[4]));
var x705: u32 = undefined;
var x706: u32 = undefined;
mulxU32(&x705, &x706, x7, (arg2[3]));
var x707: u32 = undefined;
var x708: u32 = undefined;
mulxU32(&x707, &x708, x7, (arg2[2]));
var x709: u32 = undefined;
var x710: u32 = undefined;
mulxU32(&x709, &x710, x7, (arg2[1]));
var x711: u32 = undefined;
var x712: u32 = undefined;
mulxU32(&x711, &x712, x7, (arg2[0]));
var x713: u32 = undefined;
var x714: u1 = undefined;
addcarryxU32(&x713, &x714, 0x0, x712, x709);
var x715: u32 = undefined;
var x716: u1 = undefined;
addcarryxU32(&x715, &x716, x714, x710, x707);
var x717: u32 = undefined;
var x718: u1 = undefined;
addcarryxU32(&x717, &x718, x716, x708, x705);
var x719: u32 = undefined;
var x720: u1 = undefined;
addcarryxU32(&x719, &x720, x718, x706, x703);
var x721: u32 = undefined;
var x722: u1 = undefined;
addcarryxU32(&x721, &x722, x720, x704, x701);
var x723: u32 = undefined;
var x724: u1 = undefined;
addcarryxU32(&x723, &x724, x722, x702, x699);
var x725: u32 = undefined;
var x726: u1 = undefined;
addcarryxU32(&x725, &x726, x724, x700, x697);
const x727 = (cast(u32, x726) + x698);
var x728: u32 = undefined;
var x729: u1 = undefined;
addcarryxU32(&x728, &x729, 0x0, x680, x711);
var x730: u32 = undefined;
var x731: u1 = undefined;
addcarryxU32(&x730, &x731, x729, x682, x713);
var x732: u32 = undefined;
var x733: u1 = undefined;
addcarryxU32(&x732, &x733, x731, x684, x715);
var x734: u32 = undefined;
var x735: u1 = undefined;
addcarryxU32(&x734, &x735, x733, x686, x717);
var x736: u32 = undefined;
var x737: u1 = undefined;
addcarryxU32(&x736, &x737, x735, x688, x719);
var x738: u32 = undefined;
var x739: u1 = undefined;
addcarryxU32(&x738, &x739, x737, x690, x721);
var x740: u32 = undefined;
var x741: u1 = undefined;
addcarryxU32(&x740, &x741, x739, x692, x723);
var x742: u32 = undefined;
var x743: u1 = undefined;
addcarryxU32(&x742, &x743, x741, x694, x725);
var x744: u32 = undefined;
var x745: u1 = undefined;
addcarryxU32(&x744, &x745, x743, x696, x727);
var x746: u32 = undefined;
var x747: u32 = undefined;
mulxU32(&x746, &x747, x728, 0xd2253531);
var x748: u32 = undefined;
var x749: u32 = undefined;
mulxU32(&x748, &x749, x746, 0xffffffff);
var x750: u32 = undefined;
var x751: u32 = undefined;
mulxU32(&x750, &x751, x746, 0xffffffff);
var x752: u32 = undefined;
var x753: u32 = undefined;
mulxU32(&x752, &x753, x746, 0xffffffff);
var x754: u32 = undefined;
var x755: u32 = undefined;
mulxU32(&x754, &x755, x746, 0xffffffff);
var x756: u32 = undefined;
var x757: u32 = undefined;
mulxU32(&x756, &x757, x746, 0xffffffff);
var x758: u32 = undefined;
var x759: u32 = undefined;
mulxU32(&x758, &x759, x746, 0xffffffff);
var x760: u32 = undefined;
var x761: u32 = undefined;
mulxU32(&x760, &x761, x746, 0xfffffffe);
var x762: u32 = undefined;
var x763: u32 = undefined;
mulxU32(&x762, &x763, x746, 0xfffffc2f);
var x764: u32 = undefined;
var x765: u1 = undefined;
addcarryxU32(&x764, &x765, 0x0, x763, x760);
var x766: u32 = undefined;
var x767: u1 = undefined;
addcarryxU32(&x766, &x767, x765, x761, x758);
var x768: u32 = undefined;
var x769: u1 = undefined;
addcarryxU32(&x768, &x769, x767, x759, x756);
var x770: u32 = undefined;
var x771: u1 = undefined;
addcarryxU32(&x770, &x771, x769, x757, x754);
var x772: u32 = undefined;
var x773: u1 = undefined;
addcarryxU32(&x772, &x773, x771, x755, x752);
var x774: u32 = undefined;
var x775: u1 = undefined;
addcarryxU32(&x774, &x775, x773, x753, x750);
var x776: u32 = undefined;
var x777: u1 = undefined;
addcarryxU32(&x776, &x777, x775, x751, x748);
const x778 = (cast(u32, x777) + x749);
var x779: u32 = undefined;
var x780: u1 = undefined;
addcarryxU32(&x779, &x780, 0x0, x728, x762);
var x781: u32 = undefined;
var x782: u1 = undefined;
addcarryxU32(&x781, &x782, x780, x730, x764);
var x783: u32 = undefined;
var x784: u1 = undefined;
addcarryxU32(&x783, &x784, x782, x732, x766);
var x785: u32 = undefined;
var x786: u1 = undefined;
addcarryxU32(&x785, &x786, x784, x734, x768);
var x787: u32 = undefined;
var x788: u1 = undefined;
addcarryxU32(&x787, &x788, x786, x736, x770);
var x789: u32 = undefined;
var x790: u1 = undefined;
addcarryxU32(&x789, &x790, x788, x738, x772);
var x791: u32 = undefined;
var x792: u1 = undefined;
addcarryxU32(&x791, &x792, x790, x740, x774);
var x793: u32 = undefined;
var x794: u1 = undefined;
addcarryxU32(&x793, &x794, x792, x742, x776);
var x795: u32 = undefined;
var x796: u1 = undefined;
addcarryxU32(&x795, &x796, x794, x744, x778);
const x797 = (cast(u32, x796) + cast(u32, x745));
var x798: u32 = undefined;
var x799: u1 = undefined;
subborrowxU32(&x798, &x799, 0x0, x781, 0xfffffc2f);
var x800: u32 = undefined;
var x801: u1 = undefined;
subborrowxU32(&x800, &x801, x799, x783, 0xfffffffe);
var x802: u32 = undefined;
var x803: u1 = undefined;
subborrowxU32(&x802, &x803, x801, x785, 0xffffffff);
var x804: u32 = undefined;
var x805: u1 = undefined;
subborrowxU32(&x804, &x805, x803, x787, 0xffffffff);
var x806: u32 = undefined;
var x807: u1 = undefined;
subborrowxU32(&x806, &x807, x805, x789, 0xffffffff);
var x808: u32 = undefined;
var x809: u1 = undefined;
subborrowxU32(&x808, &x809, x807, x791, 0xffffffff);
var x810: u32 = undefined;
var x811: u1 = undefined;
subborrowxU32(&x810, &x811, x809, x793, 0xffffffff);
var x812: u32 = undefined;
var x813: u1 = undefined;
subborrowxU32(&x812, &x813, x811, x795, 0xffffffff);
var x814: u32 = undefined;
var x815: u1 = undefined;
subborrowxU32(&x814, &x815, x813, x797, cast(u32, 0x0));
var x816: u32 = undefined;
cmovznzU32(&x816, x815, x798, x781);
var x817: u32 = undefined;
cmovznzU32(&x817, x815, x800, x783);
var x818: u32 = undefined;
cmovznzU32(&x818, x815, x802, x785);
var x819: u32 = undefined;
cmovznzU32(&x819, x815, x804, x787);
var x820: u32 = undefined;
cmovznzU32(&x820, x815, x806, x789);
var x821: u32 = undefined;
cmovznzU32(&x821, x815, x808, x791);
var x822: u32 = undefined;
cmovznzU32(&x822, x815, x810, x793);
var x823: u32 = undefined;
cmovznzU32(&x823, x815, x812, x795);
out1[0] = x816;
out1[1] = x817;
out1[2] = x818;
out1[3] = x819;
out1[4] = x820;
out1[5] = x821;
out1[6] = x822;
out1[7] = x823;
}
/// 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[6]);
const x7 = (arg1[7]);
const x8 = (arg1[0]);
var x9: u32 = undefined;
var x10: u32 = undefined;
mulxU32(&x9, &x10, x8, (arg1[7]));
var x11: u32 = undefined;
var x12: u32 = undefined;
mulxU32(&x11, &x12, x8, (arg1[6]));
var x13: u32 = undefined;
var x14: u32 = undefined;
mulxU32(&x13, &x14, x8, (arg1[5]));
var x15: u32 = undefined;
var x16: u32 = undefined;
mulxU32(&x15, &x16, x8, (arg1[4]));
var x17: u32 = undefined;
var x18: u32 = undefined;
mulxU32(&x17, &x18, x8, (arg1[3]));
var x19: u32 = undefined;
var x20: u32 = undefined;
mulxU32(&x19, &x20, x8, (arg1[2]));
var x21: u32 = undefined;
var x22: u32 = undefined;
mulxU32(&x21, &x22, x8, (arg1[1]));
var x23: u32 = undefined;
var x24: u32 = undefined;
mulxU32(&x23, &x24, x8, (arg1[0]));
var x25: u32 = undefined;
var x26: u1 = undefined;
addcarryxU32(&x25, &x26, 0x0, x24, x21);
var x27: u32 = undefined;
var x28: u1 = undefined;
addcarryxU32(&x27, &x28, x26, x22, x19);
var x29: u32 = undefined;
var x30: u1 = undefined;
addcarryxU32(&x29, &x30, x28, x20, x17);
var x31: u32 = undefined;
var x32: u1 = undefined;
addcarryxU32(&x31, &x32, x30, x18, x15);
var x33: u32 = undefined;
var x34: u1 = undefined;
addcarryxU32(&x33, &x34, x32, x16, x13);
var x35: u32 = undefined;
var x36: u1 = undefined;
addcarryxU32(&x35, &x36, x34, x14, x11);
var x37: u32 = undefined;
var x38: u1 = undefined;
addcarryxU32(&x37, &x38, x36, x12, x9);
const x39 = (cast(u32, x38) + x10);
var x40: u32 = undefined;
var x41: u32 = undefined;
mulxU32(&x40, &x41, x23, 0xd2253531);
var x42: u32 = undefined;
var x43: u32 = undefined;
mulxU32(&x42, &x43, x40, 0xffffffff);
var x44: u32 = undefined;
var x45: u32 = undefined;
mulxU32(&x44, &x45, x40, 0xffffffff);
var x46: u32 = undefined;
var x47: u32 = undefined;
mulxU32(&x46, &x47, x40, 0xffffffff);
var x48: u32 = undefined;
var x49: u32 = undefined;
mulxU32(&x48, &x49, x40, 0xffffffff);
var x50: u32 = undefined;
var x51: u32 = undefined;
mulxU32(&x50, &x51, x40, 0xffffffff);
var x52: u32 = undefined;
var x53: u32 = undefined;
mulxU32(&x52, &x53, x40, 0xffffffff);
var x54: u32 = undefined;
var x55: u32 = undefined;
mulxU32(&x54, &x55, x40, 0xfffffffe);
var x56: u32 = undefined;
var x57: u32 = undefined;
mulxU32(&x56, &x57, x40, 0xfffffc2f);
var x58: u32 = undefined;
var x59: u1 = undefined;
addcarryxU32(&x58, &x59, 0x0, x57, x54);
var x60: u32 = undefined;
var x61: u1 = undefined;
addcarryxU32(&x60, &x61, x59, x55, x52);
var x62: u32 = undefined;
var x63: u1 = undefined;
addcarryxU32(&x62, &x63, x61, x53, x50);
var x64: u32 = undefined;
var x65: u1 = undefined;
addcarryxU32(&x64, &x65, x63, x51, x48);
var x66: u32 = undefined;
var x67: u1 = undefined;
addcarryxU32(&x66, &x67, x65, x49, x46);
var x68: u32 = undefined;
var x69: u1 = undefined;
addcarryxU32(&x68, &x69, x67, x47, x44);
var x70: u32 = undefined;
var x71: u1 = undefined;
addcarryxU32(&x70, &x71, x69, x45, x42);
const x72 = (cast(u32, x71) + x43);
var x73: u32 = undefined;
var x74: u1 = undefined;
addcarryxU32(&x73, &x74, 0x0, x23, x56);
var x75: u32 = undefined;
var x76: u1 = undefined;
addcarryxU32(&x75, &x76, x74, x25, x58);
var x77: u32 = undefined;
var x78: u1 = undefined;
addcarryxU32(&x77, &x78, x76, x27, x60);
var x79: u32 = undefined;
var x80: u1 = undefined;
addcarryxU32(&x79, &x80, x78, x29, x62);
var x81: u32 = undefined;
var x82: u1 = undefined;
addcarryxU32(&x81, &x82, x80, x31, x64);
var x83: u32 = undefined;
var x84: u1 = undefined;
addcarryxU32(&x83, &x84, x82, x33, x66);
var x85: u32 = undefined;
var x86: u1 = undefined;
addcarryxU32(&x85, &x86, x84, x35, x68);
var x87: u32 = undefined;
var x88: u1 = undefined;
addcarryxU32(&x87, &x88, x86, x37, x70);
var x89: u32 = undefined;
var x90: u1 = undefined;
addcarryxU32(&x89, &x90, x88, x39, x72);
var x91: u32 = undefined;
var x92: u32 = undefined;
mulxU32(&x91, &x92, x1, (arg1[7]));
var x93: u32 = undefined;
var x94: u32 = undefined;
mulxU32(&x93, &x94, x1, (arg1[6]));
var x95: u32 = undefined;
var x96: u32 = undefined;
mulxU32(&x95, &x96, x1, (arg1[5]));
var x97: u32 = undefined;
var x98: u32 = undefined;
mulxU32(&x97, &x98, x1, (arg1[4]));
var x99: u32 = undefined;
var x100: u32 = undefined;
mulxU32(&x99, &x100, x1, (arg1[3]));
var x101: u32 = undefined;
var x102: u32 = undefined;
mulxU32(&x101, &x102, x1, (arg1[2]));
var x103: u32 = undefined;
var x104: u32 = undefined;
mulxU32(&x103, &x104, x1, (arg1[1]));
var x105: u32 = undefined;
var x106: u32 = undefined;
mulxU32(&x105, &x106, x1, (arg1[0]));
var x107: u32 = undefined;
var x108: u1 = undefined;
addcarryxU32(&x107, &x108, 0x0, x106, x103);
var x109: u32 = undefined;
var x110: u1 = undefined;
addcarryxU32(&x109, &x110, x108, x104, x101);
var x111: u32 = undefined;
var x112: u1 = undefined;
addcarryxU32(&x111, &x112, x110, x102, x99);
var x113: u32 = undefined;
var x114: u1 = undefined;
addcarryxU32(&x113, &x114, x112, x100, x97);
var x115: u32 = undefined;
var x116: u1 = undefined;
addcarryxU32(&x115, &x116, x114, x98, x95);
var x117: u32 = undefined;
var x118: u1 = undefined;
addcarryxU32(&x117, &x118, x116, x96, x93);
var x119: u32 = undefined;
var x120: u1 = undefined;
addcarryxU32(&x119, &x120, x118, x94, x91);
const x121 = (cast(u32, x120) + x92);
var x122: u32 = undefined;
var x123: u1 = undefined;
addcarryxU32(&x122, &x123, 0x0, x75, x105);
var x124: u32 = undefined;
var x125: u1 = undefined;
addcarryxU32(&x124, &x125, x123, x77, x107);
var x126: u32 = undefined;
var x127: u1 = undefined;
addcarryxU32(&x126, &x127, x125, x79, x109);
var x128: u32 = undefined;
var x129: u1 = undefined;
addcarryxU32(&x128, &x129, x127, x81, x111);
var x130: u32 = undefined;
var x131: u1 = undefined;
addcarryxU32(&x130, &x131, x129, x83, x113);
var x132: u32 = undefined;
var x133: u1 = undefined;
addcarryxU32(&x132, &x133, x131, x85, x115);
var x134: u32 = undefined;
var x135: u1 = undefined;
addcarryxU32(&x134, &x135, x133, x87, x117);
var x136: u32 = undefined;
var x137: u1 = undefined;
addcarryxU32(&x136, &x137, x135, x89, x119);
var x138: u32 = undefined;
var x139: u1 = undefined;
addcarryxU32(&x138, &x139, x137, cast(u32, x90), x121);
var x140: u32 = undefined;
var x141: u32 = undefined;
mulxU32(&x140, &x141, x122, 0xd2253531);
var x142: u32 = undefined;
var x143: u32 = undefined;
mulxU32(&x142, &x143, x140, 0xffffffff);
var x144: u32 = undefined;
var x145: u32 = undefined;
mulxU32(&x144, &x145, x140, 0xffffffff);
var x146: u32 = undefined;
var x147: u32 = undefined;
mulxU32(&x146, &x147, x140, 0xffffffff);
var x148: u32 = undefined;
var x149: u32 = undefined;
mulxU32(&x148, &x149, x140, 0xffffffff);
var x150: u32 = undefined;
var x151: u32 = undefined;
mulxU32(&x150, &x151, x140, 0xffffffff);
var x152: u32 = undefined;
var x153: u32 = undefined;
mulxU32(&x152, &x153, x140, 0xffffffff);
var x154: u32 = undefined;
var x155: u32 = undefined;
mulxU32(&x154, &x155, x140, 0xfffffffe);
var x156: u32 = undefined;
var x157: u32 = undefined;
mulxU32(&x156, &x157, x140, 0xfffffc2f);
var x158: u32 = undefined;
var x159: u1 = undefined;
addcarryxU32(&x158, &x159, 0x0, x157, x154);
var x160: u32 = undefined;
var x161: u1 = undefined;
addcarryxU32(&x160, &x161, x159, x155, x152);
var x162: u32 = undefined;
var x163: u1 = undefined;
addcarryxU32(&x162, &x163, x161, x153, x150);
var x164: u32 = undefined;
var x165: u1 = undefined;
addcarryxU32(&x164, &x165, x163, x151, x148);
var x166: u32 = undefined;
var x167: u1 = undefined;
addcarryxU32(&x166, &x167, x165, x149, x146);
var x168: u32 = undefined;
var x169: u1 = undefined;
addcarryxU32(&x168, &x169, x167, x147, x144);
var x170: u32 = undefined;
var x171: u1 = undefined;
addcarryxU32(&x170, &x171, x169, x145, x142);
const x172 = (cast(u32, x171) + x143);
var x173: u32 = undefined;
var x174: u1 = undefined;
addcarryxU32(&x173, &x174, 0x0, x122, x156);
var x175: u32 = undefined;
var x176: u1 = undefined;
addcarryxU32(&x175, &x176, x174, x124, x158);
var x177: u32 = undefined;
var x178: u1 = undefined;
addcarryxU32(&x177, &x178, x176, x126, x160);
var x179: u32 = undefined;
var x180: u1 = undefined;
addcarryxU32(&x179, &x180, x178, x128, x162);
var x181: u32 = undefined;
var x182: u1 = undefined;
addcarryxU32(&x181, &x182, x180, x130, x164);
var x183: u32 = undefined;
var x184: u1 = undefined;
addcarryxU32(&x183, &x184, x182, x132, x166);
var x185: u32 = undefined;
var x186: u1 = undefined;
addcarryxU32(&x185, &x186, x184, x134, x168);
var x187: u32 = undefined;
var x188: u1 = undefined;
addcarryxU32(&x187, &x188, x186, x136, x170);
var x189: u32 = undefined;
var x190: u1 = undefined;
addcarryxU32(&x189, &x190, x188, x138, x172);
const x191 = (cast(u32, x190) + cast(u32, x139));
var x192: u32 = undefined;
var x193: u32 = undefined;
mulxU32(&x192, &x193, x2, (arg1[7]));
var x194: u32 = undefined;
var x195: u32 = undefined;
mulxU32(&x194, &x195, x2, (arg1[6]));
var x196: u32 = undefined;
var x197: u32 = undefined;
mulxU32(&x196, &x197, x2, (arg1[5]));
var x198: u32 = undefined;
var x199: u32 = undefined;
mulxU32(&x198, &x199, x2, (arg1[4]));
var x200: u32 = undefined;
var x201: u32 = undefined;
mulxU32(&x200, &x201, x2, (arg1[3]));
var x202: u32 = undefined;
var x203: u32 = undefined;
mulxU32(&x202, &x203, x2, (arg1[2]));
var x204: u32 = undefined;
var x205: u32 = undefined;
mulxU32(&x204, &x205, x2, (arg1[1]));
var x206: u32 = undefined;
var x207: u32 = undefined;
mulxU32(&x206, &x207, x2, (arg1[0]));
var x208: u32 = undefined;
var x209: u1 = undefined;
addcarryxU32(&x208, &x209, 0x0, x207, x204);
var x210: u32 = undefined;
var x211: u1 = undefined;
addcarryxU32(&x210, &x211, x209, x205, x202);
var x212: u32 = undefined;
var x213: u1 = undefined;
addcarryxU32(&x212, &x213, x211, x203, x200);
var x214: u32 = undefined;
var x215: u1 = undefined;
addcarryxU32(&x214, &x215, x213, x201, x198);
var x216: u32 = undefined;
var x217: u1 = undefined;
addcarryxU32(&x216, &x217, x215, x199, x196);
var x218: u32 = undefined;
var x219: u1 = undefined;
addcarryxU32(&x218, &x219, x217, x197, x194);
var x220: u32 = undefined;
var x221: u1 = undefined;
addcarryxU32(&x220, &x221, x219, x195, x192);
const x222 = (cast(u32, x221) + x193);
var x223: u32 = undefined;
var x224: u1 = undefined;
addcarryxU32(&x223, &x224, 0x0, x175, x206);
var x225: u32 = undefined;
var x226: u1 = undefined;
addcarryxU32(&x225, &x226, x224, x177, x208);
var x227: u32 = undefined;
var x228: u1 = undefined;
addcarryxU32(&x227, &x228, x226, x179, x210);
var x229: u32 = undefined;
var x230: u1 = undefined;
addcarryxU32(&x229, &x230, x228, x181, x212);
var x231: u32 = undefined;
var x232: u1 = undefined;
addcarryxU32(&x231, &x232, x230, x183, x214);
var x233: u32 = undefined;
var x234: u1 = undefined;
addcarryxU32(&x233, &x234, x232, x185, x216);
var x235: u32 = undefined;
var x236: u1 = undefined;
addcarryxU32(&x235, &x236, x234, x187, x218);
var x237: u32 = undefined;
var x238: u1 = undefined;
addcarryxU32(&x237, &x238, x236, x189, x220);
var x239: u32 = undefined;
var x240: u1 = undefined;
addcarryxU32(&x239, &x240, x238, x191, x222);
var x241: u32 = undefined;
var x242: u32 = undefined;
mulxU32(&x241, &x242, x223, 0xd2253531);
var x243: u32 = undefined;
var x244: u32 = undefined;
mulxU32(&x243, &x244, x241, 0xffffffff);
var x245: u32 = undefined;
var x246: u32 = undefined;
mulxU32(&x245, &x246, x241, 0xffffffff);
var x247: u32 = undefined;
var x248: u32 = undefined;
mulxU32(&x247, &x248, x241, 0xffffffff);
var x249: u32 = undefined;
var x250: u32 = undefined;
mulxU32(&x249, &x250, x241, 0xffffffff);
var x251: u32 = undefined;
var x252: u32 = undefined;
mulxU32(&x251, &x252, x241, 0xffffffff);
var x253: u32 = undefined;
var x254: u32 = undefined;
mulxU32(&x253, &x254, x241, 0xffffffff);
var x255: u32 = undefined;
var x256: u32 = undefined;
mulxU32(&x255, &x256, x241, 0xfffffffe);
var x257: u32 = undefined;
var x258: u32 = undefined;
mulxU32(&x257, &x258, x241, 0xfffffc2f);
var x259: u32 = undefined;
var x260: u1 = undefined;
addcarryxU32(&x259, &x260, 0x0, x258, x255);
var x261: u32 = undefined;
var x262: u1 = undefined;
addcarryxU32(&x261, &x262, x260, x256, x253);
var x263: u32 = undefined;
var x264: u1 = undefined;
addcarryxU32(&x263, &x264, x262, x254, x251);
var x265: u32 = undefined;
var x266: u1 = undefined;
addcarryxU32(&x265, &x266, x264, x252, x249);
var x267: u32 = undefined;
var x268: u1 = undefined;
addcarryxU32(&x267, &x268, x266, x250, x247);
var x269: u32 = undefined;
var x270: u1 = undefined;
addcarryxU32(&x269, &x270, x268, x248, x245);
var x271: u32 = undefined;
var x272: u1 = undefined;
addcarryxU32(&x271, &x272, x270, x246, x243);
const x273 = (cast(u32, x272) + x244);
var x274: u32 = undefined;
var x275: u1 = undefined;
addcarryxU32(&x274, &x275, 0x0, x223, x257);
var x276: u32 = undefined;
var x277: u1 = undefined;
addcarryxU32(&x276, &x277, x275, x225, x259);
var x278: u32 = undefined;
var x279: u1 = undefined;
addcarryxU32(&x278, &x279, x277, x227, x261);
var x280: u32 = undefined;
var x281: u1 = undefined;
addcarryxU32(&x280, &x281, x279, x229, x263);
var x282: u32 = undefined;
var x283: u1 = undefined;
addcarryxU32(&x282, &x283, x281, x231, x265);
var x284: u32 = undefined;
var x285: u1 = undefined;
addcarryxU32(&x284, &x285, x283, x233, x267);
var x286: u32 = undefined;
var x287: u1 = undefined;
addcarryxU32(&x286, &x287, x285, x235, x269);
var x288: u32 = undefined;
var x289: u1 = undefined;
addcarryxU32(&x288, &x289, x287, x237, x271);
var x290: u32 = undefined;
var x291: u1 = undefined;
addcarryxU32(&x290, &x291, x289, x239, x273);
const x292 = (cast(u32, x291) + cast(u32, x240));
var x293: u32 = undefined;
var x294: u32 = undefined;
mulxU32(&x293, &x294, x3, (arg1[7]));
var x295: u32 = undefined;
var x296: u32 = undefined;
mulxU32(&x295, &x296, x3, (arg1[6]));
var x297: u32 = undefined;
var x298: u32 = undefined;
mulxU32(&x297, &x298, x3, (arg1[5]));
var x299: u32 = undefined;
var x300: u32 = undefined;
mulxU32(&x299, &x300, x3, (arg1[4]));
var x301: u32 = undefined;
var x302: u32 = undefined;
mulxU32(&x301, &x302, x3, (arg1[3]));
var x303: u32 = undefined;
var x304: u32 = undefined;
mulxU32(&x303, &x304, x3, (arg1[2]));
var x305: u32 = undefined;
var x306: u32 = undefined;
mulxU32(&x305, &x306, x3, (arg1[1]));
var x307: u32 = undefined;
var x308: u32 = undefined;
mulxU32(&x307, &x308, x3, (arg1[0]));
var x309: u32 = undefined;
var x310: u1 = undefined;
addcarryxU32(&x309, &x310, 0x0, x308, x305);
var x311: u32 = undefined;
var x312: u1 = undefined;
addcarryxU32(&x311, &x312, x310, x306, x303);
var x313: u32 = undefined;
var x314: u1 = undefined;
addcarryxU32(&x313, &x314, x312, x304, x301);
var x315: u32 = undefined;
var x316: u1 = undefined;
addcarryxU32(&x315, &x316, x314, x302, x299);
var x317: u32 = undefined;
var x318: u1 = undefined;
addcarryxU32(&x317, &x318, x316, x300, x297);
var x319: u32 = undefined;
var x320: u1 = undefined;
addcarryxU32(&x319, &x320, x318, x298, x295);
var x321: u32 = undefined;
var x322: u1 = undefined;
addcarryxU32(&x321, &x322, x320, x296, x293);
const x323 = (cast(u32, x322) + x294);
var x324: u32 = undefined;
var x325: u1 = undefined;
addcarryxU32(&x324, &x325, 0x0, x276, x307);
var x326: u32 = undefined;
var x327: u1 = undefined;
addcarryxU32(&x326, &x327, x325, x278, x309);
var x328: u32 = undefined;
var x329: u1 = undefined;
addcarryxU32(&x328, &x329, x327, x280, x311);
var x330: u32 = undefined;
var x331: u1 = undefined;
addcarryxU32(&x330, &x331, x329, x282, x313);
var x332: u32 = undefined;
var x333: u1 = undefined;
addcarryxU32(&x332, &x333, x331, x284, x315);
var x334: u32 = undefined;
var x335: u1 = undefined;
addcarryxU32(&x334, &x335, x333, x286, x317);
var x336: u32 = undefined;
var x337: u1 = undefined;
addcarryxU32(&x336, &x337, x335, x288, x319);
var x338: u32 = undefined;
var x339: u1 = undefined;
addcarryxU32(&x338, &x339, x337, x290, x321);
var x340: u32 = undefined;
var x341: u1 = undefined;
addcarryxU32(&x340, &x341, x339, x292, x323);
var x342: u32 = undefined;
var x343: u32 = undefined;
mulxU32(&x342, &x343, x324, 0xd2253531);
var x344: u32 = undefined;
var x345: u32 = undefined;
mulxU32(&x344, &x345, x342, 0xffffffff);
var x346: u32 = undefined;
var x347: u32 = undefined;
mulxU32(&x346, &x347, x342, 0xffffffff);
var x348: u32 = undefined;
var x349: u32 = undefined;
mulxU32(&x348, &x349, x342, 0xffffffff);
var x350: u32 = undefined;
var x351: u32 = undefined;
mulxU32(&x350, &x351, x342, 0xffffffff);
var x352: u32 = undefined;
var x353: u32 = undefined;
mulxU32(&x352, &x353, x342, 0xffffffff);
var x354: u32 = undefined;
var x355: u32 = undefined;
mulxU32(&x354, &x355, x342, 0xffffffff);
var x356: u32 = undefined;
var x357: u32 = undefined;
mulxU32(&x356, &x357, x342, 0xfffffffe);
var x358: u32 = undefined;
var x359: u32 = undefined;
mulxU32(&x358, &x359, x342, 0xfffffc2f);
var x360: u32 = undefined;
var x361: u1 = undefined;
addcarryxU32(&x360, &x361, 0x0, x359, x356);
var x362: u32 = undefined;
var x363: u1 = undefined;
addcarryxU32(&x362, &x363, x361, x357, x354);
var x364: u32 = undefined;
var x365: u1 = undefined;
addcarryxU32(&x364, &x365, x363, x355, x352);
var x366: u32 = undefined;
var x367: u1 = undefined;
addcarryxU32(&x366, &x367, x365, x353, x350);
var x368: u32 = undefined;
var x369: u1 = undefined;
addcarryxU32(&x368, &x369, x367, x351, x348);
var x370: u32 = undefined;
var x371: u1 = undefined;
addcarryxU32(&x370, &x371, x369, x349, x346);
var x372: u32 = undefined;
var x373: u1 = undefined;
addcarryxU32(&x372, &x373, x371, x347, x344);
const x374 = (cast(u32, x373) + x345);
var x375: u32 = undefined;
var x376: u1 = undefined;
addcarryxU32(&x375, &x376, 0x0, x324, x358);
var x377: u32 = undefined;
var x378: u1 = undefined;
addcarryxU32(&x377, &x378, x376, x326, x360);
var x379: u32 = undefined;
var x380: u1 = undefined;
addcarryxU32(&x379, &x380, x378, x328, x362);
var x381: u32 = undefined;
var x382: u1 = undefined;
addcarryxU32(&x381, &x382, x380, x330, x364);
var x383: u32 = undefined;
var x384: u1 = undefined;
addcarryxU32(&x383, &x384, x382, x332, x366);
var x385: u32 = undefined;
var x386: u1 = undefined;
addcarryxU32(&x385, &x386, x384, x334, x368);
var x387: u32 = undefined;
var x388: u1 = undefined;
addcarryxU32(&x387, &x388, x386, x336, x370);
var x389: u32 = undefined;
var x390: u1 = undefined;
addcarryxU32(&x389, &x390, x388, x338, x372);
var x391: u32 = undefined;
var x392: u1 = undefined;
addcarryxU32(&x391, &x392, x390, x340, x374);
const x393 = (cast(u32, x392) + cast(u32, x341));
var x394: u32 = undefined;
var x395: u32 = undefined;
mulxU32(&x394, &x395, x4, (arg1[7]));
var x396: u32 = undefined;
var x397: u32 = undefined;
mulxU32(&x396, &x397, x4, (arg1[6]));
var x398: u32 = undefined;
var x399: u32 = undefined;
mulxU32(&x398, &x399, x4, (arg1[5]));
var x400: u32 = undefined;
var x401: u32 = undefined;
mulxU32(&x400, &x401, x4, (arg1[4]));
var x402: u32 = undefined;
var x403: u32 = undefined;
mulxU32(&x402, &x403, x4, (arg1[3]));
var x404: u32 = undefined;
var x405: u32 = undefined;
mulxU32(&x404, &x405, x4, (arg1[2]));
var x406: u32 = undefined;
var x407: u32 = undefined;
mulxU32(&x406, &x407, x4, (arg1[1]));
var x408: u32 = undefined;
var x409: u32 = undefined;
mulxU32(&x408, &x409, x4, (arg1[0]));
var x410: u32 = undefined;
var x411: u1 = undefined;
addcarryxU32(&x410, &x411, 0x0, x409, x406);
var x412: u32 = undefined;
var x413: u1 = undefined;
addcarryxU32(&x412, &x413, x411, x407, x404);
var x414: u32 = undefined;
var x415: u1 = undefined;
addcarryxU32(&x414, &x415, x413, x405, x402);
var x416: u32 = undefined;
var x417: u1 = undefined;
addcarryxU32(&x416, &x417, x415, x403, x400);
var x418: u32 = undefined;
var x419: u1 = undefined;
addcarryxU32(&x418, &x419, x417, x401, x398);
var x420: u32 = undefined;
var x421: u1 = undefined;
addcarryxU32(&x420, &x421, x419, x399, x396);
var x422: u32 = undefined;
var x423: u1 = undefined;
addcarryxU32(&x422, &x423, x421, x397, x394);
const x424 = (cast(u32, x423) + x395);
var x425: u32 = undefined;
var x426: u1 = undefined;
addcarryxU32(&x425, &x426, 0x0, x377, x408);
var x427: u32 = undefined;
var x428: u1 = undefined;
addcarryxU32(&x427, &x428, x426, x379, x410);
var x429: u32 = undefined;
var x430: u1 = undefined;
addcarryxU32(&x429, &x430, x428, x381, x412);
var x431: u32 = undefined;
var x432: u1 = undefined;
addcarryxU32(&x431, &x432, x430, x383, x414);
var x433: u32 = undefined;
var x434: u1 = undefined;
addcarryxU32(&x433, &x434, x432, x385, x416);
var x435: u32 = undefined;
var x436: u1 = undefined;
addcarryxU32(&x435, &x436, x434, x387, x418);
var x437: u32 = undefined;
var x438: u1 = undefined;
addcarryxU32(&x437, &x438, x436, x389, x420);
var x439: u32 = undefined;
var x440: u1 = undefined;
addcarryxU32(&x439, &x440, x438, x391, x422);
var x441: u32 = undefined;
var x442: u1 = undefined;
addcarryxU32(&x441, &x442, x440, x393, x424);
var x443: u32 = undefined;
var x444: u32 = undefined;
mulxU32(&x443, &x444, x425, 0xd2253531);
var x445: u32 = undefined;
var x446: u32 = undefined;
mulxU32(&x445, &x446, x443, 0xffffffff);
var x447: u32 = undefined;
var x448: u32 = undefined;
mulxU32(&x447, &x448, x443, 0xffffffff);
var x449: u32 = undefined;
var x450: u32 = undefined;
mulxU32(&x449, &x450, x443, 0xffffffff);
var x451: u32 = undefined;
var x452: u32 = undefined;
mulxU32(&x451, &x452, x443, 0xffffffff);
var x453: u32 = undefined;
var x454: u32 = undefined;
mulxU32(&x453, &x454, x443, 0xffffffff);
var x455: u32 = undefined;
var x456: u32 = undefined;
mulxU32(&x455, &x456, x443, 0xffffffff);
var x457: u32 = undefined;
var x458: u32 = undefined;
mulxU32(&x457, &x458, x443, 0xfffffffe);
var x459: u32 = undefined;
var x460: u32 = undefined;
mulxU32(&x459, &x460, x443, 0xfffffc2f);
var x461: u32 = undefined;
var x462: u1 = undefined;
addcarryxU32(&x461, &x462, 0x0, x460, x457);
var x463: u32 = undefined;
var x464: u1 = undefined;
addcarryxU32(&x463, &x464, x462, x458, x455);
var x465: u32 = undefined;
var x466: u1 = undefined;
addcarryxU32(&x465, &x466, x464, x456, x453);
var x467: u32 = undefined;
var x468: u1 = undefined;
addcarryxU32(&x467, &x468, x466, x454, x451);
var x469: u32 = undefined;
var x470: u1 = undefined;
addcarryxU32(&x469, &x470, x468, x452, x449);
var x471: u32 = undefined;
var x472: u1 = undefined;
addcarryxU32(&x471, &x472, x470, x450, x447);
var x473: u32 = undefined;
var x474: u1 = undefined;
addcarryxU32(&x473, &x474, x472, x448, x445);
const x475 = (cast(u32, x474) + x446);
var x476: u32 = undefined;
var x477: u1 = undefined;
addcarryxU32(&x476, &x477, 0x0, x425, x459);
var x478: u32 = undefined;
var x479: u1 = undefined;
addcarryxU32(&x478, &x479, x477, x427, x461);
var x480: u32 = undefined;
var x481: u1 = undefined;
addcarryxU32(&x480, &x481, x479, x429, x463);
var x482: u32 = undefined;
var x483: u1 = undefined;
addcarryxU32(&x482, &x483, x481, x431, x465);
var x484: u32 = undefined;
var x485: u1 = undefined;
addcarryxU32(&x484, &x485, x483, x433, x467);
var x486: u32 = undefined;
var x487: u1 = undefined;
addcarryxU32(&x486, &x487, x485, x435, x469);
var x488: u32 = undefined;
var x489: u1 = undefined;
addcarryxU32(&x488, &x489, x487, x437, x471);
var x490: u32 = undefined;
var x491: u1 = undefined;
addcarryxU32(&x490, &x491, x489, x439, x473);
var x492: u32 = undefined;
var x493: u1 = undefined;
addcarryxU32(&x492, &x493, x491, x441, x475);
const x494 = (cast(u32, x493) + cast(u32, x442));
var x495: u32 = undefined;
var x496: u32 = undefined;
mulxU32(&x495, &x496, x5, (arg1[7]));
var x497: u32 = undefined;
var x498: u32 = undefined;
mulxU32(&x497, &x498, x5, (arg1[6]));
var x499: u32 = undefined;
var x500: u32 = undefined;
mulxU32(&x499, &x500, x5, (arg1[5]));
var x501: u32 = undefined;
var x502: u32 = undefined;
mulxU32(&x501, &x502, x5, (arg1[4]));
var x503: u32 = undefined;
var x504: u32 = undefined;
mulxU32(&x503, &x504, x5, (arg1[3]));
var x505: u32 = undefined;
var x506: u32 = undefined;
mulxU32(&x505, &x506, x5, (arg1[2]));
var x507: u32 = undefined;
var x508: u32 = undefined;
mulxU32(&x507, &x508, x5, (arg1[1]));
var x509: u32 = undefined;
var x510: u32 = undefined;
mulxU32(&x509, &x510, x5, (arg1[0]));
var x511: u32 = undefined;
var x512: u1 = undefined;
addcarryxU32(&x511, &x512, 0x0, x510, x507);
var x513: u32 = undefined;
var x514: u1 = undefined;
addcarryxU32(&x513, &x514, x512, x508, x505);
var x515: u32 = undefined;
var x516: u1 = undefined;
addcarryxU32(&x515, &x516, x514, x506, x503);
var x517: u32 = undefined;
var x518: u1 = undefined;
addcarryxU32(&x517, &x518, x516, x504, x501);
var x519: u32 = undefined;
var x520: u1 = undefined;
addcarryxU32(&x519, &x520, x518, x502, x499);
var x521: u32 = undefined;
var x522: u1 = undefined;
addcarryxU32(&x521, &x522, x520, x500, x497);
var x523: u32 = undefined;
var x524: u1 = undefined;
addcarryxU32(&x523, &x524, x522, x498, x495);
const x525 = (cast(u32, x524) + x496);
var x526: u32 = undefined;
var x527: u1 = undefined;
addcarryxU32(&x526, &x527, 0x0, x478, x509);
var x528: u32 = undefined;
var x529: u1 = undefined;
addcarryxU32(&x528, &x529, x527, x480, x511);
var x530: u32 = undefined;
var x531: u1 = undefined;
addcarryxU32(&x530, &x531, x529, x482, x513);
var x532: u32 = undefined;
var x533: u1 = undefined;
addcarryxU32(&x532, &x533, x531, x484, x515);
var x534: u32 = undefined;
var x535: u1 = undefined;
addcarryxU32(&x534, &x535, x533, x486, x517);
var x536: u32 = undefined;
var x537: u1 = undefined;
addcarryxU32(&x536, &x537, x535, x488, x519);
var x538: u32 = undefined;
var x539: u1 = undefined;
addcarryxU32(&x538, &x539, x537, x490, x521);
var x540: u32 = undefined;
var x541: u1 = undefined;
addcarryxU32(&x540, &x541, x539, x492, x523);
var x542: u32 = undefined;
var x543: u1 = undefined;
addcarryxU32(&x542, &x543, x541, x494, x525);
var x544: u32 = undefined;
var x545: u32 = undefined;
mulxU32(&x544, &x545, x526, 0xd2253531);
var x546: u32 = undefined;
var x547: u32 = undefined;
mulxU32(&x546, &x547, x544, 0xffffffff);
var x548: u32 = undefined;
var x549: u32 = undefined;
mulxU32(&x548, &x549, x544, 0xffffffff);
var x550: u32 = undefined;
var x551: u32 = undefined;
mulxU32(&x550, &x551, x544, 0xffffffff);
var x552: u32 = undefined;
var x553: u32 = undefined;
mulxU32(&x552, &x553, x544, 0xffffffff);
var x554: u32 = undefined;
var x555: u32 = undefined;
mulxU32(&x554, &x555, x544, 0xffffffff);
var x556: u32 = undefined;
var x557: u32 = undefined;
mulxU32(&x556, &x557, x544, 0xffffffff);
var x558: u32 = undefined;
var x559: u32 = undefined;
mulxU32(&x558, &x559, x544, 0xfffffffe);
var x560: u32 = undefined;
var x561: u32 = undefined;
mulxU32(&x560, &x561, x544, 0xfffffc2f);
var x562: u32 = undefined;
var x563: u1 = undefined;
addcarryxU32(&x562, &x563, 0x0, x561, x558);
var x564: u32 = undefined;
var x565: u1 = undefined;
addcarryxU32(&x564, &x565, x563, x559, x556);
var x566: u32 = undefined;
var x567: u1 = undefined;
addcarryxU32(&x566, &x567, x565, x557, x554);
var x568: u32 = undefined;
var x569: u1 = undefined;
addcarryxU32(&x568, &x569, x567, x555, x552);
var x570: u32 = undefined;
var x571: u1 = undefined;
addcarryxU32(&x570, &x571, x569, x553, x550);
var x572: u32 = undefined;
var x573: u1 = undefined;
addcarryxU32(&x572, &x573, x571, x551, x548);
var x574: u32 = undefined;
var x575: u1 = undefined;
addcarryxU32(&x574, &x575, x573, x549, x546);
const x576 = (cast(u32, x575) + x547);
var x577: u32 = undefined;
var x578: u1 = undefined;
addcarryxU32(&x577, &x578, 0x0, x526, x560);
var x579: u32 = undefined;
var x580: u1 = undefined;
addcarryxU32(&x579, &x580, x578, x528, x562);
var x581: u32 = undefined;
var x582: u1 = undefined;
addcarryxU32(&x581, &x582, x580, x530, x564);
var x583: u32 = undefined;
var x584: u1 = undefined;
addcarryxU32(&x583, &x584, x582, x532, x566);
var x585: u32 = undefined;
var x586: u1 = undefined;
addcarryxU32(&x585, &x586, x584, x534, x568);
var x587: u32 = undefined;
var x588: u1 = undefined;
addcarryxU32(&x587, &x588, x586, x536, x570);
var x589: u32 = undefined;
var x590: u1 = undefined;
addcarryxU32(&x589, &x590, x588, x538, x572);
var x591: u32 = undefined;
var x592: u1 = undefined;
addcarryxU32(&x591, &x592, x590, x540, x574);
var x593: u32 = undefined;
var x594: u1 = undefined;
addcarryxU32(&x593, &x594, x592, x542, x576);
const x595 = (cast(u32, x594) + cast(u32, x543));
var x596: u32 = undefined;
var x597: u32 = undefined;
mulxU32(&x596, &x597, x6, (arg1[7]));
var x598: u32 = undefined;
var x599: u32 = undefined;
mulxU32(&x598, &x599, x6, (arg1[6]));
var x600: u32 = undefined;
var x601: u32 = undefined;
mulxU32(&x600, &x601, x6, (arg1[5]));
var x602: u32 = undefined;
var x603: u32 = undefined;
mulxU32(&x602, &x603, x6, (arg1[4]));
var x604: u32 = undefined;
var x605: u32 = undefined;
mulxU32(&x604, &x605, x6, (arg1[3]));
var x606: u32 = undefined;
var x607: u32 = undefined;
mulxU32(&x606, &x607, x6, (arg1[2]));
var x608: u32 = undefined;
var x609: u32 = undefined;
mulxU32(&x608, &x609, x6, (arg1[1]));
var x610: u32 = undefined;
var x611: u32 = undefined;
mulxU32(&x610, &x611, x6, (arg1[0]));
var x612: u32 = undefined;
var x613: u1 = undefined;
addcarryxU32(&x612, &x613, 0x0, x611, x608);
var x614: u32 = undefined;
var x615: u1 = undefined;
addcarryxU32(&x614, &x615, x613, x609, x606);
var x616: u32 = undefined;
var x617: u1 = undefined;
addcarryxU32(&x616, &x617, x615, x607, x604);
var x618: u32 = undefined;
var x619: u1 = undefined;
addcarryxU32(&x618, &x619, x617, x605, x602);
var x620: u32 = undefined;
var x621: u1 = undefined;
addcarryxU32(&x620, &x621, x619, x603, x600);
var x622: u32 = undefined;
var x623: u1 = undefined;
addcarryxU32(&x622, &x623, x621, x601, x598);
var x624: u32 = undefined;
var x625: u1 = undefined;
addcarryxU32(&x624, &x625, x623, x599, x596);
const x626 = (cast(u32, x625) + x597);
var x627: u32 = undefined;
var x628: u1 = undefined;
addcarryxU32(&x627, &x628, 0x0, x579, x610);
var x629: u32 = undefined;
var x630: u1 = undefined;
addcarryxU32(&x629, &x630, x628, x581, x612);
var x631: u32 = undefined;
var x632: u1 = undefined;
addcarryxU32(&x631, &x632, x630, x583, x614);
var x633: u32 = undefined;
var x634: u1 = undefined;
addcarryxU32(&x633, &x634, x632, x585, x616);
var x635: u32 = undefined;
var x636: u1 = undefined;
addcarryxU32(&x635, &x636, x634, x587, x618);
var x637: u32 = undefined;
var x638: u1 = undefined;
addcarryxU32(&x637, &x638, x636, x589, x620);
var x639: u32 = undefined;
var x640: u1 = undefined;
addcarryxU32(&x639, &x640, x638, x591, x622);
var x641: u32 = undefined;
var x642: u1 = undefined;
addcarryxU32(&x641, &x642, x640, x593, x624);
var x643: u32 = undefined;
var x644: u1 = undefined;
addcarryxU32(&x643, &x644, x642, x595, x626);
var x645: u32 = undefined;
var x646: u32 = undefined;
mulxU32(&x645, &x646, x627, 0xd2253531);
var x647: u32 = undefined;
var x648: u32 = undefined;
mulxU32(&x647, &x648, x645, 0xffffffff);
var x649: u32 = undefined;
var x650: u32 = undefined;
mulxU32(&x649, &x650, x645, 0xffffffff);
var x651: u32 = undefined;
var x652: u32 = undefined;
mulxU32(&x651, &x652, x645, 0xffffffff);
var x653: u32 = undefined;
var x654: u32 = undefined;
mulxU32(&x653, &x654, x645, 0xffffffff);
var x655: u32 = undefined;
var x656: u32 = undefined;
mulxU32(&x655, &x656, x645, 0xffffffff);
var x657: u32 = undefined;
var x658: u32 = undefined;
mulxU32(&x657, &x658, x645, 0xffffffff);
var x659: u32 = undefined;
var x660: u32 = undefined;
mulxU32(&x659, &x660, x645, 0xfffffffe);
var x661: u32 = undefined;
var x662: u32 = undefined;
mulxU32(&x661, &x662, x645, 0xfffffc2f);
var x663: u32 = undefined;
var x664: u1 = undefined;
addcarryxU32(&x663, &x664, 0x0, x662, x659);
var x665: u32 = undefined;
var x666: u1 = undefined;
addcarryxU32(&x665, &x666, x664, x660, x657);
var x667: u32 = undefined;
var x668: u1 = undefined;
addcarryxU32(&x667, &x668, x666, x658, x655);
var x669: u32 = undefined;
var x670: u1 = undefined;
addcarryxU32(&x669, &x670, x668, x656, x653);
var x671: u32 = undefined;
var x672: u1 = undefined;
addcarryxU32(&x671, &x672, x670, x654, x651);
var x673: u32 = undefined;
var x674: u1 = undefined;
addcarryxU32(&x673, &x674, x672, x652, x649);
var x675: u32 = undefined;
var x676: u1 = undefined;
addcarryxU32(&x675, &x676, x674, x650, x647);
const x677 = (cast(u32, x676) + x648);
var x678: u32 = undefined;
var x679: u1 = undefined;
addcarryxU32(&x678, &x679, 0x0, x627, x661);
var x680: u32 = undefined;
var x681: u1 = undefined;
addcarryxU32(&x680, &x681, x679, x629, x663);
var x682: u32 = undefined;
var x683: u1 = undefined;
addcarryxU32(&x682, &x683, x681, x631, x665);
var x684: u32 = undefined;
var x685: u1 = undefined;
addcarryxU32(&x684, &x685, x683, x633, x667);
var x686: u32 = undefined;
var x687: u1 = undefined;
addcarryxU32(&x686, &x687, x685, x635, x669);
var x688: u32 = undefined;
var x689: u1 = undefined;
addcarryxU32(&x688, &x689, x687, x637, x671);
var x690: u32 = undefined;
var x691: u1 = undefined;
addcarryxU32(&x690, &x691, x689, x639, x673);
var x692: u32 = undefined;
var x693: u1 = undefined;
addcarryxU32(&x692, &x693, x691, x641, x675);
var x694: u32 = undefined;
var x695: u1 = undefined;
addcarryxU32(&x694, &x695, x693, x643, x677);
const x696 = (cast(u32, x695) + cast(u32, x644));
var x697: u32 = undefined;
var x698: u32 = undefined;
mulxU32(&x697, &x698, x7, (arg1[7]));
var x699: u32 = undefined;
var x700: u32 = undefined;
mulxU32(&x699, &x700, x7, (arg1[6]));
var x701: u32 = undefined;
var x702: u32 = undefined;
mulxU32(&x701, &x702, x7, (arg1[5]));
var x703: u32 = undefined;
var x704: u32 = undefined;
mulxU32(&x703, &x704, x7, (arg1[4]));
var x705: u32 = undefined;
var x706: u32 = undefined;
mulxU32(&x705, &x706, x7, (arg1[3]));
var x707: u32 = undefined;
var x708: u32 = undefined;
mulxU32(&x707, &x708, x7, (arg1[2]));
var x709: u32 = undefined;
var x710: u32 = undefined;
mulxU32(&x709, &x710, x7, (arg1[1]));
var x711: u32 = undefined;
var x712: u32 = undefined;
mulxU32(&x711, &x712, x7, (arg1[0]));
var x713: u32 = undefined;
var x714: u1 = undefined;
addcarryxU32(&x713, &x714, 0x0, x712, x709);
var x715: u32 = undefined;
var x716: u1 = undefined;
addcarryxU32(&x715, &x716, x714, x710, x707);
var x717: u32 = undefined;
var x718: u1 = undefined;
addcarryxU32(&x717, &x718, x716, x708, x705);
var x719: u32 = undefined;
var x720: u1 = undefined;
addcarryxU32(&x719, &x720, x718, x706, x703);
var x721: u32 = undefined;
var x722: u1 = undefined;
addcarryxU32(&x721, &x722, x720, x704, x701);
var x723: u32 = undefined;
var x724: u1 = undefined;
addcarryxU32(&x723, &x724, x722, x702, x699);
var x725: u32 = undefined;
var x726: u1 = undefined;
addcarryxU32(&x725, &x726, x724, x700, x697);
const x727 = (cast(u32, x726) + x698);
var x728: u32 = undefined;
var x729: u1 = undefined;
addcarryxU32(&x728, &x729, 0x0, x680, x711);
var x730: u32 = undefined;
var x731: u1 = undefined;
addcarryxU32(&x730, &x731, x729, x682, x713);
var x732: u32 = undefined;
var x733: u1 = undefined;
addcarryxU32(&x732, &x733, x731, x684, x715);
var x734: u32 = undefined;
var x735: u1 = undefined;
addcarryxU32(&x734, &x735, x733, x686, x717);
var x736: u32 = undefined;
var x737: u1 = undefined;
addcarryxU32(&x736, &x737, x735, x688, x719);
var x738: u32 = undefined;
var x739: u1 = undefined;
addcarryxU32(&x738, &x739, x737, x690, x721);
var x740: u32 = undefined;
var x741: u1 = undefined;
addcarryxU32(&x740, &x741, x739, x692, x723);
var x742: u32 = undefined;
var x743: u1 = undefined;
addcarryxU32(&x742, &x743, x741, x694, x725);
var x744: u32 = undefined;
var x745: u1 = undefined;
addcarryxU32(&x744, &x745, x743, x696, x727);
var x746: u32 = undefined;
var x747: u32 = undefined;
mulxU32(&x746, &x747, x728, 0xd2253531);
var x748: u32 = undefined;
var x749: u32 = undefined;
mulxU32(&x748, &x749, x746, 0xffffffff);
var x750: u32 = undefined;
var x751: u32 = undefined;
mulxU32(&x750, &x751, x746, 0xffffffff);
var x752: u32 = undefined;
var x753: u32 = undefined;
mulxU32(&x752, &x753, x746, 0xffffffff);
var x754: u32 = undefined;
var x755: u32 = undefined;
mulxU32(&x754, &x755, x746, 0xffffffff);
var x756: u32 = undefined;
var x757: u32 = undefined;
mulxU32(&x756, &x757, x746, 0xffffffff);
var x758: u32 = undefined;
var x759: u32 = undefined;
mulxU32(&x758, &x759, x746, 0xffffffff);
var x760: u32 = undefined;
var x761: u32 = undefined;
mulxU32(&x760, &x761, x746, 0xfffffffe);
var x762: u32 = undefined;
var x763: u32 = undefined;
mulxU32(&x762, &x763, x746, 0xfffffc2f);
var x764: u32 = undefined;
var x765: u1 = undefined;
addcarryxU32(&x764, &x765, 0x0, x763, x760);
var x766: u32 = undefined;
var x767: u1 = undefined;
addcarryxU32(&x766, &x767, x765, x761, x758);
var x768: u32 = undefined;
var x769: u1 = undefined;
addcarryxU32(&x768, &x769, x767, x759, x756);
var x770: u32 = undefined;
var x771: u1 = undefined;
addcarryxU32(&x770, &x771, x769, x757, x754);
var x772: u32 = undefined;
var x773: u1 = undefined;
addcarryxU32(&x772, &x773, x771, x755, x752);
var x774: u32 = undefined;
var x775: u1 = undefined;
addcarryxU32(&x774, &x775, x773, x753, x750);
var x776: u32 = undefined;
var x777: u1 = undefined;
addcarryxU32(&x776, &x777, x775, x751, x748);
const x778 = (cast(u32, x777) + x749);
var x779: u32 = undefined;
var x780: u1 = undefined;
addcarryxU32(&x779, &x780, 0x0, x728, x762);
var x781: u32 = undefined;
var x782: u1 = undefined;
addcarryxU32(&x781, &x782, x780, x730, x764);
var x783: u32 = undefined;
var x784: u1 = undefined;
addcarryxU32(&x783, &x784, x782, x732, x766);
var x785: u32 = undefined;
var x786: u1 = undefined;
addcarryxU32(&x785, &x786, x784, x734, x768);
var x787: u32 = undefined;
var x788: u1 = undefined;
addcarryxU32(&x787, &x788, x786, x736, x770);
var x789: u32 = undefined;
var x790: u1 = undefined;
addcarryxU32(&x789, &x790, x788, x738, x772);
var x791: u32 = undefined;
var x792: u1 = undefined;
addcarryxU32(&x791, &x792, x790, x740, x774);
var x793: u32 = undefined;
var x794: u1 = undefined;
addcarryxU32(&x793, &x794, x792, x742, x776);
var x795: u32 = undefined;
var x796: u1 = undefined;
addcarryxU32(&x795, &x796, x794, x744, x778);
const x797 = (cast(u32, x796) + cast(u32, x745));
var x798: u32 = undefined;
var x799: u1 = undefined;
subborrowxU32(&x798, &x799, 0x0, x781, 0xfffffc2f);
var x800: u32 = undefined;
var x801: u1 = undefined;
subborrowxU32(&x800, &x801, x799, x783, 0xfffffffe);
var x802: u32 = undefined;
var x803: u1 = undefined;
subborrowxU32(&x802, &x803, x801, x785, 0xffffffff);
var x804: u32 = undefined;
var x805: u1 = undefined;
subborrowxU32(&x804, &x805, x803, x787, 0xffffffff);
var x806: u32 = undefined;
var x807: u1 = undefined;
subborrowxU32(&x806, &x807, x805, x789, 0xffffffff);
var x808: u32 = undefined;
var x809: u1 = undefined;
subborrowxU32(&x808, &x809, x807, x791, 0xffffffff);
var x810: u32 = undefined;
var x811: u1 = undefined;
subborrowxU32(&x810, &x811, x809, x793, 0xffffffff);
var x812: u32 = undefined;
var x813: u1 = undefined;
subborrowxU32(&x812, &x813, x811, x795, 0xffffffff);
var x814: u32 = undefined;
var x815: u1 = undefined;
subborrowxU32(&x814, &x815, x813, x797, cast(u32, 0x0));
var x816: u32 = undefined;
cmovznzU32(&x816, x815, x798, x781);
var x817: u32 = undefined;
cmovznzU32(&x817, x815, x800, x783);
var x818: u32 = undefined;
cmovznzU32(&x818, x815, x802, x785);
var x819: u32 = undefined;
cmovznzU32(&x819, x815, x804, x787);
var x820: u32 = undefined;
cmovznzU32(&x820, x815, x806, x789);
var x821: u32 = undefined;
cmovznzU32(&x821, x815, x808, x791);
var x822: u32 = undefined;
cmovznzU32(&x822, x815, x810, x793);
var x823: u32 = undefined;
cmovznzU32(&x823, x815, x812, x795);
out1[0] = x816;
out1[1] = x817;
out1[2] = x818;
out1[3] = x819;
out1[4] = x820;
out1[5] = x821;
out1[6] = x822;
out1[7] = x823;
}
/// 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: u32 = undefined;
var x2: u1 = undefined;
addcarryxU32(&x1, &x2, 0x0, (arg1[0]), (arg2[0]));
var x3: u32 = undefined;
var x4: u1 = undefined;
addcarryxU32(&x3, &x4, x2, (arg1[1]), (arg2[1]));
var x5: u32 = undefined;
var x6: u1 = undefined;
addcarryxU32(&x5, &x6, x4, (arg1[2]), (arg2[2]));
var x7: u32 = undefined;
var x8: u1 = undefined;
addcarryxU32(&x7, &x8, x6, (arg1[3]), (arg2[3]));
var x9: u32 = undefined;
var x10: u1 = undefined;
addcarryxU32(&x9, &x10, x8, (arg1[4]), (arg2[4]));
var x11: u32 = undefined;
var x12: u1 = undefined;
addcarryxU32(&x11, &x12, x10, (arg1[5]), (arg2[5]));
var x13: u32 = undefined;
var x14: u1 = undefined;
addcarryxU32(&x13, &x14, x12, (arg1[6]), (arg2[6]));
var x15: u32 = undefined;
var x16: u1 = undefined;
addcarryxU32(&x15, &x16, x14, (arg1[7]), (arg2[7]));
var x17: u32 = undefined;
var x18: u1 = undefined;
subborrowxU32(&x17, &x18, 0x0, x1, 0xfffffc2f);
var x19: u32 = undefined;
var x20: u1 = undefined;
subborrowxU32(&x19, &x20, x18, x3, 0xfffffffe);
var x21: u32 = undefined;
var x22: u1 = undefined;
subborrowxU32(&x21, &x22, x20, x5, 0xffffffff);
var x23: u32 = undefined;
var x24: u1 = undefined;
subborrowxU32(&x23, &x24, x22, x7, 0xffffffff);
var x25: u32 = undefined;
var x26: u1 = undefined;
subborrowxU32(&x25, &x26, x24, x9, 0xffffffff);
var x27: u32 = undefined;
var x28: u1 = undefined;
subborrowxU32(&x27, &x28, x26, x11, 0xffffffff);
var x29: u32 = undefined;
var x30: u1 = undefined;
subborrowxU32(&x29, &x30, x28, x13, 0xffffffff);
var x31: u32 = undefined;
var x32: u1 = undefined;
subborrowxU32(&x31, &x32, x30, x15, 0xffffffff);
var x33: u32 = undefined;
var x34: u1 = undefined;
subborrowxU32(&x33, &x34, x32, cast(u32, x16), cast(u32, 0x0));
var x35: u32 = undefined;
cmovznzU32(&x35, x34, x17, x1);
var x36: u32 = undefined;
cmovznzU32(&x36, x34, x19, x3);
var x37: u32 = undefined;
cmovznzU32(&x37, x34, x21, x5);
var x38: u32 = undefined;
cmovznzU32(&x38, x34, x23, x7);
var x39: u32 = undefined;
cmovznzU32(&x39, x34, x25, x9);
var x40: u32 = undefined;
cmovznzU32(&x40, x34, x27, x11);
var x41: u32 = undefined;
cmovznzU32(&x41, x34, x29, x13);
var x42: u32 = undefined;
cmovznzU32(&x42, x34, x31, x15);
out1[0] = x35;
out1[1] = x36;
out1[2] = x37;
out1[3] = x38;
out1[4] = x39;
out1[5] = x40;
out1[6] = x41;
out1[7] = x42;
}
/// 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: u32 = undefined;
var x2: u1 = undefined;
subborrowxU32(&x1, &x2, 0x0, (arg1[0]), (arg2[0]));
var x3: u32 = undefined;
var x4: u1 = undefined;
subborrowxU32(&x3, &x4, x2, (arg1[1]), (arg2[1]));
var x5: u32 = undefined;
var x6: u1 = undefined;
subborrowxU32(&x5, &x6, x4, (arg1[2]), (arg2[2]));
var x7: u32 = undefined;
var x8: u1 = undefined;
subborrowxU32(&x7, &x8, x6, (arg1[3]), (arg2[3]));
var x9: u32 = undefined;
var x10: u1 = undefined;
subborrowxU32(&x9, &x10, x8, (arg1[4]), (arg2[4]));
var x11: u32 = undefined;
var x12: u1 = undefined;
subborrowxU32(&x11, &x12, x10, (arg1[5]), (arg2[5]));
var x13: u32 = undefined;
var x14: u1 = undefined;
subborrowxU32(&x13, &x14, x12, (arg1[6]), (arg2[6]));
var x15: u32 = undefined;
var x16: u1 = undefined;
subborrowxU32(&x15, &x16, x14, (arg1[7]), (arg2[7]));
var x17: u32 = undefined;
cmovznzU32(&x17, x16, cast(u32, 0x0), 0xffffffff);
var x18: u32 = undefined;
var x19: u1 = undefined;
addcarryxU32(&x18, &x19, 0x0, x1, (x17 & 0xfffffc2f));
var x20: u32 = undefined;
var x21: u1 = undefined;
addcarryxU32(&x20, &x21, x19, x3, (x17 & 0xfffffffe));
var x22: u32 = undefined;
var x23: u1 = undefined;
addcarryxU32(&x22, &x23, x21, x5, x17);
var x24: u32 = undefined;
var x25: u1 = undefined;
addcarryxU32(&x24, &x25, x23, x7, x17);
var x26: u32 = undefined;
var x27: u1 = undefined;
addcarryxU32(&x26, &x27, x25, x9, x17);
var x28: u32 = undefined;
var x29: u1 = undefined;
addcarryxU32(&x28, &x29, x27, x11, x17);
var x30: u32 = undefined;
var x31: u1 = undefined;
addcarryxU32(&x30, &x31, x29, x13, x17);
var x32: u32 = undefined;
var x33: u1 = undefined;
addcarryxU32(&x32, &x33, x31, x15, x17);
out1[0] = x18;
out1[1] = x20;
out1[2] = x22;
out1[3] = x24;
out1[4] = x26;
out1[5] = x28;
out1[6] = x30;
out1[7] = x32;
}
/// 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: u32 = undefined;
var x2: u1 = undefined;
subborrowxU32(&x1, &x2, 0x0, cast(u32, 0x0), (arg1[0]));
var x3: u32 = undefined;
var x4: u1 = undefined;
subborrowxU32(&x3, &x4, x2, cast(u32, 0x0), (arg1[1]));
var x5: u32 = undefined;
var x6: u1 = undefined;
subborrowxU32(&x5, &x6, x4, cast(u32, 0x0), (arg1[2]));
var x7: u32 = undefined;
var x8: u1 = undefined;
subborrowxU32(&x7, &x8, x6, cast(u32, 0x0), (arg1[3]));
var x9: u32 = undefined;
var x10: u1 = undefined;
subborrowxU32(&x9, &x10, x8, cast(u32, 0x0), (arg1[4]));
var x11: u32 = undefined;
var x12: u1 = undefined;
subborrowxU32(&x11, &x12, x10, cast(u32, 0x0), (arg1[5]));
var x13: u32 = undefined;
var x14: u1 = undefined;
subborrowxU32(&x13, &x14, x12, cast(u32, 0x0), (arg1[6]));
var x15: u32 = undefined;
var x16: u1 = undefined;
subborrowxU32(&x15, &x16, x14, cast(u32, 0x0), (arg1[7]));
var x17: u32 = undefined;
cmovznzU32(&x17, x16, cast(u32, 0x0), 0xffffffff);
var x18: u32 = undefined;
var x19: u1 = undefined;
addcarryxU32(&x18, &x19, 0x0, x1, (x17 & 0xfffffc2f));
var x20: u32 = undefined;
var x21: u1 = undefined;
addcarryxU32(&x20, &x21, x19, x3, (x17 & 0xfffffffe));
var x22: u32 = undefined;
var x23: u1 = undefined;
addcarryxU32(&x22, &x23, x21, x5, x17);
var x24: u32 = undefined;
var x25: u1 = undefined;
addcarryxU32(&x24, &x25, x23, x7, x17);
var x26: u32 = undefined;
var x27: u1 = undefined;
addcarryxU32(&x26, &x27, x25, x9, x17);
var x28: u32 = undefined;
var x29: u1 = undefined;
addcarryxU32(&x28, &x29, x27, x11, x17);
var x30: u32 = undefined;
var x31: u1 = undefined;
addcarryxU32(&x30, &x31, x29, x13, x17);
var x32: u32 = undefined;
var x33: u1 = undefined;
addcarryxU32(&x32, &x33, x31, x15, x17);
out1[0] = x18;
out1[1] = x20;
out1[2] = x22;
out1[3] = x24;
out1[4] = x26;
out1[5] = x28;
out1[6] = x30;
out1[7] = x32;
}
/// 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^32)⁻¹ mod m)^8) mod m
/// 0 ≤ eval out1 < m
///
pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void {
@setRuntimeSafety(mode == .Debug);
const x1 = (arg1[0]);
var x2: u32 = undefined;
var x3: u32 = undefined;
mulxU32(&x2, &x3, x1, 0xd2253531);
var x4: u32 = undefined;
var x5: u32 = undefined;
mulxU32(&x4, &x5, x2, 0xffffffff);
var x6: u32 = undefined;
var x7: u32 = undefined;
mulxU32(&x6, &x7, x2, 0xffffffff);
var x8: u32 = undefined;
var x9: u32 = undefined;
mulxU32(&x8, &x9, x2, 0xffffffff);
var x10: u32 = undefined;
var x11: u32 = undefined;
mulxU32(&x10, &x11, x2, 0xffffffff);
var x12: u32 = undefined;
var x13: u32 = undefined;
mulxU32(&x12, &x13, x2, 0xffffffff);
var x14: u32 = undefined;
var x15: u32 = undefined;
mulxU32(&x14, &x15, x2, 0xffffffff);
var x16: u32 = undefined;
var x17: u32 = undefined;
mulxU32(&x16, &x17, x2, 0xfffffffe);
var x18: u32 = undefined;
var x19: u32 = undefined;
mulxU32(&x18, &x19, x2, 0xfffffc2f);
var x20: u32 = undefined;
var x21: u1 = undefined;
addcarryxU32(&x20, &x21, 0x0, x19, x16);
var x22: u32 = undefined;
var x23: u1 = undefined;
addcarryxU32(&x22, &x23, x21, x17, x14);
var x24: u32 = undefined;
var x25: u1 = undefined;
addcarryxU32(&x24, &x25, x23, x15, x12);
var x26: u32 = undefined;
var x27: u1 = undefined;
addcarryxU32(&x26, &x27, x25, x13, x10);
var x28: u32 = undefined;
var x29: u1 = undefined;
addcarryxU32(&x28, &x29, x27, x11, x8);
var x30: u32 = undefined;
var x31: u1 = undefined;
addcarryxU32(&x30, &x31, x29, x9, x6);
var x32: u32 = undefined;
var x33: u1 = undefined;
addcarryxU32(&x32, &x33, x31, x7, x4);
var x34: u32 = undefined;
var x35: u1 = undefined;
addcarryxU32(&x34, &x35, 0x0, x1, x18);
var x36: u32 = undefined;
var x37: u1 = undefined;
addcarryxU32(&x36, &x37, x35, cast(u32, 0x0), x20);
var x38: u32 = undefined;
var x39: u1 = undefined;
addcarryxU32(&x38, &x39, x37, cast(u32, 0x0), x22);
var x40: u32 = undefined;
var x41: u1 = undefined;
addcarryxU32(&x40, &x41, x39, cast(u32, 0x0), x24);
var x42: u32 = undefined;
var x43: u1 = undefined;
addcarryxU32(&x42, &x43, x41, cast(u32, 0x0), x26);
var x44: u32 = undefined;
var x45: u1 = undefined;
addcarryxU32(&x44, &x45, x43, cast(u32, 0x0), x28);
var x46: u32 = undefined;
var x47: u1 = undefined;
addcarryxU32(&x46, &x47, x45, cast(u32, 0x0), x30);
var x48: u32 = undefined;
var x49: u1 = undefined;
addcarryxU32(&x48, &x49, x47, cast(u32, 0x0), x32);
var x50: u32 = undefined;
var x51: u1 = undefined;
addcarryxU32(&x50, &x51, x49, cast(u32, 0x0), (cast(u32, x33) + x5));
var x52: u32 = undefined;
var x53: u1 = undefined;
addcarryxU32(&x52, &x53, 0x0, x36, (arg1[1]));
var x54: u32 = undefined;
var x55: u1 = undefined;
addcarryxU32(&x54, &x55, x53, x38, cast(u32, 0x0));
var x56: u32 = undefined;
var x57: u1 = undefined;
addcarryxU32(&x56, &x57, x55, x40, cast(u32, 0x0));
var x58: u32 = undefined;
var x59: u1 = undefined;
addcarryxU32(&x58, &x59, x57, x42, cast(u32, 0x0));
var x60: u32 = undefined;
var x61: u1 = undefined;
addcarryxU32(&x60, &x61, x59, x44, cast(u32, 0x0));
var x62: u32 = undefined;
var x63: u1 = undefined;
addcarryxU32(&x62, &x63, x61, x46, cast(u32, 0x0));
var x64: u32 = undefined;
var x65: u1 = undefined;
addcarryxU32(&x64, &x65, x63, x48, cast(u32, 0x0));
var x66: u32 = undefined;
var x67: u1 = undefined;
addcarryxU32(&x66, &x67, x65, x50, cast(u32, 0x0));
var x68: u32 = undefined;
var x69: u32 = undefined;
mulxU32(&x68, &x69, x52, 0xd2253531);
var x70: u32 = undefined;
var x71: u32 = undefined;
mulxU32(&x70, &x71, x68, 0xffffffff);
var x72: u32 = undefined;
var x73: u32 = undefined;
mulxU32(&x72, &x73, x68, 0xffffffff);
var x74: u32 = undefined;
var x75: u32 = undefined;
mulxU32(&x74, &x75, x68, 0xffffffff);
var x76: u32 = undefined;
var x77: u32 = undefined;
mulxU32(&x76, &x77, x68, 0xffffffff);
var x78: u32 = undefined;
var x79: u32 = undefined;
mulxU32(&x78, &x79, x68, 0xffffffff);
var x80: u32 = undefined;
var x81: u32 = undefined;
mulxU32(&x80, &x81, x68, 0xffffffff);
var x82: u32 = undefined;
var x83: u32 = undefined;
mulxU32(&x82, &x83, x68, 0xfffffffe);
var x84: u32 = undefined;
var x85: u32 = undefined;
mulxU32(&x84, &x85, x68, 0xfffffc2f);
var x86: u32 = undefined;
var x87: u1 = undefined;
addcarryxU32(&x86, &x87, 0x0, x85, x82);
var x88: u32 = undefined;
var x89: u1 = undefined;
addcarryxU32(&x88, &x89, x87, x83, x80);
var x90: u32 = undefined;
var x91: u1 = undefined;
addcarryxU32(&x90, &x91, x89, x81, x78);
var x92: u32 = undefined;
var x93: u1 = undefined;
addcarryxU32(&x92, &x93, x91, x79, x76);
var x94: u32 = undefined;
var x95: u1 = undefined;
addcarryxU32(&x94, &x95, x93, x77, x74);
var x96: u32 = undefined;
var x97: u1 = undefined;
addcarryxU32(&x96, &x97, x95, x75, x72);
var x98: u32 = undefined;
var x99: u1 = undefined;
addcarryxU32(&x98, &x99, x97, x73, x70);
var x100: u32 = undefined;
var x101: u1 = undefined;
addcarryxU32(&x100, &x101, 0x0, x52, x84);
var x102: u32 = undefined;
var x103: u1 = undefined;
addcarryxU32(&x102, &x103, x101, x54, x86);
var x104: u32 = undefined;
var x105: u1 = undefined;
addcarryxU32(&x104, &x105, x103, x56, x88);
var x106: u32 = undefined;
var x107: u1 = undefined;
addcarryxU32(&x106, &x107, x105, x58, x90);
var x108: u32 = undefined;
var x109: u1 = undefined;
addcarryxU32(&x108, &x109, x107, x60, x92);
var x110: u32 = undefined;
var x111: u1 = undefined;
addcarryxU32(&x110, &x111, x109, x62, x94);
var x112: u32 = undefined;
var x113: u1 = undefined;
addcarryxU32(&x112, &x113, x111, x64, x96);
var x114: u32 = undefined;
var x115: u1 = undefined;
addcarryxU32(&x114, &x115, x113, x66, x98);
var x116: u32 = undefined;
var x117: u1 = undefined;
addcarryxU32(&x116, &x117, x115, (cast(u32, x67) + cast(u32, x51)), (cast(u32, x99) + x71));
var x118: u32 = undefined;
var x119: u1 = undefined;
addcarryxU32(&x118, &x119, 0x0, x102, (arg1[2]));
var x120: u32 = undefined;
var x121: u1 = undefined;
addcarryxU32(&x120, &x121, x119, x104, cast(u32, 0x0));
var x122: u32 = undefined;
var x123: u1 = undefined;
addcarryxU32(&x122, &x123, x121, x106, cast(u32, 0x0));
var x124: u32 = undefined;
var x125: u1 = undefined;
addcarryxU32(&x124, &x125, x123, x108, cast(u32, 0x0));
var x126: u32 = undefined;
var x127: u1 = undefined;
addcarryxU32(&x126, &x127, x125, x110, cast(u32, 0x0));
var x128: u32 = undefined;
var x129: u1 = undefined;
addcarryxU32(&x128, &x129, x127, x112, cast(u32, 0x0));
var x130: u32 = undefined;
var x131: u1 = undefined;
addcarryxU32(&x130, &x131, x129, x114, cast(u32, 0x0));
var x132: u32 = undefined;
var x133: u1 = undefined;
addcarryxU32(&x132, &x133, x131, x116, cast(u32, 0x0));
var x134: u32 = undefined;
var x135: u32 = undefined;
mulxU32(&x134, &x135, x118, 0xd2253531);
var x136: u32 = undefined;
var x137: u32 = undefined;
mulxU32(&x136, &x137, x134, 0xffffffff);
var x138: u32 = undefined;
var x139: u32 = undefined;
mulxU32(&x138, &x139, x134, 0xffffffff);
var x140: u32 = undefined;
var x141: u32 = undefined;
mulxU32(&x140, &x141, x134, 0xffffffff);
var x142: u32 = undefined;
var x143: u32 = undefined;
mulxU32(&x142, &x143, x134, 0xffffffff);
var x144: u32 = undefined;
var x145: u32 = undefined;
mulxU32(&x144, &x145, x134, 0xffffffff);
var x146: u32 = undefined;
var x147: u32 = undefined;
mulxU32(&x146, &x147, x134, 0xffffffff);
var x148: u32 = undefined;
var x149: u32 = undefined;
mulxU32(&x148, &x149, x134, 0xfffffffe);
var x150: u32 = undefined;
var x151: u32 = undefined;
mulxU32(&x150, &x151, x134, 0xfffffc2f);
var x152: u32 = undefined;
var x153: u1 = undefined;
addcarryxU32(&x152, &x153, 0x0, x151, x148);
var x154: u32 = undefined;
var x155: u1 = undefined;
addcarryxU32(&x154, &x155, x153, x149, x146);
var x156: u32 = undefined;
var x157: u1 = undefined;
addcarryxU32(&x156, &x157, x155, x147, x144);
var x158: u32 = undefined;
var x159: u1 = undefined;
addcarryxU32(&x158, &x159, x157, x145, x142);
var x160: u32 = undefined;
var x161: u1 = undefined;
addcarryxU32(&x160, &x161, x159, x143, x140);
var x162: u32 = undefined;
var x163: u1 = undefined;
addcarryxU32(&x162, &x163, x161, x141, x138);
var x164: u32 = undefined;
var x165: u1 = undefined;
addcarryxU32(&x164, &x165, x163, x139, x136);
var x166: u32 = undefined;
var x167: u1 = undefined;
addcarryxU32(&x166, &x167, 0x0, x118, x150);
var x168: u32 = undefined;
var x169: u1 = undefined;
addcarryxU32(&x168, &x169, x167, x120, x152);
var x170: u32 = undefined;
var x171: u1 = undefined;
addcarryxU32(&x170, &x171, x169, x122, x154);
var x172: u32 = undefined;
var x173: u1 = undefined;
addcarryxU32(&x172, &x173, x171, x124, x156);
var x174: u32 = undefined;
var x175: u1 = undefined;
addcarryxU32(&x174, &x175, x173, x126, x158);
var x176: u32 = undefined;
var x177: u1 = undefined;
addcarryxU32(&x176, &x177, x175, x128, x160);
var x178: u32 = undefined;
var x179: u1 = undefined;
addcarryxU32(&x178, &x179, x177, x130, x162);
var x180: u32 = undefined;
var x181: u1 = undefined;
addcarryxU32(&x180, &x181, x179, x132, x164);
var x182: u32 = undefined;
var x183: u1 = undefined;
addcarryxU32(&x182, &x183, x181, (cast(u32, x133) + cast(u32, x117)), (cast(u32, x165) + x137));
var x184: u32 = undefined;
var x185: u1 = undefined;
addcarryxU32(&x184, &x185, 0x0, x168, (arg1[3]));
var x186: u32 = undefined;
var x187: u1 = undefined;
addcarryxU32(&x186, &x187, x185, x170, cast(u32, 0x0));
var x188: u32 = undefined;
var x189: u1 = undefined;
addcarryxU32(&x188, &x189, x187, x172, cast(u32, 0x0));
var x190: u32 = undefined;
var x191: u1 = undefined;
addcarryxU32(&x190, &x191, x189, x174, cast(u32, 0x0));
var x192: u32 = undefined;
var x193: u1 = undefined;
addcarryxU32(&x192, &x193, x191, x176, cast(u32, 0x0));
var x194: u32 = undefined;
var x195: u1 = undefined;
addcarryxU32(&x194, &x195, x193, x178, cast(u32, 0x0));
var x196: u32 = undefined;
var x197: u1 = undefined;
addcarryxU32(&x196, &x197, x195, x180, cast(u32, 0x0));
var x198: u32 = undefined;
var x199: u1 = undefined;
addcarryxU32(&x198, &x199, x197, x182, cast(u32, 0x0));
var x200: u32 = undefined;
var x201: u32 = undefined;
mulxU32(&x200, &x201, x184, 0xd2253531);
var x202: u32 = undefined;
var x203: u32 = undefined;
mulxU32(&x202, &x203, x200, 0xffffffff);
var x204: u32 = undefined;
var x205: u32 = undefined;
mulxU32(&x204, &x205, x200, 0xffffffff);
var x206: u32 = undefined;
var x207: u32 = undefined;
mulxU32(&x206, &x207, x200, 0xffffffff);
var x208: u32 = undefined;
var x209: u32 = undefined;
mulxU32(&x208, &x209, x200, 0xffffffff);
var x210: u32 = undefined;
var x211: u32 = undefined;
mulxU32(&x210, &x211, x200, 0xffffffff);
var x212: u32 = undefined;
var x213: u32 = undefined;
mulxU32(&x212, &x213, x200, 0xffffffff);
var x214: u32 = undefined;
var x215: u32 = undefined;
mulxU32(&x214, &x215, x200, 0xfffffffe);
var x216: u32 = undefined;
var x217: u32 = undefined;
mulxU32(&x216, &x217, x200, 0xfffffc2f);
var x218: u32 = undefined;
var x219: u1 = undefined;
addcarryxU32(&x218, &x219, 0x0, x217, x214);
var x220: u32 = undefined;
var x221: u1 = undefined;
addcarryxU32(&x220, &x221, x219, x215, x212);
var x222: u32 = undefined;
var x223: u1 = undefined;
addcarryxU32(&x222, &x223, x221, x213, x210);
var x224: u32 = undefined;
var x225: u1 = undefined;
addcarryxU32(&x224, &x225, x223, x211, x208);
var x226: u32 = undefined;
var x227: u1 = undefined;
addcarryxU32(&x226, &x227, x225, x209, x206);
var x228: u32 = undefined;
var x229: u1 = undefined;
addcarryxU32(&x228, &x229, x227, x207, x204);
var x230: u32 = undefined;
var x231: u1 = undefined;
addcarryxU32(&x230, &x231, x229, x205, x202);
var x232: u32 = undefined;
var x233: u1 = undefined;
addcarryxU32(&x232, &x233, 0x0, x184, x216);
var x234: u32 = undefined;
var x235: u1 = undefined;
addcarryxU32(&x234, &x235, x233, x186, x218);
var x236: u32 = undefined;
var x237: u1 = undefined;
addcarryxU32(&x236, &x237, x235, x188, x220);
var x238: u32 = undefined;
var x239: u1 = undefined;
addcarryxU32(&x238, &x239, x237, x190, x222);
var x240: u32 = undefined;
var x241: u1 = undefined;
addcarryxU32(&x240, &x241, x239, x192, x224);
var x242: u32 = undefined;
var x243: u1 = undefined;
addcarryxU32(&x242, &x243, x241, x194, x226);
var x244: u32 = undefined;
var x245: u1 = undefined;
addcarryxU32(&x244, &x245, x243, x196, x228);
var x246: u32 = undefined;
var x247: u1 = undefined;
addcarryxU32(&x246, &x247, x245, x198, x230);
var x248: u32 = undefined;
var x249: u1 = undefined;
addcarryxU32(&x248, &x249, x247, (cast(u32, x199) + cast(u32, x183)), (cast(u32, x231) + x203));
var x250: u32 = undefined;
var x251: u1 = undefined;
addcarryxU32(&x250, &x251, 0x0, x234, (arg1[4]));
var x252: u32 = undefined;
var x253: u1 = undefined;
addcarryxU32(&x252, &x253, x251, x236, cast(u32, 0x0));
var x254: u32 = undefined;
var x255: u1 = undefined;
addcarryxU32(&x254, &x255, x253, x238, cast(u32, 0x0));
var x256: u32 = undefined;
var x257: u1 = undefined;
addcarryxU32(&x256, &x257, x255, x240, cast(u32, 0x0));
var x258: u32 = undefined;
var x259: u1 = undefined;
addcarryxU32(&x258, &x259, x257, x242, cast(u32, 0x0));
var x260: u32 = undefined;
var x261: u1 = undefined;
addcarryxU32(&x260, &x261, x259, x244, cast(u32, 0x0));
var x262: u32 = undefined;
var x263: u1 = undefined;
addcarryxU32(&x262, &x263, x261, x246, cast(u32, 0x0));
var x264: u32 = undefined;
var x265: u1 = undefined;
addcarryxU32(&x264, &x265, x263, x248, cast(u32, 0x0));
var x266: u32 = undefined;
var x267: u32 = undefined;
mulxU32(&x266, &x267, x250, 0xd2253531);
var x268: u32 = undefined;
var x269: u32 = undefined;
mulxU32(&x268, &x269, x266, 0xffffffff);
var x270: u32 = undefined;
var x271: u32 = undefined;
mulxU32(&x270, &x271, x266, 0xffffffff);
var x272: u32 = undefined;
var x273: u32 = undefined;
mulxU32(&x272, &x273, x266, 0xffffffff);
var x274: u32 = undefined;
var x275: u32 = undefined;
mulxU32(&x274, &x275, x266, 0xffffffff);
var x276: u32 = undefined;
var x277: u32 = undefined;
mulxU32(&x276, &x277, x266, 0xffffffff);
var x278: u32 = undefined;
var x279: u32 = undefined;
mulxU32(&x278, &x279, x266, 0xffffffff);
var x280: u32 = undefined;
var x281: u32 = undefined;
mulxU32(&x280, &x281, x266, 0xfffffffe);
var x282: u32 = undefined;
var x283: u32 = undefined;
mulxU32(&x282, &x283, x266, 0xfffffc2f);
var x284: u32 = undefined;
var x285: u1 = undefined;
addcarryxU32(&x284, &x285, 0x0, x283, x280);
var x286: u32 = undefined;
var x287: u1 = undefined;
addcarryxU32(&x286, &x287, x285, x281, x278);
var x288: u32 = undefined;
var x289: u1 = undefined;
addcarryxU32(&x288, &x289, x287, x279, x276);
var x290: u32 = undefined;
var x291: u1 = undefined;
addcarryxU32(&x290, &x291, x289, x277, x274);
var x292: u32 = undefined;
var x293: u1 = undefined;
addcarryxU32(&x292, &x293, x291, x275, x272);
var x294: u32 = undefined;
var x295: u1 = undefined;
addcarryxU32(&x294, &x295, x293, x273, x270);
var x296: u32 = undefined;
var x297: u1 = undefined;
addcarryxU32(&x296, &x297, x295, x271, x268);
var x298: u32 = undefined;
var x299: u1 = undefined;
addcarryxU32(&x298, &x299, 0x0, x250, x282);
var x300: u32 = undefined;
var x301: u1 = undefined;
addcarryxU32(&x300, &x301, x299, x252, x284);
var x302: u32 = undefined;
var x303: u1 = undefined;
addcarryxU32(&x302, &x303, x301, x254, x286);
var x304: u32 = undefined;
var x305: u1 = undefined;
addcarryxU32(&x304, &x305, x303, x256, x288);
var x306: u32 = undefined;
var x307: u1 = undefined;
addcarryxU32(&x306, &x307, x305, x258, x290);
var x308: u32 = undefined;
var x309: u1 = undefined;
addcarryxU32(&x308, &x309, x307, x260, x292);
var x310: u32 = undefined;
var x311: u1 = undefined;
addcarryxU32(&x310, &x311, x309, x262, x294);
var x312: u32 = undefined;
var x313: u1 = undefined;
addcarryxU32(&x312, &x313, x311, x264, x296);
var x314: u32 = undefined;
var x315: u1 = undefined;
addcarryxU32(&x314, &x315, x313, (cast(u32, x265) + cast(u32, x249)), (cast(u32, x297) + x269));
var x316: u32 = undefined;
var x317: u1 = undefined;
addcarryxU32(&x316, &x317, 0x0, x300, (arg1[5]));
var x318: u32 = undefined;
var x319: u1 = undefined;
addcarryxU32(&x318, &x319, x317, x302, cast(u32, 0x0));
var x320: u32 = undefined;
var x321: u1 = undefined;
addcarryxU32(&x320, &x321, x319, x304, cast(u32, 0x0));
var x322: u32 = undefined;
var x323: u1 = undefined;
addcarryxU32(&x322, &x323, x321, x306, cast(u32, 0x0));
var x324: u32 = undefined;
var x325: u1 = undefined;
addcarryxU32(&x324, &x325, x323, x308, cast(u32, 0x0));
var x326: u32 = undefined;
var x327: u1 = undefined;
addcarryxU32(&x326, &x327, x325, x310, cast(u32, 0x0));
var x328: u32 = undefined;
var x329: u1 = undefined;
addcarryxU32(&x328, &x329, x327, x312, cast(u32, 0x0));
var x330: u32 = undefined;
var x331: u1 = undefined;
addcarryxU32(&x330, &x331, x329, x314, cast(u32, 0x0));
var x332: u32 = undefined;
var x333: u32 = undefined;
mulxU32(&x332, &x333, x316, 0xd2253531);
var x334: u32 = undefined;
var x335: u32 = undefined;
mulxU32(&x334, &x335, x332, 0xffffffff);
var x336: u32 = undefined;
var x337: u32 = undefined;
mulxU32(&x336, &x337, x332, 0xffffffff);
var x338: u32 = undefined;
var x339: u32 = undefined;
mulxU32(&x338, &x339, x332, 0xffffffff);
var x340: u32 = undefined;
var x341: u32 = undefined;
mulxU32(&x340, &x341, x332, 0xffffffff);
var x342: u32 = undefined;
var x343: u32 = undefined;
mulxU32(&x342, &x343, x332, 0xffffffff);
var x344: u32 = undefined;
var x345: u32 = undefined;
mulxU32(&x344, &x345, x332, 0xffffffff);
var x346: u32 = undefined;
var x347: u32 = undefined;
mulxU32(&x346, &x347, x332, 0xfffffffe);
var x348: u32 = undefined;
var x349: u32 = undefined;
mulxU32(&x348, &x349, x332, 0xfffffc2f);
var x350: u32 = undefined;
var x351: u1 = undefined;
addcarryxU32(&x350, &x351, 0x0, x349, x346);
var x352: u32 = undefined;
var x353: u1 = undefined;
addcarryxU32(&x352, &x353, x351, x347, x344);
var x354: u32 = undefined;
var x355: u1 = undefined;
addcarryxU32(&x354, &x355, x353, x345, x342);
var x356: u32 = undefined;
var x357: u1 = undefined;
addcarryxU32(&x356, &x357, x355, x343, x340);
var x358: u32 = undefined;
var x359: u1 = undefined;
addcarryxU32(&x358, &x359, x357, x341, x338);
var x360: u32 = undefined;
var x361: u1 = undefined;
addcarryxU32(&x360, &x361, x359, x339, x336);
var x362: u32 = undefined;
var x363: u1 = undefined;
addcarryxU32(&x362, &x363, x361, x337, x334);
var x364: u32 = undefined;
var x365: u1 = undefined;
addcarryxU32(&x364, &x365, 0x0, x316, x348);
var x366: u32 = undefined;
var x367: u1 = undefined;
addcarryxU32(&x366, &x367, x365, x318, x350);
var x368: u32 = undefined;
var x369: u1 = undefined;
addcarryxU32(&x368, &x369, x367, x320, x352);
var x370: u32 = undefined;
var x371: u1 = undefined;
addcarryxU32(&x370, &x371, x369, x322, x354);
var x372: u32 = undefined;
var x373: u1 = undefined;
addcarryxU32(&x372, &x373, x371, x324, x356);
var x374: u32 = undefined;
var x375: u1 = undefined;
addcarryxU32(&x374, &x375, x373, x326, x358);
var x376: u32 = undefined;
var x377: u1 = undefined;
addcarryxU32(&x376, &x377, x375, x328, x360);
var x378: u32 = undefined;
var x379: u1 = undefined;
addcarryxU32(&x378, &x379, x377, x330, x362);
var x380: u32 = undefined;
var x381: u1 = undefined;
addcarryxU32(&x380, &x381, x379, (cast(u32, x331) + cast(u32, x315)), (cast(u32, x363) + x335));
var x382: u32 = undefined;
var x383: u1 = undefined;
addcarryxU32(&x382, &x383, 0x0, x366, (arg1[6]));
var x384: u32 = undefined;
var x385: u1 = undefined;
addcarryxU32(&x384, &x385, x383, x368, cast(u32, 0x0));
var x386: u32 = undefined;
var x387: u1 = undefined;
addcarryxU32(&x386, &x387, x385, x370, cast(u32, 0x0));
var x388: u32 = undefined;
var x389: u1 = undefined;
addcarryxU32(&x388, &x389, x387, x372, cast(u32, 0x0));
var x390: u32 = undefined;
var x391: u1 = undefined;
addcarryxU32(&x390, &x391, x389, x374, cast(u32, 0x0));
var x392: u32 = undefined;
var x393: u1 = undefined;
addcarryxU32(&x392, &x393, x391, x376, cast(u32, 0x0));
var x394: u32 = undefined;
var x395: u1 = undefined;
addcarryxU32(&x394, &x395, x393, x378, cast(u32, 0x0));
var x396: u32 = undefined;
var x397: u1 = undefined;
addcarryxU32(&x396, &x397, x395, x380, cast(u32, 0x0));
var x398: u32 = undefined;
var x399: u32 = undefined;
mulxU32(&x398, &x399, x382, 0xd2253531);
var x400: u32 = undefined;
var x401: u32 = undefined;
mulxU32(&x400, &x401, x398, 0xffffffff);
var x402: u32 = undefined;
var x403: u32 = undefined;
mulxU32(&x402, &x403, x398, 0xffffffff);
var x404: u32 = undefined;
var x405: u32 = undefined;
mulxU32(&x404, &x405, x398, 0xffffffff);
var x406: u32 = undefined;
var x407: u32 = undefined;
mulxU32(&x406, &x407, x398, 0xffffffff);
var x408: u32 = undefined;
var x409: u32 = undefined;
mulxU32(&x408, &x409, x398, 0xffffffff);
var x410: u32 = undefined;
var x411: u32 = undefined;
mulxU32(&x410, &x411, x398, 0xffffffff);
var x412: u32 = undefined;
var x413: u32 = undefined;
mulxU32(&x412, &x413, x398, 0xfffffffe);
var x414: u32 = undefined;
var x415: u32 = undefined;
mulxU32(&x414, &x415, x398, 0xfffffc2f);
var x416: u32 = undefined;
var x417: u1 = undefined;
addcarryxU32(&x416, &x417, 0x0, x415, x412);
var x418: u32 = undefined;
var x419: u1 = undefined;
addcarryxU32(&x418, &x419, x417, x413, x410);
var x420: u32 = undefined;
var x421: u1 = undefined;
addcarryxU32(&x420, &x421, x419, x411, x408);
var x422: u32 = undefined;
var x423: u1 = undefined;
addcarryxU32(&x422, &x423, x421, x409, x406);
var x424: u32 = undefined;
var x425: u1 = undefined;
addcarryxU32(&x424, &x425, x423, x407, x404);
var x426: u32 = undefined;
var x427: u1 = undefined;
addcarryxU32(&x426, &x427, x425, x405, x402);
var x428: u32 = undefined;
var x429: u1 = undefined;
addcarryxU32(&x428, &x429, x427, x403, x400);
var x430: u32 = undefined;
var x431: u1 = undefined;
addcarryxU32(&x430, &x431, 0x0, x382, x414);
var x432: u32 = undefined;
var x433: u1 = undefined;
addcarryxU32(&x432, &x433, x431, x384, x416);
var x434: u32 = undefined;
var x435: u1 = undefined;
addcarryxU32(&x434, &x435, x433, x386, x418);
var x436: u32 = undefined;
var x437: u1 = undefined;
addcarryxU32(&x436, &x437, x435, x388, x420);
var x438: u32 = undefined;
var x439: u1 = undefined;
addcarryxU32(&x438, &x439, x437, x390, x422);
var x440: u32 = undefined;
var x441: u1 = undefined;
addcarryxU32(&x440, &x441, x439, x392, x424);
var x442: u32 = undefined;
var x443: u1 = undefined;
addcarryxU32(&x442, &x443, x441, x394, x426);
var x444: u32 = undefined;
var x445: u1 = undefined;
addcarryxU32(&x444, &x445, x443, x396, x428);
var x446: u32 = undefined;
var x447: u1 = undefined;
addcarryxU32(&x446, &x447, x445, (cast(u32, x397) + cast(u32, x381)), (cast(u32, x429) + x401));
var x448: u32 = undefined;
var x449: u1 = undefined;
addcarryxU32(&x448, &x449, 0x0, x432, (arg1[7]));
var x450: u32 = undefined;
var x451: u1 = undefined;
addcarryxU32(&x450, &x451, x449, x434, cast(u32, 0x0));
var x452: u32 = undefined;
var x453: u1 = undefined;
addcarryxU32(&x452, &x453, x451, x436, cast(u32, 0x0));
var x454: u32 = undefined;
var x455: u1 = undefined;
addcarryxU32(&x454, &x455, x453, x438, cast(u32, 0x0));
var x456: u32 = undefined;
var x457: u1 = undefined;
addcarryxU32(&x456, &x457, x455, x440, cast(u32, 0x0));
var x458: u32 = undefined;
var x459: u1 = undefined;
addcarryxU32(&x458, &x459, x457, x442, cast(u32, 0x0));
var x460: u32 = undefined;
var x461: u1 = undefined;
addcarryxU32(&x460, &x461, x459, x444, cast(u32, 0x0));
var x462: u32 = undefined;
var x463: u1 = undefined;
addcarryxU32(&x462, &x463, x461, x446, cast(u32, 0x0));
var x464: u32 = undefined;
var x465: u32 = undefined;
mulxU32(&x464, &x465, x448, 0xd2253531);
var x466: u32 = undefined;
var x467: u32 = undefined;
mulxU32(&x466, &x467, x464, 0xffffffff);
var x468: u32 = undefined;
var x469: u32 = undefined;
mulxU32(&x468, &x469, x464, 0xffffffff);
var x470: u32 = undefined;
var x471: u32 = undefined;
mulxU32(&x470, &x471, x464, 0xffffffff);
var x472: u32 = undefined;
var x473: u32 = undefined;
mulxU32(&x472, &x473, x464, 0xffffffff);
var x474: u32 = undefined;
var x475: u32 = undefined;
mulxU32(&x474, &x475, x464, 0xffffffff);
var x476: u32 = undefined;
var x477: u32 = undefined;
mulxU32(&x476, &x477, x464, 0xffffffff);
var x478: u32 = undefined;
var x479: u32 = undefined;
mulxU32(&x478, &x479, x464, 0xfffffffe);
var x480: u32 = undefined;
var x481: u32 = undefined;
mulxU32(&x480, &x481, x464, 0xfffffc2f);
var x482: u32 = undefined;
var x483: u1 = undefined;
addcarryxU32(&x482, &x483, 0x0, x481, x478);
var x484: u32 = undefined;
var x485: u1 = undefined;
addcarryxU32(&x484, &x485, x483, x479, x476);
var x486: u32 = undefined;
var x487: u1 = undefined;
addcarryxU32(&x486, &x487, x485, x477, x474);
var x488: u32 = undefined;
var x489: u1 = undefined;
addcarryxU32(&x488, &x489, x487, x475, x472);
var x490: u32 = undefined;
var x491: u1 = undefined;
addcarryxU32(&x490, &x491, x489, x473, x470);
var x492: u32 = undefined;
var x493: u1 = undefined;
addcarryxU32(&x492, &x493, x491, x471, x468);
var x494: u32 = undefined;
var x495: u1 = undefined;
addcarryxU32(&x494, &x495, x493, x469, x466);
var x496: u32 = undefined;
var x497: u1 = undefined;
addcarryxU32(&x496, &x497, 0x0, x448, x480);
var x498: u32 = undefined;
var x499: u1 = undefined;
addcarryxU32(&x498, &x499, x497, x450, x482);
var x500: u32 = undefined;
var x501: u1 = undefined;
addcarryxU32(&x500, &x501, x499, x452, x484);
var x502: u32 = undefined;
var x503: u1 = undefined;
addcarryxU32(&x502, &x503, x501, x454, x486);
var x504: u32 = undefined;
var x505: u1 = undefined;
addcarryxU32(&x504, &x505, x503, x456, x488);
var x506: u32 = undefined;
var x507: u1 = undefined;
addcarryxU32(&x506, &x507, x505, x458, x490);
var x508: u32 = undefined;
var x509: u1 = undefined;
addcarryxU32(&x508, &x509, x507, x460, x492);
var x510: u32 = undefined;
var x511: u1 = undefined;
addcarryxU32(&x510, &x511, x509, x462, x494);
var x512: u32 = undefined;
var x513: u1 = undefined;
addcarryxU32(&x512, &x513, x511, (cast(u32, x463) + cast(u32, x447)), (cast(u32, x495) + x467));
var x514: u32 = undefined;
var x515: u1 = undefined;
subborrowxU32(&x514, &x515, 0x0, x498, 0xfffffc2f);
var x516: u32 = undefined;
var x517: u1 = undefined;
subborrowxU32(&x516, &x517, x515, x500, 0xfffffffe);
var x518: u32 = undefined;
var x519: u1 = undefined;
subborrowxU32(&x518, &x519, x517, x502, 0xffffffff);
var x520: u32 = undefined;
var x521: u1 = undefined;
subborrowxU32(&x520, &x521, x519, x504, 0xffffffff);
var x522: u32 = undefined;
var x523: u1 = undefined;
subborrowxU32(&x522, &x523, x521, x506, 0xffffffff);
var x524: u32 = undefined;
var x525: u1 = undefined;
subborrowxU32(&x524, &x525, x523, x508, 0xffffffff);
var x526: u32 = undefined;
var x527: u1 = undefined;
subborrowxU32(&x526, &x527, x525, x510, 0xffffffff);
var x528: u32 = undefined;
var x529: u1 = undefined;
subborrowxU32(&x528, &x529, x527, x512, 0xffffffff);
var x530: u32 = undefined;
var x531: u1 = undefined;
subborrowxU32(&x530, &x531, x529, cast(u32, x513), cast(u32, 0x0));
var x532: u32 = undefined;
cmovznzU32(&x532, x531, x514, x498);
var x533: u32 = undefined;
cmovznzU32(&x533, x531, x516, x500);
var x534: u32 = undefined;
cmovznzU32(&x534, x531, x518, x502);
var x535: u32 = undefined;
cmovznzU32(&x535, x531, x520, x504);
var x536: u32 = undefined;
cmovznzU32(&x536, x531, x522, x506);
var x537: u32 = undefined;
cmovznzU32(&x537, x531, x524, x508);
var x538: u32 = undefined;
cmovznzU32(&x538, x531, x526, x510);
var x539: u32 = undefined;
cmovznzU32(&x539, x531, x528, x512);
out1[0] = x532;
out1[1] = x533;
out1[2] = x534;
out1[3] = x535;
out1[4] = x536;
out1[5] = x537;
out1[6] = x538;
out1[7] = x539;
}
/// 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[6]);
const x7 = (arg1[7]);
const x8 = (arg1[0]);
var x9: u32 = undefined;
var x10: u32 = undefined;
mulxU32(&x9, &x10, x8, 0x7a2);
var x11: u32 = undefined;
var x12: u32 = undefined;
mulxU32(&x11, &x12, x8, 0xe90a1);
var x13: u32 = undefined;
var x14: u1 = undefined;
addcarryxU32(&x13, &x14, 0x0, x12, x9);
var x15: u32 = undefined;
var x16: u1 = undefined;
addcarryxU32(&x15, &x16, x14, x10, x8);
var x17: u32 = undefined;
var x18: u32 = undefined;
mulxU32(&x17, &x18, x11, 0xd2253531);
var x19: u32 = undefined;
var x20: u32 = undefined;
mulxU32(&x19, &x20, x17, 0xffffffff);
var x21: u32 = undefined;
var x22: u32 = undefined;
mulxU32(&x21, &x22, x17, 0xffffffff);
var x23: u32 = undefined;
var x24: u32 = undefined;
mulxU32(&x23, &x24, x17, 0xffffffff);
var x25: u32 = undefined;
var x26: u32 = undefined;
mulxU32(&x25, &x26, x17, 0xffffffff);
var x27: u32 = undefined;
var x28: u32 = undefined;
mulxU32(&x27, &x28, x17, 0xffffffff);
var x29: u32 = undefined;
var x30: u32 = undefined;
mulxU32(&x29, &x30, x17, 0xffffffff);
var x31: u32 = undefined;
var x32: u32 = undefined;
mulxU32(&x31, &x32, x17, 0xfffffffe);
var x33: u32 = undefined;
var x34: u32 = undefined;
mulxU32(&x33, &x34, x17, 0xfffffc2f);
var x35: u32 = undefined;
var x36: u1 = undefined;
addcarryxU32(&x35, &x36, 0x0, x34, x31);
var x37: u32 = undefined;
var x38: u1 = undefined;
addcarryxU32(&x37, &x38, x36, x32, x29);
var x39: u32 = undefined;
var x40: u1 = undefined;
addcarryxU32(&x39, &x40, x38, x30, x27);
var x41: u32 = undefined;
var x42: u1 = undefined;
addcarryxU32(&x41, &x42, x40, x28, x25);
var x43: u32 = undefined;
var x44: u1 = undefined;
addcarryxU32(&x43, &x44, x42, x26, x23);
var x45: u32 = undefined;
var x46: u1 = undefined;
addcarryxU32(&x45, &x46, x44, x24, x21);
var x47: u32 = undefined;
var x48: u1 = undefined;
addcarryxU32(&x47, &x48, x46, x22, x19);
var x49: u32 = undefined;
var x50: u1 = undefined;
addcarryxU32(&x49, &x50, 0x0, x11, x33);
var x51: u32 = undefined;
var x52: u1 = undefined;
addcarryxU32(&x51, &x52, x50, x13, x35);
var x53: u32 = undefined;
var x54: u1 = undefined;
addcarryxU32(&x53, &x54, x52, x15, x37);
var x55: u32 = undefined;
var x56: u1 = undefined;
addcarryxU32(&x55, &x56, x54, cast(u32, x16), x39);
var x57: u32 = undefined;
var x58: u1 = undefined;
addcarryxU32(&x57, &x58, x56, cast(u32, 0x0), x41);
var x59: u32 = undefined;
var x60: u1 = undefined;
addcarryxU32(&x59, &x60, x58, cast(u32, 0x0), x43);
var x61: u32 = undefined;
var x62: u1 = undefined;
addcarryxU32(&x61, &x62, x60, cast(u32, 0x0), x45);
var x63: u32 = undefined;
var x64: u1 = undefined;
addcarryxU32(&x63, &x64, x62, cast(u32, 0x0), x47);
var x65: u32 = undefined;
var x66: u1 = undefined;
addcarryxU32(&x65, &x66, x64, cast(u32, 0x0), (cast(u32, x48) + x20));
var x67: u32 = undefined;
var x68: u32 = undefined;
mulxU32(&x67, &x68, x1, 0x7a2);
var x69: u32 = undefined;
var x70: u32 = undefined;
mulxU32(&x69, &x70, x1, 0xe90a1);
var x71: u32 = undefined;
var x72: u1 = undefined;
addcarryxU32(&x71, &x72, 0x0, x70, x67);
var x73: u32 = undefined;
var x74: u1 = undefined;
addcarryxU32(&x73, &x74, x72, x68, x1);
var x75: u32 = undefined;
var x76: u1 = undefined;
addcarryxU32(&x75, &x76, 0x0, x51, x69);
var x77: u32 = undefined;
var x78: u1 = undefined;
addcarryxU32(&x77, &x78, x76, x53, x71);
var x79: u32 = undefined;
var x80: u1 = undefined;
addcarryxU32(&x79, &x80, x78, x55, x73);
var x81: u32 = undefined;
var x82: u1 = undefined;
addcarryxU32(&x81, &x82, x80, x57, cast(u32, x74));
var x83: u32 = undefined;
var x84: u1 = undefined;
addcarryxU32(&x83, &x84, x82, x59, cast(u32, 0x0));
var x85: u32 = undefined;
var x86: u1 = undefined;
addcarryxU32(&x85, &x86, x84, x61, cast(u32, 0x0));
var x87: u32 = undefined;
var x88: u1 = undefined;
addcarryxU32(&x87, &x88, x86, x63, cast(u32, 0x0));
var x89: u32 = undefined;
var x90: u1 = undefined;
addcarryxU32(&x89, &x90, x88, x65, cast(u32, 0x0));
var x91: u32 = undefined;
var x92: u32 = undefined;
mulxU32(&x91, &x92, x75, 0xd2253531);
var x93: u32 = undefined;
var x94: u32 = undefined;
mulxU32(&x93, &x94, x91, 0xffffffff);
var x95: u32 = undefined;
var x96: u32 = undefined;
mulxU32(&x95, &x96, x91, 0xffffffff);
var x97: u32 = undefined;
var x98: u32 = undefined;
mulxU32(&x97, &x98, x91, 0xffffffff);
var x99: u32 = undefined;
var x100: u32 = undefined;
mulxU32(&x99, &x100, x91, 0xffffffff);
var x101: u32 = undefined;
var x102: u32 = undefined;
mulxU32(&x101, &x102, x91, 0xffffffff);
var x103: u32 = undefined;
var x104: u32 = undefined;
mulxU32(&x103, &x104, x91, 0xffffffff);
var x105: u32 = undefined;
var x106: u32 = undefined;
mulxU32(&x105, &x106, x91, 0xfffffffe);
var x107: u32 = undefined;
var x108: u32 = undefined;
mulxU32(&x107, &x108, x91, 0xfffffc2f);
var x109: u32 = undefined;
var x110: u1 = undefined;
addcarryxU32(&x109, &x110, 0x0, x108, x105);
var x111: u32 = undefined;
var x112: u1 = undefined;
addcarryxU32(&x111, &x112, x110, x106, x103);
var x113: u32 = undefined;
var x114: u1 = undefined;
addcarryxU32(&x113, &x114, x112, x104, x101);
var x115: u32 = undefined;
var x116: u1 = undefined;
addcarryxU32(&x115, &x116, x114, x102, x99);
var x117: u32 = undefined;
var x118: u1 = undefined;
addcarryxU32(&x117, &x118, x116, x100, x97);
var x119: u32 = undefined;
var x120: u1 = undefined;
addcarryxU32(&x119, &x120, x118, x98, x95);
var x121: u32 = undefined;
var x122: u1 = undefined;
addcarryxU32(&x121, &x122, x120, x96, x93);
var x123: u32 = undefined;
var x124: u1 = undefined;
addcarryxU32(&x123, &x124, 0x0, x75, x107);
var x125: u32 = undefined;
var x126: u1 = undefined;
addcarryxU32(&x125, &x126, x124, x77, x109);
var x127: u32 = undefined;
var x128: u1 = undefined;
addcarryxU32(&x127, &x128, x126, x79, x111);
var x129: u32 = undefined;
var x130: u1 = undefined;
addcarryxU32(&x129, &x130, x128, x81, x113);
var x131: u32 = undefined;
var x132: u1 = undefined;
addcarryxU32(&x131, &x132, x130, x83, x115);
var x133: u32 = undefined;
var x134: u1 = undefined;
addcarryxU32(&x133, &x134, x132, x85, x117);
var x135: u32 = undefined;
var x136: u1 = undefined;
addcarryxU32(&x135, &x136, x134, x87, x119);
var x137: u32 = undefined;
var x138: u1 = undefined;
addcarryxU32(&x137, &x138, x136, x89, x121);
var x139: u32 = undefined;
var x140: u1 = undefined;
addcarryxU32(&x139, &x140, x138, (cast(u32, x90) + cast(u32, x66)), (cast(u32, x122) + x94));
var x141: u32 = undefined;
var x142: u32 = undefined;
mulxU32(&x141, &x142, x2, 0x7a2);
var x143: u32 = undefined;
var x144: u32 = undefined;
mulxU32(&x143, &x144, x2, 0xe90a1);
var x145: u32 = undefined;
var x146: u1 = undefined;
addcarryxU32(&x145, &x146, 0x0, x144, x141);
var x147: u32 = undefined;
var x148: u1 = undefined;
addcarryxU32(&x147, &x148, x146, x142, x2);
var x149: u32 = undefined;
var x150: u1 = undefined;
addcarryxU32(&x149, &x150, 0x0, x125, x143);
var x151: u32 = undefined;
var x152: u1 = undefined;
addcarryxU32(&x151, &x152, x150, x127, x145);
var x153: u32 = undefined;
var x154: u1 = undefined;
addcarryxU32(&x153, &x154, x152, x129, x147);
var x155: u32 = undefined;
var x156: u1 = undefined;
addcarryxU32(&x155, &x156, x154, x131, cast(u32, x148));
var x157: u32 = undefined;
var x158: u1 = undefined;
addcarryxU32(&x157, &x158, x156, x133, cast(u32, 0x0));
var x159: u32 = undefined;
var x160: u1 = undefined;
addcarryxU32(&x159, &x160, x158, x135, cast(u32, 0x0));
var x161: u32 = undefined;
var x162: u1 = undefined;
addcarryxU32(&x161, &x162, x160, x137, cast(u32, 0x0));
var x163: u32 = undefined;
var x164: u1 = undefined;
addcarryxU32(&x163, &x164, x162, x139, cast(u32, 0x0));
var x165: u32 = undefined;
var x166: u32 = undefined;
mulxU32(&x165, &x166, x149, 0xd2253531);
var x167: u32 = undefined;
var x168: u32 = undefined;
mulxU32(&x167, &x168, x165, 0xffffffff);
var x169: u32 = undefined;
var x170: u32 = undefined;
mulxU32(&x169, &x170, x165, 0xffffffff);
var x171: u32 = undefined;
var x172: u32 = undefined;
mulxU32(&x171, &x172, x165, 0xffffffff);
var x173: u32 = undefined;
var x174: u32 = undefined;
mulxU32(&x173, &x174, x165, 0xffffffff);
var x175: u32 = undefined;
var x176: u32 = undefined;
mulxU32(&x175, &x176, x165, 0xffffffff);
var x177: u32 = undefined;
var x178: u32 = undefined;
mulxU32(&x177, &x178, x165, 0xffffffff);
var x179: u32 = undefined;
var x180: u32 = undefined;
mulxU32(&x179, &x180, x165, 0xfffffffe);
var x181: u32 = undefined;
var x182: u32 = undefined;
mulxU32(&x181, &x182, x165, 0xfffffc2f);
var x183: u32 = undefined;
var x184: u1 = undefined;
addcarryxU32(&x183, &x184, 0x0, x182, x179);
var x185: u32 = undefined;
var x186: u1 = undefined;
addcarryxU32(&x185, &x186, x184, x180, x177);
var x187: u32 = undefined;
var x188: u1 = undefined;
addcarryxU32(&x187, &x188, x186, x178, x175);
var x189: u32 = undefined;
var x190: u1 = undefined;
addcarryxU32(&x189, &x190, x188, x176, x173);
var x191: u32 = undefined;
var x192: u1 = undefined;
addcarryxU32(&x191, &x192, x190, x174, x171);
var x193: u32 = undefined;
var x194: u1 = undefined;
addcarryxU32(&x193, &x194, x192, x172, x169);
var x195: u32 = undefined;
var x196: u1 = undefined;
addcarryxU32(&x195, &x196, x194, x170, x167);
var x197: u32 = undefined;
var x198: u1 = undefined;
addcarryxU32(&x197, &x198, 0x0, x149, x181);
var x199: u32 = undefined;
var x200: u1 = undefined;
addcarryxU32(&x199, &x200, x198, x151, x183);
var x201: u32 = undefined;
var x202: u1 = undefined;
addcarryxU32(&x201, &x202, x200, x153, x185);
var x203: u32 = undefined;
var x204: u1 = undefined;
addcarryxU32(&x203, &x204, x202, x155, x187);
var x205: u32 = undefined;
var x206: u1 = undefined;
addcarryxU32(&x205, &x206, x204, x157, x189);
var x207: u32 = undefined;
var x208: u1 = undefined;
addcarryxU32(&x207, &x208, x206, x159, x191);
var x209: u32 = undefined;
var x210: u1 = undefined;
addcarryxU32(&x209, &x210, x208, x161, x193);
var x211: u32 = undefined;
var x212: u1 = undefined;
addcarryxU32(&x211, &x212, x210, x163, x195);
var x213: u32 = undefined;
var x214: u1 = undefined;
addcarryxU32(&x213, &x214, x212, (cast(u32, x164) + cast(u32, x140)), (cast(u32, x196) + x168));
var x215: u32 = undefined;
var x216: u32 = undefined;
mulxU32(&x215, &x216, x3, 0x7a2);
var x217: u32 = undefined;
var x218: u32 = undefined;
mulxU32(&x217, &x218, x3, 0xe90a1);
var x219: u32 = undefined;
var x220: u1 = undefined;
addcarryxU32(&x219, &x220, 0x0, x218, x215);
var x221: u32 = undefined;
var x222: u1 = undefined;
addcarryxU32(&x221, &x222, x220, x216, x3);
var x223: u32 = undefined;
var x224: u1 = undefined;
addcarryxU32(&x223, &x224, 0x0, x199, x217);
var x225: u32 = undefined;
var x226: u1 = undefined;
addcarryxU32(&x225, &x226, x224, x201, x219);
var x227: u32 = undefined;
var x228: u1 = undefined;
addcarryxU32(&x227, &x228, x226, x203, x221);
var x229: u32 = undefined;
var x230: u1 = undefined;
addcarryxU32(&x229, &x230, x228, x205, cast(u32, x222));
var x231: u32 = undefined;
var x232: u1 = undefined;
addcarryxU32(&x231, &x232, x230, x207, cast(u32, 0x0));
var x233: u32 = undefined;
var x234: u1 = undefined;
addcarryxU32(&x233, &x234, x232, x209, cast(u32, 0x0));
var x235: u32 = undefined;
var x236: u1 = undefined;
addcarryxU32(&x235, &x236, x234, x211, cast(u32, 0x0));
var x237: u32 = undefined;
var x238: u1 = undefined;
addcarryxU32(&x237, &x238, x236, x213, cast(u32, 0x0));
var x239: u32 = undefined;
var x240: u32 = undefined;
mulxU32(&x239, &x240, x223, 0xd2253531);
var x241: u32 = undefined;
var x242: u32 = undefined;
mulxU32(&x241, &x242, x239, 0xffffffff);
var x243: u32 = undefined;
var x244: u32 = undefined;
mulxU32(&x243, &x244, x239, 0xffffffff);
var x245: u32 = undefined;
var x246: u32 = undefined;
mulxU32(&x245, &x246, x239, 0xffffffff);
var x247: u32 = undefined;
var x248: u32 = undefined;
mulxU32(&x247, &x248, x239, 0xffffffff);
var x249: u32 = undefined;
var x250: u32 = undefined;
mulxU32(&x249, &x250, x239, 0xffffffff);
var x251: u32 = undefined;
var x252: u32 = undefined;
mulxU32(&x251, &x252, x239, 0xffffffff);
var x253: u32 = undefined;
var x254: u32 = undefined;
mulxU32(&x253, &x254, x239, 0xfffffffe);
var x255: u32 = undefined;
var x256: u32 = undefined;
mulxU32(&x255, &x256, x239, 0xfffffc2f);
var x257: u32 = undefined;
var x258: u1 = undefined;
addcarryxU32(&x257, &x258, 0x0, x256, x253);
var x259: u32 = undefined;
var x260: u1 = undefined;
addcarryxU32(&x259, &x260, x258, x254, x251);
var x261: u32 = undefined;
var x262: u1 = undefined;
addcarryxU32(&x261, &x262, x260, x252, x249);
var x263: u32 = undefined;
var x264: u1 = undefined;
addcarryxU32(&x263, &x264, x262, x250, x247);
var x265: u32 = undefined;
var x266: u1 = undefined;
addcarryxU32(&x265, &x266, x264, x248, x245);
var x267: u32 = undefined;
var x268: u1 = undefined;
addcarryxU32(&x267, &x268, x266, x246, x243);
var x269: u32 = undefined;
var x270: u1 = undefined;
addcarryxU32(&x269, &x270, x268, x244, x241);
var x271: u32 = undefined;
var x272: u1 = undefined;
addcarryxU32(&x271, &x272, 0x0, x223, x255);
var x273: u32 = undefined;
var x274: u1 = undefined;
addcarryxU32(&x273, &x274, x272, x225, x257);
var x275: u32 = undefined;
var x276: u1 = undefined;
addcarryxU32(&x275, &x276, x274, x227, x259);
var x277: u32 = undefined;
var x278: u1 = undefined;
addcarryxU32(&x277, &x278, x276, x229, x261);
var x279: u32 = undefined;
var x280: u1 = undefined;
addcarryxU32(&x279, &x280, x278, x231, x263);
var x281: u32 = undefined;
var x282: u1 = undefined;
addcarryxU32(&x281, &x282, x280, x233, x265);
var x283: u32 = undefined;
var x284: u1 = undefined;
addcarryxU32(&x283, &x284, x282, x235, x267);
var x285: u32 = undefined;
var x286: u1 = undefined;
addcarryxU32(&x285, &x286, x284, x237, x269);
var x287: u32 = undefined;
var x288: u1 = undefined;
addcarryxU32(&x287, &x288, x286, (cast(u32, x238) + cast(u32, x214)), (cast(u32, x270) + x242));
var x289: u32 = undefined;
var x290: u32 = undefined;
mulxU32(&x289, &x290, x4, 0x7a2);
var x291: u32 = undefined;
var x292: u32 = undefined;
mulxU32(&x291, &x292, x4, 0xe90a1);
var x293: u32 = undefined;
var x294: u1 = undefined;
addcarryxU32(&x293, &x294, 0x0, x292, x289);
var x295: u32 = undefined;
var x296: u1 = undefined;
addcarryxU32(&x295, &x296, x294, x290, x4);
var x297: u32 = undefined;
var x298: u1 = undefined;
addcarryxU32(&x297, &x298, 0x0, x273, x291);
var x299: u32 = undefined;
var x300: u1 = undefined;
addcarryxU32(&x299, &x300, x298, x275, x293);
var x301: u32 = undefined;
var x302: u1 = undefined;
addcarryxU32(&x301, &x302, x300, x277, x295);
var x303: u32 = undefined;
var x304: u1 = undefined;
addcarryxU32(&x303, &x304, x302, x279, cast(u32, x296));
var x305: u32 = undefined;
var x306: u1 = undefined;
addcarryxU32(&x305, &x306, x304, x281, cast(u32, 0x0));
var x307: u32 = undefined;
var x308: u1 = undefined;
addcarryxU32(&x307, &x308, x306, x283, cast(u32, 0x0));
var x309: u32 = undefined;
var x310: u1 = undefined;
addcarryxU32(&x309, &x310, x308, x285, cast(u32, 0x0));
var x311: u32 = undefined;
var x312: u1 = undefined;
addcarryxU32(&x311, &x312, x310, x287, cast(u32, 0x0));
var x313: u32 = undefined;
var x314: u32 = undefined;
mulxU32(&x313, &x314, x297, 0xd2253531);
var x315: u32 = undefined;
var x316: u32 = undefined;
mulxU32(&x315, &x316, x313, 0xffffffff);
var x317: u32 = undefined;
var x318: u32 = undefined;
mulxU32(&x317, &x318, x313, 0xffffffff);
var x319: u32 = undefined;
var x320: u32 = undefined;
mulxU32(&x319, &x320, x313, 0xffffffff);
var x321: u32 = undefined;
var x322: u32 = undefined;
mulxU32(&x321, &x322, x313, 0xffffffff);
var x323: u32 = undefined;
var x324: u32 = undefined;
mulxU32(&x323, &x324, x313, 0xffffffff);
var x325: u32 = undefined;
var x326: u32 = undefined;
mulxU32(&x325, &x326, x313, 0xffffffff);
var x327: u32 = undefined;
var x328: u32 = undefined;
mulxU32(&x327, &x328, x313, 0xfffffffe);
var x329: u32 = undefined;
var x330: u32 = undefined;
mulxU32(&x329, &x330, x313, 0xfffffc2f);
var x331: u32 = undefined;
var x332: u1 = undefined;
addcarryxU32(&x331, &x332, 0x0, x330, x327);
var x333: u32 = undefined;
var x334: u1 = undefined;
addcarryxU32(&x333, &x334, x332, x328, x325);
var x335: u32 = undefined;
var x336: u1 = undefined;
addcarryxU32(&x335, &x336, x334, x326, x323);
var x337: u32 = undefined;
var x338: u1 = undefined;
addcarryxU32(&x337, &x338, x336, x324, x321);
var x339: u32 = undefined;
var x340: u1 = undefined;
addcarryxU32(&x339, &x340, x338, x322, x319);
var x341: u32 = undefined;
var x342: u1 = undefined;
addcarryxU32(&x341, &x342, x340, x320, x317);
var x343: u32 = undefined;
var x344: u1 = undefined;
addcarryxU32(&x343, &x344, x342, x318, x315);
var x345: u32 = undefined;
var x346: u1 = undefined;
addcarryxU32(&x345, &x346, 0x0, x297, x329);
var x347: u32 = undefined;
var x348: u1 = undefined;
addcarryxU32(&x347, &x348, x346, x299, x331);
var x349: u32 = undefined;
var x350: u1 = undefined;
addcarryxU32(&x349, &x350, x348, x301, x333);
var x351: u32 = undefined;
var x352: u1 = undefined;
addcarryxU32(&x351, &x352, x350, x303, x335);
var x353: u32 = undefined;
var x354: u1 = undefined;
addcarryxU32(&x353, &x354, x352, x305, x337);
var x355: u32 = undefined;
var x356: u1 = undefined;
addcarryxU32(&x355, &x356, x354, x307, x339);
var x357: u32 = undefined;
var x358: u1 = undefined;
addcarryxU32(&x357, &x358, x356, x309, x341);
var x359: u32 = undefined;
var x360: u1 = undefined;
addcarryxU32(&x359, &x360, x358, x311, x343);
var x361: u32 = undefined;
var x362: u1 = undefined;
addcarryxU32(&x361, &x362, x360, (cast(u32, x312) + cast(u32, x288)), (cast(u32, x344) + x316));
var x363: u32 = undefined;
var x364: u32 = undefined;
mulxU32(&x363, &x364, x5, 0x7a2);
var x365: u32 = undefined;
var x366: u32 = undefined;
mulxU32(&x365, &x366, x5, 0xe90a1);
var x367: u32 = undefined;
var x368: u1 = undefined;
addcarryxU32(&x367, &x368, 0x0, x366, x363);
var x369: u32 = undefined;
var x370: u1 = undefined;
addcarryxU32(&x369, &x370, x368, x364, x5);
var x371: u32 = undefined;
var x372: u1 = undefined;
addcarryxU32(&x371, &x372, 0x0, x347, x365);
var x373: u32 = undefined;
var x374: u1 = undefined;
addcarryxU32(&x373, &x374, x372, x349, x367);
var x375: u32 = undefined;
var x376: u1 = undefined;
addcarryxU32(&x375, &x376, x374, x351, x369);
var x377: u32 = undefined;
var x378: u1 = undefined;
addcarryxU32(&x377, &x378, x376, x353, cast(u32, x370));
var x379: u32 = undefined;
var x380: u1 = undefined;
addcarryxU32(&x379, &x380, x378, x355, cast(u32, 0x0));
var x381: u32 = undefined;
var x382: u1 = undefined;
addcarryxU32(&x381, &x382, x380, x357, cast(u32, 0x0));
var x383: u32 = undefined;
var x384: u1 = undefined;
addcarryxU32(&x383, &x384, x382, x359, cast(u32, 0x0));
var x385: u32 = undefined;
var x386: u1 = undefined;
addcarryxU32(&x385, &x386, x384, x361, cast(u32, 0x0));
var x387: u32 = undefined;
var x388: u32 = undefined;
mulxU32(&x387, &x388, x371, 0xd2253531);
var x389: u32 = undefined;
var x390: u32 = undefined;
mulxU32(&x389, &x390, x387, 0xffffffff);
var x391: u32 = undefined;
var x392: u32 = undefined;
mulxU32(&x391, &x392, x387, 0xffffffff);
var x393: u32 = undefined;
var x394: u32 = undefined;
mulxU32(&x393, &x394, x387, 0xffffffff);
var x395: u32 = undefined;
var x396: u32 = undefined;
mulxU32(&x395, &x396, x387, 0xffffffff);
var x397: u32 = undefined;
var x398: u32 = undefined;
mulxU32(&x397, &x398, x387, 0xffffffff);
var x399: u32 = undefined;
var x400: u32 = undefined;
mulxU32(&x399, &x400, x387, 0xffffffff);
var x401: u32 = undefined;
var x402: u32 = undefined;
mulxU32(&x401, &x402, x387, 0xfffffffe);
var x403: u32 = undefined;
var x404: u32 = undefined;
mulxU32(&x403, &x404, x387, 0xfffffc2f);
var x405: u32 = undefined;
var x406: u1 = undefined;
addcarryxU32(&x405, &x406, 0x0, x404, x401);
var x407: u32 = undefined;
var x408: u1 = undefined;
addcarryxU32(&x407, &x408, x406, x402, x399);
var x409: u32 = undefined;
var x410: u1 = undefined;
addcarryxU32(&x409, &x410, x408, x400, x397);
var x411: u32 = undefined;
var x412: u1 = undefined;
addcarryxU32(&x411, &x412, x410, x398, x395);
var x413: u32 = undefined;
var x414: u1 = undefined;
addcarryxU32(&x413, &x414, x412, x396, x393);
var x415: u32 = undefined;
var x416: u1 = undefined;
addcarryxU32(&x415, &x416, x414, x394, x391);
var x417: u32 = undefined;
var x418: u1 = undefined;
addcarryxU32(&x417, &x418, x416, x392, x389);
var x419: u32 = undefined;
var x420: u1 = undefined;
addcarryxU32(&x419, &x420, 0x0, x371, x403);
var x421: u32 = undefined;
var x422: u1 = undefined;
addcarryxU32(&x421, &x422, x420, x373, x405);
var x423: u32 = undefined;
var x424: u1 = undefined;
addcarryxU32(&x423, &x424, x422, x375, x407);
var x425: u32 = undefined;
var x426: u1 = undefined;
addcarryxU32(&x425, &x426, x424, x377, x409);
var x427: u32 = undefined;
var x428: u1 = undefined;
addcarryxU32(&x427, &x428, x426, x379, x411);
var x429: u32 = undefined;
var x430: u1 = undefined;
addcarryxU32(&x429, &x430, x428, x381, x413);
var x431: u32 = undefined;
var x432: u1 = undefined;
addcarryxU32(&x431, &x432, x430, x383, x415);
var x433: u32 = undefined;
var x434: u1 = undefined;
addcarryxU32(&x433, &x434, x432, x385, x417);
var x435: u32 = undefined;
var x436: u1 = undefined;
addcarryxU32(&x435, &x436, x434, (cast(u32, x386) + cast(u32, x362)), (cast(u32, x418) + x390));
var x437: u32 = undefined;
var x438: u32 = undefined;
mulxU32(&x437, &x438, x6, 0x7a2);
var x439: u32 = undefined;
var x440: u32 = undefined;
mulxU32(&x439, &x440, x6, 0xe90a1);
var x441: u32 = undefined;
var x442: u1 = undefined;
addcarryxU32(&x441, &x442, 0x0, x440, x437);
var x443: u32 = undefined;
var x444: u1 = undefined;
addcarryxU32(&x443, &x444, x442, x438, x6);
var x445: u32 = undefined;
var x446: u1 = undefined;
addcarryxU32(&x445, &x446, 0x0, x421, x439);
var x447: u32 = undefined;
var x448: u1 = undefined;
addcarryxU32(&x447, &x448, x446, x423, x441);
var x449: u32 = undefined;
var x450: u1 = undefined;
addcarryxU32(&x449, &x450, x448, x425, x443);
var x451: u32 = undefined;
var x452: u1 = undefined;
addcarryxU32(&x451, &x452, x450, x427, cast(u32, x444));
var x453: u32 = undefined;
var x454: u1 = undefined;
addcarryxU32(&x453, &x454, x452, x429, cast(u32, 0x0));
var x455: u32 = undefined;
var x456: u1 = undefined;
addcarryxU32(&x455, &x456, x454, x431, cast(u32, 0x0));
var x457: u32 = undefined;
var x458: u1 = undefined;
addcarryxU32(&x457, &x458, x456, x433, cast(u32, 0x0));
var x459: u32 = undefined;
var x460: u1 = undefined;
addcarryxU32(&x459, &x460, x458, x435, cast(u32, 0x0));
var x461: u32 = undefined;
var x462: u32 = undefined;
mulxU32(&x461, &x462, x445, 0xd2253531);
var x463: u32 = undefined;
var x464: u32 = undefined;
mulxU32(&x463, &x464, x461, 0xffffffff);
var x465: u32 = undefined;
var x466: u32 = undefined;
mulxU32(&x465, &x466, x461, 0xffffffff);
var x467: u32 = undefined;
var x468: u32 = undefined;
mulxU32(&x467, &x468, x461, 0xffffffff);
var x469: u32 = undefined;
var x470: u32 = undefined;
mulxU32(&x469, &x470, x461, 0xffffffff);
var x471: u32 = undefined;
var x472: u32 = undefined;
mulxU32(&x471, &x472, x461, 0xffffffff);
var x473: u32 = undefined;
var x474: u32 = undefined;
mulxU32(&x473, &x474, x461, 0xffffffff);
var x475: u32 = undefined;
var x476: u32 = undefined;
mulxU32(&x475, &x476, x461, 0xfffffffe);
var x477: u32 = undefined;
var x478: u32 = undefined;
mulxU32(&x477, &x478, x461, 0xfffffc2f);
var x479: u32 = undefined;
var x480: u1 = undefined;
addcarryxU32(&x479, &x480, 0x0, x478, x475);
var x481: u32 = undefined;
var x482: u1 = undefined;
addcarryxU32(&x481, &x482, x480, x476, x473);
var x483: u32 = undefined;
var x484: u1 = undefined;
addcarryxU32(&x483, &x484, x482, x474, x471);
var x485: u32 = undefined;
var x486: u1 = undefined;
addcarryxU32(&x485, &x486, x484, x472, x469);
var x487: u32 = undefined;
var x488: u1 = undefined;
addcarryxU32(&x487, &x488, x486, x470, x467);
var x489: u32 = undefined;
var x490: u1 = undefined;
addcarryxU32(&x489, &x490, x488, x468, x465);
var x491: u32 = undefined;
var x492: u1 = undefined;
addcarryxU32(&x491, &x492, x490, x466, x463);
var x493: u32 = undefined;
var x494: u1 = undefined;
addcarryxU32(&x493, &x494, 0x0, x445, x477);
var x495: u32 = undefined;
var x496: u1 = undefined;
addcarryxU32(&x495, &x496, x494, x447, x479);
var x497: u32 = undefined;
var x498: u1 = undefined;
addcarryxU32(&x497, &x498, x496, x449, x481);
var x499: u32 = undefined;
var x500: u1 = undefined;
addcarryxU32(&x499, &x500, x498, x451, x483);
var x501: u32 = undefined;
var x502: u1 = undefined;
addcarryxU32(&x501, &x502, x500, x453, x485);
var x503: u32 = undefined;
var x504: u1 = undefined;
addcarryxU32(&x503, &x504, x502, x455, x487);
var x505: u32 = undefined;
var x506: u1 = undefined;
addcarryxU32(&x505, &x506, x504, x457, x489);
var x507: u32 = undefined;
var x508: u1 = undefined;
addcarryxU32(&x507, &x508, x506, x459, x491);
var x509: u32 = undefined;
var x510: u1 = undefined;
addcarryxU32(&x509, &x510, x508, (cast(u32, x460) + cast(u32, x436)), (cast(u32, x492) + x464));
var x511: u32 = undefined;
var x512: u32 = undefined;
mulxU32(&x511, &x512, x7, 0x7a2);
var x513: u32 = undefined;
var x514: u32 = undefined;
mulxU32(&x513, &x514, x7, 0xe90a1);
var x515: u32 = undefined;
var x516: u1 = undefined;
addcarryxU32(&x515, &x516, 0x0, x514, x511);
var x517: u32 = undefined;
var x518: u1 = undefined;
addcarryxU32(&x517, &x518, x516, x512, x7);
var x519: u32 = undefined;
var x520: u1 = undefined;
addcarryxU32(&x519, &x520, 0x0, x495, x513);
var x521: u32 = undefined;
var x522: u1 = undefined;
addcarryxU32(&x521, &x522, x520, x497, x515);
var x523: u32 = undefined;
var x524: u1 = undefined;
addcarryxU32(&x523, &x524, x522, x499, x517);
var x525: u32 = undefined;
var x526: u1 = undefined;
addcarryxU32(&x525, &x526, x524, x501, cast(u32, x518));
var x527: u32 = undefined;
var x528: u1 = undefined;
addcarryxU32(&x527, &x528, x526, x503, cast(u32, 0x0));
var x529: u32 = undefined;
var x530: u1 = undefined;
addcarryxU32(&x529, &x530, x528, x505, cast(u32, 0x0));
var x531: u32 = undefined;
var x532: u1 = undefined;
addcarryxU32(&x531, &x532, x530, x507, cast(u32, 0x0));
var x533: u32 = undefined;
var x534: u1 = undefined;
addcarryxU32(&x533, &x534, x532, x509, cast(u32, 0x0));
var x535: u32 = undefined;
var x536: u32 = undefined;
mulxU32(&x535, &x536, x519, 0xd2253531);
var x537: u32 = undefined;
var x538: u32 = undefined;
mulxU32(&x537, &x538, x535, 0xffffffff);
var x539: u32 = undefined;
var x540: u32 = undefined;
mulxU32(&x539, &x540, x535, 0xffffffff);
var x541: u32 = undefined;
var x542: u32 = undefined;
mulxU32(&x541, &x542, x535, 0xffffffff);
var x543: u32 = undefined;
var x544: u32 = undefined;
mulxU32(&x543, &x544, x535, 0xffffffff);
var x545: u32 = undefined;
var x546: u32 = undefined;
mulxU32(&x545, &x546, x535, 0xffffffff);
var x547: u32 = undefined;
var x548: u32 = undefined;
mulxU32(&x547, &x548, x535, 0xffffffff);
var x549: u32 = undefined;
var x550: u32 = undefined;
mulxU32(&x549, &x550, x535, 0xfffffffe);
var x551: u32 = undefined;
var x552: u32 = undefined;
mulxU32(&x551, &x552, x535, 0xfffffc2f);
var x553: u32 = undefined;
var x554: u1 = undefined;
addcarryxU32(&x553, &x554, 0x0, x552, x549);
var x555: u32 = undefined;
var x556: u1 = undefined;
addcarryxU32(&x555, &x556, x554, x550, x547);
var x557: u32 = undefined;
var x558: u1 = undefined;
addcarryxU32(&x557, &x558, x556, x548, x545);
var x559: u32 = undefined;
var x560: u1 = undefined;
addcarryxU32(&x559, &x560, x558, x546, x543);
var x561: u32 = undefined;
var x562: u1 = undefined;
addcarryxU32(&x561, &x562, x560, x544, x541);
var x563: u32 = undefined;
var x564: u1 = undefined;
addcarryxU32(&x563, &x564, x562, x542, x539);
var x565: u32 = undefined;
var x566: u1 = undefined;
addcarryxU32(&x565, &x566, x564, x540, x537);
var x567: u32 = undefined;
var x568: u1 = undefined;
addcarryxU32(&x567, &x568, 0x0, x519, x551);
var x569: u32 = undefined;
var x570: u1 = undefined;
addcarryxU32(&x569, &x570, x568, x521, x553);
var x571: u32 = undefined;
var x572: u1 = undefined;
addcarryxU32(&x571, &x572, x570, x523, x555);
var x573: u32 = undefined;
var x574: u1 = undefined;
addcarryxU32(&x573, &x574, x572, x525, x557);
var x575: u32 = undefined;
var x576: u1 = undefined;
addcarryxU32(&x575, &x576, x574, x527, x559);
var x577: u32 = undefined;
var x578: u1 = undefined;
addcarryxU32(&x577, &x578, x576, x529, x561);
var x579: u32 = undefined;
var x580: u1 = undefined;
addcarryxU32(&x579, &x580, x578, x531, x563);
var x581: u32 = undefined;
var x582: u1 = undefined;
addcarryxU32(&x581, &x582, x580, x533, x565);
var x583: u32 = undefined;
var x584: u1 = undefined;
addcarryxU32(&x583, &x584, x582, (cast(u32, x534) + cast(u32, x510)), (cast(u32, x566) + x538));
var x585: u32 = undefined;
var x586: u1 = undefined;
subborrowxU32(&x585, &x586, 0x0, x569, 0xfffffc2f);
var x587: u32 = undefined;
var x588: u1 = undefined;
subborrowxU32(&x587, &x588, x586, x571, 0xfffffffe);
var x589: u32 = undefined;
var x590: u1 = undefined;
subborrowxU32(&x589, &x590, x588, x573, 0xffffffff);
var x591: u32 = undefined;
var x592: u1 = undefined;
subborrowxU32(&x591, &x592, x590, x575, 0xffffffff);
var x593: u32 = undefined;
var x594: u1 = undefined;
subborrowxU32(&x593, &x594, x592, x577, 0xffffffff);
var x595: u32 = undefined;
var x596: u1 = undefined;
subborrowxU32(&x595, &x596, x594, x579, 0xffffffff);
var x597: u32 = undefined;
var x598: u1 = undefined;
subborrowxU32(&x597, &x598, x596, x581, 0xffffffff);
var x599: u32 = undefined;
var x600: u1 = undefined;
subborrowxU32(&x599, &x600, x598, x583, 0xffffffff);
var x601: u32 = undefined;
var x602: u1 = undefined;
subborrowxU32(&x601, &x602, x600, cast(u32, x584), cast(u32, 0x0));
var x603: u32 = undefined;
cmovznzU32(&x603, x602, x585, x569);
var x604: u32 = undefined;
cmovznzU32(&x604, x602, x587, x571);
var x605: u32 = undefined;
cmovznzU32(&x605, x602, x589, x573);
var x606: u32 = undefined;
cmovznzU32(&x606, x602, x591, x575);
var x607: u32 = undefined;
cmovznzU32(&x607, x602, x593, x577);
var x608: u32 = undefined;
cmovznzU32(&x608, x602, x595, x579);
var x609: u32 = undefined;
cmovznzU32(&x609, x602, x597, x581);
var x610: u32 = undefined;
cmovznzU32(&x610, x602, x599, x583);
out1[0] = x603;
out1[1] = x604;
out1[2] = x605;
out1[3] = x606;
out1[4] = x607;
out1[5] = x608;
out1[6] = x609;
out1[7] = x610;
}
/// 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 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
/// Output Bounds:
/// out1: [0x0 ~> 0xffffffff]
pub fn nonzero(out1: *u32, arg1: [8]u32) void {
@setRuntimeSafety(mode == .Debug);
const x1 = ((arg1[0]) | ((arg1[1]) | ((arg1[2]) | ((arg1[3]) | ((arg1[4]) | ((arg1[5]) | ((arg1[6]) | (arg1[7]))))))));
out1.* = x1;
}
/// The function selectznz is a multi-limb conditional select.
///
/// Postconditions:
/// eval out1 = (if arg1 = 0 then eval arg2 else eval arg3)
///
/// Input Bounds:
/// arg1: [0x0 ~> 0x1]
/// arg2: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
/// arg3: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
/// Output Bounds:
/// out1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
pub fn selectznz(out1: *[8]u32, arg1: u1, arg2: [8]u32, arg3: [8]u32) void {
@setRuntimeSafety(mode == .Debug);
var x1: u32 = undefined;
cmovznzU32(&x1, arg1, (arg2[0]), (arg3[0]));
var x2: u32 = undefined;
cmovznzU32(&x2, arg1, (arg2[1]), (arg3[1]));
var x3: u32 = undefined;
cmovznzU32(&x3, arg1, (arg2[2]), (arg3[2]));
var x4: u32 = undefined;
cmovznzU32(&x4, arg1, (arg2[3]), (arg3[3]));
var x5: u32 = undefined;
cmovznzU32(&x5, arg1, (arg2[4]), (arg3[4]));
var x6: u32 = undefined;
cmovznzU32(&x6, arg1, (arg2[5]), (arg3[5]));
var x7: u32 = undefined;
cmovznzU32(&x7, arg1, (arg2[6]), (arg3[6]));
var x8: u32 = undefined;
cmovznzU32(&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 NOT in the Montgomery domain to bytes in little-endian order.
///
/// Preconditions:
/// 0 ≤ eval arg1 < m
/// Postconditions:
/// out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..31]
///
/// Input Bounds:
/// arg1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
/// Output Bounds:
/// out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]]
pub fn toBytes(out1: *[32]u8, arg1: [8]u32) void {
@setRuntimeSafety(mode == .Debug);
const x1 = (arg1[7]);
const x2 = (arg1[6]);
const x3 = (arg1[5]);
const x4 = (arg1[4]);
const x5 = (arg1[3]);
const x6 = (arg1[2]);
const x7 = (arg1[1]);
const x8 = (arg1[0]);
const x9 = cast(u8, (x8 & cast(u32, 0xff)));
const x10 = (x8 >> 8);
const x11 = cast(u8, (x10 & cast(u32, 0xff)));
const x12 = (x10 >> 8);
const x13 = cast(u8, (x12 & cast(u32, 0xff)));
const x14 = cast(u8, (x12 >> 8));
const x15 = cast(u8, (x7 & cast(u32, 0xff)));
const x16 = (x7 >> 8);
const x17 = cast(u8, (x16 & cast(u32, 0xff)));
const x18 = (x16 >> 8);
const x19 = cast(u8, (x18 & cast(u32, 0xff)));
const x20 = cast(u8, (x18 >> 8));
const x21 = cast(u8, (x6 & cast(u32, 0xff)));
const x22 = (x6 >> 8);
const x23 = cast(u8, (x22 & cast(u32, 0xff)));
const x24 = (x22 >> 8);
const x25 = cast(u8, (x24 & cast(u32, 0xff)));
const x26 = cast(u8, (x24 >> 8));
const x27 = cast(u8, (x5 & cast(u32, 0xff)));
const x28 = (x5 >> 8);
const x29 = cast(u8, (x28 & cast(u32, 0xff)));
const x30 = (x28 >> 8);
const x31 = cast(u8, (x30 & cast(u32, 0xff)));
const x32 = cast(u8, (x30 >> 8));
const x33 = cast(u8, (x4 & cast(u32, 0xff)));
const x34 = (x4 >> 8);
const x35 = cast(u8, (x34 & cast(u32, 0xff)));
const x36 = (x34 >> 8);
const x37 = cast(u8, (x36 & cast(u32, 0xff)));
const x38 = cast(u8, (x36 >> 8));
const x39 = cast(u8, (x3 & cast(u32, 0xff)));
const x40 = (x3 >> 8);
const x41 = cast(u8, (x40 & cast(u32, 0xff)));
const x42 = (x40 >> 8);
const x43 = cast(u8, (x42 & cast(u32, 0xff)));
const x44 = cast(u8, (x42 >> 8));
const x45 = cast(u8, (x2 & cast(u32, 0xff)));
const x46 = (x2 >> 8);
const x47 = cast(u8, (x46 & cast(u32, 0xff)));
const x48 = (x46 >> 8);
const x49 = cast(u8, (x48 & cast(u32, 0xff)));
const x50 = cast(u8, (x48 >> 8));
const x51 = cast(u8, (x1 & cast(u32, 0xff)));
const x52 = (x1 >> 8);
const x53 = cast(u8, (x52 & cast(u32, 0xff)));
const x54 = (x52 >> 8);
const x55 = cast(u8, (x54 & cast(u32, 0xff)));
const x56 = cast(u8, (x54 >> 8));
out1[0] = x9;
out1[1] = x11;
out1[2] = x13;
out1[3] = x14;
out1[4] = x15;
out1[5] = x17;
out1[6] = x19;
out1[7] = x20;
out1[8] = x21;
out1[9] = x23;
out1[10] = x25;
out1[11] = x26;
out1[12] = x27;
out1[13] = x29;
out1[14] = x31;
out1[15] = x32;
out1[16] = x33;
out1[17] = x35;
out1[18] = x37;
out1[19] = x38;
out1[20] = x39;
out1[21] = x41;
out1[22] = x43;
out1[23] = x44;
out1[24] = x45;
out1[25] = x47;
out1[26] = x49;
out1[27] = x50;
out1[28] = x51;
out1[29] = x53;
out1[30] = x55;
out1[31] = x56;
}
/// The function fromBytes deserializes a field element NOT in the Montgomery domain from bytes in little-endian order.
///
/// Preconditions:
/// 0 ≤ bytes_eval arg1 < m
/// Postconditions:
/// eval out1 mod m = bytes_eval arg1 mod m
/// 0 ≤ eval out1 < m
///
/// Input Bounds:
/// arg1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]]
/// Output Bounds:
/// out1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
pub fn fromBytes(out1: *[8]u32, arg1: [32]u8) void {
@setRuntimeSafety(mode == .Debug);
const x1 = (cast(u32, (arg1[31])) << 24);
const x2 = (cast(u32, (arg1[30])) << 16);
const x3 = (cast(u32, (arg1[29])) << 8);
const x4 = (arg1[28]);
const x5 = (cast(u32, (arg1[27])) << 24);
const x6 = (cast(u32, (arg1[26])) << 16);
const x7 = (cast(u32, (arg1[25])) << 8);
const x8 = (arg1[24]);
const x9 = (cast(u32, (arg1[23])) << 24);
const x10 = (cast(u32, (arg1[22])) << 16);
const x11 = (cast(u32, (arg1[21])) << 8);
const x12 = (arg1[20]);
const x13 = (cast(u32, (arg1[19])) << 24);
const x14 = (cast(u32, (arg1[18])) << 16);
const x15 = (cast(u32, (arg1[17])) << 8);
const x16 = (arg1[16]);
const x17 = (cast(u32, (arg1[15])) << 24);
const x18 = (cast(u32, (arg1[14])) << 16);
const x19 = (cast(u32, (arg1[13])) << 8);
const x20 = (arg1[12]);
const x21 = (cast(u32, (arg1[11])) << 24);
const x22 = (cast(u32, (arg1[10])) << 16);
const x23 = (cast(u32, (arg1[9])) << 8);
const x24 = (arg1[8]);
const x25 = (cast(u32, (arg1[7])) << 24);
const x26 = (cast(u32, (arg1[6])) << 16);
const x27 = (cast(u32, (arg1[5])) << 8);
const x28 = (arg1[4]);
const x29 = (cast(u32, (arg1[3])) << 24);
const x30 = (cast(u32, (arg1[2])) << 16);
const x31 = (cast(u32, (arg1[1])) << 8);
const x32 = (arg1[0]);
const x33 = (x31 + cast(u32, x32));
const x34 = (x30 + x33);
const x35 = (x29 + x34);
const x36 = (x27 + cast(u32, x28));
const x37 = (x26 + x36);
const x38 = (x25 + x37);
const x39 = (x23 + cast(u32, x24));
const x40 = (x22 + x39);
const x41 = (x21 + x40);
const x42 = (x19 + cast(u32, x20));
const x43 = (x18 + x42);
const x44 = (x17 + x43);
const x45 = (x15 + cast(u32, x16));
const x46 = (x14 + x45);
const x47 = (x13 + x46);
const x48 = (x11 + cast(u32, x12));
const x49 = (x10 + x48);
const x50 = (x9 + x49);
const x51 = (x7 + cast(u32, x8));
const x52 = (x6 + x51);
const x53 = (x5 + x52);
const x54 = (x3 + cast(u32, x4));
const x55 = (x2 + x54);
const x56 = (x1 + x55);
out1[0] = x35;
out1[1] = x38;
out1[2] = x41;
out1[3] = x44;
out1[4] = x47;
out1[5] = x50;
out1[6] = x53;
out1[7] = x56;
}
/// 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] = 0x3d1;
out1[1] = cast(u32, 0x1);
out1[2] = cast(u32, 0x0);
out1[3] = cast(u32, 0x0);
out1[4] = cast(u32, 0x0);
out1[5] = cast(u32, 0x0);
out1[6] = cast(u32, 0x0);
out1[7] = cast(u32, 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 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
pub fn msat(out1: *[9]u32) void {
@setRuntimeSafety(mode == .Debug);
out1[0] = 0xfffffc2f;
out1[1] = 0xfffffffe;
out1[2] = 0xffffffff;
out1[3] = 0xffffffff;
out1[4] = 0xffffffff;
out1[5] = 0xffffffff;
out1[6] = 0xffffffff;
out1[7] = 0xffffffff;
out1[8] = cast(u32, 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 ~> 0xffffffff]
/// arg2: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
/// arg3: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
/// arg4: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
/// arg5: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
/// Output Bounds:
/// out1: [0x0 ~> 0xffffffff]
/// out2: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
/// out3: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
/// out4: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
/// out5: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
pub fn divstep(out1: *u32, out2: *[9]u32, out3: *[9]u32, out4: *[8]u32, out5: *[8]u32, arg1: u32, arg2: [9]u32, arg3: [9]u32, arg4: [8]u32, arg5: [8]u32) void {
@setRuntimeSafety(mode == .Debug);
var x1: u32 = undefined;
var x2: u1 = undefined;
addcarryxU32(&x1, &x2, 0x0, (~arg1), cast(u32, 0x1));
const x3 = (cast(u1, (x1 >> 31)) & cast(u1, ((arg3[0]) & cast(u32, 0x1))));
var x4: u32 = undefined;
var x5: u1 = undefined;
addcarryxU32(&x4, &x5, 0x0, (~arg1), cast(u32, 0x1));
var x6: u32 = undefined;
cmovznzU32(&x6, x3, arg1, x4);
var x7: u32 = undefined;
cmovznzU32(&x7, x3, (arg2[0]), (arg3[0]));
var x8: u32 = undefined;
cmovznzU32(&x8, x3, (arg2[1]), (arg3[1]));
var x9: u32 = undefined;
cmovznzU32(&x9, x3, (arg2[2]), (arg3[2]));
var x10: u32 = undefined;
cmovznzU32(&x10, x3, (arg2[3]), (arg3[3]));
var x11: u32 = undefined;
cmovznzU32(&x11, x3, (arg2[4]), (arg3[4]));
var x12: u32 = undefined;
cmovznzU32(&x12, x3, (arg2[5]), (arg3[5]));
var x13: u32 = undefined;
cmovznzU32(&x13, x3, (arg2[6]), (arg3[6]));
var x14: u32 = undefined;
cmovznzU32(&x14, x3, (arg2[7]), (arg3[7]));
var x15: u32 = undefined;
cmovznzU32(&x15, x3, (arg2[8]), (arg3[8]));
var x16: u32 = undefined;
var x17: u1 = undefined;
addcarryxU32(&x16, &x17, 0x0, cast(u32, 0x1), (~(arg2[0])));
var x18: u32 = undefined;
var x19: u1 = undefined;
addcarryxU32(&x18, &x19, x17, cast(u32, 0x0), (~(arg2[1])));
var x20: u32 = undefined;
var x21: u1 = undefined;
addcarryxU32(&x20, &x21, x19, cast(u32, 0x0), (~(arg2[2])));
var x22: u32 = undefined;
var x23: u1 = undefined;
addcarryxU32(&x22, &x23, x21, cast(u32, 0x0), (~(arg2[3])));
var x24: u32 = undefined;
var x25: u1 = undefined;
addcarryxU32(&x24, &x25, x23, cast(u32, 0x0), (~(arg2[4])));
var x26: u32 = undefined;
var x27: u1 = undefined;
addcarryxU32(&x26, &x27, x25, cast(u32, 0x0), (~(arg2[5])));
var x28: u32 = undefined;
var x29: u1 = undefined;
addcarryxU32(&x28, &x29, x27, cast(u32, 0x0), (~(arg2[6])));
var x30: u32 = undefined;
var x31: u1 = undefined;
addcarryxU32(&x30, &x31, x29, cast(u32, 0x0), (~(arg2[7])));
var x32: u32 = undefined;
var x33: u1 = undefined;
addcarryxU32(&x32, &x33, x31, cast(u32, 0x0), (~(arg2[8])));
var x34: u32 = undefined;
cmovznzU32(&x34, x3, (arg3[0]), x16);
var x35: u32 = undefined;
cmovznzU32(&x35, x3, (arg3[1]), x18);
var x36: u32 = undefined;
cmovznzU32(&x36, x3, (arg3[2]), x20);
var x37: u32 = undefined;
cmovznzU32(&x37, x3, (arg3[3]), x22);
var x38: u32 = undefined;
cmovznzU32(&x38, x3, (arg3[4]), x24);
var x39: u32 = undefined;
cmovznzU32(&x39, x3, (arg3[5]), x26);
var x40: u32 = undefined;
cmovznzU32(&x40, x3, (arg3[6]), x28);
var x41: u32 = undefined;
cmovznzU32(&x41, x3, (arg3[7]), x30);
var x42: u32 = undefined;
cmovznzU32(&x42, x3, (arg3[8]), x32);
var x43: u32 = undefined;
cmovznzU32(&x43, x3, (arg4[0]), (arg5[0]));
var x44: u32 = undefined;
cmovznzU32(&x44, x3, (arg4[1]), (arg5[1]));
var x45: u32 = undefined;
cmovznzU32(&x45, x3, (arg4[2]), (arg5[2]));
var x46: u32 = undefined;
cmovznzU32(&x46, x3, (arg4[3]), (arg5[3]));
var x47: u32 = undefined;
cmovznzU32(&x47, x3, (arg4[4]), (arg5[4]));
var x48: u32 = undefined;
cmovznzU32(&x48, x3, (arg4[5]), (arg5[5]));
var x49: u32 = undefined;
cmovznzU32(&x49, x3, (arg4[6]), (arg5[6]));
var x50: u32 = undefined;
cmovznzU32(&x50, x3, (arg4[7]), (arg5[7]));
var x51: u32 = undefined;
var x52: u1 = undefined;
addcarryxU32(&x51, &x52, 0x0, x43, x43);
var x53: u32 = undefined;
var x54: u1 = undefined;
addcarryxU32(&x53, &x54, x52, x44, x44);
var x55: u32 = undefined;
var x56: u1 = undefined;
addcarryxU32(&x55, &x56, x54, x45, x45);
var x57: u32 = undefined;
var x58: u1 = undefined;
addcarryxU32(&x57, &x58, x56, x46, x46);
var x59: u32 = undefined;
var x60: u1 = undefined;
addcarryxU32(&x59, &x60, x58, x47, x47);
var x61: u32 = undefined;
var x62: u1 = undefined;
addcarryxU32(&x61, &x62, x60, x48, x48);
var x63: u32 = undefined;
var x64: u1 = undefined;
addcarryxU32(&x63, &x64, x62, x49, x49);
var x65: u32 = undefined;
var x66: u1 = undefined;
addcarryxU32(&x65, &x66, x64, x50, x50);
var x67: u32 = undefined;
var x68: u1 = undefined;
subborrowxU32(&x67, &x68, 0x0, x51, 0xfffffc2f);
var x69: u32 = undefined;
var x70: u1 = undefined;
subborrowxU32(&x69, &x70, x68, x53, 0xfffffffe);
var x71: u32 = undefined;
var x72: u1 = undefined;
subborrowxU32(&x71, &x72, x70, x55, 0xffffffff);
var x73: u32 = undefined;
var x74: u1 = undefined;
subborrowxU32(&x73, &x74, x72, x57, 0xffffffff);
var x75: u32 = undefined;
var x76: u1 = undefined;
subborrowxU32(&x75, &x76, x74, x59, 0xffffffff);
var x77: u32 = undefined;
var x78: u1 = undefined;
subborrowxU32(&x77, &x78, x76, x61, 0xffffffff);
var x79: u32 = undefined;
var x80: u1 = undefined;
subborrowxU32(&x79, &x80, x78, x63, 0xffffffff);
var x81: u32 = undefined;
var x82: u1 = undefined;
subborrowxU32(&x81, &x82, x80, x65, 0xffffffff);
var x83: u32 = undefined;
var x84: u1 = undefined;
subborrowxU32(&x83, &x84, x82, cast(u32, x66), cast(u32, 0x0));
const x85 = (arg4[7]);
const x86 = (arg4[6]);
const x87 = (arg4[5]);
const x88 = (arg4[4]);
const x89 = (arg4[3]);
const x90 = (arg4[2]);
const x91 = (arg4[1]);
const x92 = (arg4[0]);
var x93: u32 = undefined;
var x94: u1 = undefined;
subborrowxU32(&x93, &x94, 0x0, cast(u32, 0x0), x92);
var x95: u32 = undefined;
var x96: u1 = undefined;
subborrowxU32(&x95, &x96, x94, cast(u32, 0x0), x91);
var x97: u32 = undefined;
var x98: u1 = undefined;
subborrowxU32(&x97, &x98, x96, cast(u32, 0x0), x90);
var x99: u32 = undefined;
var x100: u1 = undefined;
subborrowxU32(&x99, &x100, x98, cast(u32, 0x0), x89);
var x101: u32 = undefined;
var x102: u1 = undefined;
subborrowxU32(&x101, &x102, x100, cast(u32, 0x0), x88);
var x103: u32 = undefined;
var x104: u1 = undefined;
subborrowxU32(&x103, &x104, x102, cast(u32, 0x0), x87);
var x105: u32 = undefined;
var x106: u1 = undefined;
subborrowxU32(&x105, &x106, x104, cast(u32, 0x0), x86);
var x107: u32 = undefined;
var x108: u1 = undefined;
subborrowxU32(&x107, &x108, x106, cast(u32, 0x0), x85);
var x109: u32 = undefined;
cmovznzU32(&x109, x108, cast(u32, 0x0), 0xffffffff);
var x110: u32 = undefined;
var x111: u1 = undefined;
addcarryxU32(&x110, &x111, 0x0, x93, (x109 & 0xfffffc2f));
var x112: u32 = undefined;
var x113: u1 = undefined;
addcarryxU32(&x112, &x113, x111, x95, (x109 & 0xfffffffe));
var x114: u32 = undefined;
var x115: u1 = undefined;
addcarryxU32(&x114, &x115, x113, x97, x109);
var x116: u32 = undefined;
var x117: u1 = undefined;
addcarryxU32(&x116, &x117, x115, x99, x109);
var x118: u32 = undefined;
var x119: u1 = undefined;
addcarryxU32(&x118, &x119, x117, x101, x109);
var x120: u32 = undefined;
var x121: u1 = undefined;
addcarryxU32(&x120, &x121, x119, x103, x109);
var x122: u32 = undefined;
var x123: u1 = undefined;
addcarryxU32(&x122, &x123, x121, x105, x109);
var x124: u32 = undefined;
var x125: u1 = undefined;
addcarryxU32(&x124, &x125, x123, x107, x109);
var x126: u32 = undefined;
cmovznzU32(&x126, x3, (arg5[0]), x110);
var x127: u32 = undefined;
cmovznzU32(&x127, x3, (arg5[1]), x112);
var x128: u32 = undefined;
cmovznzU32(&x128, x3, (arg5[2]), x114);
var x129: u32 = undefined;
cmovznzU32(&x129, x3, (arg5[3]), x116);
var x130: u32 = undefined;
cmovznzU32(&x130, x3, (arg5[4]), x118);
var x131: u32 = undefined;
cmovznzU32(&x131, x3, (arg5[5]), x120);
var x132: u32 = undefined;
cmovznzU32(&x132, x3, (arg5[6]), x122);
var x133: u32 = undefined;
cmovznzU32(&x133, x3, (arg5[7]), x124);
const x134 = cast(u1, (x34 & cast(u32, 0x1)));
var x135: u32 = undefined;
cmovznzU32(&x135, x134, cast(u32, 0x0), x7);
var x136: u32 = undefined;
cmovznzU32(&x136, x134, cast(u32, 0x0), x8);
var x137: u32 = undefined;
cmovznzU32(&x137, x134, cast(u32, 0x0), x9);
var x138: u32 = undefined;
cmovznzU32(&x138, x134, cast(u32, 0x0), x10);
var x139: u32 = undefined;
cmovznzU32(&x139, x134, cast(u32, 0x0), x11);
var x140: u32 = undefined;
cmovznzU32(&x140, x134, cast(u32, 0x0), x12);
var x141: u32 = undefined;
cmovznzU32(&x141, x134, cast(u32, 0x0), x13);
var x142: u32 = undefined;
cmovznzU32(&x142, x134, cast(u32, 0x0), x14);
var x143: u32 = undefined;
cmovznzU32(&x143, x134, cast(u32, 0x0), x15);
var x144: u32 = undefined;
var x145: u1 = undefined;
addcarryxU32(&x144, &x145, 0x0, x34, x135);
var x146: u32 = undefined;
var x147: u1 = undefined;
addcarryxU32(&x146, &x147, x145, x35, x136);
var x148: u32 = undefined;
var x149: u1 = undefined;
addcarryxU32(&x148, &x149, x147, x36, x137);
var x150: u32 = undefined;
var x151: u1 = undefined;
addcarryxU32(&x150, &x151, x149, x37, x138);
var x152: u32 = undefined;
var x153: u1 = undefined;
addcarryxU32(&x152, &x153, x151, x38, x139);
var x154: u32 = undefined;
var x155: u1 = undefined;
addcarryxU32(&x154, &x155, x153, x39, x140);
var x156: u32 = undefined;
var x157: u1 = undefined;
addcarryxU32(&x156, &x157, x155, x40, x141);
var x158: u32 = undefined;
var x159: u1 = undefined;
addcarryxU32(&x158, &x159, x157, x41, x142);
var x160: u32 = undefined;
var x161: u1 = undefined;
addcarryxU32(&x160, &x161, x159, x42, x143);
var x162: u32 = undefined;
cmovznzU32(&x162, x134, cast(u32, 0x0), x43);
var x163: u32 = undefined;
cmovznzU32(&x163, x134, cast(u32, 0x0), x44);
var x164: u32 = undefined;
cmovznzU32(&x164, x134, cast(u32, 0x0), x45);
var x165: u32 = undefined;
cmovznzU32(&x165, x134, cast(u32, 0x0), x46);
var x166: u32 = undefined;
cmovznzU32(&x166, x134, cast(u32, 0x0), x47);
var x167: u32 = undefined;
cmovznzU32(&x167, x134, cast(u32, 0x0), x48);
var x168: u32 = undefined;
cmovznzU32(&x168, x134, cast(u32, 0x0), x49);
var x169: u32 = undefined;
cmovznzU32(&x169, x134, cast(u32, 0x0), x50);
var x170: u32 = undefined;
var x171: u1 = undefined;
addcarryxU32(&x170, &x171, 0x0, x126, x162);
var x172: u32 = undefined;
var x173: u1 = undefined;
addcarryxU32(&x172, &x173, x171, x127, x163);
var x174: u32 = undefined;
var x175: u1 = undefined;
addcarryxU32(&x174, &x175, x173, x128, x164);
var x176: u32 = undefined;
var x177: u1 = undefined;
addcarryxU32(&x176, &x177, x175, x129, x165);
var x178: u32 = undefined;
var x179: u1 = undefined;
addcarryxU32(&x178, &x179, x177, x130, x166);
var x180: u32 = undefined;
var x181: u1 = undefined;
addcarryxU32(&x180, &x181, x179, x131, x167);
var x182: u32 = undefined;
var x183: u1 = undefined;
addcarryxU32(&x182, &x183, x181, x132, x168);
var x184: u32 = undefined;
var x185: u1 = undefined;
addcarryxU32(&x184, &x185, x183, x133, x169);
var x186: u32 = undefined;
var x187: u1 = undefined;
subborrowxU32(&x186, &x187, 0x0, x170, 0xfffffc2f);
var x188: u32 = undefined;
var x189: u1 = undefined;
subborrowxU32(&x188, &x189, x187, x172, 0xfffffffe);
var x190: u32 = undefined;
var x191: u1 = undefined;
subborrowxU32(&x190, &x191, x189, x174, 0xffffffff);
var x192: u32 = undefined;
var x193: u1 = undefined;
subborrowxU32(&x192, &x193, x191, x176, 0xffffffff);
var x194: u32 = undefined;
var x195: u1 = undefined;
subborrowxU32(&x194, &x195, x193, x178, 0xffffffff);
var x196: u32 = undefined;
var x197: u1 = undefined;
subborrowxU32(&x196, &x197, x195, x180, 0xffffffff);
var x198: u32 = undefined;
var x199: u1 = undefined;
subborrowxU32(&x198, &x199, x197, x182, 0xffffffff);
var x200: u32 = undefined;
var x201: u1 = undefined;
subborrowxU32(&x200, &x201, x199, x184, 0xffffffff);
var x202: u32 = undefined;
var x203: u1 = undefined;
subborrowxU32(&x202, &x203, x201, cast(u32, x185), cast(u32, 0x0));
var x204: u32 = undefined;
var x205: u1 = undefined;
addcarryxU32(&x204, &x205, 0x0, x6, cast(u32, 0x1));
const x206 = ((x144 >> 1) | ((x146 << 31) & 0xffffffff));
const x207 = ((x146 >> 1) | ((x148 << 31) & 0xffffffff));
const x208 = ((x148 >> 1) | ((x150 << 31) & 0xffffffff));
const x209 = ((x150 >> 1) | ((x152 << 31) & 0xffffffff));
const x210 = ((x152 >> 1) | ((x154 << 31) & 0xffffffff));
const x211 = ((x154 >> 1) | ((x156 << 31) & 0xffffffff));
const x212 = ((x156 >> 1) | ((x158 << 31) & 0xffffffff));
const x213 = ((x158 >> 1) | ((x160 << 31) & 0xffffffff));
const x214 = ((x160 & 0x80000000) | (x160 >> 1));
var x215: u32 = undefined;
cmovznzU32(&x215, x84, x67, x51);
var x216: u32 = undefined;
cmovznzU32(&x216, x84, x69, x53);
var x217: u32 = undefined;
cmovznzU32(&x217, x84, x71, x55);
var x218: u32 = undefined;
cmovznzU32(&x218, x84, x73, x57);
var x219: u32 = undefined;
cmovznzU32(&x219, x84, x75, x59);
var x220: u32 = undefined;
cmovznzU32(&x220, x84, x77, x61);
var x221: u32 = undefined;
cmovznzU32(&x221, x84, x79, x63);
var x222: u32 = undefined;
cmovznzU32(&x222, x84, x81, x65);
var x223: u32 = undefined;
cmovznzU32(&x223, x203, x186, x170);
var x224: u32 = undefined;
cmovznzU32(&x224, x203, x188, x172);
var x225: u32 = undefined;
cmovznzU32(&x225, x203, x190, x174);
var x226: u32 = undefined;
cmovznzU32(&x226, x203, x192, x176);
var x227: u32 = undefined;
cmovznzU32(&x227, x203, x194, x178);
var x228: u32 = undefined;
cmovznzU32(&x228, x203, x196, x180);
var x229: u32 = undefined;
cmovznzU32(&x229, x203, x198, x182);
var x230: u32 = undefined;
cmovznzU32(&x230, x203, x200, x184);
out1.* = x204;
out2[0] = x7;
out2[1] = x8;
out2[2] = x9;
out2[3] = x10;
out2[4] = x11;
out2[5] = x12;
out2[6] = x13;
out2[7] = x14;
out2[8] = x15;
out3[0] = x206;
out3[1] = x207;
out3[2] = x208;
out3[3] = x209;
out3[4] = x210;
out3[5] = x211;
out3[6] = x212;
out3[7] = x213;
out3[8] = x214;
out4[0] = x215;
out4[1] = x216;
out4[2] = x217;
out4[3] = x218;
out4[4] = x219;
out4[5] = x220;
out4[6] = x221;
out4[7] = x222;
out5[0] = x223;
out5[1] = x224;
out5[2] = x225;
out5[3] = x226;
out5[4] = x227;
out5[5] = x228;
out5[6] = x229;
out5[7] = x230;
}
/// 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 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
pub fn divstepPrecomp(out1: *[8]u32) void {
@setRuntimeSafety(mode == .Debug);
out1[0] = 0x31525e0a;
out1[1] = 0xf201a418;
out1[2] = 0xcd648d85;
out1[3] = 0x9953f9dd;
out1[4] = 0x3db210a9;
out1[5] = 0xe8602946;
out1[6] = 0x4b03709;
out1[7] = 0x24fb8a31;
} | fiat-zig/src/secp256k1_32.zig |
const std = @import("std");
const testing = std.testing;
const allocator = std.testing.allocator;
pub const Map = struct {
const SIZE = 150;
width: usize,
height: usize,
pixel: [3][SIZE][SIZE]u8,
cur: usize,
pub fn init() Map {
var self = Map{
.width = 0,
.height = 0,
.pixel = undefined,
.cur = 0,
};
return self;
}
pub fn deinit(_: *Map) void {}
pub fn process_line(self: *Map, data: []const u8) !void {
if (self.width == 0) self.width = data.len;
if (self.width != data.len) unreachable;
const y = self.height;
for (data) |c, x| {
self.pixel[self.cur][x][y] = c;
}
self.height += 1;
}
pub fn iterate(self: *Map) bool {
// 0 is always where we start
// 1 is next place; since we run two iters per step, we go back to 0
// 2 is a copy of the previous step
{
var y: usize = 0;
while (y < self.height) : (y += 1) {
var x: usize = 0;
while (x < self.width) : (x += 1) {
self.pixel[2][x][y] = self.pixel[0][x][y];
}
}
}
var h: usize = 0;
while (h < 2) : (h += 1) {
var nxt = 1 - self.cur;
{
var y: usize = 0;
while (y < self.height) : (y += 1) {
var x: usize = 0;
while (x < self.width) : (x += 1) {
self.pixel[nxt][x][y] = '.';
}
}
}
var y: usize = 0;
while (y < self.height) : (y += 1) {
var x: usize = 0;
while (x < self.width) : (x += 1) {
const c = self.pixel[self.cur][x][y];
if (c == '.') continue;
if (h == 0) {
if (c != '>') {
self.pixel[nxt][x][y] = c;
} else {
const nx = (x + 1) % self.width;
const n = self.pixel[self.cur][nx][y];
if (n == '.') {
self.pixel[nxt][nx][y] = c;
} else {
self.pixel[nxt][x][y] = c;
}
}
}
if (h == 1) {
if (c != 'v') {
self.pixel[nxt][x][y] = c;
} else {
const ny = (y + 1) % self.height;
const n = self.pixel[self.cur][x][ny];
if (n == '.') {
self.pixel[nxt][x][ny] = c;
} else {
self.pixel[nxt][x][y] = c;
}
}
}
}
}
self.cur = nxt;
}
{
var y: usize = 0;
while (y < self.height) : (y += 1) {
var x: usize = 0;
while (x < self.width) : (x += 1) {
if (self.pixel[2][x][y] != self.pixel[0][x][y]) return false;
}
}
return true;
}
}
pub fn iterate_until_stopped(self: *Map) usize {
var n: usize = 0;
while (true) {
n += 1;
const done = self.iterate();
// std.debug.warn("ITER {}\n", .{n});
// self.show();
if (done) break;
}
return n;
}
fn show(self: *Map) void {
var y: usize = 0;
while (y < self.height) : (y += 1) {
var x: usize = 0;
while (x < self.width) : (x += 1) {
std.debug.warn("{c}", .{self.pixel[self.cur][x][y]});
}
std.debug.warn("\n", .{});
}
}
};
test "sample part a" {
const data: []const u8 =
\\v...>>.vv>
\\.vv>>.vv..
\\>>.>v>...v
\\>>v>>.>.v.
\\v>v.vv.v..
\\>.>>..v...
\\.vv..>.>v.
\\v.v..>>v.v
\\....v..v.>
;
var map = Map.init();
defer map.deinit();
std.debug.warn("\n", .{});
var it = std.mem.split(u8, data, "\n");
while (it.next()) |line| {
try map.process_line(line);
}
map.show();
const iters = map.iterate_until_stopped();
try testing.expect(iters == 58);
} | 2021/p25/map.zig |
const c = @import("../c.zig");
const std = @import("std");
const vertex = @import("../vertex.zig");
const opengl = @import("../opengl_renderer.zig");
usingnamespace @import("zalgebra");
usingnamespace @import("block.zig");
pub const vec3i = Vec3(i64);
pub const vec3u = Vec3(u64);
pub const TestChunk = struct {
const Self = @This();
pub const Size = vec3u.new(32, 32, 32);
const DataSize: u64 = Size.x * Size.y * Size.z;
dirty: bool,
data: [DataSize]BlockId,
mesh: ?opengl.Mesh,
coord: vec3i,
matrix: mat4,
pub fn init(coord: vec3i) Self {
return Self {
.dirty = true,
.coord = coord,
.data = [_]BlockId{0} ** DataSize,
.mesh = null,
.matrix = mat4.from_translate(vec3.new(@intToFloat(f32, @intCast(u64, coord.x) * ChunkData32.size_x), @intToFloat(f32, @intCast(u64, coord.y) * ChunkData32.size_y), @intToFloat(f32, @intCast(u64, coord.z) * ChunkData32.size_z))),
};
}
pub fn deinit(self: *Self) void {
if (self.mesh) |chunk_mesh| {
chunk_mesh.deinit();
}
}
pub fn getBlockIndex(pos: *vec3i) ?usize {
if (pos.x >= 0 and pos.y >= 0 and pos.z >= 0) {
var index: usize = (@intCast(usize, pos.x)) + (@intCast(usize, pos.y) * Size.y) + (@intCast(usize, pos.z) * Size.y * Size.z);
if (index >= 0 and index < DataSize) {
return index;
}
}
return null;
}
fn getBlockPos(index: u64) vec3i {
const SliceSize: u64 = (Size.x * Size.y);
var z = index / SliceSize;
var z_rem = @mod(index, SliceSize);
var y = z_rem / Size.x;
var y_rem = @mod(z_rem, Size.x);
return vec3i.new(y_rem, y, z);
}
pub fn getBlock(self: *Self, pos: *vec3i) BlockId {
if (getBlockIndex(pos)) |index| {
return self.data[index];
}
else {
return 0;
}
}
pub fn setBlock(self: *Self, pos: *vec3i, id: BlockId) void {
if (getBlockIndex(pos)) |index| {
self.data[index] = id;
self.dirty = true;
}
}
pub fn render(self: *Self, matrix_uniform_index: c.GLint) void {
if (self.mesh) |mesh| {
c.glUniformMatrix4fv(matrix_uniform_index, 1, c.GL_FALSE, self.matrix.get_data());
mesh.draw();
}
}
pub fn generateChunkMesh(self: *Self, allocator: *std.mem.Allocator) void {
if (self.dirty == false) {
return;
}
if (self.mesh) |mesh| {
mesh.deinit();
}
var vertices = std.ArrayList(vertex.TexturedVertex).init(allocator);
defer vertices.deinit();
var indices = std.ArrayList(u32).init(allocator);
defer indices.deinit();
var index: vec3i = vec3i.zero();
while (index.x < Size.x) : (index.x += 1) {
index.y = 0;
while (index.y < Size.y) : (index.y += 1) {
index.z = 0;
while (index.z < Size.x) : (index.z += 1) {
var blockId = self.getBlock(&index);
var posVec = index.cast(f32);
if (blockId != 0) {
for (CubeFaceChecks) |faceCheck| {
var checkId = self.getBlock(&index.add(faceCheck.offset));
if (checkId == 0) {
var texture_index = BlockList[blockId].texture_index;
var x_offset = @intToFloat(f32, @rem(texture_index, 8));
var y_offset = @intToFloat(f32, @divTrunc(texture_index, 8));
var texture_offset = vec2.new(x_offset, y_offset).scale(1.0 / 8.0);
appendCubeFace(faceCheck.face, &vertices, &indices, posVec, texture_offset);
}
}
}
}
}
}
self.mesh = opengl.Mesh.init(vertex.TexturedVertex, u32, vertices.items, indices.items);
}
};
pub const ChunkData32 = ChunkData(32, 32, 32);
const CubeFace = enum {
x_pos,
x_neg,
y_pos,
y_neg,
z_pos,
z_neg,
};
const CubeFaceCheck = struct {
face: CubeFace,
offset: vec3i,
};
const CubeFaceChecks = [_]CubeFaceCheck{
CubeFaceCheck{.face = CubeFace.x_pos, .offset = vec3i.new( 1, 0, 0)},
CubeFaceCheck{.face = CubeFace.x_neg, .offset = vec3i.new(-1, 0, 0)},
CubeFaceCheck{.face = CubeFace.y_pos, .offset = vec3i.new( 0, 1, 0)},
CubeFaceCheck{.face = CubeFace.y_neg, .offset = vec3i.new( 0, -1, 0)},
CubeFaceCheck{.face = CubeFace.z_pos, .offset = vec3i.new( 0, 0, 1)},
CubeFaceCheck{.face = CubeFace.z_neg, .offset = vec3i.new( 0, 0, -1)},
};
pub fn ChunkData(comptime X: u64, comptime Y: u64, comptime Z: u64) type {
return struct {
const Self = @This();
pub const size_x: u64 = X;
pub const size_y: u64 = Y;
pub const size_z: u64 = Z;
const ARRAY_SIZE: u64 = size_x * size_y * size_z;
data: [ARRAY_SIZE]BlockId,
dirty: bool,
pub fn init() Self {
var data: [ARRAY_SIZE]BlockId = [_]BlockId{0} ** ARRAY_SIZE;
return .{ .data = data, .dirty = true };
}
fn getBlockIndex(pos: *vec3i) u64 {
return (@intCast(u64, pos.x)) + (@intCast(u64, pos.y) * size_y) + (@intCast(u64, pos.z) * size_y * size_z);
}
pub fn getBlock(self: *Self, pos: *vec3i) BlockId {
return self.data[getBlockIndex(pos)];
}
pub fn getBlockSafe(self: *Self, pos: *vec3i) BlockId {
if(pos.x >= Self.size_x or pos.x < 0 or pos.y >= Self.size_y or pos.y < 0 or pos.z >= Self.size_z or pos.z < 0) {
return 0;
}
return self.data[getBlockIndex(pos)];
}
pub fn setBlock(self: *Self, pos: *vec3i, id: BlockId) void {
self.data[getBlockIndex(pos)] = id;
self.dirty = true;
}
pub fn isDirty(self: *Self) bool {
return self.dirty;
}
};
}
pub fn CreateChunkMesh(comptime Chunk: type, allocator: *std.mem.Allocator, chunk: *Chunk) opengl.Mesh {
var vertices = std.ArrayList(vertex.TexturedVertex).init(allocator);
defer vertices.deinit();
var indices = std.ArrayList(u32).init(allocator);
defer indices.deinit();
var index: vec3i = vec3i.zero();
while (index.x < Chunk.size_x) : (index.x += 1) {
index.y = 0;
while (index.y < Chunk.size_y) : (index.y += 1) {
index.z = 0;
while (index.z < Chunk.size_x) : (index.z += 1) {
var blockId = chunk.getBlock(&index);
var posVec = index.cast(f32);
if (blockId != 0) {
for (CubeFaceChecks) |faceCheck| {
var checkId = chunk.getBlockSafe(&index.add(faceCheck.offset));
if (checkId == 0) {
var texture_index = BlockList[blockId].texture_index;
var x_offset = @intToFloat(f32, @rem(texture_index, 8));
var y_offset = @intToFloat(f32, @divTrunc(texture_index, 8));
var texture_offset = vec2.new(x_offset, y_offset).scale(1.0 / 8.0);
appendCubeFace(faceCheck.face, &vertices, &indices, posVec, texture_offset);
}
}
}
}
}
}
return opengl.Mesh.init(vertex.TexturedVertex, u32, vertices.items, indices.items);
}
fn appendCubeFace(face: CubeFace, vertices: *std.ArrayList(vertex.TexturedVertex), indices: *std.ArrayList(u32), position: vec3, uv_offset: vec2) void {
const cube_positions = [_]vec3{
vec3.new(0.5, 0.5, 0.5),
vec3.new(0.5, 0.5, -0.5),
vec3.new(0.5, -0.5, 0.5),
vec3.new(0.5, -0.5, -0.5),
vec3.new(-0.5, 0.5, 0.5),
vec3.new(-0.5, 0.5, -0.5),
vec3.new(-0.5, -0.5, 0.5),
vec3.new(-0.5, -0.5, -0.5),
};
const cube_uvs = [_]vec2{
vec2.new(0.0, 0.0).add(uv_offset),
vec2.new(0.0, 1.0 / 8.0).add(uv_offset),
vec2.new(1.0 / 8.0, 1.0 / 8.0).add(uv_offset),
vec2.new(1.0 / 8.0, 0.0).add(uv_offset),
};
var position_indexes: [4]usize = undefined;
switch (face) {
CubeFace.x_pos => {
position_indexes = [4]usize{ 0, 2, 3, 1 };
},
CubeFace.x_neg => {
position_indexes = [4]usize{ 5, 7, 6, 4 };
},
CubeFace.y_pos => {
position_indexes = [4]usize{ 0, 1, 5, 4 };
},
CubeFace.y_neg => {
position_indexes = [4]usize{ 6, 7, 3, 2 };
},
CubeFace.z_pos => {
position_indexes = [4]usize{ 4, 6, 2, 0 };
},
CubeFace.z_neg => {
position_indexes = [4]usize{ 1, 3, 7, 5 };
},
}
var index_offset = @intCast(u32, vertices.items.len);
vertices.appendSlice(&[_]vertex.TexturedVertex{
vertex.TexturedVertex.new(cube_positions[position_indexes[0]].add(position), cube_uvs[0]),
vertex.TexturedVertex.new(cube_positions[position_indexes[1]].add(position), cube_uvs[1]),
vertex.TexturedVertex.new(cube_positions[position_indexes[2]].add(position), cube_uvs[2]),
vertex.TexturedVertex.new(cube_positions[position_indexes[3]].add(position), cube_uvs[3]),
}) catch std.debug.panic("Failed to append", .{});
indices.appendSlice(&[_]u32{
index_offset + 0,
index_offset + 1,
index_offset + 2,
index_offset + 0,
index_offset + 2,
index_offset + 3,
}) catch std.debug.panic("Failed to append", .{});
} | src/chunk/chunk.zig |
const std = @import("std");
const c = @import("internal/c.zig");
const internal = @import("internal/internal.zig");
const log = std.log.scoped(.git);
const git = @import("git.zig");
pub const SimilarityMetric = extern struct {
file_signature: fn (out: *?*anyopaque, file: *const git.DiffFile, full_path: [*:0]const u8, payload: ?*anyopaque) callconv(.C) c_int,
buffer_signature: fn (
out: *?*anyopaque,
file: *const git.DiffFile,
buf: [*:0]const u8,
buf_len: usize,
payload: ?*anyopaque,
) callconv(.C) c_int,
free_signature: fn (sig: ?*anyopaque, payload: ?*anyopaque) callconv(.C) void,
similarity: fn (score: *c_int, siga: ?*anyopaque, sigb: ?*anyopaque, payload: ?*anyopaque) callconv(.C) c_int,
payload: ?*anyopaque,
test {
try std.testing.expectEqual(@sizeOf(c.git_diff_similarity_metric), @sizeOf(SimilarityMetric));
try std.testing.expectEqual(@bitSizeOf(c.git_diff_similarity_metric), @bitSizeOf(SimilarityMetric));
}
comptime {
std.testing.refAllDecls(@This());
}
};
pub const FileFavor = enum(c_uint) {
/// When a region of a file is changed in both branches, a conflict will be recorded in the index so that `git_checkout` can
/// produce a merge file with conflict markers in the working directory.
/// This is the default.
NORMAL = 0,
/// When a region of a file is changed in both branches, the file created in the index will contain the "ours" side of any
/// conflicting region. The index will not record a conflict.
OURS = 1,
/// When a region of a file is changed in both branches, the file created in the index will contain the "theirs" side of any
/// conflicting region. The index will not record a conflict.
THEIRS = 2,
/// When a region of a file is changed in both branches, the file created in the index will contain each unique line from each
/// side, which has the result of combining both files. The index will not record a conflict.
UNION = 3,
};
pub const MergeOptions = struct {
flags: MergeFlags = .{},
/// Similarity to consider a file renamed (default 50). If `Flags.IND_RENAMES` is enabled, added files will be compared with
/// deleted files to determine their similarity. Files that are more similar than the rename threshold (percentage-wise) will
/// be treated as a rename.
rename_threshold: c_uint = 0,
/// Maximum similarity sources to examine for renames (default 200). If the number of rename candidates (add / delete pairs)
/// is greater than this value, inexact rename detection is aborted.
///
/// This setting overrides the `merge.renameLimit` configuration value.
target_limit: c_uint = 0,
/// Pluggable similarity metric; pass `null` to use internal metric
metric: ?*SimilarityMetric = null,
/// Maximum number of times to merge common ancestors to build a virtual merge base when faced with criss-cross merges. When
/// this limit is reached, the next ancestor will simply be used instead of attempting to merge it. The default is unlimited.
recursion_limit: c_uint = 0,
/// Default merge driver to be used when both sides of a merge have changed. The default is the `text` driver.
default_driver: ?[:0]const u8 = null,
/// Flags for handling conflicting content, to be used with the standard (`text`) merge driver.
file_favor: FileFavor = .NORMAL,
file_flags: FileFlags = .{},
pub const MergeFlags = packed struct {
/// Detect renames that occur between the common ancestor and the "ours" side or the common ancestor and the "theirs"
/// side. This will enable the ability to merge between a modified and renamed file.
FIND_RENAMES: bool = false,
/// If a conflict occurs, exit immediately instead of attempting to continue resolving conflicts. The merge operation will
/// fail with `GitError.MERGECONFLICT` and no index will be returned.
FAIL_ON_CONFLICT: bool = false,
/// Do not write the REUC extension on the generated index
SKIP_REUC: bool = false,
/// If the commits being merged have multiple merge bases, do not build a recursive merge base (by merging the multiple
/// merge bases), instead simply use the first base. This flag provides a similar merge base to `git-merge-resolve`.
NO_RECURSIVE: bool = false,
z_padding: u12 = 0,
z_padding2: u16 = 0,
pub fn format(
value: MergeFlags,
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
writer: anytype,
) !void {
_ = fmt;
return internal.formatWithoutFields(
value,
options,
writer,
&.{ "z_padding", "z_padding2" },
);
}
test {
try std.testing.expectEqual(@sizeOf(u32), @sizeOf(MergeFlags));
try std.testing.expectEqual(@bitSizeOf(u32), @bitSizeOf(MergeFlags));
}
comptime {
std.testing.refAllDecls(@This());
}
};
pub const FileFlags = packed struct {
/// Create standard conflicted merge files
STYLE_MERGE: bool = false,
/// Create diff3-style files
STYLE_DIFF3: bool = false,
/// Condense non-alphanumeric regions for simplified diff file
SIMPLIFY_ALNUM: bool = false,
/// Ignore all whitespace
IGNORE_WHITESPACE: bool = false,
/// Ignore changes in amount of whitespace
IGNORE_WHITESPACE_CHANGE: bool = false,
/// Ignore whitespace at end of line
IGNORE_WHITESPACE_EOL: bool = false,
/// Use the "patience diff" algorithm
DIFF_PATIENCE: bool = false,
/// Take extra time to find minimal diff
DIFF_MINIMAL: bool = false,
z_padding: u8 = 0,
z_padding2: u16 = 0,
pub fn format(
value: FileFlags,
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
writer: anytype,
) !void {
_ = fmt;
return internal.formatWithoutFields(
value,
options,
writer,
&.{ "z_padding", "z_padding2" },
);
}
test {
try std.testing.expectEqual(@sizeOf(u32), @sizeOf(FileFlags));
try std.testing.expectEqual(@bitSizeOf(u32), @bitSizeOf(FileFlags));
}
comptime {
std.testing.refAllDecls(@This());
}
};
pub fn makeCOptionObject(self: MergeOptions) c.git_merge_options {
return .{
.version = c.GIT_MERGE_OPTIONS_VERSION,
.flags = @bitCast(u32, self.flags),
.rename_threshold = self.rename_threshold,
.target_limit = self.target_limit,
.metric = @ptrCast(?*c.git_diff_similarity_metric, self.metric),
.recursion_limit = self.recursion_limit,
.default_driver = if (self.default_driver) |ptr| ptr.ptr else null,
.file_favor = @enumToInt(self.file_favor),
.file_flags = @bitCast(u32, self.file_flags),
};
}
comptime {
std.testing.refAllDecls(@This());
}
};
comptime {
std.testing.refAllDecls(@This());
} | src/merge.zig |
pub const CA_DISP_INCOMPLETE = @as(u32, 0);
pub const CA_DISP_ERROR = @as(u32, 1);
pub const CA_DISP_REVOKED = @as(u32, 2);
pub const CA_DISP_VALID = @as(u32, 3);
pub const CA_DISP_INVALID = @as(u32, 4);
pub const CA_DISP_UNDER_SUBMISSION = @as(u32, 5);
pub const KRA_DISP_EXPIRED = @as(u32, 0);
pub const KRA_DISP_NOTFOUND = @as(u32, 1);
pub const KRA_DISP_REVOKED = @as(u32, 2);
pub const KRA_DISP_VALID = @as(u32, 3);
pub const KRA_DISP_INVALID = @as(u32, 4);
pub const KRA_DISP_UNTRUSTED = @as(u32, 5);
pub const KRA_DISP_NOTLOADED = @as(u32, 6);
pub const CA_ACCESS_MASKROLES = @as(u32, 255);
pub const CA_CRL_BASE = @as(u32, 1);
pub const CA_CRL_DELTA = @as(u32, 2);
pub const CA_CRL_REPUBLISH = @as(u32, 16);
pub const ICF_ALLOWFOREIGN = @as(u32, 65536);
pub const ICF_EXISTINGROW = @as(u32, 131072);
pub const IKF_OVERWRITE = @as(u32, 65536);
pub const CSBACKUP_TYPE_MASK = @as(u32, 3);
pub const CSRESTORE_TYPE_FULL = @as(u32, 1);
pub const CSRESTORE_TYPE_ONLINE = @as(u32, 2);
pub const CSRESTORE_TYPE_CATCHUP = @as(u32, 4);
pub const CSRESTORE_TYPE_MASK = @as(u32, 5);
pub const CSBACKUP_DISABLE_INCREMENTAL = @as(u32, 4294967295);
pub const CSBFT_DIRECTORY = @as(u32, 128);
pub const CSBFT_DATABASE_DIRECTORY = @as(u32, 64);
pub const CSBFT_LOG_DIRECTORY = @as(u32, 32);
pub const CSCONTROL_SHUTDOWN = @as(u64, 1);
pub const CSCONTROL_SUSPEND = @as(u64, 2);
pub const CSCONTROL_RESTART = @as(u64, 3);
pub const CAIF_DSENTRY = @as(u32, 1);
pub const CAIF_SHAREDFOLDERENTRY = @as(u32, 2);
pub const CAIF_REGISTRY = @as(u32, 4);
pub const CAIF_LOCAL = @as(u32, 8);
pub const CAIF_REGISTRYPARENT = @as(u32, 16);
pub const CR_IN_ENCODEANY = @as(u32, 255);
pub const CR_IN_ENCODEMASK = @as(u32, 255);
pub const CR_IN_FORMATANY = @as(u32, 0);
pub const CR_IN_PKCS10 = @as(u32, 256);
pub const CR_IN_KEYGEN = @as(u32, 512);
pub const CR_IN_PKCS7 = @as(u32, 768);
pub const CR_IN_CMC = @as(u32, 1024);
pub const CR_IN_CHALLENGERESPONSE = @as(u32, 1280);
pub const CR_IN_SIGNEDCERTIFICATETIMESTAMPLIST = @as(u32, 1536);
pub const CR_IN_FORMATMASK = @as(u32, 65280);
pub const CR_IN_SCEP = @as(u32, 65536);
pub const CR_IN_RPC = @as(u32, 131072);
pub const CR_IN_HTTP = @as(u32, 196608);
pub const CR_IN_FULLRESPONSE = @as(u32, 262144);
pub const CR_IN_CRLS = @as(u32, 524288);
pub const CR_IN_MACHINE = @as(u32, 1048576);
pub const CR_IN_ROBO = @as(u32, 2097152);
pub const CR_IN_CLIENTIDNONE = @as(u32, 4194304);
pub const CR_IN_CONNECTONLY = @as(u32, 8388608);
pub const CR_IN_RETURNCHALLENGE = @as(u32, 16777216);
pub const CR_IN_SCEPPOST = @as(u32, 33554432);
pub const CR_IN_CERTIFICATETRANSPARENCY = @as(u32, 67108864);
pub const CC_UIPICKCONFIGSKIPLOCALCA = @as(u32, 5);
pub const CR_DISP_REVOKED = @as(u32, 6);
pub const CR_OUT_BASE64REQUESTHEADER = @as(u32, 3);
pub const CR_OUT_HEX = @as(u32, 4);
pub const CR_OUT_HEXASCII = @as(u32, 5);
pub const CR_OUT_BASE64X509CRLHEADER = @as(u32, 9);
pub const CR_OUT_HEXADDR = @as(u32, 10);
pub const CR_OUT_HEXASCIIADDR = @as(u32, 11);
pub const CR_OUT_HEXRAW = @as(u32, 12);
pub const CR_OUT_ENCODEMASK = @as(u32, 255);
pub const CR_OUT_CHAIN = @as(u32, 256);
pub const CR_OUT_CRLS = @as(u32, 512);
pub const CR_OUT_NOCRLF = @as(u32, 1073741824);
pub const CR_OUT_NOCR = @as(u32, 2147483648);
pub const CR_GEMT_DEFAULT = @as(u32, 0);
pub const CR_GEMT_HRESULT_STRING = @as(u32, 1);
pub const CR_GEMT_HTTP_ERROR = @as(u32, 2);
pub const CR_PROP_NONE = @as(u32, 0);
pub const CR_PROP_FILEVERSION = @as(u32, 1);
pub const CR_PROP_PRODUCTVERSION = @as(u32, 2);
pub const CR_PROP_EXITCOUNT = @as(u32, 3);
pub const CR_PROP_EXITDESCRIPTION = @as(u32, 4);
pub const CR_PROP_POLICYDESCRIPTION = @as(u32, 5);
pub const CR_PROP_CANAME = @as(u32, 6);
pub const CR_PROP_SANITIZEDCANAME = @as(u32, 7);
pub const CR_PROP_SHAREDFOLDER = @as(u32, 8);
pub const CR_PROP_PARENTCA = @as(u32, 9);
pub const CR_PROP_CATYPE = @as(u32, 10);
pub const CR_PROP_CASIGCERTCOUNT = @as(u32, 11);
pub const CR_PROP_CASIGCERT = @as(u32, 12);
pub const CR_PROP_CASIGCERTCHAIN = @as(u32, 13);
pub const CR_PROP_CAXCHGCERTCOUNT = @as(u32, 14);
pub const CR_PROP_CAXCHGCERT = @as(u32, 15);
pub const CR_PROP_CAXCHGCERTCHAIN = @as(u32, 16);
pub const CR_PROP_BASECRL = @as(u32, 17);
pub const CR_PROP_DELTACRL = @as(u32, 18);
pub const CR_PROP_CACERTSTATE = @as(u32, 19);
pub const CR_PROP_CRLSTATE = @as(u32, 20);
pub const CR_PROP_CAPROPIDMAX = @as(u32, 21);
pub const CR_PROP_DNSNAME = @as(u32, 22);
pub const CR_PROP_ROLESEPARATIONENABLED = @as(u32, 23);
pub const CR_PROP_KRACERTUSEDCOUNT = @as(u32, 24);
pub const CR_PROP_KRACERTCOUNT = @as(u32, 25);
pub const CR_PROP_KRACERT = @as(u32, 26);
pub const CR_PROP_KRACERTSTATE = @as(u32, 27);
pub const CR_PROP_ADVANCEDSERVER = @as(u32, 28);
pub const CR_PROP_TEMPLATES = @as(u32, 29);
pub const CR_PROP_BASECRLPUBLISHSTATUS = @as(u32, 30);
pub const CR_PROP_DELTACRLPUBLISHSTATUS = @as(u32, 31);
pub const CR_PROP_CASIGCERTCRLCHAIN = @as(u32, 32);
pub const CR_PROP_CAXCHGCERTCRLCHAIN = @as(u32, 33);
pub const CR_PROP_CACERTSTATUSCODE = @as(u32, 34);
pub const CR_PROP_CAFORWARDCROSSCERT = @as(u32, 35);
pub const CR_PROP_CABACKWARDCROSSCERT = @as(u32, 36);
pub const CR_PROP_CAFORWARDCROSSCERTSTATE = @as(u32, 37);
pub const CR_PROP_CABACKWARDCROSSCERTSTATE = @as(u32, 38);
pub const CR_PROP_CACERTVERSION = @as(u32, 39);
pub const CR_PROP_SANITIZEDCASHORTNAME = @as(u32, 40);
pub const CR_PROP_CERTCDPURLS = @as(u32, 41);
pub const CR_PROP_CERTAIAURLS = @as(u32, 42);
pub const CR_PROP_CERTAIAOCSPURLS = @as(u32, 43);
pub const CR_PROP_LOCALENAME = @as(u32, 44);
pub const CR_PROP_SUBJECTTEMPLATE_OIDS = @as(u32, 45);
pub const CR_PROP_SCEPSERVERCERTS = @as(u32, 1000);
pub const CR_PROP_SCEPSERVERCAPABILITIES = @as(u32, 1001);
pub const CR_PROP_SCEPSERVERCERTSCHAIN = @as(u32, 1002);
pub const CR_PROP_SCEPMIN = @as(u32, 1000);
pub const CR_PROP_SCEPMAX = @as(u32, 1002);
pub const FR_PROP_CLAIMCHALLENGE = @as(u32, 22);
pub const EAN_NAMEOBJECTID = @as(u32, 2147483648);
pub const EANR_SUPPRESS_IA5CONVERSION = @as(u32, 2147483648);
pub const CERTENROLL_INDEX_BASE = @as(u32, 0);
pub const EXITEVENT_INVALID = @as(u32, 0);
pub const EXITEVENT_STARTUP = @as(u32, 128);
pub const EXITEVENT_CERTIMPORTED = @as(u32, 512);
pub const ENUMEXT_OBJECTID = @as(u32, 1);
pub const CMM_REFRESHONLY = @as(u32, 1);
pub const CMM_READONLY = @as(u32, 2);
pub const DBSESSIONCOUNTDEFAULT = @as(u32, 100);
pub const DBFLAGS_READONLY = @as(u32, 1);
pub const DBFLAGS_CREATEIFNEEDED = @as(u32, 2);
pub const DBFLAGS_CIRCULARLOGGING = @as(u32, 4);
pub const DBFLAGS_LAZYFLUSH = @as(u32, 8);
pub const DBFLAGS_MAXCACHESIZEX100 = @as(u32, 16);
pub const DBFLAGS_CHECKPOINTDEPTH60MB = @as(u32, 32);
pub const DBFLAGS_LOGBUFFERSLARGE = @as(u32, 64);
pub const DBFLAGS_LOGBUFFERSHUGE = @as(u32, 128);
pub const DBFLAGS_LOGFILESIZE16MB = @as(u32, 256);
pub const DBFLAGS_MULTITHREADTRANSACTIONS = @as(u32, 512);
pub const DBFLAGS_DISABLESNAPSHOTBACKUP = @as(u32, 1024);
pub const DBFLAGS_ENABLEVOLATILEREQUESTS = @as(u32, 2048);
pub const LDAPF_SSLENABLE = @as(u32, 1);
pub const LDAPF_SIGNDISABLE = @as(u32, 2);
pub const CSVER_MAJOR_WIN2K = @as(u32, 1);
pub const CSVER_MINOR_WIN2K = @as(u32, 1);
pub const CSVER_MAJOR_WHISTLER = @as(u32, 2);
pub const CSVER_MINOR_WHISTLER_BETA2 = @as(u32, 1);
pub const CSVER_MINOR_WHISTLER_BETA3 = @as(u32, 2);
pub const CSVER_MAJOR_LONGHORN = @as(u32, 3);
pub const CSVER_MINOR_LONGHORN_BETA1 = @as(u32, 1);
pub const CSVER_MAJOR_WIN7 = @as(u32, 4);
pub const CSVER_MINOR_WIN7 = @as(u32, 1);
pub const CSVER_MAJOR_WIN8 = @as(u32, 5);
pub const CSVER_MINOR_WIN8 = @as(u32, 1);
pub const CSVER_MAJOR_WINBLUE = @as(u32, 6);
pub const CSVER_MINOR_WINBLUE = @as(u32, 1);
pub const CSVER_MAJOR_THRESHOLD = @as(u32, 7);
pub const CSVER_MINOR_THRESHOLD = @as(u32, 1);
pub const CSVER_MAJOR = @as(u32, 7);
pub const CSVER_MINOR = @as(u32, 1);
pub const CCLOCKSKEWMINUTESDEFAULT = @as(u32, 10);
pub const CVIEWAGEMINUTESDEFAULT = @as(u32, 16);
pub const SETUP_SERVER_FLAG = @as(u32, 1);
pub const SETUP_CLIENT_FLAG = @as(u32, 2);
pub const SETUP_SUSPEND_FLAG = @as(u32, 4);
pub const SETUP_REQUEST_FLAG = @as(u32, 8);
pub const SETUP_ONLINE_FLAG = @as(u32, 16);
pub const SETUP_DENIED_FLAG = @as(u32, 32);
pub const SETUP_CREATEDB_FLAG = @as(u32, 64);
pub const SETUP_ATTEMPT_VROOT_CREATE = @as(u32, 128);
pub const SETUP_FORCECRL_FLAG = @as(u32, 256);
pub const SETUP_UPDATE_CAOBJECT_SVRTYPE = @as(u32, 512);
pub const SETUP_SERVER_UPGRADED_FLAG = @as(u32, 1024);
pub const SETUP_W2K_SECURITY_NOT_UPGRADED_FLAG = @as(u32, 2048);
pub const SETUP_SECURITY_CHANGED = @as(u32, 4096);
pub const SETUP_DCOM_SECURITY_UPDATED_FLAG = @as(u32, 8192);
pub const SETUP_SERVER_IS_UP_TO_DATE_FLAG = @as(u32, 16384);
pub const CRLF_DELTA_USE_OLDEST_UNEXPIRED_BASE = @as(u32, 1);
pub const CRLF_DELETE_EXPIRED_CRLS = @as(u32, 2);
pub const CRLF_CRLNUMBER_CRITICAL = @as(u32, 4);
pub const CRLF_REVCHECK_IGNORE_OFFLINE = @as(u32, 8);
pub const CRLF_IGNORE_INVALID_POLICIES = @as(u32, 16);
pub const CRLF_REBUILD_MODIFIED_SUBJECT_ONLY = @as(u32, 32);
pub const CRLF_SAVE_FAILED_CERTS = @as(u32, 64);
pub const CRLF_IGNORE_UNKNOWN_CMC_ATTRIBUTES = @as(u32, 128);
pub const CRLF_IGNORE_CROSS_CERT_TRUST_ERROR = @as(u32, 256);
pub const CRLF_PUBLISH_EXPIRED_CERT_CRLS = @as(u32, 512);
pub const CRLF_ENFORCE_ENROLLMENT_AGENT = @as(u32, 1024);
pub const CRLF_DISABLE_RDN_REORDER = @as(u32, 2048);
pub const CRLF_DISABLE_ROOT_CROSS_CERTS = @as(u32, 4096);
pub const CRLF_LOG_FULL_RESPONSE = @as(u32, 8192);
pub const CRLF_USE_XCHG_CERT_TEMPLATE = @as(u32, 16384);
pub const CRLF_USE_CROSS_CERT_TEMPLATE = @as(u32, 32768);
pub const CRLF_ALLOW_REQUEST_ATTRIBUTE_SUBJECT = @as(u32, 65536);
pub const CRLF_REVCHECK_IGNORE_NOREVCHECK = @as(u32, 131072);
pub const CRLF_PRESERVE_EXPIRED_CA_CERTS = @as(u32, 262144);
pub const CRLF_PRESERVE_REVOKED_CA_CERTS = @as(u32, 524288);
pub const CRLF_DISABLE_CHAIN_VERIFICATION = @as(u32, 1048576);
pub const CRLF_BUILD_ROOTCA_CRLENTRIES_BASEDONKEY = @as(u32, 2097152);
pub const KRAF_ENABLEFOREIGN = @as(u32, 1);
pub const KRAF_SAVEBADREQUESTKEY = @as(u32, 2);
pub const KRAF_ENABLEARCHIVEALL = @as(u32, 4);
pub const KRAF_DISABLEUSEDEFAULTPROVIDER = @as(u32, 8);
pub const IF_LOCKICERTREQUEST = @as(u32, 1);
pub const IF_NOREMOTEICERTREQUEST = @as(u32, 2);
pub const IF_NOLOCALICERTREQUEST = @as(u32, 4);
pub const IF_NORPCICERTREQUEST = @as(u32, 8);
pub const IF_NOREMOTEICERTADMIN = @as(u32, 16);
pub const IF_NOLOCALICERTADMIN = @as(u32, 32);
pub const IF_NOREMOTEICERTADMINBACKUP = @as(u32, 64);
pub const IF_NOLOCALICERTADMINBACKUP = @as(u32, 128);
pub const IF_NOSNAPSHOTBACKUP = @as(u32, 256);
pub const IF_ENFORCEENCRYPTICERTREQUEST = @as(u32, 512);
pub const IF_ENFORCEENCRYPTICERTADMIN = @as(u32, 1024);
pub const IF_ENABLEEXITKEYRETRIEVAL = @as(u32, 2048);
pub const IF_ENABLEADMINASAUDITOR = @as(u32, 4096);
pub const PROCFLG_NONE = @as(u32, 0);
pub const PROCFLG_ENFORCEGOODKEYS = @as(u32, 1);
pub const CSURL_SERVERPUBLISH = @as(u32, 1);
pub const CSURL_ADDTOCERTCDP = @as(u32, 2);
pub const CSURL_ADDTOFRESHESTCRL = @as(u32, 4);
pub const CSURL_ADDTOCRLCDP = @as(u32, 8);
pub const CSURL_PUBLISHRETRY = @as(u32, 16);
pub const CSURL_ADDTOCERTOCSP = @as(u32, 32);
pub const CSURL_SERVERPUBLISHDELTA = @as(u32, 64);
pub const CSURL_ADDTOIDP = @as(u32, 128);
pub const CAPATHLENGTH_INFINITE = @as(u32, 4294967295);
pub const REQDISP_PENDING = @as(u32, 0);
pub const REQDISP_ISSUE = @as(u32, 1);
pub const REQDISP_DENY = @as(u32, 2);
pub const REQDISP_USEREQUESTATTRIBUTE = @as(u32, 3);
pub const REQDISP_MASK = @as(u32, 255);
pub const REQDISP_PENDINGFIRST = @as(u32, 256);
pub const REQDISP_DEFAULT_ENTERPRISE = @as(u32, 1);
pub const REVEXT_CDPLDAPURL_OLD = @as(u32, 1);
pub const REVEXT_CDPHTTPURL_OLD = @as(u32, 2);
pub const REVEXT_CDPFTPURL_OLD = @as(u32, 4);
pub const REVEXT_CDPFILEURL_OLD = @as(u32, 8);
pub const REVEXT_CDPURLMASK_OLD = @as(u32, 255);
pub const REVEXT_CDPENABLE = @as(u32, 256);
pub const REVEXT_ASPENABLE = @as(u32, 512);
pub const REVEXT_DEFAULT_NODS = @as(u32, 256);
pub const REVEXT_DEFAULT_DS = @as(u32, 256);
pub const ISSCERT_LDAPURL_OLD = @as(u32, 1);
pub const ISSCERT_HTTPURL_OLD = @as(u32, 2);
pub const ISSCERT_FTPURL_OLD = @as(u32, 4);
pub const ISSCERT_FILEURL_OLD = @as(u32, 8);
pub const ISSCERT_URLMASK_OLD = @as(u32, 255);
pub const ISSCERT_ENABLE = @as(u32, 256);
pub const ISSCERT_DEFAULT_NODS = @as(u32, 256);
pub const ISSCERT_DEFAULT_DS = @as(u32, 256);
pub const EDITF_ENABLEREQUESTEXTENSIONS = @as(u32, 1);
pub const EDITF_REQUESTEXTENSIONLIST = @as(u32, 2);
pub const EDITF_DISABLEEXTENSIONLIST = @as(u32, 4);
pub const EDITF_ADDOLDKEYUSAGE = @as(u32, 8);
pub const EDITF_ADDOLDCERTTYPE = @as(u32, 16);
pub const EDITF_ATTRIBUTEENDDATE = @as(u32, 32);
pub const EDITF_BASICCONSTRAINTSCRITICAL = @as(u32, 64);
pub const EDITF_BASICCONSTRAINTSCA = @as(u32, 128);
pub const EDITF_ENABLEAKIKEYID = @as(u32, 256);
pub const EDITF_ATTRIBUTECA = @as(u32, 512);
pub const EDITF_IGNOREREQUESTERGROUP = @as(u32, 1024);
pub const EDITF_ENABLEAKIISSUERNAME = @as(u32, 2048);
pub const EDITF_ENABLEAKIISSUERSERIAL = @as(u32, 4096);
pub const EDITF_ENABLEAKICRITICAL = @as(u32, 8192);
pub const EDITF_SERVERUPGRADED = @as(u32, 16384);
pub const EDITF_ATTRIBUTEEKU = @as(u32, 32768);
pub const EDITF_ENABLEDEFAULTSMIME = @as(u32, 65536);
pub const EDITF_EMAILOPTIONAL = @as(u32, 131072);
pub const EDITF_ATTRIBUTESUBJECTALTNAME2 = @as(u32, 262144);
pub const EDITF_ENABLELDAPREFERRALS = @as(u32, 524288);
pub const EDITF_ENABLECHASECLIENTDC = @as(u32, 1048576);
pub const EDITF_AUDITCERTTEMPLATELOAD = @as(u32, 2097152);
pub const EDITF_DISABLEOLDOSCNUPN = @as(u32, 4194304);
pub const EDITF_DISABLELDAPPACKAGELIST = @as(u32, 8388608);
pub const EDITF_ENABLEUPNMAP = @as(u32, 16777216);
pub const EDITF_ENABLEOCSPREVNOCHECK = @as(u32, 33554432);
pub const EDITF_ENABLERENEWONBEHALFOF = @as(u32, 67108864);
pub const EDITF_ENABLEKEYENCIPHERMENTCACERT = @as(u32, 134217728);
pub const EXITPUB_FILE = @as(u32, 1);
pub const EXITPUB_ACTIVEDIRECTORY = @as(u32, 2);
pub const EXITPUB_REMOVEOLDCERTS = @as(u32, 16);
pub const EXITPUB_DEFAULT_ENTERPRISE = @as(u32, 2);
pub const EXITPUB_DEFAULT_STANDALONE = @as(u32, 1);
pub const TP_MACHINEPOLICY = @as(u32, 1);
pub const KR_ENABLE_MACHINE = @as(u32, 1);
pub const KR_ENABLE_USER = @as(u32, 2);
pub const EXTENSION_CRITICAL_FLAG = @as(u32, 1);
pub const EXTENSION_DISABLE_FLAG = @as(u32, 2);
pub const EXTENSION_DELETE_FLAG = @as(u32, 4);
pub const EXTENSION_POLICY_MASK = @as(u32, 65535);
pub const EXTENSION_ORIGIN_REQUEST = @as(u32, 65536);
pub const EXTENSION_ORIGIN_POLICY = @as(u32, 131072);
pub const EXTENSION_ORIGIN_ADMIN = @as(u32, 196608);
pub const EXTENSION_ORIGIN_SERVER = @as(u32, 262144);
pub const EXTENSION_ORIGIN_RENEWALCERT = @as(u32, 327680);
pub const EXTENSION_ORIGIN_IMPORTEDCERT = @as(u32, 393216);
pub const EXTENSION_ORIGIN_PKCS7 = @as(u32, 458752);
pub const EXTENSION_ORIGIN_CMC = @as(u32, 524288);
pub const EXTENSION_ORIGIN_CACERT = @as(u32, 589824);
pub const EXTENSION_ORIGIN_MASK = @as(u32, 983040);
pub const CPF_BASE = @as(u32, 1);
pub const CPF_DELTA = @as(u32, 2);
pub const CPF_COMPLETE = @as(u32, 4);
pub const CPF_SHADOW = @as(u32, 8);
pub const CPF_CASTORE_ERROR = @as(u32, 16);
pub const CPF_BADURL_ERROR = @as(u32, 32);
pub const CPF_MANUAL = @as(u32, 64);
pub const CPF_SIGNATURE_ERROR = @as(u32, 128);
pub const CPF_LDAP_ERROR = @as(u32, 256);
pub const CPF_FILE_ERROR = @as(u32, 512);
pub const CPF_FTP_ERROR = @as(u32, 1024);
pub const CPF_HTTP_ERROR = @as(u32, 2048);
pub const CPF_POSTPONED_BASE_LDAP_ERROR = @as(u32, 4096);
pub const CPF_POSTPONED_BASE_FILE_ERROR = @as(u32, 8192);
pub const PROPTYPE_MASK = @as(u32, 255);
pub const PROPCALLER_SERVER = @as(u32, 256);
pub const PROPCALLER_POLICY = @as(u32, 512);
pub const PROPCALLER_EXIT = @as(u32, 768);
pub const PROPCALLER_ADMIN = @as(u32, 1024);
pub const PROPCALLER_REQUEST = @as(u32, 1280);
pub const PROPCALLER_MASK = @as(u32, 3840);
pub const PROPFLAGS_INDEXED = @as(u32, 65536);
pub const CR_FLG_FORCETELETEX = @as(u32, 1);
pub const CR_FLG_RENEWAL = @as(u32, 2);
pub const CR_FLG_FORCEUTF8 = @as(u32, 4);
pub const CR_FLG_CAXCHGCERT = @as(u32, 8);
pub const CR_FLG_ENROLLONBEHALFOF = @as(u32, 16);
pub const CR_FLG_SUBJECTUNMODIFIED = @as(u32, 32);
pub const CR_FLG_VALIDENCRYPTEDKEYHASH = @as(u32, 64);
pub const CR_FLG_CACROSSCERT = @as(u32, 128);
pub const CR_FLG_ENFORCEUTF8 = @as(u32, 256);
pub const CR_FLG_DEFINEDCACERT = @as(u32, 512);
pub const CR_FLG_CHALLENGEPENDING = @as(u32, 1024);
pub const CR_FLG_CHALLENGESATISFIED = @as(u32, 2048);
pub const CR_FLG_TRUSTONUSE = @as(u32, 4096);
pub const CR_FLG_TRUSTEKCERT = @as(u32, 8192);
pub const CR_FLG_TRUSTEKKEY = @as(u32, 16384);
pub const CR_FLG_PUBLISHERROR = @as(u32, 2147483648);
pub const DB_DISP_ACTIVE = @as(u32, 8);
pub const DB_DISP_PENDING = @as(u32, 9);
pub const DB_DISP_QUEUE_MAX = @as(u32, 9);
pub const DB_DISP_FOREIGN = @as(u32, 12);
pub const DB_DISP_CA_CERT = @as(u32, 15);
pub const DB_DISP_CA_CERT_CHAIN = @as(u32, 16);
pub const DB_DISP_KRA_CERT = @as(u32, 17);
pub const DB_DISP_LOG_MIN = @as(u32, 20);
pub const DB_DISP_ISSUED = @as(u32, 20);
pub const DB_DISP_REVOKED = @as(u32, 21);
pub const DB_DISP_LOG_FAILED_MIN = @as(u32, 30);
pub const DB_DISP_ERROR = @as(u32, 30);
pub const DB_DISP_DENIED = @as(u32, 31);
pub const VR_PENDING = @as(u32, 0);
pub const VR_INSTANT_OK = @as(u32, 1);
pub const VR_INSTANT_BAD = @as(u32, 2);
pub const CV_OUT_HEXRAW = @as(u32, 12);
pub const CV_OUT_ENCODEMASK = @as(u32, 255);
pub const CV_OUT_NOCRLF = @as(u32, 1073741824);
pub const CV_OUT_NOCR = @as(u32, 2147483648);
pub const CVR_SEEK_NONE = @as(u32, 0);
pub const CVR_SEEK_MASK = @as(u32, 255);
pub const CVR_SEEK_NODELTA = @as(u32, 4096);
pub const CVR_SORT_NONE = @as(u32, 0);
pub const CVR_SORT_ASCEND = @as(u32, 1);
pub const CVR_SORT_DESCEND = @as(u32, 2);
pub const CV_COLUMN_EXTENSION_DEFAULT = @as(i32, -4);
pub const CV_COLUMN_ATTRIBUTE_DEFAULT = @as(i32, -5);
pub const CV_COLUMN_CRL_DEFAULT = @as(i32, -6);
pub const CV_COLUMN_LOG_REVOKED_DEFAULT = @as(i32, -7);
pub const CVRC_TABLE_MASK = @as(u32, 61440);
pub const CVRC_TABLE_SHIFT = @as(u32, 12);
pub const CRYPT_ENUM_ALL_PROVIDERS = @as(u32, 1);
pub const XEPR_ENUM_FIRST = @as(i32, -1);
pub const XEPR_DATE = @as(u32, 5);
pub const XEPR_TEMPLATENAME = @as(u32, 6);
pub const XEPR_VERSION = @as(u32, 7);
pub const XEPR_V1TEMPLATENAME = @as(u32, 9);
pub const XEPR_V2TEMPLATEOID = @as(u32, 16);
pub const XEKL_KEYSIZE_DEFAULT = @as(u32, 4);
pub const XECP_STRING_PROPERTY = @as(u32, 1);
pub const XECI_DISABLE = @as(u32, 0);
pub const XECI_XENROLL = @as(u32, 1);
pub const XECI_AUTOENROLL = @as(u32, 2);
pub const XECI_REQWIZARD = @as(u32, 3);
pub const XECI_CERTREQ = @as(u32, 4);
pub const wszCMM_PROP_NAME = "Name";
pub const wszCMM_PROP_DESCRIPTION = "Description";
pub const wszCMM_PROP_COPYRIGHT = "Copyright";
pub const wszCMM_PROP_FILEVER = "File Version";
pub const wszCMM_PROP_PRODUCTVER = "Product Version";
pub const wszCMM_PROP_DISPLAY_HWND = "HWND";
pub const wszCMM_PROP_ISMULTITHREADED = "IsMultiThreaded";
//--------------------------------------------------------------------------------
// Section: Types (344)
//--------------------------------------------------------------------------------
pub const CERT_VIEW_COLUMN_INDEX = enum(i32) {
LOG_DEFAULT = -2,
LOG_FAILED_DEFAULT = -3,
QUEUE_DEFAULT = -1,
};
pub const CV_COLUMN_LOG_DEFAULT = CERT_VIEW_COLUMN_INDEX.LOG_DEFAULT;
pub const CV_COLUMN_LOG_FAILED_DEFAULT = CERT_VIEW_COLUMN_INDEX.LOG_FAILED_DEFAULT;
pub const CV_COLUMN_QUEUE_DEFAULT = CERT_VIEW_COLUMN_INDEX.QUEUE_DEFAULT;
pub const CERT_DELETE_ROW_FLAGS = enum(u32) {
EXPIRED = 1,
REQUEST_LAST_CHANGED = 2,
};
pub const CDR_EXPIRED = CERT_DELETE_ROW_FLAGS.EXPIRED;
pub const CDR_REQUEST_LAST_CHANGED = CERT_DELETE_ROW_FLAGS.REQUEST_LAST_CHANGED;
pub const FULL_RESPONSE_PROPERTY_ID = enum(u32) {
NONE = 0,
FULLRESPONSE = 1,
STATUSINFOCOUNT = 2,
BODYPARTSTRING = 3,
STATUS = 4,
STATUSSTRING = 5,
OTHERINFOCHOICE = 6,
FAILINFO = 7,
PENDINFOTOKEN = 8,
PENDINFOTIME = 9,
ISSUEDCERTIFICATEHASH = 10,
ISSUEDCERTIFICATE = 11,
ISSUEDCERTIFICATECHAIN = 12,
ISSUEDCERTIFICATECRLCHAIN = 13,
ENCRYPTEDKEYHASH = 14,
FULLRESPONSENOPKCS7 = 15,
CAEXCHANGECERTIFICATEHASH = 16,
CAEXCHANGECERTIFICATE = 17,
CAEXCHANGECERTIFICATECHAIN = 18,
CAEXCHANGECERTIFICATECRLCHAIN = 19,
ATTESTATIONCHALLENGE = 20,
ATTESTATIONPROVIDERNAME = 21,
};
pub const FR_PROP_NONE = FULL_RESPONSE_PROPERTY_ID.NONE;
pub const FR_PROP_FULLRESPONSE = FULL_RESPONSE_PROPERTY_ID.FULLRESPONSE;
pub const FR_PROP_STATUSINFOCOUNT = FULL_RESPONSE_PROPERTY_ID.STATUSINFOCOUNT;
pub const FR_PROP_BODYPARTSTRING = FULL_RESPONSE_PROPERTY_ID.BODYPARTSTRING;
pub const FR_PROP_STATUS = FULL_RESPONSE_PROPERTY_ID.STATUS;
pub const FR_PROP_STATUSSTRING = FULL_RESPONSE_PROPERTY_ID.STATUSSTRING;
pub const FR_PROP_OTHERINFOCHOICE = FULL_RESPONSE_PROPERTY_ID.OTHERINFOCHOICE;
pub const FR_PROP_FAILINFO = FULL_RESPONSE_PROPERTY_ID.FAILINFO;
pub const FR_PROP_PENDINFOTOKEN = FULL_RESPONSE_PROPERTY_ID.PENDINFOTOKEN;
pub const FR_PROP_PENDINFOTIME = FULL_RESPONSE_PROPERTY_ID.PENDINFOTIME;
pub const FR_PROP_ISSUEDCERTIFICATEHASH = FULL_RESPONSE_PROPERTY_ID.ISSUEDCERTIFICATEHASH;
pub const FR_PROP_ISSUEDCERTIFICATE = FULL_RESPONSE_PROPERTY_ID.ISSUEDCERTIFICATE;
pub const FR_PROP_ISSUEDCERTIFICATECHAIN = FULL_RESPONSE_PROPERTY_ID.ISSUEDCERTIFICATECHAIN;
pub const FR_PROP_ISSUEDCERTIFICATECRLCHAIN = FULL_RESPONSE_PROPERTY_ID.ISSUEDCERTIFICATECRLCHAIN;
pub const FR_PROP_ENCRYPTEDKEYHASH = FULL_RESPONSE_PROPERTY_ID.ENCRYPTEDKEYHASH;
pub const FR_PROP_FULLRESPONSENOPKCS7 = FULL_RESPONSE_PROPERTY_ID.FULLRESPONSENOPKCS7;
pub const FR_PROP_CAEXCHANGECERTIFICATEHASH = FULL_RESPONSE_PROPERTY_ID.CAEXCHANGECERTIFICATEHASH;
pub const FR_PROP_CAEXCHANGECERTIFICATE = FULL_RESPONSE_PROPERTY_ID.CAEXCHANGECERTIFICATE;
pub const FR_PROP_CAEXCHANGECERTIFICATECHAIN = FULL_RESPONSE_PROPERTY_ID.CAEXCHANGECERTIFICATECHAIN;
pub const FR_PROP_CAEXCHANGECERTIFICATECRLCHAIN = FULL_RESPONSE_PROPERTY_ID.CAEXCHANGECERTIFICATECRLCHAIN;
pub const FR_PROP_ATTESTATIONCHALLENGE = FULL_RESPONSE_PROPERTY_ID.ATTESTATIONCHALLENGE;
pub const FR_PROP_ATTESTATIONPROVIDERNAME = FULL_RESPONSE_PROPERTY_ID.ATTESTATIONPROVIDERNAME;
pub const CVRC_COLUMN = enum(u32) {
SCHEMA = 0,
RESULT = 1,
VALUE = 2,
MASK = 4095,
};
pub const CVRC_COLUMN_SCHEMA = CVRC_COLUMN.SCHEMA;
pub const CVRC_COLUMN_RESULT = CVRC_COLUMN.RESULT;
pub const CVRC_COLUMN_VALUE = CVRC_COLUMN.VALUE;
pub const CVRC_COLUMN_MASK = CVRC_COLUMN.MASK;
pub const CERT_IMPORT_FLAGS = enum(u32) {
ASE64HEADER = 0,
ASE64 = 1,
INARY = 2,
};
pub const CR_IN_BASE64HEADER = CERT_IMPORT_FLAGS.ASE64HEADER;
pub const CR_IN_BASE64 = CERT_IMPORT_FLAGS.ASE64;
pub const CR_IN_BINARY = CERT_IMPORT_FLAGS.INARY;
pub const CERT_GET_CONFIG_FLAGS = enum(u32) {
DEFAULTCONFIG = 0,
FIRSTCONFIG = 2,
LOCALACTIVECONFIG = 4,
LOCALCONFIG = 3,
UIPICKCONFIG = 1,
UIPICKCONFIGSKIPLOCALCA_ = 5,
};
pub const CC_DEFAULTCONFIG = CERT_GET_CONFIG_FLAGS.DEFAULTCONFIG;
pub const CC_FIRSTCONFIG = CERT_GET_CONFIG_FLAGS.FIRSTCONFIG;
pub const CC_LOCALACTIVECONFIG = CERT_GET_CONFIG_FLAGS.LOCALACTIVECONFIG;
pub const CC_LOCALCONFIG = CERT_GET_CONFIG_FLAGS.LOCALCONFIG;
pub const CC_UIPICKCONFIG = CERT_GET_CONFIG_FLAGS.UIPICKCONFIG;
pub const CC_UIPICKCONFIGSKIPLOCALCA_ = CERT_GET_CONFIG_FLAGS.UIPICKCONFIGSKIPLOCALCA_;
pub const ENUM_CERT_COLUMN_VALUE_FLAGS = enum(u32) {
BASE64 = 1,
BASE64HEADER = 0,
BASE64REQUESTHEADER = 3,
BASE64X509CRLHEADER = 9,
BINARY = 2,
HEX = 4,
HEXADDR = 10,
HEXASCII = 5,
HEXASCIIADDR = 11,
};
pub const CV_OUT_BASE64 = ENUM_CERT_COLUMN_VALUE_FLAGS.BASE64;
pub const CV_OUT_BASE64HEADER = ENUM_CERT_COLUMN_VALUE_FLAGS.BASE64HEADER;
pub const CV_OUT_BASE64REQUESTHEADER = ENUM_CERT_COLUMN_VALUE_FLAGS.BASE64REQUESTHEADER;
pub const CV_OUT_BASE64X509CRLHEADER = ENUM_CERT_COLUMN_VALUE_FLAGS.BASE64X509CRLHEADER;
pub const CV_OUT_BINARY = ENUM_CERT_COLUMN_VALUE_FLAGS.BINARY;
pub const CV_OUT_HEX = ENUM_CERT_COLUMN_VALUE_FLAGS.HEX;
pub const CV_OUT_HEXADDR = ENUM_CERT_COLUMN_VALUE_FLAGS.HEXADDR;
pub const CV_OUT_HEXASCII = ENUM_CERT_COLUMN_VALUE_FLAGS.HEXASCII;
pub const CV_OUT_HEXASCIIADDR = ENUM_CERT_COLUMN_VALUE_FLAGS.HEXASCIIADDR;
pub const PENDING_REQUEST_DESIRED_PROPERTY = enum(u32) {
CADNS = 1,
CAFRIENDLYNAME = 3,
CANAME = 2,
HASH = 8,
REQUESTID = 4,
};
pub const XEPR_CADNS = PENDING_REQUEST_DESIRED_PROPERTY.CADNS;
pub const XEPR_CAFRIENDLYNAME = PENDING_REQUEST_DESIRED_PROPERTY.CAFRIENDLYNAME;
pub const XEPR_CANAME = PENDING_REQUEST_DESIRED_PROPERTY.CANAME;
pub const XEPR_HASH = PENDING_REQUEST_DESIRED_PROPERTY.HASH;
pub const XEPR_REQUESTID = PENDING_REQUEST_DESIRED_PROPERTY.REQUESTID;
pub const CERTADMIN_GET_ROLES_FLAGS = enum(u32) {
ADMIN = 1,
AUDITOR = 4,
ENROLL = 512,
OFFICER = 2,
OPERATOR = 8,
READ = 256,
_,
pub fn initFlags(o: struct {
ADMIN: u1 = 0,
AUDITOR: u1 = 0,
ENROLL: u1 = 0,
OFFICER: u1 = 0,
OPERATOR: u1 = 0,
READ: u1 = 0,
}) CERTADMIN_GET_ROLES_FLAGS {
return @intToEnum(CERTADMIN_GET_ROLES_FLAGS,
(if (o.ADMIN == 1) @enumToInt(CERTADMIN_GET_ROLES_FLAGS.ADMIN) else 0)
| (if (o.AUDITOR == 1) @enumToInt(CERTADMIN_GET_ROLES_FLAGS.AUDITOR) else 0)
| (if (o.ENROLL == 1) @enumToInt(CERTADMIN_GET_ROLES_FLAGS.ENROLL) else 0)
| (if (o.OFFICER == 1) @enumToInt(CERTADMIN_GET_ROLES_FLAGS.OFFICER) else 0)
| (if (o.OPERATOR == 1) @enumToInt(CERTADMIN_GET_ROLES_FLAGS.OPERATOR) else 0)
| (if (o.READ == 1) @enumToInt(CERTADMIN_GET_ROLES_FLAGS.READ) else 0)
);
}
};
pub const CA_ACCESS_ADMIN = CERTADMIN_GET_ROLES_FLAGS.ADMIN;
pub const CA_ACCESS_AUDITOR = CERTADMIN_GET_ROLES_FLAGS.AUDITOR;
pub const CA_ACCESS_ENROLL = CERTADMIN_GET_ROLES_FLAGS.ENROLL;
pub const CA_ACCESS_OFFICER = CERTADMIN_GET_ROLES_FLAGS.OFFICER;
pub const CA_ACCESS_OPERATOR = CERTADMIN_GET_ROLES_FLAGS.OPERATOR;
pub const CA_ACCESS_READ = CERTADMIN_GET_ROLES_FLAGS.READ;
pub const CR_DISP = enum(u32) {
DENIED = 2,
ERROR = 1,
INCOMPLETE = 0,
ISSUED = 3,
ISSUED_OUT_OF_BAND = 4,
UNDER_SUBMISSION = 5,
};
pub const CR_DISP_DENIED = CR_DISP.DENIED;
pub const CR_DISP_ERROR = CR_DISP.ERROR;
pub const CR_DISP_INCOMPLETE = CR_DISP.INCOMPLETE;
pub const CR_DISP_ISSUED = CR_DISP.ISSUED;
pub const CR_DISP_ISSUED_OUT_OF_BAND = CR_DISP.ISSUED_OUT_OF_BAND;
pub const CR_DISP_UNDER_SUBMISSION = CR_DISP.UNDER_SUBMISSION;
pub const XEKL_KEYSIZE = enum(u32) {
MIN = 1,
MAX = 2,
INC = 3,
};
pub const XEKL_KEYSIZE_MIN = XEKL_KEYSIZE.MIN;
pub const XEKL_KEYSIZE_MAX = XEKL_KEYSIZE.MAX;
pub const XEKL_KEYSIZE_INC = XEKL_KEYSIZE.INC;
pub const CERT_CREATE_REQUEST_FLAGS = enum(u32) {
CMC = 3,
PKCS10_V1_5 = 4,
PKCS10_V2_0 = 1,
PKCS7 = 2,
};
pub const XECR_CMC = CERT_CREATE_REQUEST_FLAGS.CMC;
pub const XECR_PKCS10_V1_5 = CERT_CREATE_REQUEST_FLAGS.PKCS10_V1_5;
pub const XECR_PKCS10_V2_0 = CERT_CREATE_REQUEST_FLAGS.PKCS10_V2_0;
pub const XECR_PKCS7 = CERT_CREATE_REQUEST_FLAGS.PKCS7;
pub const CERT_EXIT_EVENT_MASK = enum(u32) {
CERTDENIED = 4,
CERTISSUED = 1,
CERTPENDING = 2,
CERTRETRIEVEPENDING = 16,
CERTREVOKED = 8,
CRLISSUED = 32,
SHUTDOWN = 64,
_,
pub fn initFlags(o: struct {
CERTDENIED: u1 = 0,
CERTISSUED: u1 = 0,
CERTPENDING: u1 = 0,
CERTRETRIEVEPENDING: u1 = 0,
CERTREVOKED: u1 = 0,
CRLISSUED: u1 = 0,
SHUTDOWN: u1 = 0,
}) CERT_EXIT_EVENT_MASK {
return @intToEnum(CERT_EXIT_EVENT_MASK,
(if (o.CERTDENIED == 1) @enumToInt(CERT_EXIT_EVENT_MASK.CERTDENIED) else 0)
| (if (o.CERTISSUED == 1) @enumToInt(CERT_EXIT_EVENT_MASK.CERTISSUED) else 0)
| (if (o.CERTPENDING == 1) @enumToInt(CERT_EXIT_EVENT_MASK.CERTPENDING) else 0)
| (if (o.CERTRETRIEVEPENDING == 1) @enumToInt(CERT_EXIT_EVENT_MASK.CERTRETRIEVEPENDING) else 0)
| (if (o.CERTREVOKED == 1) @enumToInt(CERT_EXIT_EVENT_MASK.CERTREVOKED) else 0)
| (if (o.CRLISSUED == 1) @enumToInt(CERT_EXIT_EVENT_MASK.CRLISSUED) else 0)
| (if (o.SHUTDOWN == 1) @enumToInt(CERT_EXIT_EVENT_MASK.SHUTDOWN) else 0)
);
}
};
pub const EXITEVENT_CERTDENIED = CERT_EXIT_EVENT_MASK.CERTDENIED;
pub const EXITEVENT_CERTISSUED = CERT_EXIT_EVENT_MASK.CERTISSUED;
pub const EXITEVENT_CERTPENDING = CERT_EXIT_EVENT_MASK.CERTPENDING;
pub const EXITEVENT_CERTRETRIEVEPENDING = CERT_EXIT_EVENT_MASK.CERTRETRIEVEPENDING;
pub const EXITEVENT_CERTREVOKED = CERT_EXIT_EVENT_MASK.CERTREVOKED;
pub const EXITEVENT_CRLISSUED = CERT_EXIT_EVENT_MASK.CRLISSUED;
pub const EXITEVENT_SHUTDOWN = CERT_EXIT_EVENT_MASK.SHUTDOWN;
pub const ADDED_CERT_TYPE = enum(u32) {
@"1" = 1,
@"2" = 2,
};
pub const XECT_EXTENSION_V1 = ADDED_CERT_TYPE.@"1";
pub const XECT_EXTENSION_V2 = ADDED_CERT_TYPE.@"2";
pub const CVRC_TABLE = enum(u32) {
ATTRIBUTES = 16384,
CRL = 20480,
EXTENSIONS = 12288,
REQCERT = 0,
};
pub const CVRC_TABLE_ATTRIBUTES = CVRC_TABLE.ATTRIBUTES;
pub const CVRC_TABLE_CRL = CVRC_TABLE.CRL;
pub const CVRC_TABLE_EXTENSIONS = CVRC_TABLE.EXTENSIONS;
pub const CVRC_TABLE_REQCERT = CVRC_TABLE.REQCERT;
pub const CERT_PROPERTY_TYPE = enum(u32) {
BINARY = 3,
DATE = 2,
LONG = 1,
STRING = 4,
};
pub const PROPTYPE_BINARY = CERT_PROPERTY_TYPE.BINARY;
pub const PROPTYPE_DATE = CERT_PROPERTY_TYPE.DATE;
pub const PROPTYPE_LONG = CERT_PROPERTY_TYPE.LONG;
pub const PROPTYPE_STRING = CERT_PROPERTY_TYPE.STRING;
pub const CERT_ALT_NAME = enum(u32) {
RFC822_NAME = 2,
DNS_NAME = 3,
URL = 7,
REGISTERED_ID = 9,
DIRECTORY_NAME = 5,
IP_ADDRESS = 8,
OTHER_NAME = 1,
};
pub const CERT_ALT_NAME_RFC822_NAME = CERT_ALT_NAME.RFC822_NAME;
pub const CERT_ALT_NAME_DNS_NAME = CERT_ALT_NAME.DNS_NAME;
pub const CERT_ALT_NAME_URL = CERT_ALT_NAME.URL;
pub const CERT_ALT_NAME_REGISTERED_ID = CERT_ALT_NAME.REGISTERED_ID;
pub const CERT_ALT_NAME_DIRECTORY_NAME = CERT_ALT_NAME.DIRECTORY_NAME;
pub const CERT_ALT_NAME_IP_ADDRESS = CERT_ALT_NAME.IP_ADDRESS;
pub const CERT_ALT_NAME_OTHER_NAME = CERT_ALT_NAME.OTHER_NAME;
pub const CSBACKUP_TYPE = enum(u32) {
FULL = 1,
LOGS_ONLY = 2,
};
pub const CSBACKUP_TYPE_FULL = CSBACKUP_TYPE.FULL;
pub const CSBACKUP_TYPE_LOGS_ONLY = CSBACKUP_TYPE.LOGS_ONLY;
pub const XEKL_KEYSPEC = enum(u32) {
KEYX = 1,
SIG = 2,
};
pub const XEKL_KEYSPEC_KEYX = XEKL_KEYSPEC.KEYX;
pub const XEKL_KEYSPEC_SIG = XEKL_KEYSPEC.SIG;
pub const CERT_REQUEST_OUT_TYPE = enum(u32) {
ASE64HEADER = 0,
ASE64 = 1,
INARY = 2,
};
pub const CR_OUT_BASE64HEADER = CERT_REQUEST_OUT_TYPE.ASE64HEADER;
pub const CR_OUT_BASE64 = CERT_REQUEST_OUT_TYPE.ASE64;
pub const CR_OUT_BINARY = CERT_REQUEST_OUT_TYPE.INARY;
pub const CERT_VIEW_SEEK_OPERATOR_FLAGS = enum(u32) {
EQ = 1,
LE = 4,
LT = 2,
GE = 8,
GT = 16,
};
pub const CVR_SEEK_EQ = CERT_VIEW_SEEK_OPERATOR_FLAGS.EQ;
pub const CVR_SEEK_LE = CERT_VIEW_SEEK_OPERATOR_FLAGS.LE;
pub const CVR_SEEK_LT = CERT_VIEW_SEEK_OPERATOR_FLAGS.LT;
pub const CVR_SEEK_GE = CERT_VIEW_SEEK_OPERATOR_FLAGS.GE;
pub const CVR_SEEK_GT = CERT_VIEW_SEEK_OPERATOR_FLAGS.GT;
const CLSID_CCertAdmin_Value = @import("../../zig.zig").Guid.initString("37eabaf0-7fb6-11d0-8817-00a0c903b83c");
pub const CLSID_CCertAdmin = &CLSID_CCertAdmin_Value;
const CLSID_CCertView_Value = @import("../../zig.zig").Guid.initString("a12d0f7a-1e84-11d1-9bd6-00c04fb683fa");
pub const CLSID_CCertView = &CLSID_CCertView_Value;
const CLSID_OCSPPropertyCollection_Value = @import("../../zig.zig").Guid.initString("f935a528-ba8a-4dd9-ba79-f283275cb2de");
pub const CLSID_OCSPPropertyCollection = &CLSID_OCSPPropertyCollection_Value;
const CLSID_OCSPAdmin_Value = @import("../../zig.zig").Guid.initString("d3f73511-92c9-47cb-8ff2-8d891a7c4de4");
pub const CLSID_OCSPAdmin = &CLSID_OCSPAdmin_Value;
// TODO: this type is limited to platform 'windowsServer2003'
const IID_IEnumCERTVIEWCOLUMN_Value = @import("../../zig.zig").Guid.initString("9c735be2-57a5-11d1-9bdb-00c04fb683fa");
pub const IID_IEnumCERTVIEWCOLUMN = &IID_IEnumCERTVIEWCOLUMN_Value;
pub const IEnumCERTVIEWCOLUMN = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Next: fn(
self: *const IEnumCERTVIEWCOLUMN,
pIndex: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetName: fn(
self: *const IEnumCERTVIEWCOLUMN,
pstrOut: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDisplayName: fn(
self: *const IEnumCERTVIEWCOLUMN,
pstrOut: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetType: fn(
self: *const IEnumCERTVIEWCOLUMN,
pType: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
IsIndexed: fn(
self: *const IEnumCERTVIEWCOLUMN,
pIndexed: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetMaxLength: fn(
self: *const IEnumCERTVIEWCOLUMN,
pMaxLength: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetValue: fn(
self: *const IEnumCERTVIEWCOLUMN,
Flags: ENUM_CERT_COLUMN_VALUE_FLAGS,
pvarValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Skip: fn(
self: *const IEnumCERTVIEWCOLUMN,
celt: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reset: fn(
self: *const IEnumCERTVIEWCOLUMN,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clone: fn(
self: *const IEnumCERTVIEWCOLUMN,
ppenum: ?*?*IEnumCERTVIEWCOLUMN,
) 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 IEnumCERTVIEWCOLUMN_Next(self: *const T, pIndex: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWCOLUMN.VTable, self.vtable).Next(@ptrCast(*const IEnumCERTVIEWCOLUMN, self), pIndex);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWCOLUMN_GetName(self: *const T, pstrOut: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWCOLUMN.VTable, self.vtable).GetName(@ptrCast(*const IEnumCERTVIEWCOLUMN, self), pstrOut);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWCOLUMN_GetDisplayName(self: *const T, pstrOut: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWCOLUMN.VTable, self.vtable).GetDisplayName(@ptrCast(*const IEnumCERTVIEWCOLUMN, self), pstrOut);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWCOLUMN_GetType(self: *const T, pType: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWCOLUMN.VTable, self.vtable).GetType(@ptrCast(*const IEnumCERTVIEWCOLUMN, self), pType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWCOLUMN_IsIndexed(self: *const T, pIndexed: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWCOLUMN.VTable, self.vtable).IsIndexed(@ptrCast(*const IEnumCERTVIEWCOLUMN, self), pIndexed);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWCOLUMN_GetMaxLength(self: *const T, pMaxLength: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWCOLUMN.VTable, self.vtable).GetMaxLength(@ptrCast(*const IEnumCERTVIEWCOLUMN, self), pMaxLength);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWCOLUMN_GetValue(self: *const T, Flags: ENUM_CERT_COLUMN_VALUE_FLAGS, pvarValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWCOLUMN.VTable, self.vtable).GetValue(@ptrCast(*const IEnumCERTVIEWCOLUMN, self), Flags, pvarValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWCOLUMN_Skip(self: *const T, celt: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWCOLUMN.VTable, self.vtable).Skip(@ptrCast(*const IEnumCERTVIEWCOLUMN, self), celt);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWCOLUMN_Reset(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWCOLUMN.VTable, self.vtable).Reset(@ptrCast(*const IEnumCERTVIEWCOLUMN, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWCOLUMN_Clone(self: *const T, ppenum: ?*?*IEnumCERTVIEWCOLUMN) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWCOLUMN.VTable, self.vtable).Clone(@ptrCast(*const IEnumCERTVIEWCOLUMN, self), ppenum);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_IEnumCERTVIEWATTRIBUTE_Value = @import("../../zig.zig").Guid.initString("e77db656-7653-11d1-9bde-00c04fb683fa");
pub const IID_IEnumCERTVIEWATTRIBUTE = &IID_IEnumCERTVIEWATTRIBUTE_Value;
pub const IEnumCERTVIEWATTRIBUTE = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Next: fn(
self: *const IEnumCERTVIEWATTRIBUTE,
pIndex: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetName: fn(
self: *const IEnumCERTVIEWATTRIBUTE,
pstrOut: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetValue: fn(
self: *const IEnumCERTVIEWATTRIBUTE,
pstrOut: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Skip: fn(
self: *const IEnumCERTVIEWATTRIBUTE,
celt: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reset: fn(
self: *const IEnumCERTVIEWATTRIBUTE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clone: fn(
self: *const IEnumCERTVIEWATTRIBUTE,
ppenum: ?*?*IEnumCERTVIEWATTRIBUTE,
) 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 IEnumCERTVIEWATTRIBUTE_Next(self: *const T, pIndex: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWATTRIBUTE.VTable, self.vtable).Next(@ptrCast(*const IEnumCERTVIEWATTRIBUTE, self), pIndex);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWATTRIBUTE_GetName(self: *const T, pstrOut: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWATTRIBUTE.VTable, self.vtable).GetName(@ptrCast(*const IEnumCERTVIEWATTRIBUTE, self), pstrOut);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWATTRIBUTE_GetValue(self: *const T, pstrOut: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWATTRIBUTE.VTable, self.vtable).GetValue(@ptrCast(*const IEnumCERTVIEWATTRIBUTE, self), pstrOut);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWATTRIBUTE_Skip(self: *const T, celt: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWATTRIBUTE.VTable, self.vtable).Skip(@ptrCast(*const IEnumCERTVIEWATTRIBUTE, self), celt);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWATTRIBUTE_Reset(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWATTRIBUTE.VTable, self.vtable).Reset(@ptrCast(*const IEnumCERTVIEWATTRIBUTE, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWATTRIBUTE_Clone(self: *const T, ppenum: ?*?*IEnumCERTVIEWATTRIBUTE) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWATTRIBUTE.VTable, self.vtable).Clone(@ptrCast(*const IEnumCERTVIEWATTRIBUTE, self), ppenum);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_IEnumCERTVIEWEXTENSION_Value = @import("../../zig.zig").Guid.initString("e7dd1466-7653-11d1-9bde-00c04fb683fa");
pub const IID_IEnumCERTVIEWEXTENSION = &IID_IEnumCERTVIEWEXTENSION_Value;
pub const IEnumCERTVIEWEXTENSION = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Next: fn(
self: *const IEnumCERTVIEWEXTENSION,
pIndex: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetName: fn(
self: *const IEnumCERTVIEWEXTENSION,
pstrOut: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetFlags: fn(
self: *const IEnumCERTVIEWEXTENSION,
pFlags: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetValue: fn(
self: *const IEnumCERTVIEWEXTENSION,
Type: CERT_PROPERTY_TYPE,
Flags: ENUM_CERT_COLUMN_VALUE_FLAGS,
pvarValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Skip: fn(
self: *const IEnumCERTVIEWEXTENSION,
celt: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reset: fn(
self: *const IEnumCERTVIEWEXTENSION,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clone: fn(
self: *const IEnumCERTVIEWEXTENSION,
ppenum: ?*?*IEnumCERTVIEWEXTENSION,
) 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 IEnumCERTVIEWEXTENSION_Next(self: *const T, pIndex: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWEXTENSION.VTable, self.vtable).Next(@ptrCast(*const IEnumCERTVIEWEXTENSION, self), pIndex);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWEXTENSION_GetName(self: *const T, pstrOut: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWEXTENSION.VTable, self.vtable).GetName(@ptrCast(*const IEnumCERTVIEWEXTENSION, self), pstrOut);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWEXTENSION_GetFlags(self: *const T, pFlags: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWEXTENSION.VTable, self.vtable).GetFlags(@ptrCast(*const IEnumCERTVIEWEXTENSION, self), pFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWEXTENSION_GetValue(self: *const T, Type: CERT_PROPERTY_TYPE, Flags: ENUM_CERT_COLUMN_VALUE_FLAGS, pvarValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWEXTENSION.VTable, self.vtable).GetValue(@ptrCast(*const IEnumCERTVIEWEXTENSION, self), Type, Flags, pvarValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWEXTENSION_Skip(self: *const T, celt: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWEXTENSION.VTable, self.vtable).Skip(@ptrCast(*const IEnumCERTVIEWEXTENSION, self), celt);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWEXTENSION_Reset(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWEXTENSION.VTable, self.vtable).Reset(@ptrCast(*const IEnumCERTVIEWEXTENSION, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWEXTENSION_Clone(self: *const T, ppenum: ?*?*IEnumCERTVIEWEXTENSION) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWEXTENSION.VTable, self.vtable).Clone(@ptrCast(*const IEnumCERTVIEWEXTENSION, self), ppenum);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_IEnumCERTVIEWROW_Value = @import("../../zig.zig").Guid.initString("d1157f4c-5af2-11d1-9bdc-00c04fb683fa");
pub const IID_IEnumCERTVIEWROW = &IID_IEnumCERTVIEWROW_Value;
pub const IEnumCERTVIEWROW = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Next: fn(
self: *const IEnumCERTVIEWROW,
pIndex: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumCertViewColumn: fn(
self: *const IEnumCERTVIEWROW,
ppenum: ?*?*IEnumCERTVIEWCOLUMN,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumCertViewAttribute: fn(
self: *const IEnumCERTVIEWROW,
Flags: i32,
ppenum: ?*?*IEnumCERTVIEWATTRIBUTE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumCertViewExtension: fn(
self: *const IEnumCERTVIEWROW,
Flags: i32,
ppenum: ?*?*IEnumCERTVIEWEXTENSION,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Skip: fn(
self: *const IEnumCERTVIEWROW,
celt: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reset: fn(
self: *const IEnumCERTVIEWROW,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clone: fn(
self: *const IEnumCERTVIEWROW,
ppenum: ?*?*IEnumCERTVIEWROW,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetMaxIndex: fn(
self: *const IEnumCERTVIEWROW,
pIndex: ?*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 IEnumCERTVIEWROW_Next(self: *const T, pIndex: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWROW.VTable, self.vtable).Next(@ptrCast(*const IEnumCERTVIEWROW, self), pIndex);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWROW_EnumCertViewColumn(self: *const T, ppenum: ?*?*IEnumCERTVIEWCOLUMN) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWROW.VTable, self.vtable).EnumCertViewColumn(@ptrCast(*const IEnumCERTVIEWROW, self), ppenum);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWROW_EnumCertViewAttribute(self: *const T, Flags: i32, ppenum: ?*?*IEnumCERTVIEWATTRIBUTE) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWROW.VTable, self.vtable).EnumCertViewAttribute(@ptrCast(*const IEnumCERTVIEWROW, self), Flags, ppenum);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWROW_EnumCertViewExtension(self: *const T, Flags: i32, ppenum: ?*?*IEnumCERTVIEWEXTENSION) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWROW.VTable, self.vtable).EnumCertViewExtension(@ptrCast(*const IEnumCERTVIEWROW, self), Flags, ppenum);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWROW_Skip(self: *const T, celt: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWROW.VTable, self.vtable).Skip(@ptrCast(*const IEnumCERTVIEWROW, self), celt);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWROW_Reset(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWROW.VTable, self.vtable).Reset(@ptrCast(*const IEnumCERTVIEWROW, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWROW_Clone(self: *const T, ppenum: ?*?*IEnumCERTVIEWROW) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWROW.VTable, self.vtable).Clone(@ptrCast(*const IEnumCERTVIEWROW, self), ppenum);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumCERTVIEWROW_GetMaxIndex(self: *const T, pIndex: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumCERTVIEWROW.VTable, self.vtable).GetMaxIndex(@ptrCast(*const IEnumCERTVIEWROW, self), pIndex);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertView_Value = @import("../../zig.zig").Guid.initString("c3fac344-1e84-11d1-9bd6-00c04fb683fa");
pub const IID_ICertView = &IID_ICertView_Value;
pub const ICertView = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
OpenConnection: fn(
self: *const ICertView,
strConfig: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumCertViewColumn: fn(
self: *const ICertView,
fResultColumn: CVRC_COLUMN,
ppenum: ?*?*IEnumCERTVIEWCOLUMN,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetColumnCount: fn(
self: *const ICertView,
fResultColumn: CVRC_COLUMN,
pcColumn: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetColumnIndex: fn(
self: *const ICertView,
fResultColumn: CVRC_COLUMN,
strColumnName: ?BSTR,
pColumnIndex: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetResultColumnCount: fn(
self: *const ICertView,
cResultColumn: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetResultColumn: fn(
self: *const ICertView,
ColumnIndex: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetRestriction: fn(
self: *const ICertView,
ColumnIndex: CERT_VIEW_COLUMN_INDEX,
SeekOperator: CERT_VIEW_SEEK_OPERATOR_FLAGS,
SortOrder: i32,
pvarValue: ?*const VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
OpenView: fn(
self: *const ICertView,
ppenum: ?*?*IEnumCERTVIEWROW,
) 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 ICertView_OpenConnection(self: *const T, strConfig: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertView.VTable, self.vtable).OpenConnection(@ptrCast(*const ICertView, self), strConfig);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertView_EnumCertViewColumn(self: *const T, fResultColumn: CVRC_COLUMN, ppenum: ?*?*IEnumCERTVIEWCOLUMN) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertView.VTable, self.vtable).EnumCertViewColumn(@ptrCast(*const ICertView, self), fResultColumn, ppenum);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertView_GetColumnCount(self: *const T, fResultColumn: CVRC_COLUMN, pcColumn: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertView.VTable, self.vtable).GetColumnCount(@ptrCast(*const ICertView, self), fResultColumn, pcColumn);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertView_GetColumnIndex(self: *const T, fResultColumn: CVRC_COLUMN, strColumnName: ?BSTR, pColumnIndex: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertView.VTable, self.vtable).GetColumnIndex(@ptrCast(*const ICertView, self), fResultColumn, strColumnName, pColumnIndex);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertView_SetResultColumnCount(self: *const T, cResultColumn: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertView.VTable, self.vtable).SetResultColumnCount(@ptrCast(*const ICertView, self), cResultColumn);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertView_SetResultColumn(self: *const T, ColumnIndex: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertView.VTable, self.vtable).SetResultColumn(@ptrCast(*const ICertView, self), ColumnIndex);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertView_SetRestriction(self: *const T, ColumnIndex: CERT_VIEW_COLUMN_INDEX, SeekOperator: CERT_VIEW_SEEK_OPERATOR_FLAGS, SortOrder: i32, pvarValue: ?*const VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertView.VTable, self.vtable).SetRestriction(@ptrCast(*const ICertView, self), ColumnIndex, SeekOperator, SortOrder, pvarValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertView_OpenView(self: *const T, ppenum: ?*?*IEnumCERTVIEWROW) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertView.VTable, self.vtable).OpenView(@ptrCast(*const ICertView, self), ppenum);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertView2_Value = @import("../../zig.zig").Guid.initString("d594b282-8851-4b61-9c66-3edadf848863");
pub const IID_ICertView2 = &IID_ICertView2_Value;
pub const ICertView2 = extern struct {
pub const VTable = extern struct {
base: ICertView.VTable,
SetTable: fn(
self: *const ICertView2,
Table: CVRC_TABLE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertView.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertView2_SetTable(self: *const T, Table: CVRC_TABLE) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertView2.VTable, self.vtable).SetTable(@ptrCast(*const ICertView2, self), Table);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertAdmin_Value = @import("../../zig.zig").Guid.initString("34df6950-7fb6-11d0-8817-00a0c903b83c");
pub const IID_ICertAdmin = &IID_ICertAdmin_Value;
pub const ICertAdmin = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
IsValidCertificate: fn(
self: *const ICertAdmin,
strConfig: ?BSTR,
strSerialNumber: ?BSTR,
pDisposition: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetRevocationReason: fn(
self: *const ICertAdmin,
pReason: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
RevokeCertificate: fn(
self: *const ICertAdmin,
strConfig: ?BSTR,
strSerialNumber: ?BSTR,
Reason: i32,
Date: f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetRequestAttributes: fn(
self: *const ICertAdmin,
strConfig: ?BSTR,
RequestId: i32,
strAttributes: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetCertificateExtension: fn(
self: *const ICertAdmin,
strConfig: ?BSTR,
RequestId: i32,
strExtensionName: ?BSTR,
Type: CERT_PROPERTY_TYPE,
Flags: i32,
pvarValue: ?*const VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
DenyRequest: fn(
self: *const ICertAdmin,
strConfig: ?BSTR,
RequestId: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ResubmitRequest: fn(
self: *const ICertAdmin,
strConfig: ?BSTR,
RequestId: i32,
pDisposition: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
PublishCRL: fn(
self: *const ICertAdmin,
strConfig: ?BSTR,
Date: f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCRL: fn(
self: *const ICertAdmin,
strConfig: ?BSTR,
Flags: i32,
pstrCRL: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ImportCertificate: fn(
self: *const ICertAdmin,
strConfig: ?BSTR,
strCertificate: ?BSTR,
Flags: CERT_IMPORT_FLAGS,
pRequestId: ?*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 ICertAdmin_IsValidCertificate(self: *const T, strConfig: ?BSTR, strSerialNumber: ?BSTR, pDisposition: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin.VTable, self.vtable).IsValidCertificate(@ptrCast(*const ICertAdmin, self), strConfig, strSerialNumber, pDisposition);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin_GetRevocationReason(self: *const T, pReason: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin.VTable, self.vtable).GetRevocationReason(@ptrCast(*const ICertAdmin, self), pReason);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin_RevokeCertificate(self: *const T, strConfig: ?BSTR, strSerialNumber: ?BSTR, Reason: i32, Date: f64) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin.VTable, self.vtable).RevokeCertificate(@ptrCast(*const ICertAdmin, self), strConfig, strSerialNumber, Reason, Date);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin_SetRequestAttributes(self: *const T, strConfig: ?BSTR, RequestId: i32, strAttributes: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin.VTable, self.vtable).SetRequestAttributes(@ptrCast(*const ICertAdmin, self), strConfig, RequestId, strAttributes);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin_SetCertificateExtension(self: *const T, strConfig: ?BSTR, RequestId: i32, strExtensionName: ?BSTR, Type: CERT_PROPERTY_TYPE, Flags: i32, pvarValue: ?*const VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin.VTable, self.vtable).SetCertificateExtension(@ptrCast(*const ICertAdmin, self), strConfig, RequestId, strExtensionName, Type, Flags, pvarValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin_DenyRequest(self: *const T, strConfig: ?BSTR, RequestId: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin.VTable, self.vtable).DenyRequest(@ptrCast(*const ICertAdmin, self), strConfig, RequestId);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin_ResubmitRequest(self: *const T, strConfig: ?BSTR, RequestId: i32, pDisposition: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin.VTable, self.vtable).ResubmitRequest(@ptrCast(*const ICertAdmin, self), strConfig, RequestId, pDisposition);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin_PublishCRL(self: *const T, strConfig: ?BSTR, Date: f64) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin.VTable, self.vtable).PublishCRL(@ptrCast(*const ICertAdmin, self), strConfig, Date);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin_GetCRL(self: *const T, strConfig: ?BSTR, Flags: i32, pstrCRL: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin.VTable, self.vtable).GetCRL(@ptrCast(*const ICertAdmin, self), strConfig, Flags, pstrCRL);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin_ImportCertificate(self: *const T, strConfig: ?BSTR, strCertificate: ?BSTR, Flags: CERT_IMPORT_FLAGS, pRequestId: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin.VTable, self.vtable).ImportCertificate(@ptrCast(*const ICertAdmin, self), strConfig, strCertificate, Flags, pRequestId);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertAdmin2_Value = @import("../../zig.zig").Guid.initString("f7c3ac41-b8ce-4fb4-aa58-3d1dc0e36b39");
pub const IID_ICertAdmin2 = &IID_ICertAdmin2_Value;
pub const ICertAdmin2 = extern struct {
pub const VTable = extern struct {
base: ICertAdmin.VTable,
PublishCRLs: fn(
self: *const ICertAdmin2,
strConfig: ?BSTR,
Date: f64,
CRLFlags: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCAProperty: fn(
self: *const ICertAdmin2,
strConfig: ?BSTR,
PropId: i32,
PropIndex: i32,
PropType: i32,
Flags: i32,
pvarPropertyValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetCAProperty: fn(
self: *const ICertAdmin2,
strConfig: ?BSTR,
PropId: i32,
PropIndex: i32,
PropType: CERT_PROPERTY_TYPE,
pvarPropertyValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCAPropertyFlags: fn(
self: *const ICertAdmin2,
strConfig: ?BSTR,
PropId: i32,
pPropFlags: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCAPropertyDisplayName: fn(
self: *const ICertAdmin2,
strConfig: ?BSTR,
PropId: i32,
pstrDisplayName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetArchivedKey: fn(
self: *const ICertAdmin2,
strConfig: ?BSTR,
RequestId: i32,
Flags: i32,
pstrArchivedKey: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetConfigEntry: fn(
self: *const ICertAdmin2,
strConfig: ?BSTR,
strNodePath: ?BSTR,
strEntryName: ?BSTR,
pvarEntry: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetConfigEntry: fn(
self: *const ICertAdmin2,
strConfig: ?BSTR,
strNodePath: ?BSTR,
strEntryName: ?BSTR,
pvarEntry: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ImportKey: fn(
self: *const ICertAdmin2,
strConfig: ?BSTR,
RequestId: i32,
strCertHash: ?BSTR,
Flags: CERT_IMPORT_FLAGS,
strKey: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetMyRoles: fn(
self: *const ICertAdmin2,
strConfig: ?BSTR,
pRoles: ?*CERTADMIN_GET_ROLES_FLAGS,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
DeleteRow: fn(
self: *const ICertAdmin2,
strConfig: ?BSTR,
Flags: CERT_DELETE_ROW_FLAGS,
Date: f64,
Table: CVRC_TABLE,
RowId: i32,
pcDeleted: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertAdmin.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin2_PublishCRLs(self: *const T, strConfig: ?BSTR, Date: f64, CRLFlags: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin2.VTable, self.vtable).PublishCRLs(@ptrCast(*const ICertAdmin2, self), strConfig, Date, CRLFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin2_GetCAProperty(self: *const T, strConfig: ?BSTR, PropId: i32, PropIndex: i32, PropType: i32, Flags: i32, pvarPropertyValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin2.VTable, self.vtable).GetCAProperty(@ptrCast(*const ICertAdmin2, self), strConfig, PropId, PropIndex, PropType, Flags, pvarPropertyValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin2_SetCAProperty(self: *const T, strConfig: ?BSTR, PropId: i32, PropIndex: i32, PropType: CERT_PROPERTY_TYPE, pvarPropertyValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin2.VTable, self.vtable).SetCAProperty(@ptrCast(*const ICertAdmin2, self), strConfig, PropId, PropIndex, PropType, pvarPropertyValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin2_GetCAPropertyFlags(self: *const T, strConfig: ?BSTR, PropId: i32, pPropFlags: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin2.VTable, self.vtable).GetCAPropertyFlags(@ptrCast(*const ICertAdmin2, self), strConfig, PropId, pPropFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin2_GetCAPropertyDisplayName(self: *const T, strConfig: ?BSTR, PropId: i32, pstrDisplayName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin2.VTable, self.vtable).GetCAPropertyDisplayName(@ptrCast(*const ICertAdmin2, self), strConfig, PropId, pstrDisplayName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin2_GetArchivedKey(self: *const T, strConfig: ?BSTR, RequestId: i32, Flags: i32, pstrArchivedKey: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin2.VTable, self.vtable).GetArchivedKey(@ptrCast(*const ICertAdmin2, self), strConfig, RequestId, Flags, pstrArchivedKey);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin2_GetConfigEntry(self: *const T, strConfig: ?BSTR, strNodePath: ?BSTR, strEntryName: ?BSTR, pvarEntry: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin2.VTable, self.vtable).GetConfigEntry(@ptrCast(*const ICertAdmin2, self), strConfig, strNodePath, strEntryName, pvarEntry);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin2_SetConfigEntry(self: *const T, strConfig: ?BSTR, strNodePath: ?BSTR, strEntryName: ?BSTR, pvarEntry: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin2.VTable, self.vtable).SetConfigEntry(@ptrCast(*const ICertAdmin2, self), strConfig, strNodePath, strEntryName, pvarEntry);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin2_ImportKey(self: *const T, strConfig: ?BSTR, RequestId: i32, strCertHash: ?BSTR, Flags: CERT_IMPORT_FLAGS, strKey: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin2.VTable, self.vtable).ImportKey(@ptrCast(*const ICertAdmin2, self), strConfig, RequestId, strCertHash, Flags, strKey);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin2_GetMyRoles(self: *const T, strConfig: ?BSTR, pRoles: ?*CERTADMIN_GET_ROLES_FLAGS) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin2.VTable, self.vtable).GetMyRoles(@ptrCast(*const ICertAdmin2, self), strConfig, pRoles);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertAdmin2_DeleteRow(self: *const T, strConfig: ?BSTR, Flags: CERT_DELETE_ROW_FLAGS, Date: f64, Table: CVRC_TABLE, RowId: i32, pcDeleted: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertAdmin2.VTable, self.vtable).DeleteRow(@ptrCast(*const ICertAdmin2, self), strConfig, Flags, Date, Table, RowId, pcDeleted);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2008'
const IID_IOCSPProperty_Value = @import("../../zig.zig").Guid.initString("66fb7839-5f04-4c25-ad18-9ff1a8376ee0");
pub const IID_IOCSPProperty = &IID_IOCSPProperty_Value;
pub const IOCSPProperty = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Name: fn(
self: *const IOCSPProperty,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Value: fn(
self: *const IOCSPProperty,
pVal: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Value: fn(
self: *const IOCSPProperty,
newVal: VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Modified: fn(
self: *const IOCSPProperty,
pVal: ?*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 IOCSPProperty_get_Name(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPProperty.VTable, self.vtable).get_Name(@ptrCast(*const IOCSPProperty, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPProperty_get_Value(self: *const T, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPProperty.VTable, self.vtable).get_Value(@ptrCast(*const IOCSPProperty, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPProperty_put_Value(self: *const T, newVal: VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPProperty.VTable, self.vtable).put_Value(@ptrCast(*const IOCSPProperty, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPProperty_get_Modified(self: *const T, pVal: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPProperty.VTable, self.vtable).get_Modified(@ptrCast(*const IOCSPProperty, self), pVal);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2008'
const IID_IOCSPPropertyCollection_Value = @import("../../zig.zig").Guid.initString("2597c18d-54e6-4b74-9fa9-a6bfda99cbbe");
pub const IID_IOCSPPropertyCollection = &IID_IOCSPPropertyCollection_Value;
pub const IOCSPPropertyCollection = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const IOCSPPropertyCollection,
ppVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Item: fn(
self: *const IOCSPPropertyCollection,
Index: i32,
pVal: ?*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 IOCSPPropertyCollection,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByName: fn(
self: *const IOCSPPropertyCollection,
bstrPropName: ?BSTR,
pVal: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CreateProperty: fn(
self: *const IOCSPPropertyCollection,
bstrPropName: ?BSTR,
pVarPropValue: ?*const VARIANT,
ppVal: ?*?*IOCSPProperty,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
DeleteProperty: fn(
self: *const IOCSPPropertyCollection,
bstrPropName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromProperties: fn(
self: *const IOCSPPropertyCollection,
pVarProperties: ?*const VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetAllProperties: fn(
self: *const IOCSPPropertyCollection,
pVarProperties: ?*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 IOCSPPropertyCollection_get__NewEnum(self: *const T, ppVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPPropertyCollection.VTable, self.vtable).get__NewEnum(@ptrCast(*const IOCSPPropertyCollection, self), ppVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPPropertyCollection_get_Item(self: *const T, Index: i32, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPPropertyCollection.VTable, self.vtable).get_Item(@ptrCast(*const IOCSPPropertyCollection, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPPropertyCollection_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPPropertyCollection.VTable, self.vtable).get_Count(@ptrCast(*const IOCSPPropertyCollection, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPPropertyCollection_get_ItemByName(self: *const T, bstrPropName: ?BSTR, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPPropertyCollection.VTable, self.vtable).get_ItemByName(@ptrCast(*const IOCSPPropertyCollection, self), bstrPropName, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPPropertyCollection_CreateProperty(self: *const T, bstrPropName: ?BSTR, pVarPropValue: ?*const VARIANT, ppVal: ?*?*IOCSPProperty) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPPropertyCollection.VTable, self.vtable).CreateProperty(@ptrCast(*const IOCSPPropertyCollection, self), bstrPropName, pVarPropValue, ppVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPPropertyCollection_DeleteProperty(self: *const T, bstrPropName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPPropertyCollection.VTable, self.vtable).DeleteProperty(@ptrCast(*const IOCSPPropertyCollection, self), bstrPropName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPPropertyCollection_InitializeFromProperties(self: *const T, pVarProperties: ?*const VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPPropertyCollection.VTable, self.vtable).InitializeFromProperties(@ptrCast(*const IOCSPPropertyCollection, self), pVarProperties);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPPropertyCollection_GetAllProperties(self: *const T, pVarProperties: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPPropertyCollection.VTable, self.vtable).GetAllProperties(@ptrCast(*const IOCSPPropertyCollection, self), pVarProperties);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2008'
const IID_IOCSPCAConfiguration_Value = @import("../../zig.zig").Guid.initString("aec92b40-3d46-433f-87d1-b84d5c1e790d");
pub const IID_IOCSPCAConfiguration = &IID_IOCSPCAConfiguration_Value;
pub const IOCSPCAConfiguration = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Identifier: fn(
self: *const IOCSPCAConfiguration,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CACertificate: fn(
self: *const IOCSPCAConfiguration,
pVal: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_HashAlgorithm: fn(
self: *const IOCSPCAConfiguration,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_HashAlgorithm: fn(
self: *const IOCSPCAConfiguration,
newVal: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SigningFlags: fn(
self: *const IOCSPCAConfiguration,
pVal: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_SigningFlags: fn(
self: *const IOCSPCAConfiguration,
newVal: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SigningCertificate: fn(
self: *const IOCSPCAConfiguration,
pVal: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_SigningCertificate: fn(
self: *const IOCSPCAConfiguration,
newVal: VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ReminderDuration: fn(
self: *const IOCSPCAConfiguration,
pVal: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ReminderDuration: fn(
self: *const IOCSPCAConfiguration,
newVal: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ErrorCode: fn(
self: *const IOCSPCAConfiguration,
pVal: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CSPName: fn(
self: *const IOCSPCAConfiguration,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_KeySpec: fn(
self: *const IOCSPCAConfiguration,
pVal: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProviderCLSID: fn(
self: *const IOCSPCAConfiguration,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ProviderCLSID: fn(
self: *const IOCSPCAConfiguration,
newVal: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProviderProperties: fn(
self: *const IOCSPCAConfiguration,
pVal: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ProviderProperties: fn(
self: *const IOCSPCAConfiguration,
newVal: VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Modified: fn(
self: *const IOCSPCAConfiguration,
pVal: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_LocalRevocationInformation: fn(
self: *const IOCSPCAConfiguration,
pVal: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_LocalRevocationInformation: fn(
self: *const IOCSPCAConfiguration,
newVal: VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SigningCertificateTemplate: fn(
self: *const IOCSPCAConfiguration,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_SigningCertificateTemplate: fn(
self: *const IOCSPCAConfiguration,
newVal: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CAConfig: fn(
self: *const IOCSPCAConfiguration,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_CAConfig: fn(
self: *const IOCSPCAConfiguration,
newVal: ?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 IOCSPCAConfiguration_get_Identifier(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).get_Identifier(@ptrCast(*const IOCSPCAConfiguration, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_get_CACertificate(self: *const T, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).get_CACertificate(@ptrCast(*const IOCSPCAConfiguration, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_get_HashAlgorithm(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).get_HashAlgorithm(@ptrCast(*const IOCSPCAConfiguration, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_put_HashAlgorithm(self: *const T, newVal: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).put_HashAlgorithm(@ptrCast(*const IOCSPCAConfiguration, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_get_SigningFlags(self: *const T, pVal: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).get_SigningFlags(@ptrCast(*const IOCSPCAConfiguration, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_put_SigningFlags(self: *const T, newVal: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).put_SigningFlags(@ptrCast(*const IOCSPCAConfiguration, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_get_SigningCertificate(self: *const T, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).get_SigningCertificate(@ptrCast(*const IOCSPCAConfiguration, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_put_SigningCertificate(self: *const T, newVal: VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).put_SigningCertificate(@ptrCast(*const IOCSPCAConfiguration, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_get_ReminderDuration(self: *const T, pVal: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).get_ReminderDuration(@ptrCast(*const IOCSPCAConfiguration, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_put_ReminderDuration(self: *const T, newVal: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).put_ReminderDuration(@ptrCast(*const IOCSPCAConfiguration, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_get_ErrorCode(self: *const T, pVal: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).get_ErrorCode(@ptrCast(*const IOCSPCAConfiguration, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_get_CSPName(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).get_CSPName(@ptrCast(*const IOCSPCAConfiguration, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_get_KeySpec(self: *const T, pVal: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).get_KeySpec(@ptrCast(*const IOCSPCAConfiguration, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_get_ProviderCLSID(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).get_ProviderCLSID(@ptrCast(*const IOCSPCAConfiguration, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_put_ProviderCLSID(self: *const T, newVal: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).put_ProviderCLSID(@ptrCast(*const IOCSPCAConfiguration, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_get_ProviderProperties(self: *const T, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).get_ProviderProperties(@ptrCast(*const IOCSPCAConfiguration, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_put_ProviderProperties(self: *const T, newVal: VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).put_ProviderProperties(@ptrCast(*const IOCSPCAConfiguration, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_get_Modified(self: *const T, pVal: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).get_Modified(@ptrCast(*const IOCSPCAConfiguration, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_get_LocalRevocationInformation(self: *const T, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).get_LocalRevocationInformation(@ptrCast(*const IOCSPCAConfiguration, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_put_LocalRevocationInformation(self: *const T, newVal: VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).put_LocalRevocationInformation(@ptrCast(*const IOCSPCAConfiguration, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_get_SigningCertificateTemplate(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).get_SigningCertificateTemplate(@ptrCast(*const IOCSPCAConfiguration, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_put_SigningCertificateTemplate(self: *const T, newVal: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).put_SigningCertificateTemplate(@ptrCast(*const IOCSPCAConfiguration, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_get_CAConfig(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).get_CAConfig(@ptrCast(*const IOCSPCAConfiguration, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfiguration_put_CAConfig(self: *const T, newVal: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfiguration.VTable, self.vtable).put_CAConfig(@ptrCast(*const IOCSPCAConfiguration, self), newVal);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2008'
const IID_IOCSPCAConfigurationCollection_Value = @import("../../zig.zig").Guid.initString("2bebea0b-5ece-4f28-a91c-86b4bb20f0d3");
pub const IID_IOCSPCAConfigurationCollection = &IID_IOCSPCAConfigurationCollection_Value;
pub const IOCSPCAConfigurationCollection = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const IOCSPCAConfigurationCollection,
pVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Item: fn(
self: *const IOCSPCAConfigurationCollection,
Index: i32,
pVal: ?*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 IOCSPCAConfigurationCollection,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByName: fn(
self: *const IOCSPCAConfigurationCollection,
bstrIdentifier: ?BSTR,
pVal: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CreateCAConfiguration: fn(
self: *const IOCSPCAConfigurationCollection,
bstrIdentifier: ?BSTR,
varCACert: VARIANT,
ppVal: ?*?*IOCSPCAConfiguration,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
DeleteCAConfiguration: fn(
self: *const IOCSPCAConfigurationCollection,
bstrIdentifier: ?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 IOCSPCAConfigurationCollection_get__NewEnum(self: *const T, pVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfigurationCollection.VTable, self.vtable).get__NewEnum(@ptrCast(*const IOCSPCAConfigurationCollection, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfigurationCollection_get_Item(self: *const T, Index: i32, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfigurationCollection.VTable, self.vtable).get_Item(@ptrCast(*const IOCSPCAConfigurationCollection, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfigurationCollection_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfigurationCollection.VTable, self.vtable).get_Count(@ptrCast(*const IOCSPCAConfigurationCollection, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfigurationCollection_get_ItemByName(self: *const T, bstrIdentifier: ?BSTR, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfigurationCollection.VTable, self.vtable).get_ItemByName(@ptrCast(*const IOCSPCAConfigurationCollection, self), bstrIdentifier, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfigurationCollection_CreateCAConfiguration(self: *const T, bstrIdentifier: ?BSTR, varCACert: VARIANT, ppVal: ?*?*IOCSPCAConfiguration) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfigurationCollection.VTable, self.vtable).CreateCAConfiguration(@ptrCast(*const IOCSPCAConfigurationCollection, self), bstrIdentifier, varCACert, ppVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPCAConfigurationCollection_DeleteCAConfiguration(self: *const T, bstrIdentifier: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPCAConfigurationCollection.VTable, self.vtable).DeleteCAConfiguration(@ptrCast(*const IOCSPCAConfigurationCollection, self), bstrIdentifier);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2008'
const IID_IOCSPAdmin_Value = @import("../../zig.zig").Guid.initString("322e830d-67db-4fe9-9577-4596d9f09294");
pub const IID_IOCSPAdmin = &IID_IOCSPAdmin_Value;
pub const IOCSPAdmin = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_OCSPServiceProperties: fn(
self: *const IOCSPAdmin,
ppVal: ?*?*IOCSPPropertyCollection,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_OCSPCAConfigurationCollection: fn(
self: *const IOCSPAdmin,
pVal: ?*?*IOCSPCAConfigurationCollection,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetConfiguration: fn(
self: *const IOCSPAdmin,
bstrServerName: ?BSTR,
bForce: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetConfiguration: fn(
self: *const IOCSPAdmin,
bstrServerName: ?BSTR,
bForce: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetMyRoles: fn(
self: *const IOCSPAdmin,
bstrServerName: ?BSTR,
pRoles: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Ping: fn(
self: *const IOCSPAdmin,
bstrServerName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetSecurity: fn(
self: *const IOCSPAdmin,
bstrServerName: ?BSTR,
bstrVal: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetSecurity: fn(
self: *const IOCSPAdmin,
bstrServerName: ?BSTR,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetSigningCertificates: fn(
self: *const IOCSPAdmin,
bstrServerName: ?BSTR,
pCACertVar: ?*const VARIANT,
pVal: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetHashAlgorithms: fn(
self: *const IOCSPAdmin,
bstrServerName: ?BSTR,
bstrCAId: ?BSTR,
pVal: ?*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 IOCSPAdmin_get_OCSPServiceProperties(self: *const T, ppVal: ?*?*IOCSPPropertyCollection) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPAdmin.VTable, self.vtable).get_OCSPServiceProperties(@ptrCast(*const IOCSPAdmin, self), ppVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPAdmin_get_OCSPCAConfigurationCollection(self: *const T, pVal: ?*?*IOCSPCAConfigurationCollection) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPAdmin.VTable, self.vtable).get_OCSPCAConfigurationCollection(@ptrCast(*const IOCSPAdmin, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPAdmin_GetConfiguration(self: *const T, bstrServerName: ?BSTR, bForce: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPAdmin.VTable, self.vtable).GetConfiguration(@ptrCast(*const IOCSPAdmin, self), bstrServerName, bForce);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPAdmin_SetConfiguration(self: *const T, bstrServerName: ?BSTR, bForce: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPAdmin.VTable, self.vtable).SetConfiguration(@ptrCast(*const IOCSPAdmin, self), bstrServerName, bForce);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPAdmin_GetMyRoles(self: *const T, bstrServerName: ?BSTR, pRoles: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPAdmin.VTable, self.vtable).GetMyRoles(@ptrCast(*const IOCSPAdmin, self), bstrServerName, pRoles);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPAdmin_Ping(self: *const T, bstrServerName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPAdmin.VTable, self.vtable).Ping(@ptrCast(*const IOCSPAdmin, self), bstrServerName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPAdmin_SetSecurity(self: *const T, bstrServerName: ?BSTR, bstrVal: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPAdmin.VTable, self.vtable).SetSecurity(@ptrCast(*const IOCSPAdmin, self), bstrServerName, bstrVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPAdmin_GetSecurity(self: *const T, bstrServerName: ?BSTR, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPAdmin.VTable, self.vtable).GetSecurity(@ptrCast(*const IOCSPAdmin, self), bstrServerName, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPAdmin_GetSigningCertificates(self: *const T, bstrServerName: ?BSTR, pCACertVar: ?*const VARIANT, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPAdmin.VTable, self.vtable).GetSigningCertificates(@ptrCast(*const IOCSPAdmin, self), bstrServerName, pCACertVar, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IOCSPAdmin_GetHashAlgorithms(self: *const T, bstrServerName: ?BSTR, bstrCAId: ?BSTR, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IOCSPAdmin.VTable, self.vtable).GetHashAlgorithms(@ptrCast(*const IOCSPAdmin, self), bstrServerName, bstrCAId, pVal);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const OCSPSigningFlag = enum(i32) {
SILENT = 1,
USE_CACERT = 2,
ALLOW_SIGNINGCERT_AUTORENEWAL = 4,
FORCE_SIGNINGCERT_ISSUER_ISCA = 8,
AUTODISCOVER_SIGNINGCERT = 16,
MANUAL_ASSIGN_SIGNINGCERT = 32,
RESPONDER_ID_KEYHASH = 64,
RESPONDER_ID_NAME = 128,
ALLOW_NONCE_EXTENSION = 256,
ALLOW_SIGNINGCERT_AUTOENROLLMENT = 512,
};
pub const OCSP_SF_SILENT = OCSPSigningFlag.SILENT;
pub const OCSP_SF_USE_CACERT = OCSPSigningFlag.USE_CACERT;
pub const OCSP_SF_ALLOW_SIGNINGCERT_AUTORENEWAL = OCSPSigningFlag.ALLOW_SIGNINGCERT_AUTORENEWAL;
pub const OCSP_SF_FORCE_SIGNINGCERT_ISSUER_ISCA = OCSPSigningFlag.FORCE_SIGNINGCERT_ISSUER_ISCA;
pub const OCSP_SF_AUTODISCOVER_SIGNINGCERT = OCSPSigningFlag.AUTODISCOVER_SIGNINGCERT;
pub const OCSP_SF_MANUAL_ASSIGN_SIGNINGCERT = OCSPSigningFlag.MANUAL_ASSIGN_SIGNINGCERT;
pub const OCSP_SF_RESPONDER_ID_KEYHASH = OCSPSigningFlag.RESPONDER_ID_KEYHASH;
pub const OCSP_SF_RESPONDER_ID_NAME = OCSPSigningFlag.RESPONDER_ID_NAME;
pub const OCSP_SF_ALLOW_NONCE_EXTENSION = OCSPSigningFlag.ALLOW_NONCE_EXTENSION;
pub const OCSP_SF_ALLOW_SIGNINGCERT_AUTOENROLLMENT = OCSPSigningFlag.ALLOW_SIGNINGCERT_AUTOENROLLMENT;
pub const OCSPRequestFlag = enum(i32) {
S = 1,
};
pub const OCSP_RF_REJECT_SIGNED_REQUESTS = OCSPRequestFlag.S;
pub const CSEDB_RSTMAPW = extern struct {
pwszDatabaseName: ?PWSTR,
pwszNewDatabaseName: ?PWSTR,
};
pub const FNCERTSRVISSERVERONLINEW = fn(
pwszServerName: ?[*:0]const u16,
pfServerOnline: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const FNCERTSRVBACKUPGETDYNAMICFILELISTW = fn(
hbc: ?*anyopaque,
ppwszzFileList: ?*?*u16,
pcbSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const FNCERTSRVBACKUPPREPAREW = fn(
pwszServerName: ?[*:0]const u16,
grbitJet: u32,
dwBackupFlags: u32,
phbc: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const FNCERTSRVBACKUPGETDATABASENAMESW = fn(
hbc: ?*anyopaque,
ppwszzAttachmentInformation: ?*?*u16,
pcbSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const FNCERTSRVBACKUPOPENFILEW = fn(
hbc: ?*anyopaque,
pwszAttachmentName: ?[*:0]const u16,
cbReadHintSize: u32,
pliFileSize: ?*LARGE_INTEGER,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const FNCERTSRVBACKUPREAD = fn(
hbc: ?*anyopaque,
pvBuffer: ?*anyopaque,
cbBuffer: u32,
pcbRead: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const FNCERTSRVBACKUPCLOSE = fn(
hbc: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const FNCERTSRVBACKUPGETBACKUPLOGSW = fn(
hbc: ?*anyopaque,
ppwszzBackupLogFiles: ?*?*u16,
pcbSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const FNCERTSRVBACKUPTRUNCATELOGS = fn(
hbc: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const FNCERTSRVBACKUPEND = fn(
hbc: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const FNCERTSRVBACKUPFREE = fn(
pv: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) void;
pub const FNCERTSRVRESTOREGETDATABASELOCATIONSW = fn(
hbc: ?*anyopaque,
ppwszzDatabaseLocationList: ?*?*u16,
pcbSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const FNCERTSRVRESTOREPREPAREW = fn(
pwszServerName: ?[*:0]const u16,
dwRestoreFlags: u32,
phbc: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const FNCERTSRVRESTOREREGISTERW = fn(
hbc: ?*anyopaque,
pwszCheckPointFilePath: ?[*:0]const u16,
pwszLogPath: ?[*:0]const u16,
rgrstmap: ?*CSEDB_RSTMAPW,
crstmap: i32,
pwszBackupLogPath: ?[*:0]const u16,
genLow: u32,
genHigh: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const FNCERTSRVRESTOREREGISTERCOMPLETE = fn(
hbc: ?*anyopaque,
hrRestoreState: HRESULT,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const FNCERTSRVRESTOREEND = fn(
hbc: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const FNCERTSRVSERVERCONTROLW = fn(
pwszServerName: ?[*:0]const u16,
dwControlFlags: u32,
pcbOut: ?*u32,
ppbOut: ?*?*u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
const CLSID_CCertGetConfig_Value = @import("../../zig.zig").Guid.initString("c6cc49b0-ce17-11d0-8833-00a0c903b83c");
pub const CLSID_CCertGetConfig = &CLSID_CCertGetConfig_Value;
const CLSID_CCertConfig_Value = @import("../../zig.zig").Guid.initString("372fce38-4324-11d0-8810-00a0c903b83c");
pub const CLSID_CCertConfig = &CLSID_CCertConfig_Value;
const CLSID_CCertRequest_Value = @import("../../zig.zig").Guid.initString("98aff3f0-5524-11d0-8812-00a0c903b83c");
pub const CLSID_CCertRequest = &CLSID_CCertRequest_Value;
const CLSID_CCertServerPolicy_Value = @import("../../zig.zig").Guid.initString("aa000926-ffbe-11cf-8800-00a0c903b83c");
pub const CLSID_CCertServerPolicy = &CLSID_CCertServerPolicy_Value;
const CLSID_CCertServerExit_Value = @import("../../zig.zig").Guid.initString("4c4a5e40-732c-11d0-8816-00a0c903b83c");
pub const CLSID_CCertServerExit = &CLSID_CCertServerExit_Value;
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertServerPolicy_Value = @import("../../zig.zig").Guid.initString("aa000922-ffbe-11cf-8800-00a0c903b83c");
pub const IID_ICertServerPolicy = &IID_ICertServerPolicy_Value;
pub const ICertServerPolicy = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
SetContext: fn(
self: *const ICertServerPolicy,
Context: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetRequestProperty: fn(
self: *const ICertServerPolicy,
strPropertyName: ?BSTR,
PropertyType: i32,
pvarPropertyValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetRequestAttribute: fn(
self: *const ICertServerPolicy,
strAttributeName: ?BSTR,
pstrAttributeValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCertificateProperty: fn(
self: *const ICertServerPolicy,
strPropertyName: ?BSTR,
PropertyType: CERT_PROPERTY_TYPE,
pvarPropertyValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetCertificateProperty: fn(
self: *const ICertServerPolicy,
strPropertyName: ?BSTR,
PropertyType: i32,
pvarPropertyValue: ?*const VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCertificateExtension: fn(
self: *const ICertServerPolicy,
strExtensionName: ?BSTR,
Type: CERT_PROPERTY_TYPE,
pvarValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCertificateExtensionFlags: fn(
self: *const ICertServerPolicy,
pExtFlags: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetCertificateExtension: fn(
self: *const ICertServerPolicy,
strExtensionName: ?BSTR,
Type: i32,
ExtFlags: i32,
pvarValue: ?*const VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumerateExtensionsSetup: fn(
self: *const ICertServerPolicy,
Flags: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumerateExtensions: fn(
self: *const ICertServerPolicy,
pstrExtensionName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumerateExtensionsClose: fn(
self: *const ICertServerPolicy,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumerateAttributesSetup: fn(
self: *const ICertServerPolicy,
Flags: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumerateAttributes: fn(
self: *const ICertServerPolicy,
pstrAttributeName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumerateAttributesClose: fn(
self: *const ICertServerPolicy,
) 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 ICertServerPolicy_SetContext(self: *const T, Context: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerPolicy.VTable, self.vtable).SetContext(@ptrCast(*const ICertServerPolicy, self), Context);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerPolicy_GetRequestProperty(self: *const T, strPropertyName: ?BSTR, PropertyType: i32, pvarPropertyValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerPolicy.VTable, self.vtable).GetRequestProperty(@ptrCast(*const ICertServerPolicy, self), strPropertyName, PropertyType, pvarPropertyValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerPolicy_GetRequestAttribute(self: *const T, strAttributeName: ?BSTR, pstrAttributeValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerPolicy.VTable, self.vtable).GetRequestAttribute(@ptrCast(*const ICertServerPolicy, self), strAttributeName, pstrAttributeValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerPolicy_GetCertificateProperty(self: *const T, strPropertyName: ?BSTR, PropertyType: CERT_PROPERTY_TYPE, pvarPropertyValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerPolicy.VTable, self.vtable).GetCertificateProperty(@ptrCast(*const ICertServerPolicy, self), strPropertyName, PropertyType, pvarPropertyValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerPolicy_SetCertificateProperty(self: *const T, strPropertyName: ?BSTR, PropertyType: i32, pvarPropertyValue: ?*const VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerPolicy.VTable, self.vtable).SetCertificateProperty(@ptrCast(*const ICertServerPolicy, self), strPropertyName, PropertyType, pvarPropertyValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerPolicy_GetCertificateExtension(self: *const T, strExtensionName: ?BSTR, Type: CERT_PROPERTY_TYPE, pvarValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerPolicy.VTable, self.vtable).GetCertificateExtension(@ptrCast(*const ICertServerPolicy, self), strExtensionName, Type, pvarValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerPolicy_GetCertificateExtensionFlags(self: *const T, pExtFlags: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerPolicy.VTable, self.vtable).GetCertificateExtensionFlags(@ptrCast(*const ICertServerPolicy, self), pExtFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerPolicy_SetCertificateExtension(self: *const T, strExtensionName: ?BSTR, Type: i32, ExtFlags: i32, pvarValue: ?*const VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerPolicy.VTable, self.vtable).SetCertificateExtension(@ptrCast(*const ICertServerPolicy, self), strExtensionName, Type, ExtFlags, pvarValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerPolicy_EnumerateExtensionsSetup(self: *const T, Flags: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerPolicy.VTable, self.vtable).EnumerateExtensionsSetup(@ptrCast(*const ICertServerPolicy, self), Flags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerPolicy_EnumerateExtensions(self: *const T, pstrExtensionName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerPolicy.VTable, self.vtable).EnumerateExtensions(@ptrCast(*const ICertServerPolicy, self), pstrExtensionName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerPolicy_EnumerateExtensionsClose(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerPolicy.VTable, self.vtable).EnumerateExtensionsClose(@ptrCast(*const ICertServerPolicy, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerPolicy_EnumerateAttributesSetup(self: *const T, Flags: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerPolicy.VTable, self.vtable).EnumerateAttributesSetup(@ptrCast(*const ICertServerPolicy, self), Flags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerPolicy_EnumerateAttributes(self: *const T, pstrAttributeName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerPolicy.VTable, self.vtable).EnumerateAttributes(@ptrCast(*const ICertServerPolicy, self), pstrAttributeName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerPolicy_EnumerateAttributesClose(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerPolicy.VTable, self.vtable).EnumerateAttributesClose(@ptrCast(*const ICertServerPolicy, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertServerExit_Value = @import("../../zig.zig").Guid.initString("4ba9eb90-732c-11d0-8816-00a0c903b83c");
pub const IID_ICertServerExit = &IID_ICertServerExit_Value;
pub const ICertServerExit = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
SetContext: fn(
self: *const ICertServerExit,
Context: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetRequestProperty: fn(
self: *const ICertServerExit,
strPropertyName: ?BSTR,
PropertyType: i32,
pvarPropertyValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetRequestAttribute: fn(
self: *const ICertServerExit,
strAttributeName: ?BSTR,
pstrAttributeValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCertificateProperty: fn(
self: *const ICertServerExit,
strPropertyName: ?BSTR,
PropertyType: i32,
pvarPropertyValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCertificateExtension: fn(
self: *const ICertServerExit,
strExtensionName: ?BSTR,
Type: i32,
pvarValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCertificateExtensionFlags: fn(
self: *const ICertServerExit,
pExtFlags: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumerateExtensionsSetup: fn(
self: *const ICertServerExit,
Flags: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumerateExtensions: fn(
self: *const ICertServerExit,
pstrExtensionName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumerateExtensionsClose: fn(
self: *const ICertServerExit,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumerateAttributesSetup: fn(
self: *const ICertServerExit,
Flags: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumerateAttributes: fn(
self: *const ICertServerExit,
pstrAttributeName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumerateAttributesClose: fn(
self: *const ICertServerExit,
) 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 ICertServerExit_SetContext(self: *const T, Context: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerExit.VTable, self.vtable).SetContext(@ptrCast(*const ICertServerExit, self), Context);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerExit_GetRequestProperty(self: *const T, strPropertyName: ?BSTR, PropertyType: i32, pvarPropertyValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerExit.VTable, self.vtable).GetRequestProperty(@ptrCast(*const ICertServerExit, self), strPropertyName, PropertyType, pvarPropertyValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerExit_GetRequestAttribute(self: *const T, strAttributeName: ?BSTR, pstrAttributeValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerExit.VTable, self.vtable).GetRequestAttribute(@ptrCast(*const ICertServerExit, self), strAttributeName, pstrAttributeValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerExit_GetCertificateProperty(self: *const T, strPropertyName: ?BSTR, PropertyType: i32, pvarPropertyValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerExit.VTable, self.vtable).GetCertificateProperty(@ptrCast(*const ICertServerExit, self), strPropertyName, PropertyType, pvarPropertyValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerExit_GetCertificateExtension(self: *const T, strExtensionName: ?BSTR, Type: i32, pvarValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerExit.VTable, self.vtable).GetCertificateExtension(@ptrCast(*const ICertServerExit, self), strExtensionName, Type, pvarValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerExit_GetCertificateExtensionFlags(self: *const T, pExtFlags: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerExit.VTable, self.vtable).GetCertificateExtensionFlags(@ptrCast(*const ICertServerExit, self), pExtFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerExit_EnumerateExtensionsSetup(self: *const T, Flags: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerExit.VTable, self.vtable).EnumerateExtensionsSetup(@ptrCast(*const ICertServerExit, self), Flags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerExit_EnumerateExtensions(self: *const T, pstrExtensionName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerExit.VTable, self.vtable).EnumerateExtensions(@ptrCast(*const ICertServerExit, self), pstrExtensionName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerExit_EnumerateExtensionsClose(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerExit.VTable, self.vtable).EnumerateExtensionsClose(@ptrCast(*const ICertServerExit, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerExit_EnumerateAttributesSetup(self: *const T, Flags: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerExit.VTable, self.vtable).EnumerateAttributesSetup(@ptrCast(*const ICertServerExit, self), Flags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerExit_EnumerateAttributes(self: *const T, pstrAttributeName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerExit.VTable, self.vtable).EnumerateAttributes(@ptrCast(*const ICertServerExit, self), pstrAttributeName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertServerExit_EnumerateAttributesClose(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertServerExit.VTable, self.vtable).EnumerateAttributesClose(@ptrCast(*const ICertServerExit, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertGetConfig_Value = @import("../../zig.zig").Guid.initString("c7ea09c0-ce17-11d0-8833-00a0c903b83c");
pub const IID_ICertGetConfig = &IID_ICertGetConfig_Value;
pub const ICertGetConfig = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
GetConfig: fn(
self: *const ICertGetConfig,
Flags: CERT_GET_CONFIG_FLAGS,
pstrOut: ?*?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 ICertGetConfig_GetConfig(self: *const T, Flags: CERT_GET_CONFIG_FLAGS, pstrOut: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertGetConfig.VTable, self.vtable).GetConfig(@ptrCast(*const ICertGetConfig, self), Flags, pstrOut);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertConfig_Value = @import("../../zig.zig").Guid.initString("372fce34-4324-11d0-8810-00a0c903b83c");
pub const IID_ICertConfig = &IID_ICertConfig_Value;
pub const ICertConfig = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Reset: fn(
self: *const ICertConfig,
Index: i32,
pCount: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Next: fn(
self: *const ICertConfig,
pIndex: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetField: fn(
self: *const ICertConfig,
strFieldName: ?BSTR,
pstrOut: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetConfig: fn(
self: *const ICertConfig,
Flags: i32,
pstrOut: ?*?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 ICertConfig_Reset(self: *const T, Index: i32, pCount: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertConfig.VTable, self.vtable).Reset(@ptrCast(*const ICertConfig, self), Index, pCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertConfig_Next(self: *const T, pIndex: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertConfig.VTable, self.vtable).Next(@ptrCast(*const ICertConfig, self), pIndex);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertConfig_GetField(self: *const T, strFieldName: ?BSTR, pstrOut: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertConfig.VTable, self.vtable).GetField(@ptrCast(*const ICertConfig, self), strFieldName, pstrOut);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertConfig_GetConfig(self: *const T, Flags: i32, pstrOut: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertConfig.VTable, self.vtable).GetConfig(@ptrCast(*const ICertConfig, self), Flags, pstrOut);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertConfig2_Value = @import("../../zig.zig").Guid.initString("7a18edde-7e78-4163-8ded-78e2c9cee924");
pub const IID_ICertConfig2 = &IID_ICertConfig2_Value;
pub const ICertConfig2 = extern struct {
pub const VTable = extern struct {
base: ICertConfig.VTable,
SetSharedFolder: fn(
self: *const ICertConfig2,
strSharedFolder: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertConfig.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertConfig2_SetSharedFolder(self: *const T, strSharedFolder: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertConfig2.VTable, self.vtable).SetSharedFolder(@ptrCast(*const ICertConfig2, self), strSharedFolder);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_ICertRequest_Value = @import("../../zig.zig").Guid.initString("014e4840-5523-11d0-8812-00a0c903b83c");
pub const IID_ICertRequest = &IID_ICertRequest_Value;
pub const ICertRequest = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Submit: fn(
self: *const ICertRequest,
Flags: i32,
strRequest: ?BSTR,
strAttributes: ?BSTR,
strConfig: ?BSTR,
pDisposition: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
RetrievePending: fn(
self: *const ICertRequest,
RequestId: i32,
strConfig: ?BSTR,
pDisposition: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetLastStatus: fn(
self: *const ICertRequest,
pStatus: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetRequestId: fn(
self: *const ICertRequest,
pRequestId: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDispositionMessage: fn(
self: *const ICertRequest,
pstrDispositionMessage: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCACertificate: fn(
self: *const ICertRequest,
fExchangeCertificate: i32,
strConfig: ?BSTR,
Flags: i32,
pstrCertificate: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCertificate: fn(
self: *const ICertRequest,
Flags: i32,
pstrCertificate: ?*?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 ICertRequest_Submit(self: *const T, Flags: i32, strRequest: ?BSTR, strAttributes: ?BSTR, strConfig: ?BSTR, pDisposition: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequest.VTable, self.vtable).Submit(@ptrCast(*const ICertRequest, self), Flags, strRequest, strAttributes, strConfig, pDisposition);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequest_RetrievePending(self: *const T, RequestId: i32, strConfig: ?BSTR, pDisposition: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequest.VTable, self.vtable).RetrievePending(@ptrCast(*const ICertRequest, self), RequestId, strConfig, pDisposition);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequest_GetLastStatus(self: *const T, pStatus: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequest.VTable, self.vtable).GetLastStatus(@ptrCast(*const ICertRequest, self), pStatus);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequest_GetRequestId(self: *const T, pRequestId: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequest.VTable, self.vtable).GetRequestId(@ptrCast(*const ICertRequest, self), pRequestId);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequest_GetDispositionMessage(self: *const T, pstrDispositionMessage: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequest.VTable, self.vtable).GetDispositionMessage(@ptrCast(*const ICertRequest, self), pstrDispositionMessage);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequest_GetCACertificate(self: *const T, fExchangeCertificate: i32, strConfig: ?BSTR, Flags: i32, pstrCertificate: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequest.VTable, self.vtable).GetCACertificate(@ptrCast(*const ICertRequest, self), fExchangeCertificate, strConfig, Flags, pstrCertificate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequest_GetCertificate(self: *const T, Flags: i32, pstrCertificate: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequest.VTable, self.vtable).GetCertificate(@ptrCast(*const ICertRequest, self), Flags, pstrCertificate);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_ICertRequest2_Value = @import("../../zig.zig").Guid.initString("a4772988-4a85-4fa9-824e-b5cf5c16405a");
pub const IID_ICertRequest2 = &IID_ICertRequest2_Value;
pub const ICertRequest2 = extern struct {
pub const VTable = extern struct {
base: ICertRequest.VTable,
GetIssuedCertificate: fn(
self: *const ICertRequest2,
strConfig: ?BSTR,
RequestId: i32,
strSerialNumber: ?BSTR,
pDisposition: ?*CR_DISP,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetErrorMessageText: fn(
self: *const ICertRequest2,
hrMessage: i32,
Flags: i32,
pstrErrorMessageText: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCAProperty: fn(
self: *const ICertRequest2,
strConfig: ?BSTR,
PropId: i32,
PropIndex: i32,
PropType: i32,
Flags: i32,
pvarPropertyValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCAPropertyFlags: fn(
self: *const ICertRequest2,
strConfig: ?BSTR,
PropId: i32,
pPropFlags: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCAPropertyDisplayName: fn(
self: *const ICertRequest2,
strConfig: ?BSTR,
PropId: i32,
pstrDisplayName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetFullResponseProperty: fn(
self: *const ICertRequest2,
PropId: FULL_RESPONSE_PROPERTY_ID,
PropIndex: i32,
PropType: CERT_PROPERTY_TYPE,
Flags: CERT_REQUEST_OUT_TYPE,
pvarPropertyValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertRequest.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequest2_GetIssuedCertificate(self: *const T, strConfig: ?BSTR, RequestId: i32, strSerialNumber: ?BSTR, pDisposition: ?*CR_DISP) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequest2.VTable, self.vtable).GetIssuedCertificate(@ptrCast(*const ICertRequest2, self), strConfig, RequestId, strSerialNumber, pDisposition);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequest2_GetErrorMessageText(self: *const T, hrMessage: i32, Flags: i32, pstrErrorMessageText: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequest2.VTable, self.vtable).GetErrorMessageText(@ptrCast(*const ICertRequest2, self), hrMessage, Flags, pstrErrorMessageText);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequest2_GetCAProperty(self: *const T, strConfig: ?BSTR, PropId: i32, PropIndex: i32, PropType: i32, Flags: i32, pvarPropertyValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequest2.VTable, self.vtable).GetCAProperty(@ptrCast(*const ICertRequest2, self), strConfig, PropId, PropIndex, PropType, Flags, pvarPropertyValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequest2_GetCAPropertyFlags(self: *const T, strConfig: ?BSTR, PropId: i32, pPropFlags: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequest2.VTable, self.vtable).GetCAPropertyFlags(@ptrCast(*const ICertRequest2, self), strConfig, PropId, pPropFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequest2_GetCAPropertyDisplayName(self: *const T, strConfig: ?BSTR, PropId: i32, pstrDisplayName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequest2.VTable, self.vtable).GetCAPropertyDisplayName(@ptrCast(*const ICertRequest2, self), strConfig, PropId, pstrDisplayName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequest2_GetFullResponseProperty(self: *const T, PropId: FULL_RESPONSE_PROPERTY_ID, PropIndex: i32, PropType: CERT_PROPERTY_TYPE, Flags: CERT_REQUEST_OUT_TYPE, pvarPropertyValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequest2.VTable, self.vtable).GetFullResponseProperty(@ptrCast(*const ICertRequest2, self), PropId, PropIndex, PropType, Flags, pvarPropertyValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const X509EnrollmentAuthFlags = enum(i32) {
None = 0,
Anonymous = 1,
Kerberos = 2,
Username = 4,
Certificate = 8,
};
pub const X509AuthNone = X509EnrollmentAuthFlags.None;
pub const X509AuthAnonymous = X509EnrollmentAuthFlags.Anonymous;
pub const X509AuthKerberos = X509EnrollmentAuthFlags.Kerberos;
pub const X509AuthUsername = X509EnrollmentAuthFlags.Username;
pub const X509AuthCertificate = X509EnrollmentAuthFlags.Certificate;
// TODO: this type is limited to platform 'windows6.1'
const IID_ICertRequest3_Value = @import("../../zig.zig").Guid.initString("afc8f92b-33a2-4861-bf36-2933b7cd67b3");
pub const IID_ICertRequest3 = &IID_ICertRequest3_Value;
pub const ICertRequest3 = extern struct {
pub const VTable = extern struct {
base: ICertRequest2.VTable,
SetCredential: fn(
self: *const ICertRequest3,
hWnd: i32,
AuthType: X509EnrollmentAuthFlags,
strCredential: ?BSTR,
strPassword: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetRequestIdString: fn(
self: *const ICertRequest3,
pstrRequestId: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetIssuedCertificate2: fn(
self: *const ICertRequest3,
strConfig: ?BSTR,
strRequestId: ?BSTR,
strSerialNumber: ?BSTR,
pDisposition: ?*CR_DISP,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetRefreshPolicy: fn(
self: *const ICertRequest3,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertRequest2.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequest3_SetCredential(self: *const T, hWnd: i32, AuthType: X509EnrollmentAuthFlags, strCredential: ?BSTR, strPassword: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequest3.VTable, self.vtable).SetCredential(@ptrCast(*const ICertRequest3, self), hWnd, AuthType, strCredential, strPassword);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequest3_GetRequestIdString(self: *const T, pstrRequestId: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequest3.VTable, self.vtable).GetRequestIdString(@ptrCast(*const ICertRequest3, self), pstrRequestId);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequest3_GetIssuedCertificate2(self: *const T, strConfig: ?BSTR, strRequestId: ?BSTR, strSerialNumber: ?BSTR, pDisposition: ?*CR_DISP) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequest3.VTable, self.vtable).GetIssuedCertificate2(@ptrCast(*const ICertRequest3, self), strConfig, strRequestId, strSerialNumber, pDisposition);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequest3_GetRefreshPolicy(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequest3.VTable, self.vtable).GetRefreshPolicy(@ptrCast(*const ICertRequest3, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
const CLSID_CCertEncodeStringArray_Value = @import("../../zig.zig").Guid.initString("19a76fe0-7494-11d0-8816-00a0c903b83c");
pub const CLSID_CCertEncodeStringArray = &CLSID_CCertEncodeStringArray_Value;
const CLSID_CCertEncodeLongArray_Value = @import("../../zig.zig").Guid.initString("4e0680a0-a0a2-11d0-8821-00a0c903b83c");
pub const CLSID_CCertEncodeLongArray = &CLSID_CCertEncodeLongArray_Value;
const CLSID_CCertEncodeDateArray_Value = @import("../../zig.zig").Guid.initString("301f77b0-a470-11d0-8821-00a0c903b83c");
pub const CLSID_CCertEncodeDateArray = &CLSID_CCertEncodeDateArray_Value;
const CLSID_CCertEncodeCRLDistInfo_Value = @import("../../zig.zig").Guid.initString("01fa60a0-bbff-11d0-8825-00a0c903b83c");
pub const CLSID_CCertEncodeCRLDistInfo = &CLSID_CCertEncodeCRLDistInfo_Value;
const CLSID_CCertEncodeAltName_Value = @import("../../zig.zig").Guid.initString("1cfc4cda-1271-11d1-9bd4-00c04fb683fa");
pub const CLSID_CCertEncodeAltName = &CLSID_CCertEncodeAltName_Value;
const CLSID_CCertEncodeBitString_Value = @import("../../zig.zig").Guid.initString("6d6b3cd8-1278-11d1-9bd4-00c04fb683fa");
pub const CLSID_CCertEncodeBitString = &CLSID_CCertEncodeBitString_Value;
const CLSID_CObjectId_Value = @import("../../zig.zig").Guid.initString("884e2000-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CObjectId = &CLSID_CObjectId_Value;
const CLSID_CObjectIds_Value = @import("../../zig.zig").Guid.initString("884e2001-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CObjectIds = &CLSID_CObjectIds_Value;
const CLSID_CBinaryConverter_Value = @import("../../zig.zig").Guid.initString("884e2002-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CBinaryConverter = &CLSID_CBinaryConverter_Value;
const CLSID_CX500DistinguishedName_Value = @import("../../zig.zig").Guid.initString("884e2003-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX500DistinguishedName = &CLSID_CX500DistinguishedName_Value;
const CLSID_CCspInformation_Value = @import("../../zig.zig").Guid.initString("884e2007-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCspInformation = &CLSID_CCspInformation_Value;
const CLSID_CCspInformations_Value = @import("../../zig.zig").Guid.initString("884e2008-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCspInformations = &CLSID_CCspInformations_Value;
const CLSID_CCspStatus_Value = @import("../../zig.zig").Guid.initString("884e2009-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCspStatus = &CLSID_CCspStatus_Value;
const CLSID_CX509PublicKey_Value = @import("../../zig.zig").Guid.initString("884e200b-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509PublicKey = &CLSID_CX509PublicKey_Value;
const CLSID_CX509PrivateKey_Value = @import("../../zig.zig").Guid.initString("884e200c-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509PrivateKey = &CLSID_CX509PrivateKey_Value;
const CLSID_CX509EndorsementKey_Value = @import("../../zig.zig").Guid.initString("11a25a1d-b9a3-4edd-af83-3b59adbed361");
pub const CLSID_CX509EndorsementKey = &CLSID_CX509EndorsementKey_Value;
const CLSID_CX509Extension_Value = @import("../../zig.zig").Guid.initString("884e200d-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509Extension = &CLSID_CX509Extension_Value;
const CLSID_CX509Extensions_Value = @import("../../zig.zig").Guid.initString("884e200e-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509Extensions = &CLSID_CX509Extensions_Value;
const CLSID_CX509ExtensionKeyUsage_Value = @import("../../zig.zig").Guid.initString("884e200f-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509ExtensionKeyUsage = &CLSID_CX509ExtensionKeyUsage_Value;
const CLSID_CX509ExtensionEnhancedKeyUsage_Value = @import("../../zig.zig").Guid.initString("884e2010-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509ExtensionEnhancedKeyUsage = &CLSID_CX509ExtensionEnhancedKeyUsage_Value;
const CLSID_CX509ExtensionTemplateName_Value = @import("../../zig.zig").Guid.initString("884e2011-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509ExtensionTemplateName = &CLSID_CX509ExtensionTemplateName_Value;
const CLSID_CX509ExtensionTemplate_Value = @import("../../zig.zig").Guid.initString("884e2012-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509ExtensionTemplate = &CLSID_CX509ExtensionTemplate_Value;
const CLSID_CAlternativeName_Value = @import("../../zig.zig").Guid.initString("884e2013-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CAlternativeName = &CLSID_CAlternativeName_Value;
const CLSID_CAlternativeNames_Value = @import("../../zig.zig").Guid.initString("884e2014-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CAlternativeNames = &CLSID_CAlternativeNames_Value;
const CLSID_CX509ExtensionAlternativeNames_Value = @import("../../zig.zig").Guid.initString("884e2015-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509ExtensionAlternativeNames = &CLSID_CX509ExtensionAlternativeNames_Value;
const CLSID_CX509ExtensionBasicConstraints_Value = @import("../../zig.zig").Guid.initString("884e2016-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509ExtensionBasicConstraints = &CLSID_CX509ExtensionBasicConstraints_Value;
const CLSID_CX509ExtensionSubjectKeyIdentifier_Value = @import("../../zig.zig").Guid.initString("884e2017-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509ExtensionSubjectKeyIdentifier = &CLSID_CX509ExtensionSubjectKeyIdentifier_Value;
const CLSID_CX509ExtensionAuthorityKeyIdentifier_Value = @import("../../zig.zig").Guid.initString("<KEY>");
pub const CLSID_CX509ExtensionAuthorityKeyIdentifier = &CLSID_CX509ExtensionAuthorityKeyIdentifier_Value;
const CLSID_CSmimeCapability_Value = @import("../../zig.zig").Guid.initString("884e2019-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CSmimeCapability = &CLSID_CSmimeCapability_Value;
const CLSID_CSmimeCapabilities_Value = @import("../../zig.zig").Guid.initString("884e201a-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CSmimeCapabilities = &CLSID_CSmimeCapabilities_Value;
const CLSID_CX509ExtensionSmimeCapabilities_Value = @import("../../zig.zig").Guid.initString("884e201b-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509ExtensionSmimeCapabilities = &CLSID_CX509ExtensionSmimeCapabilities_Value;
const CLSID_CPolicyQualifier_Value = @import("../../zig.zig").Guid.initString("884e201c-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CPolicyQualifier = &CLSID_CPolicyQualifier_Value;
const CLSID_CPolicyQualifiers_Value = @import("../../zig.zig").Guid.initString("884e201d-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CPolicyQualifiers = &CLSID_CPolicyQualifiers_Value;
const CLSID_CCertificatePolicy_Value = @import("../../zig.zig").Guid.initString("884e201e-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCertificatePolicy = &CLSID_CCertificatePolicy_Value;
const CLSID_CCertificatePolicies_Value = @import("../../zig.zig").Guid.initString("884e201f-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCertificatePolicies = &CLSID_CCertificatePolicies_Value;
const CLSID_CX509ExtensionCertificatePolicies_Value = @import("../../zig.zig").Guid.initString("884e2020-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509ExtensionCertificatePolicies = &CLSID_CX509ExtensionCertificatePolicies_Value;
const CLSID_CX509ExtensionMSApplicationPolicies_Value = @import("../../zig.zig").Guid.initString("884e2021-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509ExtensionMSApplicationPolicies = &CLSID_CX509ExtensionMSApplicationPolicies_Value;
const CLSID_CX509Attribute_Value = @import("../../zig.zig").Guid.initString("884e2022-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509Attribute = &CLSID_CX509Attribute_Value;
const CLSID_CX509Attributes_Value = @import("../../zig.zig").Guid.initString("884e2023-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509Attributes = &CLSID_CX509Attributes_Value;
const CLSID_CX509AttributeExtensions_Value = @import("../../zig.zig").Guid.initString("884e2024-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509AttributeExtensions = &CLSID_CX509AttributeExtensions_Value;
const CLSID_CX509AttributeClientId_Value = @import("../../zig.zig").Guid.initString("884e2025-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509AttributeClientId = &CLSID_CX509AttributeClientId_Value;
const CLSID_CX509AttributeRenewalCertificate_Value = @import("../../zig.zig").Guid.initString("884e2026-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509AttributeRenewalCertificate = &CLSID_CX509AttributeRenewalCertificate_Value;
const CLSID_CX509AttributeArchiveKey_Value = @import("../../zig.zig").Guid.initString("<KEY>");
pub const CLSID_CX509AttributeArchiveKey = &CLSID_CX509AttributeArchiveKey_Value;
const CLSID_CX509AttributeArchiveKeyHash_Value = @import("../../zig.zig").Guid.initString("884e2028-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509AttributeArchiveKeyHash = &CLSID_CX509AttributeArchiveKeyHash_Value;
const CLSID_CX509AttributeOSVersion_Value = @import("../../zig.zig").Guid.initString("884e202a-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509AttributeOSVersion = &CLSID_CX509AttributeOSVersion_Value;
const CLSID_CX509AttributeCspProvider_Value = @import("../../zig.zig").Guid.initString("884e202b-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509AttributeCspProvider = &CLSID_CX509AttributeCspProvider_Value;
const CLSID_CCryptAttribute_Value = @import("../../zig.zig").Guid.initString("884e202c-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCryptAttribute = &CLSID_CCryptAttribute_Value;
const CLSID_CCryptAttributes_Value = @import("../../zig.zig").Guid.initString("884e202d-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCryptAttributes = &CLSID_CCryptAttributes_Value;
const CLSID_CCertProperty_Value = @import("../../zig.zig").Guid.initString("884e202e-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCertProperty = &CLSID_CCertProperty_Value;
const CLSID_CCertProperties_Value = @import("../../zig.zig").Guid.initString("884e202f-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCertProperties = &CLSID_CCertProperties_Value;
const CLSID_CCertPropertyFriendlyName_Value = @import("../../zig.zig").Guid.initString("884e2030-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCertPropertyFriendlyName = &CLSID_CCertPropertyFriendlyName_Value;
const CLSID_CCertPropertyDescription_Value = @import("../../zig.zig").Guid.initString("884e2031-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCertPropertyDescription = &CLSID_CCertPropertyDescription_Value;
const CLSID_CCertPropertyAutoEnroll_Value = @import("../../zig.zig").Guid.initString("884e2032-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCertPropertyAutoEnroll = &CLSID_CCertPropertyAutoEnroll_Value;
const CLSID_CCertPropertyRequestOriginator_Value = @import("../../zig.zig").Guid.initString("884e2033-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCertPropertyRequestOriginator = &CLSID_CCertPropertyRequestOriginator_Value;
const CLSID_CCertPropertySHA1Hash_Value = @import("../../zig.zig").Guid.initString("884e2034-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCertPropertySHA1Hash = &CLSID_CCertPropertySHA1Hash_Value;
const CLSID_CCertPropertyKeyProvInfo_Value = @import("../../zig.zig").Guid.initString("884e2036-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCertPropertyKeyProvInfo = &CLSID_CCertPropertyKeyProvInfo_Value;
const CLSID_CCertPropertyArchived_Value = @import("../../zig.zig").Guid.initString("884e2037-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCertPropertyArchived = &CLSID_CCertPropertyArchived_Value;
const CLSID_CCertPropertyBackedUp_Value = @import("../../zig.zig").Guid.initString("884e2038-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCertPropertyBackedUp = &CLSID_CCertPropertyBackedUp_Value;
const CLSID_CCertPropertyEnrollment_Value = @import("../../zig.zig").Guid.initString("884e2039-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCertPropertyEnrollment = &CLSID_CCertPropertyEnrollment_Value;
const CLSID_CCertPropertyRenewal_Value = @import("../../zig.zig").Guid.initString("884e203a-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCertPropertyRenewal = &CLSID_CCertPropertyRenewal_Value;
const CLSID_CCertPropertyArchivedKeyHash_Value = @import("../../zig.zig").Guid.initString("884e203b-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCertPropertyArchivedKeyHash = &CLSID_CCertPropertyArchivedKeyHash_Value;
const CLSID_CCertPropertyEnrollmentPolicyServer_Value = @import("../../zig.zig").Guid.initString("884e204c-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CCertPropertyEnrollmentPolicyServer = &CLSID_CCertPropertyEnrollmentPolicyServer_Value;
const CLSID_CSignerCertificate_Value = @import("../../zig.zig").Guid.initString("884e203d-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CSignerCertificate = &CLSID_CSignerCertificate_Value;
const CLSID_CX509NameValuePair_Value = @import("../../zig.zig").Guid.initString("884e203f-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509NameValuePair = &CLSID_CX509NameValuePair_Value;
const CLSID_CCertificateAttestationChallenge_Value = @import("../../zig.zig").Guid.initString("1362ada1-eb60-456a-b6e1-118050db741b");
pub const CLSID_CCertificateAttestationChallenge = &CLSID_CCertificateAttestationChallenge_Value;
const CLSID_CX509CertificateRequestPkcs10_Value = @import("../../zig.zig").Guid.initString("884e2042-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509CertificateRequestPkcs10 = &CLSID_CX509CertificateRequestPkcs10_Value;
const CLSID_CX509CertificateRequestCertificate_Value = @import("../../zig.zig").Guid.initString("884e2043-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509CertificateRequestCertificate = &CLSID_CX509CertificateRequestCertificate_Value;
const CLSID_CX509CertificateRequestPkcs7_Value = @import("../../zig.zig").Guid.initString("884e2044-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509CertificateRequestPkcs7 = &CLSID_CX509CertificateRequestPkcs7_Value;
const CLSID_CX509CertificateRequestCmc_Value = @import("../../zig.zig").Guid.initString("884e2045-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509CertificateRequestCmc = &CLSID_CX509CertificateRequestCmc_Value;
const CLSID_CX509Enrollment_Value = @import("../../zig.zig").Guid.initString("884e2046-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509Enrollment = &CLSID_CX509Enrollment_Value;
const CLSID_CX509EnrollmentWebClassFactory_Value = @import("../../zig.zig").Guid.initString("884e2049-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509EnrollmentWebClassFactory = &CLSID_CX509EnrollmentWebClassFactory_Value;
const CLSID_CX509EnrollmentHelper_Value = @import("../../zig.zig").Guid.initString("884e2050-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509EnrollmentHelper = &CLSID_CX509EnrollmentHelper_Value;
const CLSID_CX509MachineEnrollmentFactory_Value = @import("../../zig.zig").Guid.initString("884e2051-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509MachineEnrollmentFactory = &CLSID_CX509MachineEnrollmentFactory_Value;
const CLSID_CX509EnrollmentPolicyActiveDirectory_Value = @import("../../zig.zig").Guid.initString("91f39027-217f-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509EnrollmentPolicyActiveDirectory = &CLSID_CX509EnrollmentPolicyActiveDirectory_Value;
const CLSID_CX509EnrollmentPolicyWebService_Value = @import("../../zig.zig").Guid.initString("91f39028-217f-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509EnrollmentPolicyWebService = &CLSID_CX509EnrollmentPolicyWebService_Value;
const CLSID_CX509PolicyServerListManager_Value = @import("../../zig.zig").Guid.initString("91f39029-217f-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509PolicyServerListManager = &CLSID_CX509PolicyServerListManager_Value;
const CLSID_CX509PolicyServerUrl_Value = @import("../../zig.zig").Guid.initString("91f3902a-217f-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509PolicyServerUrl = &CLSID_CX509PolicyServerUrl_Value;
const CLSID_CX509CertificateTemplateADWritable_Value = @import("../../zig.zig").Guid.initString("8336e323-2e6a-4a04-937c-548f681839b3");
pub const CLSID_CX509CertificateTemplateADWritable = &CLSID_CX509CertificateTemplateADWritable_Value;
const CLSID_CX509CertificateRevocationListEntry_Value = @import("../../zig.zig").Guid.initString("884e205e-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509CertificateRevocationListEntry = &CLSID_CX509CertificateRevocationListEntry_Value;
const CLSID_CX509CertificateRevocationListEntries_Value = @import("../../zig.zig").Guid.initString("884e205f-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509CertificateRevocationListEntries = &CLSID_CX509CertificateRevocationListEntries_Value;
const CLSID_CX509CertificateRevocationList_Value = @import("../../zig.zig").Guid.initString("884e2060-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509CertificateRevocationList = &CLSID_CX509CertificateRevocationList_Value;
const CLSID_CX509SCEPEnrollment_Value = @import("../../zig.zig").Guid.initString("884e2061-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509SCEPEnrollment = &CLSID_CX509SCEPEnrollment_Value;
const CLSID_CX509SCEPEnrollmentHelper_Value = @import("../../zig.zig").Guid.initString("884e2062-217d-11da-b2a4-000e7bbb2b09");
pub const CLSID_CX509SCEPEnrollmentHelper = &CLSID_CX509SCEPEnrollmentHelper_Value;
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertManageModule_Value = @import("../../zig.zig").Guid.initString("e7d7ad42-bd3d-11d1-9a4d-00c04fc297eb");
pub const IID_ICertManageModule = &IID_ICertManageModule_Value;
pub const ICertManageModule = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
GetProperty: fn(
self: *const ICertManageModule,
strConfig: ?BSTR,
strStorageLocation: ?BSTR,
strPropertyName: ?BSTR,
Flags: i32,
pvarProperty: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetProperty: fn(
self: *const ICertManageModule,
strConfig: ?BSTR,
strStorageLocation: ?BSTR,
strPropertyName: ?BSTR,
Flags: i32,
pvarProperty: ?*const VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Configure: fn(
self: *const ICertManageModule,
strConfig: ?BSTR,
strStorageLocation: ?BSTR,
Flags: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertManageModule_GetProperty(self: *const T, strConfig: ?BSTR, strStorageLocation: ?BSTR, strPropertyName: ?BSTR, Flags: i32, pvarProperty: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertManageModule.VTable, self.vtable).GetProperty(@ptrCast(*const ICertManageModule, self), strConfig, strStorageLocation, strPropertyName, Flags, pvarProperty);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertManageModule_SetProperty(self: *const T, strConfig: ?BSTR, strStorageLocation: ?BSTR, strPropertyName: ?BSTR, Flags: i32, pvarProperty: ?*const VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertManageModule.VTable, self.vtable).SetProperty(@ptrCast(*const ICertManageModule, self), strConfig, strStorageLocation, strPropertyName, Flags, pvarProperty);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertManageModule_Configure(self: *const T, strConfig: ?BSTR, strStorageLocation: ?BSTR, Flags: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertManageModule.VTable, self.vtable).Configure(@ptrCast(*const ICertManageModule, self), strConfig, strStorageLocation, Flags);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const CERTTRANSBLOB = extern struct {
cb: u32,
pb: ?*u8,
};
pub const CERTVIEWRESTRICTION = extern struct {
ColumnIndex: u32,
SeekOperator: i32,
SortOrder: i32,
pbValue: ?*u8,
cbValue: u32,
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertPolicy_Value = @import("../../zig.zig").Guid.initString("38bb5a00-7636-11d0-b413-00a0c91bbf8c");
pub const IID_ICertPolicy = &IID_ICertPolicy_Value;
pub const ICertPolicy = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const ICertPolicy,
strConfig: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
VerifyRequest: fn(
self: *const ICertPolicy,
strConfig: ?BSTR,
Context: i32,
bNewRequest: i32,
Flags: i32,
pDisposition: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDescription: fn(
self: *const ICertPolicy,
pstrDescription: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ShutDown: fn(
self: *const ICertPolicy,
) 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 ICertPolicy_Initialize(self: *const T, strConfig: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPolicy.VTable, self.vtable).Initialize(@ptrCast(*const ICertPolicy, self), strConfig);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPolicy_VerifyRequest(self: *const T, strConfig: ?BSTR, Context: i32, bNewRequest: i32, Flags: i32, pDisposition: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPolicy.VTable, self.vtable).VerifyRequest(@ptrCast(*const ICertPolicy, self), strConfig, Context, bNewRequest, Flags, pDisposition);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPolicy_GetDescription(self: *const T, pstrDescription: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPolicy.VTable, self.vtable).GetDescription(@ptrCast(*const ICertPolicy, self), pstrDescription);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPolicy_ShutDown(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPolicy.VTable, self.vtable).ShutDown(@ptrCast(*const ICertPolicy, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertPolicy2_Value = @import("../../zig.zig").Guid.initString("3db4910e-8001-4bf1-aa1b-f43a808317a0");
pub const IID_ICertPolicy2 = &IID_ICertPolicy2_Value;
pub const ICertPolicy2 = extern struct {
pub const VTable = extern struct {
base: ICertPolicy.VTable,
GetManageModule: fn(
self: *const ICertPolicy2,
ppManageModule: ?*?*ICertManageModule,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertPolicy.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPolicy2_GetManageModule(self: *const T, ppManageModule: ?*?*ICertManageModule) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPolicy2.VTable, self.vtable).GetManageModule(@ptrCast(*const ICertPolicy2, self), ppManageModule);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const X509SCEPMessageType = enum(i32) {
Unknown = -1,
CertResponse = 3,
PKCSRequest = 19,
GetCertInitial = 20,
GetCert = 21,
GetCRL = 22,
ClaimChallengeAnswer = 41,
};
pub const SCEPMessageUnknown = X509SCEPMessageType.Unknown;
pub const SCEPMessageCertResponse = X509SCEPMessageType.CertResponse;
pub const SCEPMessagePKCSRequest = X509SCEPMessageType.PKCSRequest;
pub const SCEPMessageGetCertInitial = X509SCEPMessageType.GetCertInitial;
pub const SCEPMessageGetCert = X509SCEPMessageType.GetCert;
pub const SCEPMessageGetCRL = X509SCEPMessageType.GetCRL;
pub const SCEPMessageClaimChallengeAnswer = X509SCEPMessageType.ClaimChallengeAnswer;
pub const X509SCEPDisposition = enum(i32) {
Unknown = -1,
Success = 0,
Failure = 2,
Pending = 3,
PendingChallenge = 11,
};
pub const SCEPDispositionUnknown = X509SCEPDisposition.Unknown;
pub const SCEPDispositionSuccess = X509SCEPDisposition.Success;
pub const SCEPDispositionFailure = X509SCEPDisposition.Failure;
pub const SCEPDispositionPending = X509SCEPDisposition.Pending;
pub const SCEPDispositionPendingChallenge = X509SCEPDisposition.PendingChallenge;
pub const X509SCEPFailInfo = enum(i32) {
Unknown = -1,
BadAlgorithm = 0,
BadMessageCheck = 1,
BadRequest = 2,
BadTime = 3,
BadCertId = 4,
};
pub const SCEPFailUnknown = X509SCEPFailInfo.Unknown;
pub const SCEPFailBadAlgorithm = X509SCEPFailInfo.BadAlgorithm;
pub const SCEPFailBadMessageCheck = X509SCEPFailInfo.BadMessageCheck;
pub const SCEPFailBadRequest = X509SCEPFailInfo.BadRequest;
pub const SCEPFailBadTime = X509SCEPFailInfo.BadTime;
pub const SCEPFailBadCertId = X509SCEPFailInfo.BadCertId;
const IID_INDESPolicy_Value = @import("../../zig.zig").Guid.initString("13ca515d-431d-46cc-8c2e-1da269bbd625");
pub const IID_INDESPolicy = &IID_INDESPolicy_Value;
pub const INDESPolicy = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Initialize: fn(
self: *const INDESPolicy,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Uninitialize: fn(
self: *const INDESPolicy,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GenerateChallenge: fn(
self: *const INDESPolicy,
pwszTemplate: ?[*:0]const u16,
pwszParams: ?[*:0]const u16,
ppwszResponse: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
VerifyRequest: fn(
self: *const INDESPolicy,
pctbRequest: ?*CERTTRANSBLOB,
pctbSigningCertEncoded: ?*CERTTRANSBLOB,
pwszTemplate: ?[*:0]const u16,
pwszTransactionId: ?[*:0]const u16,
pfVerified: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Notify: fn(
self: *const INDESPolicy,
pwszChallenge: ?[*:0]const u16,
pwszTransactionId: ?[*:0]const u16,
disposition: X509SCEPDisposition,
lastHResult: i32,
pctbIssuedCertEncoded: ?*CERTTRANSBLOB,
) 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 INDESPolicy_Initialize(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const INDESPolicy.VTable, self.vtable).Initialize(@ptrCast(*const INDESPolicy, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn INDESPolicy_Uninitialize(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const INDESPolicy.VTable, self.vtable).Uninitialize(@ptrCast(*const INDESPolicy, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn INDESPolicy_GenerateChallenge(self: *const T, pwszTemplate: ?[*:0]const u16, pwszParams: ?[*:0]const u16, ppwszResponse: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const INDESPolicy.VTable, self.vtable).GenerateChallenge(@ptrCast(*const INDESPolicy, self), pwszTemplate, pwszParams, ppwszResponse);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn INDESPolicy_VerifyRequest(self: *const T, pctbRequest: ?*CERTTRANSBLOB, pctbSigningCertEncoded: ?*CERTTRANSBLOB, pwszTemplate: ?[*:0]const u16, pwszTransactionId: ?[*:0]const u16, pfVerified: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const INDESPolicy.VTable, self.vtable).VerifyRequest(@ptrCast(*const INDESPolicy, self), pctbRequest, pctbSigningCertEncoded, pwszTemplate, pwszTransactionId, pfVerified);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn INDESPolicy_Notify(self: *const T, pwszChallenge: ?[*:0]const u16, pwszTransactionId: ?[*:0]const u16, disposition: X509SCEPDisposition, lastHResult: i32, pctbIssuedCertEncoded: ?*CERTTRANSBLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const INDESPolicy.VTable, self.vtable).Notify(@ptrCast(*const INDESPolicy, self), pwszChallenge, pwszTransactionId, disposition, lastHResult, pctbIssuedCertEncoded);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const CERTENROLL_OBJECTID = enum(i32) {
_NONE = 0,
_RSA = 1,
_PKCS = 2,
_RSA_HASH = 3,
_RSA_ENCRYPT = 4,
_PKCS_1 = 5,
_PKCS_2 = 6,
_PKCS_3 = 7,
_PKCS_4 = 8,
_PKCS_5 = 9,
_PKCS_6 = 10,
_PKCS_7 = 11,
_PKCS_8 = 12,
_PKCS_9 = 13,
_PKCS_10 = 14,
_PKCS_12 = 15,
_RSA_RSA = 16,
_RSA_MD2RSA = 17,
_RSA_MD4RSA = 18,
_RSA_MD5RSA = 19,
_RSA_SHA1RSA = 20,
_RSA_SETOAEP_RSA = 21,
_RSA_DH = 22,
_RSA_data = 23,
_RSA_signedData = 24,
_RSA_envelopedData = 25,
_RSA_signEnvData = 26,
_RSA_digestedData = 27,
_RSA_hashedData = 28,
_RSA_encryptedData = 29,
_RSA_emailAddr = 30,
_RSA_unstructName = 31,
_RSA_contentType = 32,
_RSA_messageDigest = 33,
_RSA_signingTime = 34,
_RSA_counterSign = 35,
_RSA_challengePwd = 36,
_RSA_unstructAddr = 37,
_RSA_extCertAttrs = 38,
_RSA_certExtensions = 39,
_RSA_SMIMECapabilities = 40,
_RSA_preferSignedData = 41,
_RSA_SMIMEalg = 42,
_RSA_SMIMEalgESDH = 43,
_RSA_SMIMEalgCMS3DESwrap = 44,
_RSA_SMIMEalgCMSRC2wrap = 45,
_RSA_MD2 = 46,
_RSA_MD4 = 47,
_RSA_MD5 = 48,
_RSA_RC2CBC = 49,
_RSA_RC4 = 50,
_RSA_DES_EDE3_CBC = 51,
_RSA_RC5_CBCPad = 52,
_ANSI_X942 = 53,
_ANSI_X942_DH = 54,
_X957 = 55,
_X957_DSA = 56,
_X957_SHA1DSA = 57,
_DS = 58,
_DSALG = 59,
_DSALG_CRPT = 60,
_DSALG_HASH = 61,
_DSALG_SIGN = 62,
_DSALG_RSA = 63,
_OIW = 64,
_OIWSEC = 65,
_OIWSEC_md4RSA = 66,
_OIWSEC_md5RSA = 67,
_OIWSEC_md4RSA2 = 68,
_OIWSEC_desECB = 69,
_OIWSEC_desCBC = 70,
_OIWSEC_desOFB = 71,
_OIWSEC_desCFB = 72,
_OIWSEC_desMAC = 73,
_OIWSEC_rsaSign = 74,
_OIWSEC_dsa = 75,
_OIWSEC_shaDSA = 76,
_OIWSEC_mdc2RSA = 77,
_OIWSEC_shaRSA = 78,
_OIWSEC_dhCommMod = 79,
_OIWSEC_desEDE = 80,
_OIWSEC_sha = 81,
_OIWSEC_mdc2 = 82,
_OIWSEC_dsaComm = 83,
_OIWSEC_dsaCommSHA = 84,
_OIWSEC_rsaXchg = 85,
_OIWSEC_keyHashSeal = 86,
_OIWSEC_md2RSASign = 87,
_OIWSEC_md5RSASign = 88,
_OIWSEC_sha1 = 89,
_OIWSEC_dsaSHA1 = 90,
_OIWSEC_dsaCommSHA1 = 91,
_OIWSEC_sha1RSASign = 92,
_OIWDIR = 93,
_OIWDIR_CRPT = 94,
_OIWDIR_HASH = 95,
_OIWDIR_SIGN = 96,
_OIWDIR_md2 = 97,
_OIWDIR_md2RSA = 98,
_INFOSEC = 99,
_INFOSEC_sdnsSignature = 100,
_INFOSEC_mosaicSignature = 101,
_INFOSEC_sdnsConfidentiality = 102,
_INFOSEC_mosaicConfidentiality = 103,
_INFOSEC_sdnsIntegrity = 104,
_INFOSEC_mosaicIntegrity = 105,
_INFOSEC_sdnsTokenProtection = 106,
_INFOSEC_mosaicTokenProtection = 107,
_INFOSEC_sdnsKeyManagement = 108,
_INFOSEC_mosaicKeyManagement = 109,
_INFOSEC_sdnsKMandSig = 110,
_INFOSEC_mosaicKMandSig = 111,
_INFOSEC_SuiteASignature = 112,
_INFOSEC_SuiteAConfidentiality = 113,
_INFOSEC_SuiteAIntegrity = 114,
_INFOSEC_SuiteATokenProtection = 115,
_INFOSEC_SuiteAKeyManagement = 116,
_INFOSEC_SuiteAKMandSig = 117,
_INFOSEC_mosaicUpdatedSig = 118,
_INFOSEC_mosaicKMandUpdSig = 119,
_INFOSEC_mosaicUpdatedInteg = 120,
_COMMON_NAME = 121,
_SUR_NAME = 122,
_DEVICE_SERIAL_NUMBER = 123,
_COUNTRY_NAME = 124,
_LOCALITY_NAME = 125,
_STATE_OR_PROVINCE_NAME = 126,
_STREET_ADDRESS = 127,
_ORGANIZATION_NAME = 128,
_ORGANIZATIONAL_UNIT_NAME = 129,
_TITLE = 130,
_DESCRIPTION = 131,
_SEARCH_GUIDE = 132,
_BUSINESS_CATEGORY = 133,
_POSTAL_ADDRESS = 134,
_POSTAL_CODE = 135,
_POST_OFFICE_BOX = 136,
_PHYSICAL_DELIVERY_OFFICE_NAME = 137,
_TELEPHONE_NUMBER = 138,
_TELEX_NUMBER = 139,
_TELETEXT_TERMINAL_IDENTIFIER = 140,
_FACSIMILE_TELEPHONE_NUMBER = 141,
_X21_ADDRESS = 142,
_INTERNATIONAL_ISDN_NUMBER = 143,
_REGISTERED_ADDRESS = 144,
_DESTINATION_INDICATOR = 145,
_PREFERRED_DELIVERY_METHOD = 146,
_PRESENTATION_ADDRESS = 147,
_SUPPORTED_APPLICATION_CONTEXT = 148,
_MEMBER = 149,
_OWNER = 150,
_ROLE_OCCUPANT = 151,
_SEE_ALSO = 152,
_USER_PASSWORD = <PASSWORD>,
_USER_CERTIFICATE = 154,
_CA_CERTIFICATE = 155,
_AUTHORITY_REVOCATION_LIST = 156,
_CERTIFICATE_REVOCATION_LIST = 157,
_CROSS_CERTIFICATE_PAIR = 158,
_GIVEN_NAME = 159,
_INITIALS = 160,
_DN_QUALIFIER = 161,
_DOMAIN_COMPONENT = 162,
_PKCS_12_FRIENDLY_NAME_ATTR = 163,
_PKCS_12_LOCAL_KEY_ID = 164,
_PKCS_12_KEY_PROVIDER_NAME_ATTR = 165,
_LOCAL_MACHINE_KEYSET = 166,
_PKCS_12_EXTENDED_ATTRIBUTES = 167,
_KEYID_RDN = 168,
_AUTHORITY_KEY_IDENTIFIER = 169,
_KEY_ATTRIBUTES = 170,
_CERT_POLICIES_95 = 171,
_KEY_USAGE_RESTRICTION = 172,
_SUBJECT_ALT_NAME = 173,
_ISSUER_ALT_NAME = 174,
_BASIC_CONSTRAINTS = 175,
_KEY_USAGE = 176,
_PRIVATEKEY_USAGE_PERIOD = 177,
_BASIC_CONSTRAINTS2 = 178,
_CERT_POLICIES = 179,
_ANY_CERT_POLICY = 180,
_AUTHORITY_KEY_IDENTIFIER2 = 181,
_SUBJECT_KEY_IDENTIFIER = 182,
_SUBJECT_ALT_NAME2 = 183,
_ISSUER_ALT_NAME2 = 184,
_CRL_REASON_CODE = 185,
_REASON_CODE_HOLD = 186,
_CRL_DIST_POINTS = 187,
_ENHANCED_KEY_USAGE = 188,
_CRL_NUMBER = 189,
_DELTA_CRL_INDICATOR = 190,
_ISSUING_DIST_POINT = 191,
_FRESHEST_CRL = 192,
_NAME_CONSTRAINTS = 193,
_POLICY_MAPPINGS = 194,
_LEGACY_POLICY_MAPPINGS = 195,
_POLICY_CONSTRAINTS = 196,
_RENEWAL_CERTIFICATE = 197,
_ENROLLMENT_NAME_VALUE_PAIR = 198,
_ENROLLMENT_CSP_PROVIDER = 199,
_OS_VERSION = 200,
_ENROLLMENT_AGENT = 201,
_PKIX = 202,
_PKIX_PE = 203,
_AUTHORITY_INFO_ACCESS = 204,
_BIOMETRIC_EXT = 205,
_LOGOTYPE_EXT = 206,
_CERT_EXTENSIONS = 207,
_NEXT_UPDATE_LOCATION = 208,
_REMOVE_CERTIFICATE = 209,
_CROSS_CERT_DIST_POINTS = 210,
_CTL = 211,
_SORTED_CTL = 212,
_SERIALIZED = 213,
_NT_PRINCIPAL_NAME = 214,
_PRODUCT_UPDATE = 215,
_ANY_APPLICATION_POLICY = 216,
_AUTO_ENROLL_CTL_USAGE = 217,
_ENROLL_CERTTYPE_EXTENSION = 218,
_CERT_MANIFOLD = 219,
_CERTSRV_CA_VERSION = 220,
_CERTSRV_PREVIOUS_CERT_HASH = 221,
_CRL_VIRTUAL_BASE = 222,
_CRL_NEXT_PUBLISH = 223,
_KP_CA_EXCHANGE = 224,
_KP_KEY_RECOVERY_AGENT = 225,
_CERTIFICATE_TEMPLATE = 226,
_ENTERPRISE_OID_ROOT = 227,
_RDN_DUMMY_SIGNER = 228,
_APPLICATION_CERT_POLICIES = 229,
_APPLICATION_POLICY_MAPPINGS = 230,
_APPLICATION_POLICY_CONSTRAINTS = 231,
_ARCHIVED_KEY_ATTR = 232,
_CRL_SELF_CDP = 233,
_REQUIRE_CERT_CHAIN_POLICY = 234,
_ARCHIVED_KEY_CERT_HASH = 235,
_ISSUED_CERT_HASH = 236,
_DS_EMAIL_REPLICATION = 237,
_REQUEST_CLIENT_INFO = 238,
_ENCRYPTED_KEY_HASH = 239,
_CERTSRV_CROSSCA_VERSION = 240,
_NTDS_REPLICATION = 241,
_SUBJECT_DIR_ATTRS = 242,
_PKIX_KP = 243,
_PKIX_KP_SERVER_AUTH = 244,
_PKIX_KP_CLIENT_AUTH = 245,
_PKIX_KP_CODE_SIGNING = 246,
_PKIX_KP_EMAIL_PROTECTION = 247,
_PKIX_KP_IPSEC_END_SYSTEM = 248,
_PKIX_KP_IPSEC_TUNNEL = 249,
_PKIX_KP_IPSEC_USER = 250,
_PKIX_KP_TIMESTAMP_SIGNING = 251,
_PKIX_KP_OCSP_SIGNING = 252,
_PKIX_OCSP_NOCHECK = 253,
_IPSEC_KP_IKE_INTERMEDIATE = 254,
_KP_CTL_USAGE_SIGNING = 255,
_KP_TIME_STAMP_SIGNING = 256,
_SERVER_GATED_CRYPTO = 257,
_SGC_NETSCAPE = 258,
_KP_EFS = 259,
_EFS_RECOVERY = 260,
_WHQL_CRYPTO = 261,
_NT5_CRYPTO = 262,
_OEM_WHQL_CRYPTO = 263,
_EMBEDDED_NT_CRYPTO = 264,
_ROOT_LIST_SIGNER = 265,
_KP_QUALIFIED_SUBORDINATION = 266,
_KP_KEY_RECOVERY = 267,
_KP_DOCUMENT_SIGNING = 268,
_KP_LIFETIME_SIGNING = 269,
_KP_MOBILE_DEVICE_SOFTWARE = 270,
_KP_SMART_DISPLAY = 271,
_KP_CSP_SIGNATURE = 272,
_DRM = 273,
_DRM_INDIVIDUALIZATION = 274,
_LICENSES = 275,
_LICENSE_SERVER = 276,
_KP_SMARTCARD_LOGON = 277,
_YESNO_TRUST_ATTR = 278,
_PKIX_POLICY_QUALIFIER_CPS = 279,
_PKIX_POLICY_QUALIFIER_USERNOTICE = 280,
_CERT_POLICIES_95_QUALIFIER1 = 281,
_PKIX_ACC_DESCR = 282,
_PKIX_OCSP = 283,
_PKIX_CA_ISSUERS = 284,
_VERISIGN_PRIVATE_6_9 = 285,
_VERISIGN_ONSITE_JURISDICTION_HASH = 286,
_VERISIGN_BITSTRING_6_13 = 287,
_VERISIGN_ISS_STRONG_CRYPTO = 288,
_NETSCAPE = 289,
_NETSCAPE_CERT_EXTENSION = 290,
_NETSCAPE_CERT_TYPE = 291,
_NETSCAPE_BASE_URL = 292,
_NETSCAPE_REVOCATION_URL = 293,
_NETSCAPE_CA_REVOCATION_URL = 294,
_NETSCAPE_CERT_RENEWAL_URL = 295,
_NETSCAPE_CA_POLICY_URL = 296,
_NETSCAPE_SSL_SERVER_NAME = 297,
_NETSCAPE_COMMENT = 298,
_NETSCAPE_DATA_TYPE = 299,
_NETSCAPE_CERT_SEQUENCE = 300,
_CT_PKI_DATA = 301,
_CT_PKI_RESPONSE = 302,
_PKIX_NO_SIGNATURE = 303,
_CMC = 304,
_CMC_STATUS_INFO = 305,
_CMC_IDENTIFICATION = 306,
_CMC_IDENTITY_PROOF = 307,
_CMC_DATA_RETURN = 308,
_CMC_TRANSACTION_ID = 309,
_CMC_SENDER_NONCE = 310,
_CMC_RECIPIENT_NONCE = 311,
_CMC_ADD_EXTENSIONS = 312,
_CMC_ENCRYPTED_POP = 313,
_CMC_DECRYPTED_POP = 314,
_CMC_LRA_POP_WITNESS = 315,
_CMC_GET_CERT = 316,
_CMC_GET_CRL = 317,
_CMC_REVOKE_REQUEST = 318,
_CMC_REG_INFO = 319,
_CMC_RESPONSE_INFO = 320,
_CMC_QUERY_PENDING = 321,
_CMC_ID_POP_LINK_RANDOM = 322,
_CMC_ID_POP_LINK_WITNESS = 323,
_CMC_ID_CONFIRM_CERT_ACCEPTANCE = 324,
_CMC_ADD_ATTRIBUTES = 325,
_LOYALTY_OTHER_LOGOTYPE = 326,
_BACKGROUND_OTHER_LOGOTYPE = 327,
_PKIX_OCSP_BASIC_SIGNED_RESPONSE = 328,
_PKCS_7_DATA = 329,
_PKCS_7_SIGNED = 330,
_PKCS_7_ENVELOPED = 331,
_PKCS_7_SIGNEDANDENVELOPED = 332,
_PKCS_7_DIGESTED = 333,
_PKCS_7_ENCRYPTED = 334,
_PKCS_9_CONTENT_TYPE = 335,
_PKCS_9_MESSAGE_DIGEST = 336,
_CERT_PROP_ID_PREFIX = 337,
_CERT_KEY_IDENTIFIER_PROP_ID = 338,
_CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID = 339,
_CERT_SUBJECT_NAME_MD5_HASH_PROP_ID = 340,
_CERT_MD5_HASH_PROP_ID = 341,
_RSA_SHA256RSA = 342,
_RSA_SHA384RSA = 343,
_RSA_SHA512RSA = 344,
_NIST_sha256 = 345,
_NIST_sha384 = 346,
_NIST_sha512 = 347,
_RSA_MGF1 = 348,
_ECC_PUBLIC_KEY = 349,
_ECDSA_SHA1 = 350,
_ECDSA_SPECIFIED = 351,
_ANY_ENHANCED_KEY_USAGE = 352,
_RSA_SSA_PSS = 353,
_ATTR_SUPPORTED_ALGORITHMS = 355,
_ATTR_TPM_SECURITY_ASSERTIONS = 356,
_ATTR_TPM_SPECIFICATION = 357,
_CERT_DISALLOWED_FILETIME_PROP_ID = 358,
_CERT_SIGNATURE_HASH_PROP_ID = 359,
_CERT_STRONG_KEY_OS_1 = 360,
_CERT_STRONG_KEY_OS_CURRENT = 361,
_CERT_STRONG_KEY_OS_PREFIX = 362,
_CERT_STRONG_SIGN_OS_1 = 363,
_CERT_STRONG_SIGN_OS_CURRENT = 364,
_CERT_STRONG_SIGN_OS_PREFIX = 365,
_DH_SINGLE_PASS_STDDH_SHA1_KDF = 366,
_DH_SINGLE_PASS_STDDH_SHA256_KDF = 367,
_DH_SINGLE_PASS_STDDH_SHA384_KDF = 368,
_DISALLOWED_HASH = 369,
_DISALLOWED_LIST = 370,
_ECC_CURVE_P256 = 371,
_ECC_CURVE_P384 = 372,
_ECC_CURVE_P521 = 373,
_ECDSA_SHA256 = 374,
_ECDSA_SHA384 = 375,
_ECDSA_SHA512 = 376,
_ENROLL_CAXCHGCERT_HASH = 377,
_ENROLL_EK_INFO = 378,
_ENROLL_EKPUB_CHALLENGE = 379,
_ENROLL_EKVERIFYCERT = 380,
_ENROLL_EKVERIFYCREDS = 381,
_ENROLL_EKVERIFYKEY = 382,
_EV_RDN_COUNTRY = 383,
_EV_RDN_LOCALE = 384,
_EV_RDN_STATE_OR_PROVINCE = 385,
_INHIBIT_ANY_POLICY = 386,
_INTERNATIONALIZED_EMAIL_ADDRESS = 387,
_KP_KERNEL_MODE_CODE_SIGNING = 388,
_KP_KERNEL_MODE_HAL_EXTENSION_SIGNING = 389,
_KP_KERNEL_MODE_TRUSTED_BOOT_SIGNING = 390,
_KP_TPM_AIK_CERTIFICATE = 391,
_KP_TPM_EK_CERTIFICATE = 392,
_KP_TPM_PLATFORM_CERTIFICATE = 393,
_NIST_AES128_CBC = 394,
_NIST_AES128_WRAP = 395,
_NIST_AES192_CBC = 396,
_NIST_AES192_WRAP = 397,
_NIST_AES256_CBC = 398,
_NIST_AES256_WRAP = 399,
_PKCS_12_PbeIds = 400,
_PKCS_12_pbeWithSHA1And128BitRC2 = 401,
_PKCS_12_pbeWithSHA1And128BitRC4 = 402,
_PKCS_12_pbeWithSHA1And2KeyTripleDES = 403,
_PKCS_12_pbeWithSHA1And3KeyTripleDES = 404,
_PKCS_12_pbeWithSHA1And40BitRC2 = 405,
_PKCS_12_pbeWithSHA1And40BitRC4 = 406,
_PKCS_12_PROTECTED_PASSWORD_SECRET_BAG_TYPE_ID = 407,
_PKINIT_KP_KDC = 408,
_PKIX_CA_REPOSITORY = 409,
_PKIX_OCSP_NONCE = 410,
_PKIX_TIME_STAMPING = 411,
_QC_EU_COMPLIANCE = 412,
_QC_SSCD = 413,
_QC_STATEMENTS_EXT = 414,
_RDN_TPM_MANUFACTURER = 415,
_RDN_TPM_MODEL = 416,
_RDN_TPM_VERSION = 417,
_REVOKED_LIST_SIGNER = 418,
_RFC3161_counterSign = 419,
_ROOT_PROGRAM_AUTO_UPDATE_CA_REVOCATION = 420,
_ROOT_PROGRAM_AUTO_UPDATE_END_REVOCATION = 421,
_ROOT_PROGRAM_FLAGS = 422,
_ROOT_PROGRAM_NO_OCSP_FAILOVER_TO_CRL = 423,
_RSA_PSPECIFIED = 424,
_RSAES_OAEP = 425,
_SUBJECT_INFO_ACCESS = 426,
_TIMESTAMP_TOKEN = 427,
_ENROLL_SCEP_ERROR = 428,
Verisign_MessageType = 429,
Verisign_PkiStatus = 430,
Verisign_FailInfo = 431,
Verisign_SenderNonce = 432,
Verisign_RecipientNonce = 433,
Verisign_TransactionID = 434,
_ENROLL_ATTESTATION_CHALLENGE = 435,
_ENROLL_ATTESTATION_STATEMENT = 436,
_ENROLL_ENCRYPTION_ALGORITHM = 437,
_ENROLL_KSP_NAME = 438,
};
pub const XCN_OID_NONE = CERTENROLL_OBJECTID._NONE;
pub const XCN_OID_RSA = CERTENROLL_OBJECTID._RSA;
pub const XCN_OID_PKCS = CERTENROLL_OBJECTID._PKCS;
pub const XCN_OID_RSA_HASH = CERTENROLL_OBJECTID._RSA_HASH;
pub const XCN_OID_RSA_ENCRYPT = CERTENROLL_OBJECTID._RSA_ENCRYPT;
pub const XCN_OID_PKCS_1 = CERTENROLL_OBJECTID._PKCS_1;
pub const XCN_OID_PKCS_2 = CERTENROLL_OBJECTID._PKCS_2;
pub const XCN_OID_PKCS_3 = CERTENROLL_OBJECTID._PKCS_3;
pub const XCN_OID_PKCS_4 = CERTENROLL_OBJECTID._PKCS_4;
pub const XCN_OID_PKCS_5 = CERTENROLL_OBJECTID._PKCS_5;
pub const XCN_OID_PKCS_6 = CERTENROLL_OBJECTID._PKCS_6;
pub const XCN_OID_PKCS_7 = CERTENROLL_OBJECTID._PKCS_7;
pub const XCN_OID_PKCS_8 = CERTENROLL_OBJECTID._PKCS_8;
pub const XCN_OID_PKCS_9 = CERTENROLL_OBJECTID._PKCS_9;
pub const XCN_OID_PKCS_10 = CERTENROLL_OBJECTID._PKCS_10;
pub const XCN_OID_PKCS_12 = CERTENROLL_OBJECTID._PKCS_12;
pub const XCN_OID_RSA_RSA = CERTENROLL_OBJECTID._RSA_RSA;
pub const XCN_OID_RSA_MD2RSA = CERTENROLL_OBJECTID._RSA_MD2RSA;
pub const XCN_OID_RSA_MD4RSA = CERTENROLL_OBJECTID._RSA_MD4RSA;
pub const XCN_OID_RSA_MD5RSA = CERTENROLL_OBJECTID._RSA_MD5RSA;
pub const XCN_OID_RSA_SHA1RSA = CERTENROLL_OBJECTID._RSA_SHA1RSA;
pub const XCN_OID_RSA_SETOAEP_RSA = CERTENROLL_OBJECTID._RSA_SETOAEP_RSA;
pub const XCN_OID_RSA_DH = CERTENROLL_OBJECTID._RSA_DH;
pub const XCN_OID_RSA_data = CERTENROLL_OBJECTID._RSA_data;
pub const XCN_OID_RSA_signedData = CERTENROLL_OBJECTID._RSA_signedData;
pub const XCN_OID_RSA_envelopedData = CERTENROLL_OBJECTID._RSA_envelopedData;
pub const XCN_OID_RSA_signEnvData = CERTENROLL_OBJECTID._RSA_signEnvData;
pub const XCN_OID_RSA_digestedData = CERTENROLL_OBJECTID._RSA_digestedData;
pub const XCN_OID_RSA_hashedData = CERTENROLL_OBJECTID._RSA_hashedData;
pub const XCN_OID_RSA_encryptedData = CERTENROLL_OBJECTID._RSA_encryptedData;
pub const XCN_OID_RSA_emailAddr = CERTENROLL_OBJECTID._RSA_emailAddr;
pub const XCN_OID_RSA_unstructName = CERTENROLL_OBJECTID._RSA_unstructName;
pub const XCN_OID_RSA_contentType = CERTENROLL_OBJECTID._RSA_contentType;
pub const XCN_OID_RSA_messageDigest = CERTENROLL_OBJECTID._RSA_messageDigest;
pub const XCN_OID_RSA_signingTime = CERTENROLL_OBJECTID._RSA_signingTime;
pub const XCN_OID_RSA_counterSign = CERTENROLL_OBJECTID._RSA_counterSign;
pub const XCN_OID_RSA_challengePwd = CERTENROLL_OBJECTID._RSA_challengePwd;
pub const XCN_OID_RSA_unstructAddr = CERTENROLL_OBJECTID._RSA_unstructAddr;
pub const XCN_OID_RSA_extCertAttrs = CERTENROLL_OBJECTID._RSA_extCertAttrs;
pub const XCN_OID_RSA_certExtensions = CERTENROLL_OBJECTID._RSA_certExtensions;
pub const XCN_OID_RSA_SMIMECapabilities = CERTENROLL_OBJECTID._RSA_SMIMECapabilities;
pub const XCN_OID_RSA_preferSignedData = CERTENROLL_OBJECTID._RSA_preferSignedData;
pub const XCN_OID_RSA_SMIMEalg = CERTENROLL_OBJECTID._RSA_SMIMEalg;
pub const XCN_OID_RSA_SMIMEalgESDH = CERTENROLL_OBJECTID._RSA_SMIMEalgESDH;
pub const XCN_OID_RSA_SMIMEalgCMS3DESwrap = CERTENROLL_OBJECTID._RSA_SMIMEalgCMS3DESwrap;
pub const XCN_OID_RSA_SMIMEalgCMSRC2wrap = CERTENROLL_OBJECTID._RSA_SMIMEalgCMSRC2wrap;
pub const XCN_OID_RSA_MD2 = CERTENROLL_OBJECTID._RSA_MD2;
pub const XCN_OID_RSA_MD4 = CERTENROLL_OBJECTID._RSA_MD4;
pub const XCN_OID_RSA_MD5 = CERTENROLL_OBJECTID._RSA_MD5;
pub const XCN_OID_RSA_RC2CBC = CERTENROLL_OBJECTID._RSA_RC2CBC;
pub const XCN_OID_RSA_RC4 = CERTENROLL_OBJECTID._RSA_RC4;
pub const XCN_OID_RSA_DES_EDE3_CBC = CERTENROLL_OBJECTID._RSA_DES_EDE3_CBC;
pub const XCN_OID_RSA_RC5_CBCPad = CERTENROLL_OBJECTID._RSA_RC5_CBCPad;
pub const XCN_OID_ANSI_X942 = CERTENROLL_OBJECTID._ANSI_X942;
pub const XCN_OID_ANSI_X942_DH = CERTENROLL_OBJECTID._ANSI_X942_DH;
pub const XCN_OID_X957 = CERTENROLL_OBJECTID._X957;
pub const XCN_OID_X957_DSA = CERTENROLL_OBJECTID._X957_DSA;
pub const XCN_OID_X957_SHA1DSA = CERTENROLL_OBJECTID._X957_SHA1DSA;
pub const XCN_OID_DS = CERTENROLL_OBJECTID._DS;
pub const XCN_OID_DSALG = CERTENROLL_OBJECTID._DSALG;
pub const XCN_OID_DSALG_CRPT = CERTENROLL_OBJECTID._DSALG_CRPT;
pub const XCN_OID_DSALG_HASH = CERTENROLL_OBJECTID._DSALG_HASH;
pub const XCN_OID_DSALG_SIGN = CERTENROLL_OBJECTID._DSALG_SIGN;
pub const XCN_OID_DSALG_RSA = CERTENROLL_OBJECTID._DSALG_RSA;
pub const XCN_OID_OIW = CERTENROLL_OBJECTID._OIW;
pub const XCN_OID_OIWSEC = CERTENROLL_OBJECTID._OIWSEC;
pub const XCN_OID_OIWSEC_md4RSA = CERTENROLL_OBJECTID._OIWSEC_md4RSA;
pub const XCN_OID_OIWSEC_md5RSA = CERTENROLL_OBJECTID._OIWSEC_md5RSA;
pub const XCN_OID_OIWSEC_md4RSA2 = CERTENROLL_OBJECTID._OIWSEC_md4RSA2;
pub const XCN_OID_OIWSEC_desECB = CERTENROLL_OBJECTID._OIWSEC_desECB;
pub const XCN_OID_OIWSEC_desCBC = CERTENROLL_OBJECTID._OIWSEC_desCBC;
pub const XCN_OID_OIWSEC_desOFB = CERTENROLL_OBJECTID._OIWSEC_desOFB;
pub const XCN_OID_OIWSEC_desCFB = CERTENROLL_OBJECTID._OIWSEC_desCFB;
pub const XCN_OID_OIWSEC_desMAC = CERTENROLL_OBJECTID._OIWSEC_desMAC;
pub const XCN_OID_OIWSEC_rsaSign = CERTENROLL_OBJECTID._OIWSEC_rsaSign;
pub const XCN_OID_OIWSEC_dsa = CERTENROLL_OBJECTID._OIWSEC_dsa;
pub const XCN_OID_OIWSEC_shaDSA = CERTENROLL_OBJECTID._OIWSEC_shaDSA;
pub const XCN_OID_OIWSEC_mdc2RSA = CERTENROLL_OBJECTID._OIWSEC_mdc2RSA;
pub const XCN_OID_OIWSEC_shaRSA = CERTENROLL_OBJECTID._OIWSEC_shaRSA;
pub const XCN_OID_OIWSEC_dhCommMod = CERTENROLL_OBJECTID._OIWSEC_dhCommMod;
pub const XCN_OID_OIWSEC_desEDE = CERTENROLL_OBJECTID._OIWSEC_desEDE;
pub const XCN_OID_OIWSEC_sha = CERTENROLL_OBJECTID._OIWSEC_sha;
pub const XCN_OID_OIWSEC_mdc2 = CERTENROLL_OBJECTID._OIWSEC_mdc2;
pub const XCN_OID_OIWSEC_dsaComm = CERTENROLL_OBJECTID._OIWSEC_dsaComm;
pub const XCN_OID_OIWSEC_dsaCommSHA = CERTENROLL_OBJECTID._OIWSEC_dsaCommSHA;
pub const XCN_OID_OIWSEC_rsaXchg = CERTENROLL_OBJECTID._OIWSEC_rsaXchg;
pub const XCN_OID_OIWSEC_keyHashSeal = CERTENROLL_OBJECTID._OIWSEC_keyHashSeal;
pub const XCN_OID_OIWSEC_md2RSASign = CERTENROLL_OBJECTID._OIWSEC_md2RSASign;
pub const XCN_OID_OIWSEC_md5RSASign = CERTENROLL_OBJECTID._OIWSEC_md5RSASign;
pub const XCN_OID_OIWSEC_sha1 = CERTENROLL_OBJECTID._OIWSEC_sha1;
pub const XCN_OID_OIWSEC_dsaSHA1 = CERTENROLL_OBJECTID._OIWSEC_dsaSHA1;
pub const XCN_OID_OIWSEC_dsaCommSHA1 = CERTENROLL_OBJECTID._OIWSEC_dsaCommSHA1;
pub const XCN_OID_OIWSEC_sha1RSASign = CERTENROLL_OBJECTID._OIWSEC_sha1RSASign;
pub const XCN_OID_OIWDIR = CERTENROLL_OBJECTID._OIWDIR;
pub const XCN_OID_OIWDIR_CRPT = CERTENROLL_OBJECTID._OIWDIR_CRPT;
pub const XCN_OID_OIWDIR_HASH = CERTENROLL_OBJECTID._OIWDIR_HASH;
pub const XCN_OID_OIWDIR_SIGN = CERTENROLL_OBJECTID._OIWDIR_SIGN;
pub const XCN_OID_OIWDIR_md2 = CERTENROLL_OBJECTID._OIWDIR_md2;
pub const XCN_OID_OIWDIR_md2RSA = CERTENROLL_OBJECTID._OIWDIR_md2RSA;
pub const XCN_OID_INFOSEC = CERTENROLL_OBJECTID._INFOSEC;
pub const XCN_OID_INFOSEC_sdnsSignature = CERTENROLL_OBJECTID._INFOSEC_sdnsSignature;
pub const XCN_OID_INFOSEC_mosaicSignature = CERTENROLL_OBJECTID._INFOSEC_mosaicSignature;
pub const XCN_OID_INFOSEC_sdnsConfidentiality = CERTENROLL_OBJECTID._INFOSEC_sdnsConfidentiality;
pub const XCN_OID_INFOSEC_mosaicConfidentiality = CERTENROLL_OBJECTID._INFOSEC_mosaicConfidentiality;
pub const XCN_OID_INFOSEC_sdnsIntegrity = CERTENROLL_OBJECTID._INFOSEC_sdnsIntegrity;
pub const XCN_OID_INFOSEC_mosaicIntegrity = CERTENROLL_OBJECTID._INFOSEC_mosaicIntegrity;
pub const XCN_OID_INFOSEC_sdnsTokenProtection = CERTENROLL_OBJECTID._INFOSEC_sdnsTokenProtection;
pub const XCN_OID_INFOSEC_mosaicTokenProtection = CERTENROLL_OBJECTID._INFOSEC_mosaicTokenProtection;
pub const XCN_OID_INFOSEC_sdnsKeyManagement = CERTENROLL_OBJECTID._INFOSEC_sdnsKeyManagement;
pub const XCN_OID_INFOSEC_mosaicKeyManagement = CERTENROLL_OBJECTID._INFOSEC_mosaicKeyManagement;
pub const XCN_OID_INFOSEC_sdnsKMandSig = CERTENROLL_OBJECTID._INFOSEC_sdnsKMandSig;
pub const XCN_OID_INFOSEC_mosaicKMandSig = CERTENROLL_OBJECTID._INFOSEC_mosaicKMandSig;
pub const XCN_OID_INFOSEC_SuiteASignature = CERTENROLL_OBJECTID._INFOSEC_SuiteASignature;
pub const XCN_OID_INFOSEC_SuiteAConfidentiality = CERTENROLL_OBJECTID._INFOSEC_SuiteAConfidentiality;
pub const XCN_OID_INFOSEC_SuiteAIntegrity = CERTENROLL_OBJECTID._INFOSEC_SuiteAIntegrity;
pub const XCN_OID_INFOSEC_SuiteATokenProtection = CERTENROLL_OBJECTID._INFOSEC_SuiteATokenProtection;
pub const XCN_OID_INFOSEC_SuiteAKeyManagement = CERTENROLL_OBJECTID._INFOSEC_SuiteAKeyManagement;
pub const XCN_OID_INFOSEC_SuiteAKMandSig = CERTENROLL_OBJECTID._INFOSEC_SuiteAKMandSig;
pub const XCN_OID_INFOSEC_mosaicUpdatedSig = CERTENROLL_OBJECTID._INFOSEC_mosaicUpdatedSig;
pub const XCN_OID_INFOSEC_mosaicKMandUpdSig = CERTENROLL_OBJECTID._INFOSEC_mosaicKMandUpdSig;
pub const XCN_OID_INFOSEC_mosaicUpdatedInteg = CERTENROLL_OBJECTID._INFOSEC_mosaicUpdatedInteg;
pub const XCN_OID_COMMON_NAME = CERTENROLL_OBJECTID._COMMON_NAME;
pub const XCN_OID_SUR_NAME = CERTENROLL_OBJECTID._SUR_NAME;
pub const XCN_OID_DEVICE_SERIAL_NUMBER = CERTENROLL_OBJECTID._DEVICE_SERIAL_NUMBER;
pub const XCN_OID_COUNTRY_NAME = CERTENROLL_OBJECTID._COUNTRY_NAME;
pub const XCN_OID_LOCALITY_NAME = CERTENROLL_OBJECTID._LOCALITY_NAME;
pub const XCN_OID_STATE_OR_PROVINCE_NAME = CERTENROLL_OBJECTID._STATE_OR_PROVINCE_NAME;
pub const XCN_OID_STREET_ADDRESS = CERTENROLL_OBJECTID._STREET_ADDRESS;
pub const XCN_OID_ORGANIZATION_NAME = CERTENROLL_OBJECTID._ORGANIZATION_NAME;
pub const XCN_OID_ORGANIZATIONAL_UNIT_NAME = CERTENROLL_OBJECTID._ORGANIZATIONAL_UNIT_NAME;
pub const XCN_OID_TITLE = CERTENROLL_OBJECTID._TITLE;
pub const XCN_OID_DESCRIPTION = CERTENROLL_OBJECTID._DESCRIPTION;
pub const XCN_OID_SEARCH_GUIDE = CERTENROLL_OBJECTID._SEARCH_GUIDE;
pub const XCN_OID_BUSINESS_CATEGORY = CERTENROLL_OBJECTID._BUSINESS_CATEGORY;
pub const XCN_OID_POSTAL_ADDRESS = CERTENROLL_OBJECTID._POSTAL_ADDRESS;
pub const XCN_OID_POSTAL_CODE = CERTENROLL_OBJECTID._POSTAL_CODE;
pub const XCN_OID_POST_OFFICE_BOX = CERTENROLL_OBJECTID._POST_OFFICE_BOX;
pub const XCN_OID_PHYSICAL_DELIVERY_OFFICE_NAME = CERTENROLL_OBJECTID._PHYSICAL_DELIVERY_OFFICE_NAME;
pub const XCN_OID_TELEPHONE_NUMBER = CERTENROLL_OBJECTID._TELEPHONE_NUMBER;
pub const XCN_OID_TELEX_NUMBER = CERTENROLL_OBJECTID._TELEX_NUMBER;
pub const XCN_OID_TELETEXT_TERMINAL_IDENTIFIER = CERTENROLL_OBJECTID._TELETEXT_TERMINAL_IDENTIFIER;
pub const XCN_OID_FACSIMILE_TELEPHONE_NUMBER = CERTENROLL_OBJECTID._FACSIMILE_TELEPHONE_NUMBER;
pub const XCN_OID_X21_ADDRESS = CERTENROLL_OBJECTID._X21_ADDRESS;
pub const XCN_OID_INTERNATIONAL_ISDN_NUMBER = CERTENROLL_OBJECTID._INTERNATIONAL_ISDN_NUMBER;
pub const XCN_OID_REGISTERED_ADDRESS = CERTENROLL_OBJECTID._REGISTERED_ADDRESS;
pub const XCN_OID_DESTINATION_INDICATOR = CERTENROLL_OBJECTID._DESTINATION_INDICATOR;
pub const XCN_OID_PREFERRED_DELIVERY_METHOD = CERTENROLL_OBJECTID._PREFERRED_DELIVERY_METHOD;
pub const XCN_OID_PRESENTATION_ADDRESS = CERTENROLL_OBJECTID._PRESENTATION_ADDRESS;
pub const XCN_OID_SUPPORTED_APPLICATION_CONTEXT = CERTENROLL_OBJECTID._SUPPORTED_APPLICATION_CONTEXT;
pub const XCN_OID_MEMBER = CERTENROLL_OBJECTID._MEMBER;
pub const XCN_OID_OWNER = CERTENROLL_OBJECTID._OWNER;
pub const XCN_OID_ROLE_OCCUPANT = CERTENROLL_OBJECTID._ROLE_OCCUPANT;
pub const XCN_OID_SEE_ALSO = CERTENROLL_OBJECTID._SEE_ALSO;
pub const XCN_OID_USER_PASSWORD = CERTENROLL_OBJECTID._USER_PASSWORD;
pub const XCN_OID_USER_CERTIFICATE = CERTENROLL_OBJECTID._USER_CERTIFICATE;
pub const XCN_OID_CA_CERTIFICATE = CERTENROLL_OBJECTID._CA_CERTIFICATE;
pub const XCN_OID_AUTHORITY_REVOCATION_LIST = CERTENROLL_OBJECTID._AUTHORITY_REVOCATION_LIST;
pub const XCN_OID_CERTIFICATE_REVOCATION_LIST = CERTENROLL_OBJECTID._CERTIFICATE_REVOCATION_LIST;
pub const XCN_OID_CROSS_CERTIFICATE_PAIR = CERTENROLL_OBJECTID._CROSS_CERTIFICATE_PAIR;
pub const XCN_OID_GIVEN_NAME = CERTENROLL_OBJECTID._GIVEN_NAME;
pub const XCN_OID_INITIALS = CERTENROLL_OBJECTID._INITIALS;
pub const XCN_OID_DN_QUALIFIER = CERTENROLL_OBJECTID._DN_QUALIFIER;
pub const XCN_OID_DOMAIN_COMPONENT = CERTENROLL_OBJECTID._DOMAIN_COMPONENT;
pub const XCN_OID_PKCS_12_FRIENDLY_NAME_ATTR = CERTENROLL_OBJECTID._PKCS_12_FRIENDLY_NAME_ATTR;
pub const XCN_OID_PKCS_12_LOCAL_KEY_ID = CERTENROLL_OBJECTID._PKCS_12_LOCAL_KEY_ID;
pub const XCN_OID_PKCS_12_KEY_PROVIDER_NAME_ATTR = CERTENROLL_OBJECTID._PKCS_12_KEY_PROVIDER_NAME_ATTR;
pub const XCN_OID_LOCAL_MACHINE_KEYSET = CERTENROLL_OBJECTID._LOCAL_MACHINE_KEYSET;
pub const XCN_OID_PKCS_12_EXTENDED_ATTRIBUTES = CERTENROLL_OBJECTID._PKCS_12_EXTENDED_ATTRIBUTES;
pub const XCN_OID_KEYID_RDN = CERTENROLL_OBJECTID._KEYID_RDN;
pub const XCN_OID_AUTHORITY_KEY_IDENTIFIER = CERTENROLL_OBJECTID._AUTHORITY_KEY_IDENTIFIER;
pub const XCN_OID_KEY_ATTRIBUTES = CERTENROLL_OBJECTID._KEY_ATTRIBUTES;
pub const XCN_OID_CERT_POLICIES_95 = CERTENROLL_OBJECTID._CERT_POLICIES_95;
pub const XCN_OID_KEY_USAGE_RESTRICTION = CERTENROLL_OBJECTID._KEY_USAGE_RESTRICTION;
pub const XCN_OID_SUBJECT_ALT_NAME = CERTENROLL_OBJECTID._SUBJECT_ALT_NAME;
pub const XCN_OID_ISSUER_ALT_NAME = CERTENROLL_OBJECTID._ISSUER_ALT_NAME;
pub const XCN_OID_BASIC_CONSTRAINTS = CERTENROLL_OBJECTID._BASIC_CONSTRAINTS;
pub const XCN_OID_KEY_USAGE = CERTENROLL_OBJECTID._KEY_USAGE;
pub const XCN_OID_PRIVATEKEY_USAGE_PERIOD = CERTENROLL_OBJECTID._PRIVATEKEY_USAGE_PERIOD;
pub const XCN_OID_BASIC_CONSTRAINTS2 = CERTENROLL_OBJECTID._BASIC_CONSTRAINTS2;
pub const XCN_OID_CERT_POLICIES = CERTENROLL_OBJECTID._CERT_POLICIES;
pub const XCN_OID_ANY_CERT_POLICY = CERTENROLL_OBJECTID._ANY_CERT_POLICY;
pub const XCN_OID_AUTHORITY_KEY_IDENTIFIER2 = CERTENROLL_OBJECTID._AUTHORITY_KEY_IDENTIFIER2;
pub const XCN_OID_SUBJECT_KEY_IDENTIFIER = CERTENROLL_OBJECTID._SUBJECT_KEY_IDENTIFIER;
pub const XCN_OID_SUBJECT_ALT_NAME2 = CERTENROLL_OBJECTID._SUBJECT_ALT_NAME2;
pub const XCN_OID_ISSUER_ALT_NAME2 = CERTENROLL_OBJECTID._ISSUER_ALT_NAME2;
pub const XCN_OID_CRL_REASON_CODE = CERTENROLL_OBJECTID._CRL_REASON_CODE;
pub const XCN_OID_REASON_CODE_HOLD = CERTENROLL_OBJECTID._REASON_CODE_HOLD;
pub const XCN_OID_CRL_DIST_POINTS = CERTENROLL_OBJECTID._CRL_DIST_POINTS;
pub const XCN_OID_ENHANCED_KEY_USAGE = CERTENROLL_OBJECTID._ENHANCED_KEY_USAGE;
pub const XCN_OID_CRL_NUMBER = CERTENROLL_OBJECTID._CRL_NUMBER;
pub const XCN_OID_DELTA_CRL_INDICATOR = CERTENROLL_OBJECTID._DELTA_CRL_INDICATOR;
pub const XCN_OID_ISSUING_DIST_POINT = CERTENROLL_OBJECTID._ISSUING_DIST_POINT;
pub const XCN_OID_FRESHEST_CRL = CERTENROLL_OBJECTID._FRESHEST_CRL;
pub const XCN_OID_NAME_CONSTRAINTS = CERTENROLL_OBJECTID._NAME_CONSTRAINTS;
pub const XCN_OID_POLICY_MAPPINGS = CERTENROLL_OBJECTID._POLICY_MAPPINGS;
pub const XCN_OID_LEGACY_POLICY_MAPPINGS = CERTENROLL_OBJECTID._LEGACY_POLICY_MAPPINGS;
pub const XCN_OID_POLICY_CONSTRAINTS = CERTENROLL_OBJECTID._POLICY_CONSTRAINTS;
pub const XCN_OID_RENEWAL_CERTIFICATE = CERTENROLL_OBJECTID._RENEWAL_CERTIFICATE;
pub const XCN_OID_ENROLLMENT_NAME_VALUE_PAIR = CERTENROLL_OBJECTID._ENROLLMENT_NAME_VALUE_PAIR;
pub const XCN_OID_ENROLLMENT_CSP_PROVIDER = CERTENROLL_OBJECTID._ENROLLMENT_CSP_PROVIDER;
pub const XCN_OID_OS_VERSION = CERTENROLL_OBJECTID._OS_VERSION;
pub const XCN_OID_ENROLLMENT_AGENT = CERTENROLL_OBJECTID._ENROLLMENT_AGENT;
pub const XCN_OID_PKIX = CERTENROLL_OBJECTID._PKIX;
pub const XCN_OID_PKIX_PE = CERTENROLL_OBJECTID._PKIX_PE;
pub const XCN_OID_AUTHORITY_INFO_ACCESS = CERTENROLL_OBJECTID._AUTHORITY_INFO_ACCESS;
pub const XCN_OID_BIOMETRIC_EXT = CERTENROLL_OBJECTID._BIOMETRIC_EXT;
pub const XCN_OID_LOGOTYPE_EXT = CERTENROLL_OBJECTID._LOGOTYPE_EXT;
pub const XCN_OID_CERT_EXTENSIONS = CERTENROLL_OBJECTID._CERT_EXTENSIONS;
pub const XCN_OID_NEXT_UPDATE_LOCATION = CERTENROLL_OBJECTID._NEXT_UPDATE_LOCATION;
pub const XCN_OID_REMOVE_CERTIFICATE = CERTENROLL_OBJECTID._REMOVE_CERTIFICATE;
pub const XCN_OID_CROSS_CERT_DIST_POINTS = CERTENROLL_OBJECTID._CROSS_CERT_DIST_POINTS;
pub const XCN_OID_CTL = CERTENROLL_OBJECTID._CTL;
pub const XCN_OID_SORTED_CTL = CERTENROLL_OBJECTID._SORTED_CTL;
pub const XCN_OID_SERIALIZED = CERTENROLL_OBJECTID._SERIALIZED;
pub const XCN_OID_NT_PRINCIPAL_NAME = CERTENROLL_OBJECTID._NT_PRINCIPAL_NAME;
pub const XCN_OID_PRODUCT_UPDATE = CERTENROLL_OBJECTID._PRODUCT_UPDATE;
pub const XCN_OID_ANY_APPLICATION_POLICY = CERTENROLL_OBJECTID._ANY_APPLICATION_POLICY;
pub const XCN_OID_AUTO_ENROLL_CTL_USAGE = CERTENROLL_OBJECTID._AUTO_ENROLL_CTL_USAGE;
pub const XCN_OID_ENROLL_CERTTYPE_EXTENSION = CERTENROLL_OBJECTID._ENROLL_CERTTYPE_EXTENSION;
pub const XCN_OID_CERT_MANIFOLD = CERTENROLL_OBJECTID._CERT_MANIFOLD;
pub const XCN_OID_CERTSRV_CA_VERSION = CERTENROLL_OBJECTID._CERTSRV_CA_VERSION;
pub const XCN_OID_CERTSRV_PREVIOUS_CERT_HASH = CERTENROLL_OBJECTID._CERTSRV_PREVIOUS_CERT_HASH;
pub const XCN_OID_CRL_VIRTUAL_BASE = CERTENROLL_OBJECTID._CRL_VIRTUAL_BASE;
pub const XCN_OID_CRL_NEXT_PUBLISH = CERTENROLL_OBJECTID._CRL_NEXT_PUBLISH;
pub const XCN_OID_KP_CA_EXCHANGE = CERTENROLL_OBJECTID._KP_CA_EXCHANGE;
pub const XCN_OID_KP_KEY_RECOVERY_AGENT = CERTENROLL_OBJECTID._KP_KEY_RECOVERY_AGENT;
pub const XCN_OID_CERTIFICATE_TEMPLATE = CERTENROLL_OBJECTID._CERTIFICATE_TEMPLATE;
pub const XCN_OID_ENTERPRISE_OID_ROOT = CERTENROLL_OBJECTID._ENTERPRISE_OID_ROOT;
pub const XCN_OID_RDN_DUMMY_SIGNER = CERTENROLL_OBJECTID._RDN_DUMMY_SIGNER;
pub const XCN_OID_APPLICATION_CERT_POLICIES = CERTENROLL_OBJECTID._APPLICATION_CERT_POLICIES;
pub const XCN_OID_APPLICATION_POLICY_MAPPINGS = CERTENROLL_OBJECTID._APPLICATION_POLICY_MAPPINGS;
pub const XCN_OID_APPLICATION_POLICY_CONSTRAINTS = CERTENROLL_OBJECTID._APPLICATION_POLICY_CONSTRAINTS;
pub const XCN_OID_ARCHIVED_KEY_ATTR = CERTENROLL_OBJECTID._ARCHIVED_KEY_ATTR;
pub const XCN_OID_CRL_SELF_CDP = CERTENROLL_OBJECTID._CRL_SELF_CDP;
pub const XCN_OID_REQUIRE_CERT_CHAIN_POLICY = CERTENROLL_OBJECTID._REQUIRE_CERT_CHAIN_POLICY;
pub const XCN_OID_ARCHIVED_KEY_CERT_HASH = CERTENROLL_OBJECTID._ARCHIVED_KEY_CERT_HASH;
pub const XCN_OID_ISSUED_CERT_HASH = CERTENROLL_OBJECTID._ISSUED_CERT_HASH;
pub const XCN_OID_DS_EMAIL_REPLICATION = CERTENROLL_OBJECTID._DS_EMAIL_REPLICATION;
pub const XCN_OID_REQUEST_CLIENT_INFO = CERTENROLL_OBJECTID._REQUEST_CLIENT_INFO;
pub const XCN_OID_ENCRYPTED_KEY_HASH = CERTENROLL_OBJECTID._ENCRYPTED_KEY_HASH;
pub const XCN_OID_CERTSRV_CROSSCA_VERSION = CERTENROLL_OBJECTID._CERTSRV_CROSSCA_VERSION;
pub const XCN_OID_NTDS_REPLICATION = CERTENROLL_OBJECTID._NTDS_REPLICATION;
pub const XCN_OID_SUBJECT_DIR_ATTRS = CERTENROLL_OBJECTID._SUBJECT_DIR_ATTRS;
pub const XCN_OID_PKIX_KP = CERTENROLL_OBJECTID._PKIX_KP;
pub const XCN_OID_PKIX_KP_SERVER_AUTH = CERTENROLL_OBJECTID._PKIX_KP_SERVER_AUTH;
pub const XCN_OID_PKIX_KP_CLIENT_AUTH = CERTENROLL_OBJECTID._PKIX_KP_CLIENT_AUTH;
pub const XCN_OID_PKIX_KP_CODE_SIGNING = CERTENROLL_OBJECTID._PKIX_KP_CODE_SIGNING;
pub const XCN_OID_PKIX_KP_EMAIL_PROTECTION = CERTENROLL_OBJECTID._PKIX_KP_EMAIL_PROTECTION;
pub const XCN_OID_PKIX_KP_IPSEC_END_SYSTEM = CERTENROLL_OBJECTID._PKIX_KP_IPSEC_END_SYSTEM;
pub const XCN_OID_PKIX_KP_IPSEC_TUNNEL = CERTENROLL_OBJECTID._PKIX_KP_IPSEC_TUNNEL;
pub const XCN_OID_PKIX_KP_IPSEC_USER = CERTENROLL_OBJECTID._PKIX_KP_IPSEC_USER;
pub const XCN_OID_PKIX_KP_TIMESTAMP_SIGNING = CERTENROLL_OBJECTID._PKIX_KP_TIMESTAMP_SIGNING;
pub const XCN_OID_PKIX_KP_OCSP_SIGNING = CERTENROLL_OBJECTID._PKIX_KP_OCSP_SIGNING;
pub const XCN_OID_PKIX_OCSP_NOCHECK = CERTENROLL_OBJECTID._PKIX_OCSP_NOCHECK;
pub const XCN_OID_IPSEC_KP_IKE_INTERMEDIATE = CERTENROLL_OBJECTID._IPSEC_KP_IKE_INTERMEDIATE;
pub const XCN_OID_KP_CTL_USAGE_SIGNING = CERTENROLL_OBJECTID._KP_CTL_USAGE_SIGNING;
pub const XCN_OID_KP_TIME_STAMP_SIGNING = CERTENROLL_OBJECTID._KP_TIME_STAMP_SIGNING;
pub const XCN_OID_SERVER_GATED_CRYPTO = CERTENROLL_OBJECTID._SERVER_GATED_CRYPTO;
pub const XCN_OID_SGC_NETSCAPE = CERTENROLL_OBJECTID._SGC_NETSCAPE;
pub const XCN_OID_KP_EFS = CERTENROLL_OBJECTID._KP_EFS;
pub const XCN_OID_EFS_RECOVERY = CERTENROLL_OBJECTID._EFS_RECOVERY;
pub const XCN_OID_WHQL_CRYPTO = CERTENROLL_OBJECTID._WHQL_CRYPTO;
pub const XCN_OID_NT5_CRYPTO = CERTENROLL_OBJECTID._NT5_CRYPTO;
pub const XCN_OID_OEM_WHQL_CRYPTO = CERTENROLL_OBJECTID._OEM_WHQL_CRYPTO;
pub const XCN_OID_EMBEDDED_NT_CRYPTO = CERTENROLL_OBJECTID._EMBEDDED_NT_CRYPTO;
pub const XCN_OID_ROOT_LIST_SIGNER = CERTENROLL_OBJECTID._ROOT_LIST_SIGNER;
pub const XCN_OID_KP_QUALIFIED_SUBORDINATION = CERTENROLL_OBJECTID._KP_QUALIFIED_SUBORDINATION;
pub const XCN_OID_KP_KEY_RECOVERY = CERTENROLL_OBJECTID._KP_KEY_RECOVERY;
pub const XCN_OID_KP_DOCUMENT_SIGNING = CERTENROLL_OBJECTID._KP_DOCUMENT_SIGNING;
pub const XCN_OID_KP_LIFETIME_SIGNING = CERTENROLL_OBJECTID._KP_LIFETIME_SIGNING;
pub const XCN_OID_KP_MOBILE_DEVICE_SOFTWARE = CERTENROLL_OBJECTID._KP_MOBILE_DEVICE_SOFTWARE;
pub const XCN_OID_KP_SMART_DISPLAY = CERTENROLL_OBJECTID._KP_SMART_DISPLAY;
pub const XCN_OID_KP_CSP_SIGNATURE = CERTENROLL_OBJECTID._KP_CSP_SIGNATURE;
pub const XCN_OID_DRM = CERTENROLL_OBJECTID._DRM;
pub const XCN_OID_DRM_INDIVIDUALIZATION = CERTENROLL_OBJECTID._DRM_INDIVIDUALIZATION;
pub const XCN_OID_LICENSES = CERTENROLL_OBJECTID._LICENSES;
pub const XCN_OID_LICENSE_SERVER = CERTENROLL_OBJECTID._LICENSE_SERVER;
pub const XCN_OID_KP_SMARTCARD_LOGON = CERTENROLL_OBJECTID._KP_SMARTCARD_LOGON;
pub const XCN_OID_YESNO_TRUST_ATTR = CERTENROLL_OBJECTID._YESNO_TRUST_ATTR;
pub const XCN_OID_PKIX_POLICY_QUALIFIER_CPS = CERTENROLL_OBJECTID._PKIX_POLICY_QUALIFIER_CPS;
pub const XCN_OID_PKIX_POLICY_QUALIFIER_USERNOTICE = CERTENROLL_OBJECTID._PKIX_POLICY_QUALIFIER_USERNOTICE;
pub const XCN_OID_CERT_POLICIES_95_QUALIFIER1 = CERTENROLL_OBJECTID._CERT_POLICIES_95_QUALIFIER1;
pub const XCN_OID_PKIX_ACC_DESCR = CERTENROLL_OBJECTID._PKIX_ACC_DESCR;
pub const XCN_OID_PKIX_OCSP = CERTENROLL_OBJECTID._PKIX_OCSP;
pub const XCN_OID_PKIX_CA_ISSUERS = CERTENROLL_OBJECTID._PKIX_CA_ISSUERS;
pub const XCN_OID_VERISIGN_PRIVATE_6_9 = CERTENROLL_OBJECTID._VERISIGN_PRIVATE_6_9;
pub const XCN_OID_VERISIGN_ONSITE_JURISDICTION_HASH = CERTENROLL_OBJECTID._VERISIGN_ONSITE_JURISDICTION_HASH;
pub const XCN_OID_VERISIGN_BITSTRING_6_13 = CERTENROLL_OBJECTID._VERISIGN_BITSTRING_6_13;
pub const XCN_OID_VERISIGN_ISS_STRONG_CRYPTO = CERTENROLL_OBJECTID._VERISIGN_ISS_STRONG_CRYPTO;
pub const XCN_OID_NETSCAPE = CERTENROLL_OBJECTID._NETSCAPE;
pub const XCN_OID_NETSCAPE_CERT_EXTENSION = CERTENROLL_OBJECTID._NETSCAPE_CERT_EXTENSION;
pub const XCN_OID_NETSCAPE_CERT_TYPE = CERTENROLL_OBJECTID._NETSCAPE_CERT_TYPE;
pub const XCN_OID_NETSCAPE_BASE_URL = CERTENROLL_OBJECTID._NETSCAPE_BASE_URL;
pub const XCN_OID_NETSCAPE_REVOCATION_URL = CERTENROLL_OBJECTID._NETSCAPE_REVOCATION_URL;
pub const XCN_OID_NETSCAPE_CA_REVOCATION_URL = CERTENROLL_OBJECTID._NETSCAPE_CA_REVOCATION_URL;
pub const XCN_OID_NETSCAPE_CERT_RENEWAL_URL = CERTENROLL_OBJECTID._NETSCAPE_CERT_RENEWAL_URL;
pub const XCN_OID_NETSCAPE_CA_POLICY_URL = CERTENROLL_OBJECTID._NETSCAPE_CA_POLICY_URL;
pub const XCN_OID_NETSCAPE_SSL_SERVER_NAME = CERTENROLL_OBJECTID._NETSCAPE_SSL_SERVER_NAME;
pub const XCN_OID_NETSCAPE_COMMENT = CERTENROLL_OBJECTID._NETSCAPE_COMMENT;
pub const XCN_OID_NETSCAPE_DATA_TYPE = CERTENROLL_OBJECTID._NETSCAPE_DATA_TYPE;
pub const XCN_OID_NETSCAPE_CERT_SEQUENCE = CERTENROLL_OBJECTID._NETSCAPE_CERT_SEQUENCE;
pub const XCN_OID_CT_PKI_DATA = CERTENROLL_OBJECTID._CT_PKI_DATA;
pub const XCN_OID_CT_PKI_RESPONSE = CERTENROLL_OBJECTID._CT_PKI_RESPONSE;
pub const XCN_OID_PKIX_NO_SIGNATURE = CERTENROLL_OBJECTID._PKIX_NO_SIGNATURE;
pub const XCN_OID_CMC = CERTENROLL_OBJECTID._CMC;
pub const XCN_OID_CMC_STATUS_INFO = CERTENROLL_OBJECTID._CMC_STATUS_INFO;
pub const XCN_OID_CMC_IDENTIFICATION = CERTENROLL_OBJECTID._CMC_IDENTIFICATION;
pub const XCN_OID_CMC_IDENTITY_PROOF = CERTENROLL_OBJECTID._CMC_IDENTITY_PROOF;
pub const XCN_OID_CMC_DATA_RETURN = CERTENROLL_OBJECTID._CMC_DATA_RETURN;
pub const XCN_OID_CMC_TRANSACTION_ID = CERTENROLL_OBJECTID._CMC_TRANSACTION_ID;
pub const XCN_OID_CMC_SENDER_NONCE = CERTENROLL_OBJECTID._CMC_SENDER_NONCE;
pub const XCN_OID_CMC_RECIPIENT_NONCE = CERTENROLL_OBJECTID._CMC_RECIPIENT_NONCE;
pub const XCN_OID_CMC_ADD_EXTENSIONS = CERTENROLL_OBJECTID._CMC_ADD_EXTENSIONS;
pub const XCN_OID_CMC_ENCRYPTED_POP = CERTENROLL_OBJECTID._CMC_ENCRYPTED_POP;
pub const XCN_OID_CMC_DECRYPTED_POP = CERTENROLL_OBJECTID._CMC_DECRYPTED_POP;
pub const XCN_OID_CMC_LRA_POP_WITNESS = CERTENROLL_OBJECTID._CMC_LRA_POP_WITNESS;
pub const XCN_OID_CMC_GET_CERT = CERTENROLL_OBJECTID._CMC_GET_CERT;
pub const XCN_OID_CMC_GET_CRL = CERTENROLL_OBJECTID._CMC_GET_CRL;
pub const XCN_OID_CMC_REVOKE_REQUEST = CERTENROLL_OBJECTID._CMC_REVOKE_REQUEST;
pub const XCN_OID_CMC_REG_INFO = CERTENROLL_OBJECTID._CMC_REG_INFO;
pub const XCN_OID_CMC_RESPONSE_INFO = CERTENROLL_OBJECTID._CMC_RESPONSE_INFO;
pub const XCN_OID_CMC_QUERY_PENDING = CERTENROLL_OBJECTID._CMC_QUERY_PENDING;
pub const XCN_OID_CMC_ID_POP_LINK_RANDOM = CERTENROLL_OBJECTID._CMC_ID_POP_LINK_RANDOM;
pub const XCN_OID_CMC_ID_POP_LINK_WITNESS = CERTENROLL_OBJECTID._CMC_ID_POP_LINK_WITNESS;
pub const XCN_OID_CMC_ID_CONFIRM_CERT_ACCEPTANCE = CERTENROLL_OBJECTID._CMC_ID_CONFIRM_CERT_ACCEPTANCE;
pub const XCN_OID_CMC_ADD_ATTRIBUTES = CERTENROLL_OBJECTID._CMC_ADD_ATTRIBUTES;
pub const XCN_OID_LOYALTY_OTHER_LOGOTYPE = CERTENROLL_OBJECTID._LOYALTY_OTHER_LOGOTYPE;
pub const XCN_OID_BACKGROUND_OTHER_LOGOTYPE = CERTENROLL_OBJECTID._BACKGROUND_OTHER_LOGOTYPE;
pub const XCN_OID_PKIX_OCSP_BASIC_SIGNED_RESPONSE = CERTENROLL_OBJECTID._PKIX_OCSP_BASIC_SIGNED_RESPONSE;
pub const XCN_OID_PKCS_7_DATA = CERTENROLL_OBJECTID._PKCS_7_DATA;
pub const XCN_OID_PKCS_7_SIGNED = CERTENROLL_OBJECTID._PKCS_7_SIGNED;
pub const XCN_OID_PKCS_7_ENVELOPED = CERTENROLL_OBJECTID._PKCS_7_ENVELOPED;
pub const XCN_OID_PKCS_7_SIGNEDANDENVELOPED = CERTENROLL_OBJECTID._PKCS_7_SIGNEDANDENVELOPED;
pub const XCN_OID_PKCS_7_DIGESTED = CERTENROLL_OBJECTID._PKCS_7_DIGESTED;
pub const XCN_OID_PKCS_7_ENCRYPTED = CERTENROLL_OBJECTID._PKCS_7_ENCRYPTED;
pub const XCN_OID_PKCS_9_CONTENT_TYPE = CERTENROLL_OBJECTID._PKCS_9_CONTENT_TYPE;
pub const XCN_OID_PKCS_9_MESSAGE_DIGEST = CERTENROLL_OBJECTID._PKCS_9_MESSAGE_DIGEST;
pub const XCN_OID_CERT_PROP_ID_PREFIX = CERTENROLL_OBJECTID._CERT_PROP_ID_PREFIX;
pub const XCN_OID_CERT_KEY_IDENTIFIER_PROP_ID = CERTENROLL_OBJECTID._CERT_KEY_IDENTIFIER_PROP_ID;
pub const XCN_OID_CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID = CERTENROLL_OBJECTID._CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID;
pub const XCN_OID_CERT_SUBJECT_NAME_MD5_HASH_PROP_ID = CERTENROLL_OBJECTID._CERT_SUBJECT_NAME_MD5_HASH_PROP_ID;
pub const XCN_OID_CERT_MD5_HASH_PROP_ID = CERTENROLL_OBJECTID._CERT_MD5_HASH_PROP_ID;
pub const XCN_OID_RSA_SHA256RSA = CERTENROLL_OBJECTID._RSA_SHA256RSA;
pub const XCN_OID_RSA_SHA384RSA = CERTENROLL_OBJECTID._RSA_SHA384RSA;
pub const XCN_OID_RSA_SHA512RSA = CERTENROLL_OBJECTID._RSA_SHA512RSA;
pub const XCN_OID_NIST_sha256 = CERTENROLL_OBJECTID._NIST_sha256;
pub const XCN_OID_NIST_sha384 = CERTENROLL_OBJECTID._NIST_sha384;
pub const XCN_OID_NIST_sha512 = CERTENROLL_OBJECTID._NIST_sha512;
pub const XCN_OID_RSA_MGF1 = CERTENROLL_OBJECTID._RSA_MGF1;
pub const XCN_OID_ECC_PUBLIC_KEY = CERTENROLL_OBJECTID._ECC_PUBLIC_KEY;
pub const XCN_OID_ECDSA_SHA1 = CERTENROLL_OBJECTID._ECDSA_SHA1;
pub const XCN_OID_ECDSA_SPECIFIED = CERTENROLL_OBJECTID._ECDSA_SPECIFIED;
pub const XCN_OID_ANY_ENHANCED_KEY_USAGE = CERTENROLL_OBJECTID._ANY_ENHANCED_KEY_USAGE;
pub const XCN_OID_RSA_SSA_PSS = CERTENROLL_OBJECTID._RSA_SSA_PSS;
pub const XCN_OID_ATTR_SUPPORTED_ALGORITHMS = CERTENROLL_OBJECTID._ATTR_SUPPORTED_ALGORITHMS;
pub const XCN_OID_ATTR_TPM_SECURITY_ASSERTIONS = CERTENROLL_OBJECTID._ATTR_TPM_SECURITY_ASSERTIONS;
pub const XCN_OID_ATTR_TPM_SPECIFICATION = CERTENROLL_OBJECTID._ATTR_TPM_SPECIFICATION;
pub const XCN_OID_CERT_DISALLOWED_FILETIME_PROP_ID = CERTENROLL_OBJECTID._CERT_DISALLOWED_FILETIME_PROP_ID;
pub const XCN_OID_CERT_SIGNATURE_HASH_PROP_ID = CERTENROLL_OBJECTID._CERT_SIGNATURE_HASH_PROP_ID;
pub const XCN_OID_CERT_STRONG_KEY_OS_1 = CERTENROLL_OBJECTID._CERT_STRONG_KEY_OS_1;
pub const XCN_OID_CERT_STRONG_KEY_OS_CURRENT = CERTENROLL_OBJECTID._CERT_STRONG_KEY_OS_CURRENT;
pub const XCN_OID_CERT_STRONG_KEY_OS_PREFIX = CERTENROLL_OBJECTID._CERT_STRONG_KEY_OS_PREFIX;
pub const XCN_OID_CERT_STRONG_SIGN_OS_1 = CERTENROLL_OBJECTID._CERT_STRONG_SIGN_OS_1;
pub const XCN_OID_CERT_STRONG_SIGN_OS_CURRENT = CERTENROLL_OBJECTID._CERT_STRONG_SIGN_OS_CURRENT;
pub const XCN_OID_CERT_STRONG_SIGN_OS_PREFIX = CERTENROLL_OBJECTID._CERT_STRONG_SIGN_OS_PREFIX;
pub const XCN_OID_DH_SINGLE_PASS_STDDH_SHA1_KDF = CERTENROLL_OBJECTID._DH_SINGLE_PASS_STDDH_SHA1_KDF;
pub const XCN_OID_DH_SINGLE_PASS_STDDH_SHA256_KDF = CERTENROLL_OBJECTID._DH_SINGLE_PASS_STDDH_SHA256_KDF;
pub const XCN_OID_DH_SINGLE_PASS_STDDH_SHA384_KDF = CERTENROLL_OBJECTID._DH_SINGLE_PASS_STDDH_SHA384_KDF;
pub const XCN_OID_DISALLOWED_HASH = CERTENROLL_OBJECTID._DISALLOWED_HASH;
pub const XCN_OID_DISALLOWED_LIST = CERTENROLL_OBJECTID._DISALLOWED_LIST;
pub const XCN_OID_ECC_CURVE_P256 = CERTENROLL_OBJECTID._ECC_CURVE_P256;
pub const XCN_OID_ECC_CURVE_P384 = CERTENROLL_OBJECTID._ECC_CURVE_P384;
pub const XCN_OID_ECC_CURVE_P521 = CERTENROLL_OBJECTID._ECC_CURVE_P521;
pub const XCN_OID_ECDSA_SHA256 = CERTENROLL_OBJECTID._ECDSA_SHA256;
pub const XCN_OID_ECDSA_SHA384 = CERTENROLL_OBJECTID._ECDSA_SHA384;
pub const XCN_OID_ECDSA_SHA512 = CERTENROLL_OBJECTID._ECDSA_SHA512;
pub const XCN_OID_ENROLL_CAXCHGCERT_HASH = CERTENROLL_OBJECTID._ENROLL_CAXCHGCERT_HASH;
pub const XCN_OID_ENROLL_EK_INFO = CERTENROLL_OBJECTID._ENROLL_EK_INFO;
pub const XCN_OID_ENROLL_EKPUB_CHALLENGE = CERTENROLL_OBJECTID._ENROLL_EKPUB_CHALLENGE;
pub const XCN_OID_ENROLL_EKVERIFYCERT = CERTENROLL_OBJECTID._ENROLL_EKVERIFYCERT;
pub const XCN_OID_ENROLL_EKVERIFYCREDS = CERTENROLL_OBJECTID._ENROLL_EKVERIFYCREDS;
pub const XCN_OID_ENROLL_EKVERIFYKEY = CERTENROLL_OBJECTID._ENROLL_EKVERIFYKEY;
pub const XCN_OID_EV_RDN_COUNTRY = CERTENROLL_OBJECTID._EV_RDN_COUNTRY;
pub const XCN_OID_EV_RDN_LOCALE = CERTENROLL_OBJECTID._EV_RDN_LOCALE;
pub const XCN_OID_EV_RDN_STATE_OR_PROVINCE = CERTENROLL_OBJECTID._EV_RDN_STATE_OR_PROVINCE;
pub const XCN_OID_INHIBIT_ANY_POLICY = CERTENROLL_OBJECTID._INHIBIT_ANY_POLICY;
pub const XCN_OID_INTERNATIONALIZED_EMAIL_ADDRESS = CERTENROLL_OBJECTID._INTERNATIONALIZED_EMAIL_ADDRESS;
pub const XCN_OID_KP_KERNEL_MODE_CODE_SIGNING = CERTENROLL_OBJECTID._KP_KERNEL_MODE_CODE_SIGNING;
pub const XCN_OID_KP_KERNEL_MODE_HAL_EXTENSION_SIGNING = CERTENROLL_OBJECTID._KP_KERNEL_MODE_HAL_EXTENSION_SIGNING;
pub const XCN_OID_KP_KERNEL_MODE_TRUSTED_BOOT_SIGNING = CERTENROLL_OBJECTID._KP_KERNEL_MODE_TRUSTED_BOOT_SIGNING;
pub const XCN_OID_KP_TPM_AIK_CERTIFICATE = CERTENROLL_OBJECTID._KP_TPM_AIK_CERTIFICATE;
pub const XCN_OID_KP_TPM_EK_CERTIFICATE = CERTENROLL_OBJECTID._KP_TPM_EK_CERTIFICATE;
pub const XCN_OID_KP_TPM_PLATFORM_CERTIFICATE = CERTENROLL_OBJECTID._KP_TPM_PLATFORM_CERTIFICATE;
pub const XCN_OID_NIST_AES128_CBC = CERTENROLL_OBJECTID._NIST_AES128_CBC;
pub const XCN_OID_NIST_AES128_WRAP = CERTENROLL_OBJECTID._NIST_AES128_WRAP;
pub const XCN_OID_NIST_AES192_CBC = CERTENROLL_OBJECTID._NIST_AES192_CBC;
pub const XCN_OID_NIST_AES192_WRAP = CERTENROLL_OBJECTID._NIST_AES192_WRAP;
pub const XCN_OID_NIST_AES256_CBC = CERTENROLL_OBJECTID._NIST_AES256_CBC;
pub const XCN_OID_NIST_AES256_WRAP = CERTENROLL_OBJECTID._NIST_AES256_WRAP;
pub const XCN_OID_PKCS_12_PbeIds = CERTENROLL_OBJECTID._PKCS_12_PbeIds;
pub const XCN_OID_PKCS_12_pbeWithSHA1And128BitRC2 = CERTENROLL_OBJECTID._PKCS_12_pbeWithSHA1And128BitRC2;
pub const XCN_OID_PKCS_12_pbeWithSHA1And128BitRC4 = CERTENROLL_OBJECTID._PKCS_12_pbeWithSHA1And128BitRC4;
pub const XCN_OID_PKCS_12_pbeWithSHA1And2KeyTripleDES = CERTENROLL_OBJECTID._PKCS_12_pbeWithSHA1And2KeyTripleDES;
pub const XCN_OID_PKCS_12_pbeWithSHA1And3KeyTripleDES = CERTENROLL_OBJECTID._PKCS_12_pbeWithSHA1And3KeyTripleDES;
pub const XCN_OID_PKCS_12_pbeWithSHA1And40BitRC2 = CERTENROLL_OBJECTID._PKCS_12_pbeWithSHA1And40BitRC2;
pub const XCN_OID_PKCS_12_pbeWithSHA1And40BitRC4 = CERTENROLL_OBJECTID._PKCS_12_pbeWithSHA1And40BitRC4;
pub const XCN_OID_PKCS_12_PROTECTED_PASSWORD_SECRET_BAG_TYPE_ID = CERTENROLL_OBJECTID._PKCS_12_PROTECTED_PASSWORD_SECRET_BAG_TYPE_ID;
pub const XCN_OID_PKINIT_KP_KDC = CERTENROLL_OBJECTID._PKINIT_KP_KDC;
pub const XCN_OID_PKIX_CA_REPOSITORY = CERTENROLL_OBJECTID._PKIX_CA_REPOSITORY;
pub const XCN_OID_PKIX_OCSP_NONCE = CERTENROLL_OBJECTID._PKIX_OCSP_NONCE;
pub const XCN_OID_PKIX_TIME_STAMPING = CERTENROLL_OBJECTID._PKIX_TIME_STAMPING;
pub const XCN_OID_QC_EU_COMPLIANCE = CERTENROLL_OBJECTID._QC_EU_COMPLIANCE;
pub const XCN_OID_QC_SSCD = CERTENROLL_OBJECTID._QC_SSCD;
pub const XCN_OID_QC_STATEMENTS_EXT = CERTENROLL_OBJECTID._QC_STATEMENTS_EXT;
pub const XCN_OID_RDN_TPM_MANUFACTURER = CERTENROLL_OBJECTID._RDN_TPM_MANUFACTURER;
pub const XCN_OID_RDN_TPM_MODEL = CERTENROLL_OBJECTID._RDN_TPM_MODEL;
pub const XCN_OID_RDN_TPM_VERSION = CERTENROLL_OBJECTID._RDN_TPM_VERSION;
pub const XCN_OID_REVOKED_LIST_SIGNER = CERTENROLL_OBJECTID._REVOKED_LIST_SIGNER;
pub const XCN_OID_RFC3161_counterSign = CERTENROLL_OBJECTID._RFC3161_counterSign;
pub const XCN_OID_ROOT_PROGRAM_AUTO_UPDATE_CA_REVOCATION = CERTENROLL_OBJECTID._ROOT_PROGRAM_AUTO_UPDATE_CA_REVOCATION;
pub const XCN_OID_ROOT_PROGRAM_AUTO_UPDATE_END_REVOCATION = CERTENROLL_OBJECTID._ROOT_PROGRAM_AUTO_UPDATE_END_REVOCATION;
pub const XCN_OID_ROOT_PROGRAM_FLAGS = CERTENROLL_OBJECTID._ROOT_PROGRAM_FLAGS;
pub const XCN_OID_ROOT_PROGRAM_NO_OCSP_FAILOVER_TO_CRL = CERTENROLL_OBJECTID._ROOT_PROGRAM_NO_OCSP_FAILOVER_TO_CRL;
pub const XCN_OID_RSA_PSPECIFIED = CERTENROLL_OBJECTID._RSA_PSPECIFIED;
pub const XCN_OID_RSAES_OAEP = CERTENROLL_OBJECTID._RSAES_OAEP;
pub const XCN_OID_SUBJECT_INFO_ACCESS = CERTENROLL_OBJECTID._SUBJECT_INFO_ACCESS;
pub const XCN_OID_TIMESTAMP_TOKEN = CERTENROLL_OBJECTID._TIMESTAMP_TOKEN;
pub const XCN_OID_ENROLL_SCEP_ERROR = CERTENROLL_OBJECTID._ENROLL_SCEP_ERROR;
pub const XCN_OIDVerisign_MessageType = CERTENROLL_OBJECTID.Verisign_MessageType;
pub const XCN_OIDVerisign_PkiStatus = CERTENROLL_OBJECTID.Verisign_PkiStatus;
pub const XCN_OIDVerisign_FailInfo = CERTENROLL_OBJECTID.Verisign_FailInfo;
pub const XCN_OIDVerisign_SenderNonce = CERTENROLL_OBJECTID.Verisign_SenderNonce;
pub const XCN_OIDVerisign_RecipientNonce = CERTENROLL_OBJECTID.Verisign_RecipientNonce;
pub const XCN_OIDVerisign_TransactionID = CERTENROLL_OBJECTID.Verisign_TransactionID;
pub const XCN_OID_ENROLL_ATTESTATION_CHALLENGE = CERTENROLL_OBJECTID._ENROLL_ATTESTATION_CHALLENGE;
pub const XCN_OID_ENROLL_ATTESTATION_STATEMENT = CERTENROLL_OBJECTID._ENROLL_ATTESTATION_STATEMENT;
pub const XCN_OID_ENROLL_ENCRYPTION_ALGORITHM = CERTENROLL_OBJECTID._ENROLL_ENCRYPTION_ALGORITHM;
pub const XCN_OID_ENROLL_KSP_NAME = CERTENROLL_OBJECTID._ENROLL_KSP_NAME;
pub const WebSecurityLevel = enum(i32) {
Unsafe = 0,
Safe = 1,
};
pub const LevelUnsafe = WebSecurityLevel.Unsafe;
pub const LevelSafe = WebSecurityLevel.Safe;
pub const EncodingType = enum(i32) {
BASE64HEADER = 0,
BASE64 = 1,
BINARY = 2,
BASE64REQUESTHEADER = 3,
HEX = 4,
HEXASCII = 5,
BASE64_ANY = 6,
ANY = 7,
HEX_ANY = 8,
BASE64X509CRLHEADER = 9,
HEXADDR = 10,
HEXASCIIADDR = 11,
HEXRAW = 12,
BASE64URI = 13,
ENCODEMASK = 255,
CHAIN = 256,
TEXT = 512,
PERCENTESCAPE = 134217728,
HASHDATA = 268435456,
STRICT = 536870912,
NOCRLF = 1073741824,
NOCR = -2147483648,
};
pub const XCN_CRYPT_STRING_BASE64HEADER = EncodingType.BASE64HEADER;
pub const XCN_CRYPT_STRING_BASE64 = EncodingType.BASE64;
pub const XCN_CRYPT_STRING_BINARY = EncodingType.BINARY;
pub const XCN_CRYPT_STRING_BASE64REQUESTHEADER = EncodingType.BASE64REQUESTHEADER;
pub const XCN_CRYPT_STRING_HEX = EncodingType.HEX;
pub const XCN_CRYPT_STRING_HEXASCII = EncodingType.HEXASCII;
pub const XCN_CRYPT_STRING_BASE64_ANY = EncodingType.BASE64_ANY;
pub const XCN_CRYPT_STRING_ANY = EncodingType.ANY;
pub const XCN_CRYPT_STRING_HEX_ANY = EncodingType.HEX_ANY;
pub const XCN_CRYPT_STRING_BASE64X509CRLHEADER = EncodingType.BASE64X509CRLHEADER;
pub const XCN_CRYPT_STRING_HEXADDR = EncodingType.HEXADDR;
pub const XCN_CRYPT_STRING_HEXASCIIADDR = EncodingType.HEXASCIIADDR;
pub const XCN_CRYPT_STRING_HEXRAW = EncodingType.HEXRAW;
pub const XCN_CRYPT_STRING_BASE64URI = EncodingType.BASE64URI;
pub const XCN_CRYPT_STRING_ENCODEMASK = EncodingType.ENCODEMASK;
pub const XCN_CRYPT_STRING_CHAIN = EncodingType.CHAIN;
pub const XCN_CRYPT_STRING_TEXT = EncodingType.TEXT;
pub const XCN_CRYPT_STRING_PERCENTESCAPE = EncodingType.PERCENTESCAPE;
pub const XCN_CRYPT_STRING_HASHDATA = EncodingType.HASHDATA;
pub const XCN_CRYPT_STRING_STRICT = EncodingType.STRICT;
pub const XCN_CRYPT_STRING_NOCRLF = EncodingType.NOCRLF;
pub const XCN_CRYPT_STRING_NOCR = EncodingType.NOCR;
pub const PFXExportOptions = enum(i32) {
EEOnly = 0,
ChainNoRoot = 1,
ChainWithRoot = 2,
};
pub const PFXExportEEOnly = PFXExportOptions.EEOnly;
pub const PFXExportChainNoRoot = PFXExportOptions.ChainNoRoot;
pub const PFXExportChainWithRoot = PFXExportOptions.ChainWithRoot;
pub const ObjectIdGroupId = enum(i32) {
ANY_GROUP_ID = 0,
HASH_ALG_OID_GROUP_ID = 1,
ENCRYPT_ALG_OID_GROUP_ID = 2,
PUBKEY_ALG_OID_GROUP_ID = 3,
SIGN_ALG_OID_GROUP_ID = 4,
RDN_ATTR_OID_GROUP_ID = 5,
EXT_OR_ATTR_OID_GROUP_ID = 6,
ENHKEY_USAGE_OID_GROUP_ID = 7,
POLICY_OID_GROUP_ID = 8,
TEMPLATE_OID_GROUP_ID = 9,
KDF_OID_GROUP_ID = 10,
// LAST_OID_GROUP_ID = 10, this enum value conflicts with KDF_OID_GROUP_ID
// FIRST_ALG_OID_GROUP_ID = 1, this enum value conflicts with HASH_ALG_OID_GROUP_ID
// LAST_ALG_OID_GROUP_ID = 4, this enum value conflicts with SIGN_ALG_OID_GROUP_ID
GROUP_ID_MASK = 65535,
OID_PREFER_CNG_ALGID_FLAG = 1073741824,
OID_DISABLE_SEARCH_DS_FLAG = -2147483648,
OID_INFO_OID_GROUP_BIT_LEN_MASK = 268369920,
OID_INFO_OID_GROUP_BIT_LEN_SHIFT = 16,
// KEY_LENGTH_MASK = 268369920, this enum value conflicts with OID_INFO_OID_GROUP_BIT_LEN_MASK
};
pub const XCN_CRYPT_ANY_GROUP_ID = ObjectIdGroupId.ANY_GROUP_ID;
pub const XCN_CRYPT_HASH_ALG_OID_GROUP_ID = ObjectIdGroupId.HASH_ALG_OID_GROUP_ID;
pub const XCN_CRYPT_ENCRYPT_ALG_OID_GROUP_ID = ObjectIdGroupId.ENCRYPT_ALG_OID_GROUP_ID;
pub const XCN_CRYPT_PUBKEY_ALG_OID_GROUP_ID = ObjectIdGroupId.PUBKEY_ALG_OID_GROUP_ID;
pub const XCN_CRYPT_SIGN_ALG_OID_GROUP_ID = ObjectIdGroupId.SIGN_ALG_OID_GROUP_ID;
pub const XCN_CRYPT_RDN_ATTR_OID_GROUP_ID = ObjectIdGroupId.RDN_ATTR_OID_GROUP_ID;
pub const XCN_CRYPT_EXT_OR_ATTR_OID_GROUP_ID = ObjectIdGroupId.EXT_OR_ATTR_OID_GROUP_ID;
pub const XCN_CRYPT_ENHKEY_USAGE_OID_GROUP_ID = ObjectIdGroupId.ENHKEY_USAGE_OID_GROUP_ID;
pub const XCN_CRYPT_POLICY_OID_GROUP_ID = ObjectIdGroupId.POLICY_OID_GROUP_ID;
pub const XCN_CRYPT_TEMPLATE_OID_GROUP_ID = ObjectIdGroupId.TEMPLATE_OID_GROUP_ID;
pub const XCN_CRYPT_KDF_OID_GROUP_ID = ObjectIdGroupId.KDF_OID_GROUP_ID;
pub const XCN_CRYPT_LAST_OID_GROUP_ID = ObjectIdGroupId.KDF_OID_GROUP_ID;
pub const XCN_CRYPT_FIRST_ALG_OID_GROUP_ID = ObjectIdGroupId.HASH_ALG_OID_GROUP_ID;
pub const XCN_CRYPT_LAST_ALG_OID_GROUP_ID = ObjectIdGroupId.SIGN_ALG_OID_GROUP_ID;
pub const XCN_CRYPT_GROUP_ID_MASK = ObjectIdGroupId.GROUP_ID_MASK;
pub const XCN_CRYPT_OID_PREFER_CNG_ALGID_FLAG = ObjectIdGroupId.OID_PREFER_CNG_ALGID_FLAG;
pub const XCN_CRYPT_OID_DISABLE_SEARCH_DS_FLAG = ObjectIdGroupId.OID_DISABLE_SEARCH_DS_FLAG;
pub const XCN_CRYPT_OID_INFO_OID_GROUP_BIT_LEN_MASK = ObjectIdGroupId.OID_INFO_OID_GROUP_BIT_LEN_MASK;
pub const XCN_CRYPT_OID_INFO_OID_GROUP_BIT_LEN_SHIFT = ObjectIdGroupId.OID_INFO_OID_GROUP_BIT_LEN_SHIFT;
pub const XCN_CRYPT_KEY_LENGTH_MASK = ObjectIdGroupId.OID_INFO_OID_GROUP_BIT_LEN_MASK;
pub const ObjectIdPublicKeyFlags = enum(i32) {
ANY = 0,
SIGN_KEY_FLAG = -2147483648,
ENCRYPT_KEY_FLAG = 1073741824,
};
pub const XCN_CRYPT_OID_INFO_PUBKEY_ANY = ObjectIdPublicKeyFlags.ANY;
pub const XCN_CRYPT_OID_INFO_PUBKEY_SIGN_KEY_FLAG = ObjectIdPublicKeyFlags.SIGN_KEY_FLAG;
pub const XCN_CRYPT_OID_INFO_PUBKEY_ENCRYPT_KEY_FLAG = ObjectIdPublicKeyFlags.ENCRYPT_KEY_FLAG;
pub const AlgorithmFlags = enum(i32) {
None = 0,
Wrap = 1,
};
pub const AlgorithmFlagsNone = AlgorithmFlags.None;
pub const AlgorithmFlagsWrap = AlgorithmFlags.Wrap;
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IObjectId_Value = @import("../../zig.zig").Guid.initString("728ab300-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IObjectId = &IID_IObjectId_Value;
pub const IObjectId = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
InitializeFromName: fn(
self: *const IObjectId,
Name: CERTENROLL_OBJECTID,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromValue: fn(
self: *const IObjectId,
strValue: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromAlgorithmName: fn(
self: *const IObjectId,
GroupId: ObjectIdGroupId,
KeyFlags: ObjectIdPublicKeyFlags,
AlgFlags: AlgorithmFlags,
strAlgorithmName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Name: fn(
self: *const IObjectId,
pValue: ?*CERTENROLL_OBJECTID,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_FriendlyName: fn(
self: *const IObjectId,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_FriendlyName: fn(
self: *const IObjectId,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Value: fn(
self: *const IObjectId,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetAlgorithmName: fn(
self: *const IObjectId,
GroupId: ObjectIdGroupId,
KeyFlags: ObjectIdPublicKeyFlags,
pstrAlgorithmName: ?*?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 IObjectId_InitializeFromName(self: *const T, Name: CERTENROLL_OBJECTID) callconv(.Inline) HRESULT {
return @ptrCast(*const IObjectId.VTable, self.vtable).InitializeFromName(@ptrCast(*const IObjectId, self), Name);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IObjectId_InitializeFromValue(self: *const T, strValue: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IObjectId.VTable, self.vtable).InitializeFromValue(@ptrCast(*const IObjectId, self), strValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IObjectId_InitializeFromAlgorithmName(self: *const T, GroupId: ObjectIdGroupId, KeyFlags: ObjectIdPublicKeyFlags, AlgFlags: AlgorithmFlags, strAlgorithmName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IObjectId.VTable, self.vtable).InitializeFromAlgorithmName(@ptrCast(*const IObjectId, self), GroupId, KeyFlags, AlgFlags, strAlgorithmName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IObjectId_get_Name(self: *const T, pValue: ?*CERTENROLL_OBJECTID) callconv(.Inline) HRESULT {
return @ptrCast(*const IObjectId.VTable, self.vtable).get_Name(@ptrCast(*const IObjectId, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IObjectId_get_FriendlyName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IObjectId.VTable, self.vtable).get_FriendlyName(@ptrCast(*const IObjectId, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IObjectId_put_FriendlyName(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IObjectId.VTable, self.vtable).put_FriendlyName(@ptrCast(*const IObjectId, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IObjectId_get_Value(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IObjectId.VTable, self.vtable).get_Value(@ptrCast(*const IObjectId, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IObjectId_GetAlgorithmName(self: *const T, GroupId: ObjectIdGroupId, KeyFlags: ObjectIdPublicKeyFlags, pstrAlgorithmName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IObjectId.VTable, self.vtable).GetAlgorithmName(@ptrCast(*const IObjectId, self), GroupId, KeyFlags, pstrAlgorithmName);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IObjectIds_Value = @import("../../zig.zig").Guid.initString("728ab301-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IObjectIds = &IID_IObjectIds_Value;
pub const IObjectIds = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByIndex: fn(
self: *const IObjectIds,
Index: i32,
pVal: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const IObjectIds,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const IObjectIds,
pVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const IObjectIds,
pVal: ?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Remove: fn(
self: *const IObjectIds,
Index: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clear: fn(
self: *const IObjectIds,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddRange: fn(
self: *const IObjectIds,
pValue: ?*IObjectIds,
) 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 IObjectIds_get_ItemByIndex(self: *const T, Index: i32, pVal: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IObjectIds.VTable, self.vtable).get_ItemByIndex(@ptrCast(*const IObjectIds, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IObjectIds_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IObjectIds.VTable, self.vtable).get_Count(@ptrCast(*const IObjectIds, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IObjectIds_get__NewEnum(self: *const T, pVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const IObjectIds.VTable, self.vtable).get__NewEnum(@ptrCast(*const IObjectIds, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IObjectIds_Add(self: *const T, pVal: ?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IObjectIds.VTable, self.vtable).Add(@ptrCast(*const IObjectIds, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IObjectIds_Remove(self: *const T, Index: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IObjectIds.VTable, self.vtable).Remove(@ptrCast(*const IObjectIds, self), Index);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IObjectIds_Clear(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IObjectIds.VTable, self.vtable).Clear(@ptrCast(*const IObjectIds, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IObjectIds_AddRange(self: *const T, pValue: ?*IObjectIds) callconv(.Inline) HRESULT {
return @ptrCast(*const IObjectIds.VTable, self.vtable).AddRange(@ptrCast(*const IObjectIds, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IBinaryConverter_Value = @import("../../zig.zig").Guid.initString("728ab302-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IBinaryConverter = &IID_IBinaryConverter_Value;
pub const IBinaryConverter = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
StringToString: fn(
self: *const IBinaryConverter,
strEncodedIn: ?BSTR,
EncodingIn: EncodingType,
Encoding: EncodingType,
pstrEncoded: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
VariantByteArrayToString: fn(
self: *const IBinaryConverter,
pvarByteArray: ?*VARIANT,
Encoding: EncodingType,
pstrEncoded: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
StringToVariantByteArray: fn(
self: *const IBinaryConverter,
strEncoded: ?BSTR,
Encoding: EncodingType,
pvarByteArray: ?*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 IBinaryConverter_StringToString(self: *const T, strEncodedIn: ?BSTR, EncodingIn: EncodingType, Encoding: EncodingType, pstrEncoded: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IBinaryConverter.VTable, self.vtable).StringToString(@ptrCast(*const IBinaryConverter, self), strEncodedIn, EncodingIn, Encoding, pstrEncoded);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IBinaryConverter_VariantByteArrayToString(self: *const T, pvarByteArray: ?*VARIANT, Encoding: EncodingType, pstrEncoded: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IBinaryConverter.VTable, self.vtable).VariantByteArrayToString(@ptrCast(*const IBinaryConverter, self), pvarByteArray, Encoding, pstrEncoded);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IBinaryConverter_StringToVariantByteArray(self: *const T, strEncoded: ?BSTR, Encoding: EncodingType, pvarByteArray: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IBinaryConverter.VTable, self.vtable).StringToVariantByteArray(@ptrCast(*const IBinaryConverter, self), strEncoded, Encoding, pvarByteArray);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IBinaryConverter2_Value = @import("../../zig.zig").Guid.initString("8d7928b4-4e17-428d-9a17-728df00d1b2b");
pub const IID_IBinaryConverter2 = &IID_IBinaryConverter2_Value;
pub const IBinaryConverter2 = extern struct {
pub const VTable = extern struct {
base: IBinaryConverter.VTable,
StringArrayToVariantArray: fn(
self: *const IBinaryConverter2,
pvarStringArray: ?*VARIANT,
pvarVariantArray: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
VariantArrayToStringArray: fn(
self: *const IBinaryConverter2,
pvarVariantArray: ?*VARIANT,
pvarStringArray: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IBinaryConverter.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IBinaryConverter2_StringArrayToVariantArray(self: *const T, pvarStringArray: ?*VARIANT, pvarVariantArray: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IBinaryConverter2.VTable, self.vtable).StringArrayToVariantArray(@ptrCast(*const IBinaryConverter2, self), pvarStringArray, pvarVariantArray);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IBinaryConverter2_VariantArrayToStringArray(self: *const T, pvarVariantArray: ?*VARIANT, pvarStringArray: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IBinaryConverter2.VTable, self.vtable).VariantArrayToStringArray(@ptrCast(*const IBinaryConverter2, self), pvarVariantArray, pvarStringArray);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const X500NameFlags = enum(i32) {
NAME_STR_NONE = 0,
SIMPLE_NAME_STR = 1,
OID_NAME_STR = 2,
X500_NAME_STR = 3,
XML_NAME_STR = 4,
NAME_STR_SEMICOLON_FLAG = 1073741824,
NAME_STR_NO_PLUS_FLAG = 536870912,
NAME_STR_NO_QUOTING_FLAG = 268435456,
NAME_STR_CRLF_FLAG = 134217728,
NAME_STR_COMMA_FLAG = 67108864,
NAME_STR_REVERSE_FLAG = 33554432,
NAME_STR_FORWARD_FLAG = 16777216,
NAME_STR_AMBIGUOUS_SEPARATOR_FLAGS = 1275068416,
NAME_STR_DISABLE_IE4_UTF8_FLAG = 65536,
NAME_STR_ENABLE_T61_UNICODE_FLAG = 131072,
NAME_STR_ENABLE_UTF8_UNICODE_FLAG = 262144,
NAME_STR_FORCE_UTF8_DIR_STR_FLAG = 524288,
NAME_STR_DISABLE_UTF8_DIR_STR_FLAG = 1048576,
NAME_STR_ENABLE_PUNYCODE_FLAG = 2097152,
NAME_STR_DS_ESCAPED = 8388608,
};
pub const XCN_CERT_NAME_STR_NONE = X500NameFlags.NAME_STR_NONE;
pub const XCN_CERT_SIMPLE_NAME_STR = X500NameFlags.SIMPLE_NAME_STR;
pub const XCN_CERT_OID_NAME_STR = X500NameFlags.OID_NAME_STR;
pub const XCN_CERT_X500_NAME_STR = X500NameFlags.X500_NAME_STR;
pub const XCN_CERT_XML_NAME_STR = X500NameFlags.XML_NAME_STR;
pub const XCN_CERT_NAME_STR_SEMICOLON_FLAG = X500NameFlags.NAME_STR_SEMICOLON_FLAG;
pub const XCN_CERT_NAME_STR_NO_PLUS_FLAG = X500NameFlags.NAME_STR_NO_PLUS_FLAG;
pub const XCN_CERT_NAME_STR_NO_QUOTING_FLAG = X500NameFlags.NAME_STR_NO_QUOTING_FLAG;
pub const XCN_CERT_NAME_STR_CRLF_FLAG = X500NameFlags.NAME_STR_CRLF_FLAG;
pub const XCN_CERT_NAME_STR_COMMA_FLAG = X500NameFlags.NAME_STR_COMMA_FLAG;
pub const XCN_CERT_NAME_STR_REVERSE_FLAG = X500NameFlags.NAME_STR_REVERSE_FLAG;
pub const XCN_CERT_NAME_STR_FORWARD_FLAG = X500NameFlags.NAME_STR_FORWARD_FLAG;
pub const XCN_CERT_NAME_STR_AMBIGUOUS_SEPARATOR_FLAGS = X500NameFlags.NAME_STR_AMBIGUOUS_SEPARATOR_FLAGS;
pub const XCN_CERT_NAME_STR_DISABLE_IE4_UTF8_FLAG = X500NameFlags.NAME_STR_DISABLE_IE4_UTF8_FLAG;
pub const XCN_CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG = X500NameFlags.NAME_STR_ENABLE_T61_UNICODE_FLAG;
pub const XCN_CERT_NAME_STR_ENABLE_UTF8_UNICODE_FLAG = X500NameFlags.NAME_STR_ENABLE_UTF8_UNICODE_FLAG;
pub const XCN_CERT_NAME_STR_FORCE_UTF8_DIR_STR_FLAG = X500NameFlags.NAME_STR_FORCE_UTF8_DIR_STR_FLAG;
pub const XCN_CERT_NAME_STR_DISABLE_UTF8_DIR_STR_FLAG = X500NameFlags.NAME_STR_DISABLE_UTF8_DIR_STR_FLAG;
pub const XCN_CERT_NAME_STR_ENABLE_PUNYCODE_FLAG = X500NameFlags.NAME_STR_ENABLE_PUNYCODE_FLAG;
pub const XCN_CERT_NAME_STR_DS_ESCAPED = X500NameFlags.NAME_STR_DS_ESCAPED;
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX500DistinguishedName_Value = @import("../../zig.zig").Guid.initString("728ab303-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX500DistinguishedName = &IID_IX500DistinguishedName_Value;
pub const IX500DistinguishedName = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Decode: fn(
self: *const IX500DistinguishedName,
strEncodedName: ?BSTR,
Encoding: EncodingType,
NameFlags: X500NameFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Encode: fn(
self: *const IX500DistinguishedName,
strName: ?BSTR,
NameFlags: X500NameFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Name: fn(
self: *const IX500DistinguishedName,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EncodedName: fn(
self: *const IX500DistinguishedName,
Encoding: EncodingType,
pValue: ?*?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 IX500DistinguishedName_Decode(self: *const T, strEncodedName: ?BSTR, Encoding: EncodingType, NameFlags: X500NameFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const IX500DistinguishedName.VTable, self.vtable).Decode(@ptrCast(*const IX500DistinguishedName, self), strEncodedName, Encoding, NameFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX500DistinguishedName_Encode(self: *const T, strName: ?BSTR, NameFlags: X500NameFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const IX500DistinguishedName.VTable, self.vtable).Encode(@ptrCast(*const IX500DistinguishedName, self), strName, NameFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX500DistinguishedName_get_Name(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX500DistinguishedName.VTable, self.vtable).get_Name(@ptrCast(*const IX500DistinguishedName, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX500DistinguishedName_get_EncodedName(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX500DistinguishedName.VTable, self.vtable).get_EncodedName(@ptrCast(*const IX500DistinguishedName, self), Encoding, pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const X509CertificateEnrollmentContext = enum(i32) {
None = 0,
User = 1,
Machine = 2,
AdministratorForceMachine = 3,
};
pub const ContextNone = X509CertificateEnrollmentContext.None;
pub const ContextUser = X509CertificateEnrollmentContext.User;
pub const ContextMachine = X509CertificateEnrollmentContext.Machine;
pub const ContextAdministratorForceMachine = X509CertificateEnrollmentContext.AdministratorForceMachine;
pub const EnrollmentEnrollStatus = enum(i32) {
ed = 1,
Pended = 2,
UIDeferredEnrollmentRequired = 4,
Error = 16,
Unknown = 32,
Skipped = 64,
Denied = 256,
};
pub const Enrolled = EnrollmentEnrollStatus.ed;
pub const EnrollPended = EnrollmentEnrollStatus.Pended;
pub const EnrollUIDeferredEnrollmentRequired = EnrollmentEnrollStatus.UIDeferredEnrollmentRequired;
pub const EnrollError = EnrollmentEnrollStatus.Error;
pub const EnrollUnknown = EnrollmentEnrollStatus.Unknown;
pub const EnrollSkipped = EnrollmentEnrollStatus.Skipped;
pub const EnrollDenied = EnrollmentEnrollStatus.Denied;
pub const EnrollmentSelectionStatus = enum(i32) {
No = 0,
Yes = 1,
};
pub const SelectedNo = EnrollmentSelectionStatus.No;
pub const SelectedYes = EnrollmentSelectionStatus.Yes;
pub const EnrollmentDisplayStatus = enum(i32) {
No = 0,
Yes = 1,
};
pub const DisplayNo = EnrollmentDisplayStatus.No;
pub const DisplayYes = EnrollmentDisplayStatus.Yes;
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509EnrollmentStatus_Value = @import("../../zig.zig").Guid.initString("728ab304-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509EnrollmentStatus = &IID_IX509EnrollmentStatus_Value;
pub const IX509EnrollmentStatus = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
AppendText: fn(
self: *const IX509EnrollmentStatus,
strText: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Text: fn(
self: *const IX509EnrollmentStatus,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Text: fn(
self: *const IX509EnrollmentStatus,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Selected: fn(
self: *const IX509EnrollmentStatus,
pValue: ?*EnrollmentSelectionStatus,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Selected: fn(
self: *const IX509EnrollmentStatus,
Value: EnrollmentSelectionStatus,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Display: fn(
self: *const IX509EnrollmentStatus,
pValue: ?*EnrollmentDisplayStatus,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Display: fn(
self: *const IX509EnrollmentStatus,
Value: EnrollmentDisplayStatus,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Status: fn(
self: *const IX509EnrollmentStatus,
pValue: ?*EnrollmentEnrollStatus,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Status: fn(
self: *const IX509EnrollmentStatus,
Value: EnrollmentEnrollStatus,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Error: fn(
self: *const IX509EnrollmentStatus,
pValue: ?*HRESULT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Error: fn(
self: *const IX509EnrollmentStatus,
Value: HRESULT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ErrorText: fn(
self: *const IX509EnrollmentStatus,
pValue: ?*?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 IX509EnrollmentStatus_AppendText(self: *const T, strText: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentStatus.VTable, self.vtable).AppendText(@ptrCast(*const IX509EnrollmentStatus, self), strText);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentStatus_get_Text(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentStatus.VTable, self.vtable).get_Text(@ptrCast(*const IX509EnrollmentStatus, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentStatus_put_Text(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentStatus.VTable, self.vtable).put_Text(@ptrCast(*const IX509EnrollmentStatus, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentStatus_get_Selected(self: *const T, pValue: ?*EnrollmentSelectionStatus) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentStatus.VTable, self.vtable).get_Selected(@ptrCast(*const IX509EnrollmentStatus, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentStatus_put_Selected(self: *const T, Value: EnrollmentSelectionStatus) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentStatus.VTable, self.vtable).put_Selected(@ptrCast(*const IX509EnrollmentStatus, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentStatus_get_Display(self: *const T, pValue: ?*EnrollmentDisplayStatus) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentStatus.VTable, self.vtable).get_Display(@ptrCast(*const IX509EnrollmentStatus, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentStatus_put_Display(self: *const T, Value: EnrollmentDisplayStatus) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentStatus.VTable, self.vtable).put_Display(@ptrCast(*const IX509EnrollmentStatus, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentStatus_get_Status(self: *const T, pValue: ?*EnrollmentEnrollStatus) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentStatus.VTable, self.vtable).get_Status(@ptrCast(*const IX509EnrollmentStatus, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentStatus_put_Status(self: *const T, Value: EnrollmentEnrollStatus) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentStatus.VTable, self.vtable).put_Status(@ptrCast(*const IX509EnrollmentStatus, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentStatus_get_Error(self: *const T, pValue: ?*HRESULT) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentStatus.VTable, self.vtable).get_Error(@ptrCast(*const IX509EnrollmentStatus, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentStatus_put_Error(self: *const T, Value: HRESULT) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentStatus.VTable, self.vtable).put_Error(@ptrCast(*const IX509EnrollmentStatus, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentStatus_get_ErrorText(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentStatus.VTable, self.vtable).get_ErrorText(@ptrCast(*const IX509EnrollmentStatus, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const X509ProviderType = enum(i32) {
NONE = 0,
RSA_FULL = 1,
RSA_SIG = 2,
DSS = 3,
FORTEZZA = 4,
MS_EXCHANGE = 5,
SSL = 6,
RSA_SCHANNEL = 12,
DSS_DH = 13,
EC_ECDSA_SIG = 14,
EC_ECNRA_SIG = 15,
EC_ECDSA_FULL = 16,
EC_ECNRA_FULL = 17,
DH_SCHANNEL = 18,
SPYRUS_LYNKS = 20,
RNG = 21,
INTEL_SEC = 22,
REPLACE_OWF = 23,
RSA_AES = 24,
};
pub const XCN_PROV_NONE = X509ProviderType.NONE;
pub const XCN_PROV_RSA_FULL = X509ProviderType.RSA_FULL;
pub const XCN_PROV_RSA_SIG = X509ProviderType.RSA_SIG;
pub const XCN_PROV_DSS = X509ProviderType.DSS;
pub const XCN_PROV_FORTEZZA = X509ProviderType.FORTEZZA;
pub const XCN_PROV_MS_EXCHANGE = X509ProviderType.MS_EXCHANGE;
pub const XCN_PROV_SSL = X509ProviderType.SSL;
pub const XCN_PROV_RSA_SCHANNEL = X509ProviderType.RSA_SCHANNEL;
pub const XCN_PROV_DSS_DH = X509ProviderType.DSS_DH;
pub const XCN_PROV_EC_ECDSA_SIG = X509ProviderType.EC_ECDSA_SIG;
pub const XCN_PROV_EC_ECNRA_SIG = X509ProviderType.EC_ECNRA_SIG;
pub const XCN_PROV_EC_ECDSA_FULL = X509ProviderType.EC_ECDSA_FULL;
pub const XCN_PROV_EC_ECNRA_FULL = X509ProviderType.EC_ECNRA_FULL;
pub const XCN_PROV_DH_SCHANNEL = X509ProviderType.DH_SCHANNEL;
pub const XCN_PROV_SPYRUS_LYNKS = X509ProviderType.SPYRUS_LYNKS;
pub const XCN_PROV_RNG = X509ProviderType.RNG;
pub const XCN_PROV_INTEL_SEC = X509ProviderType.INTEL_SEC;
pub const XCN_PROV_REPLACE_OWF = X509ProviderType.REPLACE_OWF;
pub const XCN_PROV_RSA_AES = X509ProviderType.RSA_AES;
pub const AlgorithmType = enum(i32) {
UNKNOWN_INTERFACE = 0,
CIPHER_INTERFACE = 1,
HASH_INTERFACE = 2,
ASYMMETRIC_ENCRYPTION_INTERFACE = 3,
SIGNATURE_INTERFACE = 5,
SECRET_AGREEMENT_INTERFACE = 4,
RNG_INTERFACE = 6,
KEY_DERIVATION_INTERFACE = 7,
};
pub const XCN_BCRYPT_UNKNOWN_INTERFACE = AlgorithmType.UNKNOWN_INTERFACE;
pub const XCN_BCRYPT_CIPHER_INTERFACE = AlgorithmType.CIPHER_INTERFACE;
pub const XCN_BCRYPT_HASH_INTERFACE = AlgorithmType.HASH_INTERFACE;
pub const XCN_BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE = AlgorithmType.ASYMMETRIC_ENCRYPTION_INTERFACE;
pub const XCN_BCRYPT_SIGNATURE_INTERFACE = AlgorithmType.SIGNATURE_INTERFACE;
pub const XCN_BCRYPT_SECRET_AGREEMENT_INTERFACE = AlgorithmType.SECRET_AGREEMENT_INTERFACE;
pub const XCN_BCRYPT_RNG_INTERFACE = AlgorithmType.RNG_INTERFACE;
pub const XCN_BCRYPT_KEY_DERIVATION_INTERFACE = AlgorithmType.KEY_DERIVATION_INTERFACE;
pub const AlgorithmOperationFlags = enum(i32) {
NO_OPERATION = 0,
CIPHER_OPERATION = 1,
HASH_OPERATION = 2,
ASYMMETRIC_ENCRYPTION_OPERATION = 4,
SECRET_AGREEMENT_OPERATION = 8,
SIGNATURE_OPERATION = 16,
RNG_OPERATION = 32,
KEY_DERIVATION_OPERATION = 64,
ANY_ASYMMETRIC_OPERATION = 28,
PREFER_SIGNATURE_ONLY_OPERATION = 2097152,
PREFER_NON_SIGNATURE_OPERATION = 4194304,
EXACT_MATCH_OPERATION = 8388608,
PREFERENCE_MASK_OPERATION = 14680064,
};
pub const XCN_NCRYPT_NO_OPERATION = AlgorithmOperationFlags.NO_OPERATION;
pub const XCN_NCRYPT_CIPHER_OPERATION = AlgorithmOperationFlags.CIPHER_OPERATION;
pub const XCN_NCRYPT_HASH_OPERATION = AlgorithmOperationFlags.HASH_OPERATION;
pub const XCN_NCRYPT_ASYMMETRIC_ENCRYPTION_OPERATION = AlgorithmOperationFlags.ASYMMETRIC_ENCRYPTION_OPERATION;
pub const XCN_NCRYPT_SECRET_AGREEMENT_OPERATION = AlgorithmOperationFlags.SECRET_AGREEMENT_OPERATION;
pub const XCN_NCRYPT_SIGNATURE_OPERATION = AlgorithmOperationFlags.SIGNATURE_OPERATION;
pub const XCN_NCRYPT_RNG_OPERATION = AlgorithmOperationFlags.RNG_OPERATION;
pub const XCN_NCRYPT_KEY_DERIVATION_OPERATION = AlgorithmOperationFlags.KEY_DERIVATION_OPERATION;
pub const XCN_NCRYPT_ANY_ASYMMETRIC_OPERATION = AlgorithmOperationFlags.ANY_ASYMMETRIC_OPERATION;
pub const XCN_NCRYPT_PREFER_SIGNATURE_ONLY_OPERATION = AlgorithmOperationFlags.PREFER_SIGNATURE_ONLY_OPERATION;
pub const XCN_NCRYPT_PREFER_NON_SIGNATURE_OPERATION = AlgorithmOperationFlags.PREFER_NON_SIGNATURE_OPERATION;
pub const XCN_NCRYPT_EXACT_MATCH_OPERATION = AlgorithmOperationFlags.EXACT_MATCH_OPERATION;
pub const XCN_NCRYPT_PREFERENCE_MASK_OPERATION = AlgorithmOperationFlags.PREFERENCE_MASK_OPERATION;
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICspAlgorithm_Value = @import("../../zig.zig").Guid.initString("728ab305-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICspAlgorithm = &IID_ICspAlgorithm_Value;
pub const ICspAlgorithm = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
GetAlgorithmOid: fn(
self: *const ICspAlgorithm,
Length: i32,
AlgFlags: AlgorithmFlags,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DefaultLength: fn(
self: *const ICspAlgorithm,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IncrementLength: fn(
self: *const ICspAlgorithm,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_LongName: fn(
self: *const ICspAlgorithm,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Valid: fn(
self: *const ICspAlgorithm,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MaxLength: fn(
self: *const ICspAlgorithm,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MinLength: fn(
self: *const ICspAlgorithm,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Name: fn(
self: *const ICspAlgorithm,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Type: fn(
self: *const ICspAlgorithm,
pValue: ?*AlgorithmType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Operations: fn(
self: *const ICspAlgorithm,
pValue: ?*AlgorithmOperationFlags,
) 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 ICspAlgorithm_GetAlgorithmOid(self: *const T, Length: i32, AlgFlags: AlgorithmFlags, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspAlgorithm.VTable, self.vtable).GetAlgorithmOid(@ptrCast(*const ICspAlgorithm, self), Length, AlgFlags, ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspAlgorithm_get_DefaultLength(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspAlgorithm.VTable, self.vtable).get_DefaultLength(@ptrCast(*const ICspAlgorithm, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspAlgorithm_get_IncrementLength(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspAlgorithm.VTable, self.vtable).get_IncrementLength(@ptrCast(*const ICspAlgorithm, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspAlgorithm_get_LongName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspAlgorithm.VTable, self.vtable).get_LongName(@ptrCast(*const ICspAlgorithm, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspAlgorithm_get_Valid(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspAlgorithm.VTable, self.vtable).get_Valid(@ptrCast(*const ICspAlgorithm, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspAlgorithm_get_MaxLength(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspAlgorithm.VTable, self.vtable).get_MaxLength(@ptrCast(*const ICspAlgorithm, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspAlgorithm_get_MinLength(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspAlgorithm.VTable, self.vtable).get_MinLength(@ptrCast(*const ICspAlgorithm, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspAlgorithm_get_Name(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspAlgorithm.VTable, self.vtable).get_Name(@ptrCast(*const ICspAlgorithm, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspAlgorithm_get_Type(self: *const T, pValue: ?*AlgorithmType) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspAlgorithm.VTable, self.vtable).get_Type(@ptrCast(*const ICspAlgorithm, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspAlgorithm_get_Operations(self: *const T, pValue: ?*AlgorithmOperationFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspAlgorithm.VTable, self.vtable).get_Operations(@ptrCast(*const ICspAlgorithm, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICspAlgorithms_Value = @import("../../zig.zig").Guid.initString("728ab306-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICspAlgorithms = &IID_ICspAlgorithms_Value;
pub const ICspAlgorithms = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByIndex: fn(
self: *const ICspAlgorithms,
Index: i32,
pVal: ?*?*ICspAlgorithm,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const ICspAlgorithms,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const ICspAlgorithms,
pVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const ICspAlgorithms,
pVal: ?*ICspAlgorithm,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Remove: fn(
self: *const ICspAlgorithms,
Index: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clear: fn(
self: *const ICspAlgorithms,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByName: fn(
self: *const ICspAlgorithms,
strName: ?BSTR,
ppValue: ?*?*ICspAlgorithm,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IndexByObjectId: fn(
self: *const ICspAlgorithms,
pObjectId: ?*IObjectId,
pIndex: ?*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 ICspAlgorithms_get_ItemByIndex(self: *const T, Index: i32, pVal: ?*?*ICspAlgorithm) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspAlgorithms.VTable, self.vtable).get_ItemByIndex(@ptrCast(*const ICspAlgorithms, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspAlgorithms_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspAlgorithms.VTable, self.vtable).get_Count(@ptrCast(*const ICspAlgorithms, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspAlgorithms_get__NewEnum(self: *const T, pVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspAlgorithms.VTable, self.vtable).get__NewEnum(@ptrCast(*const ICspAlgorithms, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspAlgorithms_Add(self: *const T, pVal: ?*ICspAlgorithm) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspAlgorithms.VTable, self.vtable).Add(@ptrCast(*const ICspAlgorithms, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspAlgorithms_Remove(self: *const T, Index: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspAlgorithms.VTable, self.vtable).Remove(@ptrCast(*const ICspAlgorithms, self), Index);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspAlgorithms_Clear(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspAlgorithms.VTable, self.vtable).Clear(@ptrCast(*const ICspAlgorithms, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspAlgorithms_get_ItemByName(self: *const T, strName: ?BSTR, ppValue: ?*?*ICspAlgorithm) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspAlgorithms.VTable, self.vtable).get_ItemByName(@ptrCast(*const ICspAlgorithms, self), strName, ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspAlgorithms_get_IndexByObjectId(self: *const T, pObjectId: ?*IObjectId, pIndex: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspAlgorithms.VTable, self.vtable).get_IndexByObjectId(@ptrCast(*const ICspAlgorithms, self), pObjectId, pIndex);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const X509KeySpec = enum(i32) {
NONE = 0,
KEYEXCHANGE = 1,
SIGNATURE = 2,
};
pub const XCN_AT_NONE = X509KeySpec.NONE;
pub const XCN_AT_KEYEXCHANGE = X509KeySpec.KEYEXCHANGE;
pub const XCN_AT_SIGNATURE = X509KeySpec.SIGNATURE;
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICspInformation_Value = @import("../../zig.zig").Guid.initString("728ab307-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICspInformation = &IID_ICspInformation_Value;
pub const ICspInformation = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
InitializeFromName: fn(
self: *const ICspInformation,
strName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromType: fn(
self: *const ICspInformation,
Type: X509ProviderType,
pAlgorithm: ?*IObjectId,
MachineContext: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CspAlgorithms: fn(
self: *const ICspInformation,
ppValue: ?*?*ICspAlgorithms,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_HasHardwareRandomNumberGenerator: fn(
self: *const ICspInformation,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsHardwareDevice: fn(
self: *const ICspInformation,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsRemovable: fn(
self: *const ICspInformation,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsSoftwareDevice: fn(
self: *const ICspInformation,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Valid: fn(
self: *const ICspInformation,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MaxKeyContainerNameLength: fn(
self: *const ICspInformation,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Name: fn(
self: *const ICspInformation,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Type: fn(
self: *const ICspInformation,
pValue: ?*X509ProviderType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Version: fn(
self: *const ICspInformation,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_KeySpec: fn(
self: *const ICspInformation,
pValue: ?*X509KeySpec,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsSmartCard: fn(
self: *const ICspInformation,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDefaultSecurityDescriptor: fn(
self: *const ICspInformation,
MachineContext: i16,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_LegacyCsp: fn(
self: *const ICspInformation,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCspStatusFromOperations: fn(
self: *const ICspInformation,
pAlgorithm: ?*IObjectId,
Operations: AlgorithmOperationFlags,
ppValue: ?*?*ICspStatus,
) 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 ICspInformation_InitializeFromName(self: *const T, strName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformation.VTable, self.vtable).InitializeFromName(@ptrCast(*const ICspInformation, self), strName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformation_InitializeFromType(self: *const T, Type: X509ProviderType, pAlgorithm: ?*IObjectId, MachineContext: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformation.VTable, self.vtable).InitializeFromType(@ptrCast(*const ICspInformation, self), Type, pAlgorithm, MachineContext);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformation_get_CspAlgorithms(self: *const T, ppValue: ?*?*ICspAlgorithms) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformation.VTable, self.vtable).get_CspAlgorithms(@ptrCast(*const ICspInformation, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformation_get_HasHardwareRandomNumberGenerator(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformation.VTable, self.vtable).get_HasHardwareRandomNumberGenerator(@ptrCast(*const ICspInformation, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformation_get_IsHardwareDevice(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformation.VTable, self.vtable).get_IsHardwareDevice(@ptrCast(*const ICspInformation, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformation_get_IsRemovable(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformation.VTable, self.vtable).get_IsRemovable(@ptrCast(*const ICspInformation, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformation_get_IsSoftwareDevice(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformation.VTable, self.vtable).get_IsSoftwareDevice(@ptrCast(*const ICspInformation, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformation_get_Valid(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformation.VTable, self.vtable).get_Valid(@ptrCast(*const ICspInformation, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformation_get_MaxKeyContainerNameLength(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformation.VTable, self.vtable).get_MaxKeyContainerNameLength(@ptrCast(*const ICspInformation, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformation_get_Name(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformation.VTable, self.vtable).get_Name(@ptrCast(*const ICspInformation, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformation_get_Type(self: *const T, pValue: ?*X509ProviderType) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformation.VTable, self.vtable).get_Type(@ptrCast(*const ICspInformation, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformation_get_Version(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformation.VTable, self.vtable).get_Version(@ptrCast(*const ICspInformation, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformation_get_KeySpec(self: *const T, pValue: ?*X509KeySpec) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformation.VTable, self.vtable).get_KeySpec(@ptrCast(*const ICspInformation, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformation_get_IsSmartCard(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformation.VTable, self.vtable).get_IsSmartCard(@ptrCast(*const ICspInformation, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformation_GetDefaultSecurityDescriptor(self: *const T, MachineContext: i16, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformation.VTable, self.vtable).GetDefaultSecurityDescriptor(@ptrCast(*const ICspInformation, self), MachineContext, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformation_get_LegacyCsp(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformation.VTable, self.vtable).get_LegacyCsp(@ptrCast(*const ICspInformation, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformation_GetCspStatusFromOperations(self: *const T, pAlgorithm: ?*IObjectId, Operations: AlgorithmOperationFlags, ppValue: ?*?*ICspStatus) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformation.VTable, self.vtable).GetCspStatusFromOperations(@ptrCast(*const ICspInformation, self), pAlgorithm, Operations, ppValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICspInformations_Value = @import("../../zig.zig").Guid.initString("728ab308-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICspInformations = &IID_ICspInformations_Value;
pub const ICspInformations = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByIndex: fn(
self: *const ICspInformations,
Index: i32,
pVal: ?*?*ICspInformation,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const ICspInformations,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const ICspInformations,
pVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const ICspInformations,
pVal: ?*ICspInformation,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Remove: fn(
self: *const ICspInformations,
Index: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clear: fn(
self: *const ICspInformations,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddAvailableCsps: fn(
self: *const ICspInformations,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByName: fn(
self: *const ICspInformations,
strName: ?BSTR,
ppCspInformation: ?*?*ICspInformation,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCspStatusFromProviderName: fn(
self: *const ICspInformations,
strProviderName: ?BSTR,
LegacyKeySpec: X509KeySpec,
ppValue: ?*?*ICspStatus,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCspStatusesFromOperations: fn(
self: *const ICspInformations,
Operations: AlgorithmOperationFlags,
pCspInformation: ?*ICspInformation,
ppValue: ?*?*ICspStatuses,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetEncryptionCspAlgorithms: fn(
self: *const ICspInformations,
pCspInformation: ?*ICspInformation,
ppValue: ?*?*ICspAlgorithms,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetHashAlgorithms: fn(
self: *const ICspInformations,
pCspInformation: ?*ICspInformation,
ppValue: ?*?*IObjectIds,
) 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 ICspInformations_get_ItemByIndex(self: *const T, Index: i32, pVal: ?*?*ICspInformation) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformations.VTable, self.vtable).get_ItemByIndex(@ptrCast(*const ICspInformations, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformations_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformations.VTable, self.vtable).get_Count(@ptrCast(*const ICspInformations, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformations_get__NewEnum(self: *const T, pVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformations.VTable, self.vtable).get__NewEnum(@ptrCast(*const ICspInformations, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformations_Add(self: *const T, pVal: ?*ICspInformation) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformations.VTable, self.vtable).Add(@ptrCast(*const ICspInformations, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformations_Remove(self: *const T, Index: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformations.VTable, self.vtable).Remove(@ptrCast(*const ICspInformations, self), Index);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformations_Clear(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformations.VTable, self.vtable).Clear(@ptrCast(*const ICspInformations, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformations_AddAvailableCsps(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformations.VTable, self.vtable).AddAvailableCsps(@ptrCast(*const ICspInformations, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformations_get_ItemByName(self: *const T, strName: ?BSTR, ppCspInformation: ?*?*ICspInformation) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformations.VTable, self.vtable).get_ItemByName(@ptrCast(*const ICspInformations, self), strName, ppCspInformation);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformations_GetCspStatusFromProviderName(self: *const T, strProviderName: ?BSTR, LegacyKeySpec: X509KeySpec, ppValue: ?*?*ICspStatus) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformations.VTable, self.vtable).GetCspStatusFromProviderName(@ptrCast(*const ICspInformations, self), strProviderName, LegacyKeySpec, ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformations_GetCspStatusesFromOperations(self: *const T, Operations: AlgorithmOperationFlags, pCspInformation: ?*ICspInformation, ppValue: ?*?*ICspStatuses) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformations.VTable, self.vtable).GetCspStatusesFromOperations(@ptrCast(*const ICspInformations, self), Operations, pCspInformation, ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformations_GetEncryptionCspAlgorithms(self: *const T, pCspInformation: ?*ICspInformation, ppValue: ?*?*ICspAlgorithms) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformations.VTable, self.vtable).GetEncryptionCspAlgorithms(@ptrCast(*const ICspInformations, self), pCspInformation, ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspInformations_GetHashAlgorithms(self: *const T, pCspInformation: ?*ICspInformation, ppValue: ?*?*IObjectIds) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspInformations.VTable, self.vtable).GetHashAlgorithms(@ptrCast(*const ICspInformations, self), pCspInformation, ppValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICspStatus_Value = @import("../../zig.zig").Guid.initString("728ab309-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICspStatus = &IID_ICspStatus_Value;
pub const ICspStatus = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const ICspStatus,
pCsp: ?*ICspInformation,
pAlgorithm: ?*ICspAlgorithm,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Ordinal: fn(
self: *const ICspStatus,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Ordinal: fn(
self: *const ICspStatus,
Value: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CspAlgorithm: fn(
self: *const ICspStatus,
ppValue: ?*?*ICspAlgorithm,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CspInformation: fn(
self: *const ICspStatus,
ppValue: ?*?*ICspInformation,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EnrollmentStatus: fn(
self: *const ICspStatus,
ppValue: ?*?*IX509EnrollmentStatus,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DisplayName: fn(
self: *const ICspStatus,
pValue: ?*?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 ICspStatus_Initialize(self: *const T, pCsp: ?*ICspInformation, pAlgorithm: ?*ICspAlgorithm) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspStatus.VTable, self.vtable).Initialize(@ptrCast(*const ICspStatus, self), pCsp, pAlgorithm);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspStatus_get_Ordinal(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspStatus.VTable, self.vtable).get_Ordinal(@ptrCast(*const ICspStatus, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspStatus_put_Ordinal(self: *const T, Value: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspStatus.VTable, self.vtable).put_Ordinal(@ptrCast(*const ICspStatus, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspStatus_get_CspAlgorithm(self: *const T, ppValue: ?*?*ICspAlgorithm) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspStatus.VTable, self.vtable).get_CspAlgorithm(@ptrCast(*const ICspStatus, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspStatus_get_CspInformation(self: *const T, ppValue: ?*?*ICspInformation) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspStatus.VTable, self.vtable).get_CspInformation(@ptrCast(*const ICspStatus, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspStatus_get_EnrollmentStatus(self: *const T, ppValue: ?*?*IX509EnrollmentStatus) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspStatus.VTable, self.vtable).get_EnrollmentStatus(@ptrCast(*const ICspStatus, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspStatus_get_DisplayName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspStatus.VTable, self.vtable).get_DisplayName(@ptrCast(*const ICspStatus, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICspStatuses_Value = @import("../../zig.zig").Guid.initString("728ab30a-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICspStatuses = &IID_ICspStatuses_Value;
pub const ICspStatuses = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByIndex: fn(
self: *const ICspStatuses,
Index: i32,
pVal: ?*?*ICspStatus,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const ICspStatuses,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const ICspStatuses,
pVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const ICspStatuses,
pVal: ?*ICspStatus,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Remove: fn(
self: *const ICspStatuses,
Index: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clear: fn(
self: *const ICspStatuses,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByName: fn(
self: *const ICspStatuses,
strCspName: ?BSTR,
strAlgorithmName: ?BSTR,
ppValue: ?*?*ICspStatus,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByOrdinal: fn(
self: *const ICspStatuses,
Ordinal: i32,
ppValue: ?*?*ICspStatus,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByOperations: fn(
self: *const ICspStatuses,
strCspName: ?BSTR,
strAlgorithmName: ?BSTR,
Operations: AlgorithmOperationFlags,
ppValue: ?*?*ICspStatus,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByProvider: fn(
self: *const ICspStatuses,
pCspStatus: ?*ICspStatus,
ppValue: ?*?*ICspStatus,
) 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 ICspStatuses_get_ItemByIndex(self: *const T, Index: i32, pVal: ?*?*ICspStatus) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspStatuses.VTable, self.vtable).get_ItemByIndex(@ptrCast(*const ICspStatuses, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspStatuses_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspStatuses.VTable, self.vtable).get_Count(@ptrCast(*const ICspStatuses, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspStatuses_get__NewEnum(self: *const T, pVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspStatuses.VTable, self.vtable).get__NewEnum(@ptrCast(*const ICspStatuses, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspStatuses_Add(self: *const T, pVal: ?*ICspStatus) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspStatuses.VTable, self.vtable).Add(@ptrCast(*const ICspStatuses, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspStatuses_Remove(self: *const T, Index: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspStatuses.VTable, self.vtable).Remove(@ptrCast(*const ICspStatuses, self), Index);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspStatuses_Clear(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspStatuses.VTable, self.vtable).Clear(@ptrCast(*const ICspStatuses, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspStatuses_get_ItemByName(self: *const T, strCspName: ?BSTR, strAlgorithmName: ?BSTR, ppValue: ?*?*ICspStatus) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspStatuses.VTable, self.vtable).get_ItemByName(@ptrCast(*const ICspStatuses, self), strCspName, strAlgorithmName, ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspStatuses_get_ItemByOrdinal(self: *const T, Ordinal: i32, ppValue: ?*?*ICspStatus) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspStatuses.VTable, self.vtable).get_ItemByOrdinal(@ptrCast(*const ICspStatuses, self), Ordinal, ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspStatuses_get_ItemByOperations(self: *const T, strCspName: ?BSTR, strAlgorithmName: ?BSTR, Operations: AlgorithmOperationFlags, ppValue: ?*?*ICspStatus) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspStatuses.VTable, self.vtable).get_ItemByOperations(@ptrCast(*const ICspStatuses, self), strCspName, strAlgorithmName, Operations, ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICspStatuses_get_ItemByProvider(self: *const T, pCspStatus: ?*ICspStatus, ppValue: ?*?*ICspStatus) callconv(.Inline) HRESULT {
return @ptrCast(*const ICspStatuses.VTable, self.vtable).get_ItemByProvider(@ptrCast(*const ICspStatuses, self), pCspStatus, ppValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const KeyIdentifierHashAlgorithm = enum(i32) {
Default = 0,
Sha1 = 1,
CapiSha1 = 2,
Sha256 = 3,
HPKP = 5,
};
pub const SKIHashDefault = KeyIdentifierHashAlgorithm.Default;
pub const SKIHashSha1 = KeyIdentifierHashAlgorithm.Sha1;
pub const SKIHashCapiSha1 = KeyIdentifierHashAlgorithm.CapiSha1;
pub const SKIHashSha256 = KeyIdentifierHashAlgorithm.Sha256;
pub const SKIHashHPKP = KeyIdentifierHashAlgorithm.HPKP;
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509PublicKey_Value = @import("../../zig.zig").Guid.initString("728ab30b-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509PublicKey = &IID_IX509PublicKey_Value;
pub const IX509PublicKey = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const IX509PublicKey,
pObjectId: ?*IObjectId,
strEncodedKey: ?BSTR,
strEncodedParameters: ?BSTR,
Encoding: EncodingType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromEncodedPublicKeyInfo: fn(
self: *const IX509PublicKey,
strEncodedPublicKeyInfo: ?BSTR,
Encoding: EncodingType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Algorithm: fn(
self: *const IX509PublicKey,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Length: fn(
self: *const IX509PublicKey,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EncodedKey: fn(
self: *const IX509PublicKey,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EncodedParameters: fn(
self: *const IX509PublicKey,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ComputeKeyIdentifier: fn(
self: *const IX509PublicKey,
Algorithm: KeyIdentifierHashAlgorithm,
Encoding: EncodingType,
pValue: ?*?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 IX509PublicKey_Initialize(self: *const T, pObjectId: ?*IObjectId, strEncodedKey: ?BSTR, strEncodedParameters: ?BSTR, Encoding: EncodingType) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PublicKey.VTable, self.vtable).Initialize(@ptrCast(*const IX509PublicKey, self), pObjectId, strEncodedKey, strEncodedParameters, Encoding);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PublicKey_InitializeFromEncodedPublicKeyInfo(self: *const T, strEncodedPublicKeyInfo: ?BSTR, Encoding: EncodingType) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PublicKey.VTable, self.vtable).InitializeFromEncodedPublicKeyInfo(@ptrCast(*const IX509PublicKey, self), strEncodedPublicKeyInfo, Encoding);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PublicKey_get_Algorithm(self: *const T, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PublicKey.VTable, self.vtable).get_Algorithm(@ptrCast(*const IX509PublicKey, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PublicKey_get_Length(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PublicKey.VTable, self.vtable).get_Length(@ptrCast(*const IX509PublicKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PublicKey_get_EncodedKey(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PublicKey.VTable, self.vtable).get_EncodedKey(@ptrCast(*const IX509PublicKey, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PublicKey_get_EncodedParameters(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PublicKey.VTable, self.vtable).get_EncodedParameters(@ptrCast(*const IX509PublicKey, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PublicKey_ComputeKeyIdentifier(self: *const T, Algorithm: KeyIdentifierHashAlgorithm, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PublicKey.VTable, self.vtable).ComputeKeyIdentifier(@ptrCast(*const IX509PublicKey, self), Algorithm, Encoding, pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const X509PrivateKeyExportFlags = enum(i32) {
EXPORT_NONE = 0,
EXPORT_FLAG = 1,
PLAINTEXT_EXPORT_FLAG = 2,
ARCHIVING_FLAG = 4,
PLAINTEXT_ARCHIVING_FLAG = 8,
};
pub const XCN_NCRYPT_ALLOW_EXPORT_NONE = X509PrivateKeyExportFlags.EXPORT_NONE;
pub const XCN_NCRYPT_ALLOW_EXPORT_FLAG = X509PrivateKeyExportFlags.EXPORT_FLAG;
pub const XCN_NCRYPT_ALLOW_PLAINTEXT_EXPORT_FLAG = X509PrivateKeyExportFlags.PLAINTEXT_EXPORT_FLAG;
pub const XCN_NCRYPT_ALLOW_ARCHIVING_FLAG = X509PrivateKeyExportFlags.ARCHIVING_FLAG;
pub const XCN_NCRYPT_ALLOW_PLAINTEXT_ARCHIVING_FLAG = X509PrivateKeyExportFlags.PLAINTEXT_ARCHIVING_FLAG;
pub const X509PrivateKeyUsageFlags = enum(i32) {
USAGES_NONE = 0,
DECRYPT_FLAG = 1,
SIGNING_FLAG = 2,
KEY_AGREEMENT_FLAG = 4,
KEY_IMPORT_FLAG = 8,
ALL_USAGES = 16777215,
};
pub const XCN_NCRYPT_ALLOW_USAGES_NONE = X509PrivateKeyUsageFlags.USAGES_NONE;
pub const XCN_NCRYPT_ALLOW_DECRYPT_FLAG = X509PrivateKeyUsageFlags.DECRYPT_FLAG;
pub const XCN_NCRYPT_ALLOW_SIGNING_FLAG = X509PrivateKeyUsageFlags.SIGNING_FLAG;
pub const XCN_NCRYPT_ALLOW_KEY_AGREEMENT_FLAG = X509PrivateKeyUsageFlags.KEY_AGREEMENT_FLAG;
pub const XCN_NCRYPT_ALLOW_KEY_IMPORT_FLAG = X509PrivateKeyUsageFlags.KEY_IMPORT_FLAG;
pub const XCN_NCRYPT_ALLOW_ALL_USAGES = X509PrivateKeyUsageFlags.ALL_USAGES;
pub const X509PrivateKeyProtection = enum(i32) {
NO_PROTECTION_FLAG = 0,
PROTECT_KEY_FLAG = 1,
FORCE_HIGH_PROTECTION_FLAG = 2,
FINGERPRINT_PROTECTION_FLAG = 4,
APPCONTAINER_ACCESS_MEDIUM_FLAG = 8,
};
pub const XCN_NCRYPT_UI_NO_PROTECTION_FLAG = X509PrivateKeyProtection.NO_PROTECTION_FLAG;
pub const XCN_NCRYPT_UI_PROTECT_KEY_FLAG = X509PrivateKeyProtection.PROTECT_KEY_FLAG;
pub const XCN_NCRYPT_UI_FORCE_HIGH_PROTECTION_FLAG = X509PrivateKeyProtection.FORCE_HIGH_PROTECTION_FLAG;
pub const XCN_NCRYPT_UI_FINGERPRINT_PROTECTION_FLAG = X509PrivateKeyProtection.FINGERPRINT_PROTECTION_FLAG;
pub const XCN_NCRYPT_UI_APPCONTAINER_ACCESS_MEDIUM_FLAG = X509PrivateKeyProtection.APPCONTAINER_ACCESS_MEDIUM_FLAG;
pub const X509PrivateKeyVerify = enum(i32) {
None = 0,
Silent = 1,
SmartCardNone = 2,
SmartCardSilent = 3,
AllowUI = 4,
};
pub const VerifyNone = X509PrivateKeyVerify.None;
pub const VerifySilent = X509PrivateKeyVerify.Silent;
pub const VerifySmartCardNone = X509PrivateKeyVerify.SmartCardNone;
pub const VerifySmartCardSilent = X509PrivateKeyVerify.SmartCardSilent;
pub const VerifyAllowUI = X509PrivateKeyVerify.AllowUI;
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509PrivateKey_Value = @import("../../zig.zig").Guid.initString("728ab30c-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509PrivateKey = &IID_IX509PrivateKey_Value;
pub const IX509PrivateKey = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Open: fn(
self: *const IX509PrivateKey,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Create: fn(
self: *const IX509PrivateKey,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Close: fn(
self: *const IX509PrivateKey,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Delete: fn(
self: *const IX509PrivateKey,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Verify: fn(
self: *const IX509PrivateKey,
VerifyType: X509PrivateKeyVerify,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Import: fn(
self: *const IX509PrivateKey,
strExportType: ?BSTR,
strEncodedKey: ?BSTR,
Encoding: EncodingType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Export: fn(
self: *const IX509PrivateKey,
strExportType: ?BSTR,
Encoding: EncodingType,
pstrEncodedKey: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ExportPublicKey: fn(
self: *const IX509PrivateKey,
ppPublicKey: ?*?*IX509PublicKey,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ContainerName: fn(
self: *const IX509PrivateKey,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ContainerName: fn(
self: *const IX509PrivateKey,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ContainerNamePrefix: fn(
self: *const IX509PrivateKey,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ContainerNamePrefix: fn(
self: *const IX509PrivateKey,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ReaderName: fn(
self: *const IX509PrivateKey,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ReaderName: fn(
self: *const IX509PrivateKey,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CspInformations: fn(
self: *const IX509PrivateKey,
ppValue: ?*?*ICspInformations,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_CspInformations: fn(
self: *const IX509PrivateKey,
pValue: ?*ICspInformations,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CspStatus: fn(
self: *const IX509PrivateKey,
ppValue: ?*?*ICspStatus,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_CspStatus: fn(
self: *const IX509PrivateKey,
pValue: ?*ICspStatus,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProviderName: fn(
self: *const IX509PrivateKey,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ProviderName: fn(
self: *const IX509PrivateKey,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProviderType: fn(
self: *const IX509PrivateKey,
pValue: ?*X509ProviderType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ProviderType: fn(
self: *const IX509PrivateKey,
Value: X509ProviderType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_LegacyCsp: fn(
self: *const IX509PrivateKey,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_LegacyCsp: fn(
self: *const IX509PrivateKey,
Value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Algorithm: fn(
self: *const IX509PrivateKey,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Algorithm: fn(
self: *const IX509PrivateKey,
pValue: ?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_KeySpec: fn(
self: *const IX509PrivateKey,
pValue: ?*X509KeySpec,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_KeySpec: fn(
self: *const IX509PrivateKey,
Value: X509KeySpec,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Length: fn(
self: *const IX509PrivateKey,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Length: fn(
self: *const IX509PrivateKey,
Value: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ExportPolicy: fn(
self: *const IX509PrivateKey,
pValue: ?*X509PrivateKeyExportFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ExportPolicy: fn(
self: *const IX509PrivateKey,
Value: X509PrivateKeyExportFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_KeyUsage: fn(
self: *const IX509PrivateKey,
pValue: ?*X509PrivateKeyUsageFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_KeyUsage: fn(
self: *const IX509PrivateKey,
Value: X509PrivateKeyUsageFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_KeyProtection: fn(
self: *const IX509PrivateKey,
pValue: ?*X509PrivateKeyProtection,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_KeyProtection: fn(
self: *const IX509PrivateKey,
Value: X509PrivateKeyProtection,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MachineContext: fn(
self: *const IX509PrivateKey,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_MachineContext: fn(
self: *const IX509PrivateKey,
Value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SecurityDescriptor: fn(
self: *const IX509PrivateKey,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_SecurityDescriptor: fn(
self: *const IX509PrivateKey,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Certificate: fn(
self: *const IX509PrivateKey,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Certificate: fn(
self: *const IX509PrivateKey,
Encoding: EncodingType,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_UniqueContainerName: fn(
self: *const IX509PrivateKey,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Opened: fn(
self: *const IX509PrivateKey,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DefaultContainer: fn(
self: *const IX509PrivateKey,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Existing: fn(
self: *const IX509PrivateKey,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Existing: fn(
self: *const IX509PrivateKey,
Value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Silent: fn(
self: *const IX509PrivateKey,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Silent: fn(
self: *const IX509PrivateKey,
Value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ParentWindow: fn(
self: *const IX509PrivateKey,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ParentWindow: fn(
self: *const IX509PrivateKey,
Value: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_UIContextMessage: fn(
self: *const IX509PrivateKey,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_UIContextMessage: fn(
self: *const IX509PrivateKey,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Pin: fn(
self: *const IX509PrivateKey,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_FriendlyName: fn(
self: *const IX509PrivateKey,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_FriendlyName: fn(
self: *const IX509PrivateKey,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Description: fn(
self: *const IX509PrivateKey,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Description: fn(
self: *const IX509PrivateKey,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_Open(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).Open(@ptrCast(*const IX509PrivateKey, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_Create(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).Create(@ptrCast(*const IX509PrivateKey, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_Close(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).Close(@ptrCast(*const IX509PrivateKey, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_Delete(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).Delete(@ptrCast(*const IX509PrivateKey, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_Verify(self: *const T, VerifyType: X509PrivateKeyVerify) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).Verify(@ptrCast(*const IX509PrivateKey, self), VerifyType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_Import(self: *const T, strExportType: ?BSTR, strEncodedKey: ?BSTR, Encoding: EncodingType) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).Import(@ptrCast(*const IX509PrivateKey, self), strExportType, strEncodedKey, Encoding);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_Export(self: *const T, strExportType: ?BSTR, Encoding: EncodingType, pstrEncodedKey: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).Export(@ptrCast(*const IX509PrivateKey, self), strExportType, Encoding, pstrEncodedKey);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_ExportPublicKey(self: *const T, ppPublicKey: ?*?*IX509PublicKey) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).ExportPublicKey(@ptrCast(*const IX509PrivateKey, self), ppPublicKey);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_ContainerName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_ContainerName(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_ContainerName(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_ContainerName(@ptrCast(*const IX509PrivateKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_ContainerNamePrefix(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_ContainerNamePrefix(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_ContainerNamePrefix(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_ContainerNamePrefix(@ptrCast(*const IX509PrivateKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_ReaderName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_ReaderName(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_ReaderName(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_ReaderName(@ptrCast(*const IX509PrivateKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_CspInformations(self: *const T, ppValue: ?*?*ICspInformations) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_CspInformations(@ptrCast(*const IX509PrivateKey, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_CspInformations(self: *const T, pValue: ?*ICspInformations) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_CspInformations(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_CspStatus(self: *const T, ppValue: ?*?*ICspStatus) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_CspStatus(@ptrCast(*const IX509PrivateKey, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_CspStatus(self: *const T, pValue: ?*ICspStatus) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_CspStatus(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_ProviderName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_ProviderName(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_ProviderName(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_ProviderName(@ptrCast(*const IX509PrivateKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_ProviderType(self: *const T, pValue: ?*X509ProviderType) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_ProviderType(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_ProviderType(self: *const T, Value: X509ProviderType) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_ProviderType(@ptrCast(*const IX509PrivateKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_LegacyCsp(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_LegacyCsp(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_LegacyCsp(self: *const T, Value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_LegacyCsp(@ptrCast(*const IX509PrivateKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_Algorithm(self: *const T, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_Algorithm(@ptrCast(*const IX509PrivateKey, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_Algorithm(self: *const T, pValue: ?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_Algorithm(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_KeySpec(self: *const T, pValue: ?*X509KeySpec) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_KeySpec(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_KeySpec(self: *const T, Value: X509KeySpec) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_KeySpec(@ptrCast(*const IX509PrivateKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_Length(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_Length(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_Length(self: *const T, Value: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_Length(@ptrCast(*const IX509PrivateKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_ExportPolicy(self: *const T, pValue: ?*X509PrivateKeyExportFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_ExportPolicy(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_ExportPolicy(self: *const T, Value: X509PrivateKeyExportFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_ExportPolicy(@ptrCast(*const IX509PrivateKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_KeyUsage(self: *const T, pValue: ?*X509PrivateKeyUsageFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_KeyUsage(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_KeyUsage(self: *const T, Value: X509PrivateKeyUsageFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_KeyUsage(@ptrCast(*const IX509PrivateKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_KeyProtection(self: *const T, pValue: ?*X509PrivateKeyProtection) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_KeyProtection(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_KeyProtection(self: *const T, Value: X509PrivateKeyProtection) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_KeyProtection(@ptrCast(*const IX509PrivateKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_MachineContext(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_MachineContext(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_MachineContext(self: *const T, Value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_MachineContext(@ptrCast(*const IX509PrivateKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_SecurityDescriptor(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_SecurityDescriptor(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_SecurityDescriptor(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_SecurityDescriptor(@ptrCast(*const IX509PrivateKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_Certificate(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_Certificate(@ptrCast(*const IX509PrivateKey, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_Certificate(self: *const T, Encoding: EncodingType, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_Certificate(@ptrCast(*const IX509PrivateKey, self), Encoding, Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_UniqueContainerName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_UniqueContainerName(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_Opened(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_Opened(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_DefaultContainer(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_DefaultContainer(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_Existing(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_Existing(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_Existing(self: *const T, Value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_Existing(@ptrCast(*const IX509PrivateKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_Silent(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_Silent(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_Silent(self: *const T, Value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_Silent(@ptrCast(*const IX509PrivateKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_ParentWindow(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_ParentWindow(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_ParentWindow(self: *const T, Value: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_ParentWindow(@ptrCast(*const IX509PrivateKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_UIContextMessage(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_UIContextMessage(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_UIContextMessage(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_UIContextMessage(@ptrCast(*const IX509PrivateKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_Pin(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_Pin(@ptrCast(*const IX509PrivateKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_FriendlyName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_FriendlyName(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_FriendlyName(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_FriendlyName(@ptrCast(*const IX509PrivateKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_get_Description(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).get_Description(@ptrCast(*const IX509PrivateKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey_put_Description(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey.VTable, self.vtable).put_Description(@ptrCast(*const IX509PrivateKey, self), Value);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const X509HardwareKeyUsageFlags = enum(i32) {
PCP_NONE = 0,
TPM12_PROVIDER = 65536,
PCP_SIGNATURE_KEY = 1,
PCP_ENCRYPTION_KEY = 2,
PCP_GENERIC_KEY = 3,
PCP_STORAGE_KEY = 4,
PCP_IDENTITY_KEY = 8,
};
pub const XCN_NCRYPT_PCP_NONE = X509HardwareKeyUsageFlags.PCP_NONE;
pub const XCN_NCRYPT_TPM12_PROVIDER = X509HardwareKeyUsageFlags.TPM12_PROVIDER;
pub const XCN_NCRYPT_PCP_SIGNATURE_KEY = X509HardwareKeyUsageFlags.PCP_SIGNATURE_KEY;
pub const XCN_NCRYPT_PCP_ENCRYPTION_KEY = X509HardwareKeyUsageFlags.PCP_ENCRYPTION_KEY;
pub const XCN_NCRYPT_PCP_GENERIC_KEY = X509HardwareKeyUsageFlags.PCP_GENERIC_KEY;
pub const XCN_NCRYPT_PCP_STORAGE_KEY = X509HardwareKeyUsageFlags.PCP_STORAGE_KEY;
pub const XCN_NCRYPT_PCP_IDENTITY_KEY = X509HardwareKeyUsageFlags.PCP_IDENTITY_KEY;
pub const X509KeyParametersExportType = enum(i32) {
NONE = 0,
NAME_FOR_ENCODE_FLAG = 536870912,
PARAMETERS_FOR_ENCODE_FLAG = 268435456,
};
pub const XCN_CRYPT_OID_USE_CURVE_NONE = X509KeyParametersExportType.NONE;
pub const XCN_CRYPT_OID_USE_CURVE_NAME_FOR_ENCODE_FLAG = X509KeyParametersExportType.NAME_FOR_ENCODE_FLAG;
pub const XCN_CRYPT_OID_USE_CURVE_PARAMETERS_FOR_ENCODE_FLAG = X509KeyParametersExportType.PARAMETERS_FOR_ENCODE_FLAG;
const IID_IX509PrivateKey2_Value = @import("../../zig.zig").Guid.initString("728ab362-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509PrivateKey2 = &IID_IX509PrivateKey2_Value;
pub const IX509PrivateKey2 = extern struct {
pub const VTable = extern struct {
base: IX509PrivateKey.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_HardwareKeyUsage: fn(
self: *const IX509PrivateKey2,
pValue: ?*X509HardwareKeyUsageFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_HardwareKeyUsage: fn(
self: *const IX509PrivateKey2,
Value: X509HardwareKeyUsageFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AlternateStorageLocation: fn(
self: *const IX509PrivateKey2,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_AlternateStorageLocation: fn(
self: *const IX509PrivateKey2,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AlgorithmName: fn(
self: *const IX509PrivateKey2,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_AlgorithmName: fn(
self: *const IX509PrivateKey2,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AlgorithmParameters: fn(
self: *const IX509PrivateKey2,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_AlgorithmParameters: fn(
self: *const IX509PrivateKey2,
Encoding: EncodingType,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ParametersExportType: fn(
self: *const IX509PrivateKey2,
pValue: ?*X509KeyParametersExportType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ParametersExportType: fn(
self: *const IX509PrivateKey2,
Value: X509KeyParametersExportType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509PrivateKey.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey2_get_HardwareKeyUsage(self: *const T, pValue: ?*X509HardwareKeyUsageFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey2.VTable, self.vtable).get_HardwareKeyUsage(@ptrCast(*const IX509PrivateKey2, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey2_put_HardwareKeyUsage(self: *const T, Value: X509HardwareKeyUsageFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey2.VTable, self.vtable).put_HardwareKeyUsage(@ptrCast(*const IX509PrivateKey2, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey2_get_AlternateStorageLocation(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey2.VTable, self.vtable).get_AlternateStorageLocation(@ptrCast(*const IX509PrivateKey2, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey2_put_AlternateStorageLocation(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey2.VTable, self.vtable).put_AlternateStorageLocation(@ptrCast(*const IX509PrivateKey2, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey2_get_AlgorithmName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey2.VTable, self.vtable).get_AlgorithmName(@ptrCast(*const IX509PrivateKey2, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey2_put_AlgorithmName(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey2.VTable, self.vtable).put_AlgorithmName(@ptrCast(*const IX509PrivateKey2, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey2_get_AlgorithmParameters(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey2.VTable, self.vtable).get_AlgorithmParameters(@ptrCast(*const IX509PrivateKey2, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey2_put_AlgorithmParameters(self: *const T, Encoding: EncodingType, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey2.VTable, self.vtable).put_AlgorithmParameters(@ptrCast(*const IX509PrivateKey2, self), Encoding, Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey2_get_ParametersExportType(self: *const T, pValue: ?*X509KeyParametersExportType) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey2.VTable, self.vtable).get_ParametersExportType(@ptrCast(*const IX509PrivateKey2, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PrivateKey2_put_ParametersExportType(self: *const T, Value: X509KeyParametersExportType) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PrivateKey2.VTable, self.vtable).put_ParametersExportType(@ptrCast(*const IX509PrivateKey2, self), Value);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IX509EndorsementKey_Value = @import("../../zig.zig").Guid.initString("<KEY>");
pub const IID_IX509EndorsementKey = &IID_IX509EndorsementKey_Value;
pub const IX509EndorsementKey = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProviderName: fn(
self: *const IX509EndorsementKey,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ProviderName: fn(
self: *const IX509EndorsementKey,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Length: fn(
self: *const IX509EndorsementKey,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Opened: fn(
self: *const IX509EndorsementKey,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddCertificate: fn(
self: *const IX509EndorsementKey,
Encoding: EncodingType,
strCertificate: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
RemoveCertificate: fn(
self: *const IX509EndorsementKey,
Encoding: EncodingType,
strCertificate: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCertificateByIndex: fn(
self: *const IX509EndorsementKey,
ManufacturerOnly: i16,
dwIndex: i32,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCertificateCount: fn(
self: *const IX509EndorsementKey,
ManufacturerOnly: i16,
pCount: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ExportPublicKey: fn(
self: *const IX509EndorsementKey,
ppPublicKey: ?*?*IX509PublicKey,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Open: fn(
self: *const IX509EndorsementKey,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Close: fn(
self: *const IX509EndorsementKey,
) 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 IX509EndorsementKey_get_ProviderName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EndorsementKey.VTable, self.vtable).get_ProviderName(@ptrCast(*const IX509EndorsementKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EndorsementKey_put_ProviderName(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EndorsementKey.VTable, self.vtable).put_ProviderName(@ptrCast(*const IX509EndorsementKey, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EndorsementKey_get_Length(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EndorsementKey.VTable, self.vtable).get_Length(@ptrCast(*const IX509EndorsementKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EndorsementKey_get_Opened(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EndorsementKey.VTable, self.vtable).get_Opened(@ptrCast(*const IX509EndorsementKey, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EndorsementKey_AddCertificate(self: *const T, Encoding: EncodingType, strCertificate: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EndorsementKey.VTable, self.vtable).AddCertificate(@ptrCast(*const IX509EndorsementKey, self), Encoding, strCertificate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EndorsementKey_RemoveCertificate(self: *const T, Encoding: EncodingType, strCertificate: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EndorsementKey.VTable, self.vtable).RemoveCertificate(@ptrCast(*const IX509EndorsementKey, self), Encoding, strCertificate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EndorsementKey_GetCertificateByIndex(self: *const T, ManufacturerOnly: i16, dwIndex: i32, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EndorsementKey.VTable, self.vtable).GetCertificateByIndex(@ptrCast(*const IX509EndorsementKey, self), ManufacturerOnly, dwIndex, Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EndorsementKey_GetCertificateCount(self: *const T, ManufacturerOnly: i16, pCount: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EndorsementKey.VTable, self.vtable).GetCertificateCount(@ptrCast(*const IX509EndorsementKey, self), ManufacturerOnly, pCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EndorsementKey_ExportPublicKey(self: *const T, ppPublicKey: ?*?*IX509PublicKey) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EndorsementKey.VTable, self.vtable).ExportPublicKey(@ptrCast(*const IX509EndorsementKey, self), ppPublicKey);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EndorsementKey_Open(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EndorsementKey.VTable, self.vtable).Open(@ptrCast(*const IX509EndorsementKey, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EndorsementKey_Close(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EndorsementKey.VTable, self.vtable).Close(@ptrCast(*const IX509EndorsementKey, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509Extension_Value = @import("../../zig.zig").Guid.initString("728ab30d-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509Extension = &IID_IX509Extension_Value;
pub const IX509Extension = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const IX509Extension,
pObjectId: ?*IObjectId,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ObjectId: fn(
self: *const IX509Extension,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RawData: fn(
self: *const IX509Extension,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Critical: fn(
self: *const IX509Extension,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Critical: fn(
self: *const IX509Extension,
Value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Extension_Initialize(self: *const T, pObjectId: ?*IObjectId, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Extension.VTable, self.vtable).Initialize(@ptrCast(*const IX509Extension, self), pObjectId, Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Extension_get_ObjectId(self: *const T, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Extension.VTable, self.vtable).get_ObjectId(@ptrCast(*const IX509Extension, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Extension_get_RawData(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Extension.VTable, self.vtable).get_RawData(@ptrCast(*const IX509Extension, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Extension_get_Critical(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Extension.VTable, self.vtable).get_Critical(@ptrCast(*const IX509Extension, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Extension_put_Critical(self: *const T, Value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Extension.VTable, self.vtable).put_Critical(@ptrCast(*const IX509Extension, self), Value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509Extensions_Value = @import("../../zig.zig").Guid.initString("728ab30e-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509Extensions = &IID_IX509Extensions_Value;
pub const IX509Extensions = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByIndex: fn(
self: *const IX509Extensions,
Index: i32,
pVal: ?*?*IX509Extension,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const IX509Extensions,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const IX509Extensions,
pVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const IX509Extensions,
pVal: ?*IX509Extension,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Remove: fn(
self: *const IX509Extensions,
Index: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clear: fn(
self: *const IX509Extensions,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IndexByObjectId: fn(
self: *const IX509Extensions,
pObjectId: ?*IObjectId,
pIndex: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddRange: fn(
self: *const IX509Extensions,
pValue: ?*IX509Extensions,
) 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 IX509Extensions_get_ItemByIndex(self: *const T, Index: i32, pVal: ?*?*IX509Extension) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Extensions.VTable, self.vtable).get_ItemByIndex(@ptrCast(*const IX509Extensions, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Extensions_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Extensions.VTable, self.vtable).get_Count(@ptrCast(*const IX509Extensions, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Extensions_get__NewEnum(self: *const T, pVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Extensions.VTable, self.vtable).get__NewEnum(@ptrCast(*const IX509Extensions, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Extensions_Add(self: *const T, pVal: ?*IX509Extension) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Extensions.VTable, self.vtable).Add(@ptrCast(*const IX509Extensions, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Extensions_Remove(self: *const T, Index: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Extensions.VTable, self.vtable).Remove(@ptrCast(*const IX509Extensions, self), Index);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Extensions_Clear(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Extensions.VTable, self.vtable).Clear(@ptrCast(*const IX509Extensions, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Extensions_get_IndexByObjectId(self: *const T, pObjectId: ?*IObjectId, pIndex: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Extensions.VTable, self.vtable).get_IndexByObjectId(@ptrCast(*const IX509Extensions, self), pObjectId, pIndex);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Extensions_AddRange(self: *const T, pValue: ?*IX509Extensions) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Extensions.VTable, self.vtable).AddRange(@ptrCast(*const IX509Extensions, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const X509KeyUsageFlags = enum(i32) {
NO_KEY_USAGE = 0,
DIGITAL_SIGNATURE_KEY_USAGE = 128,
NON_REPUDIATION_KEY_USAGE = 64,
KEY_ENCIPHERMENT_KEY_USAGE = 32,
DATA_ENCIPHERMENT_KEY_USAGE = 16,
KEY_AGREEMENT_KEY_USAGE = 8,
KEY_CERT_SIGN_KEY_USAGE = 4,
OFFLINE_CRL_SIGN_KEY_USAGE = 2,
// CRL_SIGN_KEY_USAGE = 2, this enum value conflicts with OFFLINE_CRL_SIGN_KEY_USAGE
ENCIPHER_ONLY_KEY_USAGE = 1,
DECIPHER_ONLY_KEY_USAGE = 32768,
};
pub const XCN_CERT_NO_KEY_USAGE = X509KeyUsageFlags.NO_KEY_USAGE;
pub const XCN_CERT_DIGITAL_SIGNATURE_KEY_USAGE = X509KeyUsageFlags.DIGITAL_SIGNATURE_KEY_USAGE;
pub const XCN_CERT_NON_REPUDIATION_KEY_USAGE = X509KeyUsageFlags.NON_REPUDIATION_KEY_USAGE;
pub const XCN_CERT_KEY_ENCIPHERMENT_KEY_USAGE = X509KeyUsageFlags.KEY_ENCIPHERMENT_KEY_USAGE;
pub const XCN_CERT_DATA_ENCIPHERMENT_KEY_USAGE = X509KeyUsageFlags.DATA_ENCIPHERMENT_KEY_USAGE;
pub const XCN_CERT_KEY_AGREEMENT_KEY_USAGE = X509KeyUsageFlags.KEY_AGREEMENT_KEY_USAGE;
pub const XCN_CERT_KEY_CERT_SIGN_KEY_USAGE = X509KeyUsageFlags.KEY_CERT_SIGN_KEY_USAGE;
pub const XCN_CERT_OFFLINE_CRL_SIGN_KEY_USAGE = X509KeyUsageFlags.OFFLINE_CRL_SIGN_KEY_USAGE;
pub const XCN_CERT_CRL_SIGN_KEY_USAGE = X509KeyUsageFlags.OFFLINE_CRL_SIGN_KEY_USAGE;
pub const XCN_CERT_ENCIPHER_ONLY_KEY_USAGE = X509KeyUsageFlags.ENCIPHER_ONLY_KEY_USAGE;
pub const XCN_CERT_DECIPHER_ONLY_KEY_USAGE = X509KeyUsageFlags.DECIPHER_ONLY_KEY_USAGE;
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509ExtensionKeyUsage_Value = @import("../../zig.zig").Guid.initString("728ab30f-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509ExtensionKeyUsage = &IID_IX509ExtensionKeyUsage_Value;
pub const IX509ExtensionKeyUsage = extern struct {
pub const VTable = extern struct {
base: IX509Extension.VTable,
InitializeEncode: fn(
self: *const IX509ExtensionKeyUsage,
UsageFlags: X509KeyUsageFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509ExtensionKeyUsage,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_KeyUsage: fn(
self: *const IX509ExtensionKeyUsage,
pValue: ?*X509KeyUsageFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509Extension.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionKeyUsage_InitializeEncode(self: *const T, UsageFlags: X509KeyUsageFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionKeyUsage.VTable, self.vtable).InitializeEncode(@ptrCast(*const IX509ExtensionKeyUsage, self), UsageFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionKeyUsage_InitializeDecode(self: *const T, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionKeyUsage.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509ExtensionKeyUsage, self), Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionKeyUsage_get_KeyUsage(self: *const T, pValue: ?*X509KeyUsageFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionKeyUsage.VTable, self.vtable).get_KeyUsage(@ptrCast(*const IX509ExtensionKeyUsage, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509ExtensionEnhancedKeyUsage_Value = @import("../../zig.zig").Guid.initString("728ab310-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509ExtensionEnhancedKeyUsage = &IID_IX509ExtensionEnhancedKeyUsage_Value;
pub const IX509ExtensionEnhancedKeyUsage = extern struct {
pub const VTable = extern struct {
base: IX509Extension.VTable,
InitializeEncode: fn(
self: *const IX509ExtensionEnhancedKeyUsage,
pValue: ?*IObjectIds,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509ExtensionEnhancedKeyUsage,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EnhancedKeyUsage: fn(
self: *const IX509ExtensionEnhancedKeyUsage,
ppValue: ?*?*IObjectIds,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509Extension.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionEnhancedKeyUsage_InitializeEncode(self: *const T, pValue: ?*IObjectIds) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionEnhancedKeyUsage.VTable, self.vtable).InitializeEncode(@ptrCast(*const IX509ExtensionEnhancedKeyUsage, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionEnhancedKeyUsage_InitializeDecode(self: *const T, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionEnhancedKeyUsage.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509ExtensionEnhancedKeyUsage, self), Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionEnhancedKeyUsage_get_EnhancedKeyUsage(self: *const T, ppValue: ?*?*IObjectIds) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionEnhancedKeyUsage.VTable, self.vtable).get_EnhancedKeyUsage(@ptrCast(*const IX509ExtensionEnhancedKeyUsage, self), ppValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509ExtensionTemplateName_Value = @import("../../zig.zig").Guid.initString("728ab311-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509ExtensionTemplateName = &IID_IX509ExtensionTemplateName_Value;
pub const IX509ExtensionTemplateName = extern struct {
pub const VTable = extern struct {
base: IX509Extension.VTable,
InitializeEncode: fn(
self: *const IX509ExtensionTemplateName,
strTemplateName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509ExtensionTemplateName,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TemplateName: fn(
self: *const IX509ExtensionTemplateName,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509Extension.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionTemplateName_InitializeEncode(self: *const T, strTemplateName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionTemplateName.VTable, self.vtable).InitializeEncode(@ptrCast(*const IX509ExtensionTemplateName, self), strTemplateName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionTemplateName_InitializeDecode(self: *const T, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionTemplateName.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509ExtensionTemplateName, self), Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionTemplateName_get_TemplateName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionTemplateName.VTable, self.vtable).get_TemplateName(@ptrCast(*const IX509ExtensionTemplateName, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509ExtensionTemplate_Value = @import("../../zig.zig").Guid.initString("728ab312-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509ExtensionTemplate = &IID_IX509ExtensionTemplate_Value;
pub const IX509ExtensionTemplate = extern struct {
pub const VTable = extern struct {
base: IX509Extension.VTable,
InitializeEncode: fn(
self: *const IX509ExtensionTemplate,
pTemplateOid: ?*IObjectId,
MajorVersion: i32,
MinorVersion: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509ExtensionTemplate,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TemplateOid: fn(
self: *const IX509ExtensionTemplate,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MajorVersion: fn(
self: *const IX509ExtensionTemplate,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MinorVersion: fn(
self: *const IX509ExtensionTemplate,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509Extension.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionTemplate_InitializeEncode(self: *const T, pTemplateOid: ?*IObjectId, MajorVersion: i32, MinorVersion: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionTemplate.VTable, self.vtable).InitializeEncode(@ptrCast(*const IX509ExtensionTemplate, self), pTemplateOid, MajorVersion, MinorVersion);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionTemplate_InitializeDecode(self: *const T, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionTemplate.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509ExtensionTemplate, self), Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionTemplate_get_TemplateOid(self: *const T, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionTemplate.VTable, self.vtable).get_TemplateOid(@ptrCast(*const IX509ExtensionTemplate, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionTemplate_get_MajorVersion(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionTemplate.VTable, self.vtable).get_MajorVersion(@ptrCast(*const IX509ExtensionTemplate, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionTemplate_get_MinorVersion(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionTemplate.VTable, self.vtable).get_MinorVersion(@ptrCast(*const IX509ExtensionTemplate, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const AlternativeNameType = enum(i32) {
UNKNOWN = 0,
OTHER_NAME = 1,
RFC822_NAME = 2,
DNS_NAME = 3,
X400_ADDRESS = 4,
DIRECTORY_NAME = 5,
EDI_PARTY_NAME = 6,
URL = 7,
IP_ADDRESS = 8,
REGISTERED_ID = 9,
GUID = 10,
USER_PRINCIPLE_NAME = 11,
};
pub const XCN_CERT_ALT_NAME_UNKNOWN = AlternativeNameType.UNKNOWN;
pub const XCN_CERT_ALT_NAME_OTHER_NAME = AlternativeNameType.OTHER_NAME;
pub const XCN_CERT_ALT_NAME_RFC822_NAME = AlternativeNameType.RFC822_NAME;
pub const XCN_CERT_ALT_NAME_DNS_NAME = AlternativeNameType.DNS_NAME;
pub const XCN_CERT_ALT_NAME_X400_ADDRESS = AlternativeNameType.X400_ADDRESS;
pub const XCN_CERT_ALT_NAME_DIRECTORY_NAME = AlternativeNameType.DIRECTORY_NAME;
pub const XCN_CERT_ALT_NAME_EDI_PARTY_NAME = AlternativeNameType.EDI_PARTY_NAME;
pub const XCN_CERT_ALT_NAME_URL = AlternativeNameType.URL;
pub const XCN_CERT_ALT_NAME_IP_ADDRESS = AlternativeNameType.IP_ADDRESS;
pub const XCN_CERT_ALT_NAME_REGISTERED_ID = AlternativeNameType.REGISTERED_ID;
pub const XCN_CERT_ALT_NAME_GUID = AlternativeNameType.GUID;
pub const XCN_CERT_ALT_NAME_USER_PRINCIPLE_NAME = AlternativeNameType.USER_PRINCIPLE_NAME;
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IAlternativeName_Value = @import("../../zig.zig").Guid.initString("728ab313-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IAlternativeName = &IID_IAlternativeName_Value;
pub const IAlternativeName = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
InitializeFromString: fn(
self: *const IAlternativeName,
Type: AlternativeNameType,
strValue: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromRawData: fn(
self: *const IAlternativeName,
Type: AlternativeNameType,
Encoding: EncodingType,
strRawData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromOtherName: fn(
self: *const IAlternativeName,
pObjectId: ?*IObjectId,
Encoding: EncodingType,
strRawData: ?BSTR,
ToBeWrapped: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Type: fn(
self: *const IAlternativeName,
pValue: ?*AlternativeNameType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_StrValue: fn(
self: *const IAlternativeName,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ObjectId: fn(
self: *const IAlternativeName,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RawData: fn(
self: *const IAlternativeName,
Encoding: EncodingType,
pValue: ?*?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 IAlternativeName_InitializeFromString(self: *const T, Type: AlternativeNameType, strValue: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IAlternativeName.VTable, self.vtable).InitializeFromString(@ptrCast(*const IAlternativeName, self), Type, strValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAlternativeName_InitializeFromRawData(self: *const T, Type: AlternativeNameType, Encoding: EncodingType, strRawData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IAlternativeName.VTable, self.vtable).InitializeFromRawData(@ptrCast(*const IAlternativeName, self), Type, Encoding, strRawData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAlternativeName_InitializeFromOtherName(self: *const T, pObjectId: ?*IObjectId, Encoding: EncodingType, strRawData: ?BSTR, ToBeWrapped: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IAlternativeName.VTable, self.vtable).InitializeFromOtherName(@ptrCast(*const IAlternativeName, self), pObjectId, Encoding, strRawData, ToBeWrapped);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAlternativeName_get_Type(self: *const T, pValue: ?*AlternativeNameType) callconv(.Inline) HRESULT {
return @ptrCast(*const IAlternativeName.VTable, self.vtable).get_Type(@ptrCast(*const IAlternativeName, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAlternativeName_get_StrValue(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IAlternativeName.VTable, self.vtable).get_StrValue(@ptrCast(*const IAlternativeName, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAlternativeName_get_ObjectId(self: *const T, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IAlternativeName.VTable, self.vtable).get_ObjectId(@ptrCast(*const IAlternativeName, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAlternativeName_get_RawData(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IAlternativeName.VTable, self.vtable).get_RawData(@ptrCast(*const IAlternativeName, self), Encoding, pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IAlternativeNames_Value = @import("../../zig.zig").Guid.initString("728ab314-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IAlternativeNames = &IID_IAlternativeNames_Value;
pub const IAlternativeNames = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByIndex: fn(
self: *const IAlternativeNames,
Index: i32,
pVal: ?*?*IAlternativeName,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const IAlternativeNames,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const IAlternativeNames,
pVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const IAlternativeNames,
pVal: ?*IAlternativeName,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Remove: fn(
self: *const IAlternativeNames,
Index: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clear: fn(
self: *const IAlternativeNames,
) 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 IAlternativeNames_get_ItemByIndex(self: *const T, Index: i32, pVal: ?*?*IAlternativeName) callconv(.Inline) HRESULT {
return @ptrCast(*const IAlternativeNames.VTable, self.vtable).get_ItemByIndex(@ptrCast(*const IAlternativeNames, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAlternativeNames_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IAlternativeNames.VTable, self.vtable).get_Count(@ptrCast(*const IAlternativeNames, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAlternativeNames_get__NewEnum(self: *const T, pVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const IAlternativeNames.VTable, self.vtable).get__NewEnum(@ptrCast(*const IAlternativeNames, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAlternativeNames_Add(self: *const T, pVal: ?*IAlternativeName) callconv(.Inline) HRESULT {
return @ptrCast(*const IAlternativeNames.VTable, self.vtable).Add(@ptrCast(*const IAlternativeNames, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAlternativeNames_Remove(self: *const T, Index: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IAlternativeNames.VTable, self.vtable).Remove(@ptrCast(*const IAlternativeNames, self), Index);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAlternativeNames_Clear(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IAlternativeNames.VTable, self.vtable).Clear(@ptrCast(*const IAlternativeNames, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509ExtensionAlternativeNames_Value = @import("../../zig.zig").Guid.initString("728ab315-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509ExtensionAlternativeNames = &IID_IX509ExtensionAlternativeNames_Value;
pub const IX509ExtensionAlternativeNames = extern struct {
pub const VTable = extern struct {
base: IX509Extension.VTable,
InitializeEncode: fn(
self: *const IX509ExtensionAlternativeNames,
pValue: ?*IAlternativeNames,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509ExtensionAlternativeNames,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AlternativeNames: fn(
self: *const IX509ExtensionAlternativeNames,
ppValue: ?*?*IAlternativeNames,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509Extension.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionAlternativeNames_InitializeEncode(self: *const T, pValue: ?*IAlternativeNames) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionAlternativeNames.VTable, self.vtable).InitializeEncode(@ptrCast(*const IX509ExtensionAlternativeNames, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionAlternativeNames_InitializeDecode(self: *const T, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionAlternativeNames.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509ExtensionAlternativeNames, self), Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionAlternativeNames_get_AlternativeNames(self: *const T, ppValue: ?*?*IAlternativeNames) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionAlternativeNames.VTable, self.vtable).get_AlternativeNames(@ptrCast(*const IX509ExtensionAlternativeNames, self), ppValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509ExtensionBasicConstraints_Value = @import("../../zig.zig").Guid.initString("728ab316-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509ExtensionBasicConstraints = &IID_IX509ExtensionBasicConstraints_Value;
pub const IX509ExtensionBasicConstraints = extern struct {
pub const VTable = extern struct {
base: IX509Extension.VTable,
InitializeEncode: fn(
self: *const IX509ExtensionBasicConstraints,
IsCA: i16,
PathLenConstraint: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509ExtensionBasicConstraints,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsCA: fn(
self: *const IX509ExtensionBasicConstraints,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PathLenConstraint: fn(
self: *const IX509ExtensionBasicConstraints,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509Extension.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionBasicConstraints_InitializeEncode(self: *const T, IsCA: i16, PathLenConstraint: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionBasicConstraints.VTable, self.vtable).InitializeEncode(@ptrCast(*const IX509ExtensionBasicConstraints, self), IsCA, PathLenConstraint);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionBasicConstraints_InitializeDecode(self: *const T, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionBasicConstraints.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509ExtensionBasicConstraints, self), Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionBasicConstraints_get_IsCA(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionBasicConstraints.VTable, self.vtable).get_IsCA(@ptrCast(*const IX509ExtensionBasicConstraints, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionBasicConstraints_get_PathLenConstraint(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionBasicConstraints.VTable, self.vtable).get_PathLenConstraint(@ptrCast(*const IX509ExtensionBasicConstraints, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509ExtensionSubjectKeyIdentifier_Value = @import("../../zig.zig").Guid.initString("728ab317-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509ExtensionSubjectKeyIdentifier = &IID_IX509ExtensionSubjectKeyIdentifier_Value;
pub const IX509ExtensionSubjectKeyIdentifier = extern struct {
pub const VTable = extern struct {
base: IX509Extension.VTable,
InitializeEncode: fn(
self: *const IX509ExtensionSubjectKeyIdentifier,
Encoding: EncodingType,
strKeyIdentifier: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509ExtensionSubjectKeyIdentifier,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SubjectKeyIdentifier: fn(
self: *const IX509ExtensionSubjectKeyIdentifier,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509Extension.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionSubjectKeyIdentifier_InitializeEncode(self: *const T, Encoding: EncodingType, strKeyIdentifier: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionSubjectKeyIdentifier.VTable, self.vtable).InitializeEncode(@ptrCast(*const IX509ExtensionSubjectKeyIdentifier, self), Encoding, strKeyIdentifier);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionSubjectKeyIdentifier_InitializeDecode(self: *const T, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionSubjectKeyIdentifier.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509ExtensionSubjectKeyIdentifier, self), Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionSubjectKeyIdentifier_get_SubjectKeyIdentifier(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionSubjectKeyIdentifier.VTable, self.vtable).get_SubjectKeyIdentifier(@ptrCast(*const IX509ExtensionSubjectKeyIdentifier, self), Encoding, pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509ExtensionAuthorityKeyIdentifier_Value = @import("../../zig.zig").Guid.initString("728ab318-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509ExtensionAuthorityKeyIdentifier = &IID_IX509ExtensionAuthorityKeyIdentifier_Value;
pub const IX509ExtensionAuthorityKeyIdentifier = extern struct {
pub const VTable = extern struct {
base: IX509Extension.VTable,
InitializeEncode: fn(
self: *const IX509ExtensionAuthorityKeyIdentifier,
Encoding: EncodingType,
strKeyIdentifier: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509ExtensionAuthorityKeyIdentifier,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AuthorityKeyIdentifier: fn(
self: *const IX509ExtensionAuthorityKeyIdentifier,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509Extension.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionAuthorityKeyIdentifier_InitializeEncode(self: *const T, Encoding: EncodingType, strKeyIdentifier: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionAuthorityKeyIdentifier.VTable, self.vtable).InitializeEncode(@ptrCast(*const IX509ExtensionAuthorityKeyIdentifier, self), Encoding, strKeyIdentifier);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionAuthorityKeyIdentifier_InitializeDecode(self: *const T, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionAuthorityKeyIdentifier.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509ExtensionAuthorityKeyIdentifier, self), Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionAuthorityKeyIdentifier_get_AuthorityKeyIdentifier(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionAuthorityKeyIdentifier.VTable, self.vtable).get_AuthorityKeyIdentifier(@ptrCast(*const IX509ExtensionAuthorityKeyIdentifier, self), Encoding, pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ISmimeCapability_Value = @import("../../zig.zig").Guid.initString("728ab319-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ISmimeCapability = &IID_ISmimeCapability_Value;
pub const ISmimeCapability = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const ISmimeCapability,
pObjectId: ?*IObjectId,
BitCount: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ObjectId: fn(
self: *const ISmimeCapability,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BitCount: fn(
self: *const ISmimeCapability,
pValue: ?*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 ISmimeCapability_Initialize(self: *const T, pObjectId: ?*IObjectId, BitCount: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ISmimeCapability.VTable, self.vtable).Initialize(@ptrCast(*const ISmimeCapability, self), pObjectId, BitCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISmimeCapability_get_ObjectId(self: *const T, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const ISmimeCapability.VTable, self.vtable).get_ObjectId(@ptrCast(*const ISmimeCapability, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISmimeCapability_get_BitCount(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ISmimeCapability.VTable, self.vtable).get_BitCount(@ptrCast(*const ISmimeCapability, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ISmimeCapabilities_Value = @import("../../zig.zig").Guid.initString("728ab31a-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ISmimeCapabilities = &IID_ISmimeCapabilities_Value;
pub const ISmimeCapabilities = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByIndex: fn(
self: *const ISmimeCapabilities,
Index: i32,
pVal: ?*?*ISmimeCapability,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const ISmimeCapabilities,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const ISmimeCapabilities,
pVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const ISmimeCapabilities,
pVal: ?*ISmimeCapability,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Remove: fn(
self: *const ISmimeCapabilities,
Index: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clear: fn(
self: *const ISmimeCapabilities,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddFromCsp: fn(
self: *const ISmimeCapabilities,
pValue: ?*ICspInformation,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddAvailableSmimeCapabilities: fn(
self: *const ISmimeCapabilities,
MachineContext: 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 ISmimeCapabilities_get_ItemByIndex(self: *const T, Index: i32, pVal: ?*?*ISmimeCapability) callconv(.Inline) HRESULT {
return @ptrCast(*const ISmimeCapabilities.VTable, self.vtable).get_ItemByIndex(@ptrCast(*const ISmimeCapabilities, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISmimeCapabilities_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ISmimeCapabilities.VTable, self.vtable).get_Count(@ptrCast(*const ISmimeCapabilities, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISmimeCapabilities_get__NewEnum(self: *const T, pVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const ISmimeCapabilities.VTable, self.vtable).get__NewEnum(@ptrCast(*const ISmimeCapabilities, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISmimeCapabilities_Add(self: *const T, pVal: ?*ISmimeCapability) callconv(.Inline) HRESULT {
return @ptrCast(*const ISmimeCapabilities.VTable, self.vtable).Add(@ptrCast(*const ISmimeCapabilities, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISmimeCapabilities_Remove(self: *const T, Index: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ISmimeCapabilities.VTable, self.vtable).Remove(@ptrCast(*const ISmimeCapabilities, self), Index);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISmimeCapabilities_Clear(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ISmimeCapabilities.VTable, self.vtable).Clear(@ptrCast(*const ISmimeCapabilities, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISmimeCapabilities_AddFromCsp(self: *const T, pValue: ?*ICspInformation) callconv(.Inline) HRESULT {
return @ptrCast(*const ISmimeCapabilities.VTable, self.vtable).AddFromCsp(@ptrCast(*const ISmimeCapabilities, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISmimeCapabilities_AddAvailableSmimeCapabilities(self: *const T, MachineContext: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ISmimeCapabilities.VTable, self.vtable).AddAvailableSmimeCapabilities(@ptrCast(*const ISmimeCapabilities, self), MachineContext);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509ExtensionSmimeCapabilities_Value = @import("../../zig.zig").Guid.initString("728ab31b-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509ExtensionSmimeCapabilities = &IID_IX509ExtensionSmimeCapabilities_Value;
pub const IX509ExtensionSmimeCapabilities = extern struct {
pub const VTable = extern struct {
base: IX509Extension.VTable,
InitializeEncode: fn(
self: *const IX509ExtensionSmimeCapabilities,
pValue: ?*ISmimeCapabilities,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509ExtensionSmimeCapabilities,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SmimeCapabilities: fn(
self: *const IX509ExtensionSmimeCapabilities,
ppValue: ?*?*ISmimeCapabilities,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509Extension.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionSmimeCapabilities_InitializeEncode(self: *const T, pValue: ?*ISmimeCapabilities) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionSmimeCapabilities.VTable, self.vtable).InitializeEncode(@ptrCast(*const IX509ExtensionSmimeCapabilities, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionSmimeCapabilities_InitializeDecode(self: *const T, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionSmimeCapabilities.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509ExtensionSmimeCapabilities, self), Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionSmimeCapabilities_get_SmimeCapabilities(self: *const T, ppValue: ?*?*ISmimeCapabilities) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionSmimeCapabilities.VTable, self.vtable).get_SmimeCapabilities(@ptrCast(*const IX509ExtensionSmimeCapabilities, self), ppValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const PolicyQualifierType = enum(i32) {
Unknown = 0,
Url = 1,
UserNotice = 2,
Flags = 3,
};
pub const PolicyQualifierTypeUnknown = PolicyQualifierType.Unknown;
pub const PolicyQualifierTypeUrl = PolicyQualifierType.Url;
pub const PolicyQualifierTypeUserNotice = PolicyQualifierType.UserNotice;
pub const PolicyQualifierTypeFlags = PolicyQualifierType.Flags;
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IPolicyQualifier_Value = @import("../../zig.zig").Guid.initString("728ab31c-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IPolicyQualifier = &IID_IPolicyQualifier_Value;
pub const IPolicyQualifier = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
InitializeEncode: fn(
self: *const IPolicyQualifier,
strQualifier: ?BSTR,
Type: PolicyQualifierType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ObjectId: fn(
self: *const IPolicyQualifier,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Qualifier: fn(
self: *const IPolicyQualifier,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Type: fn(
self: *const IPolicyQualifier,
pValue: ?*PolicyQualifierType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RawData: fn(
self: *const IPolicyQualifier,
Encoding: EncodingType,
pValue: ?*?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 IPolicyQualifier_InitializeEncode(self: *const T, strQualifier: ?BSTR, Type: PolicyQualifierType) callconv(.Inline) HRESULT {
return @ptrCast(*const IPolicyQualifier.VTable, self.vtable).InitializeEncode(@ptrCast(*const IPolicyQualifier, self), strQualifier, Type);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPolicyQualifier_get_ObjectId(self: *const T, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IPolicyQualifier.VTable, self.vtable).get_ObjectId(@ptrCast(*const IPolicyQualifier, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPolicyQualifier_get_Qualifier(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPolicyQualifier.VTable, self.vtable).get_Qualifier(@ptrCast(*const IPolicyQualifier, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPolicyQualifier_get_Type(self: *const T, pValue: ?*PolicyQualifierType) callconv(.Inline) HRESULT {
return @ptrCast(*const IPolicyQualifier.VTable, self.vtable).get_Type(@ptrCast(*const IPolicyQualifier, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPolicyQualifier_get_RawData(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPolicyQualifier.VTable, self.vtable).get_RawData(@ptrCast(*const IPolicyQualifier, self), Encoding, pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IPolicyQualifiers_Value = @import("../../zig.zig").Guid.initString("728ab31d-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IPolicyQualifiers = &IID_IPolicyQualifiers_Value;
pub const IPolicyQualifiers = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByIndex: fn(
self: *const IPolicyQualifiers,
Index: i32,
pVal: ?*?*IPolicyQualifier,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const IPolicyQualifiers,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const IPolicyQualifiers,
pVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const IPolicyQualifiers,
pVal: ?*IPolicyQualifier,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Remove: fn(
self: *const IPolicyQualifiers,
Index: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clear: fn(
self: *const IPolicyQualifiers,
) 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 IPolicyQualifiers_get_ItemByIndex(self: *const T, Index: i32, pVal: ?*?*IPolicyQualifier) callconv(.Inline) HRESULT {
return @ptrCast(*const IPolicyQualifiers.VTable, self.vtable).get_ItemByIndex(@ptrCast(*const IPolicyQualifiers, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPolicyQualifiers_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPolicyQualifiers.VTable, self.vtable).get_Count(@ptrCast(*const IPolicyQualifiers, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPolicyQualifiers_get__NewEnum(self: *const T, pVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const IPolicyQualifiers.VTable, self.vtable).get__NewEnum(@ptrCast(*const IPolicyQualifiers, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPolicyQualifiers_Add(self: *const T, pVal: ?*IPolicyQualifier) callconv(.Inline) HRESULT {
return @ptrCast(*const IPolicyQualifiers.VTable, self.vtable).Add(@ptrCast(*const IPolicyQualifiers, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPolicyQualifiers_Remove(self: *const T, Index: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPolicyQualifiers.VTable, self.vtable).Remove(@ptrCast(*const IPolicyQualifiers, self), Index);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPolicyQualifiers_Clear(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IPolicyQualifiers.VTable, self.vtable).Clear(@ptrCast(*const IPolicyQualifiers, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICertificatePolicy_Value = @import("../../zig.zig").Guid.initString("728ab31e-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICertificatePolicy = &IID_ICertificatePolicy_Value;
pub const ICertificatePolicy = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const ICertificatePolicy,
pValue: ?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ObjectId: fn(
self: *const ICertificatePolicy,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PolicyQualifiers: fn(
self: *const ICertificatePolicy,
ppValue: ?*?*IPolicyQualifiers,
) 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 ICertificatePolicy_Initialize(self: *const T, pValue: ?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificatePolicy.VTable, self.vtable).Initialize(@ptrCast(*const ICertificatePolicy, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificatePolicy_get_ObjectId(self: *const T, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificatePolicy.VTable, self.vtable).get_ObjectId(@ptrCast(*const ICertificatePolicy, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificatePolicy_get_PolicyQualifiers(self: *const T, ppValue: ?*?*IPolicyQualifiers) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificatePolicy.VTable, self.vtable).get_PolicyQualifiers(@ptrCast(*const ICertificatePolicy, self), ppValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICertificatePolicies_Value = @import("../../zig.zig").Guid.initString("728ab31f-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICertificatePolicies = &IID_ICertificatePolicies_Value;
pub const ICertificatePolicies = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByIndex: fn(
self: *const ICertificatePolicies,
Index: i32,
pVal: ?*?*ICertificatePolicy,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const ICertificatePolicies,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const ICertificatePolicies,
pVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const ICertificatePolicies,
pVal: ?*ICertificatePolicy,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Remove: fn(
self: *const ICertificatePolicies,
Index: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clear: fn(
self: *const ICertificatePolicies,
) 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 ICertificatePolicies_get_ItemByIndex(self: *const T, Index: i32, pVal: ?*?*ICertificatePolicy) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificatePolicies.VTable, self.vtable).get_ItemByIndex(@ptrCast(*const ICertificatePolicies, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificatePolicies_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificatePolicies.VTable, self.vtable).get_Count(@ptrCast(*const ICertificatePolicies, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificatePolicies_get__NewEnum(self: *const T, pVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificatePolicies.VTable, self.vtable).get__NewEnum(@ptrCast(*const ICertificatePolicies, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificatePolicies_Add(self: *const T, pVal: ?*ICertificatePolicy) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificatePolicies.VTable, self.vtable).Add(@ptrCast(*const ICertificatePolicies, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificatePolicies_Remove(self: *const T, Index: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificatePolicies.VTable, self.vtable).Remove(@ptrCast(*const ICertificatePolicies, self), Index);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificatePolicies_Clear(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificatePolicies.VTable, self.vtable).Clear(@ptrCast(*const ICertificatePolicies, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509ExtensionCertificatePolicies_Value = @import("../../zig.zig").Guid.initString("728ab320-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509ExtensionCertificatePolicies = &IID_IX509ExtensionCertificatePolicies_Value;
pub const IX509ExtensionCertificatePolicies = extern struct {
pub const VTable = extern struct {
base: IX509Extension.VTable,
InitializeEncode: fn(
self: *const IX509ExtensionCertificatePolicies,
pValue: ?*ICertificatePolicies,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509ExtensionCertificatePolicies,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Policies: fn(
self: *const IX509ExtensionCertificatePolicies,
ppValue: ?*?*ICertificatePolicies,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509Extension.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionCertificatePolicies_InitializeEncode(self: *const T, pValue: ?*ICertificatePolicies) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionCertificatePolicies.VTable, self.vtable).InitializeEncode(@ptrCast(*const IX509ExtensionCertificatePolicies, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionCertificatePolicies_InitializeDecode(self: *const T, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionCertificatePolicies.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509ExtensionCertificatePolicies, self), Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionCertificatePolicies_get_Policies(self: *const T, ppValue: ?*?*ICertificatePolicies) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionCertificatePolicies.VTable, self.vtable).get_Policies(@ptrCast(*const IX509ExtensionCertificatePolicies, self), ppValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509ExtensionMSApplicationPolicies_Value = @import("../../zig.zig").Guid.initString("728ab321-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509ExtensionMSApplicationPolicies = &IID_IX509ExtensionMSApplicationPolicies_Value;
pub const IX509ExtensionMSApplicationPolicies = extern struct {
pub const VTable = extern struct {
base: IX509Extension.VTable,
InitializeEncode: fn(
self: *const IX509ExtensionMSApplicationPolicies,
pValue: ?*ICertificatePolicies,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509ExtensionMSApplicationPolicies,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Policies: fn(
self: *const IX509ExtensionMSApplicationPolicies,
ppValue: ?*?*ICertificatePolicies,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509Extension.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionMSApplicationPolicies_InitializeEncode(self: *const T, pValue: ?*ICertificatePolicies) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionMSApplicationPolicies.VTable, self.vtable).InitializeEncode(@ptrCast(*const IX509ExtensionMSApplicationPolicies, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionMSApplicationPolicies_InitializeDecode(self: *const T, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionMSApplicationPolicies.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509ExtensionMSApplicationPolicies, self), Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509ExtensionMSApplicationPolicies_get_Policies(self: *const T, ppValue: ?*?*ICertificatePolicies) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509ExtensionMSApplicationPolicies.VTable, self.vtable).get_Policies(@ptrCast(*const IX509ExtensionMSApplicationPolicies, self), ppValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509Attribute_Value = @import("../../zig.zig").Guid.initString("728ab322-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509Attribute = &IID_IX509Attribute_Value;
pub const IX509Attribute = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const IX509Attribute,
pObjectId: ?*IObjectId,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ObjectId: fn(
self: *const IX509Attribute,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RawData: fn(
self: *const IX509Attribute,
Encoding: EncodingType,
pValue: ?*?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 IX509Attribute_Initialize(self: *const T, pObjectId: ?*IObjectId, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Attribute.VTable, self.vtable).Initialize(@ptrCast(*const IX509Attribute, self), pObjectId, Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Attribute_get_ObjectId(self: *const T, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Attribute.VTable, self.vtable).get_ObjectId(@ptrCast(*const IX509Attribute, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Attribute_get_RawData(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Attribute.VTable, self.vtable).get_RawData(@ptrCast(*const IX509Attribute, self), Encoding, pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509Attributes_Value = @import("../../zig.zig").Guid.initString("728ab323-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509Attributes = &IID_IX509Attributes_Value;
pub const IX509Attributes = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByIndex: fn(
self: *const IX509Attributes,
Index: i32,
pVal: ?*?*IX509Attribute,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const IX509Attributes,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const IX509Attributes,
pVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const IX509Attributes,
pVal: ?*IX509Attribute,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Remove: fn(
self: *const IX509Attributes,
Index: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clear: fn(
self: *const IX509Attributes,
) 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 IX509Attributes_get_ItemByIndex(self: *const T, Index: i32, pVal: ?*?*IX509Attribute) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Attributes.VTable, self.vtable).get_ItemByIndex(@ptrCast(*const IX509Attributes, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Attributes_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Attributes.VTable, self.vtable).get_Count(@ptrCast(*const IX509Attributes, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Attributes_get__NewEnum(self: *const T, pVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Attributes.VTable, self.vtable).get__NewEnum(@ptrCast(*const IX509Attributes, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Attributes_Add(self: *const T, pVal: ?*IX509Attribute) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Attributes.VTable, self.vtable).Add(@ptrCast(*const IX509Attributes, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Attributes_Remove(self: *const T, Index: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Attributes.VTable, self.vtable).Remove(@ptrCast(*const IX509Attributes, self), Index);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Attributes_Clear(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Attributes.VTable, self.vtable).Clear(@ptrCast(*const IX509Attributes, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509AttributeExtensions_Value = @import("../../zig.zig").Guid.initString("728ab324-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509AttributeExtensions = &IID_IX509AttributeExtensions_Value;
pub const IX509AttributeExtensions = extern struct {
pub const VTable = extern struct {
base: IX509Attribute.VTable,
InitializeEncode: fn(
self: *const IX509AttributeExtensions,
pExtensions: ?*IX509Extensions,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509AttributeExtensions,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_X509Extensions: fn(
self: *const IX509AttributeExtensions,
ppValue: ?*?*IX509Extensions,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509Attribute.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeExtensions_InitializeEncode(self: *const T, pExtensions: ?*IX509Extensions) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeExtensions.VTable, self.vtable).InitializeEncode(@ptrCast(*const IX509AttributeExtensions, self), pExtensions);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeExtensions_InitializeDecode(self: *const T, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeExtensions.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509AttributeExtensions, self), Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeExtensions_get_X509Extensions(self: *const T, ppValue: ?*?*IX509Extensions) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeExtensions.VTable, self.vtable).get_X509Extensions(@ptrCast(*const IX509AttributeExtensions, self), ppValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const RequestClientInfoClientId = enum(i32) {
None = 0,
XEnroll2003 = 1,
AutoEnroll2003 = 2,
Wizard2003 = 3,
CertReq2003 = 4,
DefaultRequest = 5,
AutoEnroll = 6,
RequestWizard = 7,
EOBO = 8,
CertReq = 9,
Test = 10,
WinRT = 11,
UserStart = 1000,
};
pub const ClientIdNone = RequestClientInfoClientId.None;
pub const ClientIdXEnroll2003 = RequestClientInfoClientId.XEnroll2003;
pub const ClientIdAutoEnroll2003 = RequestClientInfoClientId.AutoEnroll2003;
pub const ClientIdWizard2003 = RequestClientInfoClientId.Wizard2003;
pub const ClientIdCertReq2003 = RequestClientInfoClientId.CertReq2003;
pub const ClientIdDefaultRequest = RequestClientInfoClientId.DefaultRequest;
pub const ClientIdAutoEnroll = RequestClientInfoClientId.AutoEnroll;
pub const ClientIdRequestWizard = RequestClientInfoClientId.RequestWizard;
pub const ClientIdEOBO = RequestClientInfoClientId.EOBO;
pub const ClientIdCertReq = RequestClientInfoClientId.CertReq;
pub const ClientIdTest = RequestClientInfoClientId.Test;
pub const ClientIdWinRT = RequestClientInfoClientId.WinRT;
pub const ClientIdUserStart = RequestClientInfoClientId.UserStart;
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509AttributeClientId_Value = @import("../../zig.zig").Guid.initString("728ab325-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509AttributeClientId = &IID_IX509AttributeClientId_Value;
pub const IX509AttributeClientId = extern struct {
pub const VTable = extern struct {
base: IX509Attribute.VTable,
InitializeEncode: fn(
self: *const IX509AttributeClientId,
ClientId: RequestClientInfoClientId,
strMachineDnsName: ?BSTR,
strUserSamName: ?BSTR,
strProcessName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509AttributeClientId,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ClientId: fn(
self: *const IX509AttributeClientId,
pValue: ?*RequestClientInfoClientId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MachineDnsName: fn(
self: *const IX509AttributeClientId,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_UserSamName: fn(
self: *const IX509AttributeClientId,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProcessName: fn(
self: *const IX509AttributeClientId,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509Attribute.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeClientId_InitializeEncode(self: *const T, ClientId: RequestClientInfoClientId, strMachineDnsName: ?BSTR, strUserSamName: ?BSTR, strProcessName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeClientId.VTable, self.vtable).InitializeEncode(@ptrCast(*const IX509AttributeClientId, self), ClientId, strMachineDnsName, strUserSamName, strProcessName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeClientId_InitializeDecode(self: *const T, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeClientId.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509AttributeClientId, self), Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeClientId_get_ClientId(self: *const T, pValue: ?*RequestClientInfoClientId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeClientId.VTable, self.vtable).get_ClientId(@ptrCast(*const IX509AttributeClientId, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeClientId_get_MachineDnsName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeClientId.VTable, self.vtable).get_MachineDnsName(@ptrCast(*const IX509AttributeClientId, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeClientId_get_UserSamName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeClientId.VTable, self.vtable).get_UserSamName(@ptrCast(*const IX509AttributeClientId, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeClientId_get_ProcessName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeClientId.VTable, self.vtable).get_ProcessName(@ptrCast(*const IX509AttributeClientId, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509AttributeRenewalCertificate_Value = @import("../../zig.zig").Guid.initString("728ab326-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509AttributeRenewalCertificate = &IID_IX509AttributeRenewalCertificate_Value;
pub const IX509AttributeRenewalCertificate = extern struct {
pub const VTable = extern struct {
base: IX509Attribute.VTable,
InitializeEncode: fn(
self: *const IX509AttributeRenewalCertificate,
Encoding: EncodingType,
strCert: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509AttributeRenewalCertificate,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RenewalCertificate: fn(
self: *const IX509AttributeRenewalCertificate,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509Attribute.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeRenewalCertificate_InitializeEncode(self: *const T, Encoding: EncodingType, strCert: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeRenewalCertificate.VTable, self.vtable).InitializeEncode(@ptrCast(*const IX509AttributeRenewalCertificate, self), Encoding, strCert);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeRenewalCertificate_InitializeDecode(self: *const T, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeRenewalCertificate.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509AttributeRenewalCertificate, self), Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeRenewalCertificate_get_RenewalCertificate(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeRenewalCertificate.VTable, self.vtable).get_RenewalCertificate(@ptrCast(*const IX509AttributeRenewalCertificate, self), Encoding, pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509AttributeArchiveKey_Value = @import("../../zig.zig").Guid.initString("728ab327-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509AttributeArchiveKey = &IID_IX509AttributeArchiveKey_Value;
pub const IX509AttributeArchiveKey = extern struct {
pub const VTable = extern struct {
base: IX509Attribute.VTable,
InitializeEncode: fn(
self: *const IX509AttributeArchiveKey,
pKey: ?*IX509PrivateKey,
Encoding: EncodingType,
strCAXCert: ?BSTR,
pAlgorithm: ?*IObjectId,
EncryptionStrength: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509AttributeArchiveKey,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EncryptedKeyBlob: fn(
self: *const IX509AttributeArchiveKey,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EncryptionAlgorithm: fn(
self: *const IX509AttributeArchiveKey,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EncryptionStrength: fn(
self: *const IX509AttributeArchiveKey,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509Attribute.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeArchiveKey_InitializeEncode(self: *const T, pKey: ?*IX509PrivateKey, Encoding: EncodingType, strCAXCert: ?BSTR, pAlgorithm: ?*IObjectId, EncryptionStrength: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeArchiveKey.VTable, self.vtable).InitializeEncode(@ptrCast(*const IX509AttributeArchiveKey, self), pKey, Encoding, strCAXCert, pAlgorithm, EncryptionStrength);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeArchiveKey_InitializeDecode(self: *const T, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeArchiveKey.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509AttributeArchiveKey, self), Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeArchiveKey_get_EncryptedKeyBlob(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeArchiveKey.VTable, self.vtable).get_EncryptedKeyBlob(@ptrCast(*const IX509AttributeArchiveKey, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeArchiveKey_get_EncryptionAlgorithm(self: *const T, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeArchiveKey.VTable, self.vtable).get_EncryptionAlgorithm(@ptrCast(*const IX509AttributeArchiveKey, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeArchiveKey_get_EncryptionStrength(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeArchiveKey.VTable, self.vtable).get_EncryptionStrength(@ptrCast(*const IX509AttributeArchiveKey, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509AttributeArchiveKeyHash_Value = @import("../../zig.zig").Guid.initString("728ab328-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509AttributeArchiveKeyHash = &IID_IX509AttributeArchiveKeyHash_Value;
pub const IX509AttributeArchiveKeyHash = extern struct {
pub const VTable = extern struct {
base: IX509Attribute.VTable,
InitializeEncodeFromEncryptedKeyBlob: fn(
self: *const IX509AttributeArchiveKeyHash,
Encoding: EncodingType,
strEncryptedKeyBlob: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509AttributeArchiveKeyHash,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EncryptedKeyHashBlob: fn(
self: *const IX509AttributeArchiveKeyHash,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509Attribute.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeArchiveKeyHash_InitializeEncodeFromEncryptedKeyBlob(self: *const T, Encoding: EncodingType, strEncryptedKeyBlob: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeArchiveKeyHash.VTable, self.vtable).InitializeEncodeFromEncryptedKeyBlob(@ptrCast(*const IX509AttributeArchiveKeyHash, self), Encoding, strEncryptedKeyBlob);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeArchiveKeyHash_InitializeDecode(self: *const T, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeArchiveKeyHash.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509AttributeArchiveKeyHash, self), Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeArchiveKeyHash_get_EncryptedKeyHashBlob(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeArchiveKeyHash.VTable, self.vtable).get_EncryptedKeyHashBlob(@ptrCast(*const IX509AttributeArchiveKeyHash, self), Encoding, pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509AttributeOSVersion_Value = @import("../../zig.zig").Guid.initString("728ab32a-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509AttributeOSVersion = &IID_IX509AttributeOSVersion_Value;
pub const IX509AttributeOSVersion = extern struct {
pub const VTable = extern struct {
base: IX509Attribute.VTable,
InitializeEncode: fn(
self: *const IX509AttributeOSVersion,
strOSVersion: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509AttributeOSVersion,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_OSVersion: fn(
self: *const IX509AttributeOSVersion,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509Attribute.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeOSVersion_InitializeEncode(self: *const T, strOSVersion: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeOSVersion.VTable, self.vtable).InitializeEncode(@ptrCast(*const IX509AttributeOSVersion, self), strOSVersion);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeOSVersion_InitializeDecode(self: *const T, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeOSVersion.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509AttributeOSVersion, self), Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeOSVersion_get_OSVersion(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeOSVersion.VTable, self.vtable).get_OSVersion(@ptrCast(*const IX509AttributeOSVersion, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509AttributeCspProvider_Value = @import("../../zig.zig").Guid.initString("728ab32b-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509AttributeCspProvider = &IID_IX509AttributeCspProvider_Value;
pub const IX509AttributeCspProvider = extern struct {
pub const VTable = extern struct {
base: IX509Attribute.VTable,
InitializeEncode: fn(
self: *const IX509AttributeCspProvider,
KeySpec: X509KeySpec,
strProviderName: ?BSTR,
Encoding: EncodingType,
strSignature: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509AttributeCspProvider,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_KeySpec: fn(
self: *const IX509AttributeCspProvider,
pValue: ?*X509KeySpec,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProviderName: fn(
self: *const IX509AttributeCspProvider,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Signature: fn(
self: *const IX509AttributeCspProvider,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509Attribute.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeCspProvider_InitializeEncode(self: *const T, KeySpec: X509KeySpec, strProviderName: ?BSTR, Encoding: EncodingType, strSignature: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeCspProvider.VTable, self.vtable).InitializeEncode(@ptrCast(*const IX509AttributeCspProvider, self), KeySpec, strProviderName, Encoding, strSignature);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeCspProvider_InitializeDecode(self: *const T, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeCspProvider.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509AttributeCspProvider, self), Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeCspProvider_get_KeySpec(self: *const T, pValue: ?*X509KeySpec) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeCspProvider.VTable, self.vtable).get_KeySpec(@ptrCast(*const IX509AttributeCspProvider, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeCspProvider_get_ProviderName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeCspProvider.VTable, self.vtable).get_ProviderName(@ptrCast(*const IX509AttributeCspProvider, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509AttributeCspProvider_get_Signature(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509AttributeCspProvider.VTable, self.vtable).get_Signature(@ptrCast(*const IX509AttributeCspProvider, self), Encoding, pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICryptAttribute_Value = @import("../../zig.zig").Guid.initString("728ab32c-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICryptAttribute = &IID_ICryptAttribute_Value;
pub const ICryptAttribute = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
InitializeFromObjectId: fn(
self: *const ICryptAttribute,
pObjectId: ?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromValues: fn(
self: *const ICryptAttribute,
pAttributes: ?*IX509Attributes,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ObjectId: fn(
self: *const ICryptAttribute,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Values: fn(
self: *const ICryptAttribute,
ppValue: ?*?*IX509Attributes,
) 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 ICryptAttribute_InitializeFromObjectId(self: *const T, pObjectId: ?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const ICryptAttribute.VTable, self.vtable).InitializeFromObjectId(@ptrCast(*const ICryptAttribute, self), pObjectId);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICryptAttribute_InitializeFromValues(self: *const T, pAttributes: ?*IX509Attributes) callconv(.Inline) HRESULT {
return @ptrCast(*const ICryptAttribute.VTable, self.vtable).InitializeFromValues(@ptrCast(*const ICryptAttribute, self), pAttributes);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICryptAttribute_get_ObjectId(self: *const T, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const ICryptAttribute.VTable, self.vtable).get_ObjectId(@ptrCast(*const ICryptAttribute, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICryptAttribute_get_Values(self: *const T, ppValue: ?*?*IX509Attributes) callconv(.Inline) HRESULT {
return @ptrCast(*const ICryptAttribute.VTable, self.vtable).get_Values(@ptrCast(*const ICryptAttribute, self), ppValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICryptAttributes_Value = @import("../../zig.zig").Guid.initString("728ab32d-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICryptAttributes = &IID_ICryptAttributes_Value;
pub const ICryptAttributes = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByIndex: fn(
self: *const ICryptAttributes,
Index: i32,
pVal: ?*?*ICryptAttribute,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const ICryptAttributes,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const ICryptAttributes,
pVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const ICryptAttributes,
pVal: ?*ICryptAttribute,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Remove: fn(
self: *const ICryptAttributes,
Index: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clear: fn(
self: *const ICryptAttributes,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IndexByObjectId: fn(
self: *const ICryptAttributes,
pObjectId: ?*IObjectId,
pIndex: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddRange: fn(
self: *const ICryptAttributes,
pValue: ?*ICryptAttributes,
) 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 ICryptAttributes_get_ItemByIndex(self: *const T, Index: i32, pVal: ?*?*ICryptAttribute) callconv(.Inline) HRESULT {
return @ptrCast(*const ICryptAttributes.VTable, self.vtable).get_ItemByIndex(@ptrCast(*const ICryptAttributes, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICryptAttributes_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICryptAttributes.VTable, self.vtable).get_Count(@ptrCast(*const ICryptAttributes, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICryptAttributes_get__NewEnum(self: *const T, pVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const ICryptAttributes.VTable, self.vtable).get__NewEnum(@ptrCast(*const ICryptAttributes, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICryptAttributes_Add(self: *const T, pVal: ?*ICryptAttribute) callconv(.Inline) HRESULT {
return @ptrCast(*const ICryptAttributes.VTable, self.vtable).Add(@ptrCast(*const ICryptAttributes, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICryptAttributes_Remove(self: *const T, Index: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICryptAttributes.VTable, self.vtable).Remove(@ptrCast(*const ICryptAttributes, self), Index);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICryptAttributes_Clear(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICryptAttributes.VTable, self.vtable).Clear(@ptrCast(*const ICryptAttributes, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICryptAttributes_get_IndexByObjectId(self: *const T, pObjectId: ?*IObjectId, pIndex: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICryptAttributes.VTable, self.vtable).get_IndexByObjectId(@ptrCast(*const ICryptAttributes, self), pObjectId, pIndex);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICryptAttributes_AddRange(self: *const T, pValue: ?*ICryptAttributes) callconv(.Inline) HRESULT {
return @ptrCast(*const ICryptAttributes.VTable, self.vtable).AddRange(@ptrCast(*const ICryptAttributes, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const CERTENROLL_PROPERTYID = enum(i32) {
PROPERTYID_NONE = 0,
CERT_KEY_PROV_HANDLE_PROP_ID = 1,
CERT_KEY_PROV_INFO_PROP_ID = 2,
CERT_SHA1_HASH_PROP_ID = 3,
CERT_MD5_HASH_PROP_ID = 4,
// CERT_HASH_PROP_ID = 3, this enum value conflicts with CERT_SHA1_HASH_PROP_ID
CERT_KEY_CONTEXT_PROP_ID = 5,
CERT_KEY_SPEC_PROP_ID = 6,
CERT_IE30_RESERVED_PROP_ID = 7,
CERT_PUBKEY_HASH_RESERVED_PROP_ID = 8,
CERT_ENHKEY_USAGE_PROP_ID = 9,
// CERT_CTL_USAGE_PROP_ID = 9, this enum value conflicts with CERT_ENHKEY_USAGE_PROP_ID
CERT_NEXT_UPDATE_LOCATION_PROP_ID = 10,
CERT_FRIENDLY_NAME_PROP_ID = 11,
CERT_PVK_FILE_PROP_ID = 12,
CERT_DESCRIPTION_PROP_ID = 13,
CERT_ACCESS_STATE_PROP_ID = 14,
CERT_SIGNATURE_HASH_PROP_ID = 15,
CERT_SMART_CARD_DATA_PROP_ID = 16,
CERT_EFS_PROP_ID = 17,
CERT_FORTEZZA_DATA_PROP_ID = 18,
CERT_ARCHIVED_PROP_ID = 19,
CERT_KEY_IDENTIFIER_PROP_ID = 20,
CERT_AUTO_ENROLL_PROP_ID = 21,
CERT_PUBKEY_ALG_PARA_PROP_ID = 22,
CERT_CROSS_CERT_DIST_POINTS_PROP_ID = 23,
CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID = 24,
CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID = 25,
CERT_ENROLLMENT_PROP_ID = 26,
CERT_DATE_STAMP_PROP_ID = 27,
CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID = 28,
CERT_SUBJECT_NAME_MD5_HASH_PROP_ID = 29,
CERT_EXTENDED_ERROR_INFO_PROP_ID = 30,
CERT_RENEWAL_PROP_ID = 64,
CERT_ARCHIVED_KEY_HASH_PROP_ID = 65,
CERT_AUTO_ENROLL_RETRY_PROP_ID = 66,
CERT_AIA_URL_RETRIEVED_PROP_ID = 67,
CERT_AUTHORITY_INFO_ACCESS_PROP_ID = 68,
CERT_BACKED_UP_PROP_ID = 69,
CERT_OCSP_RESPONSE_PROP_ID = 70,
CERT_REQUEST_ORIGINATOR_PROP_ID = 71,
CERT_SOURCE_LOCATION_PROP_ID = 72,
CERT_SOURCE_URL_PROP_ID = 73,
CERT_NEW_KEY_PROP_ID = 74,
CERT_OCSP_CACHE_PREFIX_PROP_ID = 75,
CERT_SMART_CARD_ROOT_INFO_PROP_ID = 76,
CERT_NO_AUTO_EXPIRE_CHECK_PROP_ID = 77,
CERT_NCRYPT_KEY_HANDLE_PROP_ID = 78,
CERT_HCRYPTPROV_OR_NCRYPT_KEY_HANDLE_PROP_ID = 79,
CERT_SUBJECT_INFO_ACCESS_PROP_ID = 80,
CERT_CA_OCSP_AUTHORITY_INFO_ACCESS_PROP_ID = 81,
CERT_CA_DISABLE_CRL_PROP_ID = 82,
CERT_ROOT_PROGRAM_CERT_POLICIES_PROP_ID = 83,
CERT_ROOT_PROGRAM_NAME_CONSTRAINTS_PROP_ID = 84,
CERT_SUBJECT_OCSP_AUTHORITY_INFO_ACCESS_PROP_ID = 85,
CERT_SUBJECT_DISABLE_CRL_PROP_ID = 86,
CERT_CEP_PROP_ID = 87,
CERT_SIGN_HASH_CNG_ALG_PROP_ID = 89,
CERT_SCARD_PIN_ID_PROP_ID = 90,
CERT_SCARD_PIN_INFO_PROP_ID = 91,
CERT_SUBJECT_PUB_KEY_BIT_LENGTH_PROP_ID = 92,
CERT_PUB_KEY_CNG_ALG_BIT_LENGTH_PROP_ID = 93,
CERT_ISSUER_PUB_KEY_BIT_LENGTH_PROP_ID = 94,
CERT_ISSUER_CHAIN_SIGN_HASH_CNG_ALG_PROP_ID = 95,
CERT_ISSUER_CHAIN_PUB_KEY_CNG_ALG_BIT_LENGTH_PROP_ID = 96,
CERT_NO_EXPIRE_NOTIFICATION_PROP_ID = 97,
CERT_AUTH_ROOT_SHA256_HASH_PROP_ID = 98,
CERT_NCRYPT_KEY_HANDLE_TRANSFER_PROP_ID = 99,
CERT_HCRYPTPROV_TRANSFER_PROP_ID = 100,
CERT_SMART_CARD_READER_PROP_ID = 101,
CERT_SEND_AS_TRUSTED_ISSUER_PROP_ID = 102,
CERT_KEY_REPAIR_ATTEMPTED_PROP_ID = 103,
CERT_DISALLOWED_FILETIME_PROP_ID = 104,
CERT_ROOT_PROGRAM_CHAIN_POLICIES_PROP_ID = 105,
CERT_SMART_CARD_READER_NON_REMOVABLE_PROP_ID = 106,
CERT_SHA256_HASH_PROP_ID = 107,
CERT_SCEP_SERVER_CERTS_PROP_ID = 108,
CERT_SCEP_RA_SIGNATURE_CERT_PROP_ID = 109,
CERT_SCEP_RA_ENCRYPTION_CERT_PROP_ID = 110,
CERT_SCEP_CA_CERT_PROP_ID = 111,
CERT_SCEP_SIGNER_CERT_PROP_ID = 112,
CERT_SCEP_NONCE_PROP_ID = 113,
CERT_SCEP_ENCRYPT_HASH_CNG_ALG_PROP_ID = 114,
CERT_SCEP_FLAGS_PROP_ID = 115,
CERT_SCEP_GUID_PROP_ID = 116,
CERT_SERIALIZABLE_KEY_CONTEXT_PROP_ID = 117,
CERT_ISOLATED_KEY_PROP_ID = 118,
CERT_SERIAL_CHAIN_PROP_ID = 119,
CERT_KEY_CLASSIFICATION_PROP_ID = 120,
CERT_DISALLOWED_ENHKEY_USAGE_PROP_ID = 122,
CERT_NONCOMPLIANT_ROOT_URL_PROP_ID = 123,
CERT_PIN_SHA256_HASH_PROP_ID = 124,
CERT_CLR_DELETE_KEY_PROP_ID = 125,
CERT_NOT_BEFORE_FILETIME_PROP_ID = 126,
CERT_CERT_NOT_BEFORE_ENHKEY_USAGE_PROP_ID = 127,
CERT_FIRST_RESERVED_PROP_ID = 128,
CERT_LAST_RESERVED_PROP_ID = 32767,
CERT_FIRST_USER_PROP_ID = 32768,
CERT_LAST_USER_PROP_ID = 65535,
CERT_STORE_LOCALIZED_NAME_PROP_ID = 4096,
};
pub const XCN_PROPERTYID_NONE = CERTENROLL_PROPERTYID.PROPERTYID_NONE;
pub const XCN_CERT_KEY_PROV_HANDLE_PROP_ID = CERTENROLL_PROPERTYID.CERT_KEY_PROV_HANDLE_PROP_ID;
pub const XCN_CERT_KEY_PROV_INFO_PROP_ID = CERTENROLL_PROPERTYID.CERT_KEY_PROV_INFO_PROP_ID;
pub const XCN_CERT_SHA1_HASH_PROP_ID = CERTENROLL_PROPERTYID.CERT_SHA1_HASH_PROP_ID;
pub const XCN_CERT_MD5_HASH_PROP_ID = CERTENROLL_PROPERTYID.CERT_MD5_HASH_PROP_ID;
pub const XCN_CERT_HASH_PROP_ID = CERTENROLL_PROPERTYID.CERT_SHA1_HASH_PROP_ID;
pub const XCN_CERT_KEY_CONTEXT_PROP_ID = CERTENROLL_PROPERTYID.CERT_KEY_CONTEXT_PROP_ID;
pub const XCN_CERT_KEY_SPEC_PROP_ID = CERTENROLL_PROPERTYID.CERT_KEY_SPEC_PROP_ID;
pub const XCN_CERT_IE30_RESERVED_PROP_ID = CERTENROLL_PROPERTYID.CERT_IE30_RESERVED_PROP_ID;
pub const XCN_CERT_PUBKEY_HASH_RESERVED_PROP_ID = CERTENROLL_PROPERTYID.CERT_PUBKEY_HASH_RESERVED_PROP_ID;
pub const XCN_CERT_ENHKEY_USAGE_PROP_ID = CERTENROLL_PROPERTYID.CERT_ENHKEY_USAGE_PROP_ID;
pub const XCN_CERT_CTL_USAGE_PROP_ID = CERTENROLL_PROPERTYID.CERT_ENHKEY_USAGE_PROP_ID;
pub const XCN_CERT_NEXT_UPDATE_LOCATION_PROP_ID = CERTENROLL_PROPERTYID.CERT_NEXT_UPDATE_LOCATION_PROP_ID;
pub const XCN_CERT_FRIENDLY_NAME_PROP_ID = CERTENROLL_PROPERTYID.CERT_FRIENDLY_NAME_PROP_ID;
pub const XCN_CERT_PVK_FILE_PROP_ID = CERTENROLL_PROPERTYID.CERT_PVK_FILE_PROP_ID;
pub const XCN_CERT_DESCRIPTION_PROP_ID = CERTENROLL_PROPERTYID.CERT_DESCRIPTION_PROP_ID;
pub const XCN_CERT_ACCESS_STATE_PROP_ID = CERTENROLL_PROPERTYID.CERT_ACCESS_STATE_PROP_ID;
pub const XCN_CERT_SIGNATURE_HASH_PROP_ID = CERTENROLL_PROPERTYID.CERT_SIGNATURE_HASH_PROP_ID;
pub const XCN_CERT_SMART_CARD_DATA_PROP_ID = CERTENROLL_PROPERTYID.CERT_SMART_CARD_DATA_PROP_ID;
pub const XCN_CERT_EFS_PROP_ID = CERTENROLL_PROPERTYID.CERT_EFS_PROP_ID;
pub const XCN_CERT_FORTEZZA_DATA_PROP_ID = CERTENROLL_PROPERTYID.CERT_FORTEZZA_DATA_PROP_ID;
pub const XCN_CERT_ARCHIVED_PROP_ID = CERTENROLL_PROPERTYID.CERT_ARCHIVED_PROP_ID;
pub const XCN_CERT_KEY_IDENTIFIER_PROP_ID = CERTENROLL_PROPERTYID.CERT_KEY_IDENTIFIER_PROP_ID;
pub const XCN_CERT_AUTO_ENROLL_PROP_ID = CERTENROLL_PROPERTYID.CERT_AUTO_ENROLL_PROP_ID;
pub const XCN_CERT_PUBKEY_ALG_PARA_PROP_ID = CERTENROLL_PROPERTYID.CERT_PUBKEY_ALG_PARA_PROP_ID;
pub const XCN_CERT_CROSS_CERT_DIST_POINTS_PROP_ID = CERTENROLL_PROPERTYID.CERT_CROSS_CERT_DIST_POINTS_PROP_ID;
pub const XCN_CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID = CERTENROLL_PROPERTYID.CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID;
pub const XCN_CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID = CERTENROLL_PROPERTYID.CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID;
pub const XCN_CERT_ENROLLMENT_PROP_ID = CERTENROLL_PROPERTYID.CERT_ENROLLMENT_PROP_ID;
pub const XCN_CERT_DATE_STAMP_PROP_ID = CERTENROLL_PROPERTYID.CERT_DATE_STAMP_PROP_ID;
pub const XCN_CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID = CERTENROLL_PROPERTYID.CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID;
pub const XCN_CERT_SUBJECT_NAME_MD5_HASH_PROP_ID = CERTENROLL_PROPERTYID.CERT_SUBJECT_NAME_MD5_HASH_PROP_ID;
pub const XCN_CERT_EXTENDED_ERROR_INFO_PROP_ID = CERTENROLL_PROPERTYID.CERT_EXTENDED_ERROR_INFO_PROP_ID;
pub const XCN_CERT_RENEWAL_PROP_ID = CERTENROLL_PROPERTYID.CERT_RENEWAL_PROP_ID;
pub const XCN_CERT_ARCHIVED_KEY_HASH_PROP_ID = CERTENROLL_PROPERTYID.CERT_ARCHIVED_KEY_HASH_PROP_ID;
pub const XCN_CERT_AUTO_ENROLL_RETRY_PROP_ID = CERTENROLL_PROPERTYID.CERT_AUTO_ENROLL_RETRY_PROP_ID;
pub const XCN_CERT_AIA_URL_RETRIEVED_PROP_ID = CERTENROLL_PROPERTYID.CERT_AIA_URL_RETRIEVED_PROP_ID;
pub const XCN_CERT_AUTHORITY_INFO_ACCESS_PROP_ID = CERTENROLL_PROPERTYID.CERT_AUTHORITY_INFO_ACCESS_PROP_ID;
pub const XCN_CERT_BACKED_UP_PROP_ID = CERTENROLL_PROPERTYID.CERT_BACKED_UP_PROP_ID;
pub const XCN_CERT_OCSP_RESPONSE_PROP_ID = CERTENROLL_PROPERTYID.CERT_OCSP_RESPONSE_PROP_ID;
pub const XCN_CERT_REQUEST_ORIGINATOR_PROP_ID = CERTENROLL_PROPERTYID.CERT_REQUEST_ORIGINATOR_PROP_ID;
pub const XCN_CERT_SOURCE_LOCATION_PROP_ID = CERTENROLL_PROPERTYID.CERT_SOURCE_LOCATION_PROP_ID;
pub const XCN_CERT_SOURCE_URL_PROP_ID = CERTENROLL_PROPERTYID.CERT_SOURCE_URL_PROP_ID;
pub const XCN_CERT_NEW_KEY_PROP_ID = CERTENROLL_PROPERTYID.CERT_NEW_KEY_PROP_ID;
pub const XCN_CERT_OCSP_CACHE_PREFIX_PROP_ID = CERTENROLL_PROPERTYID.CERT_OCSP_CACHE_PREFIX_PROP_ID;
pub const XCN_CERT_SMART_CARD_ROOT_INFO_PROP_ID = CERTENROLL_PROPERTYID.CERT_SMART_CARD_ROOT_INFO_PROP_ID;
pub const XCN_CERT_NO_AUTO_EXPIRE_CHECK_PROP_ID = CERTENROLL_PROPERTYID.CERT_NO_AUTO_EXPIRE_CHECK_PROP_ID;
pub const XCN_CERT_NCRYPT_KEY_HANDLE_PROP_ID = CERTENROLL_PROPERTYID.CERT_NCRYPT_KEY_HANDLE_PROP_ID;
pub const XCN_CERT_HCRYPTPROV_OR_NCRYPT_KEY_HANDLE_PROP_ID = CERTENROLL_PROPERTYID.CERT_HCRYPTPROV_OR_NCRYPT_KEY_HANDLE_PROP_ID;
pub const XCN_CERT_SUBJECT_INFO_ACCESS_PROP_ID = CERTENROLL_PROPERTYID.CERT_SUBJECT_INFO_ACCESS_PROP_ID;
pub const XCN_CERT_CA_OCSP_AUTHORITY_INFO_ACCESS_PROP_ID = CERTENROLL_PROPERTYID.CERT_CA_OCSP_AUTHORITY_INFO_ACCESS_PROP_ID;
pub const XCN_CERT_CA_DISABLE_CRL_PROP_ID = CERTENROLL_PROPERTYID.CERT_CA_DISABLE_CRL_PROP_ID;
pub const XCN_CERT_ROOT_PROGRAM_CERT_POLICIES_PROP_ID = CERTENROLL_PROPERTYID.CERT_ROOT_PROGRAM_CERT_POLICIES_PROP_ID;
pub const XCN_CERT_ROOT_PROGRAM_NAME_CONSTRAINTS_PROP_ID = CERTENROLL_PROPERTYID.CERT_ROOT_PROGRAM_NAME_CONSTRAINTS_PROP_ID;
pub const XCN_CERT_SUBJECT_OCSP_AUTHORITY_INFO_ACCESS_PROP_ID = CERTENROLL_PROPERTYID.CERT_SUBJECT_OCSP_AUTHORITY_INFO_ACCESS_PROP_ID;
pub const XCN_CERT_SUBJECT_DISABLE_CRL_PROP_ID = CERTENROLL_PROPERTYID.CERT_SUBJECT_DISABLE_CRL_PROP_ID;
pub const XCN_CERT_CEP_PROP_ID = CERTENROLL_PROPERTYID.CERT_CEP_PROP_ID;
pub const XCN_CERT_SIGN_HASH_CNG_ALG_PROP_ID = CERTENROLL_PROPERTYID.CERT_SIGN_HASH_CNG_ALG_PROP_ID;
pub const XCN_CERT_SCARD_PIN_ID_PROP_ID = CERTENROLL_PROPERTYID.CERT_SCARD_PIN_ID_PROP_ID;
pub const XCN_CERT_SCARD_PIN_INFO_PROP_ID = CERTENROLL_PROPERTYID.CERT_SCARD_PIN_INFO_PROP_ID;
pub const XCN_CERT_SUBJECT_PUB_KEY_BIT_LENGTH_PROP_ID = CERTENROLL_PROPERTYID.CERT_SUBJECT_PUB_KEY_BIT_LENGTH_PROP_ID;
pub const XCN_CERT_PUB_KEY_CNG_ALG_BIT_LENGTH_PROP_ID = CERTENROLL_PROPERTYID.CERT_PUB_KEY_CNG_ALG_BIT_LENGTH_PROP_ID;
pub const XCN_CERT_ISSUER_PUB_KEY_BIT_LENGTH_PROP_ID = CERTENROLL_PROPERTYID.CERT_ISSUER_PUB_KEY_BIT_LENGTH_PROP_ID;
pub const XCN_CERT_ISSUER_CHAIN_SIGN_HASH_CNG_ALG_PROP_ID = CERTENROLL_PROPERTYID.CERT_ISSUER_CHAIN_SIGN_HASH_CNG_ALG_PROP_ID;
pub const XCN_CERT_ISSUER_CHAIN_PUB_KEY_CNG_ALG_BIT_LENGTH_PROP_ID = CERTENROLL_PROPERTYID.CERT_ISSUER_CHAIN_PUB_KEY_CNG_ALG_BIT_LENGTH_PROP_ID;
pub const XCN_CERT_NO_EXPIRE_NOTIFICATION_PROP_ID = CERTENROLL_PROPERTYID.CERT_NO_EXPIRE_NOTIFICATION_PROP_ID;
pub const XCN_CERT_AUTH_ROOT_SHA256_HASH_PROP_ID = CERTENROLL_PROPERTYID.CERT_AUTH_ROOT_SHA256_HASH_PROP_ID;
pub const XCN_CERT_NCRYPT_KEY_HANDLE_TRANSFER_PROP_ID = CERTENROLL_PROPERTYID.CERT_NCRYPT_KEY_HANDLE_TRANSFER_PROP_ID;
pub const XCN_CERT_HCRYPTPROV_TRANSFER_PROP_ID = CERTENROLL_PROPERTYID.CERT_HCRYPTPROV_TRANSFER_PROP_ID;
pub const XCN_CERT_SMART_CARD_READER_PROP_ID = CERTENROLL_PROPERTYID.CERT_SMART_CARD_READER_PROP_ID;
pub const XCN_CERT_SEND_AS_TRUSTED_ISSUER_PROP_ID = CERTENROLL_PROPERTYID.CERT_SEND_AS_TRUSTED_ISSUER_PROP_ID;
pub const XCN_CERT_KEY_REPAIR_ATTEMPTED_PROP_ID = CERTENROLL_PROPERTYID.CERT_KEY_REPAIR_ATTEMPTED_PROP_ID;
pub const XCN_CERT_DISALLOWED_FILETIME_PROP_ID = CERTENROLL_PROPERTYID.CERT_DISALLOWED_FILETIME_PROP_ID;
pub const XCN_CERT_ROOT_PROGRAM_CHAIN_POLICIES_PROP_ID = CERTENROLL_PROPERTYID.CERT_ROOT_PROGRAM_CHAIN_POLICIES_PROP_ID;
pub const XCN_CERT_SMART_CARD_READER_NON_REMOVABLE_PROP_ID = CERTENROLL_PROPERTYID.CERT_SMART_CARD_READER_NON_REMOVABLE_PROP_ID;
pub const XCN_CERT_SHA256_HASH_PROP_ID = CERTENROLL_PROPERTYID.CERT_SHA256_HASH_PROP_ID;
pub const XCN_CERT_SCEP_SERVER_CERTS_PROP_ID = CERTENROLL_PROPERTYID.CERT_SCEP_SERVER_CERTS_PROP_ID;
pub const XCN_CERT_SCEP_RA_SIGNATURE_CERT_PROP_ID = CERTENROLL_PROPERTYID.CERT_SCEP_RA_SIGNATURE_CERT_PROP_ID;
pub const XCN_CERT_SCEP_RA_ENCRYPTION_CERT_PROP_ID = CERTENROLL_PROPERTYID.CERT_SCEP_RA_ENCRYPTION_CERT_PROP_ID;
pub const XCN_CERT_SCEP_CA_CERT_PROP_ID = CERTENROLL_PROPERTYID.CERT_SCEP_CA_CERT_PROP_ID;
pub const XCN_CERT_SCEP_SIGNER_CERT_PROP_ID = CERTENROLL_PROPERTYID.CERT_SCEP_SIGNER_CERT_PROP_ID;
pub const XCN_CERT_SCEP_NONCE_PROP_ID = CERTENROLL_PROPERTYID.CERT_SCEP_NONCE_PROP_ID;
pub const XCN_CERT_SCEP_ENCRYPT_HASH_CNG_ALG_PROP_ID = CERTENROLL_PROPERTYID.CERT_SCEP_ENCRYPT_HASH_CNG_ALG_PROP_ID;
pub const XCN_CERT_SCEP_FLAGS_PROP_ID = CERTENROLL_PROPERTYID.CERT_SCEP_FLAGS_PROP_ID;
pub const XCN_CERT_SCEP_GUID_PROP_ID = CERTENROLL_PROPERTYID.CERT_SCEP_GUID_PROP_ID;
pub const XCN_CERT_SERIALIZABLE_KEY_CONTEXT_PROP_ID = CERTENROLL_PROPERTYID.CERT_SERIALIZABLE_KEY_CONTEXT_PROP_ID;
pub const XCN_CERT_ISOLATED_KEY_PROP_ID = CERTENROLL_PROPERTYID.CERT_ISOLATED_KEY_PROP_ID;
pub const XCN_CERT_SERIAL_CHAIN_PROP_ID = CERTENROLL_PROPERTYID.CERT_SERIAL_CHAIN_PROP_ID;
pub const XCN_CERT_KEY_CLASSIFICATION_PROP_ID = CERTENROLL_PROPERTYID.CERT_KEY_CLASSIFICATION_PROP_ID;
pub const XCN_CERT_DISALLOWED_ENHKEY_USAGE_PROP_ID = CERTENROLL_PROPERTYID.CERT_DISALLOWED_ENHKEY_USAGE_PROP_ID;
pub const XCN_CERT_NONCOMPLIANT_ROOT_URL_PROP_ID = CERTENROLL_PROPERTYID.CERT_NONCOMPLIANT_ROOT_URL_PROP_ID;
pub const XCN_CERT_PIN_SHA256_HASH_PROP_ID = CERTENROLL_PROPERTYID.CERT_PIN_SHA256_HASH_PROP_ID;
pub const XCN_CERT_CLR_DELETE_KEY_PROP_ID = CERTENROLL_PROPERTYID.CERT_CLR_DELETE_KEY_PROP_ID;
pub const XCN_CERT_NOT_BEFORE_FILETIME_PROP_ID = CERTENROLL_PROPERTYID.CERT_NOT_BEFORE_FILETIME_PROP_ID;
pub const XCN_CERT_CERT_NOT_BEFORE_ENHKEY_USAGE_PROP_ID = CERTENROLL_PROPERTYID.CERT_CERT_NOT_BEFORE_ENHKEY_USAGE_PROP_ID;
pub const XCN_CERT_FIRST_RESERVED_PROP_ID = CERTENROLL_PROPERTYID.CERT_FIRST_RESERVED_PROP_ID;
pub const XCN_CERT_LAST_RESERVED_PROP_ID = CERTENROLL_PROPERTYID.CERT_LAST_RESERVED_PROP_ID;
pub const XCN_CERT_FIRST_USER_PROP_ID = CERTENROLL_PROPERTYID.CERT_FIRST_USER_PROP_ID;
pub const XCN_CERT_LAST_USER_PROP_ID = CERTENROLL_PROPERTYID.CERT_LAST_USER_PROP_ID;
pub const XCN_CERT_STORE_LOCALIZED_NAME_PROP_ID = CERTENROLL_PROPERTYID.CERT_STORE_LOCALIZED_NAME_PROP_ID;
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICertProperty_Value = @import("../../zig.zig").Guid.initString("728ab32e-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICertProperty = &IID_ICertProperty_Value;
pub const ICertProperty = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
InitializeFromCertificate: fn(
self: *const ICertProperty,
MachineContext: i16,
Encoding: EncodingType,
strCertificate: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const ICertProperty,
Encoding: EncodingType,
strEncodedData: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PropertyId: fn(
self: *const ICertProperty,
pValue: ?*CERTENROLL_PROPERTYID,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_PropertyId: fn(
self: *const ICertProperty,
Value: CERTENROLL_PROPERTYID,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RawData: fn(
self: *const ICertProperty,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
RemoveFromCertificate: fn(
self: *const ICertProperty,
MachineContext: i16,
Encoding: EncodingType,
strCertificate: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetValueOnCertificate: fn(
self: *const ICertProperty,
MachineContext: i16,
Encoding: EncodingType,
strCertificate: ?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 ICertProperty_InitializeFromCertificate(self: *const T, MachineContext: i16, Encoding: EncodingType, strCertificate: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertProperty.VTable, self.vtable).InitializeFromCertificate(@ptrCast(*const ICertProperty, self), MachineContext, Encoding, strCertificate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertProperty_InitializeDecode(self: *const T, Encoding: EncodingType, strEncodedData: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertProperty.VTable, self.vtable).InitializeDecode(@ptrCast(*const ICertProperty, self), Encoding, strEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertProperty_get_PropertyId(self: *const T, pValue: ?*CERTENROLL_PROPERTYID) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertProperty.VTable, self.vtable).get_PropertyId(@ptrCast(*const ICertProperty, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertProperty_put_PropertyId(self: *const T, Value: CERTENROLL_PROPERTYID) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertProperty.VTable, self.vtable).put_PropertyId(@ptrCast(*const ICertProperty, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertProperty_get_RawData(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertProperty.VTable, self.vtable).get_RawData(@ptrCast(*const ICertProperty, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertProperty_RemoveFromCertificate(self: *const T, MachineContext: i16, Encoding: EncodingType, strCertificate: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertProperty.VTable, self.vtable).RemoveFromCertificate(@ptrCast(*const ICertProperty, self), MachineContext, Encoding, strCertificate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertProperty_SetValueOnCertificate(self: *const T, MachineContext: i16, Encoding: EncodingType, strCertificate: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertProperty.VTable, self.vtable).SetValueOnCertificate(@ptrCast(*const ICertProperty, self), MachineContext, Encoding, strCertificate);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICertProperties_Value = @import("../../zig.zig").Guid.initString("728ab32f-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICertProperties = &IID_ICertProperties_Value;
pub const ICertProperties = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByIndex: fn(
self: *const ICertProperties,
Index: i32,
pVal: ?*?*ICertProperty,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const ICertProperties,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const ICertProperties,
pVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const ICertProperties,
pVal: ?*ICertProperty,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Remove: fn(
self: *const ICertProperties,
Index: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clear: fn(
self: *const ICertProperties,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromCertificate: fn(
self: *const ICertProperties,
MachineContext: i16,
Encoding: EncodingType,
strCertificate: ?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 ICertProperties_get_ItemByIndex(self: *const T, Index: i32, pVal: ?*?*ICertProperty) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertProperties.VTable, self.vtable).get_ItemByIndex(@ptrCast(*const ICertProperties, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertProperties_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertProperties.VTable, self.vtable).get_Count(@ptrCast(*const ICertProperties, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertProperties_get__NewEnum(self: *const T, pVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertProperties.VTable, self.vtable).get__NewEnum(@ptrCast(*const ICertProperties, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertProperties_Add(self: *const T, pVal: ?*ICertProperty) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertProperties.VTable, self.vtable).Add(@ptrCast(*const ICertProperties, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertProperties_Remove(self: *const T, Index: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertProperties.VTable, self.vtable).Remove(@ptrCast(*const ICertProperties, self), Index);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertProperties_Clear(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertProperties.VTable, self.vtable).Clear(@ptrCast(*const ICertProperties, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertProperties_InitializeFromCertificate(self: *const T, MachineContext: i16, Encoding: EncodingType, strCertificate: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertProperties.VTable, self.vtable).InitializeFromCertificate(@ptrCast(*const ICertProperties, self), MachineContext, Encoding, strCertificate);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICertPropertyFriendlyName_Value = @import("../../zig.zig").Guid.initString("728ab330-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICertPropertyFriendlyName = &IID_ICertPropertyFriendlyName_Value;
pub const ICertPropertyFriendlyName = extern struct {
pub const VTable = extern struct {
base: ICertProperty.VTable,
Initialize: fn(
self: *const ICertPropertyFriendlyName,
strFriendlyName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_FriendlyName: fn(
self: *const ICertPropertyFriendlyName,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertProperty.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyFriendlyName_Initialize(self: *const T, strFriendlyName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyFriendlyName.VTable, self.vtable).Initialize(@ptrCast(*const ICertPropertyFriendlyName, self), strFriendlyName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyFriendlyName_get_FriendlyName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyFriendlyName.VTable, self.vtable).get_FriendlyName(@ptrCast(*const ICertPropertyFriendlyName, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICertPropertyDescription_Value = @import("../../zig.zig").Guid.initString("728ab331-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICertPropertyDescription = &IID_ICertPropertyDescription_Value;
pub const ICertPropertyDescription = extern struct {
pub const VTable = extern struct {
base: ICertProperty.VTable,
Initialize: fn(
self: *const ICertPropertyDescription,
strDescription: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Description: fn(
self: *const ICertPropertyDescription,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertProperty.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyDescription_Initialize(self: *const T, strDescription: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyDescription.VTable, self.vtable).Initialize(@ptrCast(*const ICertPropertyDescription, self), strDescription);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyDescription_get_Description(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyDescription.VTable, self.vtable).get_Description(@ptrCast(*const ICertPropertyDescription, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICertPropertyAutoEnroll_Value = @import("../../zig.zig").Guid.initString("728ab332-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICertPropertyAutoEnroll = &IID_ICertPropertyAutoEnroll_Value;
pub const ICertPropertyAutoEnroll = extern struct {
pub const VTable = extern struct {
base: ICertProperty.VTable,
Initialize: fn(
self: *const ICertPropertyAutoEnroll,
strTemplateName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TemplateName: fn(
self: *const ICertPropertyAutoEnroll,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertProperty.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyAutoEnroll_Initialize(self: *const T, strTemplateName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyAutoEnroll.VTable, self.vtable).Initialize(@ptrCast(*const ICertPropertyAutoEnroll, self), strTemplateName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyAutoEnroll_get_TemplateName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyAutoEnroll.VTable, self.vtable).get_TemplateName(@ptrCast(*const ICertPropertyAutoEnroll, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICertPropertyRequestOriginator_Value = @import("../../zig.zig").Guid.initString("728ab333-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICertPropertyRequestOriginator = &IID_ICertPropertyRequestOriginator_Value;
pub const ICertPropertyRequestOriginator = extern struct {
pub const VTable = extern struct {
base: ICertProperty.VTable,
Initialize: fn(
self: *const ICertPropertyRequestOriginator,
strRequestOriginator: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromLocalRequestOriginator: fn(
self: *const ICertPropertyRequestOriginator,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RequestOriginator: fn(
self: *const ICertPropertyRequestOriginator,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertProperty.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyRequestOriginator_Initialize(self: *const T, strRequestOriginator: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyRequestOriginator.VTable, self.vtable).Initialize(@ptrCast(*const ICertPropertyRequestOriginator, self), strRequestOriginator);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyRequestOriginator_InitializeFromLocalRequestOriginator(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyRequestOriginator.VTable, self.vtable).InitializeFromLocalRequestOriginator(@ptrCast(*const ICertPropertyRequestOriginator, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyRequestOriginator_get_RequestOriginator(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyRequestOriginator.VTable, self.vtable).get_RequestOriginator(@ptrCast(*const ICertPropertyRequestOriginator, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICertPropertySHA1Hash_Value = @import("../../zig.zig").Guid.initString("728ab334-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICertPropertySHA1Hash = &IID_ICertPropertySHA1Hash_Value;
pub const ICertPropertySHA1Hash = extern struct {
pub const VTable = extern struct {
base: ICertProperty.VTable,
Initialize: fn(
self: *const ICertPropertySHA1Hash,
Encoding: EncodingType,
strRenewalValue: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SHA1Hash: fn(
self: *const ICertPropertySHA1Hash,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertProperty.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertySHA1Hash_Initialize(self: *const T, Encoding: EncodingType, strRenewalValue: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertySHA1Hash.VTable, self.vtable).Initialize(@ptrCast(*const ICertPropertySHA1Hash, self), Encoding, strRenewalValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertySHA1Hash_get_SHA1Hash(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertySHA1Hash.VTable, self.vtable).get_SHA1Hash(@ptrCast(*const ICertPropertySHA1Hash, self), Encoding, pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICertPropertyKeyProvInfo_Value = @import("../../zig.zig").Guid.initString("728ab336-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICertPropertyKeyProvInfo = &IID_ICertPropertyKeyProvInfo_Value;
pub const ICertPropertyKeyProvInfo = extern struct {
pub const VTable = extern struct {
base: ICertProperty.VTable,
Initialize: fn(
self: *const ICertPropertyKeyProvInfo,
pValue: ?*IX509PrivateKey,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PrivateKey: fn(
self: *const ICertPropertyKeyProvInfo,
ppValue: ?*?*IX509PrivateKey,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertProperty.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyKeyProvInfo_Initialize(self: *const T, pValue: ?*IX509PrivateKey) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyKeyProvInfo.VTable, self.vtable).Initialize(@ptrCast(*const ICertPropertyKeyProvInfo, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyKeyProvInfo_get_PrivateKey(self: *const T, ppValue: ?*?*IX509PrivateKey) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyKeyProvInfo.VTable, self.vtable).get_PrivateKey(@ptrCast(*const ICertPropertyKeyProvInfo, self), ppValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICertPropertyArchived_Value = @import("../../zig.zig").Guid.initString("728ab337-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICertPropertyArchived = &IID_ICertPropertyArchived_Value;
pub const ICertPropertyArchived = extern struct {
pub const VTable = extern struct {
base: ICertProperty.VTable,
Initialize: fn(
self: *const ICertPropertyArchived,
ArchivedValue: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Archived: fn(
self: *const ICertPropertyArchived,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertProperty.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyArchived_Initialize(self: *const T, ArchivedValue: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyArchived.VTable, self.vtable).Initialize(@ptrCast(*const ICertPropertyArchived, self), ArchivedValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyArchived_get_Archived(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyArchived.VTable, self.vtable).get_Archived(@ptrCast(*const ICertPropertyArchived, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICertPropertyBackedUp_Value = @import("../../zig.zig").Guid.initString("728ab338-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICertPropertyBackedUp = &IID_ICertPropertyBackedUp_Value;
pub const ICertPropertyBackedUp = extern struct {
pub const VTable = extern struct {
base: ICertProperty.VTable,
InitializeFromCurrentTime: fn(
self: *const ICertPropertyBackedUp,
BackedUpValue: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Initialize: fn(
self: *const ICertPropertyBackedUp,
BackedUpValue: i16,
Date: f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BackedUpValue: fn(
self: *const ICertPropertyBackedUp,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BackedUpTime: fn(
self: *const ICertPropertyBackedUp,
pDate: ?*f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertProperty.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyBackedUp_InitializeFromCurrentTime(self: *const T, BackedUpValue: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyBackedUp.VTable, self.vtable).InitializeFromCurrentTime(@ptrCast(*const ICertPropertyBackedUp, self), BackedUpValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyBackedUp_Initialize(self: *const T, BackedUpValue: i16, Date: f64) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyBackedUp.VTable, self.vtable).Initialize(@ptrCast(*const ICertPropertyBackedUp, self), BackedUpValue, Date);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyBackedUp_get_BackedUpValue(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyBackedUp.VTable, self.vtable).get_BackedUpValue(@ptrCast(*const ICertPropertyBackedUp, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyBackedUp_get_BackedUpTime(self: *const T, pDate: ?*f64) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyBackedUp.VTable, self.vtable).get_BackedUpTime(@ptrCast(*const ICertPropertyBackedUp, self), pDate);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICertPropertyEnrollment_Value = @import("../../zig.zig").Guid.initString("728ab339-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICertPropertyEnrollment = &IID_ICertPropertyEnrollment_Value;
pub const ICertPropertyEnrollment = extern struct {
pub const VTable = extern struct {
base: ICertProperty.VTable,
Initialize: fn(
self: *const ICertPropertyEnrollment,
RequestId: i32,
strCADnsName: ?BSTR,
strCAName: ?BSTR,
strFriendlyName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RequestId: fn(
self: *const ICertPropertyEnrollment,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CADnsName: fn(
self: *const ICertPropertyEnrollment,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CAName: fn(
self: *const ICertPropertyEnrollment,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_FriendlyName: fn(
self: *const ICertPropertyEnrollment,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertProperty.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyEnrollment_Initialize(self: *const T, RequestId: i32, strCADnsName: ?BSTR, strCAName: ?BSTR, strFriendlyName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyEnrollment.VTable, self.vtable).Initialize(@ptrCast(*const ICertPropertyEnrollment, self), RequestId, strCADnsName, strCAName, strFriendlyName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyEnrollment_get_RequestId(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyEnrollment.VTable, self.vtable).get_RequestId(@ptrCast(*const ICertPropertyEnrollment, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyEnrollment_get_CADnsName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyEnrollment.VTable, self.vtable).get_CADnsName(@ptrCast(*const ICertPropertyEnrollment, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyEnrollment_get_CAName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyEnrollment.VTable, self.vtable).get_CAName(@ptrCast(*const ICertPropertyEnrollment, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyEnrollment_get_FriendlyName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyEnrollment.VTable, self.vtable).get_FriendlyName(@ptrCast(*const ICertPropertyEnrollment, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICertPropertyRenewal_Value = @import("../../zig.zig").Guid.initString("728ab33a-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICertPropertyRenewal = &IID_ICertPropertyRenewal_Value;
pub const ICertPropertyRenewal = extern struct {
pub const VTable = extern struct {
base: ICertProperty.VTable,
Initialize: fn(
self: *const ICertPropertyRenewal,
Encoding: EncodingType,
strRenewalValue: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromCertificateHash: fn(
self: *const ICertPropertyRenewal,
MachineContext: i16,
Encoding: EncodingType,
strCertificate: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Renewal: fn(
self: *const ICertPropertyRenewal,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertProperty.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyRenewal_Initialize(self: *const T, Encoding: EncodingType, strRenewalValue: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyRenewal.VTable, self.vtable).Initialize(@ptrCast(*const ICertPropertyRenewal, self), Encoding, strRenewalValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyRenewal_InitializeFromCertificateHash(self: *const T, MachineContext: i16, Encoding: EncodingType, strCertificate: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyRenewal.VTable, self.vtable).InitializeFromCertificateHash(@ptrCast(*const ICertPropertyRenewal, self), MachineContext, Encoding, strCertificate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyRenewal_get_Renewal(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyRenewal.VTable, self.vtable).get_Renewal(@ptrCast(*const ICertPropertyRenewal, self), Encoding, pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ICertPropertyArchivedKeyHash_Value = @import("../../zig.zig").Guid.initString("728ab33b-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICertPropertyArchivedKeyHash = &IID_ICertPropertyArchivedKeyHash_Value;
pub const ICertPropertyArchivedKeyHash = extern struct {
pub const VTable = extern struct {
base: ICertProperty.VTable,
Initialize: fn(
self: *const ICertPropertyArchivedKeyHash,
Encoding: EncodingType,
strArchivedKeyHashValue: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ArchivedKeyHash: fn(
self: *const ICertPropertyArchivedKeyHash,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertProperty.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyArchivedKeyHash_Initialize(self: *const T, Encoding: EncodingType, strArchivedKeyHashValue: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyArchivedKeyHash.VTable, self.vtable).Initialize(@ptrCast(*const ICertPropertyArchivedKeyHash, self), Encoding, strArchivedKeyHashValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyArchivedKeyHash_get_ArchivedKeyHash(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyArchivedKeyHash.VTable, self.vtable).get_ArchivedKeyHash(@ptrCast(*const ICertPropertyArchivedKeyHash, self), Encoding, pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const EnrollmentPolicyServerPropertyFlags = enum(i32) {
None = 0,
PolicyServer = 1,
};
pub const DefaultNone = EnrollmentPolicyServerPropertyFlags.None;
pub const DefaultPolicyServer = EnrollmentPolicyServerPropertyFlags.PolicyServer;
pub const PolicyServerUrlFlags = enum(i32) {
None = 0,
LocationGroupPolicy = 1,
LocationRegistry = 2,
UseClientId = 4,
AutoEnrollmentEnabled = 16,
AllowUnTrustedCA = 32,
};
pub const PsfNone = PolicyServerUrlFlags.None;
pub const PsfLocationGroupPolicy = PolicyServerUrlFlags.LocationGroupPolicy;
pub const PsfLocationRegistry = PolicyServerUrlFlags.LocationRegistry;
pub const PsfUseClientId = PolicyServerUrlFlags.UseClientId;
pub const PsfAutoEnrollmentEnabled = PolicyServerUrlFlags.AutoEnrollmentEnabled;
pub const PsfAllowUnTrustedCA = PolicyServerUrlFlags.AllowUnTrustedCA;
// TODO: this type is limited to platform 'windows6.1'
const IID_ICertPropertyEnrollmentPolicyServer_Value = @import("../../zig.zig").Guid.initString("728ab34a-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ICertPropertyEnrollmentPolicyServer = &IID_ICertPropertyEnrollmentPolicyServer_Value;
pub const ICertPropertyEnrollmentPolicyServer = extern struct {
pub const VTable = extern struct {
base: ICertProperty.VTable,
Initialize: fn(
self: *const ICertPropertyEnrollmentPolicyServer,
PropertyFlags: EnrollmentPolicyServerPropertyFlags,
AuthFlags: X509EnrollmentAuthFlags,
EnrollmentServerAuthFlags: X509EnrollmentAuthFlags,
UrlFlags: PolicyServerUrlFlags,
strRequestId: ?BSTR,
strUrl: ?BSTR,
strId: ?BSTR,
strEnrollmentServerUrl: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetPolicyServerUrl: fn(
self: *const ICertPropertyEnrollmentPolicyServer,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetPolicyServerId: fn(
self: *const ICertPropertyEnrollmentPolicyServer,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetEnrollmentServerUrl: fn(
self: *const ICertPropertyEnrollmentPolicyServer,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetRequestIdString: fn(
self: *const ICertPropertyEnrollmentPolicyServer,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetPropertyFlags: fn(
self: *const ICertPropertyEnrollmentPolicyServer,
pValue: ?*EnrollmentPolicyServerPropertyFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetUrlFlags: fn(
self: *const ICertPropertyEnrollmentPolicyServer,
pValue: ?*PolicyServerUrlFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetAuthentication: fn(
self: *const ICertPropertyEnrollmentPolicyServer,
pValue: ?*X509EnrollmentAuthFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetEnrollmentServerAuthentication: fn(
self: *const ICertPropertyEnrollmentPolicyServer,
pValue: ?*X509EnrollmentAuthFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertProperty.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyEnrollmentPolicyServer_Initialize(self: *const T, PropertyFlags: EnrollmentPolicyServerPropertyFlags, AuthFlags: X509EnrollmentAuthFlags, EnrollmentServerAuthFlags: X509EnrollmentAuthFlags, UrlFlags: PolicyServerUrlFlags, strRequestId: ?BSTR, strUrl: ?BSTR, strId: ?BSTR, strEnrollmentServerUrl: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyEnrollmentPolicyServer.VTable, self.vtable).Initialize(@ptrCast(*const ICertPropertyEnrollmentPolicyServer, self), PropertyFlags, AuthFlags, EnrollmentServerAuthFlags, UrlFlags, strRequestId, strUrl, strId, strEnrollmentServerUrl);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyEnrollmentPolicyServer_GetPolicyServerUrl(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyEnrollmentPolicyServer.VTable, self.vtable).GetPolicyServerUrl(@ptrCast(*const ICertPropertyEnrollmentPolicyServer, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyEnrollmentPolicyServer_GetPolicyServerId(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyEnrollmentPolicyServer.VTable, self.vtable).GetPolicyServerId(@ptrCast(*const ICertPropertyEnrollmentPolicyServer, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyEnrollmentPolicyServer_GetEnrollmentServerUrl(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyEnrollmentPolicyServer.VTable, self.vtable).GetEnrollmentServerUrl(@ptrCast(*const ICertPropertyEnrollmentPolicyServer, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyEnrollmentPolicyServer_GetRequestIdString(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyEnrollmentPolicyServer.VTable, self.vtable).GetRequestIdString(@ptrCast(*const ICertPropertyEnrollmentPolicyServer, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyEnrollmentPolicyServer_GetPropertyFlags(self: *const T, pValue: ?*EnrollmentPolicyServerPropertyFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyEnrollmentPolicyServer.VTable, self.vtable).GetPropertyFlags(@ptrCast(*const ICertPropertyEnrollmentPolicyServer, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyEnrollmentPolicyServer_GetUrlFlags(self: *const T, pValue: ?*PolicyServerUrlFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyEnrollmentPolicyServer.VTable, self.vtable).GetUrlFlags(@ptrCast(*const ICertPropertyEnrollmentPolicyServer, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyEnrollmentPolicyServer_GetAuthentication(self: *const T, pValue: ?*X509EnrollmentAuthFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyEnrollmentPolicyServer.VTable, self.vtable).GetAuthentication(@ptrCast(*const ICertPropertyEnrollmentPolicyServer, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertPropertyEnrollmentPolicyServer_GetEnrollmentServerAuthentication(self: *const T, pValue: ?*X509EnrollmentAuthFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertPropertyEnrollmentPolicyServer.VTable, self.vtable).GetEnrollmentServerAuthentication(@ptrCast(*const ICertPropertyEnrollmentPolicyServer, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509SignatureInformation_Value = @import("../../zig.zig").Guid.initString("728ab33c-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509SignatureInformation = &IID_IX509SignatureInformation_Value;
pub const IX509SignatureInformation = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_HashAlgorithm: fn(
self: *const IX509SignatureInformation,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_HashAlgorithm: fn(
self: *const IX509SignatureInformation,
pValue: ?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PublicKeyAlgorithm: fn(
self: *const IX509SignatureInformation,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_PublicKeyAlgorithm: fn(
self: *const IX509SignatureInformation,
pValue: ?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Parameters: fn(
self: *const IX509SignatureInformation,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Parameters: fn(
self: *const IX509SignatureInformation,
Encoding: EncodingType,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AlternateSignatureAlgorithm: fn(
self: *const IX509SignatureInformation,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_AlternateSignatureAlgorithm: fn(
self: *const IX509SignatureInformation,
Value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AlternateSignatureAlgorithmSet: fn(
self: *const IX509SignatureInformation,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_NullSigned: fn(
self: *const IX509SignatureInformation,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_NullSigned: fn(
self: *const IX509SignatureInformation,
Value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetSignatureAlgorithm: fn(
self: *const IX509SignatureInformation,
Pkcs7Signature: i16,
SignatureKey: i16,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetDefaultValues: fn(
self: *const IX509SignatureInformation,
) 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 IX509SignatureInformation_get_HashAlgorithm(self: *const T, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SignatureInformation.VTable, self.vtable).get_HashAlgorithm(@ptrCast(*const IX509SignatureInformation, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SignatureInformation_put_HashAlgorithm(self: *const T, pValue: ?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SignatureInformation.VTable, self.vtable).put_HashAlgorithm(@ptrCast(*const IX509SignatureInformation, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SignatureInformation_get_PublicKeyAlgorithm(self: *const T, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SignatureInformation.VTable, self.vtable).get_PublicKeyAlgorithm(@ptrCast(*const IX509SignatureInformation, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SignatureInformation_put_PublicKeyAlgorithm(self: *const T, pValue: ?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SignatureInformation.VTable, self.vtable).put_PublicKeyAlgorithm(@ptrCast(*const IX509SignatureInformation, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SignatureInformation_get_Parameters(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SignatureInformation.VTable, self.vtable).get_Parameters(@ptrCast(*const IX509SignatureInformation, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SignatureInformation_put_Parameters(self: *const T, Encoding: EncodingType, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SignatureInformation.VTable, self.vtable).put_Parameters(@ptrCast(*const IX509SignatureInformation, self), Encoding, Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SignatureInformation_get_AlternateSignatureAlgorithm(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SignatureInformation.VTable, self.vtable).get_AlternateSignatureAlgorithm(@ptrCast(*const IX509SignatureInformation, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SignatureInformation_put_AlternateSignatureAlgorithm(self: *const T, Value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SignatureInformation.VTable, self.vtable).put_AlternateSignatureAlgorithm(@ptrCast(*const IX509SignatureInformation, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SignatureInformation_get_AlternateSignatureAlgorithmSet(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SignatureInformation.VTable, self.vtable).get_AlternateSignatureAlgorithmSet(@ptrCast(*const IX509SignatureInformation, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SignatureInformation_get_NullSigned(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SignatureInformation.VTable, self.vtable).get_NullSigned(@ptrCast(*const IX509SignatureInformation, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SignatureInformation_put_NullSigned(self: *const T, Value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SignatureInformation.VTable, self.vtable).put_NullSigned(@ptrCast(*const IX509SignatureInformation, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SignatureInformation_GetSignatureAlgorithm(self: *const T, Pkcs7Signature: i16, SignatureKey: i16, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SignatureInformation.VTable, self.vtable).GetSignatureAlgorithm(@ptrCast(*const IX509SignatureInformation, self), Pkcs7Signature, SignatureKey, ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SignatureInformation_SetDefaultValues(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SignatureInformation.VTable, self.vtable).SetDefaultValues(@ptrCast(*const IX509SignatureInformation, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ISignerCertificate_Value = @import("../../zig.zig").Guid.initString("728ab33d-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ISignerCertificate = &IID_ISignerCertificate_Value;
pub const ISignerCertificate = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const ISignerCertificate,
MachineContext: i16,
VerifyType: X509PrivateKeyVerify,
Encoding: EncodingType,
strCertificate: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Certificate: fn(
self: *const ISignerCertificate,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PrivateKey: fn(
self: *const ISignerCertificate,
ppValue: ?*?*IX509PrivateKey,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Silent: fn(
self: *const ISignerCertificate,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Silent: fn(
self: *const ISignerCertificate,
Value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ParentWindow: fn(
self: *const ISignerCertificate,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ParentWindow: fn(
self: *const ISignerCertificate,
Value: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_UIContextMessage: fn(
self: *const ISignerCertificate,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_UIContextMessage: fn(
self: *const ISignerCertificate,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Pin: fn(
self: *const ISignerCertificate,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SignatureInformation: fn(
self: *const ISignerCertificate,
ppValue: ?*?*IX509SignatureInformation,
) 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 ISignerCertificate_Initialize(self: *const T, MachineContext: i16, VerifyType: X509PrivateKeyVerify, Encoding: EncodingType, strCertificate: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ISignerCertificate.VTable, self.vtable).Initialize(@ptrCast(*const ISignerCertificate, self), MachineContext, VerifyType, Encoding, strCertificate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISignerCertificate_get_Certificate(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ISignerCertificate.VTable, self.vtable).get_Certificate(@ptrCast(*const ISignerCertificate, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISignerCertificate_get_PrivateKey(self: *const T, ppValue: ?*?*IX509PrivateKey) callconv(.Inline) HRESULT {
return @ptrCast(*const ISignerCertificate.VTable, self.vtable).get_PrivateKey(@ptrCast(*const ISignerCertificate, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISignerCertificate_get_Silent(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ISignerCertificate.VTable, self.vtable).get_Silent(@ptrCast(*const ISignerCertificate, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISignerCertificate_put_Silent(self: *const T, Value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ISignerCertificate.VTable, self.vtable).put_Silent(@ptrCast(*const ISignerCertificate, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISignerCertificate_get_ParentWindow(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ISignerCertificate.VTable, self.vtable).get_ParentWindow(@ptrCast(*const ISignerCertificate, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISignerCertificate_put_ParentWindow(self: *const T, Value: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ISignerCertificate.VTable, self.vtable).put_ParentWindow(@ptrCast(*const ISignerCertificate, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISignerCertificate_get_UIContextMessage(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ISignerCertificate.VTable, self.vtable).get_UIContextMessage(@ptrCast(*const ISignerCertificate, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISignerCertificate_put_UIContextMessage(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ISignerCertificate.VTable, self.vtable).put_UIContextMessage(@ptrCast(*const ISignerCertificate, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISignerCertificate_put_Pin(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ISignerCertificate.VTable, self.vtable).put_Pin(@ptrCast(*const ISignerCertificate, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISignerCertificate_get_SignatureInformation(self: *const T, ppValue: ?*?*IX509SignatureInformation) callconv(.Inline) HRESULT {
return @ptrCast(*const ISignerCertificate.VTable, self.vtable).get_SignatureInformation(@ptrCast(*const ISignerCertificate, self), ppValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_ISignerCertificates_Value = @import("../../zig.zig").Guid.initString("728ab33e-217d-11da-b2a4-000e7bbb2b09");
pub const IID_ISignerCertificates = &IID_ISignerCertificates_Value;
pub const ISignerCertificates = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByIndex: fn(
self: *const ISignerCertificates,
Index: i32,
pVal: ?*?*ISignerCertificate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const ISignerCertificates,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const ISignerCertificates,
pVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const ISignerCertificates,
pVal: ?*ISignerCertificate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Remove: fn(
self: *const ISignerCertificates,
Index: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clear: fn(
self: *const ISignerCertificates,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Find: fn(
self: *const ISignerCertificates,
pSignerCert: ?*ISignerCertificate,
piSignerCert: ?*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 ISignerCertificates_get_ItemByIndex(self: *const T, Index: i32, pVal: ?*?*ISignerCertificate) callconv(.Inline) HRESULT {
return @ptrCast(*const ISignerCertificates.VTable, self.vtable).get_ItemByIndex(@ptrCast(*const ISignerCertificates, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISignerCertificates_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ISignerCertificates.VTable, self.vtable).get_Count(@ptrCast(*const ISignerCertificates, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISignerCertificates_get__NewEnum(self: *const T, pVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const ISignerCertificates.VTable, self.vtable).get__NewEnum(@ptrCast(*const ISignerCertificates, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISignerCertificates_Add(self: *const T, pVal: ?*ISignerCertificate) callconv(.Inline) HRESULT {
return @ptrCast(*const ISignerCertificates.VTable, self.vtable).Add(@ptrCast(*const ISignerCertificates, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISignerCertificates_Remove(self: *const T, Index: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ISignerCertificates.VTable, self.vtable).Remove(@ptrCast(*const ISignerCertificates, self), Index);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISignerCertificates_Clear(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ISignerCertificates.VTable, self.vtable).Clear(@ptrCast(*const ISignerCertificates, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISignerCertificates_Find(self: *const T, pSignerCert: ?*ISignerCertificate, piSignerCert: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ISignerCertificates.VTable, self.vtable).Find(@ptrCast(*const ISignerCertificates, self), pSignerCert, piSignerCert);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509NameValuePair_Value = @import("../../zig.zig").Guid.initString("728ab33f-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509NameValuePair = &IID_IX509NameValuePair_Value;
pub const IX509NameValuePair = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const IX509NameValuePair,
strName: ?BSTR,
strValue: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Value: fn(
self: *const IX509NameValuePair,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Name: fn(
self: *const IX509NameValuePair,
pValue: ?*?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 IX509NameValuePair_Initialize(self: *const T, strName: ?BSTR, strValue: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509NameValuePair.VTable, self.vtable).Initialize(@ptrCast(*const IX509NameValuePair, self), strName, strValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509NameValuePair_get_Value(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509NameValuePair.VTable, self.vtable).get_Value(@ptrCast(*const IX509NameValuePair, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509NameValuePair_get_Name(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509NameValuePair.VTable, self.vtable).get_Name(@ptrCast(*const IX509NameValuePair, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509NameValuePairs_Value = @import("../../zig.zig").Guid.initString("728ab340-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509NameValuePairs = &IID_IX509NameValuePairs_Value;
pub const IX509NameValuePairs = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByIndex: fn(
self: *const IX509NameValuePairs,
Index: i32,
pVal: ?*?*IX509NameValuePair,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const IX509NameValuePairs,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const IX509NameValuePairs,
pVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const IX509NameValuePairs,
pVal: ?*IX509NameValuePair,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Remove: fn(
self: *const IX509NameValuePairs,
Index: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clear: fn(
self: *const IX509NameValuePairs,
) 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 IX509NameValuePairs_get_ItemByIndex(self: *const T, Index: i32, pVal: ?*?*IX509NameValuePair) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509NameValuePairs.VTable, self.vtable).get_ItemByIndex(@ptrCast(*const IX509NameValuePairs, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509NameValuePairs_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509NameValuePairs.VTable, self.vtable).get_Count(@ptrCast(*const IX509NameValuePairs, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509NameValuePairs_get__NewEnum(self: *const T, pVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509NameValuePairs.VTable, self.vtable).get__NewEnum(@ptrCast(*const IX509NameValuePairs, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509NameValuePairs_Add(self: *const T, pVal: ?*IX509NameValuePair) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509NameValuePairs.VTable, self.vtable).Add(@ptrCast(*const IX509NameValuePairs, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509NameValuePairs_Remove(self: *const T, Index: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509NameValuePairs.VTable, self.vtable).Remove(@ptrCast(*const IX509NameValuePairs, self), Index);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509NameValuePairs_Clear(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509NameValuePairs.VTable, self.vtable).Clear(@ptrCast(*const IX509NameValuePairs, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const EnrollmentTemplateProperty = enum(i32) {
CommonName = 1,
FriendlyName = 2,
EKUs = 3,
CryptoProviders = 4,
MajorRevision = 5,
Description = 6,
KeySpec = 7,
SchemaVersion = 8,
MinorRevision = 9,
RASignatureCount = 10,
MinimumKeySize = 11,
OID = 12,
Supersede = 13,
RACertificatePolicies = 14,
RAEKUs = 15,
CertificatePolicies = 16,
V1ApplicationPolicy = 17,
AsymmetricAlgorithm = 18,
KeySecurityDescriptor = 19,
SymmetricAlgorithm = 20,
SymmetricKeyLength = 21,
HashAlgorithm = 22,
KeyUsage = 23,
EnrollmentFlags = 24,
SubjectNameFlags = 25,
PrivateKeyFlags = 26,
GeneralFlags = 27,
SecurityDescriptor = 28,
Extensions = 29,
ValidityPeriod = 30,
RenewalPeriod = 31,
};
pub const TemplatePropCommonName = EnrollmentTemplateProperty.CommonName;
pub const TemplatePropFriendlyName = EnrollmentTemplateProperty.FriendlyName;
pub const TemplatePropEKUs = EnrollmentTemplateProperty.EKUs;
pub const TemplatePropCryptoProviders = EnrollmentTemplateProperty.CryptoProviders;
pub const TemplatePropMajorRevision = EnrollmentTemplateProperty.MajorRevision;
pub const TemplatePropDescription = EnrollmentTemplateProperty.Description;
pub const TemplatePropKeySpec = EnrollmentTemplateProperty.KeySpec;
pub const TemplatePropSchemaVersion = EnrollmentTemplateProperty.SchemaVersion;
pub const TemplatePropMinorRevision = EnrollmentTemplateProperty.MinorRevision;
pub const TemplatePropRASignatureCount = EnrollmentTemplateProperty.RASignatureCount;
pub const TemplatePropMinimumKeySize = EnrollmentTemplateProperty.MinimumKeySize;
pub const TemplatePropOID = EnrollmentTemplateProperty.OID;
pub const TemplatePropSupersede = EnrollmentTemplateProperty.Supersede;
pub const TemplatePropRACertificatePolicies = EnrollmentTemplateProperty.RACertificatePolicies;
pub const TemplatePropRAEKUs = EnrollmentTemplateProperty.RAEKUs;
pub const TemplatePropCertificatePolicies = EnrollmentTemplateProperty.CertificatePolicies;
pub const TemplatePropV1ApplicationPolicy = EnrollmentTemplateProperty.V1ApplicationPolicy;
pub const TemplatePropAsymmetricAlgorithm = EnrollmentTemplateProperty.AsymmetricAlgorithm;
pub const TemplatePropKeySecurityDescriptor = EnrollmentTemplateProperty.KeySecurityDescriptor;
pub const TemplatePropSymmetricAlgorithm = EnrollmentTemplateProperty.SymmetricAlgorithm;
pub const TemplatePropSymmetricKeyLength = EnrollmentTemplateProperty.SymmetricKeyLength;
pub const TemplatePropHashAlgorithm = EnrollmentTemplateProperty.HashAlgorithm;
pub const TemplatePropKeyUsage = EnrollmentTemplateProperty.KeyUsage;
pub const TemplatePropEnrollmentFlags = EnrollmentTemplateProperty.EnrollmentFlags;
pub const TemplatePropSubjectNameFlags = EnrollmentTemplateProperty.SubjectNameFlags;
pub const TemplatePropPrivateKeyFlags = EnrollmentTemplateProperty.PrivateKeyFlags;
pub const TemplatePropGeneralFlags = EnrollmentTemplateProperty.GeneralFlags;
pub const TemplatePropSecurityDescriptor = EnrollmentTemplateProperty.SecurityDescriptor;
pub const TemplatePropExtensions = EnrollmentTemplateProperty.Extensions;
pub const TemplatePropValidityPeriod = EnrollmentTemplateProperty.ValidityPeriod;
pub const TemplatePropRenewalPeriod = EnrollmentTemplateProperty.RenewalPeriod;
// TODO: this type is limited to platform 'windows6.1'
const IID_IX509CertificateTemplate_Value = @import("../../zig.zig").Guid.initString("54244a13-555a-4e22-896d-1b0e52f76406");
pub const IID_IX509CertificateTemplate = &IID_IX509CertificateTemplate_Value;
pub const IX509CertificateTemplate = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Property: fn(
self: *const IX509CertificateTemplate,
property: EnrollmentTemplateProperty,
pValue: ?*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 IX509CertificateTemplate_get_Property(self: *const T, property: EnrollmentTemplateProperty, pValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateTemplate.VTable, self.vtable).get_Property(@ptrCast(*const IX509CertificateTemplate, self), property, pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.1'
const IID_IX509CertificateTemplates_Value = @import("../../zig.zig").Guid.initString("13b79003-2181-11da-b2a4-000e7bbb2b09");
pub const IID_IX509CertificateTemplates = &IID_IX509CertificateTemplates_Value;
pub const IX509CertificateTemplates = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByIndex: fn(
self: *const IX509CertificateTemplates,
Index: i32,
pVal: ?*?*IX509CertificateTemplate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const IX509CertificateTemplates,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const IX509CertificateTemplates,
pVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const IX509CertificateTemplates,
pVal: ?*IX509CertificateTemplate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Remove: fn(
self: *const IX509CertificateTemplates,
Index: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clear: fn(
self: *const IX509CertificateTemplates,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByName: fn(
self: *const IX509CertificateTemplates,
bstrName: ?BSTR,
ppValue: ?*?*IX509CertificateTemplate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByOid: fn(
self: *const IX509CertificateTemplates,
pOid: ?*IObjectId,
ppValue: ?*?*IX509CertificateTemplate,
) 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 IX509CertificateTemplates_get_ItemByIndex(self: *const T, Index: i32, pVal: ?*?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateTemplates.VTable, self.vtable).get_ItemByIndex(@ptrCast(*const IX509CertificateTemplates, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateTemplates_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateTemplates.VTable, self.vtable).get_Count(@ptrCast(*const IX509CertificateTemplates, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateTemplates_get__NewEnum(self: *const T, pVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateTemplates.VTable, self.vtable).get__NewEnum(@ptrCast(*const IX509CertificateTemplates, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateTemplates_Add(self: *const T, pVal: ?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateTemplates.VTable, self.vtable).Add(@ptrCast(*const IX509CertificateTemplates, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateTemplates_Remove(self: *const T, Index: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateTemplates.VTable, self.vtable).Remove(@ptrCast(*const IX509CertificateTemplates, self), Index);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateTemplates_Clear(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateTemplates.VTable, self.vtable).Clear(@ptrCast(*const IX509CertificateTemplates, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateTemplates_get_ItemByName(self: *const T, bstrName: ?BSTR, ppValue: ?*?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateTemplates.VTable, self.vtable).get_ItemByName(@ptrCast(*const IX509CertificateTemplates, self), bstrName, ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateTemplates_get_ItemByOid(self: *const T, pOid: ?*IObjectId, ppValue: ?*?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateTemplates.VTable, self.vtable).get_ItemByOid(@ptrCast(*const IX509CertificateTemplates, self), pOid, ppValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const CommitTemplateFlags = enum(i32) {
SaveTemplateGenerateOID = 1,
SaveTemplateUseCurrentOID = 2,
SaveTemplateOverwrite = 3,
DeleteTemplate = 4,
};
pub const CommitFlagSaveTemplateGenerateOID = CommitTemplateFlags.SaveTemplateGenerateOID;
pub const CommitFlagSaveTemplateUseCurrentOID = CommitTemplateFlags.SaveTemplateUseCurrentOID;
pub const CommitFlagSaveTemplateOverwrite = CommitTemplateFlags.SaveTemplateOverwrite;
pub const CommitFlagDeleteTemplate = CommitTemplateFlags.DeleteTemplate;
// TODO: this type is limited to platform 'windows6.1'
const IID_IX509CertificateTemplateWritable_Value = @import("../../zig.zig").Guid.initString("f49466a7-395a-4e9e-b6e7-32b331600dc0");
pub const IID_IX509CertificateTemplateWritable = &IID_IX509CertificateTemplateWritable_Value;
pub const IX509CertificateTemplateWritable = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const IX509CertificateTemplateWritable,
pValue: ?*IX509CertificateTemplate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Commit: fn(
self: *const IX509CertificateTemplateWritable,
commitFlags: CommitTemplateFlags,
strServerContext: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Property: fn(
self: *const IX509CertificateTemplateWritable,
property: EnrollmentTemplateProperty,
pValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Property: fn(
self: *const IX509CertificateTemplateWritable,
property: EnrollmentTemplateProperty,
value: VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Template: fn(
self: *const IX509CertificateTemplateWritable,
ppValue: ?*?*IX509CertificateTemplate,
) 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 IX509CertificateTemplateWritable_Initialize(self: *const T, pValue: ?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateTemplateWritable.VTable, self.vtable).Initialize(@ptrCast(*const IX509CertificateTemplateWritable, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateTemplateWritable_Commit(self: *const T, commitFlags: CommitTemplateFlags, strServerContext: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateTemplateWritable.VTable, self.vtable).Commit(@ptrCast(*const IX509CertificateTemplateWritable, self), commitFlags, strServerContext);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateTemplateWritable_get_Property(self: *const T, property: EnrollmentTemplateProperty, pValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateTemplateWritable.VTable, self.vtable).get_Property(@ptrCast(*const IX509CertificateTemplateWritable, self), property, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateTemplateWritable_put_Property(self: *const T, property: EnrollmentTemplateProperty, value: VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateTemplateWritable.VTable, self.vtable).put_Property(@ptrCast(*const IX509CertificateTemplateWritable, self), property, value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateTemplateWritable_get_Template(self: *const T, ppValue: ?*?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateTemplateWritable.VTable, self.vtable).get_Template(@ptrCast(*const IX509CertificateTemplateWritable, self), ppValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const EnrollmentCAProperty = enum(i32) {
CommonName = 1,
DistinguishedName = 2,
SanitizedName = 3,
SanitizedShortName = 4,
DNSName = 5,
CertificateTypes = 6,
Certificate = 7,
Description = 8,
WebServers = 9,
SiteName = 10,
Security = 11,
RenewalOnly = 12,
};
pub const CAPropCommonName = EnrollmentCAProperty.CommonName;
pub const CAPropDistinguishedName = EnrollmentCAProperty.DistinguishedName;
pub const CAPropSanitizedName = EnrollmentCAProperty.SanitizedName;
pub const CAPropSanitizedShortName = EnrollmentCAProperty.SanitizedShortName;
pub const CAPropDNSName = EnrollmentCAProperty.DNSName;
pub const CAPropCertificateTypes = EnrollmentCAProperty.CertificateTypes;
pub const CAPropCertificate = EnrollmentCAProperty.Certificate;
pub const CAPropDescription = EnrollmentCAProperty.Description;
pub const CAPropWebServers = EnrollmentCAProperty.WebServers;
pub const CAPropSiteName = EnrollmentCAProperty.SiteName;
pub const CAPropSecurity = EnrollmentCAProperty.Security;
pub const CAPropRenewalOnly = EnrollmentCAProperty.RenewalOnly;
// TODO: this type is limited to platform 'windows6.1'
const IID_ICertificationAuthority_Value = @import("../../zig.zig").Guid.initString("835d1f61-1e95-4bc8-b4d3-976c42b968f7");
pub const IID_ICertificationAuthority = &IID_ICertificationAuthority_Value;
pub const ICertificationAuthority = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Property: fn(
self: *const ICertificationAuthority,
property: EnrollmentCAProperty,
pValue: ?*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 ICertificationAuthority_get_Property(self: *const T, property: EnrollmentCAProperty, pValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificationAuthority.VTable, self.vtable).get_Property(@ptrCast(*const ICertificationAuthority, self), property, pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.1'
const IID_ICertificationAuthorities_Value = @import("../../zig.zig").Guid.initString("13b79005-2181-11da-b2a4-000e7bbb2b09");
pub const IID_ICertificationAuthorities = &IID_ICertificationAuthorities_Value;
pub const ICertificationAuthorities = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByIndex: fn(
self: *const ICertificationAuthorities,
Index: i32,
pVal: ?*?*ICertificationAuthority,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const ICertificationAuthorities,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const ICertificationAuthorities,
pVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const ICertificationAuthorities,
pVal: ?*ICertificationAuthority,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Remove: fn(
self: *const ICertificationAuthorities,
Index: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clear: fn(
self: *const ICertificationAuthorities,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ComputeSiteCosts: fn(
self: *const ICertificationAuthorities,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByName: fn(
self: *const ICertificationAuthorities,
strName: ?BSTR,
ppValue: ?*?*ICertificationAuthority,
) 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 ICertificationAuthorities_get_ItemByIndex(self: *const T, Index: i32, pVal: ?*?*ICertificationAuthority) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificationAuthorities.VTable, self.vtable).get_ItemByIndex(@ptrCast(*const ICertificationAuthorities, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificationAuthorities_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificationAuthorities.VTable, self.vtable).get_Count(@ptrCast(*const ICertificationAuthorities, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificationAuthorities_get__NewEnum(self: *const T, pVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificationAuthorities.VTable, self.vtable).get__NewEnum(@ptrCast(*const ICertificationAuthorities, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificationAuthorities_Add(self: *const T, pVal: ?*ICertificationAuthority) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificationAuthorities.VTable, self.vtable).Add(@ptrCast(*const ICertificationAuthorities, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificationAuthorities_Remove(self: *const T, Index: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificationAuthorities.VTable, self.vtable).Remove(@ptrCast(*const ICertificationAuthorities, self), Index);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificationAuthorities_Clear(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificationAuthorities.VTable, self.vtable).Clear(@ptrCast(*const ICertificationAuthorities, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificationAuthorities_ComputeSiteCosts(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificationAuthorities.VTable, self.vtable).ComputeSiteCosts(@ptrCast(*const ICertificationAuthorities, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificationAuthorities_get_ItemByName(self: *const T, strName: ?BSTR, ppValue: ?*?*ICertificationAuthority) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificationAuthorities.VTable, self.vtable).get_ItemByName(@ptrCast(*const ICertificationAuthorities, self), strName, ppValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const X509EnrollmentPolicyLoadOption = enum(i32) {
Default = 0,
CacheOnly = 1,
Reload = 2,
RegisterForADChanges = 4,
};
pub const LoadOptionDefault = X509EnrollmentPolicyLoadOption.Default;
pub const LoadOptionCacheOnly = X509EnrollmentPolicyLoadOption.CacheOnly;
pub const LoadOptionReload = X509EnrollmentPolicyLoadOption.Reload;
pub const LoadOptionRegisterForADChanges = X509EnrollmentPolicyLoadOption.RegisterForADChanges;
pub const EnrollmentPolicyFlags = enum(i32) {
GroupPolicyList = 2,
UserServerList = 4,
};
pub const DisableGroupPolicyList = EnrollmentPolicyFlags.GroupPolicyList;
pub const DisableUserServerList = EnrollmentPolicyFlags.UserServerList;
pub const PolicyServerUrlPropertyID = enum(i32) {
PolicyID = 0,
FriendlyName = 1,
};
pub const PsPolicyID = PolicyServerUrlPropertyID.PolicyID;
pub const PsFriendlyName = PolicyServerUrlPropertyID.FriendlyName;
pub const X509EnrollmentPolicyExportFlags = enum(i32) {
Templates = 1,
OIDs = 2,
CAs = 4,
};
pub const ExportTemplates = X509EnrollmentPolicyExportFlags.Templates;
pub const ExportOIDs = X509EnrollmentPolicyExportFlags.OIDs;
pub const ExportCAs = X509EnrollmentPolicyExportFlags.CAs;
// TODO: this type is limited to platform 'windows6.1'
const IID_IX509EnrollmentPolicyServer_Value = @import("../../zig.zig").Guid.initString("13b79026-2181-11da-b2a4-000e7bbb2b09");
pub const IID_IX509EnrollmentPolicyServer = &IID_IX509EnrollmentPolicyServer_Value;
pub const IX509EnrollmentPolicyServer = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const IX509EnrollmentPolicyServer,
bstrPolicyServerUrl: ?BSTR,
bstrPolicyServerId: ?BSTR,
authFlags: X509EnrollmentAuthFlags,
fIsUnTrusted: i16,
context: X509CertificateEnrollmentContext,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
LoadPolicy: fn(
self: *const IX509EnrollmentPolicyServer,
option: X509EnrollmentPolicyLoadOption,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetTemplates: fn(
self: *const IX509EnrollmentPolicyServer,
pTemplates: ?*?*IX509CertificateTemplates,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCAsForTemplate: fn(
self: *const IX509EnrollmentPolicyServer,
pTemplate: ?*IX509CertificateTemplate,
ppCAs: ?*?*ICertificationAuthorities,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCAs: fn(
self: *const IX509EnrollmentPolicyServer,
ppCAs: ?*?*ICertificationAuthorities,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Validate: fn(
self: *const IX509EnrollmentPolicyServer,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCustomOids: fn(
self: *const IX509EnrollmentPolicyServer,
ppObjectIds: ?*?*IObjectIds,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetNextUpdateTime: fn(
self: *const IX509EnrollmentPolicyServer,
pDate: ?*f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetLastUpdateTime: fn(
self: *const IX509EnrollmentPolicyServer,
pDate: ?*f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetPolicyServerUrl: fn(
self: *const IX509EnrollmentPolicyServer,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetPolicyServerId: fn(
self: *const IX509EnrollmentPolicyServer,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetFriendlyName: fn(
self: *const IX509EnrollmentPolicyServer,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetIsDefaultCEP: fn(
self: *const IX509EnrollmentPolicyServer,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetUseClientId: fn(
self: *const IX509EnrollmentPolicyServer,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetAllowUnTrustedCA: fn(
self: *const IX509EnrollmentPolicyServer,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCachePath: fn(
self: *const IX509EnrollmentPolicyServer,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCacheDir: fn(
self: *const IX509EnrollmentPolicyServer,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetAuthFlags: fn(
self: *const IX509EnrollmentPolicyServer,
pValue: ?*X509EnrollmentAuthFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetCredential: fn(
self: *const IX509EnrollmentPolicyServer,
hWndParent: i32,
flag: X509EnrollmentAuthFlags,
strCredential: ?BSTR,
strPassword: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
QueryChanges: fn(
self: *const IX509EnrollmentPolicyServer,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeImport: fn(
self: *const IX509EnrollmentPolicyServer,
val: VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Export: fn(
self: *const IX509EnrollmentPolicyServer,
exportFlags: X509EnrollmentPolicyExportFlags,
pVal: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Cost: fn(
self: *const IX509EnrollmentPolicyServer,
pValue: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Cost: fn(
self: *const IX509EnrollmentPolicyServer,
value: u32,
) 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 IX509EnrollmentPolicyServer_Initialize(self: *const T, bstrPolicyServerUrl: ?BSTR, bstrPolicyServerId: ?BSTR, authFlags: X509EnrollmentAuthFlags, fIsUnTrusted: i16, context: X509CertificateEnrollmentContext) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).Initialize(@ptrCast(*const IX509EnrollmentPolicyServer, self), bstrPolicyServerUrl, bstrPolicyServerId, authFlags, fIsUnTrusted, context);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_LoadPolicy(self: *const T, option: X509EnrollmentPolicyLoadOption) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).LoadPolicy(@ptrCast(*const IX509EnrollmentPolicyServer, self), option);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_GetTemplates(self: *const T, pTemplates: ?*?*IX509CertificateTemplates) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).GetTemplates(@ptrCast(*const IX509EnrollmentPolicyServer, self), pTemplates);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_GetCAsForTemplate(self: *const T, pTemplate: ?*IX509CertificateTemplate, ppCAs: ?*?*ICertificationAuthorities) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).GetCAsForTemplate(@ptrCast(*const IX509EnrollmentPolicyServer, self), pTemplate, ppCAs);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_GetCAs(self: *const T, ppCAs: ?*?*ICertificationAuthorities) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).GetCAs(@ptrCast(*const IX509EnrollmentPolicyServer, self), ppCAs);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_Validate(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).Validate(@ptrCast(*const IX509EnrollmentPolicyServer, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_GetCustomOids(self: *const T, ppObjectIds: ?*?*IObjectIds) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).GetCustomOids(@ptrCast(*const IX509EnrollmentPolicyServer, self), ppObjectIds);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_GetNextUpdateTime(self: *const T, pDate: ?*f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).GetNextUpdateTime(@ptrCast(*const IX509EnrollmentPolicyServer, self), pDate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_GetLastUpdateTime(self: *const T, pDate: ?*f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).GetLastUpdateTime(@ptrCast(*const IX509EnrollmentPolicyServer, self), pDate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_GetPolicyServerUrl(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).GetPolicyServerUrl(@ptrCast(*const IX509EnrollmentPolicyServer, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_GetPolicyServerId(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).GetPolicyServerId(@ptrCast(*const IX509EnrollmentPolicyServer, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_GetFriendlyName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).GetFriendlyName(@ptrCast(*const IX509EnrollmentPolicyServer, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_GetIsDefaultCEP(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).GetIsDefaultCEP(@ptrCast(*const IX509EnrollmentPolicyServer, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_GetUseClientId(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).GetUseClientId(@ptrCast(*const IX509EnrollmentPolicyServer, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_GetAllowUnTrustedCA(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).GetAllowUnTrustedCA(@ptrCast(*const IX509EnrollmentPolicyServer, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_GetCachePath(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).GetCachePath(@ptrCast(*const IX509EnrollmentPolicyServer, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_GetCacheDir(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).GetCacheDir(@ptrCast(*const IX509EnrollmentPolicyServer, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_GetAuthFlags(self: *const T, pValue: ?*X509EnrollmentAuthFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).GetAuthFlags(@ptrCast(*const IX509EnrollmentPolicyServer, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_SetCredential(self: *const T, hWndParent: i32, flag: X509EnrollmentAuthFlags, strCredential: ?BSTR, strPassword: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).SetCredential(@ptrCast(*const IX509EnrollmentPolicyServer, self), hWndParent, flag, strCredential, strPassword);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_QueryChanges(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).QueryChanges(@ptrCast(*const IX509EnrollmentPolicyServer, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_InitializeImport(self: *const T, val: VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).InitializeImport(@ptrCast(*const IX509EnrollmentPolicyServer, self), val);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_Export(self: *const T, exportFlags: X509EnrollmentPolicyExportFlags, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).Export(@ptrCast(*const IX509EnrollmentPolicyServer, self), exportFlags, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_get_Cost(self: *const T, pValue: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).get_Cost(@ptrCast(*const IX509EnrollmentPolicyServer, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentPolicyServer_put_Cost(self: *const T, value: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentPolicyServer.VTable, self.vtable).put_Cost(@ptrCast(*const IX509EnrollmentPolicyServer, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.1'
const IID_IX509PolicyServerUrl_Value = @import("../../zig.zig").Guid.initString("884e204a-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509PolicyServerUrl = &IID_IX509PolicyServerUrl_Value;
pub const IX509PolicyServerUrl = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const IX509PolicyServerUrl,
context: X509CertificateEnrollmentContext,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Url: fn(
self: *const IX509PolicyServerUrl,
ppValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Url: fn(
self: *const IX509PolicyServerUrl,
pValue: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Default: fn(
self: *const IX509PolicyServerUrl,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Default: fn(
self: *const IX509PolicyServerUrl,
value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Flags: fn(
self: *const IX509PolicyServerUrl,
pValue: ?*PolicyServerUrlFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Flags: fn(
self: *const IX509PolicyServerUrl,
Flags: PolicyServerUrlFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AuthFlags: fn(
self: *const IX509PolicyServerUrl,
pValue: ?*X509EnrollmentAuthFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_AuthFlags: fn(
self: *const IX509PolicyServerUrl,
Flags: X509EnrollmentAuthFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Cost: fn(
self: *const IX509PolicyServerUrl,
pValue: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Cost: fn(
self: *const IX509PolicyServerUrl,
value: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetStringProperty: fn(
self: *const IX509PolicyServerUrl,
propertyId: PolicyServerUrlPropertyID,
ppValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetStringProperty: fn(
self: *const IX509PolicyServerUrl,
propertyId: PolicyServerUrlPropertyID,
pValue: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
UpdateRegistry: fn(
self: *const IX509PolicyServerUrl,
context: X509CertificateEnrollmentContext,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
RemoveFromRegistry: fn(
self: *const IX509PolicyServerUrl,
context: X509CertificateEnrollmentContext,
) 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 IX509PolicyServerUrl_Initialize(self: *const T, context: X509CertificateEnrollmentContext) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerUrl.VTable, self.vtable).Initialize(@ptrCast(*const IX509PolicyServerUrl, self), context);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerUrl_get_Url(self: *const T, ppValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerUrl.VTable, self.vtable).get_Url(@ptrCast(*const IX509PolicyServerUrl, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerUrl_put_Url(self: *const T, pValue: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerUrl.VTable, self.vtable).put_Url(@ptrCast(*const IX509PolicyServerUrl, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerUrl_get_Default(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerUrl.VTable, self.vtable).get_Default(@ptrCast(*const IX509PolicyServerUrl, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerUrl_put_Default(self: *const T, value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerUrl.VTable, self.vtable).put_Default(@ptrCast(*const IX509PolicyServerUrl, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerUrl_get_Flags(self: *const T, pValue: ?*PolicyServerUrlFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerUrl.VTable, self.vtable).get_Flags(@ptrCast(*const IX509PolicyServerUrl, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerUrl_put_Flags(self: *const T, Flags: PolicyServerUrlFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerUrl.VTable, self.vtable).put_Flags(@ptrCast(*const IX509PolicyServerUrl, self), Flags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerUrl_get_AuthFlags(self: *const T, pValue: ?*X509EnrollmentAuthFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerUrl.VTable, self.vtable).get_AuthFlags(@ptrCast(*const IX509PolicyServerUrl, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerUrl_put_AuthFlags(self: *const T, Flags: X509EnrollmentAuthFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerUrl.VTable, self.vtable).put_AuthFlags(@ptrCast(*const IX509PolicyServerUrl, self), Flags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerUrl_get_Cost(self: *const T, pValue: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerUrl.VTable, self.vtable).get_Cost(@ptrCast(*const IX509PolicyServerUrl, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerUrl_put_Cost(self: *const T, value: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerUrl.VTable, self.vtable).put_Cost(@ptrCast(*const IX509PolicyServerUrl, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerUrl_GetStringProperty(self: *const T, propertyId: PolicyServerUrlPropertyID, ppValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerUrl.VTable, self.vtable).GetStringProperty(@ptrCast(*const IX509PolicyServerUrl, self), propertyId, ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerUrl_SetStringProperty(self: *const T, propertyId: PolicyServerUrlPropertyID, pValue: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerUrl.VTable, self.vtable).SetStringProperty(@ptrCast(*const IX509PolicyServerUrl, self), propertyId, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerUrl_UpdateRegistry(self: *const T, context: X509CertificateEnrollmentContext) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerUrl.VTable, self.vtable).UpdateRegistry(@ptrCast(*const IX509PolicyServerUrl, self), context);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerUrl_RemoveFromRegistry(self: *const T, context: X509CertificateEnrollmentContext) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerUrl.VTable, self.vtable).RemoveFromRegistry(@ptrCast(*const IX509PolicyServerUrl, self), context);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509PolicyServerListManager_Value = @import("../../zig.zig").Guid.initString("884e204b-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509PolicyServerListManager = &IID_IX509PolicyServerListManager_Value;
pub const IX509PolicyServerListManager = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByIndex: fn(
self: *const IX509PolicyServerListManager,
Index: i32,
pVal: ?*?*IX509PolicyServerUrl,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const IX509PolicyServerListManager,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const IX509PolicyServerListManager,
pVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const IX509PolicyServerListManager,
pVal: ?*IX509PolicyServerUrl,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Remove: fn(
self: *const IX509PolicyServerListManager,
Index: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clear: fn(
self: *const IX509PolicyServerListManager,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Initialize: fn(
self: *const IX509PolicyServerListManager,
context: X509CertificateEnrollmentContext,
Flags: PolicyServerUrlFlags,
) 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 IX509PolicyServerListManager_get_ItemByIndex(self: *const T, Index: i32, pVal: ?*?*IX509PolicyServerUrl) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerListManager.VTable, self.vtable).get_ItemByIndex(@ptrCast(*const IX509PolicyServerListManager, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerListManager_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerListManager.VTable, self.vtable).get_Count(@ptrCast(*const IX509PolicyServerListManager, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerListManager_get__NewEnum(self: *const T, pVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerListManager.VTable, self.vtable).get__NewEnum(@ptrCast(*const IX509PolicyServerListManager, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerListManager_Add(self: *const T, pVal: ?*IX509PolicyServerUrl) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerListManager.VTable, self.vtable).Add(@ptrCast(*const IX509PolicyServerListManager, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerListManager_Remove(self: *const T, Index: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerListManager.VTable, self.vtable).Remove(@ptrCast(*const IX509PolicyServerListManager, self), Index);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerListManager_Clear(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerListManager.VTable, self.vtable).Clear(@ptrCast(*const IX509PolicyServerListManager, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509PolicyServerListManager_Initialize(self: *const T, context: X509CertificateEnrollmentContext, Flags: PolicyServerUrlFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509PolicyServerListManager.VTable, self.vtable).Initialize(@ptrCast(*const IX509PolicyServerListManager, self), context, Flags);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const X509RequestType = enum(i32) {
Any = 0,
Pkcs10 = 1,
Pkcs7 = 2,
Cmc = 3,
Certificate = 4,
};
pub const TypeAny = X509RequestType.Any;
pub const TypePkcs10 = X509RequestType.Pkcs10;
pub const TypePkcs7 = X509RequestType.Pkcs7;
pub const TypeCmc = X509RequestType.Cmc;
pub const TypeCertificate = X509RequestType.Certificate;
pub const X509RequestInheritOptions = enum(i32) {
Default = 0,
NewDefaultKey = 1,
NewSimilarKey = 2,
PrivateKey = 3,
PublicKey = 4,
KeyMask = 15,
None = 16,
RenewalCertificateFlag = 32,
TemplateFlag = 64,
SubjectFlag = 128,
ExtensionsFlag = 256,
SubjectAltNameFlag = 512,
ValidityPeriodFlag = 1024,
Reserved80000000 = -2147483648,
};
pub const InheritDefault = X509RequestInheritOptions.Default;
pub const InheritNewDefaultKey = X509RequestInheritOptions.NewDefaultKey;
pub const InheritNewSimilarKey = X509RequestInheritOptions.NewSimilarKey;
pub const InheritPrivateKey = X509RequestInheritOptions.PrivateKey;
pub const InheritPublicKey = X509RequestInheritOptions.PublicKey;
pub const InheritKeyMask = X509RequestInheritOptions.KeyMask;
pub const InheritNone = X509RequestInheritOptions.None;
pub const InheritRenewalCertificateFlag = X509RequestInheritOptions.RenewalCertificateFlag;
pub const InheritTemplateFlag = X509RequestInheritOptions.TemplateFlag;
pub const InheritSubjectFlag = X509RequestInheritOptions.SubjectFlag;
pub const InheritExtensionsFlag = X509RequestInheritOptions.ExtensionsFlag;
pub const InheritSubjectAltNameFlag = X509RequestInheritOptions.SubjectAltNameFlag;
pub const InheritValidityPeriodFlag = X509RequestInheritOptions.ValidityPeriodFlag;
pub const InheritReserved80000000 = X509RequestInheritOptions.Reserved80000000;
pub const InnerRequestLevel = enum(i32) {
Innermost = 0,
Next = 1,
};
pub const LevelInnermost = InnerRequestLevel.Innermost;
pub const LevelNext = InnerRequestLevel.Next;
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509CertificateRequest_Value = @import("../../zig.zig").Guid.initString("728ab341-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509CertificateRequest = &IID_IX509CertificateRequest_Value;
pub const IX509CertificateRequest = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const IX509CertificateRequest,
Context: X509CertificateEnrollmentContext,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Encode: fn(
self: *const IX509CertificateRequest,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ResetForEncode: fn(
self: *const IX509CertificateRequest,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetInnerRequest: fn(
self: *const IX509CertificateRequest,
Level: InnerRequestLevel,
ppValue: ?*?*IX509CertificateRequest,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Type: fn(
self: *const IX509CertificateRequest,
pValue: ?*X509RequestType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EnrollmentContext: fn(
self: *const IX509CertificateRequest,
pValue: ?*X509CertificateEnrollmentContext,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Silent: fn(
self: *const IX509CertificateRequest,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Silent: fn(
self: *const IX509CertificateRequest,
Value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ParentWindow: fn(
self: *const IX509CertificateRequest,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ParentWindow: fn(
self: *const IX509CertificateRequest,
Value: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_UIContextMessage: fn(
self: *const IX509CertificateRequest,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_UIContextMessage: fn(
self: *const IX509CertificateRequest,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SuppressDefaults: fn(
self: *const IX509CertificateRequest,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_SuppressDefaults: fn(
self: *const IX509CertificateRequest,
Value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RenewalCertificate: fn(
self: *const IX509CertificateRequest,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_RenewalCertificate: fn(
self: *const IX509CertificateRequest,
Encoding: EncodingType,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ClientId: fn(
self: *const IX509CertificateRequest,
pValue: ?*RequestClientInfoClientId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ClientId: fn(
self: *const IX509CertificateRequest,
Value: RequestClientInfoClientId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CspInformations: fn(
self: *const IX509CertificateRequest,
ppValue: ?*?*ICspInformations,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_CspInformations: fn(
self: *const IX509CertificateRequest,
pValue: ?*ICspInformations,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_HashAlgorithm: fn(
self: *const IX509CertificateRequest,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_HashAlgorithm: fn(
self: *const IX509CertificateRequest,
pValue: ?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AlternateSignatureAlgorithm: fn(
self: *const IX509CertificateRequest,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_AlternateSignatureAlgorithm: fn(
self: *const IX509CertificateRequest,
Value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RawData: fn(
self: *const IX509CertificateRequest,
Encoding: EncodingType,
pValue: ?*?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 IX509CertificateRequest_Initialize(self: *const T, Context: X509CertificateEnrollmentContext) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).Initialize(@ptrCast(*const IX509CertificateRequest, self), Context);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_Encode(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).Encode(@ptrCast(*const IX509CertificateRequest, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_ResetForEncode(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).ResetForEncode(@ptrCast(*const IX509CertificateRequest, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_GetInnerRequest(self: *const T, Level: InnerRequestLevel, ppValue: ?*?*IX509CertificateRequest) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).GetInnerRequest(@ptrCast(*const IX509CertificateRequest, self), Level, ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_get_Type(self: *const T, pValue: ?*X509RequestType) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).get_Type(@ptrCast(*const IX509CertificateRequest, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_get_EnrollmentContext(self: *const T, pValue: ?*X509CertificateEnrollmentContext) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).get_EnrollmentContext(@ptrCast(*const IX509CertificateRequest, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_get_Silent(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).get_Silent(@ptrCast(*const IX509CertificateRequest, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_put_Silent(self: *const T, Value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).put_Silent(@ptrCast(*const IX509CertificateRequest, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_get_ParentWindow(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).get_ParentWindow(@ptrCast(*const IX509CertificateRequest, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_put_ParentWindow(self: *const T, Value: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).put_ParentWindow(@ptrCast(*const IX509CertificateRequest, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_get_UIContextMessage(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).get_UIContextMessage(@ptrCast(*const IX509CertificateRequest, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_put_UIContextMessage(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).put_UIContextMessage(@ptrCast(*const IX509CertificateRequest, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_get_SuppressDefaults(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).get_SuppressDefaults(@ptrCast(*const IX509CertificateRequest, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_put_SuppressDefaults(self: *const T, Value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).put_SuppressDefaults(@ptrCast(*const IX509CertificateRequest, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_get_RenewalCertificate(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).get_RenewalCertificate(@ptrCast(*const IX509CertificateRequest, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_put_RenewalCertificate(self: *const T, Encoding: EncodingType, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).put_RenewalCertificate(@ptrCast(*const IX509CertificateRequest, self), Encoding, Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_get_ClientId(self: *const T, pValue: ?*RequestClientInfoClientId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).get_ClientId(@ptrCast(*const IX509CertificateRequest, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_put_ClientId(self: *const T, Value: RequestClientInfoClientId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).put_ClientId(@ptrCast(*const IX509CertificateRequest, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_get_CspInformations(self: *const T, ppValue: ?*?*ICspInformations) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).get_CspInformations(@ptrCast(*const IX509CertificateRequest, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_put_CspInformations(self: *const T, pValue: ?*ICspInformations) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).put_CspInformations(@ptrCast(*const IX509CertificateRequest, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_get_HashAlgorithm(self: *const T, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).get_HashAlgorithm(@ptrCast(*const IX509CertificateRequest, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_put_HashAlgorithm(self: *const T, pValue: ?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).put_HashAlgorithm(@ptrCast(*const IX509CertificateRequest, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_get_AlternateSignatureAlgorithm(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).get_AlternateSignatureAlgorithm(@ptrCast(*const IX509CertificateRequest, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_put_AlternateSignatureAlgorithm(self: *const T, Value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).put_AlternateSignatureAlgorithm(@ptrCast(*const IX509CertificateRequest, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequest_get_RawData(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequest.VTable, self.vtable).get_RawData(@ptrCast(*const IX509CertificateRequest, self), Encoding, pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const Pkcs10AllowedSignatureTypes = enum(i32) {
KeySignature = 1,
NullSignature = 2,
};
pub const AllowedKeySignature = Pkcs10AllowedSignatureTypes.KeySignature;
pub const AllowedNullSignature = Pkcs10AllowedSignatureTypes.NullSignature;
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509CertificateRequestPkcs10_Value = @import("../../zig.zig").Guid.initString("728ab342-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509CertificateRequestPkcs10 = &IID_IX509CertificateRequestPkcs10_Value;
pub const IX509CertificateRequestPkcs10 = extern struct {
pub const VTable = extern struct {
base: IX509CertificateRequest.VTable,
InitializeFromTemplateName: fn(
self: *const IX509CertificateRequestPkcs10,
Context: X509CertificateEnrollmentContext,
strTemplateName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromPrivateKey: fn(
self: *const IX509CertificateRequestPkcs10,
Context: X509CertificateEnrollmentContext,
pPrivateKey: ?*IX509PrivateKey,
strTemplateName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromPublicKey: fn(
self: *const IX509CertificateRequestPkcs10,
Context: X509CertificateEnrollmentContext,
pPublicKey: ?*IX509PublicKey,
strTemplateName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromCertificate: fn(
self: *const IX509CertificateRequestPkcs10,
Context: X509CertificateEnrollmentContext,
strCertificate: ?BSTR,
Encoding: EncodingType,
InheritOptions: X509RequestInheritOptions,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509CertificateRequestPkcs10,
strEncodedData: ?BSTR,
Encoding: EncodingType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CheckSignature: fn(
self: *const IX509CertificateRequestPkcs10,
AllowedSignatureTypes: Pkcs10AllowedSignatureTypes,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
IsSmartCard: fn(
self: *const IX509CertificateRequestPkcs10,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TemplateObjectId: fn(
self: *const IX509CertificateRequestPkcs10,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PublicKey: fn(
self: *const IX509CertificateRequestPkcs10,
ppValue: ?*?*IX509PublicKey,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PrivateKey: fn(
self: *const IX509CertificateRequestPkcs10,
ppValue: ?*?*IX509PrivateKey,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_NullSigned: fn(
self: *const IX509CertificateRequestPkcs10,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ReuseKey: fn(
self: *const IX509CertificateRequestPkcs10,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_OldCertificate: fn(
self: *const IX509CertificateRequestPkcs10,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Subject: fn(
self: *const IX509CertificateRequestPkcs10,
ppValue: ?*?*IX500DistinguishedName,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Subject: fn(
self: *const IX509CertificateRequestPkcs10,
pValue: ?*IX500DistinguishedName,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CspStatuses: fn(
self: *const IX509CertificateRequestPkcs10,
ppValue: ?*?*ICspStatuses,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SmimeCapabilities: fn(
self: *const IX509CertificateRequestPkcs10,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_SmimeCapabilities: fn(
self: *const IX509CertificateRequestPkcs10,
Value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SignatureInformation: fn(
self: *const IX509CertificateRequestPkcs10,
ppValue: ?*?*IX509SignatureInformation,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_KeyContainerNamePrefix: fn(
self: *const IX509CertificateRequestPkcs10,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_KeyContainerNamePrefix: fn(
self: *const IX509CertificateRequestPkcs10,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CryptAttributes: fn(
self: *const IX509CertificateRequestPkcs10,
ppValue: ?*?*ICryptAttributes,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_X509Extensions: fn(
self: *const IX509CertificateRequestPkcs10,
ppValue: ?*?*IX509Extensions,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CriticalExtensions: fn(
self: *const IX509CertificateRequestPkcs10,
ppValue: ?*?*IObjectIds,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SuppressOids: fn(
self: *const IX509CertificateRequestPkcs10,
ppValue: ?*?*IObjectIds,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RawDataToBeSigned: fn(
self: *const IX509CertificateRequestPkcs10,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Signature: fn(
self: *const IX509CertificateRequestPkcs10,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCspStatuses: fn(
self: *const IX509CertificateRequestPkcs10,
KeySpec: X509KeySpec,
ppCspStatuses: ?*?*ICspStatuses,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509CertificateRequest.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_InitializeFromTemplateName(self: *const T, Context: X509CertificateEnrollmentContext, strTemplateName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).InitializeFromTemplateName(@ptrCast(*const IX509CertificateRequestPkcs10, self), Context, strTemplateName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_InitializeFromPrivateKey(self: *const T, Context: X509CertificateEnrollmentContext, pPrivateKey: ?*IX509PrivateKey, strTemplateName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).InitializeFromPrivateKey(@ptrCast(*const IX509CertificateRequestPkcs10, self), Context, pPrivateKey, strTemplateName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_InitializeFromPublicKey(self: *const T, Context: X509CertificateEnrollmentContext, pPublicKey: ?*IX509PublicKey, strTemplateName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).InitializeFromPublicKey(@ptrCast(*const IX509CertificateRequestPkcs10, self), Context, pPublicKey, strTemplateName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_InitializeFromCertificate(self: *const T, Context: X509CertificateEnrollmentContext, strCertificate: ?BSTR, Encoding: EncodingType, InheritOptions: X509RequestInheritOptions) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).InitializeFromCertificate(@ptrCast(*const IX509CertificateRequestPkcs10, self), Context, strCertificate, Encoding, InheritOptions);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_InitializeDecode(self: *const T, strEncodedData: ?BSTR, Encoding: EncodingType) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509CertificateRequestPkcs10, self), strEncodedData, Encoding);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_CheckSignature(self: *const T, AllowedSignatureTypes: Pkcs10AllowedSignatureTypes) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).CheckSignature(@ptrCast(*const IX509CertificateRequestPkcs10, self), AllowedSignatureTypes);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_IsSmartCard(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).IsSmartCard(@ptrCast(*const IX509CertificateRequestPkcs10, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_get_TemplateObjectId(self: *const T, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).get_TemplateObjectId(@ptrCast(*const IX509CertificateRequestPkcs10, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_get_PublicKey(self: *const T, ppValue: ?*?*IX509PublicKey) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).get_PublicKey(@ptrCast(*const IX509CertificateRequestPkcs10, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_get_PrivateKey(self: *const T, ppValue: ?*?*IX509PrivateKey) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).get_PrivateKey(@ptrCast(*const IX509CertificateRequestPkcs10, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_get_NullSigned(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).get_NullSigned(@ptrCast(*const IX509CertificateRequestPkcs10, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_get_ReuseKey(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).get_ReuseKey(@ptrCast(*const IX509CertificateRequestPkcs10, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_get_OldCertificate(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).get_OldCertificate(@ptrCast(*const IX509CertificateRequestPkcs10, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_get_Subject(self: *const T, ppValue: ?*?*IX500DistinguishedName) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).get_Subject(@ptrCast(*const IX509CertificateRequestPkcs10, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_put_Subject(self: *const T, pValue: ?*IX500DistinguishedName) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).put_Subject(@ptrCast(*const IX509CertificateRequestPkcs10, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_get_CspStatuses(self: *const T, ppValue: ?*?*ICspStatuses) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).get_CspStatuses(@ptrCast(*const IX509CertificateRequestPkcs10, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_get_SmimeCapabilities(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).get_SmimeCapabilities(@ptrCast(*const IX509CertificateRequestPkcs10, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_put_SmimeCapabilities(self: *const T, Value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).put_SmimeCapabilities(@ptrCast(*const IX509CertificateRequestPkcs10, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_get_SignatureInformation(self: *const T, ppValue: ?*?*IX509SignatureInformation) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).get_SignatureInformation(@ptrCast(*const IX509CertificateRequestPkcs10, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_get_KeyContainerNamePrefix(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).get_KeyContainerNamePrefix(@ptrCast(*const IX509CertificateRequestPkcs10, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_put_KeyContainerNamePrefix(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).put_KeyContainerNamePrefix(@ptrCast(*const IX509CertificateRequestPkcs10, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_get_CryptAttributes(self: *const T, ppValue: ?*?*ICryptAttributes) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).get_CryptAttributes(@ptrCast(*const IX509CertificateRequestPkcs10, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_get_X509Extensions(self: *const T, ppValue: ?*?*IX509Extensions) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).get_X509Extensions(@ptrCast(*const IX509CertificateRequestPkcs10, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_get_CriticalExtensions(self: *const T, ppValue: ?*?*IObjectIds) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).get_CriticalExtensions(@ptrCast(*const IX509CertificateRequestPkcs10, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_get_SuppressOids(self: *const T, ppValue: ?*?*IObjectIds) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).get_SuppressOids(@ptrCast(*const IX509CertificateRequestPkcs10, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_get_RawDataToBeSigned(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).get_RawDataToBeSigned(@ptrCast(*const IX509CertificateRequestPkcs10, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_get_Signature(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).get_Signature(@ptrCast(*const IX509CertificateRequestPkcs10, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10_GetCspStatuses(self: *const T, KeySpec: X509KeySpec, ppCspStatuses: ?*?*ICspStatuses) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10.VTable, self.vtable).GetCspStatuses(@ptrCast(*const IX509CertificateRequestPkcs10, self), KeySpec, ppCspStatuses);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.1'
const IID_IX509CertificateRequestPkcs10V2_Value = @import("../../zig.zig").Guid.initString("728ab35b-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509CertificateRequestPkcs10V2 = &IID_IX509CertificateRequestPkcs10V2_Value;
pub const IX509CertificateRequestPkcs10V2 = extern struct {
pub const VTable = extern struct {
base: IX509CertificateRequestPkcs10.VTable,
InitializeFromTemplate: fn(
self: *const IX509CertificateRequestPkcs10V2,
context: X509CertificateEnrollmentContext,
pPolicyServer: ?*IX509EnrollmentPolicyServer,
pTemplate: ?*IX509CertificateTemplate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromPrivateKeyTemplate: fn(
self: *const IX509CertificateRequestPkcs10V2,
Context: X509CertificateEnrollmentContext,
pPrivateKey: ?*IX509PrivateKey,
pPolicyServer: ?*IX509EnrollmentPolicyServer,
pTemplate: ?*IX509CertificateTemplate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromPublicKeyTemplate: fn(
self: *const IX509CertificateRequestPkcs10V2,
Context: X509CertificateEnrollmentContext,
pPublicKey: ?*IX509PublicKey,
pPolicyServer: ?*IX509EnrollmentPolicyServer,
pTemplate: ?*IX509CertificateTemplate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PolicyServer: fn(
self: *const IX509CertificateRequestPkcs10V2,
ppPolicyServer: ?*?*IX509EnrollmentPolicyServer,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Template: fn(
self: *const IX509CertificateRequestPkcs10V2,
ppTemplate: ?*?*IX509CertificateTemplate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509CertificateRequestPkcs10.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V2_InitializeFromTemplate(self: *const T, context: X509CertificateEnrollmentContext, pPolicyServer: ?*IX509EnrollmentPolicyServer, pTemplate: ?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V2.VTable, self.vtable).InitializeFromTemplate(@ptrCast(*const IX509CertificateRequestPkcs10V2, self), context, pPolicyServer, pTemplate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V2_InitializeFromPrivateKeyTemplate(self: *const T, Context: X509CertificateEnrollmentContext, pPrivateKey: ?*IX509PrivateKey, pPolicyServer: ?*IX509EnrollmentPolicyServer, pTemplate: ?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V2.VTable, self.vtable).InitializeFromPrivateKeyTemplate(@ptrCast(*const IX509CertificateRequestPkcs10V2, self), Context, pPrivateKey, pPolicyServer, pTemplate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V2_InitializeFromPublicKeyTemplate(self: *const T, Context: X509CertificateEnrollmentContext, pPublicKey: ?*IX509PublicKey, pPolicyServer: ?*IX509EnrollmentPolicyServer, pTemplate: ?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V2.VTable, self.vtable).InitializeFromPublicKeyTemplate(@ptrCast(*const IX509CertificateRequestPkcs10V2, self), Context, pPublicKey, pPolicyServer, pTemplate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V2_get_PolicyServer(self: *const T, ppPolicyServer: ?*?*IX509EnrollmentPolicyServer) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V2.VTable, self.vtable).get_PolicyServer(@ptrCast(*const IX509CertificateRequestPkcs10V2, self), ppPolicyServer);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V2_get_Template(self: *const T, ppTemplate: ?*?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V2.VTable, self.vtable).get_Template(@ptrCast(*const IX509CertificateRequestPkcs10V2, self), ppTemplate);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IX509CertificateRequestPkcs10V3_Value = @import("../../zig.zig").Guid.initString("54ea9942-3d66-4530-b76e-7c9170d3ec52");
pub const IID_IX509CertificateRequestPkcs10V3 = &IID_IX509CertificateRequestPkcs10V3_Value;
pub const IX509CertificateRequestPkcs10V3 = extern struct {
pub const VTable = extern struct {
base: IX509CertificateRequestPkcs10V2.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AttestPrivateKey: fn(
self: *const IX509CertificateRequestPkcs10V3,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_AttestPrivateKey: fn(
self: *const IX509CertificateRequestPkcs10V3,
Value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AttestationEncryptionCertificate: fn(
self: *const IX509CertificateRequestPkcs10V3,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_AttestationEncryptionCertificate: fn(
self: *const IX509CertificateRequestPkcs10V3,
Encoding: EncodingType,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EncryptionAlgorithm: fn(
self: *const IX509CertificateRequestPkcs10V3,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_EncryptionAlgorithm: fn(
self: *const IX509CertificateRequestPkcs10V3,
pValue: ?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EncryptionStrength: fn(
self: *const IX509CertificateRequestPkcs10V3,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_EncryptionStrength: fn(
self: *const IX509CertificateRequestPkcs10V3,
Value: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ChallengePassword: fn(
self: *const IX509CertificateRequestPkcs10V3,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ChallengePassword: fn(
self: *const IX509CertificateRequestPkcs10V3,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_NameValuePairs: fn(
self: *const IX509CertificateRequestPkcs10V3,
ppValue: ?*?*IX509NameValuePairs,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509CertificateRequestPkcs10V2.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V3_get_AttestPrivateKey(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V3.VTable, self.vtable).get_AttestPrivateKey(@ptrCast(*const IX509CertificateRequestPkcs10V3, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V3_put_AttestPrivateKey(self: *const T, Value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V3.VTable, self.vtable).put_AttestPrivateKey(@ptrCast(*const IX509CertificateRequestPkcs10V3, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V3_get_AttestationEncryptionCertificate(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V3.VTable, self.vtable).get_AttestationEncryptionCertificate(@ptrCast(*const IX509CertificateRequestPkcs10V3, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V3_put_AttestationEncryptionCertificate(self: *const T, Encoding: EncodingType, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V3.VTable, self.vtable).put_AttestationEncryptionCertificate(@ptrCast(*const IX509CertificateRequestPkcs10V3, self), Encoding, Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V3_get_EncryptionAlgorithm(self: *const T, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V3.VTable, self.vtable).get_EncryptionAlgorithm(@ptrCast(*const IX509CertificateRequestPkcs10V3, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V3_put_EncryptionAlgorithm(self: *const T, pValue: ?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V3.VTable, self.vtable).put_EncryptionAlgorithm(@ptrCast(*const IX509CertificateRequestPkcs10V3, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V3_get_EncryptionStrength(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V3.VTable, self.vtable).get_EncryptionStrength(@ptrCast(*const IX509CertificateRequestPkcs10V3, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V3_put_EncryptionStrength(self: *const T, Value: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V3.VTable, self.vtable).put_EncryptionStrength(@ptrCast(*const IX509CertificateRequestPkcs10V3, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V3_get_ChallengePassword(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V3.VTable, self.vtable).get_ChallengePassword(@ptrCast(*const IX509CertificateRequestPkcs10V3, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V3_put_ChallengePassword(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V3.VTable, self.vtable).put_ChallengePassword(@ptrCast(*const IX509CertificateRequestPkcs10V3, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V3_get_NameValuePairs(self: *const T, ppValue: ?*?*IX509NameValuePairs) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V3.VTable, self.vtable).get_NameValuePairs(@ptrCast(*const IX509CertificateRequestPkcs10V3, self), ppValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const KeyAttestationClaimType = enum(i32) {
NONE = 0,
AUTHORITY_AND_SUBJECT = 3,
AUTHORITY_ONLY = 1,
SUBJECT_ONLY = 2,
UNKNOWN = 4096,
};
pub const XCN_NCRYPT_CLAIM_NONE = KeyAttestationClaimType.NONE;
pub const XCN_NCRYPT_CLAIM_AUTHORITY_AND_SUBJECT = KeyAttestationClaimType.AUTHORITY_AND_SUBJECT;
pub const XCN_NCRYPT_CLAIM_AUTHORITY_ONLY = KeyAttestationClaimType.AUTHORITY_ONLY;
pub const XCN_NCRYPT_CLAIM_SUBJECT_ONLY = KeyAttestationClaimType.SUBJECT_ONLY;
pub const XCN_NCRYPT_CLAIM_UNKNOWN = KeyAttestationClaimType.UNKNOWN;
const IID_IX509CertificateRequestPkcs10V4_Value = @import("../../zig.zig").Guid.initString("728ab363-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509CertificateRequestPkcs10V4 = &IID_IX509CertificateRequestPkcs10V4_Value;
pub const IX509CertificateRequestPkcs10V4 = extern struct {
pub const VTable = extern struct {
base: IX509CertificateRequestPkcs10V3.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ClaimType: fn(
self: *const IX509CertificateRequestPkcs10V4,
pValue: ?*KeyAttestationClaimType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ClaimType: fn(
self: *const IX509CertificateRequestPkcs10V4,
Value: KeyAttestationClaimType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AttestPrivateKeyPreferred: fn(
self: *const IX509CertificateRequestPkcs10V4,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_AttestPrivateKeyPreferred: fn(
self: *const IX509CertificateRequestPkcs10V4,
Value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509CertificateRequestPkcs10V3.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V4_get_ClaimType(self: *const T, pValue: ?*KeyAttestationClaimType) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V4.VTable, self.vtable).get_ClaimType(@ptrCast(*const IX509CertificateRequestPkcs10V4, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V4_put_ClaimType(self: *const T, Value: KeyAttestationClaimType) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V4.VTable, self.vtable).put_ClaimType(@ptrCast(*const IX509CertificateRequestPkcs10V4, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V4_get_AttestPrivateKeyPreferred(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V4.VTable, self.vtable).get_AttestPrivateKeyPreferred(@ptrCast(*const IX509CertificateRequestPkcs10V4, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs10V4_put_AttestPrivateKeyPreferred(self: *const T, Value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs10V4.VTable, self.vtable).put_AttestPrivateKeyPreferred(@ptrCast(*const IX509CertificateRequestPkcs10V4, self), Value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509CertificateRequestCertificate_Value = @import("../../zig.zig").Guid.initString("728ab343-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509CertificateRequestCertificate = &IID_IX509CertificateRequestCertificate_Value;
pub const IX509CertificateRequestCertificate = extern struct {
pub const VTable = extern struct {
base: IX509CertificateRequestPkcs10.VTable,
CheckPublicKeySignature: fn(
self: *const IX509CertificateRequestCertificate,
pPublicKey: ?*IX509PublicKey,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Issuer: fn(
self: *const IX509CertificateRequestCertificate,
ppValue: ?*?*IX500DistinguishedName,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Issuer: fn(
self: *const IX509CertificateRequestCertificate,
pValue: ?*IX500DistinguishedName,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_NotBefore: fn(
self: *const IX509CertificateRequestCertificate,
pValue: ?*f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_NotBefore: fn(
self: *const IX509CertificateRequestCertificate,
Value: f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_NotAfter: fn(
self: *const IX509CertificateRequestCertificate,
pValue: ?*f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_NotAfter: fn(
self: *const IX509CertificateRequestCertificate,
Value: f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SerialNumber: fn(
self: *const IX509CertificateRequestCertificate,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_SerialNumber: fn(
self: *const IX509CertificateRequestCertificate,
Encoding: EncodingType,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SignerCertificate: fn(
self: *const IX509CertificateRequestCertificate,
ppValue: ?*?*ISignerCertificate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_SignerCertificate: fn(
self: *const IX509CertificateRequestCertificate,
pValue: ?*ISignerCertificate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509CertificateRequestPkcs10.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCertificate_CheckPublicKeySignature(self: *const T, pPublicKey: ?*IX509PublicKey) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCertificate.VTable, self.vtable).CheckPublicKeySignature(@ptrCast(*const IX509CertificateRequestCertificate, self), pPublicKey);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCertificate_get_Issuer(self: *const T, ppValue: ?*?*IX500DistinguishedName) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCertificate.VTable, self.vtable).get_Issuer(@ptrCast(*const IX509CertificateRequestCertificate, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCertificate_put_Issuer(self: *const T, pValue: ?*IX500DistinguishedName) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCertificate.VTable, self.vtable).put_Issuer(@ptrCast(*const IX509CertificateRequestCertificate, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCertificate_get_NotBefore(self: *const T, pValue: ?*f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCertificate.VTable, self.vtable).get_NotBefore(@ptrCast(*const IX509CertificateRequestCertificate, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCertificate_put_NotBefore(self: *const T, Value: f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCertificate.VTable, self.vtable).put_NotBefore(@ptrCast(*const IX509CertificateRequestCertificate, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCertificate_get_NotAfter(self: *const T, pValue: ?*f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCertificate.VTable, self.vtable).get_NotAfter(@ptrCast(*const IX509CertificateRequestCertificate, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCertificate_put_NotAfter(self: *const T, Value: f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCertificate.VTable, self.vtable).put_NotAfter(@ptrCast(*const IX509CertificateRequestCertificate, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCertificate_get_SerialNumber(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCertificate.VTable, self.vtable).get_SerialNumber(@ptrCast(*const IX509CertificateRequestCertificate, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCertificate_put_SerialNumber(self: *const T, Encoding: EncodingType, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCertificate.VTable, self.vtable).put_SerialNumber(@ptrCast(*const IX509CertificateRequestCertificate, self), Encoding, Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCertificate_get_SignerCertificate(self: *const T, ppValue: ?*?*ISignerCertificate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCertificate.VTable, self.vtable).get_SignerCertificate(@ptrCast(*const IX509CertificateRequestCertificate, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCertificate_put_SignerCertificate(self: *const T, pValue: ?*ISignerCertificate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCertificate.VTable, self.vtable).put_SignerCertificate(@ptrCast(*const IX509CertificateRequestCertificate, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.1'
const IID_IX509CertificateRequestCertificate2_Value = @import("../../zig.zig").Guid.initString("728ab35a-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509CertificateRequestCertificate2 = &IID_IX509CertificateRequestCertificate2_Value;
pub const IX509CertificateRequestCertificate2 = extern struct {
pub const VTable = extern struct {
base: IX509CertificateRequestCertificate.VTable,
InitializeFromTemplate: fn(
self: *const IX509CertificateRequestCertificate2,
context: X509CertificateEnrollmentContext,
pPolicyServer: ?*IX509EnrollmentPolicyServer,
pTemplate: ?*IX509CertificateTemplate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromPrivateKeyTemplate: fn(
self: *const IX509CertificateRequestCertificate2,
Context: X509CertificateEnrollmentContext,
pPrivateKey: ?*IX509PrivateKey,
pPolicyServer: ?*IX509EnrollmentPolicyServer,
pTemplate: ?*IX509CertificateTemplate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PolicyServer: fn(
self: *const IX509CertificateRequestCertificate2,
ppPolicyServer: ?*?*IX509EnrollmentPolicyServer,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Template: fn(
self: *const IX509CertificateRequestCertificate2,
ppTemplate: ?*?*IX509CertificateTemplate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509CertificateRequestCertificate.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCertificate2_InitializeFromTemplate(self: *const T, context: X509CertificateEnrollmentContext, pPolicyServer: ?*IX509EnrollmentPolicyServer, pTemplate: ?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCertificate2.VTable, self.vtable).InitializeFromTemplate(@ptrCast(*const IX509CertificateRequestCertificate2, self), context, pPolicyServer, pTemplate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCertificate2_InitializeFromPrivateKeyTemplate(self: *const T, Context: X509CertificateEnrollmentContext, pPrivateKey: ?*IX509PrivateKey, pPolicyServer: ?*IX509EnrollmentPolicyServer, pTemplate: ?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCertificate2.VTable, self.vtable).InitializeFromPrivateKeyTemplate(@ptrCast(*const IX509CertificateRequestCertificate2, self), Context, pPrivateKey, pPolicyServer, pTemplate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCertificate2_get_PolicyServer(self: *const T, ppPolicyServer: ?*?*IX509EnrollmentPolicyServer) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCertificate2.VTable, self.vtable).get_PolicyServer(@ptrCast(*const IX509CertificateRequestCertificate2, self), ppPolicyServer);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCertificate2_get_Template(self: *const T, ppTemplate: ?*?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCertificate2.VTable, self.vtable).get_Template(@ptrCast(*const IX509CertificateRequestCertificate2, self), ppTemplate);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509CertificateRequestPkcs7_Value = @import("../../zig.zig").Guid.initString("728ab344-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509CertificateRequestPkcs7 = &IID_IX509CertificateRequestPkcs7_Value;
pub const IX509CertificateRequestPkcs7 = extern struct {
pub const VTable = extern struct {
base: IX509CertificateRequest.VTable,
InitializeFromTemplateName: fn(
self: *const IX509CertificateRequestPkcs7,
Context: X509CertificateEnrollmentContext,
strTemplateName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromCertificate: fn(
self: *const IX509CertificateRequestPkcs7,
Context: X509CertificateEnrollmentContext,
RenewalRequest: i16,
strCertificate: ?BSTR,
Encoding: EncodingType,
InheritOptions: X509RequestInheritOptions,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromInnerRequest: fn(
self: *const IX509CertificateRequestPkcs7,
pInnerRequest: ?*IX509CertificateRequest,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509CertificateRequestPkcs7,
strEncodedData: ?BSTR,
Encoding: EncodingType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RequesterName: fn(
self: *const IX509CertificateRequestPkcs7,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_RequesterName: fn(
self: *const IX509CertificateRequestPkcs7,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SignerCertificate: fn(
self: *const IX509CertificateRequestPkcs7,
ppValue: ?*?*ISignerCertificate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_SignerCertificate: fn(
self: *const IX509CertificateRequestPkcs7,
pValue: ?*ISignerCertificate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509CertificateRequest.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs7_InitializeFromTemplateName(self: *const T, Context: X509CertificateEnrollmentContext, strTemplateName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs7.VTable, self.vtable).InitializeFromTemplateName(@ptrCast(*const IX509CertificateRequestPkcs7, self), Context, strTemplateName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs7_InitializeFromCertificate(self: *const T, Context: X509CertificateEnrollmentContext, RenewalRequest: i16, strCertificate: ?BSTR, Encoding: EncodingType, InheritOptions: X509RequestInheritOptions) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs7.VTable, self.vtable).InitializeFromCertificate(@ptrCast(*const IX509CertificateRequestPkcs7, self), Context, RenewalRequest, strCertificate, Encoding, InheritOptions);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs7_InitializeFromInnerRequest(self: *const T, pInnerRequest: ?*IX509CertificateRequest) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs7.VTable, self.vtable).InitializeFromInnerRequest(@ptrCast(*const IX509CertificateRequestPkcs7, self), pInnerRequest);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs7_InitializeDecode(self: *const T, strEncodedData: ?BSTR, Encoding: EncodingType) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs7.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509CertificateRequestPkcs7, self), strEncodedData, Encoding);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs7_get_RequesterName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs7.VTable, self.vtable).get_RequesterName(@ptrCast(*const IX509CertificateRequestPkcs7, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs7_put_RequesterName(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs7.VTable, self.vtable).put_RequesterName(@ptrCast(*const IX509CertificateRequestPkcs7, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs7_get_SignerCertificate(self: *const T, ppValue: ?*?*ISignerCertificate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs7.VTable, self.vtable).get_SignerCertificate(@ptrCast(*const IX509CertificateRequestPkcs7, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs7_put_SignerCertificate(self: *const T, pValue: ?*ISignerCertificate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs7.VTable, self.vtable).put_SignerCertificate(@ptrCast(*const IX509CertificateRequestPkcs7, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.1'
const IID_IX509CertificateRequestPkcs7V2_Value = @import("../../zig.zig").Guid.initString("728ab35c-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509CertificateRequestPkcs7V2 = &IID_IX509CertificateRequestPkcs7V2_Value;
pub const IX509CertificateRequestPkcs7V2 = extern struct {
pub const VTable = extern struct {
base: IX509CertificateRequestPkcs7.VTable,
InitializeFromTemplate: fn(
self: *const IX509CertificateRequestPkcs7V2,
context: X509CertificateEnrollmentContext,
pPolicyServer: ?*IX509EnrollmentPolicyServer,
pTemplate: ?*IX509CertificateTemplate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PolicyServer: fn(
self: *const IX509CertificateRequestPkcs7V2,
ppPolicyServer: ?*?*IX509EnrollmentPolicyServer,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Template: fn(
self: *const IX509CertificateRequestPkcs7V2,
ppTemplate: ?*?*IX509CertificateTemplate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CheckCertificateSignature: fn(
self: *const IX509CertificateRequestPkcs7V2,
ValidateCertificateChain: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509CertificateRequestPkcs7.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs7V2_InitializeFromTemplate(self: *const T, context: X509CertificateEnrollmentContext, pPolicyServer: ?*IX509EnrollmentPolicyServer, pTemplate: ?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs7V2.VTable, self.vtable).InitializeFromTemplate(@ptrCast(*const IX509CertificateRequestPkcs7V2, self), context, pPolicyServer, pTemplate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs7V2_get_PolicyServer(self: *const T, ppPolicyServer: ?*?*IX509EnrollmentPolicyServer) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs7V2.VTable, self.vtable).get_PolicyServer(@ptrCast(*const IX509CertificateRequestPkcs7V2, self), ppPolicyServer);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs7V2_get_Template(self: *const T, ppTemplate: ?*?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs7V2.VTable, self.vtable).get_Template(@ptrCast(*const IX509CertificateRequestPkcs7V2, self), ppTemplate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestPkcs7V2_CheckCertificateSignature(self: *const T, ValidateCertificateChain: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestPkcs7V2.VTable, self.vtable).CheckCertificateSignature(@ptrCast(*const IX509CertificateRequestPkcs7V2, self), ValidateCertificateChain);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509CertificateRequestCmc_Value = @import("../../zig.zig").Guid.initString("728ab345-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509CertificateRequestCmc = &IID_IX509CertificateRequestCmc_Value;
pub const IX509CertificateRequestCmc = extern struct {
pub const VTable = extern struct {
base: IX509CertificateRequestPkcs7.VTable,
InitializeFromInnerRequestTemplateName: fn(
self: *const IX509CertificateRequestCmc,
pInnerRequest: ?*IX509CertificateRequest,
strTemplateName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TemplateObjectId: fn(
self: *const IX509CertificateRequestCmc,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_NullSigned: fn(
self: *const IX509CertificateRequestCmc,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CryptAttributes: fn(
self: *const IX509CertificateRequestCmc,
ppValue: ?*?*ICryptAttributes,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_NameValuePairs: fn(
self: *const IX509CertificateRequestCmc,
ppValue: ?*?*IX509NameValuePairs,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_X509Extensions: fn(
self: *const IX509CertificateRequestCmc,
ppValue: ?*?*IX509Extensions,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CriticalExtensions: fn(
self: *const IX509CertificateRequestCmc,
ppValue: ?*?*IObjectIds,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SuppressOids: fn(
self: *const IX509CertificateRequestCmc,
ppValue: ?*?*IObjectIds,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TransactionId: fn(
self: *const IX509CertificateRequestCmc,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_TransactionId: fn(
self: *const IX509CertificateRequestCmc,
Value: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SenderNonce: fn(
self: *const IX509CertificateRequestCmc,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_SenderNonce: fn(
self: *const IX509CertificateRequestCmc,
Encoding: EncodingType,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SignatureInformation: fn(
self: *const IX509CertificateRequestCmc,
ppValue: ?*?*IX509SignatureInformation,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ArchivePrivateKey: fn(
self: *const IX509CertificateRequestCmc,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ArchivePrivateKey: fn(
self: *const IX509CertificateRequestCmc,
Value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_KeyArchivalCertificate: fn(
self: *const IX509CertificateRequestCmc,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_KeyArchivalCertificate: fn(
self: *const IX509CertificateRequestCmc,
Encoding: EncodingType,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EncryptionAlgorithm: fn(
self: *const IX509CertificateRequestCmc,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_EncryptionAlgorithm: fn(
self: *const IX509CertificateRequestCmc,
pValue: ?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EncryptionStrength: fn(
self: *const IX509CertificateRequestCmc,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_EncryptionStrength: fn(
self: *const IX509CertificateRequestCmc,
Value: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EncryptedKeyHash: fn(
self: *const IX509CertificateRequestCmc,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SignerCertificates: fn(
self: *const IX509CertificateRequestCmc,
ppValue: ?*?*ISignerCertificates,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509CertificateRequestPkcs7.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_InitializeFromInnerRequestTemplateName(self: *const T, pInnerRequest: ?*IX509CertificateRequest, strTemplateName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).InitializeFromInnerRequestTemplateName(@ptrCast(*const IX509CertificateRequestCmc, self), pInnerRequest, strTemplateName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_get_TemplateObjectId(self: *const T, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).get_TemplateObjectId(@ptrCast(*const IX509CertificateRequestCmc, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_get_NullSigned(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).get_NullSigned(@ptrCast(*const IX509CertificateRequestCmc, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_get_CryptAttributes(self: *const T, ppValue: ?*?*ICryptAttributes) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).get_CryptAttributes(@ptrCast(*const IX509CertificateRequestCmc, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_get_NameValuePairs(self: *const T, ppValue: ?*?*IX509NameValuePairs) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).get_NameValuePairs(@ptrCast(*const IX509CertificateRequestCmc, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_get_X509Extensions(self: *const T, ppValue: ?*?*IX509Extensions) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).get_X509Extensions(@ptrCast(*const IX509CertificateRequestCmc, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_get_CriticalExtensions(self: *const T, ppValue: ?*?*IObjectIds) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).get_CriticalExtensions(@ptrCast(*const IX509CertificateRequestCmc, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_get_SuppressOids(self: *const T, ppValue: ?*?*IObjectIds) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).get_SuppressOids(@ptrCast(*const IX509CertificateRequestCmc, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_get_TransactionId(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).get_TransactionId(@ptrCast(*const IX509CertificateRequestCmc, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_put_TransactionId(self: *const T, Value: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).put_TransactionId(@ptrCast(*const IX509CertificateRequestCmc, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_get_SenderNonce(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).get_SenderNonce(@ptrCast(*const IX509CertificateRequestCmc, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_put_SenderNonce(self: *const T, Encoding: EncodingType, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).put_SenderNonce(@ptrCast(*const IX509CertificateRequestCmc, self), Encoding, Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_get_SignatureInformation(self: *const T, ppValue: ?*?*IX509SignatureInformation) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).get_SignatureInformation(@ptrCast(*const IX509CertificateRequestCmc, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_get_ArchivePrivateKey(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).get_ArchivePrivateKey(@ptrCast(*const IX509CertificateRequestCmc, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_put_ArchivePrivateKey(self: *const T, Value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).put_ArchivePrivateKey(@ptrCast(*const IX509CertificateRequestCmc, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_get_KeyArchivalCertificate(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).get_KeyArchivalCertificate(@ptrCast(*const IX509CertificateRequestCmc, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_put_KeyArchivalCertificate(self: *const T, Encoding: EncodingType, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).put_KeyArchivalCertificate(@ptrCast(*const IX509CertificateRequestCmc, self), Encoding, Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_get_EncryptionAlgorithm(self: *const T, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).get_EncryptionAlgorithm(@ptrCast(*const IX509CertificateRequestCmc, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_put_EncryptionAlgorithm(self: *const T, pValue: ?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).put_EncryptionAlgorithm(@ptrCast(*const IX509CertificateRequestCmc, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_get_EncryptionStrength(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).get_EncryptionStrength(@ptrCast(*const IX509CertificateRequestCmc, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_put_EncryptionStrength(self: *const T, Value: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).put_EncryptionStrength(@ptrCast(*const IX509CertificateRequestCmc, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_get_EncryptedKeyHash(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).get_EncryptedKeyHash(@ptrCast(*const IX509CertificateRequestCmc, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc_get_SignerCertificates(self: *const T, ppValue: ?*?*ISignerCertificates) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc.VTable, self.vtable).get_SignerCertificates(@ptrCast(*const IX509CertificateRequestCmc, self), ppValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.1'
const IID_IX509CertificateRequestCmc2_Value = @import("../../zig.zig").Guid.initString("728ab35d-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509CertificateRequestCmc2 = &IID_IX509CertificateRequestCmc2_Value;
pub const IX509CertificateRequestCmc2 = extern struct {
pub const VTable = extern struct {
base: IX509CertificateRequestCmc.VTable,
InitializeFromTemplate: fn(
self: *const IX509CertificateRequestCmc2,
context: X509CertificateEnrollmentContext,
pPolicyServer: ?*IX509EnrollmentPolicyServer,
pTemplate: ?*IX509CertificateTemplate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromInnerRequestTemplate: fn(
self: *const IX509CertificateRequestCmc2,
pInnerRequest: ?*IX509CertificateRequest,
pPolicyServer: ?*IX509EnrollmentPolicyServer,
pTemplate: ?*IX509CertificateTemplate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PolicyServer: fn(
self: *const IX509CertificateRequestCmc2,
ppPolicyServer: ?*?*IX509EnrollmentPolicyServer,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Template: fn(
self: *const IX509CertificateRequestCmc2,
ppTemplate: ?*?*IX509CertificateTemplate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CheckSignature: fn(
self: *const IX509CertificateRequestCmc2,
AllowedSignatureTypes: Pkcs10AllowedSignatureTypes,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CheckCertificateSignature: fn(
self: *const IX509CertificateRequestCmc2,
pSignerCertificate: ?*ISignerCertificate,
ValidateCertificateChain: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509CertificateRequestCmc.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc2_InitializeFromTemplate(self: *const T, context: X509CertificateEnrollmentContext, pPolicyServer: ?*IX509EnrollmentPolicyServer, pTemplate: ?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc2.VTable, self.vtable).InitializeFromTemplate(@ptrCast(*const IX509CertificateRequestCmc2, self), context, pPolicyServer, pTemplate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc2_InitializeFromInnerRequestTemplate(self: *const T, pInnerRequest: ?*IX509CertificateRequest, pPolicyServer: ?*IX509EnrollmentPolicyServer, pTemplate: ?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc2.VTable, self.vtable).InitializeFromInnerRequestTemplate(@ptrCast(*const IX509CertificateRequestCmc2, self), pInnerRequest, pPolicyServer, pTemplate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc2_get_PolicyServer(self: *const T, ppPolicyServer: ?*?*IX509EnrollmentPolicyServer) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc2.VTable, self.vtable).get_PolicyServer(@ptrCast(*const IX509CertificateRequestCmc2, self), ppPolicyServer);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc2_get_Template(self: *const T, ppTemplate: ?*?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc2.VTable, self.vtable).get_Template(@ptrCast(*const IX509CertificateRequestCmc2, self), ppTemplate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc2_CheckSignature(self: *const T, AllowedSignatureTypes: Pkcs10AllowedSignatureTypes) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc2.VTable, self.vtable).CheckSignature(@ptrCast(*const IX509CertificateRequestCmc2, self), AllowedSignatureTypes);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRequestCmc2_CheckCertificateSignature(self: *const T, pSignerCertificate: ?*ISignerCertificate, ValidateCertificateChain: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRequestCmc2.VTable, self.vtable).CheckCertificateSignature(@ptrCast(*const IX509CertificateRequestCmc2, self), pSignerCertificate, ValidateCertificateChain);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const InstallResponseRestrictionFlags = enum(i32) {
None = 0,
NoOutstandingRequest = 1,
UntrustedCertificate = 2,
UntrustedRoot = 4,
};
pub const AllowNone = InstallResponseRestrictionFlags.None;
pub const AllowNoOutstandingRequest = InstallResponseRestrictionFlags.NoOutstandingRequest;
pub const AllowUntrustedCertificate = InstallResponseRestrictionFlags.UntrustedCertificate;
pub const AllowUntrustedRoot = InstallResponseRestrictionFlags.UntrustedRoot;
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509Enrollment_Value = @import("../../zig.zig").Guid.initString("728ab346-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509Enrollment = &IID_IX509Enrollment_Value;
pub const IX509Enrollment = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const IX509Enrollment,
Context: X509CertificateEnrollmentContext,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromTemplateName: fn(
self: *const IX509Enrollment,
Context: X509CertificateEnrollmentContext,
strTemplateName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeFromRequest: fn(
self: *const IX509Enrollment,
pRequest: ?*IX509CertificateRequest,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CreateRequest: fn(
self: *const IX509Enrollment,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Enroll: fn(
self: *const IX509Enrollment,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InstallResponse: fn(
self: *const IX509Enrollment,
Restrictions: InstallResponseRestrictionFlags,
strResponse: ?BSTR,
Encoding: EncodingType,
strPassword: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CreatePFX: fn(
self: *const IX509Enrollment,
strPassword: ?BSTR,
ExportOptions: PFXExportOptions,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Request: fn(
self: *const IX509Enrollment,
pValue: ?*?*IX509CertificateRequest,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Silent: fn(
self: *const IX509Enrollment,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Silent: fn(
self: *const IX509Enrollment,
Value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ParentWindow: fn(
self: *const IX509Enrollment,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ParentWindow: fn(
self: *const IX509Enrollment,
Value: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_NameValuePairs: fn(
self: *const IX509Enrollment,
ppValue: ?*?*IX509NameValuePairs,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EnrollmentContext: fn(
self: *const IX509Enrollment,
pValue: ?*X509CertificateEnrollmentContext,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Status: fn(
self: *const IX509Enrollment,
ppValue: ?*?*IX509EnrollmentStatus,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Certificate: fn(
self: *const IX509Enrollment,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Response: fn(
self: *const IX509Enrollment,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CertificateFriendlyName: fn(
self: *const IX509Enrollment,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_CertificateFriendlyName: fn(
self: *const IX509Enrollment,
strValue: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CertificateDescription: fn(
self: *const IX509Enrollment,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_CertificateDescription: fn(
self: *const IX509Enrollment,
strValue: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RequestId: fn(
self: *const IX509Enrollment,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CAConfigString: fn(
self: *const IX509Enrollment,
pValue: ?*?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 IX509Enrollment_Initialize(self: *const T, Context: X509CertificateEnrollmentContext) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).Initialize(@ptrCast(*const IX509Enrollment, self), Context);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_InitializeFromTemplateName(self: *const T, Context: X509CertificateEnrollmentContext, strTemplateName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).InitializeFromTemplateName(@ptrCast(*const IX509Enrollment, self), Context, strTemplateName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_InitializeFromRequest(self: *const T, pRequest: ?*IX509CertificateRequest) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).InitializeFromRequest(@ptrCast(*const IX509Enrollment, self), pRequest);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_CreateRequest(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).CreateRequest(@ptrCast(*const IX509Enrollment, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_Enroll(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).Enroll(@ptrCast(*const IX509Enrollment, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_InstallResponse(self: *const T, Restrictions: InstallResponseRestrictionFlags, strResponse: ?BSTR, Encoding: EncodingType, strPassword: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).InstallResponse(@ptrCast(*const IX509Enrollment, self), Restrictions, strResponse, Encoding, strPassword);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_CreatePFX(self: *const T, strPassword: ?BSTR, ExportOptions: PFXExportOptions, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).CreatePFX(@ptrCast(*const IX509Enrollment, self), strPassword, ExportOptions, Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_get_Request(self: *const T, pValue: ?*?*IX509CertificateRequest) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).get_Request(@ptrCast(*const IX509Enrollment, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_get_Silent(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).get_Silent(@ptrCast(*const IX509Enrollment, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_put_Silent(self: *const T, Value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).put_Silent(@ptrCast(*const IX509Enrollment, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_get_ParentWindow(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).get_ParentWindow(@ptrCast(*const IX509Enrollment, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_put_ParentWindow(self: *const T, Value: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).put_ParentWindow(@ptrCast(*const IX509Enrollment, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_get_NameValuePairs(self: *const T, ppValue: ?*?*IX509NameValuePairs) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).get_NameValuePairs(@ptrCast(*const IX509Enrollment, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_get_EnrollmentContext(self: *const T, pValue: ?*X509CertificateEnrollmentContext) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).get_EnrollmentContext(@ptrCast(*const IX509Enrollment, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_get_Status(self: *const T, ppValue: ?*?*IX509EnrollmentStatus) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).get_Status(@ptrCast(*const IX509Enrollment, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_get_Certificate(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).get_Certificate(@ptrCast(*const IX509Enrollment, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_get_Response(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).get_Response(@ptrCast(*const IX509Enrollment, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_get_CertificateFriendlyName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).get_CertificateFriendlyName(@ptrCast(*const IX509Enrollment, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_put_CertificateFriendlyName(self: *const T, strValue: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).put_CertificateFriendlyName(@ptrCast(*const IX509Enrollment, self), strValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_get_CertificateDescription(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).get_CertificateDescription(@ptrCast(*const IX509Enrollment, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_put_CertificateDescription(self: *const T, strValue: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).put_CertificateDescription(@ptrCast(*const IX509Enrollment, self), strValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_get_RequestId(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).get_RequestId(@ptrCast(*const IX509Enrollment, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment_get_CAConfigString(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment.VTable, self.vtable).get_CAConfigString(@ptrCast(*const IX509Enrollment, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.1'
const IID_IX509Enrollment2_Value = @import("../../zig.zig").Guid.initString("728ab350-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509Enrollment2 = &IID_IX509Enrollment2_Value;
pub const IX509Enrollment2 = extern struct {
pub const VTable = extern struct {
base: IX509Enrollment.VTable,
InitializeFromTemplate: fn(
self: *const IX509Enrollment2,
context: X509CertificateEnrollmentContext,
pPolicyServer: ?*IX509EnrollmentPolicyServer,
pTemplate: ?*IX509CertificateTemplate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InstallResponse2: fn(
self: *const IX509Enrollment2,
Restrictions: InstallResponseRestrictionFlags,
strResponse: ?BSTR,
Encoding: EncodingType,
strPassword: ?BSTR,
strEnrollmentPolicyServerUrl: ?BSTR,
strEnrollmentPolicyServerID: ?BSTR,
EnrollmentPolicyServerFlags: PolicyServerUrlFlags,
authFlags: X509EnrollmentAuthFlags,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PolicyServer: fn(
self: *const IX509Enrollment2,
ppPolicyServer: ?*?*IX509EnrollmentPolicyServer,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Template: fn(
self: *const IX509Enrollment2,
ppTemplate: ?*?*IX509CertificateTemplate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RequestIdString: fn(
self: *const IX509Enrollment2,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509Enrollment.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment2_InitializeFromTemplate(self: *const T, context: X509CertificateEnrollmentContext, pPolicyServer: ?*IX509EnrollmentPolicyServer, pTemplate: ?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment2.VTable, self.vtable).InitializeFromTemplate(@ptrCast(*const IX509Enrollment2, self), context, pPolicyServer, pTemplate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment2_InstallResponse2(self: *const T, Restrictions: InstallResponseRestrictionFlags, strResponse: ?BSTR, Encoding: EncodingType, strPassword: ?BSTR, strEnrollmentPolicyServerUrl: ?BSTR, strEnrollmentPolicyServerID: ?BSTR, EnrollmentPolicyServerFlags: PolicyServerUrlFlags, authFlags: X509EnrollmentAuthFlags) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment2.VTable, self.vtable).InstallResponse2(@ptrCast(*const IX509Enrollment2, self), Restrictions, strResponse, Encoding, strPassword, strEnrollmentPolicyServerUrl, strEnrollmentPolicyServerID, EnrollmentPolicyServerFlags, authFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment2_get_PolicyServer(self: *const T, ppPolicyServer: ?*?*IX509EnrollmentPolicyServer) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment2.VTable, self.vtable).get_PolicyServer(@ptrCast(*const IX509Enrollment2, self), ppPolicyServer);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment2_get_Template(self: *const T, ppTemplate: ?*?*IX509CertificateTemplate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment2.VTable, self.vtable).get_Template(@ptrCast(*const IX509Enrollment2, self), ppTemplate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509Enrollment2_get_RequestIdString(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509Enrollment2.VTable, self.vtable).get_RequestIdString(@ptrCast(*const IX509Enrollment2, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const WebEnrollmentFlags = enum(i32) {
t = 1,
};
pub const EnrollPrompt = WebEnrollmentFlags.t;
// TODO: this type is limited to platform 'windows6.1'
const IID_IX509EnrollmentHelper_Value = @import("../../zig.zig").Guid.initString("728ab351-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509EnrollmentHelper = &IID_IX509EnrollmentHelper_Value;
pub const IX509EnrollmentHelper = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
AddPolicyServer: fn(
self: *const IX509EnrollmentHelper,
strEnrollmentPolicyServerURI: ?BSTR,
strEnrollmentPolicyID: ?BSTR,
EnrollmentPolicyServerFlags: PolicyServerUrlFlags,
authFlags: X509EnrollmentAuthFlags,
strCredential: ?BSTR,
strPassword: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddEnrollmentServer: fn(
self: *const IX509EnrollmentHelper,
strEnrollmentServerURI: ?BSTR,
authFlags: X509EnrollmentAuthFlags,
strCredential: ?BSTR,
strPassword: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Enroll: fn(
self: *const IX509EnrollmentHelper,
strEnrollmentPolicyServerURI: ?BSTR,
strTemplateName: ?BSTR,
Encoding: EncodingType,
enrollFlags: WebEnrollmentFlags,
pstrCertificate: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Initialize: fn(
self: *const IX509EnrollmentHelper,
Context: X509CertificateEnrollmentContext,
) 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 IX509EnrollmentHelper_AddPolicyServer(self: *const T, strEnrollmentPolicyServerURI: ?BSTR, strEnrollmentPolicyID: ?BSTR, EnrollmentPolicyServerFlags: PolicyServerUrlFlags, authFlags: X509EnrollmentAuthFlags, strCredential: ?BSTR, strPassword: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentHelper.VTable, self.vtable).AddPolicyServer(@ptrCast(*const IX509EnrollmentHelper, self), strEnrollmentPolicyServerURI, strEnrollmentPolicyID, EnrollmentPolicyServerFlags, authFlags, strCredential, strPassword);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentHelper_AddEnrollmentServer(self: *const T, strEnrollmentServerURI: ?BSTR, authFlags: X509EnrollmentAuthFlags, strCredential: ?BSTR, strPassword: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentHelper.VTable, self.vtable).AddEnrollmentServer(@ptrCast(*const IX509EnrollmentHelper, self), strEnrollmentServerURI, authFlags, strCredential, strPassword);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentHelper_Enroll(self: *const T, strEnrollmentPolicyServerURI: ?BSTR, strTemplateName: ?BSTR, Encoding: EncodingType, enrollFlags: WebEnrollmentFlags, pstrCertificate: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentHelper.VTable, self.vtable).Enroll(@ptrCast(*const IX509EnrollmentHelper, self), strEnrollmentPolicyServerURI, strTemplateName, Encoding, enrollFlags, pstrCertificate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509EnrollmentHelper_Initialize(self: *const T, Context: X509CertificateEnrollmentContext) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentHelper.VTable, self.vtable).Initialize(@ptrCast(*const IX509EnrollmentHelper, self), Context);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IX509EnrollmentWebClassFactory_Value = @import("../../zig.zig").Guid.initString("728ab349-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509EnrollmentWebClassFactory = &IID_IX509EnrollmentWebClassFactory_Value;
pub const IX509EnrollmentWebClassFactory = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
CreateObject: fn(
self: *const IX509EnrollmentWebClassFactory,
strProgID: ?BSTR,
ppIUnknown: ?*?*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 IX509EnrollmentWebClassFactory_CreateObject(self: *const T, strProgID: ?BSTR, ppIUnknown: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509EnrollmentWebClassFactory.VTable, self.vtable).CreateObject(@ptrCast(*const IX509EnrollmentWebClassFactory, self), strProgID, ppIUnknown);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.1'
const IID_IX509MachineEnrollmentFactory_Value = @import("../../zig.zig").Guid.initString("728ab352-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509MachineEnrollmentFactory = &IID_IX509MachineEnrollmentFactory_Value;
pub const IX509MachineEnrollmentFactory = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
CreateObject: fn(
self: *const IX509MachineEnrollmentFactory,
strProgID: ?BSTR,
ppIHelper: ?*?*IX509EnrollmentHelper,
) 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 IX509MachineEnrollmentFactory_CreateObject(self: *const T, strProgID: ?BSTR, ppIHelper: ?*?*IX509EnrollmentHelper) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509MachineEnrollmentFactory.VTable, self.vtable).CreateObject(@ptrCast(*const IX509MachineEnrollmentFactory, self), strProgID, ppIHelper);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const CRLRevocationReason = enum(i32) {
UNSPECIFIED = 0,
KEY_COMPROMISE = 1,
CA_COMPROMISE = 2,
AFFILIATION_CHANGED = 3,
SUPERSEDED = 4,
CESSATION_OF_OPERATION = 5,
CERTIFICATE_HOLD = 6,
REMOVE_FROM_CRL = 8,
PRIVILEGE_WITHDRAWN = 9,
AA_COMPROMISE = 10,
};
pub const XCN_CRL_REASON_UNSPECIFIED = CRLRevocationReason.UNSPECIFIED;
pub const XCN_CRL_REASON_KEY_COMPROMISE = CRLRevocationReason.KEY_COMPROMISE;
pub const XCN_CRL_REASON_CA_COMPROMISE = CRLRevocationReason.CA_COMPROMISE;
pub const XCN_CRL_REASON_AFFILIATION_CHANGED = CRLRevocationReason.AFFILIATION_CHANGED;
pub const XCN_CRL_REASON_SUPERSEDED = CRLRevocationReason.SUPERSEDED;
pub const XCN_CRL_REASON_CESSATION_OF_OPERATION = CRLRevocationReason.CESSATION_OF_OPERATION;
pub const XCN_CRL_REASON_CERTIFICATE_HOLD = CRLRevocationReason.CERTIFICATE_HOLD;
pub const XCN_CRL_REASON_REMOVE_FROM_CRL = CRLRevocationReason.REMOVE_FROM_CRL;
pub const XCN_CRL_REASON_PRIVILEGE_WITHDRAWN = CRLRevocationReason.PRIVILEGE_WITHDRAWN;
pub const XCN_CRL_REASON_AA_COMPROMISE = CRLRevocationReason.AA_COMPROMISE;
const IID_IX509CertificateRevocationListEntry_Value = @import("../../zig.zig").Guid.initString("728ab35e-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509CertificateRevocationListEntry = &IID_IX509CertificateRevocationListEntry_Value;
pub const IX509CertificateRevocationListEntry = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const IX509CertificateRevocationListEntry,
Encoding: EncodingType,
SerialNumber: ?BSTR,
RevocationDate: f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SerialNumber: fn(
self: *const IX509CertificateRevocationListEntry,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RevocationDate: fn(
self: *const IX509CertificateRevocationListEntry,
pValue: ?*f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RevocationReason: fn(
self: *const IX509CertificateRevocationListEntry,
pValue: ?*CRLRevocationReason,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_RevocationReason: fn(
self: *const IX509CertificateRevocationListEntry,
Value: CRLRevocationReason,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_X509Extensions: fn(
self: *const IX509CertificateRevocationListEntry,
ppValue: ?*?*IX509Extensions,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CriticalExtensions: fn(
self: *const IX509CertificateRevocationListEntry,
ppValue: ?*?*IObjectIds,
) 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 IX509CertificateRevocationListEntry_Initialize(self: *const T, Encoding: EncodingType, SerialNumber: ?BSTR, RevocationDate: f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationListEntry.VTable, self.vtable).Initialize(@ptrCast(*const IX509CertificateRevocationListEntry, self), Encoding, SerialNumber, RevocationDate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationListEntry_get_SerialNumber(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationListEntry.VTable, self.vtable).get_SerialNumber(@ptrCast(*const IX509CertificateRevocationListEntry, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationListEntry_get_RevocationDate(self: *const T, pValue: ?*f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationListEntry.VTable, self.vtable).get_RevocationDate(@ptrCast(*const IX509CertificateRevocationListEntry, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationListEntry_get_RevocationReason(self: *const T, pValue: ?*CRLRevocationReason) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationListEntry.VTable, self.vtable).get_RevocationReason(@ptrCast(*const IX509CertificateRevocationListEntry, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationListEntry_put_RevocationReason(self: *const T, Value: CRLRevocationReason) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationListEntry.VTable, self.vtable).put_RevocationReason(@ptrCast(*const IX509CertificateRevocationListEntry, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationListEntry_get_X509Extensions(self: *const T, ppValue: ?*?*IX509Extensions) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationListEntry.VTable, self.vtable).get_X509Extensions(@ptrCast(*const IX509CertificateRevocationListEntry, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationListEntry_get_CriticalExtensions(self: *const T, ppValue: ?*?*IObjectIds) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationListEntry.VTable, self.vtable).get_CriticalExtensions(@ptrCast(*const IX509CertificateRevocationListEntry, self), ppValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IX509CertificateRevocationListEntries_Value = @import("../../zig.zig").Guid.initString("728ab35f-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509CertificateRevocationListEntries = &IID_IX509CertificateRevocationListEntries_Value;
pub const IX509CertificateRevocationListEntries = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ItemByIndex: fn(
self: *const IX509CertificateRevocationListEntries,
Index: i32,
pVal: ?*?*IX509CertificateRevocationListEntry,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const IX509CertificateRevocationListEntries,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const IX509CertificateRevocationListEntries,
pVal: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const IX509CertificateRevocationListEntries,
pVal: ?*IX509CertificateRevocationListEntry,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Remove: fn(
self: *const IX509CertificateRevocationListEntries,
Index: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clear: fn(
self: *const IX509CertificateRevocationListEntries,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IndexBySerialNumber: fn(
self: *const IX509CertificateRevocationListEntries,
Encoding: EncodingType,
SerialNumber: ?BSTR,
pIndex: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddRange: fn(
self: *const IX509CertificateRevocationListEntries,
pValue: ?*IX509CertificateRevocationListEntries,
) 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 IX509CertificateRevocationListEntries_get_ItemByIndex(self: *const T, Index: i32, pVal: ?*?*IX509CertificateRevocationListEntry) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationListEntries.VTable, self.vtable).get_ItemByIndex(@ptrCast(*const IX509CertificateRevocationListEntries, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationListEntries_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationListEntries.VTable, self.vtable).get_Count(@ptrCast(*const IX509CertificateRevocationListEntries, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationListEntries_get__NewEnum(self: *const T, pVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationListEntries.VTable, self.vtable).get__NewEnum(@ptrCast(*const IX509CertificateRevocationListEntries, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationListEntries_Add(self: *const T, pVal: ?*IX509CertificateRevocationListEntry) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationListEntries.VTable, self.vtable).Add(@ptrCast(*const IX509CertificateRevocationListEntries, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationListEntries_Remove(self: *const T, Index: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationListEntries.VTable, self.vtable).Remove(@ptrCast(*const IX509CertificateRevocationListEntries, self), Index);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationListEntries_Clear(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationListEntries.VTable, self.vtable).Clear(@ptrCast(*const IX509CertificateRevocationListEntries, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationListEntries_get_IndexBySerialNumber(self: *const T, Encoding: EncodingType, SerialNumber: ?BSTR, pIndex: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationListEntries.VTable, self.vtable).get_IndexBySerialNumber(@ptrCast(*const IX509CertificateRevocationListEntries, self), Encoding, SerialNumber, pIndex);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationListEntries_AddRange(self: *const T, pValue: ?*IX509CertificateRevocationListEntries) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationListEntries.VTable, self.vtable).AddRange(@ptrCast(*const IX509CertificateRevocationListEntries, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IX509CertificateRevocationList_Value = @import("../../zig.zig").Guid.initString("728ab360-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509CertificateRevocationList = &IID_IX509CertificateRevocationList_Value;
pub const IX509CertificateRevocationList = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const IX509CertificateRevocationList,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDecode: fn(
self: *const IX509CertificateRevocationList,
strEncodedData: ?BSTR,
Encoding: EncodingType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Encode: fn(
self: *const IX509CertificateRevocationList,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ResetForEncode: fn(
self: *const IX509CertificateRevocationList,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CheckPublicKeySignature: fn(
self: *const IX509CertificateRevocationList,
pPublicKey: ?*IX509PublicKey,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CheckSignature: fn(
self: *const IX509CertificateRevocationList,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Issuer: fn(
self: *const IX509CertificateRevocationList,
ppValue: ?*?*IX500DistinguishedName,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Issuer: fn(
self: *const IX509CertificateRevocationList,
pValue: ?*IX500DistinguishedName,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ThisUpdate: fn(
self: *const IX509CertificateRevocationList,
pValue: ?*f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ThisUpdate: fn(
self: *const IX509CertificateRevocationList,
Value: f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_NextUpdate: fn(
self: *const IX509CertificateRevocationList,
pValue: ?*f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_NextUpdate: fn(
self: *const IX509CertificateRevocationList,
Value: f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_X509CRLEntries: fn(
self: *const IX509CertificateRevocationList,
ppValue: ?*?*IX509CertificateRevocationListEntries,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_X509Extensions: fn(
self: *const IX509CertificateRevocationList,
ppValue: ?*?*IX509Extensions,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CriticalExtensions: fn(
self: *const IX509CertificateRevocationList,
ppValue: ?*?*IObjectIds,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SignerCertificate: fn(
self: *const IX509CertificateRevocationList,
ppValue: ?*?*ISignerCertificate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_SignerCertificate: fn(
self: *const IX509CertificateRevocationList,
pValue: ?*ISignerCertificate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CRLNumber: fn(
self: *const IX509CertificateRevocationList,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_CRLNumber: fn(
self: *const IX509CertificateRevocationList,
Encoding: EncodingType,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CAVersion: fn(
self: *const IX509CertificateRevocationList,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_CAVersion: fn(
self: *const IX509CertificateRevocationList,
pValue: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BaseCRL: fn(
self: *const IX509CertificateRevocationList,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_NullSigned: fn(
self: *const IX509CertificateRevocationList,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_HashAlgorithm: fn(
self: *const IX509CertificateRevocationList,
ppValue: ?*?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_HashAlgorithm: fn(
self: *const IX509CertificateRevocationList,
pValue: ?*IObjectId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AlternateSignatureAlgorithm: fn(
self: *const IX509CertificateRevocationList,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_AlternateSignatureAlgorithm: fn(
self: *const IX509CertificateRevocationList,
Value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SignatureInformation: fn(
self: *const IX509CertificateRevocationList,
ppValue: ?*?*IX509SignatureInformation,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RawData: fn(
self: *const IX509CertificateRevocationList,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RawDataToBeSigned: fn(
self: *const IX509CertificateRevocationList,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Signature: fn(
self: *const IX509CertificateRevocationList,
Encoding: EncodingType,
pValue: ?*?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 IX509CertificateRevocationList_Initialize(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).Initialize(@ptrCast(*const IX509CertificateRevocationList, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_InitializeDecode(self: *const T, strEncodedData: ?BSTR, Encoding: EncodingType) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).InitializeDecode(@ptrCast(*const IX509CertificateRevocationList, self), strEncodedData, Encoding);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_Encode(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).Encode(@ptrCast(*const IX509CertificateRevocationList, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_ResetForEncode(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).ResetForEncode(@ptrCast(*const IX509CertificateRevocationList, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_CheckPublicKeySignature(self: *const T, pPublicKey: ?*IX509PublicKey) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).CheckPublicKeySignature(@ptrCast(*const IX509CertificateRevocationList, self), pPublicKey);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_CheckSignature(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).CheckSignature(@ptrCast(*const IX509CertificateRevocationList, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_get_Issuer(self: *const T, ppValue: ?*?*IX500DistinguishedName) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).get_Issuer(@ptrCast(*const IX509CertificateRevocationList, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_put_Issuer(self: *const T, pValue: ?*IX500DistinguishedName) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).put_Issuer(@ptrCast(*const IX509CertificateRevocationList, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_get_ThisUpdate(self: *const T, pValue: ?*f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).get_ThisUpdate(@ptrCast(*const IX509CertificateRevocationList, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_put_ThisUpdate(self: *const T, Value: f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).put_ThisUpdate(@ptrCast(*const IX509CertificateRevocationList, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_get_NextUpdate(self: *const T, pValue: ?*f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).get_NextUpdate(@ptrCast(*const IX509CertificateRevocationList, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_put_NextUpdate(self: *const T, Value: f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).put_NextUpdate(@ptrCast(*const IX509CertificateRevocationList, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_get_X509CRLEntries(self: *const T, ppValue: ?*?*IX509CertificateRevocationListEntries) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).get_X509CRLEntries(@ptrCast(*const IX509CertificateRevocationList, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_get_X509Extensions(self: *const T, ppValue: ?*?*IX509Extensions) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).get_X509Extensions(@ptrCast(*const IX509CertificateRevocationList, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_get_CriticalExtensions(self: *const T, ppValue: ?*?*IObjectIds) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).get_CriticalExtensions(@ptrCast(*const IX509CertificateRevocationList, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_get_SignerCertificate(self: *const T, ppValue: ?*?*ISignerCertificate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).get_SignerCertificate(@ptrCast(*const IX509CertificateRevocationList, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_put_SignerCertificate(self: *const T, pValue: ?*ISignerCertificate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).put_SignerCertificate(@ptrCast(*const IX509CertificateRevocationList, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_get_CRLNumber(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).get_CRLNumber(@ptrCast(*const IX509CertificateRevocationList, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_put_CRLNumber(self: *const T, Encoding: EncodingType, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).put_CRLNumber(@ptrCast(*const IX509CertificateRevocationList, self), Encoding, Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_get_CAVersion(self: *const T, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).get_CAVersion(@ptrCast(*const IX509CertificateRevocationList, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_put_CAVersion(self: *const T, pValue: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).put_CAVersion(@ptrCast(*const IX509CertificateRevocationList, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_get_BaseCRL(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).get_BaseCRL(@ptrCast(*const IX509CertificateRevocationList, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_get_NullSigned(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).get_NullSigned(@ptrCast(*const IX509CertificateRevocationList, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_get_HashAlgorithm(self: *const T, ppValue: ?*?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).get_HashAlgorithm(@ptrCast(*const IX509CertificateRevocationList, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_put_HashAlgorithm(self: *const T, pValue: ?*IObjectId) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).put_HashAlgorithm(@ptrCast(*const IX509CertificateRevocationList, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_get_AlternateSignatureAlgorithm(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).get_AlternateSignatureAlgorithm(@ptrCast(*const IX509CertificateRevocationList, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_put_AlternateSignatureAlgorithm(self: *const T, Value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).put_AlternateSignatureAlgorithm(@ptrCast(*const IX509CertificateRevocationList, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_get_SignatureInformation(self: *const T, ppValue: ?*?*IX509SignatureInformation) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).get_SignatureInformation(@ptrCast(*const IX509CertificateRevocationList, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_get_RawData(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).get_RawData(@ptrCast(*const IX509CertificateRevocationList, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_get_RawDataToBeSigned(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).get_RawDataToBeSigned(@ptrCast(*const IX509CertificateRevocationList, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509CertificateRevocationList_get_Signature(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509CertificateRevocationList.VTable, self.vtable).get_Signature(@ptrCast(*const IX509CertificateRevocationList, self), Encoding, pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_ICertificateAttestationChallenge_Value = @import("../../zig.zig").Guid.initString("6f175a7c-4a3a-40ae-9dba-592fd6bbf9b8");
pub const IID_ICertificateAttestationChallenge = &IID_ICertificateAttestationChallenge_Value;
pub const ICertificateAttestationChallenge = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const ICertificateAttestationChallenge,
Encoding: EncodingType,
strPendingFullCmcResponseWithChallenge: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
DecryptChallenge: fn(
self: *const ICertificateAttestationChallenge,
Encoding: EncodingType,
pstrEnvelopedPkcs7ReencryptedToCA: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RequestID: fn(
self: *const ICertificateAttestationChallenge,
pstrRequestID: ?*?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 ICertificateAttestationChallenge_Initialize(self: *const T, Encoding: EncodingType, strPendingFullCmcResponseWithChallenge: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificateAttestationChallenge.VTable, self.vtable).Initialize(@ptrCast(*const ICertificateAttestationChallenge, self), Encoding, strPendingFullCmcResponseWithChallenge);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificateAttestationChallenge_DecryptChallenge(self: *const T, Encoding: EncodingType, pstrEnvelopedPkcs7ReencryptedToCA: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificateAttestationChallenge.VTable, self.vtable).DecryptChallenge(@ptrCast(*const ICertificateAttestationChallenge, self), Encoding, pstrEnvelopedPkcs7ReencryptedToCA);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificateAttestationChallenge_get_RequestID(self: *const T, pstrRequestID: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificateAttestationChallenge.VTable, self.vtable).get_RequestID(@ptrCast(*const ICertificateAttestationChallenge, self), pstrRequestID);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_ICertificateAttestationChallenge2_Value = @import("../../zig.zig").Guid.initString("4631334d-e266-47d6-bd79-be53cb2e2753");
pub const IID_ICertificateAttestationChallenge2 = &IID_ICertificateAttestationChallenge2_Value;
pub const ICertificateAttestationChallenge2 = extern struct {
pub const VTable = extern struct {
base: ICertificateAttestationChallenge.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_KeyContainerName: fn(
self: *const ICertificateAttestationChallenge2,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_KeyBlob: fn(
self: *const ICertificateAttestationChallenge2,
Encoding: EncodingType,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertificateAttestationChallenge.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificateAttestationChallenge2_put_KeyContainerName(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificateAttestationChallenge2.VTable, self.vtable).put_KeyContainerName(@ptrCast(*const ICertificateAttestationChallenge2, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificateAttestationChallenge2_put_KeyBlob(self: *const T, Encoding: EncodingType, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificateAttestationChallenge2.VTable, self.vtable).put_KeyBlob(@ptrCast(*const ICertificateAttestationChallenge2, self), Encoding, Value);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IX509SCEPEnrollment_Value = @import("../../zig.zig").Guid.initString("728ab361-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509SCEPEnrollment = &IID_IX509SCEPEnrollment_Value;
pub const IX509SCEPEnrollment = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const IX509SCEPEnrollment,
pRequest: ?*IX509CertificateRequestPkcs10,
strThumbprint: ?BSTR,
ThumprintEncoding: EncodingType,
strServerCertificates: ?BSTR,
Encoding: EncodingType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeForPending: fn(
self: *const IX509SCEPEnrollment,
Context: X509CertificateEnrollmentContext,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CreateRequestMessage: fn(
self: *const IX509SCEPEnrollment,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CreateRetrievePendingMessage: fn(
self: *const IX509SCEPEnrollment,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CreateRetrieveCertificateMessage: fn(
self: *const IX509SCEPEnrollment,
Context: X509CertificateEnrollmentContext,
strIssuer: ?BSTR,
IssuerEncoding: EncodingType,
strSerialNumber: ?BSTR,
SerialNumberEncoding: EncodingType,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ProcessResponseMessage: fn(
self: *const IX509SCEPEnrollment,
strResponse: ?BSTR,
Encoding: EncodingType,
pDisposition: ?*X509SCEPDisposition,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ServerCapabilities: fn(
self: *const IX509SCEPEnrollment,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_FailInfo: fn(
self: *const IX509SCEPEnrollment,
pValue: ?*X509SCEPFailInfo,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SignerCertificate: fn(
self: *const IX509SCEPEnrollment,
ppValue: ?*?*ISignerCertificate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_SignerCertificate: fn(
self: *const IX509SCEPEnrollment,
pValue: ?*ISignerCertificate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_OldCertificate: fn(
self: *const IX509SCEPEnrollment,
ppValue: ?*?*ISignerCertificate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_OldCertificate: fn(
self: *const IX509SCEPEnrollment,
pValue: ?*ISignerCertificate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TransactionId: fn(
self: *const IX509SCEPEnrollment,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_TransactionId: fn(
self: *const IX509SCEPEnrollment,
Encoding: EncodingType,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Request: fn(
self: *const IX509SCEPEnrollment,
ppValue: ?*?*IX509CertificateRequestPkcs10,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CertificateFriendlyName: fn(
self: *const IX509SCEPEnrollment,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_CertificateFriendlyName: fn(
self: *const IX509SCEPEnrollment,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Status: fn(
self: *const IX509SCEPEnrollment,
ppValue: ?*?*IX509EnrollmentStatus,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Certificate: fn(
self: *const IX509SCEPEnrollment,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Silent: fn(
self: *const IX509SCEPEnrollment,
pValue: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Silent: fn(
self: *const IX509SCEPEnrollment,
Value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
DeleteRequest: fn(
self: *const IX509SCEPEnrollment,
) 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 IX509SCEPEnrollment_Initialize(self: *const T, pRequest: ?*IX509CertificateRequestPkcs10, strThumbprint: ?BSTR, ThumprintEncoding: EncodingType, strServerCertificates: ?BSTR, Encoding: EncodingType) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).Initialize(@ptrCast(*const IX509SCEPEnrollment, self), pRequest, strThumbprint, ThumprintEncoding, strServerCertificates, Encoding);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_InitializeForPending(self: *const T, Context: X509CertificateEnrollmentContext) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).InitializeForPending(@ptrCast(*const IX509SCEPEnrollment, self), Context);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_CreateRequestMessage(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).CreateRequestMessage(@ptrCast(*const IX509SCEPEnrollment, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_CreateRetrievePendingMessage(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).CreateRetrievePendingMessage(@ptrCast(*const IX509SCEPEnrollment, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_CreateRetrieveCertificateMessage(self: *const T, Context: X509CertificateEnrollmentContext, strIssuer: ?BSTR, IssuerEncoding: EncodingType, strSerialNumber: ?BSTR, SerialNumberEncoding: EncodingType, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).CreateRetrieveCertificateMessage(@ptrCast(*const IX509SCEPEnrollment, self), Context, strIssuer, IssuerEncoding, strSerialNumber, SerialNumberEncoding, Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_ProcessResponseMessage(self: *const T, strResponse: ?BSTR, Encoding: EncodingType, pDisposition: ?*X509SCEPDisposition) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).ProcessResponseMessage(@ptrCast(*const IX509SCEPEnrollment, self), strResponse, Encoding, pDisposition);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_put_ServerCapabilities(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).put_ServerCapabilities(@ptrCast(*const IX509SCEPEnrollment, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_get_FailInfo(self: *const T, pValue: ?*X509SCEPFailInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).get_FailInfo(@ptrCast(*const IX509SCEPEnrollment, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_get_SignerCertificate(self: *const T, ppValue: ?*?*ISignerCertificate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).get_SignerCertificate(@ptrCast(*const IX509SCEPEnrollment, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_put_SignerCertificate(self: *const T, pValue: ?*ISignerCertificate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).put_SignerCertificate(@ptrCast(*const IX509SCEPEnrollment, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_get_OldCertificate(self: *const T, ppValue: ?*?*ISignerCertificate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).get_OldCertificate(@ptrCast(*const IX509SCEPEnrollment, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_put_OldCertificate(self: *const T, pValue: ?*ISignerCertificate) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).put_OldCertificate(@ptrCast(*const IX509SCEPEnrollment, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_get_TransactionId(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).get_TransactionId(@ptrCast(*const IX509SCEPEnrollment, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_put_TransactionId(self: *const T, Encoding: EncodingType, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).put_TransactionId(@ptrCast(*const IX509SCEPEnrollment, self), Encoding, Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_get_Request(self: *const T, ppValue: ?*?*IX509CertificateRequestPkcs10) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).get_Request(@ptrCast(*const IX509SCEPEnrollment, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_get_CertificateFriendlyName(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).get_CertificateFriendlyName(@ptrCast(*const IX509SCEPEnrollment, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_put_CertificateFriendlyName(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).put_CertificateFriendlyName(@ptrCast(*const IX509SCEPEnrollment, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_get_Status(self: *const T, ppValue: ?*?*IX509EnrollmentStatus) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).get_Status(@ptrCast(*const IX509SCEPEnrollment, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_get_Certificate(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).get_Certificate(@ptrCast(*const IX509SCEPEnrollment, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_get_Silent(self: *const T, pValue: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).get_Silent(@ptrCast(*const IX509SCEPEnrollment, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_put_Silent(self: *const T, Value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).put_Silent(@ptrCast(*const IX509SCEPEnrollment, self), Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment_DeleteRequest(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment.VTable, self.vtable).DeleteRequest(@ptrCast(*const IX509SCEPEnrollment, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const X509SCEPProcessMessageFlags = enum(i32) {
Default = 0,
SkipCertInstall = 1,
};
pub const SCEPProcessDefault = X509SCEPProcessMessageFlags.Default;
pub const SCEPProcessSkipCertInstall = X509SCEPProcessMessageFlags.SkipCertInstall;
pub const DelayRetryAction = enum(i32) {
Unknown = 0,
None = 1,
Short = 2,
Long = 3,
Success = 4,
PastSuccess = 5,
};
pub const DelayRetryUnknown = DelayRetryAction.Unknown;
pub const DelayRetryNone = DelayRetryAction.None;
pub const DelayRetryShort = DelayRetryAction.Short;
pub const DelayRetryLong = DelayRetryAction.Long;
pub const DelayRetrySuccess = DelayRetryAction.Success;
pub const DelayRetryPastSuccess = DelayRetryAction.PastSuccess;
const IID_IX509SCEPEnrollment2_Value = @import("../../zig.zig").Guid.initString("728ab364-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509SCEPEnrollment2 = &IID_IX509SCEPEnrollment2_Value;
pub const IX509SCEPEnrollment2 = extern struct {
pub const VTable = extern struct {
base: IX509SCEPEnrollment.VTable,
CreateChallengeAnswerMessage: fn(
self: *const IX509SCEPEnrollment2,
Encoding: EncodingType,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ProcessResponseMessage2: fn(
self: *const IX509SCEPEnrollment2,
Flags: X509SCEPProcessMessageFlags,
strResponse: ?BSTR,
Encoding: EncodingType,
pDisposition: ?*X509SCEPDisposition,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ResultMessageText: fn(
self: *const IX509SCEPEnrollment2,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DelayRetry: fn(
self: *const IX509SCEPEnrollment2,
pValue: ?*DelayRetryAction,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ActivityId: fn(
self: *const IX509SCEPEnrollment2,
pValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ActivityId: fn(
self: *const IX509SCEPEnrollment2,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IX509SCEPEnrollment.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment2_CreateChallengeAnswerMessage(self: *const T, Encoding: EncodingType, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment2.VTable, self.vtable).CreateChallengeAnswerMessage(@ptrCast(*const IX509SCEPEnrollment2, self), Encoding, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment2_ProcessResponseMessage2(self: *const T, Flags: X509SCEPProcessMessageFlags, strResponse: ?BSTR, Encoding: EncodingType, pDisposition: ?*X509SCEPDisposition) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment2.VTable, self.vtable).ProcessResponseMessage2(@ptrCast(*const IX509SCEPEnrollment2, self), Flags, strResponse, Encoding, pDisposition);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment2_get_ResultMessageText(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment2.VTable, self.vtable).get_ResultMessageText(@ptrCast(*const IX509SCEPEnrollment2, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment2_get_DelayRetry(self: *const T, pValue: ?*DelayRetryAction) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment2.VTable, self.vtable).get_DelayRetry(@ptrCast(*const IX509SCEPEnrollment2, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment2_get_ActivityId(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment2.VTable, self.vtable).get_ActivityId(@ptrCast(*const IX509SCEPEnrollment2, self), pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollment2_put_ActivityId(self: *const T, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollment2.VTable, self.vtable).put_ActivityId(@ptrCast(*const IX509SCEPEnrollment2, self), Value);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IX509SCEPEnrollmentHelper_Value = @import("../../zig.zig").Guid.initString("728ab365-217d-11da-b2a4-000e7bbb2b09");
pub const IID_IX509SCEPEnrollmentHelper = &IID_IX509SCEPEnrollmentHelper_Value;
pub const IX509SCEPEnrollmentHelper = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const IX509SCEPEnrollmentHelper,
strServerUrl: ?BSTR,
strRequestHeaders: ?BSTR,
pRequest: ?*IX509CertificateRequestPkcs10,
strCACertificateThumbprint: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeForPending: fn(
self: *const IX509SCEPEnrollmentHelper,
strServerUrl: ?BSTR,
strRequestHeaders: ?BSTR,
Context: X509CertificateEnrollmentContext,
strTransactionId: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Enroll: fn(
self: *const IX509SCEPEnrollmentHelper,
ProcessFlags: X509SCEPProcessMessageFlags,
pDisposition: ?*X509SCEPDisposition,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
FetchPending: fn(
self: *const IX509SCEPEnrollmentHelper,
ProcessFlags: X509SCEPProcessMessageFlags,
pDisposition: ?*X509SCEPDisposition,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_X509SCEPEnrollment: fn(
self: *const IX509SCEPEnrollmentHelper,
ppValue: ?*?*IX509SCEPEnrollment,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ResultMessageText: fn(
self: *const IX509SCEPEnrollmentHelper,
pValue: ?*?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 IX509SCEPEnrollmentHelper_Initialize(self: *const T, strServerUrl: ?BSTR, strRequestHeaders: ?BSTR, pRequest: ?*IX509CertificateRequestPkcs10, strCACertificateThumbprint: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollmentHelper.VTable, self.vtable).Initialize(@ptrCast(*const IX509SCEPEnrollmentHelper, self), strServerUrl, strRequestHeaders, pRequest, strCACertificateThumbprint);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollmentHelper_InitializeForPending(self: *const T, strServerUrl: ?BSTR, strRequestHeaders: ?BSTR, Context: X509CertificateEnrollmentContext, strTransactionId: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollmentHelper.VTable, self.vtable).InitializeForPending(@ptrCast(*const IX509SCEPEnrollmentHelper, self), strServerUrl, strRequestHeaders, Context, strTransactionId);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollmentHelper_Enroll(self: *const T, ProcessFlags: X509SCEPProcessMessageFlags, pDisposition: ?*X509SCEPDisposition) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollmentHelper.VTable, self.vtable).Enroll(@ptrCast(*const IX509SCEPEnrollmentHelper, self), ProcessFlags, pDisposition);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollmentHelper_FetchPending(self: *const T, ProcessFlags: X509SCEPProcessMessageFlags, pDisposition: ?*X509SCEPDisposition) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollmentHelper.VTable, self.vtable).FetchPending(@ptrCast(*const IX509SCEPEnrollmentHelper, self), ProcessFlags, pDisposition);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollmentHelper_get_X509SCEPEnrollment(self: *const T, ppValue: ?*?*IX509SCEPEnrollment) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollmentHelper.VTable, self.vtable).get_X509SCEPEnrollment(@ptrCast(*const IX509SCEPEnrollmentHelper, self), ppValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IX509SCEPEnrollmentHelper_get_ResultMessageText(self: *const T, pValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IX509SCEPEnrollmentHelper.VTable, self.vtable).get_ResultMessageText(@ptrCast(*const IX509SCEPEnrollmentHelper, self), pValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const X509CertificateTemplateGeneralFlag = enum(i32) {
MachineType = 64,
CA = 128,
CrossCA = 2048,
Default = 65536,
Modified = 131072,
DonotPersist = 4096,
};
pub const GeneralMachineType = X509CertificateTemplateGeneralFlag.MachineType;
pub const GeneralCA = X509CertificateTemplateGeneralFlag.CA;
pub const GeneralCrossCA = X509CertificateTemplateGeneralFlag.CrossCA;
pub const GeneralDefault = X509CertificateTemplateGeneralFlag.Default;
pub const GeneralModified = X509CertificateTemplateGeneralFlag.Modified;
pub const GeneralDonotPersist = X509CertificateTemplateGeneralFlag.DonotPersist;
pub const X509CertificateTemplateEnrollmentFlag = enum(i32) {
IncludeSymmetricAlgorithms = 1,
PendAllRequests = 2,
PublishToKRAContainer = 4,
PublishToDS = 8,
AutoEnrollmentCheckUserDSCertificate = 16,
AutoEnrollment = 32,
DomainAuthenticationNotRequired = 128,
PreviousApprovalValidateReenrollment = 64,
UserInteractionRequired = 256,
AddTemplateName = 512,
RemoveInvalidCertificateFromPersonalStore = 1024,
AllowEnrollOnBehalfOf = 2048,
AddOCSPNoCheck = 4096,
ReuseKeyOnFullSmartCard = 8192,
NoRevocationInfoInCerts = 16384,
IncludeBasicConstraintsForEECerts = 32768,
PreviousApprovalKeyBasedValidateReenrollment = 65536,
CertificateIssuancePoliciesFromRequest = 131072,
SkipAutoRenewal = 262144,
};
pub const EnrollmentIncludeSymmetricAlgorithms = X509CertificateTemplateEnrollmentFlag.IncludeSymmetricAlgorithms;
pub const EnrollmentPendAllRequests = X509CertificateTemplateEnrollmentFlag.PendAllRequests;
pub const EnrollmentPublishToKRAContainer = X509CertificateTemplateEnrollmentFlag.PublishToKRAContainer;
pub const EnrollmentPublishToDS = X509CertificateTemplateEnrollmentFlag.PublishToDS;
pub const EnrollmentAutoEnrollmentCheckUserDSCertificate = X509CertificateTemplateEnrollmentFlag.AutoEnrollmentCheckUserDSCertificate;
pub const EnrollmentAutoEnrollment = X509CertificateTemplateEnrollmentFlag.AutoEnrollment;
pub const EnrollmentDomainAuthenticationNotRequired = X509CertificateTemplateEnrollmentFlag.DomainAuthenticationNotRequired;
pub const EnrollmentPreviousApprovalValidateReenrollment = X509CertificateTemplateEnrollmentFlag.PreviousApprovalValidateReenrollment;
pub const EnrollmentUserInteractionRequired = X509CertificateTemplateEnrollmentFlag.UserInteractionRequired;
pub const EnrollmentAddTemplateName = X509CertificateTemplateEnrollmentFlag.AddTemplateName;
pub const EnrollmentRemoveInvalidCertificateFromPersonalStore = X509CertificateTemplateEnrollmentFlag.RemoveInvalidCertificateFromPersonalStore;
pub const EnrollmentAllowEnrollOnBehalfOf = X509CertificateTemplateEnrollmentFlag.AllowEnrollOnBehalfOf;
pub const EnrollmentAddOCSPNoCheck = X509CertificateTemplateEnrollmentFlag.AddOCSPNoCheck;
pub const EnrollmentReuseKeyOnFullSmartCard = X509CertificateTemplateEnrollmentFlag.ReuseKeyOnFullSmartCard;
pub const EnrollmentNoRevocationInfoInCerts = X509CertificateTemplateEnrollmentFlag.NoRevocationInfoInCerts;
pub const EnrollmentIncludeBasicConstraintsForEECerts = X509CertificateTemplateEnrollmentFlag.IncludeBasicConstraintsForEECerts;
pub const EnrollmentPreviousApprovalKeyBasedValidateReenrollment = X509CertificateTemplateEnrollmentFlag.PreviousApprovalKeyBasedValidateReenrollment;
pub const EnrollmentCertificateIssuancePoliciesFromRequest = X509CertificateTemplateEnrollmentFlag.CertificateIssuancePoliciesFromRequest;
pub const EnrollmentSkipAutoRenewal = X509CertificateTemplateEnrollmentFlag.SkipAutoRenewal;
pub const X509CertificateTemplateSubjectNameFlag = enum(i32) {
NameEnrolleeSupplies = 1,
NameRequireDirectoryPath = -2147483648,
NameRequireCommonName = 1073741824,
NameRequireEmail = 536870912,
NameRequireDNS = 268435456,
NameAndAlternativeNameOldCertSupplies = 8,
AlternativeNameEnrolleeSupplies = 65536,
AlternativeNameRequireDirectoryGUID = 16777216,
AlternativeNameRequireUPN = 33554432,
AlternativeNameRequireEmail = 67108864,
AlternativeNameRequireSPN = 8388608,
AlternativeNameRequireDNS = 134217728,
AlternativeNameRequireDomainDNS = 4194304,
};
pub const SubjectNameEnrolleeSupplies = X509CertificateTemplateSubjectNameFlag.NameEnrolleeSupplies;
pub const SubjectNameRequireDirectoryPath = X509CertificateTemplateSubjectNameFlag.NameRequireDirectoryPath;
pub const SubjectNameRequireCommonName = X509CertificateTemplateSubjectNameFlag.NameRequireCommonName;
pub const SubjectNameRequireEmail = X509CertificateTemplateSubjectNameFlag.NameRequireEmail;
pub const SubjectNameRequireDNS = X509CertificateTemplateSubjectNameFlag.NameRequireDNS;
pub const SubjectNameAndAlternativeNameOldCertSupplies = X509CertificateTemplateSubjectNameFlag.NameAndAlternativeNameOldCertSupplies;
pub const SubjectAlternativeNameEnrolleeSupplies = X509CertificateTemplateSubjectNameFlag.AlternativeNameEnrolleeSupplies;
pub const SubjectAlternativeNameRequireDirectoryGUID = X509CertificateTemplateSubjectNameFlag.AlternativeNameRequireDirectoryGUID;
pub const SubjectAlternativeNameRequireUPN = X509CertificateTemplateSubjectNameFlag.AlternativeNameRequireUPN;
pub const SubjectAlternativeNameRequireEmail = X509CertificateTemplateSubjectNameFlag.AlternativeNameRequireEmail;
pub const SubjectAlternativeNameRequireSPN = X509CertificateTemplateSubjectNameFlag.AlternativeNameRequireSPN;
pub const SubjectAlternativeNameRequireDNS = X509CertificateTemplateSubjectNameFlag.AlternativeNameRequireDNS;
pub const SubjectAlternativeNameRequireDomainDNS = X509CertificateTemplateSubjectNameFlag.AlternativeNameRequireDomainDNS;
pub const X509CertificateTemplatePrivateKeyFlag = enum(i32) {
RequireArchival = 1,
Exportable = 16,
RequireStrongKeyProtection = 32,
RequireAlternateSignatureAlgorithm = 64,
RequireSameKeyRenewal = 128,
UseLegacyProvider = 256,
EKTrustOnUse = 512,
EKValidateCert = 1024,
EKValidateKey = 2048,
AttestNone = 0,
AttestPreferred = 4096,
AttestRequired = 8192,
AttestMask = 12288,
AttestWithoutPolicy = 16384,
ServerVersionMask = 983040,
// ServerVersionShift = 16, this enum value conflicts with Exportable
HelloKspKey = 1048576,
HelloLogonKey = 2097152,
ClientVersionMask = 251658240,
ClientVersionShift = 24,
};
pub const PrivateKeyRequireArchival = X509CertificateTemplatePrivateKeyFlag.RequireArchival;
pub const PrivateKeyExportable = X509CertificateTemplatePrivateKeyFlag.Exportable;
pub const PrivateKeyRequireStrongKeyProtection = X509CertificateTemplatePrivateKeyFlag.RequireStrongKeyProtection;
pub const PrivateKeyRequireAlternateSignatureAlgorithm = X509CertificateTemplatePrivateKeyFlag.RequireAlternateSignatureAlgorithm;
pub const PrivateKeyRequireSameKeyRenewal = X509CertificateTemplatePrivateKeyFlag.RequireSameKeyRenewal;
pub const PrivateKeyUseLegacyProvider = X509CertificateTemplatePrivateKeyFlag.UseLegacyProvider;
pub const PrivateKeyEKTrustOnUse = X509CertificateTemplatePrivateKeyFlag.EKTrustOnUse;
pub const PrivateKeyEKValidateCert = X509CertificateTemplatePrivateKeyFlag.EKValidateCert;
pub const PrivateKeyEKValidateKey = X509CertificateTemplatePrivateKeyFlag.EKValidateKey;
pub const PrivateKeyAttestNone = X509CertificateTemplatePrivateKeyFlag.AttestNone;
pub const PrivateKeyAttestPreferred = X509CertificateTemplatePrivateKeyFlag.AttestPreferred;
pub const PrivateKeyAttestRequired = X509CertificateTemplatePrivateKeyFlag.AttestRequired;
pub const PrivateKeyAttestMask = X509CertificateTemplatePrivateKeyFlag.AttestMask;
pub const PrivateKeyAttestWithoutPolicy = X509CertificateTemplatePrivateKeyFlag.AttestWithoutPolicy;
pub const PrivateKeyServerVersionMask = X509CertificateTemplatePrivateKeyFlag.ServerVersionMask;
pub const PrivateKeyServerVersionShift = X509CertificateTemplatePrivateKeyFlag.Exportable;
pub const PrivateKeyHelloKspKey = X509CertificateTemplatePrivateKeyFlag.HelloKspKey;
pub const PrivateKeyHelloLogonKey = X509CertificateTemplatePrivateKeyFlag.HelloLogonKey;
pub const PrivateKeyClientVersionMask = X509CertificateTemplatePrivateKeyFlag.ClientVersionMask;
pub const PrivateKeyClientVersionShift = X509CertificateTemplatePrivateKeyFlag.ClientVersionShift;
pub const ImportPFXFlags = enum(i32) {
None = 0,
MachineContext = 1,
ForceOverwrite = 2,
Silent = 4,
SaveProperties = 8,
Exportable = 16,
ExportableEncrypted = 32,
NoUserProtected = 64,
UserProtected = 128,
UserProtectedHigh = 256,
InstallCertificate = 512,
InstallChain = 1024,
InstallChainAndRoot = 2048,
};
pub const ImportNone = ImportPFXFlags.None;
pub const ImportMachineContext = ImportPFXFlags.MachineContext;
pub const ImportForceOverwrite = ImportPFXFlags.ForceOverwrite;
pub const ImportSilent = ImportPFXFlags.Silent;
pub const ImportSaveProperties = ImportPFXFlags.SaveProperties;
pub const ImportExportable = ImportPFXFlags.Exportable;
pub const ImportExportableEncrypted = ImportPFXFlags.ExportableEncrypted;
pub const ImportNoUserProtected = ImportPFXFlags.NoUserProtected;
pub const ImportUserProtected = ImportPFXFlags.UserProtected;
pub const ImportUserProtectedHigh = ImportPFXFlags.UserProtectedHigh;
pub const ImportInstallCertificate = ImportPFXFlags.InstallCertificate;
pub const ImportInstallChain = ImportPFXFlags.InstallChain;
pub const ImportInstallChainAndRoot = ImportPFXFlags.InstallChainAndRoot;
pub const FNIMPORTPFXTOPROVIDER = fn(
hWndParent: ?HWND,
// TODO: what to do with BytesParamIndex 2?
pbPFX: ?*const u8,
cbPFX: u32,
ImportFlags: ImportPFXFlags,
pwszPassword: ?[*:0]const u16,
pwszProviderName: ?[*:0]const u16,
pwszReaderName: ?[*:0]const u16,
pwszContainerNamePrefix: ?[*:0]const u16,
pwszPin: ?[*:0]const u16,
pwszFriendlyName: ?[*:0]const u16,
pcCertOut: ?*u32,
prgpCertOut: ?*?*?*CERT_CONTEXT,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const FNIMPORTPFXTOPROVIDERFREEDATA = fn(
cCert: u32,
rgpCert: ?[*]?*CERT_CONTEXT,
) callconv(@import("std").os.windows.WINAPI) void;
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertEncodeStringArray_Value = @import("../../zig.zig").Guid.initString("12a88820-7494-11d0-8816-00a0c903b83c");
pub const IID_ICertEncodeStringArray = &IID_ICertEncodeStringArray_Value;
pub const ICertEncodeStringArray = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Decode: fn(
self: *const ICertEncodeStringArray,
strBinary: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetStringType: fn(
self: *const ICertEncodeStringArray,
pStringType: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCount: fn(
self: *const ICertEncodeStringArray,
pCount: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetValue: fn(
self: *const ICertEncodeStringArray,
Index: i32,
pstr: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reset: fn(
self: *const ICertEncodeStringArray,
Count: i32,
StringType: CERT_RDN_ATTR_VALUE_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetValue: fn(
self: *const ICertEncodeStringArray,
Index: i32,
str: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Encode: fn(
self: *const ICertEncodeStringArray,
pstrBinary: ?*?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 ICertEncodeStringArray_Decode(self: *const T, strBinary: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeStringArray.VTable, self.vtable).Decode(@ptrCast(*const ICertEncodeStringArray, self), strBinary);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeStringArray_GetStringType(self: *const T, pStringType: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeStringArray.VTable, self.vtable).GetStringType(@ptrCast(*const ICertEncodeStringArray, self), pStringType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeStringArray_GetCount(self: *const T, pCount: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeStringArray.VTable, self.vtable).GetCount(@ptrCast(*const ICertEncodeStringArray, self), pCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeStringArray_GetValue(self: *const T, Index: i32, pstr: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeStringArray.VTable, self.vtable).GetValue(@ptrCast(*const ICertEncodeStringArray, self), Index, pstr);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeStringArray_Reset(self: *const T, Count: i32, StringType: CERT_RDN_ATTR_VALUE_TYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeStringArray.VTable, self.vtable).Reset(@ptrCast(*const ICertEncodeStringArray, self), Count, StringType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeStringArray_SetValue(self: *const T, Index: i32, str: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeStringArray.VTable, self.vtable).SetValue(@ptrCast(*const ICertEncodeStringArray, self), Index, str);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeStringArray_Encode(self: *const T, pstrBinary: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeStringArray.VTable, self.vtable).Encode(@ptrCast(*const ICertEncodeStringArray, self), pstrBinary);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_ICertEncodeStringArray2_Value = @import("../../zig.zig").Guid.initString("9c680d93-9b7d-4e95-9018-4ffe10ba5ada");
pub const IID_ICertEncodeStringArray2 = &IID_ICertEncodeStringArray2_Value;
pub const ICertEncodeStringArray2 = extern struct {
pub const VTable = extern struct {
base: ICertEncodeStringArray.VTable,
DecodeBlob: fn(
self: *const ICertEncodeStringArray2,
strEncodedData: ?BSTR,
Encoding: EncodingType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EncodeBlob: fn(
self: *const ICertEncodeStringArray2,
Encoding: EncodingType,
pstrEncodedData: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertEncodeStringArray.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeStringArray2_DecodeBlob(self: *const T, strEncodedData: ?BSTR, Encoding: EncodingType) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeStringArray2.VTable, self.vtable).DecodeBlob(@ptrCast(*const ICertEncodeStringArray2, self), strEncodedData, Encoding);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeStringArray2_EncodeBlob(self: *const T, Encoding: EncodingType, pstrEncodedData: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeStringArray2.VTable, self.vtable).EncodeBlob(@ptrCast(*const ICertEncodeStringArray2, self), Encoding, pstrEncodedData);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertEncodeLongArray_Value = @import("../../zig.zig").Guid.initString("15e2f230-a0a2-11d0-8821-00a0c903b83c");
pub const IID_ICertEncodeLongArray = &IID_ICertEncodeLongArray_Value;
pub const ICertEncodeLongArray = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Decode: fn(
self: *const ICertEncodeLongArray,
strBinary: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCount: fn(
self: *const ICertEncodeLongArray,
pCount: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetValue: fn(
self: *const ICertEncodeLongArray,
Index: i32,
pValue: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reset: fn(
self: *const ICertEncodeLongArray,
Count: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetValue: fn(
self: *const ICertEncodeLongArray,
Index: i32,
Value: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Encode: fn(
self: *const ICertEncodeLongArray,
pstrBinary: ?*?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 ICertEncodeLongArray_Decode(self: *const T, strBinary: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeLongArray.VTable, self.vtable).Decode(@ptrCast(*const ICertEncodeLongArray, self), strBinary);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeLongArray_GetCount(self: *const T, pCount: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeLongArray.VTable, self.vtable).GetCount(@ptrCast(*const ICertEncodeLongArray, self), pCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeLongArray_GetValue(self: *const T, Index: i32, pValue: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeLongArray.VTable, self.vtable).GetValue(@ptrCast(*const ICertEncodeLongArray, self), Index, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeLongArray_Reset(self: *const T, Count: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeLongArray.VTable, self.vtable).Reset(@ptrCast(*const ICertEncodeLongArray, self), Count);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeLongArray_SetValue(self: *const T, Index: i32, Value: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeLongArray.VTable, self.vtable).SetValue(@ptrCast(*const ICertEncodeLongArray, self), Index, Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeLongArray_Encode(self: *const T, pstrBinary: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeLongArray.VTable, self.vtable).Encode(@ptrCast(*const ICertEncodeLongArray, self), pstrBinary);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_ICertEncodeLongArray2_Value = @import("../../zig.zig").Guid.initString("4efde84a-bd9b-4fc2-a108-c347d478840f");
pub const IID_ICertEncodeLongArray2 = &IID_ICertEncodeLongArray2_Value;
pub const ICertEncodeLongArray2 = extern struct {
pub const VTable = extern struct {
base: ICertEncodeLongArray.VTable,
DecodeBlob: fn(
self: *const ICertEncodeLongArray2,
strEncodedData: ?BSTR,
Encoding: EncodingType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EncodeBlob: fn(
self: *const ICertEncodeLongArray2,
Encoding: EncodingType,
pstrEncodedData: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertEncodeLongArray.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeLongArray2_DecodeBlob(self: *const T, strEncodedData: ?BSTR, Encoding: EncodingType) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeLongArray2.VTable, self.vtable).DecodeBlob(@ptrCast(*const ICertEncodeLongArray2, self), strEncodedData, Encoding);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeLongArray2_EncodeBlob(self: *const T, Encoding: EncodingType, pstrEncodedData: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeLongArray2.VTable, self.vtable).EncodeBlob(@ptrCast(*const ICertEncodeLongArray2, self), Encoding, pstrEncodedData);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertEncodeDateArray_Value = @import("../../zig.zig").Guid.initString("2f9469a0-a470-11d0-8821-00a0c903b83c");
pub const IID_ICertEncodeDateArray = &IID_ICertEncodeDateArray_Value;
pub const ICertEncodeDateArray = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Decode: fn(
self: *const ICertEncodeDateArray,
strBinary: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCount: fn(
self: *const ICertEncodeDateArray,
pCount: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetValue: fn(
self: *const ICertEncodeDateArray,
Index: i32,
pValue: ?*f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reset: fn(
self: *const ICertEncodeDateArray,
Count: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetValue: fn(
self: *const ICertEncodeDateArray,
Index: i32,
Value: f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Encode: fn(
self: *const ICertEncodeDateArray,
pstrBinary: ?*?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 ICertEncodeDateArray_Decode(self: *const T, strBinary: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeDateArray.VTable, self.vtable).Decode(@ptrCast(*const ICertEncodeDateArray, self), strBinary);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeDateArray_GetCount(self: *const T, pCount: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeDateArray.VTable, self.vtable).GetCount(@ptrCast(*const ICertEncodeDateArray, self), pCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeDateArray_GetValue(self: *const T, Index: i32, pValue: ?*f64) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeDateArray.VTable, self.vtable).GetValue(@ptrCast(*const ICertEncodeDateArray, self), Index, pValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeDateArray_Reset(self: *const T, Count: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeDateArray.VTable, self.vtable).Reset(@ptrCast(*const ICertEncodeDateArray, self), Count);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeDateArray_SetValue(self: *const T, Index: i32, Value: f64) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeDateArray.VTable, self.vtable).SetValue(@ptrCast(*const ICertEncodeDateArray, self), Index, Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeDateArray_Encode(self: *const T, pstrBinary: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeDateArray.VTable, self.vtable).Encode(@ptrCast(*const ICertEncodeDateArray, self), pstrBinary);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_ICertEncodeDateArray2_Value = @import("../../zig.zig").Guid.initString("99a4edb5-2b8e-448d-bf95-bba8d7789dc8");
pub const IID_ICertEncodeDateArray2 = &IID_ICertEncodeDateArray2_Value;
pub const ICertEncodeDateArray2 = extern struct {
pub const VTable = extern struct {
base: ICertEncodeDateArray.VTable,
DecodeBlob: fn(
self: *const ICertEncodeDateArray2,
strEncodedData: ?BSTR,
Encoding: EncodingType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EncodeBlob: fn(
self: *const ICertEncodeDateArray2,
Encoding: EncodingType,
pstrEncodedData: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertEncodeDateArray.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeDateArray2_DecodeBlob(self: *const T, strEncodedData: ?BSTR, Encoding: EncodingType) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeDateArray2.VTable, self.vtable).DecodeBlob(@ptrCast(*const ICertEncodeDateArray2, self), strEncodedData, Encoding);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeDateArray2_EncodeBlob(self: *const T, Encoding: EncodingType, pstrEncodedData: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeDateArray2.VTable, self.vtable).EncodeBlob(@ptrCast(*const ICertEncodeDateArray2, self), Encoding, pstrEncodedData);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertEncodeCRLDistInfo_Value = @import("../../zig.zig").Guid.initString("01958640-bbff-11d0-8825-00a0c903b83c");
pub const IID_ICertEncodeCRLDistInfo = &IID_ICertEncodeCRLDistInfo_Value;
pub const ICertEncodeCRLDistInfo = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Decode: fn(
self: *const ICertEncodeCRLDistInfo,
strBinary: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDistPointCount: fn(
self: *const ICertEncodeCRLDistInfo,
pDistPointCount: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetNameCount: fn(
self: *const ICertEncodeCRLDistInfo,
DistPointIndex: i32,
pNameCount: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetNameChoice: fn(
self: *const ICertEncodeCRLDistInfo,
DistPointIndex: i32,
NameIndex: i32,
pNameChoice: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetName: fn(
self: *const ICertEncodeCRLDistInfo,
DistPointIndex: i32,
NameIndex: i32,
pstrName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reset: fn(
self: *const ICertEncodeCRLDistInfo,
DistPointCount: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetNameCount: fn(
self: *const ICertEncodeCRLDistInfo,
DistPointIndex: i32,
NameCount: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetNameEntry: fn(
self: *const ICertEncodeCRLDistInfo,
DistPointIndex: i32,
NameIndex: i32,
NameChoice: CERT_ALT_NAME,
strName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Encode: fn(
self: *const ICertEncodeCRLDistInfo,
pstrBinary: ?*?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 ICertEncodeCRLDistInfo_Decode(self: *const T, strBinary: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeCRLDistInfo.VTable, self.vtable).Decode(@ptrCast(*const ICertEncodeCRLDistInfo, self), strBinary);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeCRLDistInfo_GetDistPointCount(self: *const T, pDistPointCount: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeCRLDistInfo.VTable, self.vtable).GetDistPointCount(@ptrCast(*const ICertEncodeCRLDistInfo, self), pDistPointCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeCRLDistInfo_GetNameCount(self: *const T, DistPointIndex: i32, pNameCount: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeCRLDistInfo.VTable, self.vtable).GetNameCount(@ptrCast(*const ICertEncodeCRLDistInfo, self), DistPointIndex, pNameCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeCRLDistInfo_GetNameChoice(self: *const T, DistPointIndex: i32, NameIndex: i32, pNameChoice: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeCRLDistInfo.VTable, self.vtable).GetNameChoice(@ptrCast(*const ICertEncodeCRLDistInfo, self), DistPointIndex, NameIndex, pNameChoice);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeCRLDistInfo_GetName(self: *const T, DistPointIndex: i32, NameIndex: i32, pstrName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeCRLDistInfo.VTable, self.vtable).GetName(@ptrCast(*const ICertEncodeCRLDistInfo, self), DistPointIndex, NameIndex, pstrName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeCRLDistInfo_Reset(self: *const T, DistPointCount: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeCRLDistInfo.VTable, self.vtable).Reset(@ptrCast(*const ICertEncodeCRLDistInfo, self), DistPointCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeCRLDistInfo_SetNameCount(self: *const T, DistPointIndex: i32, NameCount: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeCRLDistInfo.VTable, self.vtable).SetNameCount(@ptrCast(*const ICertEncodeCRLDistInfo, self), DistPointIndex, NameCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeCRLDistInfo_SetNameEntry(self: *const T, DistPointIndex: i32, NameIndex: i32, NameChoice: CERT_ALT_NAME, strName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeCRLDistInfo.VTable, self.vtable).SetNameEntry(@ptrCast(*const ICertEncodeCRLDistInfo, self), DistPointIndex, NameIndex, NameChoice, strName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeCRLDistInfo_Encode(self: *const T, pstrBinary: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeCRLDistInfo.VTable, self.vtable).Encode(@ptrCast(*const ICertEncodeCRLDistInfo, self), pstrBinary);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_ICertEncodeCRLDistInfo2_Value = @import("../../zig.zig").Guid.initString("b4275d4b-3e30-446f-ad36-09d03120b078");
pub const IID_ICertEncodeCRLDistInfo2 = &IID_ICertEncodeCRLDistInfo2_Value;
pub const ICertEncodeCRLDistInfo2 = extern struct {
pub const VTable = extern struct {
base: ICertEncodeCRLDistInfo.VTable,
DecodeBlob: fn(
self: *const ICertEncodeCRLDistInfo2,
strEncodedData: ?BSTR,
Encoding: EncodingType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EncodeBlob: fn(
self: *const ICertEncodeCRLDistInfo2,
Encoding: EncodingType,
pstrEncodedData: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertEncodeCRLDistInfo.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeCRLDistInfo2_DecodeBlob(self: *const T, strEncodedData: ?BSTR, Encoding: EncodingType) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeCRLDistInfo2.VTable, self.vtable).DecodeBlob(@ptrCast(*const ICertEncodeCRLDistInfo2, self), strEncodedData, Encoding);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeCRLDistInfo2_EncodeBlob(self: *const T, Encoding: EncodingType, pstrEncodedData: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeCRLDistInfo2.VTable, self.vtable).EncodeBlob(@ptrCast(*const ICertEncodeCRLDistInfo2, self), Encoding, pstrEncodedData);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertEncodeAltName_Value = @import("../../zig.zig").Guid.initString("1c9a8c70-1271-11d1-9bd4-00c04fb683fa");
pub const IID_ICertEncodeAltName = &IID_ICertEncodeAltName_Value;
pub const ICertEncodeAltName = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Decode: fn(
self: *const ICertEncodeAltName,
strBinary: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetNameCount: fn(
self: *const ICertEncodeAltName,
pNameCount: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetNameChoice: fn(
self: *const ICertEncodeAltName,
NameIndex: i32,
pNameChoice: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetName: fn(
self: *const ICertEncodeAltName,
NameIndex: i32,
pstrName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reset: fn(
self: *const ICertEncodeAltName,
NameCount: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetNameEntry: fn(
self: *const ICertEncodeAltName,
NameIndex: i32,
NameChoice: CERT_ALT_NAME,
strName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Encode: fn(
self: *const ICertEncodeAltName,
pstrBinary: ?*?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 ICertEncodeAltName_Decode(self: *const T, strBinary: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeAltName.VTable, self.vtable).Decode(@ptrCast(*const ICertEncodeAltName, self), strBinary);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeAltName_GetNameCount(self: *const T, pNameCount: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeAltName.VTable, self.vtable).GetNameCount(@ptrCast(*const ICertEncodeAltName, self), pNameCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeAltName_GetNameChoice(self: *const T, NameIndex: i32, pNameChoice: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeAltName.VTable, self.vtable).GetNameChoice(@ptrCast(*const ICertEncodeAltName, self), NameIndex, pNameChoice);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeAltName_GetName(self: *const T, NameIndex: i32, pstrName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeAltName.VTable, self.vtable).GetName(@ptrCast(*const ICertEncodeAltName, self), NameIndex, pstrName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeAltName_Reset(self: *const T, NameCount: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeAltName.VTable, self.vtable).Reset(@ptrCast(*const ICertEncodeAltName, self), NameCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeAltName_SetNameEntry(self: *const T, NameIndex: i32, NameChoice: CERT_ALT_NAME, strName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeAltName.VTable, self.vtable).SetNameEntry(@ptrCast(*const ICertEncodeAltName, self), NameIndex, NameChoice, strName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeAltName_Encode(self: *const T, pstrBinary: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeAltName.VTable, self.vtable).Encode(@ptrCast(*const ICertEncodeAltName, self), pstrBinary);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_ICertEncodeAltName2_Value = @import("../../zig.zig").Guid.initString("f67fe177-5ef1-4535-b4ce-29df15e2e0c3");
pub const IID_ICertEncodeAltName2 = &IID_ICertEncodeAltName2_Value;
pub const ICertEncodeAltName2 = extern struct {
pub const VTable = extern struct {
base: ICertEncodeAltName.VTable,
DecodeBlob: fn(
self: *const ICertEncodeAltName2,
strEncodedData: ?BSTR,
Encoding: EncodingType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EncodeBlob: fn(
self: *const ICertEncodeAltName2,
Encoding: EncodingType,
pstrEncodedData: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetNameBlob: fn(
self: *const ICertEncodeAltName2,
NameIndex: i32,
Encoding: EncodingType,
pstrName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetNameEntryBlob: fn(
self: *const ICertEncodeAltName2,
NameIndex: i32,
NameChoice: i32,
strName: ?BSTR,
Encoding: EncodingType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertEncodeAltName.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeAltName2_DecodeBlob(self: *const T, strEncodedData: ?BSTR, Encoding: EncodingType) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeAltName2.VTable, self.vtable).DecodeBlob(@ptrCast(*const ICertEncodeAltName2, self), strEncodedData, Encoding);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeAltName2_EncodeBlob(self: *const T, Encoding: EncodingType, pstrEncodedData: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeAltName2.VTable, self.vtable).EncodeBlob(@ptrCast(*const ICertEncodeAltName2, self), Encoding, pstrEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeAltName2_GetNameBlob(self: *const T, NameIndex: i32, Encoding: EncodingType, pstrName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeAltName2.VTable, self.vtable).GetNameBlob(@ptrCast(*const ICertEncodeAltName2, self), NameIndex, Encoding, pstrName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeAltName2_SetNameEntryBlob(self: *const T, NameIndex: i32, NameChoice: i32, strName: ?BSTR, Encoding: EncodingType) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeAltName2.VTable, self.vtable).SetNameEntryBlob(@ptrCast(*const ICertEncodeAltName2, self), NameIndex, NameChoice, strName, Encoding);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertEncodeBitString_Value = @import("../../zig.zig").Guid.initString("6db525be-1278-11d1-9bd4-00c04fb683fa");
pub const IID_ICertEncodeBitString = &IID_ICertEncodeBitString_Value;
pub const ICertEncodeBitString = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Decode: fn(
self: *const ICertEncodeBitString,
strBinary: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetBitCount: fn(
self: *const ICertEncodeBitString,
pBitCount: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetBitString: fn(
self: *const ICertEncodeBitString,
pstrBitString: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Encode: fn(
self: *const ICertEncodeBitString,
BitCount: i32,
strBitString: ?BSTR,
pstrBinary: ?*?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 ICertEncodeBitString_Decode(self: *const T, strBinary: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeBitString.VTable, self.vtable).Decode(@ptrCast(*const ICertEncodeBitString, self), strBinary);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeBitString_GetBitCount(self: *const T, pBitCount: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeBitString.VTable, self.vtable).GetBitCount(@ptrCast(*const ICertEncodeBitString, self), pBitCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeBitString_GetBitString(self: *const T, pstrBitString: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeBitString.VTable, self.vtable).GetBitString(@ptrCast(*const ICertEncodeBitString, self), pstrBitString);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeBitString_Encode(self: *const T, BitCount: i32, strBitString: ?BSTR, pstrBinary: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeBitString.VTable, self.vtable).Encode(@ptrCast(*const ICertEncodeBitString, self), BitCount, strBitString, pstrBinary);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_ICertEncodeBitString2_Value = @import("../../zig.zig").Guid.initString("e070d6e7-23ef-4dd2-8242-ebd9c928cb30");
pub const IID_ICertEncodeBitString2 = &IID_ICertEncodeBitString2_Value;
pub const ICertEncodeBitString2 = extern struct {
pub const VTable = extern struct {
base: ICertEncodeBitString.VTable,
DecodeBlob: fn(
self: *const ICertEncodeBitString2,
strEncodedData: ?BSTR,
Encoding: EncodingType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EncodeBlob: fn(
self: *const ICertEncodeBitString2,
BitCount: i32,
strBitString: ?BSTR,
EncodingIn: EncodingType,
Encoding: EncodingType,
pstrEncodedData: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetBitStringBlob: fn(
self: *const ICertEncodeBitString2,
Encoding: EncodingType,
pstrBitString: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertEncodeBitString.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeBitString2_DecodeBlob(self: *const T, strEncodedData: ?BSTR, Encoding: EncodingType) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeBitString2.VTable, self.vtable).DecodeBlob(@ptrCast(*const ICertEncodeBitString2, self), strEncodedData, Encoding);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeBitString2_EncodeBlob(self: *const T, BitCount: i32, strBitString: ?BSTR, EncodingIn: EncodingType, Encoding: EncodingType, pstrEncodedData: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeBitString2.VTable, self.vtable).EncodeBlob(@ptrCast(*const ICertEncodeBitString2, self), BitCount, strBitString, EncodingIn, Encoding, pstrEncodedData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertEncodeBitString2_GetBitStringBlob(self: *const T, Encoding: EncodingType, pstrBitString: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertEncodeBitString2.VTable, self.vtable).GetBitStringBlob(@ptrCast(*const ICertEncodeBitString2, self), Encoding, pstrBitString);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertExit_Value = @import("../../zig.zig").Guid.initString("e19ae1a0-7364-11d0-8816-00a0c903b83c");
pub const IID_ICertExit = &IID_ICertExit_Value;
pub const ICertExit = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Initialize: fn(
self: *const ICertExit,
strConfig: ?BSTR,
pEventMask: ?*CERT_EXIT_EVENT_MASK,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Notify: fn(
self: *const ICertExit,
ExitEvent: i32,
Context: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDescription: fn(
self: *const ICertExit,
pstrDescription: ?*?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 ICertExit_Initialize(self: *const T, strConfig: ?BSTR, pEventMask: ?*CERT_EXIT_EVENT_MASK) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertExit.VTable, self.vtable).Initialize(@ptrCast(*const ICertExit, self), strConfig, pEventMask);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertExit_Notify(self: *const T, ExitEvent: i32, Context: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertExit.VTable, self.vtable).Notify(@ptrCast(*const ICertExit, self), ExitEvent, Context);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertExit_GetDescription(self: *const T, pstrDescription: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertExit.VTable, self.vtable).GetDescription(@ptrCast(*const ICertExit, self), pstrDescription);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2003'
const IID_ICertExit2_Value = @import("../../zig.zig").Guid.initString("0abf484b-d049-464d-a7ed-552e7529b0ff");
pub const IID_ICertExit2 = &IID_ICertExit2_Value;
pub const ICertExit2 = extern struct {
pub const VTable = extern struct {
base: ICertExit.VTable,
GetManageModule: fn(
self: *const ICertExit2,
ppManageModule: ?*?*ICertManageModule,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertExit.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertExit2_GetManageModule(self: *const T, ppManageModule: ?*?*ICertManageModule) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertExit2.VTable, self.vtable).GetManageModule(@ptrCast(*const ICertExit2, self), ppManageModule);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const ENUM_CATYPES = enum(i32) {
ENTERPRISE_ROOTCA = 0,
ENTERPRISE_SUBCA = 1,
STANDALONE_ROOTCA = 3,
STANDALONE_SUBCA = 4,
UNKNOWN_CA = 5,
};
pub const ENUM_ENTERPRISE_ROOTCA = ENUM_CATYPES.ENTERPRISE_ROOTCA;
pub const ENUM_ENTERPRISE_SUBCA = ENUM_CATYPES.ENTERPRISE_SUBCA;
pub const ENUM_STANDALONE_ROOTCA = ENUM_CATYPES.STANDALONE_ROOTCA;
pub const ENUM_STANDALONE_SUBCA = ENUM_CATYPES.STANDALONE_SUBCA;
pub const ENUM_UNKNOWN_CA = ENUM_CATYPES.UNKNOWN_CA;
pub const CAINFO = extern struct {
cbSize: u32,
CAType: ENUM_CATYPES,
cCASignatureCerts: u32,
cCAExchangeCerts: u32,
cExitModules: u32,
lPropIdMax: i32,
lRoleSeparationEnabled: i32,
cKRACertUsedCount: u32,
cKRACertCount: u32,
fAdvancedServer: u32,
};
const CLSID_CEnroll2_Value = @import("../../zig.zig").Guid.initString("127698e4-e730-4e5c-a2b1-21490a70c8a1");
pub const CLSID_CEnroll2 = &CLSID_CEnroll2_Value;
const CLSID_CEnroll_Value = @import("../../zig.zig").Guid.initString("43f8f289-7a20-11d0-8f06-00c04fc295e1");
pub const CLSID_CEnroll = &CLSID_CEnroll_Value;
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_ICEnroll_Value = @import("../../zig.zig").Guid.initString("43f8f288-7a20-11d0-8f06-00c04fc295e1");
pub const IID_ICEnroll = &IID_ICEnroll_Value;
pub const ICEnroll = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
createFilePKCS10: fn(
self: *const ICEnroll,
DNName: ?BSTR,
Usage: ?BSTR,
wszPKCS10FileName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
acceptFilePKCS7: fn(
self: *const ICEnroll,
wszPKCS7FileName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
createPKCS10: fn(
self: *const ICEnroll,
DNName: ?BSTR,
Usage: ?BSTR,
pPKCS10: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
acceptPKCS7: fn(
self: *const ICEnroll,
PKCS7: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
getCertFromPKCS7: fn(
self: *const ICEnroll,
wszPKCS7: ?BSTR,
pbstrCert: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
enumProviders: fn(
self: *const ICEnroll,
dwIndex: i32,
dwFlags: i32,
pbstrProvName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
enumContainers: fn(
self: *const ICEnroll,
dwIndex: i32,
pbstr: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
freeRequestInfo: fn(
self: *const ICEnroll,
PKCS7OrPKCS10: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MyStoreName: fn(
self: *const ICEnroll,
pbstrName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_MyStoreName: fn(
self: *const ICEnroll,
bstrName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MyStoreType: fn(
self: *const ICEnroll,
pbstrType: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_MyStoreType: fn(
self: *const ICEnroll,
bstrType: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MyStoreFlags: fn(
self: *const ICEnroll,
pdwFlags: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_MyStoreFlags: fn(
self: *const ICEnroll,
dwFlags: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CAStoreName: fn(
self: *const ICEnroll,
pbstrName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_CAStoreName: fn(
self: *const ICEnroll,
bstrName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CAStoreType: fn(
self: *const ICEnroll,
pbstrType: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_CAStoreType: fn(
self: *const ICEnroll,
bstrType: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CAStoreFlags: fn(
self: *const ICEnroll,
pdwFlags: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_CAStoreFlags: fn(
self: *const ICEnroll,
dwFlags: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RootStoreName: fn(
self: *const ICEnroll,
pbstrName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_RootStoreName: fn(
self: *const ICEnroll,
bstrName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RootStoreType: fn(
self: *const ICEnroll,
pbstrType: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_RootStoreType: fn(
self: *const ICEnroll,
bstrType: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RootStoreFlags: fn(
self: *const ICEnroll,
pdwFlags: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_RootStoreFlags: fn(
self: *const ICEnroll,
dwFlags: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RequestStoreName: fn(
self: *const ICEnroll,
pbstrName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_RequestStoreName: fn(
self: *const ICEnroll,
bstrName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RequestStoreType: fn(
self: *const ICEnroll,
pbstrType: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_RequestStoreType: fn(
self: *const ICEnroll,
bstrType: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RequestStoreFlags: fn(
self: *const ICEnroll,
pdwFlags: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_RequestStoreFlags: fn(
self: *const ICEnroll,
dwFlags: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ContainerName: fn(
self: *const ICEnroll,
pbstrContainer: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ContainerName: fn(
self: *const ICEnroll,
bstrContainer: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProviderName: fn(
self: *const ICEnroll,
pbstrProvider: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ProviderName: fn(
self: *const ICEnroll,
bstrProvider: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProviderType: fn(
self: *const ICEnroll,
pdwType: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ProviderType: fn(
self: *const ICEnroll,
dwType: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_KeySpec: fn(
self: *const ICEnroll,
pdw: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_KeySpec: fn(
self: *const ICEnroll,
dw: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProviderFlags: fn(
self: *const ICEnroll,
pdwFlags: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ProviderFlags: fn(
self: *const ICEnroll,
dwFlags: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_UseExistingKeySet: fn(
self: *const ICEnroll,
fUseExistingKeys: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_UseExistingKeySet: fn(
self: *const ICEnroll,
fUseExistingKeys: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_GenKeyFlags: fn(
self: *const ICEnroll,
pdwFlags: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_GenKeyFlags: fn(
self: *const ICEnroll,
dwFlags: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DeleteRequestCert: fn(
self: *const ICEnroll,
fDelete: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_DeleteRequestCert: fn(
self: *const ICEnroll,
fDelete: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_WriteCertToCSP: fn(
self: *const ICEnroll,
fBool: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_WriteCertToCSP: fn(
self: *const ICEnroll,
fBool: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SPCFileName: fn(
self: *const ICEnroll,
pbstr: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_SPCFileName: fn(
self: *const ICEnroll,
bstr: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PVKFileName: fn(
self: *const ICEnroll,
pbstr: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_PVKFileName: fn(
self: *const ICEnroll,
bstr: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_HashAlgorithm: fn(
self: *const ICEnroll,
pbstr: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_HashAlgorithm: fn(
self: *const ICEnroll,
bstr: ?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 ICEnroll_createFilePKCS10(self: *const T, DNName: ?BSTR, Usage: ?BSTR, wszPKCS10FileName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).createFilePKCS10(@ptrCast(*const ICEnroll, self), DNName, Usage, wszPKCS10FileName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_acceptFilePKCS7(self: *const T, wszPKCS7FileName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).acceptFilePKCS7(@ptrCast(*const ICEnroll, self), wszPKCS7FileName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_createPKCS10(self: *const T, DNName: ?BSTR, Usage: ?BSTR, pPKCS10: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).createPKCS10(@ptrCast(*const ICEnroll, self), DNName, Usage, pPKCS10);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_acceptPKCS7(self: *const T, PKCS7: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).acceptPKCS7(@ptrCast(*const ICEnroll, self), PKCS7);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_getCertFromPKCS7(self: *const T, wszPKCS7: ?BSTR, pbstrCert: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).getCertFromPKCS7(@ptrCast(*const ICEnroll, self), wszPKCS7, pbstrCert);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_enumProviders(self: *const T, dwIndex: i32, dwFlags: i32, pbstrProvName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).enumProviders(@ptrCast(*const ICEnroll, self), dwIndex, dwFlags, pbstrProvName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_enumContainers(self: *const T, dwIndex: i32, pbstr: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).enumContainers(@ptrCast(*const ICEnroll, self), dwIndex, pbstr);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_freeRequestInfo(self: *const T, PKCS7OrPKCS10: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).freeRequestInfo(@ptrCast(*const ICEnroll, self), PKCS7OrPKCS10);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_MyStoreName(self: *const T, pbstrName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_MyStoreName(@ptrCast(*const ICEnroll, self), pbstrName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_MyStoreName(self: *const T, bstrName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_MyStoreName(@ptrCast(*const ICEnroll, self), bstrName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_MyStoreType(self: *const T, pbstrType: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_MyStoreType(@ptrCast(*const ICEnroll, self), pbstrType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_MyStoreType(self: *const T, bstrType: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_MyStoreType(@ptrCast(*const ICEnroll, self), bstrType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_MyStoreFlags(self: *const T, pdwFlags: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_MyStoreFlags(@ptrCast(*const ICEnroll, self), pdwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_MyStoreFlags(self: *const T, dwFlags: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_MyStoreFlags(@ptrCast(*const ICEnroll, self), dwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_CAStoreName(self: *const T, pbstrName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_CAStoreName(@ptrCast(*const ICEnroll, self), pbstrName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_CAStoreName(self: *const T, bstrName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_CAStoreName(@ptrCast(*const ICEnroll, self), bstrName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_CAStoreType(self: *const T, pbstrType: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_CAStoreType(@ptrCast(*const ICEnroll, self), pbstrType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_CAStoreType(self: *const T, bstrType: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_CAStoreType(@ptrCast(*const ICEnroll, self), bstrType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_CAStoreFlags(self: *const T, pdwFlags: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_CAStoreFlags(@ptrCast(*const ICEnroll, self), pdwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_CAStoreFlags(self: *const T, dwFlags: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_CAStoreFlags(@ptrCast(*const ICEnroll, self), dwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_RootStoreName(self: *const T, pbstrName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_RootStoreName(@ptrCast(*const ICEnroll, self), pbstrName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_RootStoreName(self: *const T, bstrName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_RootStoreName(@ptrCast(*const ICEnroll, self), bstrName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_RootStoreType(self: *const T, pbstrType: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_RootStoreType(@ptrCast(*const ICEnroll, self), pbstrType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_RootStoreType(self: *const T, bstrType: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_RootStoreType(@ptrCast(*const ICEnroll, self), bstrType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_RootStoreFlags(self: *const T, pdwFlags: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_RootStoreFlags(@ptrCast(*const ICEnroll, self), pdwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_RootStoreFlags(self: *const T, dwFlags: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_RootStoreFlags(@ptrCast(*const ICEnroll, self), dwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_RequestStoreName(self: *const T, pbstrName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_RequestStoreName(@ptrCast(*const ICEnroll, self), pbstrName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_RequestStoreName(self: *const T, bstrName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_RequestStoreName(@ptrCast(*const ICEnroll, self), bstrName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_RequestStoreType(self: *const T, pbstrType: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_RequestStoreType(@ptrCast(*const ICEnroll, self), pbstrType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_RequestStoreType(self: *const T, bstrType: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_RequestStoreType(@ptrCast(*const ICEnroll, self), bstrType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_RequestStoreFlags(self: *const T, pdwFlags: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_RequestStoreFlags(@ptrCast(*const ICEnroll, self), pdwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_RequestStoreFlags(self: *const T, dwFlags: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_RequestStoreFlags(@ptrCast(*const ICEnroll, self), dwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_ContainerName(self: *const T, pbstrContainer: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_ContainerName(@ptrCast(*const ICEnroll, self), pbstrContainer);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_ContainerName(self: *const T, bstrContainer: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_ContainerName(@ptrCast(*const ICEnroll, self), bstrContainer);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_ProviderName(self: *const T, pbstrProvider: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_ProviderName(@ptrCast(*const ICEnroll, self), pbstrProvider);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_ProviderName(self: *const T, bstrProvider: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_ProviderName(@ptrCast(*const ICEnroll, self), bstrProvider);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_ProviderType(self: *const T, pdwType: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_ProviderType(@ptrCast(*const ICEnroll, self), pdwType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_ProviderType(self: *const T, dwType: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_ProviderType(@ptrCast(*const ICEnroll, self), dwType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_KeySpec(self: *const T, pdw: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_KeySpec(@ptrCast(*const ICEnroll, self), pdw);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_KeySpec(self: *const T, dw: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_KeySpec(@ptrCast(*const ICEnroll, self), dw);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_ProviderFlags(self: *const T, pdwFlags: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_ProviderFlags(@ptrCast(*const ICEnroll, self), pdwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_ProviderFlags(self: *const T, dwFlags: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_ProviderFlags(@ptrCast(*const ICEnroll, self), dwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_UseExistingKeySet(self: *const T, fUseExistingKeys: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_UseExistingKeySet(@ptrCast(*const ICEnroll, self), fUseExistingKeys);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_UseExistingKeySet(self: *const T, fUseExistingKeys: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_UseExistingKeySet(@ptrCast(*const ICEnroll, self), fUseExistingKeys);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_GenKeyFlags(self: *const T, pdwFlags: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_GenKeyFlags(@ptrCast(*const ICEnroll, self), pdwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_GenKeyFlags(self: *const T, dwFlags: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_GenKeyFlags(@ptrCast(*const ICEnroll, self), dwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_DeleteRequestCert(self: *const T, fDelete: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_DeleteRequestCert(@ptrCast(*const ICEnroll, self), fDelete);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_DeleteRequestCert(self: *const T, fDelete: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_DeleteRequestCert(@ptrCast(*const ICEnroll, self), fDelete);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_WriteCertToCSP(self: *const T, fBool: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_WriteCertToCSP(@ptrCast(*const ICEnroll, self), fBool);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_WriteCertToCSP(self: *const T, fBool: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_WriteCertToCSP(@ptrCast(*const ICEnroll, self), fBool);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_SPCFileName(self: *const T, pbstr: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_SPCFileName(@ptrCast(*const ICEnroll, self), pbstr);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_SPCFileName(self: *const T, bstr: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_SPCFileName(@ptrCast(*const ICEnroll, self), bstr);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_PVKFileName(self: *const T, pbstr: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_PVKFileName(@ptrCast(*const ICEnroll, self), pbstr);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_PVKFileName(self: *const T, bstr: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_PVKFileName(@ptrCast(*const ICEnroll, self), bstr);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_get_HashAlgorithm(self: *const T, pbstr: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).get_HashAlgorithm(@ptrCast(*const ICEnroll, self), pbstr);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll_put_HashAlgorithm(self: *const T, bstr: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll.VTable, self.vtable).put_HashAlgorithm(@ptrCast(*const ICEnroll, self), bstr);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_ICEnroll2_Value = @import("../../zig.zig").Guid.initString("704ca730-c90b-11d1-9bec-00c04fc295e1");
pub const IID_ICEnroll2 = &IID_ICEnroll2_Value;
pub const ICEnroll2 = extern struct {
pub const VTable = extern struct {
base: ICEnroll.VTable,
addCertTypeToRequest: fn(
self: *const ICEnroll2,
CertType: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
addNameValuePairToSignature: fn(
self: *const ICEnroll2,
Name: ?BSTR,
Value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_WriteCertToUserDS: fn(
self: *const ICEnroll2,
fBool: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_WriteCertToUserDS: fn(
self: *const ICEnroll2,
fBool: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EnableT61DNEncoding: fn(
self: *const ICEnroll2,
fBool: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_EnableT61DNEncoding: fn(
self: *const ICEnroll2,
fBool: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICEnroll.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll2_addCertTypeToRequest(self: *const T, CertType: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll2.VTable, self.vtable).addCertTypeToRequest(@ptrCast(*const ICEnroll2, self), CertType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll2_addNameValuePairToSignature(self: *const T, Name: ?BSTR, Value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll2.VTable, self.vtable).addNameValuePairToSignature(@ptrCast(*const ICEnroll2, self), Name, Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll2_get_WriteCertToUserDS(self: *const T, fBool: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll2.VTable, self.vtable).get_WriteCertToUserDS(@ptrCast(*const ICEnroll2, self), fBool);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll2_put_WriteCertToUserDS(self: *const T, fBool: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll2.VTable, self.vtable).put_WriteCertToUserDS(@ptrCast(*const ICEnroll2, self), fBool);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll2_get_EnableT61DNEncoding(self: *const T, fBool: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll2.VTable, self.vtable).get_EnableT61DNEncoding(@ptrCast(*const ICEnroll2, self), fBool);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll2_put_EnableT61DNEncoding(self: *const T, fBool: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll2.VTable, self.vtable).put_EnableT61DNEncoding(@ptrCast(*const ICEnroll2, self), fBool);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_ICEnroll3_Value = @import("../../zig.zig").Guid.initString("c28c2d95-b7de-11d2-a421-00c04f79fe8e");
pub const IID_ICEnroll3 = &IID_ICEnroll3_Value;
pub const ICEnroll3 = extern struct {
pub const VTable = extern struct {
base: ICEnroll2.VTable,
InstallPKCS7: fn(
self: *const ICEnroll3,
PKCS7: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reset: fn(
self: *const ICEnroll3,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetSupportedKeySpec: fn(
self: *const ICEnroll3,
pdwKeySpec: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetKeyLen: fn(
self: *const ICEnroll3,
fMin: BOOL,
fExchange: BOOL,
pdwKeySize: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumAlgs: fn(
self: *const ICEnroll3,
dwIndex: i32,
algClass: i32,
pdwAlgID: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetAlgName: fn(
self: *const ICEnroll3,
algID: i32,
pbstr: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ReuseHardwareKeyIfUnableToGenNew: fn(
self: *const ICEnroll3,
fReuseHardwareKeyIfUnableToGenNew: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ReuseHardwareKeyIfUnableToGenNew: fn(
self: *const ICEnroll3,
fReuseHardwareKeyIfUnableToGenNew: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_HashAlgID: fn(
self: *const ICEnroll3,
hashAlgID: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_HashAlgID: fn(
self: *const ICEnroll3,
hashAlgID: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_LimitExchangeKeyToEncipherment: fn(
self: *const ICEnroll3,
fLimitExchangeKeyToEncipherment: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_LimitExchangeKeyToEncipherment: fn(
self: *const ICEnroll3,
fLimitExchangeKeyToEncipherment: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_EnableSMIMECapabilities: fn(
self: *const ICEnroll3,
fEnableSMIMECapabilities: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EnableSMIMECapabilities: fn(
self: *const ICEnroll3,
fEnableSMIMECapabilities: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICEnroll2.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll3_InstallPKCS7(self: *const T, PKCS7: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll3.VTable, self.vtable).InstallPKCS7(@ptrCast(*const ICEnroll3, self), PKCS7);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll3_Reset(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll3.VTable, self.vtable).Reset(@ptrCast(*const ICEnroll3, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll3_GetSupportedKeySpec(self: *const T, pdwKeySpec: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll3.VTable, self.vtable).GetSupportedKeySpec(@ptrCast(*const ICEnroll3, self), pdwKeySpec);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll3_GetKeyLen(self: *const T, fMin: BOOL, fExchange: BOOL, pdwKeySize: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll3.VTable, self.vtable).GetKeyLen(@ptrCast(*const ICEnroll3, self), fMin, fExchange, pdwKeySize);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll3_EnumAlgs(self: *const T, dwIndex: i32, algClass: i32, pdwAlgID: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll3.VTable, self.vtable).EnumAlgs(@ptrCast(*const ICEnroll3, self), dwIndex, algClass, pdwAlgID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll3_GetAlgName(self: *const T, algID: i32, pbstr: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll3.VTable, self.vtable).GetAlgName(@ptrCast(*const ICEnroll3, self), algID, pbstr);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll3_put_ReuseHardwareKeyIfUnableToGenNew(self: *const T, fReuseHardwareKeyIfUnableToGenNew: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll3.VTable, self.vtable).put_ReuseHardwareKeyIfUnableToGenNew(@ptrCast(*const ICEnroll3, self), fReuseHardwareKeyIfUnableToGenNew);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll3_get_ReuseHardwareKeyIfUnableToGenNew(self: *const T, fReuseHardwareKeyIfUnableToGenNew: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll3.VTable, self.vtable).get_ReuseHardwareKeyIfUnableToGenNew(@ptrCast(*const ICEnroll3, self), fReuseHardwareKeyIfUnableToGenNew);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll3_put_HashAlgID(self: *const T, hashAlgID: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll3.VTable, self.vtable).put_HashAlgID(@ptrCast(*const ICEnroll3, self), hashAlgID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll3_get_HashAlgID(self: *const T, hashAlgID: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll3.VTable, self.vtable).get_HashAlgID(@ptrCast(*const ICEnroll3, self), hashAlgID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll3_put_LimitExchangeKeyToEncipherment(self: *const T, fLimitExchangeKeyToEncipherment: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll3.VTable, self.vtable).put_LimitExchangeKeyToEncipherment(@ptrCast(*const ICEnroll3, self), fLimitExchangeKeyToEncipherment);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll3_get_LimitExchangeKeyToEncipherment(self: *const T, fLimitExchangeKeyToEncipherment: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll3.VTable, self.vtable).get_LimitExchangeKeyToEncipherment(@ptrCast(*const ICEnroll3, self), fLimitExchangeKeyToEncipherment);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll3_put_EnableSMIMECapabilities(self: *const T, fEnableSMIMECapabilities: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll3.VTable, self.vtable).put_EnableSMIMECapabilities(@ptrCast(*const ICEnroll3, self), fEnableSMIMECapabilities);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll3_get_EnableSMIMECapabilities(self: *const T, fEnableSMIMECapabilities: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll3.VTable, self.vtable).get_EnableSMIMECapabilities(@ptrCast(*const ICEnroll3, self), fEnableSMIMECapabilities);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_ICEnroll4_Value = @import("../../zig.zig").Guid.initString("c1f1188a-2eb5-4a80-841b-7e729a356d90");
pub const IID_ICEnroll4 = &IID_ICEnroll4_Value;
pub const ICEnroll4 = extern struct {
pub const VTable = extern struct {
base: ICEnroll3.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_PrivateKeyArchiveCertificate: fn(
self: *const ICEnroll4,
bstrCert: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PrivateKeyArchiveCertificate: fn(
self: *const ICEnroll4,
pbstrCert: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ThumbPrint: fn(
self: *const ICEnroll4,
bstrThumbPrint: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ThumbPrint: fn(
self: *const ICEnroll4,
pbstrThumbPrint: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
binaryToString: fn(
self: *const ICEnroll4,
Flags: i32,
strBinary: ?BSTR,
pstrEncoded: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
stringToBinary: fn(
self: *const ICEnroll4,
Flags: i32,
strEncoded: ?BSTR,
pstrBinary: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
addExtensionToRequest: fn(
self: *const ICEnroll4,
Flags: i32,
strName: ?BSTR,
strValue: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
addAttributeToRequest: fn(
self: *const ICEnroll4,
Flags: i32,
strName: ?BSTR,
strValue: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
addNameValuePairToRequest: fn(
self: *const ICEnroll4,
Flags: i32,
strName: ?BSTR,
strValue: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
resetExtensions: fn(
self: *const ICEnroll4,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
resetAttributes: fn(
self: *const ICEnroll4,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
createRequest: fn(
self: *const ICEnroll4,
Flags: CERT_CREATE_REQUEST_FLAGS,
strDNName: ?BSTR,
Usage: ?BSTR,
pstrRequest: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
createFileRequest: fn(
self: *const ICEnroll4,
Flags: CERT_CREATE_REQUEST_FLAGS,
strDNName: ?BSTR,
strUsage: ?BSTR,
strRequestFileName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
acceptResponse: fn(
self: *const ICEnroll4,
strResponse: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
acceptFileResponse: fn(
self: *const ICEnroll4,
strResponseFileName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
getCertFromResponse: fn(
self: *const ICEnroll4,
strResponse: ?BSTR,
pstrCert: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
getCertFromFileResponse: fn(
self: *const ICEnroll4,
strResponseFileName: ?BSTR,
pstrCert: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
createPFX: fn(
self: *const ICEnroll4,
strPassword: ?BSTR,
pstrPFX: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
createFilePFX: fn(
self: *const ICEnroll4,
strPassword: ?BSTR,
strPFXFileName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
setPendingRequestInfo: fn(
self: *const ICEnroll4,
lRequestID: i32,
strCADNS: ?BSTR,
strCAName: ?BSTR,
strFriendlyName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
enumPendingRequest: fn(
self: *const ICEnroll4,
lIndex: i32,
lDesiredProperty: PENDING_REQUEST_DESIRED_PROPERTY,
pvarProperty: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
removePendingRequest: fn(
self: *const ICEnroll4,
strThumbprint: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetKeyLenEx: fn(
self: *const ICEnroll4,
lSizeSpec: XEKL_KEYSIZE,
lKeySpec: XEKL_KEYSPEC,
pdwKeySize: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InstallPKCS7Ex: fn(
self: *const ICEnroll4,
PKCS7: ?BSTR,
plCertInstalled: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
addCertTypeToRequestEx: fn(
self: *const ICEnroll4,
lType: ADDED_CERT_TYPE,
bstrOIDOrName: ?BSTR,
lMajorVersion: i32,
fMinorVersion: BOOL,
lMinorVersion: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
getProviderType: fn(
self: *const ICEnroll4,
strProvName: ?BSTR,
plProvType: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_SignerCertificate: fn(
self: *const ICEnroll4,
bstrCert: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ClientId: fn(
self: *const ICEnroll4,
lClientId: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ClientId: fn(
self: *const ICEnroll4,
plClientId: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
addBlobPropertyToCertificate: fn(
self: *const ICEnroll4,
lPropertyId: i32,
lReserved: i32,
bstrProperty: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
resetBlobProperties: fn(
self: *const ICEnroll4,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_IncludeSubjectKeyID: fn(
self: *const ICEnroll4,
fInclude: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IncludeSubjectKeyID: fn(
self: *const ICEnroll4,
pfInclude: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICEnroll3.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_put_PrivateKeyArchiveCertificate(self: *const T, bstrCert: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).put_PrivateKeyArchiveCertificate(@ptrCast(*const ICEnroll4, self), bstrCert);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_get_PrivateKeyArchiveCertificate(self: *const T, pbstrCert: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).get_PrivateKeyArchiveCertificate(@ptrCast(*const ICEnroll4, self), pbstrCert);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_put_ThumbPrint(self: *const T, bstrThumbPrint: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).put_ThumbPrint(@ptrCast(*const ICEnroll4, self), bstrThumbPrint);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_get_ThumbPrint(self: *const T, pbstrThumbPrint: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).get_ThumbPrint(@ptrCast(*const ICEnroll4, self), pbstrThumbPrint);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_binaryToString(self: *const T, Flags: i32, strBinary: ?BSTR, pstrEncoded: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).binaryToString(@ptrCast(*const ICEnroll4, self), Flags, strBinary, pstrEncoded);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_stringToBinary(self: *const T, Flags: i32, strEncoded: ?BSTR, pstrBinary: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).stringToBinary(@ptrCast(*const ICEnroll4, self), Flags, strEncoded, pstrBinary);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_addExtensionToRequest(self: *const T, Flags: i32, strName: ?BSTR, strValue: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).addExtensionToRequest(@ptrCast(*const ICEnroll4, self), Flags, strName, strValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_addAttributeToRequest(self: *const T, Flags: i32, strName: ?BSTR, strValue: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).addAttributeToRequest(@ptrCast(*const ICEnroll4, self), Flags, strName, strValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_addNameValuePairToRequest(self: *const T, Flags: i32, strName: ?BSTR, strValue: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).addNameValuePairToRequest(@ptrCast(*const ICEnroll4, self), Flags, strName, strValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_resetExtensions(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).resetExtensions(@ptrCast(*const ICEnroll4, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_resetAttributes(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).resetAttributes(@ptrCast(*const ICEnroll4, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_createRequest(self: *const T, Flags: CERT_CREATE_REQUEST_FLAGS, strDNName: ?BSTR, Usage: ?BSTR, pstrRequest: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).createRequest(@ptrCast(*const ICEnroll4, self), Flags, strDNName, Usage, pstrRequest);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_createFileRequest(self: *const T, Flags: CERT_CREATE_REQUEST_FLAGS, strDNName: ?BSTR, strUsage: ?BSTR, strRequestFileName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).createFileRequest(@ptrCast(*const ICEnroll4, self), Flags, strDNName, strUsage, strRequestFileName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_acceptResponse(self: *const T, strResponse: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).acceptResponse(@ptrCast(*const ICEnroll4, self), strResponse);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_acceptFileResponse(self: *const T, strResponseFileName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).acceptFileResponse(@ptrCast(*const ICEnroll4, self), strResponseFileName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_getCertFromResponse(self: *const T, strResponse: ?BSTR, pstrCert: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).getCertFromResponse(@ptrCast(*const ICEnroll4, self), strResponse, pstrCert);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_getCertFromFileResponse(self: *const T, strResponseFileName: ?BSTR, pstrCert: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).getCertFromFileResponse(@ptrCast(*const ICEnroll4, self), strResponseFileName, pstrCert);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_createPFX(self: *const T, strPassword: ?BSTR, pstrPFX: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).createPFX(@ptrCast(*const ICEnroll4, self), strPassword, pstrPFX);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_createFilePFX(self: *const T, strPassword: ?BSTR, strPFXFileName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).createFilePFX(@ptrCast(*const ICEnroll4, self), strPassword, strPFXFileName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_setPendingRequestInfo(self: *const T, lRequestID: i32, strCADNS: ?BSTR, strCAName: ?BSTR, strFriendlyName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).setPendingRequestInfo(@ptrCast(*const ICEnroll4, self), lRequestID, strCADNS, strCAName, strFriendlyName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_enumPendingRequest(self: *const T, lIndex: i32, lDesiredProperty: PENDING_REQUEST_DESIRED_PROPERTY, pvarProperty: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).enumPendingRequest(@ptrCast(*const ICEnroll4, self), lIndex, lDesiredProperty, pvarProperty);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_removePendingRequest(self: *const T, strThumbprint: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).removePendingRequest(@ptrCast(*const ICEnroll4, self), strThumbprint);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_GetKeyLenEx(self: *const T, lSizeSpec: XEKL_KEYSIZE, lKeySpec: XEKL_KEYSPEC, pdwKeySize: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).GetKeyLenEx(@ptrCast(*const ICEnroll4, self), lSizeSpec, lKeySpec, pdwKeySize);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_InstallPKCS7Ex(self: *const T, PKCS7: ?BSTR, plCertInstalled: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).InstallPKCS7Ex(@ptrCast(*const ICEnroll4, self), PKCS7, plCertInstalled);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_addCertTypeToRequestEx(self: *const T, lType: ADDED_CERT_TYPE, bstrOIDOrName: ?BSTR, lMajorVersion: i32, fMinorVersion: BOOL, lMinorVersion: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).addCertTypeToRequestEx(@ptrCast(*const ICEnroll4, self), lType, bstrOIDOrName, lMajorVersion, fMinorVersion, lMinorVersion);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_getProviderType(self: *const T, strProvName: ?BSTR, plProvType: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).getProviderType(@ptrCast(*const ICEnroll4, self), strProvName, plProvType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_put_SignerCertificate(self: *const T, bstrCert: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).put_SignerCertificate(@ptrCast(*const ICEnroll4, self), bstrCert);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_put_ClientId(self: *const T, lClientId: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).put_ClientId(@ptrCast(*const ICEnroll4, self), lClientId);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_get_ClientId(self: *const T, plClientId: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).get_ClientId(@ptrCast(*const ICEnroll4, self), plClientId);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_addBlobPropertyToCertificate(self: *const T, lPropertyId: i32, lReserved: i32, bstrProperty: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).addBlobPropertyToCertificate(@ptrCast(*const ICEnroll4, self), lPropertyId, lReserved, bstrProperty);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_resetBlobProperties(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).resetBlobProperties(@ptrCast(*const ICEnroll4, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_put_IncludeSubjectKeyID(self: *const T, fInclude: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).put_IncludeSubjectKeyID(@ptrCast(*const ICEnroll4, self), fInclude);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICEnroll4_get_IncludeSubjectKeyID(self: *const T, pfInclude: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ICEnroll4.VTable, self.vtable).get_IncludeSubjectKeyID(@ptrCast(*const ICEnroll4, self), pfInclude);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IEnroll_Value = @import("../../zig.zig").Guid.initString("acaa7838-4585-11d1-ab57-00c04fc295e1");
pub const IID_IEnroll = &IID_IEnroll_Value;
pub const IEnroll = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
createFilePKCS10WStr: fn(
self: *const IEnroll,
DNName: ?[*:0]const u16,
Usage: ?[*:0]const u16,
wszPKCS10FileName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
acceptFilePKCS7WStr: fn(
self: *const IEnroll,
wszPKCS7FileName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
createPKCS10WStr: fn(
self: *const IEnroll,
DNName: ?[*:0]const u16,
Usage: ?[*:0]const u16,
pPkcs10Blob: ?*CRYPTOAPI_BLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
acceptPKCS7Blob: fn(
self: *const IEnroll,
pBlobPKCS7: ?*CRYPTOAPI_BLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
getCertContextFromPKCS7: fn(
self: *const IEnroll,
pBlobPKCS7: ?*CRYPTOAPI_BLOB,
) callconv(@import("std").os.windows.WINAPI) ?*CERT_CONTEXT,
getMyStore: fn(
self: *const IEnroll,
) callconv(@import("std").os.windows.WINAPI) ?*anyopaque,
getCAStore: fn(
self: *const IEnroll,
) callconv(@import("std").os.windows.WINAPI) ?*anyopaque,
getROOTHStore: fn(
self: *const IEnroll,
) callconv(@import("std").os.windows.WINAPI) ?*anyopaque,
enumProvidersWStr: fn(
self: *const IEnroll,
dwIndex: i32,
dwFlags: i32,
pbstrProvName: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
enumContainersWStr: fn(
self: *const IEnroll,
dwIndex: i32,
pbstr: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
freeRequestInfoBlob: fn(
self: *const IEnroll,
pkcs7OrPkcs10: CRYPTOAPI_BLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MyStoreNameWStr: fn(
self: *const IEnroll,
szwName: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_MyStoreNameWStr: fn(
self: *const IEnroll,
szwName: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MyStoreTypeWStr: fn(
self: *const IEnroll,
szwType: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_MyStoreTypeWStr: fn(
self: *const IEnroll,
szwType: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MyStoreFlags: fn(
self: *const IEnroll,
pdwFlags: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_MyStoreFlags: fn(
self: *const IEnroll,
dwFlags: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CAStoreNameWStr: fn(
self: *const IEnroll,
szwName: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_CAStoreNameWStr: fn(
self: *const IEnroll,
szwName: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CAStoreTypeWStr: fn(
self: *const IEnroll,
szwType: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_CAStoreTypeWStr: fn(
self: *const IEnroll,
szwType: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CAStoreFlags: fn(
self: *const IEnroll,
pdwFlags: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_CAStoreFlags: fn(
self: *const IEnroll,
dwFlags: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RootStoreNameWStr: fn(
self: *const IEnroll,
szwName: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_RootStoreNameWStr: fn(
self: *const IEnroll,
szwName: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RootStoreTypeWStr: fn(
self: *const IEnroll,
szwType: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_RootStoreTypeWStr: fn(
self: *const IEnroll,
szwType: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RootStoreFlags: fn(
self: *const IEnroll,
pdwFlags: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_RootStoreFlags: fn(
self: *const IEnroll,
dwFlags: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RequestStoreNameWStr: fn(
self: *const IEnroll,
szwName: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_RequestStoreNameWStr: fn(
self: *const IEnroll,
szwName: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RequestStoreTypeWStr: fn(
self: *const IEnroll,
szwType: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_RequestStoreTypeWStr: fn(
self: *const IEnroll,
szwType: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RequestStoreFlags: fn(
self: *const IEnroll,
pdwFlags: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_RequestStoreFlags: fn(
self: *const IEnroll,
dwFlags: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ContainerNameWStr: fn(
self: *const IEnroll,
szwContainer: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ContainerNameWStr: fn(
self: *const IEnroll,
szwContainer: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProviderNameWStr: fn(
self: *const IEnroll,
szwProvider: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ProviderNameWStr: fn(
self: *const IEnroll,
szwProvider: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProviderType: fn(
self: *const IEnroll,
pdwType: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ProviderType: fn(
self: *const IEnroll,
dwType: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_KeySpec: fn(
self: *const IEnroll,
pdw: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_KeySpec: fn(
self: *const IEnroll,
dw: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProviderFlags: fn(
self: *const IEnroll,
pdwFlags: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ProviderFlags: fn(
self: *const IEnroll,
dwFlags: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_UseExistingKeySet: fn(
self: *const IEnroll,
fUseExistingKeys: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_UseExistingKeySet: fn(
self: *const IEnroll,
fUseExistingKeys: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_GenKeyFlags: fn(
self: *const IEnroll,
pdwFlags: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_GenKeyFlags: fn(
self: *const IEnroll,
dwFlags: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DeleteRequestCert: fn(
self: *const IEnroll,
fDelete: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_DeleteRequestCert: fn(
self: *const IEnroll,
fDelete: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_WriteCertToUserDS: fn(
self: *const IEnroll,
fBool: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_WriteCertToUserDS: fn(
self: *const IEnroll,
fBool: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EnableT61DNEncoding: fn(
self: *const IEnroll,
fBool: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_EnableT61DNEncoding: fn(
self: *const IEnroll,
fBool: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_WriteCertToCSP: fn(
self: *const IEnroll,
fBool: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_WriteCertToCSP: fn(
self: *const IEnroll,
fBool: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SPCFileNameWStr: fn(
self: *const IEnroll,
szw: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_SPCFileNameWStr: fn(
self: *const IEnroll,
szw: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PVKFileNameWStr: fn(
self: *const IEnroll,
szw: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_PVKFileNameWStr: fn(
self: *const IEnroll,
szw: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_HashAlgorithmWStr: fn(
self: *const IEnroll,
szw: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_HashAlgorithmWStr: fn(
self: *const IEnroll,
szw: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RenewalCertificate: fn(
self: *const IEnroll,
ppCertContext: ?*?*CERT_CONTEXT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_RenewalCertificate: fn(
self: *const IEnroll,
pCertContext: ?*const CERT_CONTEXT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddCertTypeToRequestWStr: fn(
self: *const IEnroll,
szw: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddNameValuePairToSignatureWStr: fn(
self: *const IEnroll,
Name: ?PWSTR,
Value: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddExtensionsToRequest: fn(
self: *const IEnroll,
pCertExtensions: ?*CERT_EXTENSIONS,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddAuthenticatedAttributesToPKCS7Request: fn(
self: *const IEnroll,
pAttributes: ?*CRYPT_ATTRIBUTES,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CreatePKCS7RequestFromRequest: fn(
self: *const IEnroll,
pRequest: ?*CRYPTOAPI_BLOB,
pSigningCertContext: ?*const CERT_CONTEXT,
pPkcs7Blob: ?*CRYPTOAPI_BLOB,
) 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 IEnroll_createFilePKCS10WStr(self: *const T, DNName: ?[*:0]const u16, Usage: ?[*:0]const u16, wszPKCS10FileName: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).createFilePKCS10WStr(@ptrCast(*const IEnroll, self), DNName, Usage, wszPKCS10FileName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_acceptFilePKCS7WStr(self: *const T, wszPKCS7FileName: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).acceptFilePKCS7WStr(@ptrCast(*const IEnroll, self), wszPKCS7FileName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_createPKCS10WStr(self: *const T, DNName: ?[*:0]const u16, Usage: ?[*:0]const u16, pPkcs10Blob: ?*CRYPTOAPI_BLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).createPKCS10WStr(@ptrCast(*const IEnroll, self), DNName, Usage, pPkcs10Blob);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_acceptPKCS7Blob(self: *const T, pBlobPKCS7: ?*CRYPTOAPI_BLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).acceptPKCS7Blob(@ptrCast(*const IEnroll, self), pBlobPKCS7);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_getCertContextFromPKCS7(self: *const T, pBlobPKCS7: ?*CRYPTOAPI_BLOB) callconv(.Inline) ?*CERT_CONTEXT {
return @ptrCast(*const IEnroll.VTable, self.vtable).getCertContextFromPKCS7(@ptrCast(*const IEnroll, self), pBlobPKCS7);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_getMyStore(self: *const T) callconv(.Inline) ?*anyopaque {
return @ptrCast(*const IEnroll.VTable, self.vtable).getMyStore(@ptrCast(*const IEnroll, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_getCAStore(self: *const T) callconv(.Inline) ?*anyopaque {
return @ptrCast(*const IEnroll.VTable, self.vtable).getCAStore(@ptrCast(*const IEnroll, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_getROOTHStore(self: *const T) callconv(.Inline) ?*anyopaque {
return @ptrCast(*const IEnroll.VTable, self.vtable).getROOTHStore(@ptrCast(*const IEnroll, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_enumProvidersWStr(self: *const T, dwIndex: i32, dwFlags: i32, pbstrProvName: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).enumProvidersWStr(@ptrCast(*const IEnroll, self), dwIndex, dwFlags, pbstrProvName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_enumContainersWStr(self: *const T, dwIndex: i32, pbstr: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).enumContainersWStr(@ptrCast(*const IEnroll, self), dwIndex, pbstr);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_freeRequestInfoBlob(self: *const T, pkcs7OrPkcs10: CRYPTOAPI_BLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).freeRequestInfoBlob(@ptrCast(*const IEnroll, self), pkcs7OrPkcs10);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_MyStoreNameWStr(self: *const T, szwName: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_MyStoreNameWStr(@ptrCast(*const IEnroll, self), szwName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_MyStoreNameWStr(self: *const T, szwName: ?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_MyStoreNameWStr(@ptrCast(*const IEnroll, self), szwName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_MyStoreTypeWStr(self: *const T, szwType: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_MyStoreTypeWStr(@ptrCast(*const IEnroll, self), szwType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_MyStoreTypeWStr(self: *const T, szwType: ?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_MyStoreTypeWStr(@ptrCast(*const IEnroll, self), szwType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_MyStoreFlags(self: *const T, pdwFlags: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_MyStoreFlags(@ptrCast(*const IEnroll, self), pdwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_MyStoreFlags(self: *const T, dwFlags: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_MyStoreFlags(@ptrCast(*const IEnroll, self), dwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_CAStoreNameWStr(self: *const T, szwName: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_CAStoreNameWStr(@ptrCast(*const IEnroll, self), szwName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_CAStoreNameWStr(self: *const T, szwName: ?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_CAStoreNameWStr(@ptrCast(*const IEnroll, self), szwName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_CAStoreTypeWStr(self: *const T, szwType: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_CAStoreTypeWStr(@ptrCast(*const IEnroll, self), szwType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_CAStoreTypeWStr(self: *const T, szwType: ?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_CAStoreTypeWStr(@ptrCast(*const IEnroll, self), szwType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_CAStoreFlags(self: *const T, pdwFlags: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_CAStoreFlags(@ptrCast(*const IEnroll, self), pdwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_CAStoreFlags(self: *const T, dwFlags: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_CAStoreFlags(@ptrCast(*const IEnroll, self), dwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_RootStoreNameWStr(self: *const T, szwName: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_RootStoreNameWStr(@ptrCast(*const IEnroll, self), szwName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_RootStoreNameWStr(self: *const T, szwName: ?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_RootStoreNameWStr(@ptrCast(*const IEnroll, self), szwName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_RootStoreTypeWStr(self: *const T, szwType: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_RootStoreTypeWStr(@ptrCast(*const IEnroll, self), szwType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_RootStoreTypeWStr(self: *const T, szwType: ?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_RootStoreTypeWStr(@ptrCast(*const IEnroll, self), szwType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_RootStoreFlags(self: *const T, pdwFlags: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_RootStoreFlags(@ptrCast(*const IEnroll, self), pdwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_RootStoreFlags(self: *const T, dwFlags: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_RootStoreFlags(@ptrCast(*const IEnroll, self), dwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_RequestStoreNameWStr(self: *const T, szwName: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_RequestStoreNameWStr(@ptrCast(*const IEnroll, self), szwName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_RequestStoreNameWStr(self: *const T, szwName: ?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_RequestStoreNameWStr(@ptrCast(*const IEnroll, self), szwName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_RequestStoreTypeWStr(self: *const T, szwType: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_RequestStoreTypeWStr(@ptrCast(*const IEnroll, self), szwType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_RequestStoreTypeWStr(self: *const T, szwType: ?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_RequestStoreTypeWStr(@ptrCast(*const IEnroll, self), szwType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_RequestStoreFlags(self: *const T, pdwFlags: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_RequestStoreFlags(@ptrCast(*const IEnroll, self), pdwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_RequestStoreFlags(self: *const T, dwFlags: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_RequestStoreFlags(@ptrCast(*const IEnroll, self), dwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_ContainerNameWStr(self: *const T, szwContainer: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_ContainerNameWStr(@ptrCast(*const IEnroll, self), szwContainer);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_ContainerNameWStr(self: *const T, szwContainer: ?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_ContainerNameWStr(@ptrCast(*const IEnroll, self), szwContainer);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_ProviderNameWStr(self: *const T, szwProvider: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_ProviderNameWStr(@ptrCast(*const IEnroll, self), szwProvider);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_ProviderNameWStr(self: *const T, szwProvider: ?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_ProviderNameWStr(@ptrCast(*const IEnroll, self), szwProvider);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_ProviderType(self: *const T, pdwType: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_ProviderType(@ptrCast(*const IEnroll, self), pdwType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_ProviderType(self: *const T, dwType: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_ProviderType(@ptrCast(*const IEnroll, self), dwType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_KeySpec(self: *const T, pdw: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_KeySpec(@ptrCast(*const IEnroll, self), pdw);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_KeySpec(self: *const T, dw: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_KeySpec(@ptrCast(*const IEnroll, self), dw);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_ProviderFlags(self: *const T, pdwFlags: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_ProviderFlags(@ptrCast(*const IEnroll, self), pdwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_ProviderFlags(self: *const T, dwFlags: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_ProviderFlags(@ptrCast(*const IEnroll, self), dwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_UseExistingKeySet(self: *const T, fUseExistingKeys: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_UseExistingKeySet(@ptrCast(*const IEnroll, self), fUseExistingKeys);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_UseExistingKeySet(self: *const T, fUseExistingKeys: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_UseExistingKeySet(@ptrCast(*const IEnroll, self), fUseExistingKeys);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_GenKeyFlags(self: *const T, pdwFlags: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_GenKeyFlags(@ptrCast(*const IEnroll, self), pdwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_GenKeyFlags(self: *const T, dwFlags: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_GenKeyFlags(@ptrCast(*const IEnroll, self), dwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_DeleteRequestCert(self: *const T, fDelete: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_DeleteRequestCert(@ptrCast(*const IEnroll, self), fDelete);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_DeleteRequestCert(self: *const T, fDelete: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_DeleteRequestCert(@ptrCast(*const IEnroll, self), fDelete);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_WriteCertToUserDS(self: *const T, fBool: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_WriteCertToUserDS(@ptrCast(*const IEnroll, self), fBool);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_WriteCertToUserDS(self: *const T, fBool: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_WriteCertToUserDS(@ptrCast(*const IEnroll, self), fBool);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_EnableT61DNEncoding(self: *const T, fBool: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_EnableT61DNEncoding(@ptrCast(*const IEnroll, self), fBool);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_EnableT61DNEncoding(self: *const T, fBool: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_EnableT61DNEncoding(@ptrCast(*const IEnroll, self), fBool);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_WriteCertToCSP(self: *const T, fBool: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_WriteCertToCSP(@ptrCast(*const IEnroll, self), fBool);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_WriteCertToCSP(self: *const T, fBool: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_WriteCertToCSP(@ptrCast(*const IEnroll, self), fBool);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_SPCFileNameWStr(self: *const T, szw: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_SPCFileNameWStr(@ptrCast(*const IEnroll, self), szw);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_SPCFileNameWStr(self: *const T, szw: ?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_SPCFileNameWStr(@ptrCast(*const IEnroll, self), szw);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_PVKFileNameWStr(self: *const T, szw: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_PVKFileNameWStr(@ptrCast(*const IEnroll, self), szw);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_PVKFileNameWStr(self: *const T, szw: ?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_PVKFileNameWStr(@ptrCast(*const IEnroll, self), szw);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_HashAlgorithmWStr(self: *const T, szw: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_HashAlgorithmWStr(@ptrCast(*const IEnroll, self), szw);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_HashAlgorithmWStr(self: *const T, szw: ?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_HashAlgorithmWStr(@ptrCast(*const IEnroll, self), szw);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_get_RenewalCertificate(self: *const T, ppCertContext: ?*?*CERT_CONTEXT) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).get_RenewalCertificate(@ptrCast(*const IEnroll, self), ppCertContext);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_put_RenewalCertificate(self: *const T, pCertContext: ?*const CERT_CONTEXT) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).put_RenewalCertificate(@ptrCast(*const IEnroll, self), pCertContext);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_AddCertTypeToRequestWStr(self: *const T, szw: ?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).AddCertTypeToRequestWStr(@ptrCast(*const IEnroll, self), szw);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_AddNameValuePairToSignatureWStr(self: *const T, Name: ?PWSTR, Value: ?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).AddNameValuePairToSignatureWStr(@ptrCast(*const IEnroll, self), Name, Value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_AddExtensionsToRequest(self: *const T, pCertExtensions: ?*CERT_EXTENSIONS) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).AddExtensionsToRequest(@ptrCast(*const IEnroll, self), pCertExtensions);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_AddAuthenticatedAttributesToPKCS7Request(self: *const T, pAttributes: ?*CRYPT_ATTRIBUTES) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).AddAuthenticatedAttributesToPKCS7Request(@ptrCast(*const IEnroll, self), pAttributes);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll_CreatePKCS7RequestFromRequest(self: *const T, pRequest: ?*CRYPTOAPI_BLOB, pSigningCertContext: ?*const CERT_CONTEXT, pPkcs7Blob: ?*CRYPTOAPI_BLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll.VTable, self.vtable).CreatePKCS7RequestFromRequest(@ptrCast(*const IEnroll, self), pRequest, pSigningCertContext, pPkcs7Blob);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IEnroll2_Value = @import("../../zig.zig").Guid.initString("c080e199-b7df-11d2-a421-00c04f79fe8e");
pub const IID_IEnroll2 = &IID_IEnroll2_Value;
pub const IEnroll2 = extern struct {
pub const VTable = extern struct {
base: IEnroll.VTable,
InstallPKCS7Blob: fn(
self: *const IEnroll2,
pBlobPKCS7: ?*CRYPTOAPI_BLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reset: fn(
self: *const IEnroll2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetSupportedKeySpec: fn(
self: *const IEnroll2,
pdwKeySpec: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetKeyLen: fn(
self: *const IEnroll2,
fMin: BOOL,
fExchange: BOOL,
pdwKeySize: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumAlgs: fn(
self: *const IEnroll2,
dwIndex: i32,
algClass: i32,
pdwAlgID: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetAlgNameWStr: fn(
self: *const IEnroll2,
algID: i32,
ppwsz: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ReuseHardwareKeyIfUnableToGenNew: fn(
self: *const IEnroll2,
fReuseHardwareKeyIfUnableToGenNew: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ReuseHardwareKeyIfUnableToGenNew: fn(
self: *const IEnroll2,
fReuseHardwareKeyIfUnableToGenNew: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_HashAlgID: fn(
self: *const IEnroll2,
hashAlgID: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_HashAlgID: fn(
self: *const IEnroll2,
hashAlgID: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetHStoreMy: fn(
self: *const IEnroll2,
hStore: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetHStoreCA: fn(
self: *const IEnroll2,
hStore: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetHStoreROOT: fn(
self: *const IEnroll2,
hStore: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetHStoreRequest: fn(
self: *const IEnroll2,
hStore: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_LimitExchangeKeyToEncipherment: fn(
self: *const IEnroll2,
fLimitExchangeKeyToEncipherment: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_LimitExchangeKeyToEncipherment: fn(
self: *const IEnroll2,
fLimitExchangeKeyToEncipherment: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_EnableSMIMECapabilities: fn(
self: *const IEnroll2,
fEnableSMIMECapabilities: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EnableSMIMECapabilities: fn(
self: *const IEnroll2,
fEnableSMIMECapabilities: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IEnroll.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll2_InstallPKCS7Blob(self: *const T, pBlobPKCS7: ?*CRYPTOAPI_BLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll2.VTable, self.vtable).InstallPKCS7Blob(@ptrCast(*const IEnroll2, self), pBlobPKCS7);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll2_Reset(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll2.VTable, self.vtable).Reset(@ptrCast(*const IEnroll2, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll2_GetSupportedKeySpec(self: *const T, pdwKeySpec: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll2.VTable, self.vtable).GetSupportedKeySpec(@ptrCast(*const IEnroll2, self), pdwKeySpec);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll2_GetKeyLen(self: *const T, fMin: BOOL, fExchange: BOOL, pdwKeySize: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll2.VTable, self.vtable).GetKeyLen(@ptrCast(*const IEnroll2, self), fMin, fExchange, pdwKeySize);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll2_EnumAlgs(self: *const T, dwIndex: i32, algClass: i32, pdwAlgID: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll2.VTable, self.vtable).EnumAlgs(@ptrCast(*const IEnroll2, self), dwIndex, algClass, pdwAlgID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll2_GetAlgNameWStr(self: *const T, algID: i32, ppwsz: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll2.VTable, self.vtable).GetAlgNameWStr(@ptrCast(*const IEnroll2, self), algID, ppwsz);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll2_put_ReuseHardwareKeyIfUnableToGenNew(self: *const T, fReuseHardwareKeyIfUnableToGenNew: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll2.VTable, self.vtable).put_ReuseHardwareKeyIfUnableToGenNew(@ptrCast(*const IEnroll2, self), fReuseHardwareKeyIfUnableToGenNew);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll2_get_ReuseHardwareKeyIfUnableToGenNew(self: *const T, fReuseHardwareKeyIfUnableToGenNew: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll2.VTable, self.vtable).get_ReuseHardwareKeyIfUnableToGenNew(@ptrCast(*const IEnroll2, self), fReuseHardwareKeyIfUnableToGenNew);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll2_put_HashAlgID(self: *const T, hashAlgID: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll2.VTable, self.vtable).put_HashAlgID(@ptrCast(*const IEnroll2, self), hashAlgID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll2_get_HashAlgID(self: *const T, hashAlgID: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll2.VTable, self.vtable).get_HashAlgID(@ptrCast(*const IEnroll2, self), hashAlgID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll2_SetHStoreMy(self: *const T, hStore: ?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll2.VTable, self.vtable).SetHStoreMy(@ptrCast(*const IEnroll2, self), hStore);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll2_SetHStoreCA(self: *const T, hStore: ?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll2.VTable, self.vtable).SetHStoreCA(@ptrCast(*const IEnroll2, self), hStore);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll2_SetHStoreROOT(self: *const T, hStore: ?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll2.VTable, self.vtable).SetHStoreROOT(@ptrCast(*const IEnroll2, self), hStore);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll2_SetHStoreRequest(self: *const T, hStore: ?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll2.VTable, self.vtable).SetHStoreRequest(@ptrCast(*const IEnroll2, self), hStore);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll2_put_LimitExchangeKeyToEncipherment(self: *const T, fLimitExchangeKeyToEncipherment: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll2.VTable, self.vtable).put_LimitExchangeKeyToEncipherment(@ptrCast(*const IEnroll2, self), fLimitExchangeKeyToEncipherment);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll2_get_LimitExchangeKeyToEncipherment(self: *const T, fLimitExchangeKeyToEncipherment: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll2.VTable, self.vtable).get_LimitExchangeKeyToEncipherment(@ptrCast(*const IEnroll2, self), fLimitExchangeKeyToEncipherment);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll2_put_EnableSMIMECapabilities(self: *const T, fEnableSMIMECapabilities: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll2.VTable, self.vtable).put_EnableSMIMECapabilities(@ptrCast(*const IEnroll2, self), fEnableSMIMECapabilities);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll2_get_EnableSMIMECapabilities(self: *const T, fEnableSMIMECapabilities: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll2.VTable, self.vtable).get_EnableSMIMECapabilities(@ptrCast(*const IEnroll2, self), fEnableSMIMECapabilities);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IEnroll4_Value = @import("../../zig.zig").Guid.initString("f8053fe5-78f4-448f-a0db-41d61b73446b");
pub const IID_IEnroll4 = &IID_IEnroll4_Value;
pub const IEnroll4 = extern struct {
pub const VTable = extern struct {
base: IEnroll2.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ThumbPrintWStr: fn(
self: *const IEnroll4,
thumbPrintBlob: CRYPTOAPI_BLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ThumbPrintWStr: fn(
self: *const IEnroll4,
thumbPrintBlob: ?*CRYPTOAPI_BLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetPrivateKeyArchiveCertificate: fn(
self: *const IEnroll4,
pPrivateKeyArchiveCert: ?*const CERT_CONTEXT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetPrivateKeyArchiveCertificate: fn(
self: *const IEnroll4,
) callconv(@import("std").os.windows.WINAPI) ?*CERT_CONTEXT,
binaryBlobToString: fn(
self: *const IEnroll4,
Flags: i32,
pblobBinary: ?*CRYPTOAPI_BLOB,
ppwszString: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
stringToBinaryBlob: fn(
self: *const IEnroll4,
Flags: i32,
pwszString: ?[*:0]const u16,
pblobBinary: ?*CRYPTOAPI_BLOB,
pdwSkip: ?*i32,
pdwFlags: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
addExtensionToRequestWStr: fn(
self: *const IEnroll4,
Flags: i32,
pwszName: ?[*:0]const u16,
pblobValue: ?*CRYPTOAPI_BLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
addAttributeToRequestWStr: fn(
self: *const IEnroll4,
Flags: i32,
pwszName: ?[*:0]const u16,
pblobValue: ?*CRYPTOAPI_BLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
addNameValuePairToRequestWStr: fn(
self: *const IEnroll4,
Flags: i32,
pwszName: ?[*:0]const u16,
pwszValue: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
resetExtensions: fn(
self: *const IEnroll4,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
resetAttributes: fn(
self: *const IEnroll4,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
createRequestWStr: fn(
self: *const IEnroll4,
Flags: CERT_CREATE_REQUEST_FLAGS,
pwszDNName: ?[*:0]const u16,
pwszUsage: ?[*:0]const u16,
pblobRequest: ?*CRYPTOAPI_BLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
createFileRequestWStr: fn(
self: *const IEnroll4,
Flags: CERT_CREATE_REQUEST_FLAGS,
pwszDNName: ?[*:0]const u16,
pwszUsage: ?[*:0]const u16,
pwszRequestFileName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
acceptResponseBlob: fn(
self: *const IEnroll4,
pblobResponse: ?*CRYPTOAPI_BLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
acceptFileResponseWStr: fn(
self: *const IEnroll4,
pwszResponseFileName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
getCertContextFromResponseBlob: fn(
self: *const IEnroll4,
pblobResponse: ?*CRYPTOAPI_BLOB,
ppCertContext: ?*?*CERT_CONTEXT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
getCertContextFromFileResponseWStr: fn(
self: *const IEnroll4,
pwszResponseFileName: ?[*:0]const u16,
ppCertContext: ?*?*CERT_CONTEXT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
createPFXWStr: fn(
self: *const IEnroll4,
pwszPassword: ?[*:0]const u16,
pblobPFX: ?*CRYPTOAPI_BLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
createFilePFXWStr: fn(
self: *const IEnroll4,
pwszPassword: ?[*:0]const u16,
pwszPFXFileName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
setPendingRequestInfoWStr: fn(
self: *const IEnroll4,
lRequestID: i32,
pwszCADNS: ?[*:0]const u16,
pwszCAName: ?[*:0]const u16,
pwszFriendlyName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
enumPendingRequestWStr: fn(
self: *const IEnroll4,
lIndex: i32,
lDesiredProperty: PENDING_REQUEST_DESIRED_PROPERTY,
ppProperty: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
removePendingRequestWStr: fn(
self: *const IEnroll4,
thumbPrintBlob: CRYPTOAPI_BLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetKeyLenEx: fn(
self: *const IEnroll4,
lSizeSpec: XEKL_KEYSIZE,
lKeySpec: XEKL_KEYSPEC,
pdwKeySize: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InstallPKCS7BlobEx: fn(
self: *const IEnroll4,
pBlobPKCS7: ?*CRYPTOAPI_BLOB,
plCertInstalled: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddCertTypeToRequestWStrEx: fn(
self: *const IEnroll4,
lType: ADDED_CERT_TYPE,
pwszOIDOrName: ?[*:0]const u16,
lMajorVersion: i32,
fMinorVersion: BOOL,
lMinorVersion: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
getProviderTypeWStr: fn(
self: *const IEnroll4,
pwszProvName: ?[*:0]const u16,
plProvType: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
addBlobPropertyToCertificateWStr: fn(
self: *const IEnroll4,
lPropertyId: i32,
lReserved: i32,
pBlobProperty: ?*CRYPTOAPI_BLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetSignerCertificate: fn(
self: *const IEnroll4,
pSignerCert: ?*const CERT_CONTEXT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ClientId: fn(
self: *const IEnroll4,
lClientId: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ClientId: fn(
self: *const IEnroll4,
plClientId: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_IncludeSubjectKeyID: fn(
self: *const IEnroll4,
fInclude: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IncludeSubjectKeyID: fn(
self: *const IEnroll4,
pfInclude: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IEnroll2.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_put_ThumbPrintWStr(self: *const T, thumbPrintBlob: CRYPTOAPI_BLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).put_ThumbPrintWStr(@ptrCast(*const IEnroll4, self), thumbPrintBlob);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_get_ThumbPrintWStr(self: *const T, thumbPrintBlob: ?*CRYPTOAPI_BLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).get_ThumbPrintWStr(@ptrCast(*const IEnroll4, self), thumbPrintBlob);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_SetPrivateKeyArchiveCertificate(self: *const T, pPrivateKeyArchiveCert: ?*const CERT_CONTEXT) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).SetPrivateKeyArchiveCertificate(@ptrCast(*const IEnroll4, self), pPrivateKeyArchiveCert);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_GetPrivateKeyArchiveCertificate(self: *const T) callconv(.Inline) ?*CERT_CONTEXT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).GetPrivateKeyArchiveCertificate(@ptrCast(*const IEnroll4, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_binaryBlobToString(self: *const T, Flags: i32, pblobBinary: ?*CRYPTOAPI_BLOB, ppwszString: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).binaryBlobToString(@ptrCast(*const IEnroll4, self), Flags, pblobBinary, ppwszString);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_stringToBinaryBlob(self: *const T, Flags: i32, pwszString: ?[*:0]const u16, pblobBinary: ?*CRYPTOAPI_BLOB, pdwSkip: ?*i32, pdwFlags: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).stringToBinaryBlob(@ptrCast(*const IEnroll4, self), Flags, pwszString, pblobBinary, pdwSkip, pdwFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_addExtensionToRequestWStr(self: *const T, Flags: i32, pwszName: ?[*:0]const u16, pblobValue: ?*CRYPTOAPI_BLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).addExtensionToRequestWStr(@ptrCast(*const IEnroll4, self), Flags, pwszName, pblobValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_addAttributeToRequestWStr(self: *const T, Flags: i32, pwszName: ?[*:0]const u16, pblobValue: ?*CRYPTOAPI_BLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).addAttributeToRequestWStr(@ptrCast(*const IEnroll4, self), Flags, pwszName, pblobValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_addNameValuePairToRequestWStr(self: *const T, Flags: i32, pwszName: ?[*:0]const u16, pwszValue: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).addNameValuePairToRequestWStr(@ptrCast(*const IEnroll4, self), Flags, pwszName, pwszValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_resetExtensions(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).resetExtensions(@ptrCast(*const IEnroll4, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_resetAttributes(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).resetAttributes(@ptrCast(*const IEnroll4, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_createRequestWStr(self: *const T, Flags: CERT_CREATE_REQUEST_FLAGS, pwszDNName: ?[*:0]const u16, pwszUsage: ?[*:0]const u16, pblobRequest: ?*CRYPTOAPI_BLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).createRequestWStr(@ptrCast(*const IEnroll4, self), Flags, pwszDNName, pwszUsage, pblobRequest);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_createFileRequestWStr(self: *const T, Flags: CERT_CREATE_REQUEST_FLAGS, pwszDNName: ?[*:0]const u16, pwszUsage: ?[*:0]const u16, pwszRequestFileName: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).createFileRequestWStr(@ptrCast(*const IEnroll4, self), Flags, pwszDNName, pwszUsage, pwszRequestFileName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_acceptResponseBlob(self: *const T, pblobResponse: ?*CRYPTOAPI_BLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).acceptResponseBlob(@ptrCast(*const IEnroll4, self), pblobResponse);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_acceptFileResponseWStr(self: *const T, pwszResponseFileName: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).acceptFileResponseWStr(@ptrCast(*const IEnroll4, self), pwszResponseFileName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_getCertContextFromResponseBlob(self: *const T, pblobResponse: ?*CRYPTOAPI_BLOB, ppCertContext: ?*?*CERT_CONTEXT) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).getCertContextFromResponseBlob(@ptrCast(*const IEnroll4, self), pblobResponse, ppCertContext);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_getCertContextFromFileResponseWStr(self: *const T, pwszResponseFileName: ?[*:0]const u16, ppCertContext: ?*?*CERT_CONTEXT) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).getCertContextFromFileResponseWStr(@ptrCast(*const IEnroll4, self), pwszResponseFileName, ppCertContext);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_createPFXWStr(self: *const T, pwszPassword: ?[*:0]const u16, pblobPFX: ?*CRYPTOAPI_BLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).createPFXWStr(@ptrCast(*const IEnroll4, self), pwszPassword, pblobPFX);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_createFilePFXWStr(self: *const T, pwszPassword: ?[*:0]const u16, pwszPFXFileName: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).createFilePFXWStr(@ptrCast(*const IEnroll4, self), pwszPassword, pwszPFXFileName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_setPendingRequestInfoWStr(self: *const T, lRequestID: i32, pwszCADNS: ?[*:0]const u16, pwszCAName: ?[*:0]const u16, pwszFriendlyName: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).setPendingRequestInfoWStr(@ptrCast(*const IEnroll4, self), lRequestID, pwszCADNS, pwszCAName, pwszFriendlyName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_enumPendingRequestWStr(self: *const T, lIndex: i32, lDesiredProperty: PENDING_REQUEST_DESIRED_PROPERTY, ppProperty: ?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).enumPendingRequestWStr(@ptrCast(*const IEnroll4, self), lIndex, lDesiredProperty, ppProperty);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_removePendingRequestWStr(self: *const T, thumbPrintBlob: CRYPTOAPI_BLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).removePendingRequestWStr(@ptrCast(*const IEnroll4, self), thumbPrintBlob);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_GetKeyLenEx(self: *const T, lSizeSpec: XEKL_KEYSIZE, lKeySpec: XEKL_KEYSPEC, pdwKeySize: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).GetKeyLenEx(@ptrCast(*const IEnroll4, self), lSizeSpec, lKeySpec, pdwKeySize);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_InstallPKCS7BlobEx(self: *const T, pBlobPKCS7: ?*CRYPTOAPI_BLOB, plCertInstalled: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).InstallPKCS7BlobEx(@ptrCast(*const IEnroll4, self), pBlobPKCS7, plCertInstalled);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_AddCertTypeToRequestWStrEx(self: *const T, lType: ADDED_CERT_TYPE, pwszOIDOrName: ?[*:0]const u16, lMajorVersion: i32, fMinorVersion: BOOL, lMinorVersion: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).AddCertTypeToRequestWStrEx(@ptrCast(*const IEnroll4, self), lType, pwszOIDOrName, lMajorVersion, fMinorVersion, lMinorVersion);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_getProviderTypeWStr(self: *const T, pwszProvName: ?[*:0]const u16, plProvType: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).getProviderTypeWStr(@ptrCast(*const IEnroll4, self), pwszProvName, plProvType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_addBlobPropertyToCertificateWStr(self: *const T, lPropertyId: i32, lReserved: i32, pBlobProperty: ?*CRYPTOAPI_BLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).addBlobPropertyToCertificateWStr(@ptrCast(*const IEnroll4, self), lPropertyId, lReserved, pBlobProperty);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_SetSignerCertificate(self: *const T, pSignerCert: ?*const CERT_CONTEXT) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).SetSignerCertificate(@ptrCast(*const IEnroll4, self), pSignerCert);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_put_ClientId(self: *const T, lClientId: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).put_ClientId(@ptrCast(*const IEnroll4, self), lClientId);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_get_ClientId(self: *const T, plClientId: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).get_ClientId(@ptrCast(*const IEnroll4, self), plClientId);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_put_IncludeSubjectKeyID(self: *const T, fInclude: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).put_IncludeSubjectKeyID(@ptrCast(*const IEnroll4, self), fInclude);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnroll4_get_IncludeSubjectKeyID(self: *const T, pfInclude: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnroll4.VTable, self.vtable).get_IncludeSubjectKeyID(@ptrCast(*const IEnroll4, self), pfInclude);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_ICertRequestD_Value = @import("../../zig.zig").Guid.initString("d99e6e70-fc88-11d0-b498-00a0c90312f3");
pub const IID_ICertRequestD = &IID_ICertRequestD_Value;
pub const ICertRequestD = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Request: fn(
self: *const ICertRequestD,
dwFlags: u32,
pwszAuthority: ?[*:0]const u16,
pdwRequestId: ?*u32,
pdwDisposition: ?*u32,
pwszAttributes: ?[*:0]const u16,
pctbRequest: ?*const CERTTRANSBLOB,
pctbCertChain: ?*CERTTRANSBLOB,
pctbEncodedCert: ?*CERTTRANSBLOB,
pctbDispositionMessage: ?*CERTTRANSBLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCACert: fn(
self: *const ICertRequestD,
fchain: u32,
pwszAuthority: ?[*:0]const u16,
pctbOut: ?*CERTTRANSBLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Ping: fn(
self: *const ICertRequestD,
pwszAuthority: ?[*: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 ICertRequestD_Request(self: *const T, dwFlags: u32, pwszAuthority: ?[*:0]const u16, pdwRequestId: ?*u32, pdwDisposition: ?*u32, pwszAttributes: ?[*:0]const u16, pctbRequest: ?*const CERTTRANSBLOB, pctbCertChain: ?*CERTTRANSBLOB, pctbEncodedCert: ?*CERTTRANSBLOB, pctbDispositionMessage: ?*CERTTRANSBLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequestD.VTable, self.vtable).Request(@ptrCast(*const ICertRequestD, self), dwFlags, pwszAuthority, pdwRequestId, pdwDisposition, pwszAttributes, pctbRequest, pctbCertChain, pctbEncodedCert, pctbDispositionMessage);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequestD_GetCACert(self: *const T, fchain: u32, pwszAuthority: ?[*:0]const u16, pctbOut: ?*CERTTRANSBLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequestD.VTable, self.vtable).GetCACert(@ptrCast(*const ICertRequestD, self), fchain, pwszAuthority, pctbOut);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequestD_Ping(self: *const T, pwszAuthority: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequestD.VTable, self.vtable).Ping(@ptrCast(*const ICertRequestD, self), pwszAuthority);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_ICertRequestD2_Value = @import("../../zig.zig").Guid.initString("5422fd3a-d4b8-4cef-a12e-e87d4ca22e90");
pub const IID_ICertRequestD2 = &IID_ICertRequestD2_Value;
pub const ICertRequestD2 = extern struct {
pub const VTable = extern struct {
base: ICertRequestD.VTable,
Request2: fn(
self: *const ICertRequestD2,
pwszAuthority: ?[*:0]const u16,
dwFlags: u32,
pwszSerialNumber: ?[*:0]const u16,
pdwRequestId: ?*u32,
pdwDisposition: ?*u32,
pwszAttributes: ?[*:0]const u16,
pctbRequest: ?*const CERTTRANSBLOB,
pctbFullResponse: ?*CERTTRANSBLOB,
pctbEncodedCert: ?*CERTTRANSBLOB,
pctbDispositionMessage: ?*CERTTRANSBLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCAProperty: fn(
self: *const ICertRequestD2,
pwszAuthority: ?[*:0]const u16,
PropId: i32,
PropIndex: i32,
PropType: i32,
pctbPropertyValue: ?*CERTTRANSBLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCAPropertyInfo: fn(
self: *const ICertRequestD2,
pwszAuthority: ?[*:0]const u16,
pcProperty: ?*i32,
pctbPropInfo: ?*CERTTRANSBLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Ping2: fn(
self: *const ICertRequestD2,
pwszAuthority: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ICertRequestD.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequestD2_Request2(self: *const T, pwszAuthority: ?[*:0]const u16, dwFlags: u32, pwszSerialNumber: ?[*:0]const u16, pdwRequestId: ?*u32, pdwDisposition: ?*u32, pwszAttributes: ?[*:0]const u16, pctbRequest: ?*const CERTTRANSBLOB, pctbFullResponse: ?*CERTTRANSBLOB, pctbEncodedCert: ?*CERTTRANSBLOB, pctbDispositionMessage: ?*CERTTRANSBLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequestD2.VTable, self.vtable).Request2(@ptrCast(*const ICertRequestD2, self), pwszAuthority, dwFlags, pwszSerialNumber, pdwRequestId, pdwDisposition, pwszAttributes, pctbRequest, pctbFullResponse, pctbEncodedCert, pctbDispositionMessage);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequestD2_GetCAProperty(self: *const T, pwszAuthority: ?[*:0]const u16, PropId: i32, PropIndex: i32, PropType: i32, pctbPropertyValue: ?*CERTTRANSBLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequestD2.VTable, self.vtable).GetCAProperty(@ptrCast(*const ICertRequestD2, self), pwszAuthority, PropId, PropIndex, PropType, pctbPropertyValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequestD2_GetCAPropertyInfo(self: *const T, pwszAuthority: ?[*:0]const u16, pcProperty: ?*i32, pctbPropInfo: ?*CERTTRANSBLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequestD2.VTable, self.vtable).GetCAPropertyInfo(@ptrCast(*const ICertRequestD2, self), pwszAuthority, pcProperty, pctbPropInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertRequestD2_Ping2(self: *const T, pwszAuthority: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertRequestD2.VTable, self.vtable).Ping2(@ptrCast(*const ICertRequestD2, self), pwszAuthority);
}
};}
pub usingnamespace MethodMixin(@This());
};
//--------------------------------------------------------------------------------
// Section: Functions (26)
//--------------------------------------------------------------------------------
// TODO: this type is limited to platform 'windowsServer2003'
pub extern "certadm" fn CertSrvIsServerOnlineW(
pwszServerName: ?[*:0]const u16,
pfServerOnline: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windowsServer2003'
pub extern "certadm" fn CertSrvBackupGetDynamicFileListW(
hbc: ?*anyopaque,
ppwszzFileList: ?*?PWSTR,
pcbSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windowsServer2003'
pub extern "certadm" fn CertSrvBackupPrepareW(
pwszServerName: ?[*:0]const u16,
grbitJet: u32,
dwBackupFlags: CSBACKUP_TYPE,
phbc: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windowsServer2003'
pub extern "certadm" fn CertSrvBackupGetDatabaseNamesW(
hbc: ?*anyopaque,
ppwszzAttachmentInformation: ?*?PWSTR,
pcbSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windowsServer2003'
pub extern "certadm" fn CertSrvBackupOpenFileW(
hbc: ?*anyopaque,
pwszAttachmentName: ?[*:0]const u16,
cbReadHintSize: u32,
pliFileSize: ?*LARGE_INTEGER,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windowsServer2003'
pub extern "certadm" fn CertSrvBackupRead(
hbc: ?*anyopaque,
pvBuffer: ?*anyopaque,
cbBuffer: u32,
pcbRead: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windowsServer2003'
pub extern "certadm" fn CertSrvBackupClose(
hbc: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windowsServer2003'
pub extern "certadm" fn CertSrvBackupGetBackupLogsW(
hbc: ?*anyopaque,
ppwszzBackupLogFiles: ?*?PWSTR,
pcbSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windowsServer2003'
pub extern "certadm" fn CertSrvBackupTruncateLogs(
hbc: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windowsServer2003'
pub extern "certadm" fn CertSrvBackupEnd(
hbc: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windowsServer2003'
pub extern "certadm" fn CertSrvBackupFree(
pv: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) void;
// TODO: this type is limited to platform 'windowsServer2003'
pub extern "certadm" fn CertSrvRestoreGetDatabaseLocationsW(
hbc: ?*anyopaque,
ppwszzDatabaseLocationList: ?*?PWSTR,
pcbSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windowsServer2003'
pub extern "certadm" fn CertSrvRestorePrepareW(
pwszServerName: ?[*:0]const u16,
dwRestoreFlags: u32,
phbc: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windowsServer2003'
pub extern "certadm" fn CertSrvRestoreRegisterW(
hbc: ?*anyopaque,
pwszCheckPointFilePath: ?[*:0]const u16,
pwszLogPath: ?[*:0]const u16,
rgrstmap: ?*CSEDB_RSTMAPW,
crstmap: i32,
pwszBackupLogPath: ?[*:0]const u16,
genLow: u32,
genHigh: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windowsServer2003'
pub extern "certadm" fn CertSrvRestoreRegisterThroughFile(
hbc: ?*anyopaque,
pwszCheckPointFilePath: ?[*:0]const u16,
pwszLogPath: ?[*:0]const u16,
rgrstmap: ?*CSEDB_RSTMAPW,
crstmap: i32,
pwszBackupLogPath: ?[*:0]const u16,
genLow: u32,
genHigh: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windowsServer2003'
pub extern "certadm" fn CertSrvRestoreRegisterComplete(
hbc: ?*anyopaque,
hrRestoreState: HRESULT,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windowsServer2003'
pub extern "certadm" fn CertSrvRestoreEnd(
hbc: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windowsServer2003'
pub extern "certadm" fn CertSrvServerControlW(
pwszServerName: ?[*:0]const u16,
dwControlFlags: u32,
pcbOut: ?*u32,
ppbOut: ?*?*u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows6.1'
pub extern "certpoleng" fn PstGetTrustAnchors(
pTargetName: ?*UNICODE_STRING,
cCriteria: u32,
rgpCriteria: ?[*]CERT_SELECT_CRITERIA,
ppTrustedIssuers: ?*?*SecPkgContext_IssuerListInfoEx,
) callconv(@import("std").os.windows.WINAPI) NTSTATUS;
pub extern "certpoleng" fn PstGetTrustAnchorsEx(
pTargetName: ?*UNICODE_STRING,
cCriteria: u32,
rgpCriteria: ?[*]CERT_SELECT_CRITERIA,
pCertContext: ?*const CERT_CONTEXT,
ppTrustedIssuers: ?*?*SecPkgContext_IssuerListInfoEx,
) callconv(@import("std").os.windows.WINAPI) NTSTATUS;
pub extern "certpoleng" fn PstGetCertificateChain(
pCert: ?*const CERT_CONTEXT,
pTrustedIssuers: ?*SecPkgContext_IssuerListInfoEx,
ppCertChainContext: ?*?*CERT_CHAIN_CONTEXT,
) callconv(@import("std").os.windows.WINAPI) NTSTATUS;
// TODO: this type is limited to platform 'windows6.1'
pub extern "certpoleng" fn PstGetCertificates(
pTargetName: ?*UNICODE_STRING,
cCriteria: u32,
rgpCriteria: ?[*]CERT_SELECT_CRITERIA,
bIsClient: BOOL,
pdwCertChainContextCount: ?*u32,
ppCertChainContexts: ?*?*?*CERT_CHAIN_CONTEXT,
) callconv(@import("std").os.windows.WINAPI) NTSTATUS;
// TODO: this type is limited to platform 'windows6.1'
pub extern "certpoleng" fn PstAcquirePrivateKey(
pCert: ?*const CERT_CONTEXT,
) callconv(@import("std").os.windows.WINAPI) NTSTATUS;
// TODO: this type is limited to platform 'windows6.1'
pub extern "certpoleng" fn PstValidate(
pTargetName: ?*UNICODE_STRING,
bIsClient: BOOL,
pRequestedIssuancePolicy: ?*CERT_USAGE_MATCH,
phAdditionalCertStore: ?*?*anyopaque,
pCert: ?*const CERT_CONTEXT,
pProvGUID: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) NTSTATUS;
// TODO: this type is limited to platform 'windows6.1'
pub extern "certpoleng" fn PstMapCertificate(
pCert: ?*const CERT_CONTEXT,
pTokenInformationType: ?*LSA_TOKEN_INFORMATION_TYPE,
ppTokenInformation: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) NTSTATUS;
// TODO: this type is limited to platform 'windows6.1'
pub extern "certpoleng" fn PstGetUserNameForCertificate(
pCertContext: ?*const CERT_CONTEXT,
UserName: ?*UNICODE_STRING,
) callconv(@import("std").os.windows.WINAPI) NTSTATUS;
//--------------------------------------------------------------------------------
// 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 (22)
//--------------------------------------------------------------------------------
const Guid = @import("../../zig.zig").Guid;
const BOOL = @import("../../foundation.zig").BOOL;
const BSTR = @import("../../foundation.zig").BSTR;
const CERT_CHAIN_CONTEXT = @import("../../security/cryptography.zig").CERT_CHAIN_CONTEXT;
const CERT_CONTEXT = @import("../../security/cryptography.zig").CERT_CONTEXT;
const CERT_EXTENSIONS = @import("../../security/cryptography.zig").CERT_EXTENSIONS;
const CERT_RDN_ATTR_VALUE_TYPE = @import("../../security/cryptography.zig").CERT_RDN_ATTR_VALUE_TYPE;
const CERT_SELECT_CRITERIA = @import("../../security/cryptography.zig").CERT_SELECT_CRITERIA;
const CERT_USAGE_MATCH = @import("../../security/cryptography.zig").CERT_USAGE_MATCH;
const CRYPT_ATTRIBUTES = @import("../../security/cryptography.zig").CRYPT_ATTRIBUTES;
const CRYPTOAPI_BLOB = @import("../../security/cryptography.zig").CRYPTOAPI_BLOB;
const HRESULT = @import("../../foundation.zig").HRESULT;
const HWND = @import("../../foundation.zig").HWND;
const IDispatch = @import("../../system/com.zig").IDispatch;
const IUnknown = @import("../../system/com.zig").IUnknown;
const LARGE_INTEGER = @import("../../foundation.zig").LARGE_INTEGER;
const LSA_TOKEN_INFORMATION_TYPE = @import("../../security/authentication/identity.zig").LSA_TOKEN_INFORMATION_TYPE;
const NTSTATUS = @import("../../foundation.zig").NTSTATUS;
const PWSTR = @import("../../foundation.zig").PWSTR;
const SecPkgContext_IssuerListInfoEx = @import("../../security/authentication/identity.zig").SecPkgContext_IssuerListInfoEx;
const UNICODE_STRING = @import("../../foundation.zig").UNICODE_STRING;
const VARIANT = @import("../../system/com.zig").VARIANT;
test {
// The following '_ = <FuncPtrType>' lines are a workaround for https://github.com/ziglang/zig/issues/4476
if (@hasDecl(@This(), "FNCERTSRVISSERVERONLINEW")) { _ = FNCERTSRVISSERVERONLINEW; }
if (@hasDecl(@This(), "FNCERTSRVBACKUPGETDYNAMICFILELISTW")) { _ = FNCERTSRVBACKUPGETDYNAMICFILELISTW; }
if (@hasDecl(@This(), "FNCERTSRVBACKUPPREPAREW")) { _ = FNCERTSRVBACKUPPREPAREW; }
if (@hasDecl(@This(), "FNCERTSRVBACKUPGETDATABASENAMESW")) { _ = FNCERTSRVBACKUPGETDATABASENAMESW; }
if (@hasDecl(@This(), "FNCERTSRVBACKUPOPENFILEW")) { _ = FNCERTSRVBACKUPOPENFILEW; }
if (@hasDecl(@This(), "FNCERTSRVBACKUPREAD")) { _ = FNCERTSRVBACKUPREAD; }
if (@hasDecl(@This(), "FNCERTSRVBACKUPCLOSE")) { _ = FNCERTSRVBACKUPCLOSE; }
if (@hasDecl(@This(), "FNCERTSRVBACKUPGETBACKUPLOGSW")) { _ = FNCERTSRVBACKUPGETBACKUPLOGSW; }
if (@hasDecl(@This(), "FNCERTSRVBACKUPTRUNCATELOGS")) { _ = FNCERTSRVBACKUPTRUNCATELOGS; }
if (@hasDecl(@This(), "FNCERTSRVBACKUPEND")) { _ = FNCERTSRVBACKUPEND; }
if (@hasDecl(@This(), "FNCERTSRVBACKUPFREE")) { _ = FNCERTSRVBACKUPFREE; }
if (@hasDecl(@This(), "FNCERTSRVRESTOREGETDATABASELOCATIONSW")) { _ = FNCERTSRVRESTOREGETDATABASELOCATIONSW; }
if (@hasDecl(@This(), "FNCERTSRVRESTOREPREPAREW")) { _ = FNCERTSRVRESTOREPREPAREW; }
if (@hasDecl(@This(), "FNCERTSRVRESTOREREGISTERW")) { _ = FNCERTSRVRESTOREREGISTERW; }
if (@hasDecl(@This(), "FNCERTSRVRESTOREREGISTERCOMPLETE")) { _ = FNCERTSRVRESTOREREGISTERCOMPLETE; }
if (@hasDecl(@This(), "FNCERTSRVRESTOREEND")) { _ = FNCERTSRVRESTOREEND; }
if (@hasDecl(@This(), "FNCERTSRVSERVERCONTROLW")) { _ = FNCERTSRVSERVERCONTROLW; }
if (@hasDecl(@This(), "FNIMPORTPFXTOPROVIDER")) { _ = FNIMPORTPFXTOPROVIDER; }
if (@hasDecl(@This(), "FNIMPORTPFXTOPROVIDERFREEDATA")) { _ = FNIMPORTPFXTOPROVIDERFREEDATA; }
@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/security/cryptography/certificates.zig |
const std = @import("std");
const c = @import("c.zig");
// Type Aliases
pub const Window = c.SDL_Window;
pub const Renderer = c.SDL_Renderer;
pub const Surface = c.SDL_Surface;
pub const Texture = c.SDL_Texture;
pub const Rect = c.SDL_Rect;
pub const Event = c.SDL_Event;
pub const RendererFlip = c.SDL_RendererFlip;
pub const Color = c.SDL_Color;
// Function Forwards
pub const init = c.SDL_Init;
pub const quit = c.SDL_Quit;
pub const delay = c.SDL_Delay;
pub const getTicks = c.SDL_GetTicks;
pub const pollEvent = c.SDL_PollEvent;
pub const waitEvent = c.SDL_WaitEvent;
pub const waitEventTimeout = c.SDL_WaitEventTimeout;
pub const getKeyboardState = c.SDL_GetKeyboardState;
pub const destroyWindow = c.SDL_DestroyWindow;
pub const destroyRenderer = c.SDL_DestroyRenderer;
pub const renderCopyEx = c.SDL_RenderCopyEx;
pub const renderDrawRects = c.SDL_RenderDrawRects;
pub const renderSetLogicalSize = c.SDL_RenderSetLogicalSize;
pub const loadBmp = c.SDL_LoadBMP;
pub const freeSurface = c.SDL_FreeSurface;
pub const createTextureFromSurface = c.SDL_CreateTextureFromSurface;
pub const queryTexture = c.SDL_QueryTexture;
// Constant Forwards
pub const INIT_EVERYTHING = c.SDL_INIT_EVERYTHING;
pub const INIT_VIDEO = c.SDL_INIT_VIDEO;
pub const WINDOWPOS_CENTERED = c.SDL_WINDOWPOS_CENTERED;
pub const WINDOW_SHOWN = c.SDL_WINDOW_SHOWN;
pub const KEYDOWN = c.SDL_KEYDOWN;
pub const KEYUP = c.SDL_KEYUP;
pub const QUIT = c.SDL_QUIT;
pub const MOUSEBUTTONDOWN = c.SDL_MOUSEBUTTONDOWN;
pub const WINDOW_BORDERLESS = c.SDL_WINDOW_BORDERLESS;
pub const WINDOW_FULLSCREEN = c.SDL_WINDOW_FULLSCREEN;
// SDL Scan codes
pub const SCANCODE_DOWN = c.SDL_SCANCODE_DOWN;
pub const SCANCODE_UP = c.SDL_SCANCODE_UP;
pub const SCANCODE_LEFT = c.SDL_SCANCODE_LEFT;
pub const SCANCODE_RIGHT = c.SDL_SCANCODE_RIGHT;
pub const SCANCODE_1 = c.SDL_SCANCODE_1;
pub const SCANCODE_2 = c.SDL_SCANCODE_2;
pub const SCANCODE_3 = c.SDL_SCANCODE_3;
pub const SCANCODE_4 = c.SDL_SCANCODE_4;
pub const SCANCODE_5 = c.SDL_SCANCODE_5;
pub const SCANCODE_6 = c.SDL_SCANCODE_6;
pub const SCANCODE_7 = c.SDL_SCANCODE_7;
pub const SCANCODE_8 = c.SDL_SCANCODE_8;
pub const SCANCODE_9 = c.SDL_SCANCODE_9;
pub const SCANCODE_BACKSPACE = c.SDL_SCANCODE_BACKSPACE;
pub const SCANCODE_C = c.SDL_SCANCODE_C;
pub const SCANCODE_R = c.SDL_SCANCODE_R;
pub const SCANCODE_Z = c.SDL_SCANCODE_Z;
pub const SCANCODE_X = c.SDL_SCANCODE_X;
// Errors
const InitError = error{InitializationError};
const CreateError = error{
WindowCreationError,
RendererCreationError,
};
// Non-forwarding functions
pub fn getError() []const u8 {
return "Hello there";
}
pub fn clearError() void {}
pub fn createWindow(
window_name: []const u8,
x_pos: i32,
y_pos: i32,
width: i32,
height: i32,
flags: var,
) !*Window {
var opt_window: ?*Window = c.SDL_CreateWindow(
window_name.ptr,
x_pos,
y_pos,
width,
height,
makeFlags(flags),
);
if (opt_window) |window| {
return window;
}
handleError("Error creating Window");
return CreateError.WindowCreationError;
}
pub fn createRenderer(window: *Window, index: i32, flags: var) !*Renderer {
var opt_render: ?*Renderer = c.SDL_CreateRenderer(
window,
index,
makeFlags(flags),
);
if (opt_render) |render| {
return render;
}
handleError("Error creating Renderer");
return CreateError.RendererCreationError;
}
pub fn destroyTexture(texture: *Texture) void {
c.SDL_DestroyTexture(texture);
}
pub fn handleError(function_str: []const u8) void {
std.debug.warn(
"{}: {}\n",
.{ function_str, getError() },
);
clearError();
}
pub fn renderClear(renderer: *Renderer) !void {
const result = c.SDL_RenderClear(renderer);
if (result != 0) {
handleError("Error clearing renderer");
return error.RENDER_CLEAR_ERROR;
}
}
pub fn setRenderDrawColor(renderer: *Renderer, color: Color) !void {
const result = c.SDL_SetRenderDrawColor(
renderer,
color.r,
color.g,
color.b,
color.a,
);
if (result != 0) {
handleError("Error setting render draw color");
return error.SET_RENDER_DRAW_COLOR_ERROR;
}
}
pub fn renderCopy(renderer: *Renderer, texture: *Texture, source_rect: *const Rect, dest_rect: *const Rect) !void {
const result = c.SDL_RenderCopy(renderer, texture, source_rect, dest_rect);
if (result != 0) {
handleError("Error copying texture");
return error.RENDER_COPY_ERROR;
}
}
pub fn renderPresent(renderer: *Renderer) void {
c.SDL_RenderPresent(renderer);
}
pub fn renderDrawRect(renderer: *Renderer, rect: *const Rect) !void {
const result = c.SDL_RenderDrawRect(renderer, rect);
if (result != 0) {
handleError("Error rendering rectangle");
return error.RENDER_DRAW_RECT_ERROR;
}
}
pub fn renderFillRect(renderer: *Renderer, rect: *const Rect) !void {
const result = c.SDL_RenderFillRect(renderer, rect);
if (result != 0) {
handleError("Error rendering filled rectangle");
return error.RENDER_FILL_RECT_ERROR;
}
}
// Useful struct for setting color
//pub const Color = struct {
// r: u8,
// g: u8,
// b: u8,
// a: u8,
//};
pub const BLACK = Color{
.r = 0,
.g = 0,
.b = 0,
.a = 255,
};
pub const WHITE = Color{
.r = 255,
.g = 255,
.b = 255,
.a = 255,
};
pub const RED = Color{
.r = 255,
.g = 0,
.b = 0,
.a = 255,
};
pub const GREEN = Color{
.r = 0,
.g = 255,
.b = 0,
.a = 255,
};
pub const BLUE = Color{
.r = 0,
.g = 0,
.b = 255,
.a = 255,
};
// Helper functions
fn makeFlags(args: var) u32 {
var flags: u32 = 0;
inline for (args) |flag| {
flags = flags | @as(u32, flag);
}
return flags;
} | deps/sdl/src/sdl.zig |
pub const EPERM = 1;
/// No such file or directory
pub const ENOENT = 2;
/// No such process
pub const ESRCH = 3;
/// Interrupted system call
pub const EINTR = 4;
/// I/O error
pub const EIO = 5;
/// No such device or address
pub const ENXIO = 6;
/// Arg list too long
pub const E2BIG = 7;
/// Exec format error
pub const ENOEXEC = 8;
/// Bad file number
pub const EBADF = 9;
/// No child processes
pub const ECHILD = 10;
/// Try again
pub const EAGAIN = 11;
/// Out of memory
pub const ENOMEM = 12;
/// Permission denied
pub const EACCES = 13;
/// Bad address
pub const EFAULT = 14;
/// Block device required
pub const ENOTBLK = 15;
/// Device or resource busy
pub const EBUSY = 16;
/// File exists
pub const EEXIST = 17;
/// Cross-device link
pub const EXDEV = 18;
/// No such device
pub const ENODEV = 19;
/// Not a directory
pub const ENOTDIR = 20;
/// Is a directory
pub const EISDIR = 21;
/// Invalid argument
pub const EINVAL = 22;
/// File table overflow
pub const ENFILE = 23;
/// Too many open files
pub const EMFILE = 24;
/// Not a typewriter
pub const ENOTTY = 25;
/// Text file busy
pub const ETXTBSY = 26;
/// File too large
pub const EFBIG = 27;
/// No space left on device
pub const ENOSPC = 28;
/// Illegal seek
pub const ESPIPE = 29;
/// Read-only file system
pub const EROFS = 30;
/// Too many links
pub const EMLINK = 31;
/// Broken pipe
pub const EPIPE = 32;
/// Math argument out of domain of func
pub const EDOM = 33;
/// Math result not representable
pub const ERANGE = 34;
/// Resource deadlock would occur
pub const EDEADLK = 35;
/// File name too long
pub const ENAMETOOLONG = 36;
/// No record locks available
pub const ENOLCK = 37;
/// Function not implemented
pub const ENOSYS = 38;
/// Directory not empty
pub const ENOTEMPTY = 39;
/// Too many symbolic links encountered
pub const ELOOP = 40;
/// Operation would block
pub const EWOULDBLOCK = EAGAIN;
/// No message of desired type
pub const ENOMSG = 42;
/// Identifier removed
pub const EIDRM = 43;
/// Channel number out of range
pub const ECHRNG = 44;
/// Level 2 not synchronized
pub const EL2NSYNC = 45;
/// Level 3 halted
pub const EL3HLT = 46;
/// Level 3 reset
pub const EL3RST = 47;
/// Link number out of range
pub const ELNRNG = 48;
/// Protocol driver not attached
pub const EUNATCH = 49;
/// No CSI structure available
pub const ENOCSI = 50;
/// Level 2 halted
pub const EL2HLT = 51;
/// Invalid exchange
pub const EBADE = 52;
/// Invalid request descriptor
pub const EBADR = 53;
/// Exchange full
pub const EXFULL = 54;
/// No anode
pub const ENOANO = 55;
/// Invalid request code
pub const EBADRQC = 56;
/// Invalid slot
pub const EBADSLT = 57;
/// Bad font file format
pub const EBFONT = 59;
/// Device not a stream
pub const ENOSTR = 60;
/// No data available
pub const ENODATA = 61;
/// Timer expired
pub const ETIME = 62;
/// Out of streams resources
pub const ENOSR = 63;
/// Machine is not on the network
pub const ENONET = 64;
/// Package not installed
pub const ENOPKG = 65;
/// Object is remote
pub const EREMOTE = 66;
/// Link has been severed
pub const ENOLINK = 67;
/// Advertise error
pub const EADV = 68;
/// Srmount error
pub const ESRMNT = 69;
/// Communication error on send
pub const ECOMM = 70;
/// Protocol error
pub const EPROTO = 71;
/// Multihop attempted
pub const EMULTIHOP = 72;
/// RFS specific error
pub const EDOTDOT = 73;
/// Not a data message
pub const EBADMSG = 74;
/// Value too large for defined data type
pub const EOVERFLOW = 75;
/// Name not unique on network
pub const ENOTUNIQ = 76;
/// File descriptor in bad state
pub const EBADFD = 77;
/// Remote address changed
pub const EREMCHG = 78;
/// Can not access a needed shared library
pub const ELIBACC = 79;
/// Accessing a corrupted shared library
pub const ELIBBAD = 80;
/// .lib section in a.out corrupted
pub const ELIBSCN = 81;
/// Attempting to link in too many shared libraries
pub const ELIBMAX = 82;
/// Cannot exec a shared library directly
pub const ELIBEXEC = 83;
/// Illegal byte sequence
pub const EILSEQ = 84;
/// Interrupted system call should be restarted
pub const ERESTART = 85;
/// Streams pipe error
pub const ESTRPIPE = 86;
/// Too many users
pub const EUSERS = 87;
/// Socket operation on non-socket
pub const ENOTSOCK = 88;
/// Destination address required
pub const EDESTADDRREQ = 89;
/// Message too long
pub const EMSGSIZE = 90;
/// Protocol wrong type for socket
pub const EPROTOTYPE = 91;
/// Protocol not available
pub const ENOPROTOOPT = 92;
/// Protocol not supported
pub const EPROTONOSUPPORT = 93;
/// Socket type not supported
pub const ESOCKTNOSUPPORT = 94;
/// Operation not supported on transport endpoint
pub const EOPNOTSUPP = 95;
pub const ENOTSUP = EOPNOTSUPP;
/// Protocol family not supported
pub const EPFNOSUPPORT = 96;
/// Address family not supported by protocol
pub const EAFNOSUPPORT = 97;
/// Address already in use
pub const EADDRINUSE = 98;
/// Cannot assign requested address
pub const EADDRNOTAVAIL = 99;
/// Network is down
pub const ENETDOWN = 100;
/// Network is unreachable
pub const ENETUNREACH = 101;
/// Network dropped connection because of reset
pub const ENETRESET = 102;
/// Software caused connection abort
pub const ECONNABORTED = 103;
/// Connection reset by peer
pub const ECONNRESET = 104;
/// No buffer space available
pub const ENOBUFS = 105;
/// Transport endpoint is already connected
pub const EISCONN = 106;
/// Transport endpoint is not connected
pub const ENOTCONN = 107;
/// Cannot send after transport endpoint shutdown
pub const ESHUTDOWN = 108;
/// Too many references: cannot splice
pub const ETOOMANYREFS = 109;
/// Connection timed out
pub const ETIMEDOUT = 110;
/// Connection refused
pub const ECONNREFUSED = 111;
/// Host is down
pub const EHOSTDOWN = 112;
/// No route to host
pub const EHOSTUNREACH = 113;
/// Operation already in progress
pub const EALREADY = 114;
/// Operation now in progress
pub const EINPROGRESS = 115;
/// Stale NFS file handle
pub const ESTALE = 116;
/// Structure needs cleaning
pub const EUCLEAN = 117;
/// Not a XENIX named type file
pub const ENOTNAM = 118;
/// No XENIX semaphores available
pub const ENAVAIL = 119;
/// Is a named type file
pub const EISNAM = 120;
/// Remote I/O error
pub const EREMOTEIO = 121;
/// Quota exceeded
pub const EDQUOT = 122;
/// No medium found
pub const ENOMEDIUM = 123;
/// Wrong medium type
pub const EMEDIUMTYPE = 124;
/// Operation canceled
pub const ECANCELED = 125;
/// Required key not available
pub const ENOKEY = 126;
/// Key has expired
pub const EKEYEXPIRED = 127;
/// Key has been revoked
pub const EKEYREVOKED = 128;
/// Key was rejected by service
pub const EKEYREJECTED = 129;
// for robust mutexes
/// Owner died
pub const EOWNERDEAD = 130;
/// State not recoverable
pub const ENOTRECOVERABLE = 131;
/// Operation not possible due to RF-kill
pub const ERFKILL = 132;
/// Memory page has hardware error
pub const EHWPOISON = 133;
// nameserver query return codes
/// DNS server returned answer with no data
pub const ENSROK = 0;
/// DNS server returned answer with no data
pub const ENSRNODATA = 160;
/// DNS server claims query was misformatted
pub const ENSRFORMERR = 161;
/// DNS server returned general failure
pub const ENSRSERVFAIL = 162;
/// Domain name not found
pub const ENSRNOTFOUND = 163;
/// DNS server does not implement requested operation
pub const ENSRNOTIMP = 164;
/// DNS server refused query
pub const ENSRREFUSED = 165;
/// Misformatted DNS query
pub const ENSRBADQUERY = 166;
/// Misformatted domain name
pub const ENSRBADNAME = 167;
/// Unsupported address family
pub const ENSRBADFAMILY = 168;
/// Misformatted DNS reply
pub const ENSRBADRESP = 169;
/// Could not contact DNS servers
pub const ENSRCONNREFUSED = 170;
/// Timeout while contacting DNS servers
pub const ENSRTIMEOUT = 171;
/// End of file
pub const ENSROF = 172;
/// Error reading file
pub const ENSRFILE = 173;
/// Out of memory
pub const ENSRNOMEM = 174;
/// Application terminated lookup
pub const ENSRDESTRUCTION = 175;
/// Domain name is too long
pub const ENSRQUERYDOMAINTOOLONG = 176;
/// Domain name is too long
pub const ENSRCNAMELOOP = 177; | lib/std/os/bits/linux/errno-generic.zig |
const sg = @import("sokol").gfx;
//
// #version:1# (machine generated, don't edit!)
//
// Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
//
// Cmdline: sokol-shdc -i texcube.glsl -o texcube.glsl.zig -l glsl330:metal_macos:hlsl4 -f sokol_zig
//
// Overview:
//
// Shader program 'texcube':
// Get shader desc: shd.texcubeShaderDesc(sg.queryBackend());
// Vertex shader: vs
// Attribute slots:
// ATTR_vs_pos = 0
// ATTR_vs_color0 = 1
// ATTR_vs_texcoord0 = 2
// Uniform block 'vs_params':
// C struct: vs_params_t
// Bind slot: SLOT_vs_params = 0
// Fragment shader: fs
// Image 'tex':
// Type: ._2D
// Component Type: .FLOAT
// Bind slot: SLOT_tex = 0
//
//
pub const ATTR_vs_pos = 0;
pub const ATTR_vs_color0 = 1;
pub const ATTR_vs_texcoord0 = 2;
pub const SLOT_tex = 0;
pub const SLOT_vs_params = 0;
pub const VsParams = extern struct {
mvp: @import("../math.zig").Mat4 align(16),
};
//
// #version 330
//
// uniform vec4 vs_params[4];
// layout(location = 0) in vec4 pos;
// out vec4 color;
// layout(location = 1) in vec4 color0;
// out vec2 uv;
// layout(location = 2) in vec2 texcoord0;
//
// void main()
// {
// gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * pos;
// color = color0;
// uv = texcoord0 * 5.0;
// }
//
//
const vs_source_glsl330 = [332]u8 {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e,
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,0x5f,0x70,0x61,
0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,
0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,
0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,
0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,
0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,
0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,
0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79,
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,
0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,
0x72,0x64,0x30,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,
0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,
0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
0x5b,0x32,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,
0x5d,0x29,0x20,0x2a,0x20,0x70,0x6f,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,
0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,
0x20,0x2a,0x20,0x35,0x2e,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
//
// #version 330
//
// uniform sampler2D tex;
//
// layout(location = 0) out vec4 frag_color;
// in vec2 uv;
// in vec4 color;
//
// void main()
// {
// frag_color = texture(tex, uv) * color;
// }
//
//
const fs_source_glsl330 = [169]u8 {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e,
0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,
0x74,0x65,0x78,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,
0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,
0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,
0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x69,0x6e,0x20,0x76,
0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,
0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,
0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,
0x72,0x65,0x28,0x74,0x65,0x78,0x2c,0x20,0x75,0x76,0x29,0x20,0x2a,0x20,0x63,0x6f,
0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
//
// cbuffer vs_params : register(b0)
// {
// row_major float4x4 _21_mvp : packoffset(c0);
// };
//
//
// static float4 gl_Position;
// static float4 pos;
// static float4 color;
// static float4 color0;
// static float2 uv;
// static float2 texcoord0;
//
// struct SPIRV_Cross_Input
// {
// float4 pos : TEXCOORD0;
// float4 color0 : TEXCOORD1;
// float2 texcoord0 : TEXCOORD2;
// };
//
// struct SPIRV_Cross_Output
// {
// float4 color : TEXCOORD0;
// float2 uv : TEXCOORD1;
// float4 gl_Position : SV_Position;
// };
//
// #line 18 "texcube.glsl"
// void vert_main()
// {
// #line 18 "texcube.glsl"
// gl_Position = mul(pos, _21_mvp);
// #line 19 "texcube.glsl"
// color = color0;
// #line 20 "texcube.glsl"
// uv = texcoord0 * 5.0f;
// }
//
// SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
// {
// pos = stage_input.pos;
// color0 = stage_input.color0;
// texcoord0 = stage_input.texcoord0;
// vert_main();
// SPIRV_Cross_Output stage_output;
// stage_output.gl_Position = gl_Position;
// stage_output.color = color;
// stage_output.uv = uv;
// return stage_output;
// }
//
const vs_source_hlsl4 = [1015]u8 {
0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
0x73,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x30,0x29,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x72,0x6f,0x77,0x5f,0x6d,0x61,0x6a,0x6f,0x72,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x5f,0x32,0x31,0x5f,0x6d,0x76,
0x70,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,
0x30,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,
0x6f,0x6e,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x20,0x70,0x6f,0x73,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x73,0x74,0x61,0x74,
0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,
0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,
0x75,0x76,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x0a,0x73,0x74,
0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,
0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x20,0x70,0x6f,0x73,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,
0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
0x63,0x6f,0x6c,0x6f,0x72,0x30,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,
0x44,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x74,
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,
0x4f,0x52,0x44,0x32,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,
0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,
0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,
0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,
0x76,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x31,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,
0x69,0x74,0x69,0x6f,0x6e,0x20,0x3a,0x20,0x53,0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,
0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,
0x38,0x20,0x22,0x74,0x65,0x78,0x63,0x75,0x62,0x65,0x2e,0x67,0x6c,0x73,0x6c,0x22,
0x0a,0x76,0x6f,0x69,0x64,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,
0x29,0x0a,0x7b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x38,0x20,0x22,0x74,0x65,
0x78,0x63,0x75,0x62,0x65,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,
0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x75,
0x6c,0x28,0x70,0x6f,0x73,0x2c,0x20,0x5f,0x32,0x31,0x5f,0x6d,0x76,0x70,0x29,0x3b,
0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x39,0x20,0x22,0x74,0x65,0x78,0x63,0x75,
0x62,0x65,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,
0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x23,0x6c,0x69,
0x6e,0x65,0x20,0x32,0x30,0x20,0x22,0x74,0x65,0x78,0x63,0x75,0x62,0x65,0x2e,0x67,
0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x74,0x65,
0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x20,0x2a,0x20,0x35,0x2e,0x30,0x66,0x3b,0x0a,
0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,
0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,
0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,
0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x70,0x6f,0x73,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,
0x74,0x2e,0x70,0x6f,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,
0x30,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,
0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,0x63,
0x6f,0x6f,0x72,0x64,0x30,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,
0x70,0x75,0x74,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,
0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,
0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,
0x75,0x74,0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,
0x6e,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,
0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,
0x74,0x2e,0x75,0x76,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,
0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,
0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x00,
};
//
// Texture2D<float4> tex : register(t0);
// SamplerState _tex_sampler : register(s0);
//
// static float4 frag_color;
// static float2 uv;
// static float4 color;
//
// struct SPIRV_Cross_Input
// {
// float4 color : TEXCOORD0;
// float2 uv : TEXCOORD1;
// };
//
// struct SPIRV_Cross_Output
// {
// float4 frag_color : SV_Target0;
// };
//
// #line 13 "texcube.glsl"
// void frag_main()
// {
// #line 13 "texcube.glsl"
// frag_color = tex.Sample(_tex_sampler, uv) * color;
// }
//
// SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
// {
// uv = stage_input.uv;
// color = stage_input.color;
// frag_main();
// SPIRV_Cross_Output stage_output;
// stage_output.frag_color = frag_color;
// return stage_output;
// }
//
const fs_source_hlsl4 = [665]u8 {
0x54,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x44,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x3e,0x20,0x74,0x65,0x78,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,
0x28,0x74,0x30,0x29,0x3b,0x0a,0x53,0x61,0x6d,0x70,0x6c,0x65,0x72,0x53,0x74,0x61,
0x74,0x65,0x20,0x5f,0x74,0x65,0x78,0x5f,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,
0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x73,0x30,0x29,0x3b,0x0a,
0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,
0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,
0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x3b,0x0a,0x73,0x74,0x61,
0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,
0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,
0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,
0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,
0x4f,0x4f,0x52,0x44,0x31,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,
0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,
0x74,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,0x53,
0x56,0x5f,0x54,0x61,0x72,0x67,0x65,0x74,0x30,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,
0x6c,0x69,0x6e,0x65,0x20,0x31,0x33,0x20,0x22,0x74,0x65,0x78,0x63,0x75,0x62,0x65,
0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x76,0x6f,0x69,0x64,0x20,0x66,0x72,0x61,0x67,
0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,
0x31,0x33,0x20,0x22,0x74,0x65,0x78,0x63,0x75,0x62,0x65,0x2e,0x67,0x6c,0x73,0x6c,
0x22,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,
0x20,0x3d,0x20,0x74,0x65,0x78,0x2e,0x53,0x61,0x6d,0x70,0x6c,0x65,0x28,0x5f,0x74,
0x65,0x78,0x5f,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x2c,0x20,0x75,0x76,0x29,0x20,
0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,
0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x6d,
0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,
0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,
0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x73,0x74,
0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x75,0x76,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,
0x69,0x6e,0x70,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,
0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,
0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,
0x70,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,
0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,
0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x00,
};
//
// #include <metal_stdlib>
// #include <simd/simd.h>
//
// using namespace metal;
//
// struct vs_params
// {
// float4x4 mvp;
// };
//
// struct main0_out
// {
// float4 color [[user(locn0)]];
// float2 uv [[user(locn1)]];
// float4 gl_Position [[position]];
// };
//
// struct main0_in
// {
// float4 pos [[attribute(0)]];
// float4 color0 [[attribute(1)]];
// float2 texcoord0 [[attribute(2)]];
// };
//
// #line 18 "texcube.glsl"
// vertex main0_out main0(main0_in in [[stage_in]], constant vs_params& _21 [[buffer(0)]])
// {
// main0_out out = {};
// #line 18 "texcube.glsl"
// out.gl_Position = _21.mvp * in.pos;
// #line 19 "texcube.glsl"
// out.color = in.color0;
// #line 20 "texcube.glsl"
// out.uv = in.texcoord0 * 5.0;
// return out;
// }
//
//
const vs_source_metal_macos = [698]u8 {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x76,
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x6d,0x76,0x70,0x3b,0x0a,0x7d,0x3b,0x0a,
0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,
0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,
0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,
0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,
0x20,0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,
0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,
0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,
0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x70,0x6f,0x73,0x20,0x5b,
0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,
0x72,0x30,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,
0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,
0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,
0x69,0x62,0x75,0x74,0x65,0x28,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,
0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x38,0x20,0x22,0x74,0x65,0x78,0x63,0x75,0x62,
0x65,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,
0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,
0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,
0x74,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x32,0x31,
0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,
0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,
0x31,0x38,0x20,0x22,0x74,0x65,0x78,0x63,0x75,0x62,0x65,0x2e,0x67,0x6c,0x73,0x6c,
0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,
0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x32,0x31,0x2e,0x6d,0x76,0x70,0x20,
0x2a,0x20,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,
0x31,0x39,0x20,0x22,0x74,0x65,0x78,0x63,0x75,0x62,0x65,0x2e,0x67,0x6c,0x73,0x6c,
0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x20,
0x3d,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x23,0x6c,0x69,
0x6e,0x65,0x20,0x32,0x30,0x20,0x22,0x74,0x65,0x78,0x63,0x75,0x62,0x65,0x2e,0x67,
0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x75,0x76,0x20,
0x3d,0x20,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x20,0x2a,
0x20,0x35,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,
0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
//
// #include <metal_stdlib>
// #include <simd/simd.h>
//
// using namespace metal;
//
// struct main0_out
// {
// float4 frag_color [[color(0)]];
// };
//
// struct main0_in
// {
// float4 color [[user(locn0)]];
// float2 uv [[user(locn1)]];
// };
//
// #line 13 "texcube.glsl"
// fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> tex [[texture(0)]], sampler texSmplr [[sampler(0)]])
// {
// main0_out out = {};
// #line 13 "texcube.glsl"
// out.frag_color = tex.sample(texSmplr, in.uv) * in.color;
// return out;
// }
//
//
const fs_source_metal_macos = [494]u8 {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,
0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,
0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,
0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x32,0x20,0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,
0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,
0x31,0x33,0x20,0x22,0x74,0x65,0x78,0x63,0x75,0x62,0x65,0x2e,0x67,0x6c,0x73,0x6c,
0x22,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,
0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,
0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,
0x6e,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,
0x6c,0x6f,0x61,0x74,0x3e,0x20,0x74,0x65,0x78,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,
0x75,0x72,0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,
0x72,0x20,0x74,0x65,0x78,0x53,0x6d,0x70,0x6c,0x72,0x20,0x5b,0x5b,0x73,0x61,0x6d,
0x70,0x6c,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,
0x20,0x7b,0x7d,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x33,0x20,0x22,0x74,
0x65,0x78,0x63,0x75,0x62,0x65,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,
0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,
0x3d,0x20,0x74,0x65,0x78,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x74,0x65,0x78,
0x53,0x6d,0x70,0x6c,0x72,0x2c,0x20,0x69,0x6e,0x2e,0x75,0x76,0x29,0x20,0x2a,0x20,
0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,
0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
pub fn shaderDesc(backend: sg.Backend) sg.ShaderDesc {
var desc: sg.ShaderDesc = .{};
switch (backend) {
.GLCORE33 => {
desc.attrs[0].name = "pos";
desc.attrs[1].name = "color0";
desc.attrs[2].name = "texcoord0";
desc.vs.source = &vs_source_glsl330;
desc.vs.entry = "main";
desc.vs.uniform_blocks[0].size = 64;
desc.vs.uniform_blocks[0].uniforms[0].name = "vs_params";
desc.vs.uniform_blocks[0].uniforms[0].type = .FLOAT4;
desc.vs.uniform_blocks[0].uniforms[0].array_count = 4;
desc.fs.source = &fs_source_glsl330;
desc.fs.entry = "main";
desc.fs.images[0].name = "tex";
desc.fs.images[0].type = ._2D;
desc.fs.images[0].sampler_type = .FLOAT;
desc.label = "texcube_shader";
},
.D3D11 => {
desc.attrs[0].sem_name = "TEXCOORD";
desc.attrs[0].sem_index = 0;
desc.attrs[1].sem_name = "TEXCOORD";
desc.attrs[1].sem_index = 1;
desc.attrs[2].sem_name = "TEXCOORD";
desc.attrs[2].sem_index = 2;
desc.vs.source = &vs_source_hlsl4;
desc.vs.d3d11_target = "vs_4_0";
desc.vs.entry = "main";
desc.vs.uniform_blocks[0].size = 64;
desc.fs.source = &fs_source_hlsl4;
desc.fs.d3d11_target = "ps_4_0";
desc.fs.entry = "main";
desc.fs.images[0].name = "tex";
desc.fs.images[0].type = ._2D;
desc.fs.images[0].sampler_type = .FLOAT;
desc.label = "texcube_shader";
},
.METAL_MACOS => {
desc.vs.source = &vs_source_metal_macos;
desc.vs.entry = "main0";
desc.vs.uniform_blocks[0].size = 64;
desc.fs.source = &fs_source_metal_macos;
desc.fs.entry = "main0";
desc.fs.images[0].name = "tex";
desc.fs.images[0].type = ._2D;
desc.fs.images[0].sampler_type = .FLOAT;
desc.label = "texcube_shader";
},
else => {},
}
return desc;
} | src/shaders/mainshader.zig |
const blz = @import("blz.zig");
const common = @import("common.zig");
const fun = @import("fun");
const overlay = @import("overlay.zig");
const std = @import("std");
const debug = std.debug;
const generic = fun.generic;
const heap = std.heap;
const io = std.io;
const mem = std.mem;
const os = std.os;
const lu16 = fun.platform.lu16;
const lu32 = fun.platform.lu32;
pub const fs = @import("fs.zig");
pub const Banner = @import("banner.zig").Banner;
pub const Header = @import("header.zig").Header;
pub const Overlay = overlay.Overlay;
test "nds" {
_ = @import("banner.zig");
_ = @import("blz.zig");
_ = @import("common.zig");
_ = @import("formats.zig");
_ = @import("fs.zig");
_ = @import("header.zig");
_ = @import("overlay.zig");
_ = @import("test.zig");
}
pub const Rom = struct {
allocator: *mem.Allocator,
// TODO: Do we actually want to store the header?
// Info like offsets, the user of the lib shouldn't touch, but other info, are allowed.
// Instead of storing the header. Only store info relevant for customization, and let
// the writeToFile function generate the offsets
// Or maybe the user of the lib should be able to set the offsets manually. Maybe they want
// to have the rom change as little as possible so they can share small patches.
header: Header,
banner: Banner,
arm9: []u8,
arm7: []u8,
// After arm9, there is 12 bytes that might be a nitro footer. If the first
// 4 bytes are == 0xDEC00621, then it's a nitro_footer.
// NOTE: This information was deduced from reading the source code for
// ndstool and EveryFileExplore. http://problemkaputt.de/gbatek.htm does
// not seem to have this information anywhere.
nitro_footer: [3]lu32,
arm9_overlay_table: []Overlay,
arm9_overlay_files: [][]u8,
arm7_overlay_table: []Overlay,
arm7_overlay_files: [][]u8,
root: *fs.Nitro,
pub fn fromFile(file: std.fs.File, allocator: *mem.Allocator) !Rom {
var file_stream = file.inStream();
var stream = &file_stream.stream;
const header = try stream.readStruct(Header);
try header.validate();
const arm9 = blk: {
try file.seekTo(header.arm9_rom_offset.value());
const raw = try allocator.alloc(u8, header.arm9_size.value());
errdefer allocator.free(raw);
try stream.readNoEof(raw);
if (blz.decode(raw, allocator)) |decoded| {
allocator.free(raw);
break :blk decoded;
} else |_| {
// If blz.decode failes, we assume that the arm9 is not encoded and just use the raw data
break :blk raw;
}
};
errdefer allocator.free(arm9);
const nitro_footer = blk: {
var res: [3]lu32 = undefined;
try stream.readNoEof(@sliceToBytes(res[0..]));
break :blk res;
};
try file.seekTo(header.arm7_rom_offset.value());
const arm7 = try allocator.alloc(u8, header.arm7_size.value());
errdefer allocator.free(arm7);
try stream.readNoEof(arm7);
// TODO: On dsi, this can be of different sizes
try file.seekTo(header.banner_offset.value());
const banner = try stream.readStruct(Banner);
try banner.validate();
if (header.fat_size.value() % @sizeOf(fs.FatEntry) != 0)
return error.InvalidFatSize;
try file.seekTo(header.fnt_offset.value());
const fnt = try allocator.alloc(u8, header.fnt_size.value());
errdefer allocator.free(fnt);
try stream.readNoEof(fnt);
try file.seekTo(header.fat_offset.value());
const fat = try allocator.alloc(fs.FatEntry, header.fat_size.value() / @sizeOf(fs.FatEntry));
errdefer allocator.free(fat);
try stream.readNoEof(@sliceToBytes(fat));
const root = try fs.readNitro(file, allocator, fnt, fat);
errdefer root.destroy();
try file.seekTo(header.arm9_overlay_offset.value());
const arm9_overlay_table = try allocator.alloc(Overlay, header.arm9_overlay_size.value() / @sizeOf(Overlay));
errdefer allocator.free(arm9_overlay_table);
try stream.readNoEof(@sliceToBytes(arm9_overlay_table));
const arm9_overlay_files = try overlay.readFiles(file, allocator, arm9_overlay_table, fat);
errdefer overlay.freeFiles(arm9_overlay_files, allocator);
try file.seekTo(header.arm7_overlay_offset.value());
const arm7_overlay_table = try allocator.alloc(Overlay, header.arm7_overlay_size.value() / @sizeOf(Overlay));
errdefer allocator.free(arm7_overlay_table);
try stream.readNoEof(@sliceToBytes(arm7_overlay_table));
const arm7_overlay_files = try overlay.readFiles(file, allocator, arm7_overlay_table, fat);
errdefer overlay.freeFiles(arm7_overlay_files, allocator);
return Rom{
.allocator = allocator,
.header = header,
.banner = banner,
.arm9 = arm9,
.arm7 = arm7,
.nitro_footer = nitro_footer,
.arm9_overlay_table = arm9_overlay_table,
.arm9_overlay_files = arm9_overlay_files,
.arm7_overlay_table = arm7_overlay_table,
.arm7_overlay_files = arm7_overlay_files,
.root = root,
};
}
pub fn writeToFile(rom: Rom, file: std.fs.File) !void {
var arena = heap.ArenaAllocator.init(rom.allocator);
defer arena.deinit();
const allocator = &arena.allocator;
var header = rom.header;
const arm9_pos = 0x4000;
try file.seekTo(arm9_pos);
// TODO: There might be times when people want/need to encode the arm9 again when saving,
// so we should probably give them the option to do so.
// Maybe encoding and decoding, is something that should be done outside the loading/saving
// of roms. Hmmm :thinking:
try file.write(rom.arm9);
if (rom.hasNitroFooter()) {
try file.write(@sliceToBytes(rom.nitro_footer[0..]));
}
header.arm9_rom_offset = lu32.init(@intCast(u32, arm9_pos));
header.arm9_size = lu32.init(@intCast(u32, rom.arm9.len));
const arm7_pos = blk: {
var res = try file.getPos();
if (res < 0x8000) {
try file.seekTo(0x8000);
res = 0x8000;
}
break :blk res;
};
try file.write(rom.arm7);
header.arm7_rom_offset = lu32.init(@intCast(u32, arm7_pos));
header.arm7_size = lu32.init(@intCast(u32, rom.arm7.len));
const banner_pos = try file.getPos();
try file.write(mem.toBytes(rom.banner));
header.banner_offset = lu32.init(@intCast(u32, banner_pos));
header.banner_size = lu32.init(@sizeOf(Banner));
const fntAndFiles = try fs.getFntAndFiles(fs.Nitro, rom.root, allocator);
const files = fntAndFiles.files;
const main_fnt = fntAndFiles.main_fnt;
const sub_fnt = fntAndFiles.sub_fnt;
const fnt_pos = try file.getPos();
try file.write(@sliceToBytes(main_fnt));
try file.write(sub_fnt);
header.fnt_offset = lu32.init(@intCast(u32, fnt_pos));
header.fnt_size = lu32.init(@intCast(u32, main_fnt.len * @sizeOf(fs.FntMainEntry) + sub_fnt.len));
var fat = std.ArrayList(fs.FatEntry).init(allocator);
try fat.ensureCapacity(files.len + rom.arm9_overlay_files.len + rom.arm7_overlay_files.len);
for (files) |f| {
const pos = @intCast(u32, try file.getPos());
try fs.writeNitroFile(file, allocator, f.*);
fat.append(fs.FatEntry.init(pos, @intCast(u32, try file.getPos()) - pos)) catch unreachable;
}
for (rom.arm9_overlay_files) |f, i| {
const pos = @intCast(u32, try file.getPos());
try file.write(f);
fat.append(fs.FatEntry.init(pos, @intCast(u32, try file.getPos()) - pos)) catch unreachable;
const table_entry = &rom.arm9_overlay_table[i];
table_entry.overlay_id = lu32.init(@intCast(u32, i));
table_entry.file_id = lu32.init(@intCast(u32, files.len + i));
}
for (rom.arm7_overlay_files) |f, i| {
const pos = @intCast(u32, try file.getPos());
try file.write(f);
fat.append(fs.FatEntry.init(pos, @intCast(u32, try file.getPos()) - pos)) catch unreachable;
const table_entry = &rom.arm7_overlay_table[i];
table_entry.overlay_id = lu32.init(@intCast(u32, i));
table_entry.file_id = lu32.init(@intCast(u32, rom.arm9_overlay_files.len + files.len + i));
}
const fat_pos = try file.getPos();
try file.write(@sliceToBytes(fat.toSliceConst()));
header.fat_offset = lu32.init(@intCast(u32, fat_pos));
header.fat_size = lu32.init(@intCast(u32, (files.len + rom.arm9_overlay_table.len + rom.arm7_overlay_table.len) * @sizeOf(fs.FatEntry)));
const arm9_overlay_pos = try file.getPos();
try file.write(@sliceToBytes(rom.arm9_overlay_table));
header.arm9_overlay_offset = lu32.init(@intCast(u32, arm9_overlay_pos));
header.arm9_overlay_size = lu32.init(@intCast(u32, rom.arm9_overlay_table.len * @sizeOf(Overlay)));
const arm7_overlay_pos = try file.getPos();
try file.write(@sliceToBytes(rom.arm7_overlay_table));
header.arm7_overlay_offset = lu32.init(@intCast(u32, arm7_overlay_pos));
header.arm7_overlay_size = lu32.init(@intCast(u32, rom.arm7_overlay_table.len * @sizeOf(Overlay)));
header.total_used_rom_size = lu32.init(common.@"align"(@intCast(u32, try file.getPos()), u32(4)));
header.device_capacity = blk: {
// Devicecapacity (Chipsize = 128KB SHL nn) (eg. 7 = 16MB)
const size = header.total_used_rom_size.value();
var device_cap: u6 = 0;
while (@shlExact(u64(128000), device_cap) < size) : (device_cap += 1) {}
break :blk device_cap;
};
header.header_checksum = lu16.init(header.calcChecksum());
try header.validate();
try file.seekTo(0x00);
try file.write(mem.toBytes(header));
}
pub fn hasNitroFooter(rom: Rom) bool {
return rom.nitro_footer[0].value() == 0xDEC00621;
}
pub fn deinit(rom: *Rom) void {
rom.allocator.free(rom.arm9);
rom.allocator.free(rom.arm7);
rom.allocator.free(rom.arm9_overlay_table);
rom.allocator.free(rom.arm7_overlay_table);
overlay.freeFiles(rom.arm9_overlay_files, rom.allocator);
overlay.freeFiles(rom.arm7_overlay_files, rom.allocator);
rom.root.destroy();
rom.* = undefined;
}
}; | src/index.zig |
const std = @import("std");
const debug = std.debug;
const assert = debug.assert;
const uefi = std.os.uefi;
const Allocator = std.mem.Allocator;
const ThisAllocator = @This();
// Pre-boot allocator in UEFI environment
var systemAllocatorState = Allocator{
.allocFn = alloc,
.resizeFn = resize,
};
pub const systemAllocator = &systemAllocatorState;
const ALLOCATION_HEADER_COOKIE = 0x3b064be8fe2dc;
const AllocationHeader = struct { cookie: u64, size: usize, base: [*]align(8) u8 };
// This function assumes that we have not exited boot services, otherwise KVM internal error or UEFI system reset will kick in.
fn alloc(allocator: *Allocator, n: usize, ptrAlign: u29, lenAlign: u29, ra: usize) error{OutOfMemory}![]u8 {
assert(n > 0);
const bootServices = uefi.system_table.boot_services.?;
const MemoryType = uefi.tables.MemoryType;
const Success = uefi.Status.Success;
var ptr: [*]align(8) u8 = undefined;
const adjustedSize = n + ptrAlign + @sizeOf(AllocationHeader);
const result = bootServices.allocatePool(MemoryType.LoaderData, adjustedSize, &ptr);
if (result != Success) {
return error.OutOfMemory;
}
const adjustedPtr = std.mem.alignForward(@ptrToInt(ptr) + @sizeOf(AllocationHeader), ptrAlign);
const allocHeaderPtr = @intToPtr(*AllocationHeader, adjustedPtr - @sizeOf(AllocationHeader));
allocHeaderPtr.cookie = ALLOCATION_HEADER_COOKIE;
allocHeaderPtr.base = ptr;
allocHeaderPtr.size = adjustedSize;
return @intToPtr([*]u8, adjustedPtr)[0..n];
}
fn resize(
allocator: *Allocator,
buf: []u8,
bufAlign: u29,
newSize: usize,
lenAlign: u29,
returnAddress: usize,
) Allocator.Error!usize {
// TODO: implement resizing.
if (newSize != 0) {
return error.OutOfMemory;
}
const allocHeaderPtr = @intToPtr(*AllocationHeader, @ptrToInt(buf.ptr) - @sizeOf(AllocationHeader));
if (allocHeaderPtr.cookie != ALLOCATION_HEADER_COOKIE) {
// This is the sign of memory stomping.
return error.OutOfMemory;
}
const freedSize = allocHeaderPtr.size;
_ = uefi.system_table.boot_services.?.freePool(allocHeaderPtr.base);
return freedSize;
} | src/kernel/uefi/allocator.zig |
const std = @import("std");
const testing = std.testing;
const Allocator = std.mem.Allocator;
// Use Edwards25519 at the moment, since bandersnatch is currently
// unavailable, and Edwards is the only curve available in zig, that
// both supports addition and serializes to 32 bytes.
const curve = std.crypto.ecc.Edwards25519;
const Slot = [32]u8;
const Key = [32]u8;
const Stem = [31]u8;
const Hash = [32]u8;
fn generateInsecure(comptime n: usize) ![n]curve {
var r: [n]curve = undefined;
var i: usize = 0;
var v: [32]u8 = undefined;
while (i < n) : (i += 1) {
std.mem.writeIntSliceBig(usize, v[0..], i + 2);
r[i] = try curve.mul(curve.basePoint, v);
}
return r;
}
const LastLevelNode = struct {
values: [256]?*Slot,
key: Stem,
fn computeSuffixNodeCommitment(srs: [256]curve, values: []const ?*Slot) !Hash {
var multiplier = [_]u8{0} ** 32;
var i: usize = 0;
var ret = curve.identityElement;
while (i < values.len) : (i += 1) {
if (values[i] != null) {
std.mem.copy(u8, multiplier[16..], values[i].?[0..16]);
multiplier[15] = 1; // set the leaf marker
ret = curve.add(ret, try curve.mul(srs[2 * i], multiplier));
multiplier[15] = 0; // clear the leaf marker
// Multiplying by 0 will give the identity element, and
// the Edwards25519 won't allow this result. Since it's
// a no-op anyway, skip it.
for (multiplier[16..]) |v| {
if (v != 0) {
std.mem.copy(u8, multiplier[16..], values[i].?[16..]);
ret = curve.add(ret, try curve.mul(srs[2 * i + 1], multiplier));
}
}
}
}
return ret.toBytes();
}
fn isZero(stem: []const u8) bool {
for (stem) |v| {
if (v != 0)
return false;
}
return true;
}
fn computeCommitment(self: *const LastLevelNode) !Hash {
// TODO find a way to generate this at compile/startup
// time, without running into the 1000 backwards branches
// issue.
const srs = try generateInsecure(256);
const c1 = try computeSuffixNodeCommitment(srs, self.values[0..128]);
const c2 = try computeSuffixNodeCommitment(srs, self.values[128..]);
var stem = [_]u8{0} ** 32;
std.mem.copy(u8, stem[1..], self.key[0..]);
var res = curve.add(try curve.mul(srs[2], c2), try curve.mul(srs[3], c2));
res = curve.add(res, srs[0]);
if (!isZero(stem[0..])) {
res = curve.add(res, try curve.mul(srs[1], stem));
}
return res.toBytes();
}
};
const BranchNode = struct {
children: [256]Node,
depth: u8,
count: u8,
fn computeCommitment(self: *const BranchNode) !Hash {
// TODO find a way to generate this at compile/startup
// time, without running into the 1000 backwards branches
// issue.
const srs = try generateInsecure(256);
var res = curve.identityElement;
for (self.children) |child, i| {
if (child != .empty) {
res = curve.add(res, try curve.mul(srs[i], try child.commitment()));
}
}
return res.toBytes();
}
};
fn newll(key: Key, value: *Slot, allocator: *Allocator) !*LastLevelNode {
const slot = key[31];
var ll = try allocator.create(LastLevelNode);
ll.values = [_]?*Slot{null} ** 256;
ll.key = [_]u8{0} ** 31;
std.mem.copy(u8, ll.key[0..], key[0..31]);
ll.values[slot] = try allocator.create(Slot);
std.mem.copy(u8, ll.values[slot].?[0..], value[0..]);
return ll;
}
const Node = union(enum) {
last_level: *LastLevelNode,
branch: *BranchNode,
hash: Hash,
empty: struct {},
fn new() @This() {
return @This(){ .empty = .{} };
}
fn insert(self: *Node, key: Key, value: *Slot, allocator: *Allocator) !void {
return self.insert_with_depth(key, value, allocator, 0);
}
fn insert_with_depth(self: *Node, key: Key, value: *Slot, allocator: *Allocator, depth: u8) !void {
return switch (self.*) {
.empty => {
self.* = @unionInit(Node, "last_level", try newll(key, value, allocator));
},
.hash => error.InsertIntoHash,
.last_level => |ll| {
// Check if the stems are the same, if so, then just place the value
// in the corresponding slot, as the final extension tree has been
// reached.
const diffidx = std.mem.indexOfDiff(u8, ll.key[0..], key[0..31]);
if (diffidx == null) {
ll.values[key[31]] = try allocator.create(Slot);
std.mem.copy(u8, ll.values[key[31]].?[0..], value[0..]);
return;
}
var br = try allocator.create(BranchNode);
br.children = [_]Node{Node{ .empty = .{} }} ** 256;
br.depth = depth;
br.count = 2;
br.children[ll.key[br.depth]] = Node{ .last_level = ll };
self.* = @unionInit(Node, "branch", br);
// Recurse into the child, if this is empty then it will be turned
// into a last_level node in the recursing .empty case, and if the
// next byte in the key are the same, it will recurse into another
// .last_level case, potentially doing so over the whole stem.
return br.children[key[br.depth]].insert_with_depth(key, value, allocator, depth + 1);
},
.branch => |br| br.children[key[br.depth]].insert(key, value, allocator),
};
}
fn tear_down(self: *Node, allocator: *Allocator) void {
switch (self.*) {
.empty => {},
.last_level => |ll| {
for (ll.values) |v| {
if (v != null) {
allocator.free(v.?);
}
}
allocator.destroy(ll);
},
.branch => |br| {
for (br.children) |_, i| {
br.children[i].tear_down(allocator);
}
allocator.destroy(br);
},
.hash => {},
}
}
fn commitment(self: *const Node) !Hash {
return switch (self.*) {
.empty => [_]u8{0} ** 32,
.hash => |h| h,
.last_level => |ll| ll.computeCommitment(),
.branch => |br| br.computeCommitment(),
};
}
};
test "inserting into hash raises an error" {
var root_ = Node{ .hash = [_]u8{0} ** 32 };
var root: *Node = &root_;
var value = [_]u8{0} ** 32;
try testing.expectError(error.InsertIntoHash, root.insert([_]u8{0} ** 32, &value, testing.allocator));
}
test "insert into empty tree" {
var root_ = Node.new();
var root: *Node = &root_;
var value = [_]u8{0} ** 32;
try root.insert([_]u8{0} ** 32, &value, testing.allocator);
defer root.tear_down(testing.allocator);
switch (root.*) {
Node.last_level => |ll| {
for (ll.values) |v, i| {
if (i == 0) {
try testing.expect(v != null);
} else {
try testing.expect(v == null);
}
}
},
else => return error.InvalidNodeType,
}
}
test "insert into a last_level node, difference in suffix" {
var root_ = Node.new();
var root = &root_;
var value = [_]u8{0} ** 32;
try root.insert([_]u8{0} ** 32, &value, testing.allocator);
try root.insert([_]u8{0} ** 31 ++ [1]u8{1}, &value, testing.allocator);
defer root.tear_down(testing.allocator);
switch (root.*) {
Node.last_level => |ll| {
for (ll.values) |v, i| {
if (i < 2) {
try testing.expect(v != null);
} else {
try testing.expect(v == null);
}
}
},
else => return error.InvalidNodeType,
}
}
test "insert into a last_level node, difference in stem" {
var root_ = Node.new();
var root = &root_;
var value = [_]u8{0} ** 32;
try root.insert([_]u8{0} ** 32, &value, testing.allocator);
try root.insert([1]u8{1} ++ [_]u8{0} ** 31, &value, testing.allocator);
defer root.tear_down(testing.allocator);
switch (root.*) {
Node.branch => |br| {
for (br.children) |child, i| {
switch (child) {
Node.last_level => |ll| {
try testing.expect(i < 2);
for (ll.values) |v, j| {
if (j == 0) {
try testing.expect(v != null);
} else {
try testing.expect(v == null);
}
}
},
Node.empty => try testing.expect(i >= 2),
else => return error.InvalidNodeType,
}
}
},
else => return error.InvalidNodeType,
}
}
test "insert into a last_level node, difference in last byte of stem" {
var root_ = Node.new();
var root = &root_;
var value = [_]u8{0} ** 32;
try root.insert([_]u8{0} ** 32, &value, testing.allocator);
try root.insert([_]u8{0} ** 30 ++ [2]u8{ 1, 0 }, &value, testing.allocator);
defer root.tear_down(testing.allocator);
var br: *BranchNode = root.branch;
while (true) {
if (br.depth < 30) {
for (br.children) |child, i| {
if (i == 0) try testing.expect(child == .branch) else try testing.expect(child == .empty);
}
br = br.children[0].branch;
} else if (br.depth == 30) {
for (br.children) |child, i| {
if (i < 2) try testing.expect(child == .last_level) else try testing.expect(child == .empty);
}
break;
} else {
try testing.expect(false);
}
}
}
test "insert into a branch node" {
var root_ = Node.new();
var root = &root_;
var value = [_]u8{0} ** 32;
try root.insert([_]u8{0} ** 32, &value, testing.allocator);
try root.insert([1]u8{1} ++ [_]u8{0} ** 31, &value, testing.allocator);
defer root.tear_down(testing.allocator);
var br: *BranchNode = root.branch;
try testing.expect(br.children[0] == .last_level);
try testing.expect(br.children[1] == .last_level);
var i: usize = 2;
while (i < 256) : (i += 1) {
try testing.expect(br.children[i] == .empty);
}
}
test "compute root commitment of a last_level node" {
var root_ = Node.new();
var root = &root_;
var value = [_]u8{0} ** 32;
try root.insert([_]u8{1} ** 32, &value, testing.allocator);
defer root.tear_down(testing.allocator);
_ = try root.commitment();
}
test "compute root commitment of a last_level node, with 0 key" {
var root_ = Node.new();
var root = &root_;
var value = [_]u8{0} ** 32;
try root.insert([_]u8{0} ** 32, &value, testing.allocator);
defer root.tear_down(testing.allocator);
_ = try root.commitment();
}
test "compute root commitment of a branch node" {
var root_ = Node.new();
var root = &root_;
var value = [_]u8{0} ** 32;
try root.insert([_]u8{0} ** 32, &value, testing.allocator);
try root.insert([_]u8{1} ** 32, &value, testing.allocator);
defer root.tear_down(testing.allocator);
_ = try root.commitment();
} | src/main.zig |
const std = @import("std");
const os = std.os;
const ptrace = @import("ptrace.zig");
pub const WaitResult = struct {
pid: os.pid_t,
status: Status,
};
pub const Status = union(enum) {
exit: u32,
kill: u32,
stop: Signal,
ptrace: PtraceSignal,
};
// Signal delivered on syscalls.
// Would otherwise be a regular SIGTRAP if the caller does not set PTRACE_O_TRACESYSGOOD.
// It is important that users of the "events.zig" code ensure that option has been set.
// The "events.zig" code will only be treating SIGTRAP and PTRACE_SIGTRAP differently.
const PTRACE_SIGTRAP = os.SIGTRAP | 0x80;
const Signal = extern enum {
hup = os.SIGHUP,
int = os.SIGINT,
quit = os.SIGQUIT,
ill = os.SIGILL,
trap = os.SIGTRAP,
abrt = os.SIGABRT,
iot = os.SIGIOT,
bus = os.SIGBUS,
fpe = os.SIGFPE,
kill = os.SIGKILL,
usr1 = os.SIGUSR1,
segv = os.SIGSEGV,
usr2 = os.SIGUSR2,
pipe = os.SIGPIPE,
alrm = os.SIGALRM,
term = os.SIGTERM,
stkflt = os.SIGSTKFLT,
chld = os.SIGCHLD,
cont = os.SIGCONT,
stop = os.SIGSTOP,
tstp = os.SIGTSTP,
ttin = os.SIGTTIN,
ttou = os.SIGTTOU,
urg = os.SIGURG,
xcpu = os.SIGXCPU,
xfsz = os.SIGXFSZ,
vtalrm = os.SIGVTALRM,
prof = os.SIGPROF,
winch = os.SIGWINCH,
io = os.SIGIO,
poll = os.SIGPOLL,
pwr = os.SIGPWR,
sys = os.SIGSYS,
unused = os.SIGUNUSED,
};
const PTRACE_TRAP = os.SIGTRAP | 0x80;
const PtraceSignal = enum {
// ptrace events
e_clone,
e_exec,
e_exit,
e_fork,
e_vfork,
e_vfork_done,
e_seccomp,
// Trap only applies when PTRACE_O_TRACESYSGOOD flag has been set.
// Otherwise, wait result will return a normal SIGTRAP result.
syscall_trap,
pub fn fromWstatus(wstatus: u32) ?PtraceSignal {
if (@intCast(c_int, os.WSTOPSIG(wstatus)) == PTRACE_TRAP) return PtraceSignal.syscall_trap;
return switch (wstatus >> 8) {
(os.SIGTRAP | (@enumToInt(ptrace.Event.clone) << 8)) => PtraceSignal.e_clone,
(os.SIGTRAP | (@enumToInt(ptrace.Event.exec) << 8)) => PtraceSignal.e_exec,
(os.SIGTRAP | (@enumToInt(ptrace.Event.exit) << 8)) => PtraceSignal.e_exit,
(os.SIGTRAP | (@enumToInt(ptrace.Event.fork) << 8)) => PtraceSignal.e_fork,
(os.SIGTRAP | (@enumToInt(ptrace.Event.vfork) << 8)) => PtraceSignal.e_vfork,
(os.SIGTRAP | (@enumToInt(ptrace.Event.vfork_done) << 8)) => PtraceSignal.e_vfork_done,
(os.SIGTRAP | (@enumToInt(ptrace.Event.seccomp) << 8)) => PtraceSignal.e_seccomp,
else => null,
};
}
};
pub fn waitpid(pid: os.pid_t, flags: u32) !WaitResult {
var status: u32 = 0;
const pid_from_wait = os.linux.waitpid(pid, &status, flags);
const err = os.errno(status);
if (status == -1) {
switch (err) {
os.ESRCH => return error.NoSuchProcess,
else => {
std.debug.warn("Error number \"{}\"; ", .{err});
std.debug.warn("Unknown error\n", .{});
return error.UnknownWaitPidError;
},
}
}
return WaitResult{ .pid = @intCast(os.pid_t, pid_from_wait), .status = try interpret_status(status) };
}
// Using this because os.WIFSTOPPED resulted in @intCast truncation errors
// Function taken from /usr/include/x86_64-linux-gnu/bits/waitstatus.h
pub fn WIFSTOPPED(wstatus: u32) bool {
return (wstatus & 0xff) == 0x7f;
}
pub fn interpret_status(wstatus: u32) !Status {
if (os.WIFEXITED(wstatus)) {
return Status{ .exit = os.WEXITSTATUS(wstatus) };
} else if (os.WIFSIGNALED(wstatus)) {
return Status{ .kill = os.WTERMSIG(wstatus) };
} else if (WIFSTOPPED(wstatus)) {
if (PtraceSignal.fromWstatus(wstatus)) |psignal| {
return Status{ .ptrace = psignal };
}
const signal = @intToEnum(Signal, @intCast(c_int, os.WSTOPSIG(wstatus)));
return Status{ .stop = signal };
}
@panic("Unrecognized status. 'interpret_status' fn not finished.");
// return error.UnrecognizedStatus;
// os.WIFCONTINUED does not exist in x86_64-linux zig std library. We will try ignoring it for now.
} | src/waitpid.zig |
const std = @import("std");
const t = std.testing;
const BitArrayList = @import("bit_array_list.zig").BitArrayList;
const log = std.log.scoped(.compact);
/// Useful for keeping elements closer together in memory when you're using a bunch of insert/delete,
/// while keeping realloc to a minimum and preserving the element's initial insert index.
/// Backed by std.ArrayList.
/// Item ids are reused once removed.
/// Items are assigned an id and have O(1) access time by id.
/// TODO: Iterating can be just as fast as a dense array if CompactIdGenerator kept a sorted list of freed id ranges.
/// Although that also means delete ops would need to be O(logn).
pub fn CompactUnorderedList(comptime Id: type, comptime T: type) type {
if (@typeInfo(Id).Int.signedness != .unsigned) {
@compileError("Unsigned id type required.");
}
return struct {
id_gen: CompactIdGenerator(Id),
// TODO: Rename to buf.
data: std.ArrayList(T),
// Keep track of whether an item exists at id in order to perform iteration.
// TODO: Rename to exists.
// TODO: Maybe the user should provide this if it's important. It would also simplify the api and remove optional return types. It also means iteration won't be possible.
data_exists: BitArrayList,
const Self = @This();
const Iterator = struct {
// The current id should reflect the id of the value returned from next or nextPtr.
cur_id: Id,
list: *const Self,
fn init(list: *const Self) @This() {
return .{
.cur_id = std.math.maxInt(Id),
.list = list,
};
}
pub fn reset(self: *@This()) void {
self.idx = std.math.maxInt(Id);
}
pub fn nextPtr(self: *@This()) ?*T {
self.cur_id +%= 1;
while (true) {
if (self.cur_id < self.list.data.items.len) {
if (!self.list.data_exists.isSet(self.cur_id)) {
self.cur_id += 1;
continue;
} else {
return &self.list.data.items[self.cur_id];
}
} else {
return null;
}
}
}
pub fn next(self: *@This()) ?T {
self.cur_id +%= 1;
while (true) {
if (self.cur_id < self.list.data.items.len) {
if (!self.list.data_exists.isSet(self.cur_id)) {
self.cur_id += 1;
continue;
} else {
return self.list.data.items[self.cur_id];
}
} else {
return null;
}
}
}
};
pub fn init(alloc: std.mem.Allocator) @This() {
const new = @This(){
.id_gen = CompactIdGenerator(Id).init(alloc, 0),
.data = std.ArrayList(T).init(alloc),
.data_exists = BitArrayList.init(alloc),
};
return new;
}
pub fn deinit(self: Self) void {
self.id_gen.deinit();
self.data.deinit();
self.data_exists.deinit();
}
pub fn iterator(self: *const Self) Iterator {
return Iterator.init(self);
}
// Returns the id of the item.
pub fn add(self: *Self, item: T) !Id {
const new_id = self.id_gen.getNextId();
errdefer self.id_gen.deleteId(new_id);
if (new_id >= self.data.items.len) {
try self.data.resize(new_id + 1);
try self.data_exists.resize(new_id + 1);
}
self.data.items[new_id] = item;
self.data_exists.set(new_id);
return new_id;
}
pub fn set(self: *Self, id: Id, item: T) void {
self.data.items[id] = item;
}
pub fn remove(self: *Self, id: Id) void {
self.data_exists.unset(id);
self.id_gen.deleteId(id);
}
pub fn clearRetainingCapacity(self: *Self) void {
self.data_exists.clearRetainingCapacity();
self.id_gen.clearRetainingCapacity();
self.data.clearRetainingCapacity();
}
pub fn get(self: Self, id: Id) ?T {
if (self.has(id)) {
return self.data.items[id];
} else return null;
}
pub fn getNoCheck(self: Self, id: Id) T {
return self.data.items[id];
}
pub fn getPtr(self: *const Self, id: Id) ?*T {
if (self.has(id)) {
return &self.data.items[id];
} else return null;
}
pub fn getPtrNoCheck(self: Self, id: Id) *T {
return &self.data.items[id];
}
pub fn has(self: Self, id: Id) bool {
return self.data_exists.isSet(id);
}
pub fn size(self: Self) usize {
return self.data.items.len - self.id_gen.next_ids.count;
}
};
}
test "CompactUnorderedList" {
{
// General test.
var arr = CompactUnorderedList(u32, u8).init(t.allocator);
defer arr.deinit();
_ = try arr.add(1);
const id = try arr.add(2);
_ = try arr.add(3);
arr.remove(id);
// Test adding to a removed slot.
_ = try arr.add(4);
const id2 = try arr.add(5);
// Test iterator skips removed slot.
arr.remove(id2);
var iter = arr.iterator();
try t.expectEqual(iter.next(), 1);
try t.expectEqual(iter.next(), 4);
try t.expectEqual(iter.next(), 3);
try t.expectEqual(iter.next(), null);
try t.expectEqual(arr.size(), 3);
}
{
// Empty test.
var arr = CompactUnorderedList(u32, u8).init(t.allocator);
defer arr.deinit();
var iter = arr.iterator();
try t.expectEqual(iter.next(), null);
try t.expectEqual(arr.size(), 0);
}
}
/// Buffer is a CompactUnorderedList.
pub fn CompactSinglyLinkedList(comptime Id: type, comptime T: type) type {
const Null = CompactNull(Id);
const Node = CompactSinglyLinkedListNode(Id, T);
return struct {
const Self = @This();
first: Id,
nodes: CompactUnorderedList(Id, Node),
pub fn init(alloc: std.mem.Allocator) Self {
return .{
.first = Null,
.nodes = CompactUnorderedList(Id, Node).init(alloc),
};
}
pub fn deinit(self: Self) void {
self.nodes.deinit();
}
pub fn insertAfter(self: *Self, id: Id, data: T) !Id {
if (self.nodes.has(id)) {
const new = try self.nodes.add(.{
.next = self.nodes.getNoCheck(id).next,
.data = data,
});
self.nodes.getPtrNoCheck(id).next = new;
return new;
} else return error.NoElement;
}
pub fn removeNext(self: *Self, id: Id) !bool {
if (self.nodes.has(id)) {
const at = self.nodes.getPtrNoCheck(id);
if (at.next != Null) {
const next = at.next;
at.next = self.nodes.getNoCheck(next).next;
self.nodes.remove(next);
return true;
} else return false;
} else return error.NoElement;
}
pub fn getNode(self: *const Self, id: Id) ?Node {
return self.nodes.get(id);
}
pub fn getNodeAssumeExists(self: *const Self, id: Id) Node {
return self.nodes.getNoCheck(id);
}
pub fn get(self: *const Self, id: Id) ?T {
if (self.nodes.has(id)) {
return self.nodes.getNoCheck(id).data;
} else return null;
}
pub fn getNoCheck(self: *const Self, id: Id) T {
return self.nodes.getNoCheck(id).data;
}
pub fn getAt(self: *const Self, idx: usize) Id {
var i: u32 = 0;
var cur = self.first.?;
while (i != idx) : (i += 1) {
cur = self.getNext(cur).?;
}
return cur;
}
pub fn getFirst(self: *const Self) Id {
return self.first;
}
pub fn getNext(self: Self, id: Id) ?Id {
if (self.nodes.has(id)) {
return self.nodes.getNoCheck(id).next;
} else return null;
}
pub fn prepend(self: *Self, data: T) !Id {
const node = Node{
.next = self.first,
.data = data,
};
self.first = try self.nodes.add(node);
return self.first;
}
pub fn removeFirst(self: *Self) bool {
if (self.first != Null) {
const next = self.getNodeAssumeExists(self.first).next;
self.nodes.remove(self.first);
self.first = next;
return true;
} else return false;
}
};
}
test "CompactSinglyLinkedList" {
const Null = CompactNull(u32);
{
// General test.
var list = CompactSinglyLinkedList(u32, u8).init(t.allocator);
defer list.deinit();
const first = try list.prepend(1);
var last = first;
last = try list.insertAfter(last, 2);
last = try list.insertAfter(last, 3);
// Test remove next.
_ = try list.removeNext(first);
// Test remove first.
_ = list.removeFirst();
var id = list.getFirst();
try t.expectEqual(list.get(id), 3);
id = list.getNext(id).?;
try t.expectEqual(id, Null);
}
{
// Empty test.
var list = CompactSinglyLinkedList(u32, u8).init(t.allocator);
defer list.deinit();
try t.expectEqual(list.getFirst(), Null);
}
}
/// Id should be an unsigned integer type.
/// Max value of Id is used to indicate null. (An optional would increase the struct size.)
pub fn CompactSinglyLinkedListNode(comptime Id: type, comptime T: type) type {
return struct {
next: Id,
data: T,
};
}
pub fn CompactNull(comptime Id: type) Id {
return comptime std.math.maxInt(Id);
}
/// Stores multiple linked lists together in memory.
pub fn CompactManySinglyLinkedList(comptime ListId: type, comptime Index: type, comptime T: type) type {
const Node = CompactSinglyLinkedListNode(Index, T);
const Null = CompactNull(Index);
return struct {
const Self = @This();
const List = struct {
head: ?Index,
};
nodes: CompactUnorderedList(Index, Node),
lists: CompactUnorderedList(ListId, List),
pub fn init(alloc: std.mem.Allocator) Self {
return .{
.nodes = CompactUnorderedList(Index, Node).init(alloc),
.lists = CompactUnorderedList(ListId, List).init(alloc),
};
}
pub fn deinit(self: Self) void {
self.nodes.deinit();
self.lists.deinit();
}
// Returns detached item.
pub fn detachAfter(self: *Self, id: Index) !Index {
if (self.nodes.has(id)) {
const item = self.getNodePtrAssumeExists(id);
const detached = item.next;
item.next = Null;
return detached;
} else return error.NoElement;
}
pub fn insertAfter(self: *Self, id: Index, data: T) !Index {
if (self.nodes.has(id)) {
const new = try self.nodes.add(.{
.next = self.nodes.getNoCheck(id).next,
.data = data,
});
self.nodes.getPtrNoCheck(id).next = new;
return new;
} else return error.NoElement;
}
pub fn setDetachedToEnd(self: *Self, id: Index, detached_id: Index) void {
const item = self.nodes.getPtr(id).?;
item.next = detached_id;
}
pub fn addListWithDetachedHead(self: *Self, id: Index) !ListId {
return self.lists.add(.{ .head = id });
}
pub fn addListWithHead(self: *Self, data: T) !ListId {
const item_id = try self.addDetachedItem(data);
return self.addListWithDetachedHead(item_id);
}
pub fn addEmptyList(self: *Self) !ListId {
return self.lists.add(.{ .head = Null });
}
pub fn addDetachedItem(self: *Self, data: T) !Index {
return try self.nodes.add(.{
.next = Null,
.data = data,
});
}
pub fn prepend(self: *Self, list_id: ListId, data: T) !Index {
const list = self.getList(list_id);
const item = Node{
.next = list.first,
.data = data,
};
list.first = try self.nodes.add(item);
return list.first.?;
}
pub fn removeFirst(self: *Self, list_id: ListId) bool {
const list = self.getList(list_id);
if (list.first == null) {
return false;
} else {
const next = self.getNext(list.first.?);
self.nodes.remove(list.first.?);
list.first = next;
return true;
}
}
pub fn removeNext(self: *Self, id: Index) !bool {
if (self.nodes.has(id)) {
const at = self.nodes.getPtrNoCheck(id);
if (at.next != Null) {
const next = at.next;
at.next = self.nodes.getNoCheck(next).next;
self.nodes.remove(next);
return true;
} else return false;
} else return error.NoElement;
}
pub fn removeDetached(self: *Self, id: Index) void {
self.nodes.remove(id);
}
pub fn getListPtr(self: *const Self, id: ListId) *List {
return self.lists.getPtr(id);
}
pub fn getListHead(self: *const Self, id: ListId) ?Index {
if (self.lists.has(id)) {
return self.lists.getNoCheck(id).head;
} else return null;
}
pub fn findInList(self: Self, list_id: ListId, ctx: anytype, pred: fn (ctx: @TypeOf(ctx), buf: Self, item_id: Index) bool) ?Index {
var id = self.getListHead(list_id) orelse return null;
while (id != Null) {
if (pred(ctx, self, id)) {
return id;
}
id = self.getNextIdNoCheck(id);
}
return null;
}
pub fn has(self: Self, id: Index) bool {
return self.nodes.has(id);
}
pub fn getNode(self: Self, id: Index) ?Node {
return self.nodes.get(id);
}
pub fn getNodeAssumeExists(self: Self, id: Index) Node {
return self.nodes.getNoCheck(id);
}
pub fn getNodePtr(self: Self, id: Index) ?*Node {
return self.nodes.getPtr(id);
}
pub fn getNodePtrAssumeExists(self: Self, id: Index) *Node {
return self.nodes.getPtrNoCheck(id);
}
pub fn get(self: Self, id: Index) ?T {
if (self.nodes.has(id)) {
return self.nodes.getNoCheck(id).data;
} else return null;
}
pub fn getNoCheck(self: Self, id: Index) T {
return self.nodes.getNoCheck(id).data;
}
pub fn getIdAt(self: Self, list_id: ListId, idx: usize) Index {
var i: u32 = 0;
var cur: Index = self.getListHead(list_id).?;
while (i != idx) : (i += 1) {
cur = self.getNextId(cur).?;
}
return cur;
}
pub fn getPtr(self: Self, id: Index) ?*T {
if (self.nodes.has(id)) {
return &self.nodes.getPtrNoCheck(id).data;
} else return null;
}
pub fn getPtrNoCheck(self: Self, id: Index) *T {
return &self.nodes.getPtrNoCheck(id).data;
}
pub fn getNextId(self: Self, id: Index) ?Index {
if (self.nodes.get(id)) |node| {
return node.next;
} else return null;
}
pub fn getNextIdNoCheck(self: Self, id: Index) Index {
return self.nodes.getNoCheck(id).next;
}
pub fn getNextNode(self: Self, id: Index) ?Node {
if (self.getNext(id)) |next| {
return self.getNode(next);
} else return null;
}
pub fn getNextData(self: *const Self, id: Index) ?T {
if (self.getNext(id)) |next| {
return self.get(next);
} else return null;
}
};
}
test "CompactManySinglyLinkedList" {
const Null = CompactNull(u32);
var lists = CompactManySinglyLinkedList(u32, u32, u32).init(t.allocator);
defer lists.deinit();
const list_id = try lists.addListWithHead(10);
const head = lists.getListHead(list_id).?;
// Test detachAfter.
const after = try lists.insertAfter(head, 20);
try t.expectEqual(lists.getNextIdNoCheck(head), after);
try t.expectEqual(lists.detachAfter(head), after);
try t.expectEqual(lists.getNextIdNoCheck(head), Null);
}
/// Reuses deleted ids.
/// Uses a fifo id buffer to get the next id if not empty, otherwise it uses the next id counter.
pub fn CompactIdGenerator(comptime T: type) type {
return struct {
const Self = @This();
start_id: T,
next_default_id: T,
next_ids: std.fifo.LinearFifo(T, .Dynamic),
pub fn init(alloc: std.mem.Allocator, start_id: T) Self {
return .{
.start_id = start_id,
.next_default_id = start_id,
.next_ids = std.fifo.LinearFifo(T, .Dynamic).init(alloc),
};
}
pub fn peekNextId(self: Self) T {
if (self.next_ids.readableLength() == 0) {
return self.next_default_id;
} else {
return self.next_ids.peekItem(0);
}
}
pub fn getNextId(self: *Self) T {
if (self.next_ids.readableLength() == 0) {
defer self.next_default_id += 1;
return self.next_default_id;
} else {
return self.next_ids.readItem().?;
}
}
pub fn clearRetainingCapacity(self: *Self) void {
self.next_default_id = self.start_id;
self.next_ids.head = 0;
self.next_ids.count = 0;
}
pub fn deleteId(self: *Self, id: T) void {
self.next_ids.writeItem(id) catch unreachable;
}
pub fn deinit(self: Self) void {
self.next_ids.deinit();
}
};
}
test "CompactIdGenerator" {
var gen = CompactIdGenerator(u16).init(t.allocator, 1);
defer gen.deinit();
try t.expectEqual(gen.getNextId(), 1);
try t.expectEqual(gen.getNextId(), 2);
gen.deleteId(1);
try t.expectEqual(gen.getNextId(), 1);
try t.expectEqual(gen.getNextId(), 3);
}
/// Holds linked lists in a compact buffer. Does not keep track of list heads.
/// This might replace CompactManySinglyLinkedList.
pub fn CompactSinglyLinkedListBuffer(comptime Id: type, comptime T: type) type {
const Null = comptime CompactNull(Id);
const OptId = Id;
return struct {
const Self = @This();
pub const Node = CompactSinglyLinkedListNode(Id, T);
nodes: CompactUnorderedList(Id, Node),
pub fn init(alloc: std.mem.Allocator) Self {
return .{
.nodes = CompactUnorderedList(Id, Node).init(alloc),
};
}
pub fn deinit(self: Self) void {
self.nodes.deinit();
}
pub fn clearRetainingCapacity(self: *Self) void {
self.nodes.clearRetainingCapacity();
}
pub fn getNode(self: Self, idx: Id) ?Node {
return self.nodes.get(idx);
}
pub fn getNodeNoCheck(self: Self, idx: Id) Node {
return self.nodes.getNoCheck(idx);
}
pub fn getNodePtrNoCheck(self: Self, idx: Id) *Node {
return self.nodes.getPtrNoCheck(idx);
}
pub fn iterator(self: Self) CompactUnorderedList(Id, Node).Iterator {
return self.nodes.iterator();
}
pub fn iterFirstNoCheck(self: Self) Id {
var iter = self.nodes.iterator();
_ = iter.next();
return iter.cur_id;
}
pub fn iterFirstValueNoCheck(self: Self) T {
var iter = self.nodes.iterator();
return iter.next().?.data;
}
pub fn size(self: Self) usize {
return self.nodes.size();
}
pub fn getLast(self: Self, id: Id) ?Id {
if (id == Null) {
return null;
}
if (self.nodes.has(id)) {
var cur = id;
while (cur != Null) {
const next = self.getNextNoCheck(cur);
if (next == Null) {
return cur;
}
cur = next;
}
unreachable;
} else return null;
}
pub fn get(self: Self, id: Id) ?T {
if (self.nodes.has(id)) {
return self.nodes.getNoCheck(id).data;
} else return null;
}
pub fn getNoCheck(self: Self, idx: Id) T {
return self.nodes.getNoCheck(idx).data;
}
pub fn getPtrNoCheck(self: Self, idx: Id) *T {
return &self.nodes.getPtrNoCheck(idx).data;
}
pub fn getNextNoCheck(self: Self, id: Id) OptId {
return self.nodes.getNoCheck(id).next;
}
pub fn getNext(self: Self, id: Id) ?OptId {
if (self.nodes.has(id)) {
return self.nodes.getNoCheck(id).next;
} else return null;
}
/// Adds a new head node.
pub fn add(self: *Self, data: T) !Id {
return try self.nodes.add(.{
.next = Null,
.data = data,
});
}
pub fn insertBeforeHead(self: *Self, head_id: Id, data: T) !Id {
if (self.nodes.has(head_id)) {
return try self.nodes.add(.{
.next = head_id,
.data = data,
});
} else return error.NoElement;
}
pub fn insertBeforeHeadNoCheck(self: *Self, head_id: Id, data: T) !Id {
return try self.nodes.add(.{
.next = head_id,
.data = data,
});
}
pub fn insertAfter(self: *Self, id: Id, data: T) !Id {
if (self.nodes.has(id)) {
const new = try self.nodes.add(.{
.next = self.nodes.getNoCheck(id).next,
.data = data,
});
self.nodes.getPtrNoCheck(id).next = new;
return new;
} else return error.NoElement;
}
pub fn removeAfter(self: *Self, id: Id) !void {
if (self.nodes.has(id)) {
const next = self.getNextNoCheck(id);
if (next != Null) {
const next_next = self.getNextNoCheck(next);
self.nodes.getNoCheck(id).next = next_next;
self.nodes.remove(next);
}
} else return error.NoElement;
}
pub fn removeAssumeNoPrev(self: *Self, id: Id) !void {
if (self.nodes.has(id)) {
self.nodes.remove(id);
} else return error.NoElement;
}
};
}
test "CompactSinglyLinkedListBuffer" {
var buf = CompactSinglyLinkedListBuffer(u32, u32).init(t.allocator);
defer buf.deinit();
const head = try buf.add(1);
try t.expectEqual(buf.get(head).?, 1);
try t.expectEqual(buf.getNoCheck(head), 1);
try t.expectEqual(buf.getNode(head).?.data, 1);
try t.expectEqual(buf.getNodeNoCheck(head).data, 1);
const second = try buf.insertAfter(head, 2);
try t.expectEqual(buf.getNodeNoCheck(head).next, second);
try t.expectEqual(buf.getNoCheck(second), 2);
try buf.removeAssumeNoPrev(head);
try t.expectEqual(buf.get(head), null);
} | examples/gkurve/data_structures/compact.zig |
const std = @import("std");
const c = @import("c");
pub const Direction = enum(u3) {
invalid = c.HB_DIRECTION_INVALID,
ltr = c.HB_DIRECTION_LTR,
rtl = c.HB_DIRECTION_RTL,
ttb = c.HB_DIRECTION_TTB,
bit = c.HB_DIRECTION_BTT,
pub fn fromString(str: []const u8) Direction {
return @intToEnum(Direction, c.hb_direction_from_string(str.ptr, @intCast(c_int, str.len)));
}
pub fn toString(self: Direction) [:0]const u8 {
return std.mem.span(c.hb_direction_to_string(@enumToInt(self)));
}
};
pub const Script = enum(u31) {
common = c.HB_SCRIPT_COMMON,
inherited = c.HB_SCRIPT_INHERITED,
unknown = c.HB_SCRIPT_UNKNOWN,
arabic = c.HB_SCRIPT_ARABIC,
armenian = c.HB_SCRIPT_ARMENIAN,
bengali = c.HB_SCRIPT_BENGALI,
cyrillic = c.HB_SCRIPT_CYRILLIC,
devanagari = c.HB_SCRIPT_DEVANAGARI,
georgian = c.HB_SCRIPT_GEORGIAN,
greek = c.HB_SCRIPT_GREEK,
gujarati = c.HB_SCRIPT_GUJARATI,
gurmukhi = c.HB_SCRIPT_GURMUKHI,
hangul = c.HB_SCRIPT_HANGUL,
han = c.HB_SCRIPT_HAN,
hebrew = c.HB_SCRIPT_HEBREW,
hiragana = c.HB_SCRIPT_HIRAGANA,
kannada = c.HB_SCRIPT_KANNADA,
katakana = c.HB_SCRIPT_KATAKANA,
lao = c.HB_SCRIPT_LAO,
latin = c.HB_SCRIPT_LATIN,
malayalam = c.HB_SCRIPT_MALAYALAM,
oriya = c.HB_SCRIPT_ORIYA,
tamil = c.HB_SCRIPT_TAMIL,
telugu = c.HB_SCRIPT_TELUGU,
thai = c.HB_SCRIPT_THAI,
tibetan = c.HB_SCRIPT_TIBETAN,
bopomofo = c.HB_SCRIPT_BOPOMOFO,
braille = c.HB_SCRIPT_BRAILLE,
canadian_syllabics = c.HB_SCRIPT_CANADIAN_SYLLABICS,
cherokee = c.HB_SCRIPT_CHEROKEE,
ethiopic = c.HB_SCRIPT_ETHIOPIC,
khmer = c.HB_SCRIPT_KHMER,
mongolian = c.HB_SCRIPT_MONGOLIAN,
myanmar = c.HB_SCRIPT_MYANMAR,
ogham = c.HB_SCRIPT_OGHAM,
runic = c.HB_SCRIPT_RUNIC,
sinhala = c.HB_SCRIPT_SINHALA,
syriac = c.HB_SCRIPT_SYRIAC,
thaana = c.HB_SCRIPT_THAANA,
yi = c.HB_SCRIPT_YI,
deseret = c.HB_SCRIPT_DESERET,
gothic = c.HB_SCRIPT_GOTHIC,
old_italic = c.HB_SCRIPT_OLD_ITALIC,
buhid = c.HB_SCRIPT_BUHID,
hanunoo = c.HB_SCRIPT_HANUNOO,
tagalog = c.HB_SCRIPT_TAGALOG,
tagbanwa = c.HB_SCRIPT_TAGBANWA,
cypriot = c.HB_SCRIPT_CYPRIOT,
limbu = c.HB_SCRIPT_LIMBU,
linear_b = c.HB_SCRIPT_LINEAR_B,
osmanya = c.HB_SCRIPT_OSMANYA,
shavian = c.HB_SCRIPT_SHAVIAN,
tai_le = c.HB_SCRIPT_TAI_LE,
ugaritic = c.HB_SCRIPT_UGARITIC,
buginese = c.HB_SCRIPT_BUGINESE,
coptic = c.HB_SCRIPT_COPTIC,
glagolitic = c.HB_SCRIPT_GLAGOLITIC,
kharoshthi = c.HB_SCRIPT_KHAROSHTHI,
new_tai_lue = c.HB_SCRIPT_NEW_TAI_LUE,
old_persian = c.HB_SCRIPT_OLD_PERSIAN,
syloti_nagri = c.HB_SCRIPT_SYLOTI_NAGRI,
tifinagh = c.HB_SCRIPT_TIFINAGH,
balinese = c.HB_SCRIPT_BALINESE,
cuneiform = c.HB_SCRIPT_CUNEIFORM,
nko = c.HB_SCRIPT_NKO,
phags_pa = c.HB_SCRIPT_PHAGS_PA,
phoenician = c.HB_SCRIPT_PHOENICIAN,
carian = c.HB_SCRIPT_CARIAN,
cham = c.HB_SCRIPT_CHAM,
kayah_li = c.HB_SCRIPT_KAYAH_LI,
lepcha = c.HB_SCRIPT_LEPCHA,
lycian = c.HB_SCRIPT_LYCIAN,
lydian = c.HB_SCRIPT_LYDIAN,
ol_chiki = c.HB_SCRIPT_OL_CHIKI,
rejang = c.HB_SCRIPT_REJANG,
saurashtra = c.HB_SCRIPT_SAURASHTRA,
sundanese = c.HB_SCRIPT_SUNDANESE,
vai = c.HB_SCRIPT_VAI,
avestan = c.HB_SCRIPT_AVESTAN,
bamum = c.HB_SCRIPT_BAMUM,
egyptian_hieroglyphs = c.HB_SCRIPT_EGYPTIAN_HIEROGLYPHS,
imperial_aramaic = c.HB_SCRIPT_IMPERIAL_ARAMAIC,
inscriptional_pahlavi = c.HB_SCRIPT_INSCRIPTIONAL_PAHLAVI,
inscriptional_parthian = c.HB_SCRIPT_INSCRIPTIONAL_PARTHIAN,
javanese = c.HB_SCRIPT_JAVANESE,
kaithi = c.HB_SCRIPT_KAITHI,
lisu = c.HB_SCRIPT_LISU,
meetei_mayek = c.HB_SCRIPT_MEETEI_MAYEK,
old_south_arabian = c.HB_SCRIPT_OLD_SOUTH_ARABIAN,
old_turkic = c.HB_SCRIPT_OLD_TURKIC,
samaritan = c.HB_SCRIPT_SAMARITAN,
tai_tham = c.HB_SCRIPT_TAI_THAM,
tai_viet = c.HB_SCRIPT_TAI_VIET,
batak = c.HB_SCRIPT_BATAK,
brahmi = c.HB_SCRIPT_BRAHMI,
mandaic = c.HB_SCRIPT_MANDAIC,
chakma = c.HB_SCRIPT_CHAKMA,
meroitic_cursive = c.HB_SCRIPT_MEROITIC_CURSIVE,
meroitic_hieroglyphs = c.HB_SCRIPT_MEROITIC_HIEROGLYPHS,
miao = c.HB_SCRIPT_MIAO,
sharada = c.HB_SCRIPT_SHARADA,
sora_sompeng = c.HB_SCRIPT_SORA_SOMPENG,
takri = c.HB_SCRIPT_TAKRI,
bassa_vah = c.HB_SCRIPT_BASSA_VAH,
caucasian_albanian = c.HB_SCRIPT_CAUCASIAN_ALBANIAN,
duployan = c.HB_SCRIPT_DUPLOYAN,
elbasan = c.HB_SCRIPT_ELBASAN,
grantha = c.HB_SCRIPT_GRANTHA,
khojki = c.HB_SCRIPT_KHOJKI,
khudawadi = c.HB_SCRIPT_KHUDAWADI,
linear_a = c.HB_SCRIPT_LINEAR_A,
mahajani = c.HB_SCRIPT_MAHAJANI,
manichaean = c.HB_SCRIPT_MANICHAEAN,
mende_kikakui = c.HB_SCRIPT_MENDE_KIKAKUI,
modi = c.HB_SCRIPT_MODI,
mro = c.HB_SCRIPT_MRO,
nabataean = c.HB_SCRIPT_NABATAEAN,
old_north_arabian = c.HB_SCRIPT_OLD_NORTH_ARABIAN,
old_permic = c.HB_SCRIPT_OLD_PERMIC,
pahawh_hmong = c.HB_SCRIPT_PAHAWH_HMONG,
palmyrene = c.HB_SCRIPT_PALMYRENE,
pau_cin_hau = c.HB_SCRIPT_PAU_CIN_HAU,
psalter_pahlavi = c.HB_SCRIPT_PSALTER_PAHLAVI,
siddham = c.HB_SCRIPT_SIDDHAM,
tirhuta = c.HB_SCRIPT_TIRHUTA,
warang_citi = c.HB_SCRIPT_WARANG_CITI,
ahom = c.HB_SCRIPT_AHOM,
anatolian_hieroglyphs = c.HB_SCRIPT_ANATOLIAN_HIEROGLYPHS,
hatran = c.HB_SCRIPT_HATRAN,
multani = c.HB_SCRIPT_MULTANI,
old_hungarian = c.HB_SCRIPT_OLD_HUNGARIAN,
signwriting = c.HB_SCRIPT_SIGNWRITING,
adlam = c.HB_SCRIPT_ADLAM,
bhaiksuki = c.HB_SCRIPT_BHAIKSUKI,
marchen = c.HB_SCRIPT_MARCHEN,
osage = c.HB_SCRIPT_OSAGE,
tangut = c.HB_SCRIPT_TANGUT,
newa = c.HB_SCRIPT_NEWA,
masaram_gondi = c.HB_SCRIPT_MASARAM_GONDI,
nushu = c.HB_SCRIPT_NUSHU,
soyombo = c.HB_SCRIPT_SOYOMBO,
zanabazar_square = c.HB_SCRIPT_ZANABAZAR_SQUARE,
dogra = c.HB_SCRIPT_DOGRA,
gunjala_gondi = c.HB_SCRIPT_GUNJALA_GONDI,
hanifi_rohingya = c.HB_SCRIPT_HANIFI_ROHINGYA,
makasar = c.HB_SCRIPT_MAKASAR,
medefaidrin = c.HB_SCRIPT_MEDEFAIDRIN,
old_sogdian = c.HB_SCRIPT_OLD_SOGDIAN,
sogdian = c.HB_SCRIPT_SOGDIAN,
elymaic = c.HB_SCRIPT_ELYMAIC,
nandinagari = c.HB_SCRIPT_NANDINAGARI,
nyiakeng_puachue_hmong = c.HB_SCRIPT_NYIAKENG_PUACHUE_HMONG,
wancho = c.HB_SCRIPT_WANCHO,
chorasmian = c.HB_SCRIPT_CHORASMIAN,
dives_akuru = c.HB_SCRIPT_DIVES_AKURU,
khitan_small_script = c.HB_SCRIPT_KHITAN_SMALL_SCRIPT,
yezidi = c.HB_SCRIPT_YEZIDI,
cypro_minoan = c.HB_SCRIPT_CYPRO_MINOAN,
old_uyghur = c.HB_SCRIPT_OLD_UYGHUR,
tangsa = c.HB_SCRIPT_TANGSA,
toto = c.HB_SCRIPT_TOTO,
vithkuqi = c.HB_SCRIPT_VITHKUQI,
math = c.HB_SCRIPT_MATH,
invalid = c.HB_SCRIPT_INVALID,
pub fn fromISO15924Tag(tag: Tag) Script {
return @intToEnum(Script, c.hb_script_from_iso15924_tag(tag.handle));
}
pub fn fromString(str: []const u8) Script {
return @intToEnum(Script, c.hb_script_from_string(str.ptr, @intCast(c_int, str.len)));
}
pub fn toISO15924Tag(self: Script) Tag {
return .{ .handle = c.hb_script_to_iso15924_tag(@enumToInt(self)) };
}
pub fn getHorizontalDirection(self: Script) Direction {
return @intToEnum(Direction, c.hb_script_get_horizontal_direction(@enumToInt(self)));
}
};
pub const Language = struct {
handle: c.hb_language_t,
pub fn fromString(name: []const u8) Language {
return .{
.handle = c.hb_language_from_string(name.ptr, @intCast(c_int, name.len)),
};
}
pub fn toString(self: Language) [:0]const u8 {
return std.mem.span(c.hb_language_to_string(self.handle));
}
pub fn getDefault() Language {
return .{ .handle = c.hb_language_get_default() };
}
};
pub const Feature = extern struct {
tag: c.hb_tag_t,
value: u32,
start: c_uint,
end: c_uint,
pub fn fromString(str: []const u8) ?Feature {
var f: Feature = undefined;
return if (hb_feature_from_string(str.ptr, @intCast(c_int, str.len), &f) > 1)
f
else
null;
}
pub fn toString(self: *Feature, buf: []u8) void {
hb_feature_to_string(self, buf.ptr, @intCast(c_uint, buf.len));
}
};
pub const Variation = extern struct {
tag: u32,
value: f32,
pub fn fromString(str: []const u8) ?Variation {
var v: Variation = undefined;
return if (hb_variation_from_string(str.ptr, @intCast(c_int, str.len), &v) > 1)
v
else
null;
}
pub fn toString(self: *Variation, buf: []u8) void {
hb_variation_to_string(self, buf.ptr, @intCast(c_uint, buf.len));
}
pub fn tag(self: Variation) Tag {
return .{ .handle = self.tag };
}
pub fn value(self: Variation) f32 {
return self.value;
}
};
pub const Tag = struct {
handle: u32,
pub fn fromString(str: []const u8) Tag {
return .{ .handle = c.hb_tag_from_string(str.ptr, @intCast(c_int, str.len)) };
}
pub fn toString(self: Tag) []const u8 {
var str: [4]u8 = undefined;
c.hb_tag_to_string(self.handle, &str[0]);
return &str;
}
};
pub extern fn hb_feature_from_string(str: [*c]const u8, len: c_int, feature: [*c]Feature) u8;
pub extern fn hb_feature_to_string(feature: [*c]Feature, buf: [*c]u8, size: c_uint) void;
pub extern fn hb_variation_from_string(str: [*c]const u8, len: c_int, variation: [*c]Variation) u8;
pub extern fn hb_variation_to_string(variation: [*c]Variation, buf: [*c]u8, size: c_uint) void; | freetype/src/harfbuzz/common.zig |
const std = @import("std");
const Arena = std.heap.ArenaAllocator;
const expect = std.testing.expect;
const expectEqual = std.testing.expectEqual;
const expectEqualStrings = std.testing.expectEqualStrings;
const yeti = @import("yeti");
const Component = yeti.ecs.Component;
const ECS = yeti.ecs.ECS;
const IteratorComponents = yeti.ecs.IteratorComponents;
const typeid = yeti.ecs.typeid;
const Name = struct {
value: []const u8,
};
const Age = struct {
value: u8,
};
const Job = struct {
value: []const u8,
};
test "construct type" {
const components = .{ Name, Age };
const Components = IteratorComponents(components);
const type_info = @typeInfo(Components).Struct;
try expectEqual(type_info.layout, .Auto);
const fields = type_info.fields;
try expectEqual(fields.len, 2);
const names = fields[0];
try expectEqualStrings(names.name, "Name");
try expectEqual(names.field_type, *Component(Name));
try expectEqual(names.default_value, null);
try expectEqual(names.is_comptime, false);
try expectEqual(names.alignment, 8);
try expectEqual(type_info.decls.len, 0);
try expectEqual(type_info.is_tuple, false);
const ages = fields[1];
try expectEqualStrings(ages.name, "Age");
try expectEqual(ages.field_type, *Component(Age));
try expectEqual(ages.default_value, null);
try expectEqual(ages.is_comptime, false);
try expectEqual(ages.alignment, 8);
try expectEqual(type_info.decls.len, 0);
try expectEqual(type_info.is_tuple, false);
}
test "entity get and set component" {
var arena = Arena.init(std.heap.page_allocator);
defer arena.deinit();
var ecs = ECS.init(&arena);
const entity = try ecs.createEntity(.{});
_ = try entity.set(.{Name{ .value = "Joe" }});
try expectEqual(entity.get(Name), Name{ .value = "Joe" });
_ = try entity.set(.{Name{ .value = "Bob" }});
try expectEqual(entity.get(Name), Name{ .value = "Bob" });
}
test "entity get and set components" {
var arena = Arena.init(std.heap.page_allocator);
defer arena.deinit();
var ecs = ECS.init(&arena);
const entity = try ecs.createEntity(.{});
_ = try entity.set(.{ Name{ .value = "Joe" }, Age{ .value = 20 } });
try expectEqual(entity.get(Name), Name{ .value = "Joe" });
try expectEqual(entity.get(Age), Age{ .value = 20 });
}
test "entity get and set components on creation" {
var arena = Arena.init(std.heap.page_allocator);
defer arena.deinit();
var ecs = ECS.init(&arena);
const entity = try ecs.createEntity(.{ Name{ .value = "Joe" }, Age{ .value = 20 } });
try expectEqual(entity.get(Name), Name{ .value = "Joe" });
try expectEqual(entity.get(Age), Age{ .value = 20 });
}
test "ecs get and set components" {
var arena = Arena.init(std.heap.page_allocator);
defer arena.deinit();
var ecs = ECS.init(&arena);
try ecs.set(.{ Name{ .value = "Joe" }, Age{ .value = 20 } });
try expectEqual(ecs.get(Name), Name{ .value = "Joe" });
try expectEqual(ecs.get(Age), Age{ .value = 20 });
}
test "ecs query entities with components" {
var arena = Arena.init(std.heap.page_allocator);
defer arena.deinit();
var ecs = ECS.init(&arena);
const joe = try ecs.createEntity(.{ Name{ .value = "Joe" }, Age{ .value = 20 } });
const bob = try ecs.createEntity(.{Name{ .value = "Bob" }});
const sally = try ecs.createEntity(.{ Name{ .value = "Sally" }, Age{ .value = 24 } });
{
var iterator = ecs.query(.{ Name, Age });
try expectEqual(iterator.next(), joe);
try expectEqual(iterator.next(), sally);
try expectEqual(iterator.next(), null);
}
{
var iterator = ecs.query(.{Name});
try expectEqual(iterator.next(), joe);
try expectEqual(iterator.next(), bob);
try expectEqual(iterator.next(), sally);
try expectEqual(iterator.next(), null);
}
}
test "type id" {
const Foo = struct {
const Baz = struct {
x: f64,
};
baz: Baz,
};
const Bar = struct {
const Baz = struct {
y: f64,
};
baz: Baz,
};
const foo_baz = typeid(Foo.Baz);
const bar_baz = typeid(Bar.Baz);
try expect(foo_baz != bar_baz);
} | src/tests/test_ecs.zig |
const std = @import("std");
const mem = std.mem;
const common = @import("common.zig");
const Ondemand = @import("ondemand.zig");
const println = common.println;
const print = common.print;
const llvm = @import("llvm_intrinsics.zig");
depth: u8 = 0,
const Logger = @This();
pub const MAX_DEPTH = 30;
const LOG_EVENT_LEN = 20;
const LOG_BUFFER_LEN = 30;
const LOG_SMALL_BUFFER_LEN = 10;
const LOG_INDEX_LEN = 5;
fn pad_with(comptime s: []const u8, comptime pad_byte: u8, comptime len: u8) [len]u8 {
var buf = [1]u8{pad_byte} ** len;
buf[0..s.len].* = s[0..s.len].*;
return buf;
}
fn pad_with_alloc(s: []const u8, pad_byte: u8, len: u8, allocator: mem.Allocator) []const u8 {
var buf = allocator.alloc(u8, len) catch return s;
std.mem.set(u8, buf, pad_byte);
std.mem.copy(u8, buf, s[0..std.math.min(s.len, buf.len)]);
return buf;
}
pub fn start(log: *Logger, iter: anytype) void {
_ = iter;
if (common.debug) {
log.depth = 0;
const event_txt = pad_with("Event", ' ', LOG_EVENT_LEN);
const buffer_txt = pad_with("Buffer", ' ', LOG_BUFFER_LEN);
const next_txt = pad_with("Next", ' ', LOG_SMALL_BUFFER_LEN);
println("", .{});
println("| {s} | {s} | {s} | Next# | Detail |", .{ event_txt, buffer_txt, next_txt });
println("|{s}|{s}|{s}|-------|--------|", .{
pad_with("", '-', LOG_EVENT_LEN + 2),
pad_with("", '-', LOG_BUFFER_LEN + 2),
pad_with("", '-', LOG_SMALL_BUFFER_LEN + 2),
});
}
}
fn printable_char(c: u8) u8 {
return if (c >= 0x20 and c < 128) c else ' ';
}
pub fn line_fmt(log: *Logger, iter: anytype, title_prefix: []const u8, title: []const u8, comptime detail_fmt: []const u8, detail_args: anytype) void {
var buf: [0x100]u8 = undefined;
log.line(iter, title_prefix, title, std.fmt.bufPrint(&buf, detail_fmt, detail_args) catch return);
}
pub fn line(log: *Logger, iter: anytype, title_prefix: []const u8, title: []const u8, detail: []const u8) void {
if (iter.depth >= Logger.MAX_DEPTH) return;
var log_buf: [0x100]u8 = undefined;
var log_buf2: [LOG_BUFFER_LEN]u8 = undefined;
if (!common.debug) return;
var log_fba = std.heap.FixedBufferAllocator.init(&log_buf);
const depth_padding = pad_with_alloc("", ' ', @intCast(u8, if (log.depth < 0x0f) log.depth * 2 else 0xff), log_fba.allocator());
const titles = std.fmt.allocPrint(
log_fba.allocator(),
"{s}{s}{s}",
.{ depth_padding, title_prefix, title },
) catch return;
const p1 = pad_with_alloc(titles, ' ', LOG_EVENT_LEN, log_fba.allocator());
print("| {s} ", .{p1});
const current_index = if (iter.at_beginning()) null else iter.next_structural() - 1;
const next_index = iter.next_structural();
const is_ondemand = @TypeOf(iter) == *Ondemand.Iterator;
const content = blk: {
if (current_index) |ci| {
if (is_ondemand) {
var len = std.math.min(iter.parser.read_buf_len, log_buf2.len);
const ptr = iter.peek(ci, len) catch break :blk null;
mem.copy(u8, &log_buf2, ptr[0..len]);
}
for (log_buf2) |*c, i| {
if (!is_ondemand)
c.* = printable_char(iter.parser.bytes[ci[0] + i])
else
c.* = printable_char(c.*);
}
break :blk pad_with_alloc(&log_buf2, ' ', LOG_BUFFER_LEN, log_fba.allocator());
} else {
break :blk &pad_with("", ' ', LOG_BUFFER_LEN);
}
};
print("| {s} ", .{content});
const next_content = blk: {
if (is_ondemand) {
const len = std.math.min(iter.parser.read_buf_len, log_buf2.len);
const ptr = iter.peek(next_index, len) catch break :blk null;
mem.copy(u8, &log_buf2, ptr[0..len]);
}
const end_pos = if (!is_ondemand) iter.parser.bytes.len else iter.parser.end_pos;
for (log_buf2) |*c, i| {
if (next_index[0] + i >= end_pos) break;
// std.log.debug("bytes.len {} next_index[0] {} i {}", .{ iter.parser.bytes.len, next_index[0], i });
if (!is_ondemand)
c.* = printable_char(iter.parser.bytes[next_index[0] + i])
else
c.* = printable_char(c.*);
}
break :blk pad_with_alloc(&log_buf2, ' ', LOG_SMALL_BUFFER_LEN, log_fba.allocator());
};
print("| {s} ", .{next_content});
if (current_index) |ci| {
print("| {s} ", .{
pad_with_alloc(
std.fmt.bufPrint(&log_buf2, "{}", .{ci[0]}) catch return,
' ',
LOG_INDEX_LEN,
log_fba.allocator(),
),
});
} else {
print("| {s} ", .{&pad_with("", ' ', LOG_INDEX_LEN)});
}
// printf("| %*u ", LOG_INDEX_LEN, structurals.next_tape_index());
println("| {s} ", .{detail});
}
pub fn value(log: *Logger, iter: anytype, typ: []const u8) void {
log.line(iter, "", typ, "");
}
pub fn value2(log: *Logger, iter: anytype, typ: []const u8, detail: []const u8, delta: u32, depth_delta: u32) void {
// log.line(iter, "", typ, "");
log.line_fmt(iter, typ, detail, "start pos {} depth {}", .{ delta, depth_delta });
}
pub fn start_value(log: *Logger, iter: anytype, typ: []const u8) void {
log.line(iter, "+", typ, "");
if (common.debug) log.depth = log.depth +| 1;
}
pub fn end_value(log: *Logger, iter: anytype, typ: []const u8) void {
if (common.debug) log.depth = log.depth -| 1;
log.line(iter, "-", typ, "");
}
pub fn err(log: *Logger, iter: anytype, err_msg: []const u8) void {
_ = iter;
_ = log;
if (common.debug) std.log.err("{s}", .{err_msg});
}
pub fn err_fmt(log: *Logger, iter: anytype, comptime fmt: []const u8, args: anytype) void {
_ = iter;
_ = log;
if (common.debug) std.log.err(fmt, args);
}
pub fn event(log: *Logger, iter: anytype, typ: []const u8, detail: []const u8, delta: i32, depth_delta: i32) void {
log.line_fmt(iter, typ, detail, "{} {}", .{ delta, depth_delta });
} | src/Logger.zig |
const std = @import("std");
const string = []const u8;
const gpa = std.heap.c_allocator;
const zfetch = @import("zfetch");
const json = @import("json");
const u = @import("./../util/index.zig");
//
//
pub const commands = struct {
pub const add = @import("./zpm/add.zig");
pub const showjson = @import("./zpm/showjson.zig");
pub const tags = @import("./zpm/tags.zig");
pub const search = @import("./zpm/search.zig");
};
pub const server_root = "https://zig.pm/api";
pub const Package = struct {
author: string,
name: string,
tags: []const string,
git: string,
root_file: string,
description: string,
source: u32,
links: []const ?string,
};
pub fn execute(args: [][]u8) !void {
if (args.len == 0) {
std.debug.print("{s}\n", .{
\\This is a subcommand for use with https://github.com/zigtools/zpm-server instances but has no default behavior on its own aside from showing you this nice help text.
\\
\\The default remote is https://zig.pm/.
\\
\\The subcommands available are:
\\ - add Append this package to your dependencies
\\ - showjson Print raw json from queried API responses
\\ - tags Print the list of tags available on the server.
\\ - search Search the api for available packages and print them.
});
return;
}
inline for (comptime std.meta.declarations(commands)) |decl| {
if (std.mem.eql(u8, args[0], decl.name)) {
const cmd = @field(commands, decl.name);
try cmd.execute(args[1..]);
return;
}
}
u.fail("unknown command \"{s}\" for \"zigmod zpm\"", .{args[0]});
}
pub fn server_fetch(url: string) !json.Value {
const req = try zfetch.Request.init(gpa, url, null);
defer req.deinit();
try req.do(.GET, null, null);
const r = req.reader();
const body_content = try r.readAllAlloc(gpa, std.math.maxInt(usize));
const val = try json.parse(gpa, body_content);
return val;
}
pub fn server_fetchArray(url: string) ![]const Package {
const val = try server_fetch(url);
var list = std.ArrayList(Package).init(gpa);
errdefer list.deinit();
for (val.Array) |item| {
if (item.getT("root_file", .String) == null) continue;
try list.append(Package{
.name = item.getT("name", .String).?,
.author = item.getT("author", .String).?,
.description = item.getT("description", .String).?,
.tags = try valueStrArray(item.getT("tags", .Array).?),
.git = item.getT("git", .String).?,
.root_file = item.getT("root_file", .String).?,
.source = @intCast(u32, item.getT("source", .Int).?),
.links = try valueLinks(item.get("links").?),
});
}
return list.toOwnedSlice();
}
fn valueStrArray(vals: []json.Value) ![]string {
var list = std.ArrayList(string).init(gpa);
errdefer list.deinit();
for (vals) |item| {
if (item != .String) continue;
try list.append(item.String);
}
return list.toOwnedSlice();
}
fn valueLinks(vals: json.Value) ![]?string {
var list = std.ArrayList(?string).init(gpa);
errdefer list.deinit();
try list.append(vals.getT("github", .String));
try list.append(vals.getT("aquila", .String));
try list.append(vals.getT("astrolabe", .String));
return list.toOwnedSlice();
} | src/cmd/zpm.zig |
const std = @import("std");
const input = @import("input.zig");
pub fn run(stdout: anytype) anyerror!void {
{
var input_ = try input.readFile("inputs/day8");
defer input_.deinit();
const result = try part1(&input_);
try stdout.print("8a: {}\n", .{ result });
std.debug.assert(result == 239);
}
{
var input_ = try input.readFile("inputs/day8");
defer input_.deinit();
const result = try part2(&input_);
try stdout.print("8b: {}\n", .{ result });
std.debug.assert(result == 946346);
}
}
fn part1(input_: anytype) !usize {
var result: usize = 0;
while (try input_.next()) |line| {
var line_parts = std.mem.split(u8, line, " | ");
_ = line_parts.next();
const output_part = line_parts.next() orelse return error.InvalidInput;
var output_digits = std.mem.split(u8, output_part, " ");
while (output_digits.next()) |output_digit| {
result += @as(usize, switch (output_digit.len) {
2, 3, 4, 7 => 1,
5, 6 => 0,
else => return error.InvalidInput,
});
}
}
return result;
}
fn part2(input_: anytype) !u64 {
var result: u64 = 0;
while (try input_.next()) |line| {
var line_parts = std.mem.split(u8, line, " | ");
const input_part = line_parts.next() orelse return error.InvalidInput;
var input_digits = std.mem.split(u8, input_part, " ");
// pppp
// q r
// q r
// ssss
// t u
// t u
// vvvv
//
// [2] one = ..r..u.
// [3] seven = p.r..u.
// [4] four = .qrs.u.
// [5] two = p.rst.v
// [5] three = p.rs.uv
// [5] five = pq.s.uv
// [6] zero = pqr.tuv
// [6] six = pq.stuv
// [6] nine = pqrs.uv
// [7] eight = pqrstuv
var maybe_one: ?SegmentSet = null;
var maybe_four: ?SegmentSet = null;
var maybe_seven: ?SegmentSet = null;
var maybe_eight: ?SegmentSet = null;
var two_or_three_or_five_list = std.BoundedArray(SegmentSet, 3).init(0) catch unreachable;
var zero_or_six_or_nine_list = std.BoundedArray(SegmentSet, 3).init(0) catch unreachable;
while (input_digits.next()) |input_digit| {
switch (input_digit.len) {
2 => {
if (maybe_one != null) {
return error.InvalidInput;
}
maybe_one = try makeSegmentSet(input_digit);
},
3 => {
if (maybe_seven != null) {
return error.InvalidInput;
}
maybe_seven = try makeSegmentSet(input_digit);
},
4 => {
if (maybe_four != null) {
return error.InvalidInput;
}
maybe_four = try makeSegmentSet(input_digit);
},
5 => try two_or_three_or_five_list.append(try makeSegmentSet(input_digit)),
6 => try zero_or_six_or_nine_list.append(try makeSegmentSet(input_digit)),
7 => {
if (maybe_eight != null) {
return error.InvalidInput;
}
maybe_eight = try makeSegmentSet(input_digit);
},
else => return error.InvalidInput,
}
}
const one = maybe_one orelse return error.InvalidInput;
const four = maybe_four orelse return error.InvalidInput;
const seven = maybe_seven orelse return error.InvalidInput;
const eight = maybe_eight orelse return error.InvalidInput;
const two_or_three_or_five = two_or_three_or_five_list.constSlice();
if (two_or_three_or_five.len != 3) {
return error.InvalidInput;
}
const zero_or_six_or_nine = zero_or_six_or_nine_list.constSlice();
if (zero_or_six_or_nine.len != 3) {
return error.InvalidInput;
}
std.debug.assert(eight == 0b1111111);
// seven - one => p
const p = seven & ~one;
std.debug.assert(@popCount(SegmentSet, p) == 1);
// two - four - seven => tv
// three - four - seven => v
// five - four - seven => v
const v = v: {
for (two_or_three_or_five) |two_or_three_or_five_| {
const tv = two_or_three_or_five_ & ~four & ~seven;
if (@popCount(SegmentSet, tv) == 1) {
break :v tv;
}
}
unreachable;
};
// eight - four - seven - v => t
const t = ~four & ~seven & ~v;
std.debug.assert(@popCount(SegmentSet, t) == 1);
// two - one - p - t - v => s
// three - one - p - t - v => s
// five - one - p - t - v => qs
const s = s: {
for (two_or_three_or_five) |two_or_three_or_five_| {
const qs = two_or_three_or_five_ & ~one & ~p & ~t & ~v;
if (@popCount(SegmentSet, qs) == 1) {
break :s qs;
}
}
unreachable;
};
// eight - one - p - s - t - v => q
const q = ~one & ~p & ~s & ~t & ~v;
std.debug.assert(@popCount(SegmentSet, q) == 1);
// zero - p - q - s - t - v => ru
// six - p - q - s - t - v => u
// nine - p - q - s - t - v => ru
const u = u: {
for (zero_or_six_or_nine) |zero_or_six_or_nine_| {
const ru = zero_or_six_or_nine_ & ~p & ~q & ~s & ~t & ~v;
if (@popCount(SegmentSet, ru) == 1) {
break :u ru;
}
}
unreachable;
};
// eight - p - q - s - t - u - v => r
const r = ~p & ~q & ~s & ~t & ~u & ~v;
std.debug.assert(@popCount(SegmentSet, r) == 1);
const digits = [_]SegmentSet {
p | q | r | t | u | v,
r | u,
p | r | s | t | v,
p | r | s | u | v,
q | r | s | u,
p | q | s | u | v,
p | q | s | t | u | v,
p | r | u,
p | q | r | s | t | u | v,
p | q | r | s | u | v,
};
const outputs = line_parts.next() orelse return error.InvalidInput;
var output_parts = std.mem.split(u8, outputs, " ");
var output_num: u64 = 0;
while (output_parts.next()) |output| {
const output_set = try makeSegmentSet(output);
const digit = std.mem.indexOfScalar(SegmentSet, digits[0..], output_set) orelse return error.InvalidInput;
output_num = output_num * 10 + digit;
}
result += output_num;
}
return result;
}
const SegmentSet = u7;
fn makeSegmentSet(s: []const u8) !SegmentSet {
var result: SegmentSet = 0;
for (s) |c| {
switch (c) {
'a' => result |= 0b1000000,
'b' => result |= 0b0100000,
'c' => result |= 0b0010000,
'd' => result |= 0b0001000,
'e' => result |= 0b0000100,
'f' => result |= 0b0000010,
'g' => result |= 0b0000001,
else => return error.InvalidInput,
}
}
return result;
}
test "day 8 example 1" {
const input_ =
\\be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | fdgacbe cefdb cefbgd gcbe
\\edbfga begcd cbg gc gcadebf fbgde acbgfd abcde gfcbed gfec | fcgedb cgb dgebacf gc
\\fgaebd cg bdaec gdafb agbcfd gdcbef bgcad gfac gcb cdgabef | cg cg fdcagb cbg
\\fbegcd cbd adcefb dageb afcb bc aefdc ecdab fgdeca fcdbega | efabcd cedba gadfec cb
\\aecbfdg fbg gf bafeg dbefa fcge gcbea fcaegb dgceab fcbdga | gecf egdcabf bgf bfgea
\\fgeab ca afcebg bdacfeg cfaedg gcfdb baec bfadeg bafgc acf | gebdcfa ecba ca fadegcb
\\dbcfg fgd bdegcaf fgec aegbdf ecdfab fbedc dacgb gdcebf gf | cefg dcbef fcge gbcadfe
\\bdfegc cbegaf gecbf dfcage bdacg ed bedf ced adcbefg gebcd | ed bcgafe cdgba cbgef
\\egadfb cdbfeg cegd fecab cgb gbdefca cg fgcdab egfdb bfceg | gbdfcae bgc cg cgb
\\gcafb gcf dcaebfg ecagb gf abcdeg gaef cafbge fdbac fegbdc | fgae cfgab fg bagce
;
try std.testing.expectEqual(@as(usize, 26), try part1(&input.readString(input_)));
try std.testing.expectEqual(@as(u64, 8394 + 9781 + 1197 + 9361 + 4873 + 8418 + 4548 + 1625 + 8717 + 4315), try part2(&input.readString(input_)));
} | src/day8.zig |
const std = @import("std");
const ArrayList = std.ArrayList;
const stdout = std.io.getStdOut().outStream();
const allocPrint0 = std.fmt.allocPrint0;
const parse = @import("parse.zig");
const NodeKind = parse.NodeKind;
const Node = parse.Node;
const Obj = parse.Obj;
const assert = @import("std").debug.assert;
const err = @import("error.zig");
const errorAt = err.errorAt;
const errorAtToken = err.errorAtToken;
const t = @import("type.zig");
const Type = t.Type;
const TypeKind = t.TypeKind;
const allocator = @import("allocator.zig");
const getAllocator = allocator.getAllocator;
var depth: usize = 0;
var count_i: usize = 0;
var ARGREG8 = [_][:0]const u8{ "%dil", "%sil", "%dl", "%cl", "%r8b", "%r9b" };
var ARGREG16 = [_][:0]const u8{ "%di", "%si", "%dx", "%cx", "%r8w", "%r9w" };
var ARGREG32 = [_][:0]const u8{ "%edi", "%esi", "%edx", "%ecx", "%r8d", "%r9d" };
var ARGREG64 = [_][:0]const u8{ "%rdi", "%rsi", "%rdx", "%rcx", "%r8", "%r9" };
var current_fn: *Obj = undefined;
var outStream: std.fs.File.OutStream = undefined;
pub fn codegen(prog: ArrayList(*Obj), out: *std.fs.File) !void {
outStream = out.outStream();
_ = assignLvarOffsets(prog);
try emitData(prog);
try emitText(prog);
}
fn emitData(prog: ArrayList(*Obj)) !void {
for (prog.items) |v| {
if (v.*.is_function)
continue;
try println(" .data", .{});
try println(" .globl {}", .{v.*.name});
try println("{}:", .{v.*.name});
if (v.*.init_data.len != 0) {
for (v.*.init_data) |c| {
try println(" .byte {}", .{c});
}
try println(" .byte 0", .{});
} else {
try println(" .zero {}", .{v.*.ty.?.*.size});
}
}
}
fn emitText(prog: ArrayList(*Obj)) !void {
for (prog.items) |func| {
if (!func.*.is_function or !func.*.is_definition)
continue;
try println(" .globl {}", .{func.*.name});
try println(" .text", .{});
try println("{}:", .{func.*.name});
current_fn = func;
// Prologue
try println(" push %rbp", .{});
try println(" mov %rsp, %rbp", .{});
try println(" sub ${}, %rsp", .{func.*.stack_size});
if (func.params != null) {
const fparams = func.params.?.items;
var i: usize = fparams.len;
while (i > 0) {
const fparam = fparams[i - 1];
try storeGp(fparam.*.offset, fparam.*.ty.?.*.size, fparams.len - i);
i -= 1;
}
}
try genStmt(func.*.body);
assert(depth == 0);
try println(".L.return.{}:", .{func.*.name});
try println(" mov %rbp, %rsp", .{});
try println(" pop %rbp", .{});
try println(" ret", .{});
}
}
fn genStmt(node: *Node) anyerror!void {
try println(" .loc 1 {}", .{node.*.tok.*.line_no});
switch (node.*.kind) {
NodeKind.NdIf => {
const c = count();
try genExpr(node.*.cond);
try println(" cmp $0, %rax", .{});
try println(" je .L.else.{}", .{c});
try genStmt(node.*.then.?);
try println(" jmp .L.end.{}", .{c});
try println(".L.else.{}:", .{c});
if (node.*.els != null)
try genStmt(node.*.els.?);
try println(".L.end.{}:", .{c});
return;
},
NodeKind.NdFor => {
const c = count();
if (node.*.init != null)
try genStmt(node.*.init.?);
try println(".L.begin.{}:", .{c});
if (node.*.cond != null) {
try genExpr(node.*.cond);
try println(" cmp $0, %rax", .{});
try println(" je .L.end.{}", .{c});
}
try genStmt(node.*.then.?);
if (node.*.inc != null)
try genExpr(node.*.inc);
try println(" jmp .L.begin.{}", .{c});
try println(".L.end.{}:", .{c});
return;
},
NodeKind.NdBlock => {
var n = node.*.body;
while (n != null) {
try genStmt(n.?);
n = n.?.*.next;
}
},
NodeKind.NdReturn => {
try genExpr(node.*.lhs);
try println(" jmp .L.return.{}", .{current_fn.*.name});
},
NodeKind.NdExprStmt => {
try genExpr(node.*.lhs);
},
else => {
errorAtToken(node.*.tok, "invalid statement");
},
}
}
fn genExpr(nodeWithNull: ?*Node) anyerror!void {
if (nodeWithNull == null) {
return;
}
const node: *Node = nodeWithNull.?;
try println(" .loc 1 {}", .{node.*.tok.*.line_no});
switch (node.*.kind) {
NodeKind.NdNum => {
try println(" mov ${}, %rax", .{node.*.val});
return;
},
NodeKind.NdNeg => {
try genExpr(node.*.lhs);
try println(" neg %rax", .{});
return;
},
NodeKind.NdVar, NodeKind.NdMember => {
try genAddr(node);
try load(node.*.ty.?);
return;
},
NodeKind.NdDeref => {
try genExpr(node.*.lhs);
try load(node.*.ty.?);
return;
},
NodeKind.NdAddr => {
try genAddr(node.*.lhs.?);
return;
},
NodeKind.NdAssign => {
try genAddr(node.*.lhs.?);
try push();
try genExpr(node.*.rhs.?);
try store(node.*.ty.?);
return;
},
NodeKind.NdStmtExpr => {
var n = node.*.body;
while (n != null) : (n = n.?.*.next) {
try genStmt(n.?);
}
return;
},
NodeKind.NdComma => {
try genExpr(node.*.lhs);
try genExpr(node.*.rhs);
return;
},
NodeKind.NdCast => {
try genExpr(node.*.lhs);
try cast(node.*.lhs.?.*.ty.?, node.*.ty.?);
return;
},
NodeKind.NdFuncall => {
var arg: ?*Node = node.*.args;
var nargs: usize = 0;
while (arg != null) {
try genExpr(arg.?);
try push();
nargs += 1;
arg = arg.?.*.next;
}
while (nargs > 0) {
try pop(ARGREG64[nargs - 1]);
nargs -= 1;
}
try println(" mov $0, %rax", .{});
try println(" call {}", .{node.*.funcname});
return;
},
else => {},
}
try genExpr(node.*.rhs);
try push();
try genExpr(node.*.lhs);
try pop("%rdi");
var ax = "%eax";
var di = "%edi";
if (node.*.lhs.?.*.ty.?.*.kind == .TyLong or node.*.lhs.?.*.ty.?.*.base != null) {
ax = "%rax";
di = "%rdi";
}
switch (node.*.kind) {
NodeKind.NdAdd => try println(" add {}, {}", .{ di, ax }),
NodeKind.NdSub => try println(" sub {}, {}", .{ di, ax }),
NodeKind.NdMul => try println(" imul {}, {}", .{ di, ax }),
NodeKind.NdDiv => {
if (node.*.lhs.?.*.ty.?.*.size == 8) {
try println(" cqo", .{});
} else {
try println(" cdq", .{});
}
try println(" idiv {}", .{di});
},
NodeKind.NdEq, NodeKind.NdNe, NodeKind.NdLt, NodeKind.NdLe => {
try println(" cmp {}, {}", .{ di, ax });
if (node.*.kind == NodeKind.NdEq) {
try println(" sete %al", .{});
} else if (node.*.kind == NodeKind.NdNe) {
try println(" setne %al", .{});
} else if (node.*.kind == NodeKind.NdLt) {
try println(" setl %al", .{});
} else if (node.*.kind == NodeKind.NdLe) {
try println(" setle %al", .{});
}
try println(" movzb %al, %rax", .{});
},
else => errorAtToken(node.*.tok, "code generationに失敗しました"),
}
}
fn push() !void {
try println(" push %rax", .{});
depth += 1;
}
fn pop(arg: [:0]const u8) !void {
try println(" pop {}", .{arg});
depth -= 1;
}
fn genAddr(node: *Node) anyerror!void {
switch (node.*.kind) {
NodeKind.NdVar => {
if (node.*.variable.?.*.is_local) {
try println(" lea {}(%rbp), %rax", .{node.*.variable.?.*.offset});
} else {
try println(" lea {}(%rip), %rax", .{node.*.variable.?.*.name});
}
return;
},
NodeKind.NdDeref => {
try genExpr(node.*.lhs);
return;
},
NodeKind.NdComma => {
try genExpr(node.*.lhs);
try genAddr(node.*.rhs.?);
return;
},
NodeKind.NdMember => {
try genAddr(node.*.lhs.?);
try println(" add ${}, %rax", .{node.*.member.?.*.offset});
return;
},
else => errorAtToken(node.*.tok, "ローカル変数ではありません"),
}
}
fn assignLvarOffsets(prog: ArrayList(*Obj)) void {
for (prog.items) |func| {
if (!func.*.is_function)
continue;
var offset: i32 = 0;
if (func.*.locals != null) {
const ls = func.*.locals.?.items;
if (ls.len > 0) {
var li: usize = ls.len - 1;
while (true) {
offset += @intCast(i32, ls[li].ty.?.*.size);
offset = alignTo(offset, @intCast(i32, ls[li].ty.?.*.alignment));
ls[li].offset = -offset;
if (li > 0) {
li -= 1;
} else {
break;
}
}
}
}
func.*.stack_size = alignTo(offset, 16);
}
}
// アライン処理。関数を呼び出す前にRBPを16アラインしないといけない。
pub fn alignTo(n: i32, a: i32) i32 {
return @divFloor((n + a - 1), a) * a;
}
fn count() !usize {
count_i += 1;
return count_i;
}
fn load(ty: *Type) !void {
if (ty.*.kind == TypeKind.TyArray or ty.*.kind == TypeKind.TyStruct or ty.*.kind == TypeKind.TyUnion) {
return;
}
if (ty.*.size == 1) {
try println(" movsbl (%rax), %eax", .{});
} else if (ty.*.size == 2) {
try println(" movswl (%rax), %eax", .{});
} else if (ty.*.size == 4) {
try println(" movsxd (%rax), %rax", .{});
} else {
try println(" mov (%rax), %rax", .{});
}
}
fn store(ty: *Type) !void {
try pop("%rdi");
if (ty.*.kind == TypeKind.TyStruct or ty.*.kind == TypeKind.TyUnion) {
var i: usize = 0;
while (i < ty.*.size) : (i += 1) {
try println(" mov {}(%rax), %r8b", .{i});
try println(" mov %r8b, {}(%rdi)", .{i});
}
return;
}
if (ty.*.size == 1) {
try println(" mov %al, (%rdi)", .{});
} else if (ty.*.size == 2) {
try println(" mov %ax, (%rdi)", .{});
} else if (ty.*.size == 4) {
try println(" mov %eax, (%rdi)", .{});
} else {
try println(" mov %rax, (%rdi)", .{});
}
}
pub fn println(comptime format: []const u8, args: anytype) !void {
try outStream.print(format, args);
try outStream.print("\n", .{});
}
fn storeGp(offset: i32, size: usize, reg: usize) !void {
switch (size) {
1 => try println(" mov {}, {}(%rbp)", .{ ARGREG8[reg], offset }),
2 => try println(" mov {}, {}(%rbp)", .{ ARGREG16[reg], offset }),
4 => try println(" mov {}, {}(%rbp)", .{ ARGREG32[reg], offset }),
8 => try println(" mov {}, {}(%rbp)", .{ ARGREG64[reg], offset }),
else => unreachable,
}
}
fn cast(from: *Type, to: *Type) !void {
if (to.*.kind == .TyVoid)
return;
var t1 = getTypeId(from);
var t2 = getTypeId(to);
if (castTable[t1][t2] != null)
try println(" {}", .{castTable[t1][t2]});
}
const TypeId = enum(usize) {
I8, I16, I32, I64
};
fn getTypeId(ty: *Type) usize {
return switch (ty.*.kind) {
TypeKind.TyChar => @enumToInt(TypeId.I8),
TypeKind.TyShort => @enumToInt(TypeId.I16),
TypeKind.TyInt => @enumToInt(TypeId.I32),
else => @enumToInt(TypeId.I64),
};
}
const i32i8: [:0]const u8 = "movsbl %al, %eax";
const i32i16: [:0]const u8 = "movswl %ax, %eax";
const i32i64: [:0]const u8 = "movsxd %eax, %rax";
const castTable = [4][4]?[:0]const u8{
.{ null, null, null, i32i64 }, // i8
.{ i32i8, null, null, i32i64 }, // i16
.{ i32i8, i32i16, null, i32i64 }, // i32
.{ i32i8, i32i16, null, null }, // i64
}; | src/codegen.zig |
export fn zig_entry() align(16) callconv(.Naked) void {
asm volatile (
\\push 12(%%ecx)
\\push 8(%%ecx)
\\push 4(%%ecx)
\\push 0(%%ecx)
\\push %%esi
\\push %%edi
\\push %%ebp
::: "memory"
);
asm volatile (
\\push %%esp # all registers state
\\push %%edx # interrupt frame
\\push %%ebx # error code
\\push %%eax # interrupt number
\\mov %%esp, %%ebp
\\push %%esp # interrupt context
\\call interruptRouter
\\mov %%ebp, %%esp
\\add $16, %%esp # 'pop' of interrupt context
::: "memory"
);
asm volatile (
\\pop %%ebp
\\pop %%edi
\\pop %%esi
\\pop %%edx
\\pop %%ecx
\\pop %%ebx
\\pop %%eax
::: "memory"
);
}
const FnHandler = fn() align(16) callconv(.Naked) noreturn;
// Create entry points for all interrupts
pub const handlers = blk: {
const N = 256;
var fns: [N]FnHandler = undefined;
inline for (fns) |*f, i| {
f.* = handler_init(i);
}
break :blk fns;
};
fn handler_init(comptime N: usize) FnHandler {
const has_error_code = switch (N) {
8, 10, 11, 12, 13, 14, 17 => true,
else => false,
};
const impl = struct {
fn inner() align(16) callconv(.Naked) noreturn {
asm volatile (
\\push %%eax
\\push %%ebx
\\push %%ecx
\\push %%edx
\\mov %%esp, %%ecx
);
if (has_error_code) {
asm volatile ("lea 20(%%ecx), %%edx");
asm volatile ("mov 16(%%ecx), %%ebx");
}
else {
asm volatile ("lea 16(%%ecx), %%edx");
asm volatile ("xor %%ebx, %%ebx");
}
asm volatile ("call zig_entry" ::
[n] "{eax}" (@as(u32, N))
: "memory"
);
// 'pop' off the error code and registers
if (has_error_code) {
asm volatile ("add $20, %%esp");
}
else {
asm volatile ("add $16, %%esp");
}
while (true) {
asm volatile ("iret");
}
}
};
return impl.inner;
} | src/interrupts/handlers.zig |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.