code
stringlengths 38
801k
| repo_path
stringlengths 6
263
|
|---|---|
const std = @import("std");
const zua = @import("zua.zig");
const Token = zua.lex.Token;
// From lopcodes.h:
//
// We assume that instructions are unsigned numbers.
// All instructions have an opcode in the first 6 bits.
// Instructions can have the following fields:
// 'A': 8 bits
// 'B': 9 bits
// 'C': 9 bits
// 'Bx': 18 bits ('B' and 'C' together)
// 'sBx': signed Bx
//
// A signed argument is represented in excess K; that is, the number
// value is the unsigned value minus K. K is exactly the maximum value
// for that argument (so that -max is represented by 0, and +max is
// represented by 2*max), which is half the maximum for the corresponding
// unsigned argument.
pub const OpCode = enum(u6) {
// TODO: rest of the opcodes
move = 0,
loadk = 1,
loadbool = 2,
loadnil = 3,
getglobal = 5,
gettable = 6,
setglobal = 7,
settable = 9,
newtable = 10,
self = 11,
add = 12,
sub = 13,
mul = 14,
div = 15,
mod = 16,
pow = 17,
unm = 18,
not = 19,
len = 20,
concat = 21,
jmp = 22,
call = 28,
tailcall = 29,
@"return" = 30,
setlist = 34,
vararg = 37,
pub fn InstructionType(op: OpCode) type {
return switch (op) {
.move => Instruction.Move,
.loadk => Instruction.LoadK,
.loadbool => Instruction.LoadBool,
.loadnil => Instruction.LoadNil,
.getglobal => Instruction.GetGlobal,
.gettable => Instruction.GetTable,
.setglobal => Instruction.SetGlobal,
.settable => Instruction.SetTable,
.newtable => Instruction.NewTable,
.self => Instruction.Self,
.add, .sub, .mul, .div, .mod, .pow => Instruction.BinaryMath,
.unm => Instruction.UnaryMinus,
.not => Instruction.Not,
.len => Instruction.Length,
.concat => Instruction.Concat,
.jmp => Instruction.Jump,
.call, .tailcall => Instruction.Call,
.@"return" => Instruction.Return,
.setlist => Instruction.SetList,
.vararg => Instruction.VarArg,
};
}
pub const OpMode = enum {
iABC,
iABx,
iAsBx,
};
// A mapping of OpCode -> OpMode
const op_modes = blk: {
const max_fields = std.math.maxInt(@typeInfo(OpCode).Enum.tag_type);
var array: [max_fields]OpMode = undefined;
for (@typeInfo(OpCode).Enum.fields) |field| {
const Type = @field(OpCode, field.name).InstructionType();
const mode: OpMode = switch (@typeInfo(Type).Struct.fields[0].field_type) {
Instruction.ABC => .iABC,
Instruction.ABx => .iABx,
Instruction.AsBx => .iAsBx,
else => unreachable,
};
array[field.value] = mode;
}
break :blk array;
};
pub fn getOpMode(self: OpCode) OpMode {
return op_modes[@enumToInt(self)];
}
pub const OpArgMask = enum {
NotUsed, // N
Used, // U
RegisterOrJumpOffset, // R
ConstantOrRegisterConstant, // K
};
pub const OpMeta = struct {
b_mode: OpArgMask,
c_mode: OpArgMask,
sets_register_in_a: bool,
test_t_mode: bool,
};
const op_meta = blk: {
const max_fields = std.math.maxInt(@typeInfo(OpCode).Enum.tag_type);
var array: [max_fields]*const OpMeta = undefined;
for (@typeInfo(OpCode).Enum.fields) |field| {
const Type = @field(OpCode, field.name).InstructionType();
const meta = &@field(Type, "meta");
array[field.value] = meta;
}
break :blk array;
};
pub fn getBMode(self: OpCode) OpArgMask {
return op_meta[@enumToInt(self)].b_mode;
}
pub fn getCMode(self: OpCode) OpArgMask {
return op_meta[@enumToInt(self)].c_mode;
}
/// If true, the instruction will set the register index specified in its `A` value
pub fn setsRegisterInA(self: OpCode) bool {
return op_meta[@enumToInt(self)].sets_register_in_a;
}
// TODO rename
/// operator is a test
pub fn testTMode(self: OpCode) bool {
return op_meta[@enumToInt(self)].test_t_mode;
}
};
// R(x) - register
// Kst(x) - constant (in constant table)
// RK(x) == if ISK(x) then Kst(INDEXK(x)) else R(x)
/// SIZE_B define equivalent (lopcodes.h)
const bit_size_b = 9;
/// BITRK define equivalent (lopcodes.h)
const rk_bit_mask_constant: u9 = 1 << (bit_size_b - 1);
/// MAXINDEXRK define equivalent (lopcodes.h)
pub const rk_max_constant_index: u9 = rk_bit_mask_constant - 1;
/// ISK macro equivalent (lopcodes.h)
pub fn rkIsConstant(val: u9) bool {
return val & rk_bit_mask_constant != 0;
}
/// INDEXK macro equivalent (lopcodes.h)
pub fn rkGetConstantIndex(val: u9) u9 {
return val & ~rk_bit_mask_constant;
}
/// RKASK macro equivalent (lopcodes.h)
pub fn constantIndexToRK(val: u9) u9 {
return val | rk_bit_mask_constant;
}
/// To be bit-casted depending on the op field
pub const Instruction = packed struct {
op: OpCode,
a: u8,
fields: u18,
pub const ABC = packed struct {
op: OpCode,
a: u8,
c: u9,
b: u9,
pub fn init(op: OpCode, a: u8, b: u9, c: u9) Instruction.ABC {
return .{
.op = op,
.a = a,
.b = b,
.c = c,
};
}
pub const max_a = std.math.maxInt(u8);
pub const max_b = std.math.maxInt(u9);
pub const max_c = std.math.maxInt(u9);
};
pub const ABx = packed struct {
op: OpCode,
a: u8,
bx: u18,
pub fn init(op: OpCode, a: u8, bx: u18) Instruction.ABx {
return .{
.op = op,
.a = a,
.bx = bx,
};
}
pub const max_bx = std.math.maxInt(u18);
};
pub const AsBx = packed struct {
op: OpCode,
a: u8,
/// Underscore in the name to make it hard to accidentally use this field directly.
/// Stored as unsigned for binary compatibility
_bx: u18,
pub fn init(op: OpCode, a: u8, sbx: i18) Instruction.AsBx {
return .{
.op = op,
.a = a,
._bx = signedBxToUnsigned(sbx),
};
}
pub fn getSignedBx(self: *const Instruction.AsBx) i18 {
return unsignedBxToSigned(self._bx);
}
pub fn setSignedBx(self: *Instruction.AsBx, val: i18) void {
self._bx = signedBxToUnsigned(val);
}
pub const max_sbx = std.math.maxInt(i18);
// Not std.math.minInt because of the subtraction stuff
pub const min_sbx = -max_sbx;
pub fn unsignedBxToSigned(Bx: u18) i18 {
const fitting_int = std.math.IntFittingRange(min_sbx, ABx.max_bx);
return @intCast(i18, @intCast(fitting_int, Bx) - max_sbx);
}
pub fn signedBxToUnsigned(sBx: i18) u18 {
const fitting_int = std.math.IntFittingRange(min_sbx, ABx.max_bx);
return @intCast(u18, @intCast(fitting_int, sBx) + max_sbx);
}
};
/// R(A) := R(B)
pub const Move = packed struct {
/// really only A B
instruction: Instruction.ABC,
pub const meta: OpCode.OpMeta = .{
.b_mode = .RegisterOrJumpOffset,
.c_mode = .NotUsed,
.sets_register_in_a = true,
.test_t_mode = false,
};
};
/// R(A) := Kst(Bx)
pub const LoadK = packed struct {
instruction: Instruction.ABx,
pub const meta: OpCode.OpMeta = .{
.b_mode = .ConstantOrRegisterConstant,
.c_mode = .NotUsed,
.sets_register_in_a = true,
.test_t_mode = false,
};
pub fn init(result_reg: u8, constant_index: u18) LoadK {
return .{
.instruction = Instruction.ABx.init(
.loadk,
result_reg,
constant_index,
),
};
}
};
/// R(A) := (Bool)B; if (C) pc++
pub const LoadBool = packed struct {
instruction: Instruction.ABC,
pub const meta: OpCode.OpMeta = .{
.b_mode = .Used,
.c_mode = .Used,
.sets_register_in_a = true,
.test_t_mode = false,
};
pub fn init(result_reg: u8, val: bool, does_jump: bool) LoadBool {
return .{
.instruction = Instruction.ABC.init(
.loadbool,
result_reg,
@boolToInt(val),
@boolToInt(does_jump),
),
};
}
pub fn doesJump(self: *const LoadBool) bool {
return self.instruction.c != 0;
}
};
/// R(A) := ... := R(B) := nil
pub const LoadNil = packed struct {
/// really only A B
instruction: Instruction.ABC,
pub const meta: OpCode.OpMeta = .{
.b_mode = .RegisterOrJumpOffset,
.c_mode = .NotUsed,
.sets_register_in_a = true,
.test_t_mode = false,
};
/// Note: reg_range_start and reg_range_end are both inclusive,
/// so for setting a single register start and end should
/// be equal
pub fn init(reg_range_start: u8, reg_range_end: u9) LoadNil {
std.debug.assert(reg_range_end >= reg_range_start);
return .{
.instruction = Instruction.ABC.init(
.loadnil,
reg_range_start,
reg_range_end,
0,
),
};
}
pub fn assignsToMultipleRegisters(self: LoadNil) bool {
return self.instruction.a != @truncate(u8, self.instruction.b);
}
pub fn willAssignToRegister(self: LoadNil, reg: u8) bool {
return reg >= self.instruction.a and reg <= self.instruction.b;
}
};
/// R(A) := Gbl[Kst(Bx)]
pub const GetGlobal = packed struct {
instruction: Instruction.ABx,
pub const meta: OpCode.OpMeta = .{
.b_mode = .ConstantOrRegisterConstant,
.c_mode = .NotUsed,
.sets_register_in_a = true,
.test_t_mode = false,
};
pub fn init(result_reg: u8, name_constant_index: u18) GetGlobal {
return .{
.instruction = .{
.op = .getglobal,
.a = result_reg,
.bx = name_constant_index,
},
};
}
};
/// R(A) := R(B)[RK(C)]
pub const GetTable = packed struct {
instruction: Instruction.ABC,
pub const meta: OpCode.OpMeta = .{
.b_mode = .RegisterOrJumpOffset,
.c_mode = .ConstantOrRegisterConstant,
.sets_register_in_a = true,
.test_t_mode = false,
};
pub fn init(result_reg: u8, table_reg: u9, key_rk: u9) GetTable {
return .{
.instruction = .{
.op = .gettable,
.a = result_reg,
.b = table_reg,
.c = key_rk,
},
};
}
};
/// Gbl[Kst(Bx)] := R(A)
pub const SetGlobal = packed struct {
instruction: Instruction.ABx,
pub const meta: OpCode.OpMeta = .{
.b_mode = .ConstantOrRegisterConstant,
.c_mode = .NotUsed,
.sets_register_in_a = false,
.test_t_mode = false,
};
pub fn init(name_constant_index: u18, source_reg: u8) SetGlobal {
return .{
.instruction = .{
.op = .setglobal,
.a = source_reg,
.bx = name_constant_index,
},
};
}
};
/// R(A)[RK(B)] := RK(C)
pub const SetTable = packed struct {
instruction: Instruction.ABC,
pub const meta: OpCode.OpMeta = .{
.b_mode = .ConstantOrRegisterConstant,
.c_mode = .ConstantOrRegisterConstant,
.sets_register_in_a = false,
.test_t_mode = false,
};
pub fn init(table_reg: u8, key_rk: u9, val_rk: u9) SetTable {
return .{
.instruction = Instruction.ABC.init(
.settable,
table_reg,
key_rk,
val_rk,
),
};
}
};
/// R(A) := {} (size = B,C)
pub const NewTable = packed struct {
instruction: Instruction.ABC,
pub const meta: OpCode.OpMeta = .{
.b_mode = .Used,
.c_mode = .Used,
.sets_register_in_a = true,
.test_t_mode = false,
};
pub fn setArraySize(self: *NewTable, num: zua.object.FloatingPointByteIntType) void {
self.instruction.b = @intCast(u9, zua.object.intToFloatingPointByte(num));
}
pub fn setTableSize(self: *NewTable, num: zua.object.FloatingPointByteIntType) void {
self.instruction.c = @intCast(u9, zua.object.intToFloatingPointByte(num));
}
};
/// R(A+1) := R(B); R(A) := R(B)[RK(C)]
pub const Self = packed struct {
instruction: Instruction.ABC,
pub const meta: OpCode.OpMeta = .{
.b_mode = .RegisterOrJumpOffset,
.c_mode = .ConstantOrRegisterConstant,
.sets_register_in_a = true,
.test_t_mode = false,
};
/// Stores the function (gotten from table[key]) in `setup_reg_start`
/// and the table itself in `setup_reg_start + 1`
pub fn init(setup_reg_start: u8, table_reg: u9, key_rk: u9) Self {
return .{ .instruction = .{
.op = .self,
.a = setup_reg_start,
.b = table_reg,
.c = key_rk,
} };
}
};
/// R(A) := RK(B) <operation> RK(C)
pub const BinaryMath = packed struct {
instruction: Instruction.ABC,
pub const meta: OpCode.OpMeta = .{
.b_mode = .ConstantOrRegisterConstant,
.c_mode = .ConstantOrRegisterConstant,
.sets_register_in_a = true,
.test_t_mode = false,
};
pub fn init(op: OpCode, result_reg: u8, left_rk: u9, right_rk: u9) BinaryMath {
return .{
.instruction = Instruction.ABC.init(
op,
result_reg,
left_rk,
right_rk,
),
};
}
pub fn tokenToOpCode(token: Token) OpCode {
return switch (token.char.?) {
'+' => .add,
'-' => .sub,
'*' => .mul,
'/' => .div,
'%' => .mod,
'^' => .pow,
else => unreachable,
};
}
};
/// R(A) := -R(B)
pub const UnaryMinus = packed struct {
/// really only A B
instruction: Instruction.ABC,
pub const meta: OpCode.OpMeta = .{
.b_mode = .RegisterOrJumpOffset,
.c_mode = .NotUsed,
.sets_register_in_a = true,
.test_t_mode = false,
};
};
/// R(A) := not R(B)
pub const Not = packed struct {
/// really only A B
instruction: Instruction.ABC,
pub const meta: OpCode.OpMeta = .{
.b_mode = .RegisterOrJumpOffset,
.c_mode = .NotUsed,
.sets_register_in_a = true,
.test_t_mode = false,
};
pub fn init(result_reg: u8, value_reg: u9) Not {
return .{
.instruction = Instruction.ABC.init(
.not,
result_reg,
value_reg,
0,
),
};
}
};
/// R(A) := length of R(B)
pub const Length = packed struct {
instruction: Instruction.ABC,
pub const meta: OpCode.OpMeta = .{
.b_mode = .RegisterOrJumpOffset,
.c_mode = .NotUsed,
.sets_register_in_a = true,
.test_t_mode = false,
};
};
/// R(A) := R(B).. ... ..R(C)
pub const Concat = packed struct {
instruction: Instruction.ABC,
pub const meta: OpCode.OpMeta = .{
.b_mode = .RegisterOrJumpOffset,
.c_mode = .RegisterOrJumpOffset,
.sets_register_in_a = true,
.test_t_mode = false,
};
pub fn init(result_reg: u8, start_reg: u9, end_reg: u9) Concat {
std.debug.assert(end_reg > start_reg);
return .{ .instruction = .{
.op = .concat,
.a = result_reg,
.b = start_reg,
.c = end_reg,
} };
}
pub fn getStartReg(self: Concat) u9 {
return self.instruction.b;
}
pub fn setStartReg(self: *Concat, start_reg: u9) void {
self.instruction.b = start_reg;
}
pub fn getEndReg(self: Concat) u9 {
return self.instruction.c;
}
pub fn setEndReg(self: *Concat, end_reg: u9) void {
self.instruction.c = end_reg;
}
pub fn numConcattedValues(self: Concat) u9 {
return (self.instruction.c - self.instruction.b) + 1;
}
};
/// pc+=sBx
pub const Jump = packed struct {
/// really only sBx
instruction: Instruction.AsBx,
pub const meta: OpCode.OpMeta = .{
.b_mode = .RegisterOrJumpOffset,
.c_mode = .NotUsed,
.sets_register_in_a = false,
.test_t_mode = false,
};
pub fn init(offset: ?i18) Jump {
const instruction = Instruction.AsBx.init(.jmp, 0, 0);
var jmp = @bitCast(Jump, instruction);
jmp.setOffset(offset);
return jmp;
}
/// -1 can be used to represent 'no jump' here because that would mean that an instruction
/// is jumping to itself, which is obviously not something we'd ever want to do
const no_jump = -1;
pub fn getOffset(self: *const Jump) ?i18 {
const sbx = self.instruction.getSignedBx();
if (sbx == no_jump) return null;
return sbx;
}
pub fn setOffset(self: *Jump, offset: ?i18) void {
self.instruction.setSignedBx(offset orelse no_jump);
}
pub fn offsetToAbsolute(pc: usize, offset: i18) usize {
// As I understand it, the + 1 here is necessary to emulate
// the implicit pc++ when evaluating the jmp instruction itself.
// That is, if there's bytecode like:
// 1 jmp 1
// 2 something
// 3 something
// then the jmp would offset pc by 1, but then it'd get offset
// again by the natural movement of the pc after evaluating
// any instruction, so we'd actually end up at 3
//
// TODO better understand why this + 1 exists/verify the above
return @intCast(usize, @intCast(isize, pc + 1) + offset);
}
};
/// Used for both call and tailcall opcodes
/// call: R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1))
/// tailcall: return R(A)(R(A+1), ... ,R(A+B-1))
pub const Call = packed struct {
instruction: Instruction.ABC,
pub const meta: OpCode.OpMeta = .{
.b_mode = .Used,
.c_mode = .Used,
.sets_register_in_a = true,
.test_t_mode = false,
};
pub fn init(result_reg_start: u8, num_params: u9, num_return_values: ?u9) Call {
const c_val = if (num_return_values != null) num_return_values.? + 1 else 0;
return .{
.instruction = Instruction.ABC.init(
// TODO: This is always being .call is kinda weird, but it happens to work with
// how the Lua compiler handles call/tailcall (they all start as call
// and then get converted to tailcall)
.call,
result_reg_start,
num_params + 1,
c_val,
),
};
}
pub fn getNumParams(self: Call) u9 {
return self.instruction.b - 1;
}
// 'base register for call' is what it's called in lparser.c:643
pub fn setResultRegStart(self: *Call, base_reg: u8) void {
self.instruction.a = base_reg;
}
pub fn getResultRegStart(self: *const Call) u8 {
return self.instruction.a;
}
pub fn getResultRegEnd(self: *const Call) ?u9 {
if (self.getNumReturnValues()) |return_vals| {
if (return_vals > 0) {
return self.getResultRegStart() + return_vals - 1;
} else {
return null;
}
} else {
return null;
}
}
pub fn setNumReturnValues(self: *Call, num_return_values: ?u9) void {
if (num_return_values) |v| {
self.instruction.c = v + 1;
} else {
self.instruction.c = 0;
}
}
pub fn getNumReturnValues(self: *const Call) ?u9 {
if (self.isMultipleReturns()) return null;
return self.instruction.c - 1;
}
pub fn isMultipleReturns(self: *const Call) bool {
return self.instruction.c == 0;
}
};
/// return R(A), ... ,R(A+B-2)
/// if (B == 0) then return up to `top'
pub const Return = packed struct {
/// really only A B
instruction: Instruction.ABC,
pub const meta: OpCode.OpMeta = .{
.b_mode = .Used,
.c_mode = .NotUsed,
.sets_register_in_a = false,
.test_t_mode = false,
};
pub fn init(first_return_value_register: u8, num_return_values: ?u9) Return {
const b_val = if (num_return_values != null) num_return_values.? + 1 else 0;
return .{
.instruction = Instruction.ABC.init(
.@"return",
first_return_value_register,
b_val,
0,
),
};
}
pub fn getFirstReturnValueRegister(self: *const Return) u8 {
return self.instruction.a;
}
pub fn setFirstReturnValueRegister(self: *Return, first_return_value_register: u8) void {
self.instruction.a = first_return_value_register;
}
pub fn setNumReturnValues(self: *Return, num_return_values: ?u9) void {
if (num_return_values) |v| {
self.instruction.b = v + 1;
} else {
self.instruction.b = 0;
}
}
pub fn getNumReturnValues(self: *const Return) ?u9 {
if (self.isMultipleReturns()) return null;
return self.instruction.b - 1;
}
pub fn isMultipleReturns(self: *const Return) bool {
return self.instruction.b == 0;
}
};
/// R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B
/// if (B == 0) then B = `top'
/// if (C == 0) then next `instruction' is real C
pub const SetList = packed struct {
instruction: Instruction.ABC,
pub const meta: OpCode.OpMeta = .{
.b_mode = .Used,
.c_mode = .Used,
.sets_register_in_a = false,
.test_t_mode = false,
};
pub const batch_num_in_next_instruction = 0;
/// Note: If the resulting SetList's c value is `batch_num_in_next_instruction`
/// (or `isBatchNumberStoredInNextInstruction` returns true), then this instruction
/// will need an additional instruction after it that contains the full batch number
/// (as a bare u32)
pub fn init(table_reg: u8, num_values: usize, to_store: ?usize) SetList {
const flush_batch_num: usize = SetList.numValuesToFlushBatchNum(num_values);
const num_values_in_batch: u9 = if (to_store == null) 0 else @intCast(u9, to_store.?);
const c_val = if (flush_batch_num <= Instruction.ABC.max_c)
@intCast(u9, flush_batch_num)
else
batch_num_in_next_instruction;
return .{ .instruction = .{
.op = .setlist,
.a = table_reg,
.b = num_values_in_batch,
.c = c_val,
} };
}
pub fn numValuesToFlushBatchNum(num_values: usize) usize {
return (num_values - 1) / Instruction.SetList.fields_per_flush + 1;
}
pub fn isBatchNumberStoredInNextInstruction(self: *const SetList) bool {
return self.instruction.c == 0;
}
/// equivalent to LFIELDS_PER_FLUSH from lopcodes.h
pub const fields_per_flush = 50;
};
/// R(A), R(A+1), ..., R(A+B-1) = vararg
pub const VarArg = packed struct {
instruction: Instruction.ABC,
pub const meta: OpCode.OpMeta = .{
.b_mode = .Used,
.c_mode = .NotUsed,
.sets_register_in_a = true,
.test_t_mode = false,
};
pub fn init(first_return_value_register: u8, num_return_values: ?u9) VarArg {
const b_val = if (num_return_values != null) num_return_values.? + 1 else 0;
return .{
.instruction = Instruction.ABC.init(
.vararg,
first_return_value_register,
b_val,
0,
),
};
}
pub fn getFirstReturnValueRegister(self: *const VarArg) u8 {
return self.instruction.a;
}
pub fn setFirstReturnValueRegister(self: *VarArg, first_return_value_register: u8) void {
self.instruction.a = first_return_value_register;
}
pub fn setNumReturnValues(self: *VarArg, num_return_values: ?u9) void {
if (num_return_values) |v| {
self.instruction.b = v + 1;
} else {
self.instruction.b = 0;
}
}
pub fn getNumReturnValues(self: *const VarArg) ?u9 {
if (self.isMultipleReturns()) return null;
return self.instruction.b - 1;
}
pub fn isMultipleReturns(self: *const VarArg) bool {
return self.instruction.b == 0;
}
};
};
test "sBx" {
try std.testing.expectEqual(
@as(i18, Instruction.AsBx.min_sbx),
Instruction.AsBx.unsignedBxToSigned(0),
);
const max_sbx_as_bx = Instruction.AsBx.signedBxToUnsigned(Instruction.AsBx.max_sbx);
try std.testing.expectEqual(
@as(i18, Instruction.AsBx.max_sbx),
Instruction.AsBx.unsignedBxToSigned(max_sbx_as_bx),
);
}
|
src/opcodes.zig
|
const std = @import("std");
const input = @import("input.zig");
pub fn run(stdout: anytype) anyerror!void {
{
var input_ = try input.readFile("inputs/day6");
defer input_.deinit();
const result = try part1(&input_);
try stdout.print("6a: {}\n", .{ result });
std.debug.assert(result == 365862);
}
{
var input_ = try input.readFile("inputs/day6");
defer input_.deinit();
const result = try part2(&input_);
try stdout.print("6b: {}\n", .{ result });
std.debug.assert(result == 1653250886439);
}
}
fn part1(input_: anytype) !usize {
return solve(input_, 80);
}
fn part2(input_: anytype) !usize {
return solve(input_, 256);
}
fn solve(input_: anytype, num_days: usize) !usize {
const next_reproduction_after = 6;
const newborn_next_reproduction_after = 8;
const max_reproduction_after = std.math.max(next_reproduction_after, newborn_next_reproduction_after);
const ReproductionAfter = std.math.IntFittingRange(0, max_reproduction_after);
const line = (try input_.next()) orelse return error.InvalidInput;
var line_parts = std.mem.split(u8, line, ",");
var fish = [_]usize { 0 } ** (1 + max_reproduction_after);
while (line_parts.next()) |part| {
var num_days_remaining = try std.fmt.parseInt(ReproductionAfter, part, 10);
fish[num_days_remaining] += 1;
}
var day: usize = 0;
while (day < num_days) : (day += 1) {
const num_newborns = fish[0];
std.mem.copy(usize, fish[0..(fish.len - 1)], fish[1..]);
fish[next_reproduction_after] += num_newborns;
fish[newborn_next_reproduction_after] = num_newborns;
}
var sum: usize = 0;
for (fish) |num_fish| {
sum += num_fish;
}
return sum;
}
test "day 6 example 1" {
const input_ =
\\3,4,3,1,2
;
try std.testing.expectEqual(@as(usize, 5934), try part1(&input.readString(input_)));
try std.testing.expectEqual(@as(usize, 26984457539), try part2(&input.readString(input_)));
}
|
src/day6.zig
|
const std = @import("std");
const Allocator = std.mem.Allocator;
const List = std.ArrayList;
const Map = std.AutoHashMap;
const StrMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
const Str = []const u8;
const util = @import("util.zig");
const gpa = util.gpa;
const data = @embedFile("../data/day07.txt");
//const data = "16,1,2,0,4,2,7,1,2,14";
pub fn main() !void {
const input: []u32 = blk: {
var iter = tokenize(u8, data, ",\r\n");
var list = std.ArrayList(u32).init(gpa);
while (iter.next()) |s| {
const n = try parseInt(u32, s, 10);
try list.append(n);
}
break :blk list.toOwnedSlice();
};
{ // part 1
// find initial upper and lower bounds
var low: u32 = comptime std.math.maxInt(u32);
var high: u32 = 0;
for (input) |n| {
if (n > high) high = n;
if (n < low) low = n;
}
var mincost: u32 = std.math.maxInt(u32);
var testpoint = low; while (testpoint <= high) : (testpoint += 1) {
var cost: u32 = 0;
for (input) |n| {
cost += if (testpoint < n) (n - testpoint) else (testpoint - n);
}
if (cost < mincost) mincost = cost;
}
print("{}\n", .{mincost});
}
{ // part 2
// find initial upper and lower bounds
var low: u32 = comptime std.math.maxInt(u32);
var high: u32 = 0;
for (input) |n| {
if (n > high) high = n;
if (n < low) low = n;
}
var mincost: u32 = std.math.maxInt(u32);
var testpoint = low; while (testpoint <= high) : (testpoint += 1) {
var cost: u32 = 0;
for (input) |n| {
const d = if (testpoint < n) (n - testpoint) else (testpoint - n);
cost += d*(d+1)/2;
}
if (cost < mincost) mincost = cost;
}
print("{}\n", .{mincost});
}
}
// Useful stdlib functions
const tokenize = std.mem.tokenize;
const split = std.mem.split;
const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear;
const lastIndexOf = std.mem.lastIndexOfScalar;
const lastIndexOfAny = std.mem.lastIndexOfAny;
const lastIndexOfStr = std.mem.lastIndexOfLinear;
const trim = std.mem.trim;
const sliceMin = std.mem.min;
const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat;
const min = std.math.min;
const min3 = std.math.min3;
const max = std.math.max;
const max3 = std.math.max3;
const print = std.debug.print;
const assert = std.debug.assert;
const sort = std.sort.sort;
const asc = std.sort.asc;
const desc = std.sort.desc;
|
src/day07.zig
|
const std = @import("std");
const zigimg = @import("zigimg");
const nooice = @import("nooice");
usingnamespace @import("global.zig");
const height_max: f32 = 2000;
const height_max_normalized = 1;
const height_water: f32 = 200;
const height_water_normalized = height_water / height_max;
const height_mountain_base: f32 = 1000;
const height_mountain_base_normalized = height_mountain_base / height_max;
pub fn make_heightmap(allocator: *std.mem.Allocator, width: usize, height: usize) !void {
println("make_heightmap begin");
defer println("make_heightmap end");
var heightmap_normalized = try allocator.alloc(f32, width * height);
defer allocator.free(heightmap_normalized);
{
println(" fbm begin");
defer println(" fbm end");
const seed = 0;
var y: usize = 0;
while (y < height) : (y += 1) {
var x: usize = 0;
while (x < width) : (x += 1) {
var xf = @intToFloat(f32, x);
var yf = @intToFloat(f32, y);
var fbm = nooice.fbm.noise_fbm_2d(xf, yf, seed, 5, 0.5, 300);
var i = x + y * width;
heightmap_normalized[i] = fbm;
}
}
}
{
println(" scale begin");
defer println(" scale end");
const span = nooice.transform.get_span(f32, heightmap_normalized);
nooice.transform.normalize(f32, heightmap_normalized, span.min, span.max);
const curve: nooice.transform.Curve(f32, 8) = .{
.points_x = [_]f32{ 0, height_water_normalized, 0.7, 1, 0, 0, 0, 0 },
.points_y = [_]f32{ 0, height_water_normalized, height_mountain_base_normalized, 1, 0, 0, 0, 0 },
};
nooice.transform.scale_with_curve_linear(f32, heightmap_normalized, curve);
}
{
println(" image begin");
defer println(" image end");
var img = try zigimg.Image.create(allocator, width, height, .Grayscale16, .Pgm);
const seed = 0;
var y: usize = 0;
while (y < height) : (y += 1) {
var x: usize = 0;
while (x < width) : (x += 1) {
const i = x + y * width;
const value = @floatToInt(u16, heightmap_normalized[i] * @intToFloat(f32, std.math.maxInt(u16)));
img.pixels.?.Grayscale16[i].value = value;
}
}
var pgm_opt: zigimg.AllFormats.PGM.EncoderOptions = .{ .binary = true };
const encoder_options = zigimg.AllFormats.ImageEncoderOptions{ .pgm = pgm_opt };
try img.writeToFilePath("data/gen/heightmap.pgm", img.image_format, encoder_options);
}
{
println(" splatmap begin");
defer println(" splatmap end");
var img = try zigimg.Image.create(allocator, width, height, .Grayscale8, .Pgm);
const seed = 0;
var y: usize = 0;
while (y < height) : (y += 1) {
var x: usize = 0;
while (x < width) : (x += 1) {
const i = x + y * width;
const value = heightmap_normalized[i];
if (value < height_water_normalized) {
img.pixels.?.Grayscale8[i].value = 0;
} else if (value < height_mountain_base_normalized) {
img.pixels.?.Grayscale8[i].value = 64;
} else {
img.pixels.?.Grayscale8[i].value = 128;
}
}
}
var pgm_opt: zigimg.AllFormats.PGM.EncoderOptions = .{ .binary = true };
const encoder_options = zigimg.AllFormats.ImageEncoderOptions{ .pgm = pgm_opt };
try img.writeToFilePath("data/gen/splatmap.pgm", img.image_format, encoder_options);
}
}
|
src/terrain_generation.zig
|
const std = @import("std");
const atomic = std.atomic;
const Atomic = std.atomic.Atomic;
const AtomicOrder = std.builtin.AtomicOrder;
pub fn Ring(comptime T: type) type {
// FIXME: check this is 64 bytes on all platforms
const cacheLineSize = 64;
return struct {
consumerHead: Atomic(usize),
pad1: [cacheLineSize - @sizeOf(usize)]u8 = undefined,
producerTail: Atomic(usize),
pad2: [cacheLineSize - @sizeOf(usize)]u8 = undefined,
buffer: [*]T,
size: usize,
mask: usize,
const Self = @This();
pub fn init(buffer: [*]T, size: usize) Self {
return Self{
.consumerHead = Atomic(usize).init(0),
.producerTail = Atomic(usize).init(0),
.buffer = buffer,
.size = size,
.mask = size - 1,
};
}
pub fn enqueue(self: *Self, value: T) bool {
const consumer = self.consumerHead.load(AtomicOrder.Acquire);
const producer = self.producerTail.load(AtomicOrder.Acquire);
const delta = producer + 1;
if (delta & self.mask == consumer & self.mask)
return false;
self.buffer[producer & self.mask] = value;
atomic.fence(AtomicOrder.Release);
self.producerTail.store(delta, AtomicOrder.Release);
return true;
}
pub fn dequeue(self: *Self) ?T {
const consumer = self.consumerHead.load(AtomicOrder.Acquire);
const producer = self.producerTail.load(AtomicOrder.Acquire);
if (consumer == producer)
return null;
atomic.fence(AtomicOrder.Acquire);
const value = self.buffer[consumer & self.mask];
atomic.fence(AtomicOrder.Release);
self.consumerHead.store(consumer + 1, AtomicOrder.Release);
return value;
}
pub fn length(self: *Self) usize {
const consumer = self.consumerHead.load(AtomicOrder.Acquire);
const producer = self.producerTail.load(AtomicOrder.Acquire);
return (producer - consumer) & self.mask;
}
};
}
const expect = std.testing.expect;
test "enqueue" {
var buffer = [4]i32{ 0, 0, 0, 0 };
var ring = Ring(i32).init(&buffer, buffer.len);
try expect(ring.enqueue(2) == true);
try expect(ring.enqueue(3) == true);
try expect(ring.enqueue(5) == true);
try expect(ring.enqueue(7) == false);
try expect(buffer[0] == 2);
try expect(buffer[1] == 3);
try expect(buffer[2] == 5);
try expect(buffer[3] == 0);
}
test "dequeue" {
var buffer: [4]i32 = undefined;
var ring = Ring(i32).init(&buffer, buffer.len);
_ = ring.enqueue(2);
_ = ring.enqueue(3);
_ = ring.enqueue(5);
try expect(ring.dequeue().? == 2);
try expect(ring.dequeue().? == 3);
try expect(ring.dequeue().? == 5);
}
test "length" {
var buffer: [8]i32 = undefined;
var ring = Ring(i32).init(&buffer, buffer.len);
try expect(ring.length() == 0);
_ = ring.enqueue(2);
_ = ring.enqueue(3);
_ = ring.enqueue(5);
try expect(ring.length() == 3);
_ = ring.dequeue();
_ = ring.dequeue();
try expect(ring.length() == 1);
_ = ring.dequeue();
try expect(ring.length() == 0);
}
|
spsc_ring.zig
|
const std = @import("std");
const dt = @import("datatable.zig");
const testing = std.testing;
test "table without using id" {
const columns = [_]dt.Column{
.{ .name = "Middle Name", .allow_empty = true },
.{ .name = "<NAME>" },
.{ .name = "Age" },
.{ .name = "Ph No", .max_len = 10 },
};
var user_table = dt.DataTable.init(std.heap.page_allocator);
defer user_table.deinit();
try user_table.addSingleColumn(dt.Column{ .name = "First Name" });
try user_table.addManyColumns(columns[0..]);
try testing.expect(user_table.totalColumns() == 5);
try user_table.insertSingleData(&[_][]const u8{
"Prajwal", "", "Chapagain", "20", "9815009744",
});
try user_table.insertManyData(&[_][]const []const u8{
&.{ "Samyam", "", "Timsina", "18", "1234567890" },
&.{ "Ramesh", "", "Dhungana", "19", "9800000900" },
});
try testing.expect(user_table.isDataExistOnColumn("Last Name", "Ramesh") == false);
try testing.expect(user_table.isDataExistOnColumn("First Name", "Prajwal") == true);
var searched_data = try user_table.searchData("Ph No", "9815009744");
try testing.expect(searched_data.len == 5);
var col1_data = try user_table.selectColumnByNum(1);
try testing.expect(col1_data.len == 3 and std.mem.eql(u8, col1_data[2], "Ramesh"));
var col4_data = try user_table.selectColumnByName("Ph No");
try testing.expect(col4_data.len == 3 and std.mem.eql(u8, col4_data[1], "1234567890"));
//user_table.deleteColumnByNum(2);
//user_table.deleteColumnByName("Date");
}
test "table with using id" {
var books_table = try dt.DataTable.initWithIdColumn(std.heap.page_allocator);
defer books_table.deinit();
try books_table.addManyColumns(&[_]dt.Column{
.{ .name = "Book name" },
.{ .name = "Author" },
});
try testing.expect(books_table.totalColumns() == 3);
try books_table.insertManyData(&[_][]const []const u8{
&.{ "Book 1", "person 1" },
&.{ "Book 2", "person 2" },
&.{ "Book 3", "person 3" },
&.{ "Book 4", "person 4" },
});
try testing.expect(books_table.isDataExistOnColumn("Author", "person 3") == true);
var book1_data = try books_table.searchData("Book name", "Book 1");
try testing.expect(book1_data.len == 2);
var col1_data = try books_table.selectColumnByNum(1);
try testing.expect(col1_data.len == 4);
try testing.expect(std.mem.eql(u8, col1_data[0], "Book 1"));
try testing.expect(std.mem.eql(u8, col1_data[1], "Book 2"));
try testing.expect(std.mem.eql(u8, col1_data[2], "Book 3"));
try testing.expect(std.mem.eql(u8, col1_data[3], "Book 4"));
var col1_data_searched_by_name = try books_table.selectColumnByName("Book name");
try testing.expect(col1_data_searched_by_name.len == 4);
try testing.expect(std.mem.eql(u8, col1_data_searched_by_name[0], "Book 1"));
try testing.expect(std.mem.eql(u8, col1_data_searched_by_name[1], "Book 2"));
try testing.expect(std.mem.eql(u8, col1_data_searched_by_name[2], "Book 3"));
try testing.expect(std.mem.eql(u8, col1_data_searched_by_name[3], "Book 4"));
}
|
src/main.zig
|
const std = @import("std");
const Type = @import("../Type.zig");
const DW = std.dwarf;
// zig fmt: off
/// Definitions of all of the x64 registers. The order is semantically meaningful.
/// The registers are defined such that IDs go in descending order of 64-bit,
/// 32-bit, 16-bit, and then 8-bit, and each set contains exactly sixteen
/// registers. This results in some useful properties:
///
/// Any 64-bit register can be turned into its 32-bit form by adding 16, and
/// vice versa. This also works between 32-bit and 16-bit forms. With 8-bit, it
/// works for all except for sp, bp, si, and di, which do *not* have an 8-bit
/// form.
///
/// If (register & 8) is set, the register is extended.
///
/// The ID can be easily determined by figuring out what range the register is
/// in, and then subtracting the base.
pub const Register = enum(u8) {
// 0 through 15, 64-bit registers. 8-15 are extended.
// id is just the int value.
rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi,
r8, r9, r10, r11, r12, r13, r14, r15,
// 16 through 31, 32-bit registers. 24-31 are extended.
// id is int value - 16.
eax, ecx, edx, ebx, esp, ebp, esi, edi,
r8d, r9d, r10d, r11d, r12d, r13d, r14d, r15d,
// 32-47, 16-bit registers. 40-47 are extended.
// id is int value - 32.
ax, cx, dx, bx, sp, bp, si, di,
r8w, r9w, r10w, r11w, r12w, r13w, r14w, r15w,
// 48-63, 8-bit registers. 56-63 are extended.
// id is int value - 48.
al, cl, dl, bl, ah, ch, dh, bh,
r8b, r9b, r10b, r11b, r12b, r13b, r14b, r15b,
/// Returns the bit-width of the register.
pub fn size(self: Register) u7 {
return switch (@enumToInt(self)) {
0...15 => 64,
16...31 => 32,
32...47 => 16,
48...64 => 8,
else => unreachable,
};
}
/// Returns whether the register is *extended*. Extended registers are the
/// new registers added with amd64, r8 through r15. This also includes any
/// other variant of access to those registers, such as r8b, r15d, and so
/// on. This is needed because access to these registers requires special
/// handling via the REX prefix, via the B or R bits, depending on context.
pub fn isExtended(self: Register) bool {
return @enumToInt(self) & 0x08 != 0;
}
/// This returns the 4-bit register ID, which is used in practically every
/// opcode. Note that bit 3 (the highest bit) is *never* used directly in
/// an instruction (@see isExtended), and requires special handling. The
/// lower three bits are often embedded directly in instructions (such as
/// the B8 variant of moves), or used in R/M bytes.
pub fn id(self: Register) u4 {
return @truncate(u4, @enumToInt(self));
}
/// Returns the index into `callee_preserved_regs`.
pub fn allocIndex(self: Register) ?u4 {
return switch (self) {
.rax, .eax, .ax, .al => 0,
.rcx, .ecx, .cx, .cl => 1,
.rdx, .edx, .dx, .dl => 2,
.rsi, .esi, .si => 3,
.rdi, .edi, .di => 4,
.r8, .r8d, .r8w, .r8b => 5,
.r9, .r9d, .r9w, .r9b => 6,
.r10, .r10d, .r10w, .r10b => 7,
.r11, .r11d, .r11w, .r11b => 8,
else => null,
};
}
/// Convert from any register to its 64 bit alias.
pub fn to64(self: Register) Register {
return @intToEnum(Register, self.id());
}
/// Convert from any register to its 32 bit alias.
pub fn to32(self: Register) Register {
return @intToEnum(Register, @as(u8, self.id()) + 16);
}
/// Convert from any register to its 16 bit alias.
pub fn to16(self: Register) Register {
return @intToEnum(Register, @as(u8, self.id()) + 32);
}
/// Convert from any register to its 8 bit alias.
pub fn to8(self: Register) Register {
return @intToEnum(Register, @as(u8, self.id()) + 48);
}
pub fn dwarfLocOp(self: Register) u8 {
return switch (self.to64()) {
.rax => DW.OP_reg0,
.rdx => DW.OP_reg1,
.rcx => DW.OP_reg2,
.rbx => DW.OP_reg3,
.rsi => DW.OP_reg4,
.rdi => DW.OP_reg5,
.rbp => DW.OP_reg6,
.rsp => DW.OP_reg7,
.r8 => DW.OP_reg8,
.r9 => DW.OP_reg9,
.r10 => DW.OP_reg10,
.r11 => DW.OP_reg11,
.r12 => DW.OP_reg12,
.r13 => DW.OP_reg13,
.r14 => DW.OP_reg14,
.r15 => DW.OP_reg15,
else => unreachable,
};
}
};
// zig fmt: on
/// These registers belong to the called function.
pub const callee_preserved_regs = [_]Register{ .rax, .rcx, .rdx, .rsi, .rdi, .r8, .r9, .r10, .r11 };
pub const c_abi_int_param_regs = [_]Register{ .rdi, .rsi, .rdx, .rcx, .r8, .r9 };
pub const c_abi_int_return_regs = [_]Register{ .rax, .rdx };
// TODO add these registers to the enum and populate dwarfLocOp
// // Return Address register. This is stored in `0(%rsp, "")` and is not a physical register.
// RA = (16, "RA"),
//
// XMM0 = (17, "xmm0"),
// XMM1 = (18, "xmm1"),
// XMM2 = (19, "xmm2"),
// XMM3 = (20, "xmm3"),
// XMM4 = (21, "xmm4"),
// XMM5 = (22, "xmm5"),
// XMM6 = (23, "xmm6"),
// XMM7 = (24, "xmm7"),
//
// XMM8 = (25, "xmm8"),
// XMM9 = (26, "xmm9"),
// XMM10 = (27, "xmm10"),
// XMM11 = (28, "xmm11"),
// XMM12 = (29, "xmm12"),
// XMM13 = (30, "xmm13"),
// XMM14 = (31, "xmm14"),
// XMM15 = (32, "xmm15"),
//
// ST0 = (33, "st0"),
// ST1 = (34, "st1"),
// ST2 = (35, "st2"),
// ST3 = (36, "st3"),
// ST4 = (37, "st4"),
// ST5 = (38, "st5"),
// ST6 = (39, "st6"),
// ST7 = (40, "st7"),
//
// MM0 = (41, "mm0"),
// MM1 = (42, "mm1"),
// MM2 = (43, "mm2"),
// MM3 = (44, "mm3"),
// MM4 = (45, "mm4"),
// MM5 = (46, "mm5"),
// MM6 = (47, "mm6"),
// MM7 = (48, "mm7"),
//
// RFLAGS = (49, "rFLAGS"),
// ES = (50, "es"),
// CS = (51, "cs"),
// SS = (52, "ss"),
// DS = (53, "ds"),
// FS = (54, "fs"),
// GS = (55, "gs"),
//
// FS_BASE = (58, "fs.base"),
// GS_BASE = (59, "gs.base"),
//
// TR = (62, "tr"),
// LDTR = (63, "ldtr"),
// MXCSR = (64, "mxcsr"),
// FCW = (65, "fcw"),
// FSW = (66, "fsw"),
//
// XMM16 = (67, "xmm16"),
// XMM17 = (68, "xmm17"),
// XMM18 = (69, "xmm18"),
// XMM19 = (70, "xmm19"),
// XMM20 = (71, "xmm20"),
// XMM21 = (72, "xmm21"),
// XMM22 = (73, "xmm22"),
// XMM23 = (74, "xmm23"),
// XMM24 = (75, "xmm24"),
// XMM25 = (76, "xmm25"),
// XMM26 = (77, "xmm26"),
// XMM27 = (78, "xmm27"),
// XMM28 = (79, "xmm28"),
// XMM29 = (80, "xmm29"),
// XMM30 = (81, "xmm30"),
// XMM31 = (82, "xmm31"),
//
// K0 = (118, "k0"),
// K1 = (119, "k1"),
// K2 = (120, "k2"),
// K3 = (121, "k3"),
// K4 = (122, "k4"),
// K5 = (123, "k5"),
// K6 = (124, "k6"),
// K7 = (125, "k7"),
|
src/codegen/x86_64.zig
|
const std = @import("std");
const wayland = @import("wayland");
const wl = wayland.client.wl;
const zwlr = wayland.client.zwlr;
const gpa = std.heap.c_allocator;
const ToplevelInfo = struct {
title: []const u8 = undefined,
app_id: []const u8 = undefined,
maximized: bool = false,
minimized: bool = false,
activated: bool = false,
fullscreen: bool = false,
// TODO: parent and output
};
const InfoList = std.TailQueue(ToplevelInfo);
pub fn main() anyerror!void {
const display = try wl.Display.connect(null);
const registry = try display.getRegistry();
var info_list = InfoList{};
var opt_manager: ?*zwlr.ForeignToplevelManagerV1 = null;
registry.setListener(*?*zwlr.ForeignToplevelManagerV1, registryListener, &opt_manager) catch unreachable;
_ = try display.roundtrip();
const manager = opt_manager orelse return error.ForeignToplevelManagementNotAdvertised;
manager.setListener(*InfoList, managerListener, &info_list) catch unreachable;
_ = try display.roundtrip();
const slice = gpa.alloc(ToplevelInfo, info_list.len) catch @panic("out of memory");
var it = info_list.first;
var i: usize = 0;
while (it) |node| : (it = node.next) {
slice[i] = node.data;
i += 1;
}
const stdout = std.io.getStdOut().writer();
try std.json.stringify(slice, .{ .whitespace = .{} }, stdout);
try stdout.writeByte('\n');
}
fn registryListener(registry: *wl.Registry, event: wl.Registry.Event, manager: *?*zwlr.ForeignToplevelManagerV1) void {
switch (event) {
.global => |global| {
if (std.cstr.cmp(global.interface, zwlr.ForeignToplevelManagerV1.getInterface().name) == 0) {
manager.* = registry.bind(global.name, zwlr.ForeignToplevelManagerV1, 1) catch return;
}
},
.global_remove => {},
}
}
fn managerListener(
manager: *zwlr.ForeignToplevelManagerV1,
event: zwlr.ForeignToplevelManagerV1.Event,
info_list: *InfoList,
) void {
switch (event) {
.toplevel => |ev| {
const node = gpa.create(InfoList.Node) catch @panic("out of memory");
node.data = .{};
info_list.append(node);
ev.toplevel.setListener(*ToplevelInfo, handleListener, &node.data) catch unreachable;
},
.finished => {},
}
}
fn handleListener(
handle: *zwlr.ForeignToplevelHandleV1,
event: zwlr.ForeignToplevelHandleV1.Event,
info: *ToplevelInfo,
) void {
switch (event) {
.title => |ev| info.title = gpa.dupe(u8, std.mem.span(ev.title)) catch @panic("out of memory"),
.app_id => |ev| info.app_id = gpa.dupe(u8, std.mem.span(ev.app_id)) catch @panic("out of memory"),
.state => |ev| {
for (ev.state.slice(zwlr.ForeignToplevelHandleV1.State)) |state| {
switch (state) {
.maximized => info.maximized = true,
.minimized => info.minimized = true,
.activated => info.activated = true,
.fullscreen => info.fullscreen = true,
else => {},
}
}
},
.done, .closed, .output_enter, .output_leave, .parent => {},
}
}
|
ltoplevels.zig
|
const std = @import("std");
const mem = std.mem;
const mpack = @import("./mpack.zig");
const RPC = @import("./RPC.zig");
const ChildProcess = std.ChildProcess;
pub fn spawn(allocator: *mem.Allocator) !*std.ChildProcess {
//const argv = &[_][]const u8{ "nvim", "--embed" };
const argv = &[_][]const u8{ "nvim", "--embed", "-u", "NORC" };
const child = try std.ChildProcess.init(argv, allocator);
child.stdout_behavior = ChildProcess.StdIo.Pipe;
child.stdin_behavior = ChildProcess.StdIo.Pipe;
child.stderr_behavior = ChildProcess.StdIo.Inherit;
try child.spawn();
return child;
}
pub fn attach_test(encoder: anytype) !void {
if (false) {
try encoder.putArrayHead(4);
try encoder.putInt(0); // request
try encoder.putInt(0); // msgid
try encoder.putStr("nvim_get_api_info");
try encoder.putArrayHead(0);
} else {
try encoder.putArrayHead(4);
try encoder.putInt(0); // request
try encoder.putInt(0); // msgid
try encoder.putStr("nvim_ui_attach");
try encoder.putArrayHead(3);
try encoder.putInt(80); // width
try encoder.putInt(24); // height
try encoder.putMapHead(1);
try encoder.putStr("ext_linegrid");
try encoder.putBool(true);
}
}
pub fn unsafe_input(encoder: anytype, input: []const u8) !void {
try encoder.putArrayHead(3);
try encoder.putInt(2); // request
try encoder.putStr("nvim_input");
try encoder.putArrayHead(1);
try encoder.putStr(input);
}
pub fn dummy_loop(stdout: anytype, allocator: *mem.Allocator) !void {
var buf: [1024]u8 = undefined;
var lenny = try stdout.read(&buf);
var decoder = mpack.Decoder{ .data = buf[0..lenny] };
var rpc = RPC.init(allocator);
var decodeFrame: @Frame(RPC.decodeLoop) = async rpc.decodeLoop(&decoder);
// @compileLog(@sizeOf(@Frame(decodeLoop)));
// 11920 with fully async readHead()
// 5928 without
while (decoder.frame != null) {
const oldlen = decoder.data.len;
if (oldlen > 0 and decoder.data.ptr != &buf) {
// TODO: avoid move if remaining space is plenty (like > 900)
mem.copy(u8, &buf, decoder.data);
}
lenny = try stdout.read(buf[oldlen..]);
decoder.data = buf[0 .. oldlen + lenny];
resume decoder.frame.?;
}
try nosuspend await decodeFrame;
}
|
src/io_native.zig
|
const std = @import("std");
pub fn build(b: *std.build.Builder) !void {
_ = try addFuzzer(b, "json", &.{});
_ = try addFuzzer(b, "tokenizer", &.{});
_ = try addFuzzer(b, "parse", &.{});
_ = try addFuzzer(b, "deflate", &.{});
_ = try addFuzzer(b, "deflate-roundtrip", &.{});
const deflate_puff = try addFuzzer(b, "deflate-puff", &.{});
for (deflate_puff.libExes()) |lib_exe| {
lib_exe.addIncludeDir("lib/puff");
lib_exe.addCSourceFile("lib/puff/puff.c", &.{});
lib_exe.linkLibC();
}
const sin = try addFuzzer(b, "sin", &.{"-lm"});
for (sin.libExes()) |lib_exe| {
lib_exe.linkLibC();
}
// tools
const sin_musl = b.addExecutable("sin-musl", "tools/sin-musl.zig");
sin_musl.setTarget(.{ .abi = .musl });
sin_musl.linkLibC();
const install_sin_musl = b.addInstallArtifact(sin_musl);
const tools_step = b.step("tools", "Build and install tools");
tools_step.dependOn(&install_sin_musl.step);
}
fn addFuzzer(b: *std.build.Builder, comptime name: []const u8, afl_clang_args: []const []const u8) !FuzzerSteps {
// The library
const fuzz_lib = b.addStaticLibrary("fuzz-" ++ name ++ "-lib", "fuzzers/" ++ name ++ ".zig");
fuzz_lib.setBuildMode(.Debug);
fuzz_lib.want_lto = true;
fuzz_lib.bundle_compiler_rt = true;
// Setup the output name
const fuzz_executable_name = "fuzz-" ++ name;
const fuzz_exe_path = try std.fs.path.join(b.allocator, &.{ b.cache_root, fuzz_executable_name });
// We want `afl-clang-lto -o path/to/output path/to/library`
const fuzz_compile = b.addSystemCommand(&.{ "afl-clang-lto", "-o", fuzz_exe_path });
// Add the path to the library file to afl-clang-lto's args
fuzz_compile.addArtifactArg(fuzz_lib);
// Custom args
fuzz_compile.addArgs(afl_clang_args);
// Install the cached output to the install 'bin' path
const fuzz_install = b.addInstallBinFile(.{ .path = fuzz_exe_path }, fuzz_executable_name);
// Add a top-level step that compiles and installs the fuzz executable
const fuzz_compile_run = b.step("fuzz-" ++ name, "Build executable for fuzz testing '" ++ name ++ "' using afl-clang-lto");
fuzz_compile_run.dependOn(&fuzz_compile.step);
fuzz_compile_run.dependOn(&fuzz_install.step);
// Compile a companion exe for debugging crashes
const fuzz_debug_exe = b.addExecutable("fuzz-" ++ name ++ "-debug", "fuzzers/" ++ name ++ ".zig");
fuzz_debug_exe.setBuildMode(.Debug);
// Only install fuzz-debug when the fuzz step is run
const install_fuzz_debug_exe = b.addInstallArtifact(fuzz_debug_exe);
fuzz_compile_run.dependOn(&install_fuzz_debug_exe.step);
return FuzzerSteps{
.lib = fuzz_lib,
.debug_exe = fuzz_debug_exe,
};
}
const FuzzerSteps = struct {
lib: *std.build.LibExeObjStep,
debug_exe: *std.build.LibExeObjStep,
pub fn libExes(self: *const FuzzerSteps) [2]*std.build.LibExeObjStep {
return [_]*std.build.LibExeObjStep{ self.lib, self.debug_exe };
}
};
|
build.zig
|
const std = @import("std");
const xml = @import("xml.zig");
const Peripheral = @import("Peripheral.zig");
const Register = @import("Register.zig");
const Field = @import("Field.zig");
const ArenaAllocator = std.heap.ArenaAllocator;
const Allocator = std.mem.Allocator;
pub fn parsePeripheral(arena: *ArenaAllocator, node: *xml.Node) !Peripheral {
const allocator = arena.allocator();
return Peripheral{
.name = try allocator.dupe(u8, xml.getAttribute(node, "name") orelse return error.NoName),
.version = if (xml.getAttribute(node, "version")) |version|
try allocator.dupe(u8, version)
else
null,
.description = if (xml.getAttribute(node, "caption")) |caption|
try allocator.dupe(u8, caption)
else
null,
// TODO: make sure this is always null
.base_addr = null,
};
}
pub fn parseRegister(arena: *ArenaAllocator, node: *xml.Node, regs_start_addr: usize, has_fields: bool) !Register {
const allocator = arena.allocator();
return Register{
.name = try allocator.dupe(u8, xml.getAttribute(node, "name") orelse return error.NoName),
.description = if (xml.getAttribute(node, "caption")) |caption|
try allocator.dupe(u8, caption)
else
null,
.addr_offset = if (xml.getAttribute(node, "offset")) |reg_offset_str|
regs_start_addr + try std.fmt.parseInt(usize, reg_offset_str, 0)
else
return error.NoAddrOffset,
.size = if (xml.getAttribute(node, "size")) |size_str| blk: {
const full_size = 8 * try std.fmt.parseInt(usize, size_str, 0);
if (!has_fields) {
const mask = try std.fmt.parseInt(u64, xml.getAttribute(node, "mask") orelse break :blk full_size, 0);
// ensure it starts at bit 0
if (mask & 0x1 == 0)
break :blk full_size;
var cursor: u7 = 0;
while ((mask & (@as(u64, 1) << @intCast(u6, cursor))) != 0 and cursor < @bitSizeOf(u64)) : (cursor += 1) {}
// we now have width, make sure that the mask is contiguous
const width = cursor;
while (cursor < @bitSizeOf(u64)) : (cursor += 1) {
if ((mask & (@as(u64, 1) << @intCast(u6, cursor))) != 0) {
break :blk full_size;
}
} else break :blk width;
}
break :blk full_size;
} else return error.NoSize, // if this shows up then we need to determine the default size of a register
};
}
pub fn parseField(arena: *ArenaAllocator, node: *xml.Node) !Field {
const allocator = arena.allocator();
const name = try allocator.dupe(u8, xml.getAttribute(node, "name") orelse return error.NoName);
const mask = try std.fmt.parseInt(u64, xml.getAttribute(node, "mask") orelse return error.NoMask, 0);
var offset: u7 = 0;
while ((mask & (@as(u64, 1) << @intCast(u6, offset))) == 0 and offset < @bitSizeOf(usize)) : (offset += 1) {}
var cursor: u7 = offset;
while ((mask & (@as(u64, 1) << @intCast(u6, cursor))) != 0 and cursor < @bitSizeOf(u64)) : (cursor += 1) {}
const width = cursor - offset;
while (cursor < @bitSizeOf(u64)) : (cursor += 1)
if ((mask & (@as(u64, 1) << @intCast(u6, cursor))) != 0) {
std.log.warn("found mask with discontinuous bits: {s}, ignoring", .{name});
return error.InvalidMask;
};
return Field{
.name = name,
.description = if (xml.getAttribute(node, "caption")) |caption|
try allocator.dupe(u8, caption)
else
null,
.offset = offset,
.width = width,
};
}
|
src/atdf.zig
|
const std = @import("std");
const build_options = @import("build_options");
const stdx = @import("stdx");
const fatal = stdx.fatal;
const unsupported = stdx.unsupported;
const math = stdx.math;
const Vec2 = math.Vec2;
const builtin = @import("builtin");
const t = stdx.testing;
const sdl = @import("sdl");
const ft = @import("freetype");
const platform = @import("platform");
const cgltf = @import("cgltf");
pub const transform = @import("transform.zig");
pub const Transform = transform.Transform;
pub const svg = @import("svg.zig");
const SvgPath = svg.SvgPath;
const draw_cmd = @import("draw_cmd.zig");
pub const DrawCommandList = draw_cmd.DrawCommandList;
const _ttf = @import("ttf.zig");
const _color = @import("color.zig");
pub const Color = _color.Color;
const fps = @import("fps.zig");
pub const FpsLimiter = fps.FpsLimiter;
pub const DefaultFpsLimiter = fps.DefaultFpsLimiter;
const text_renderer = @import("backend/gpu/text_renderer.zig");
const FontCache = gpu.FontCache;
const log = stdx.log.scoped(.graphics);
pub const curve = @import("curve.zig");
const camera = @import("camera.zig");
pub const Camera = camera.Camera;
pub const CameraModule = camera.CameraModule;
pub const initTextureProjection = camera.initTextureProjection;
pub const initPerspectiveProjection = camera.initPerspectiveProjection;
pub const tessellator = @import("tessellator.zig");
pub const RectBinPacker = @import("rect_bin_packer.zig").RectBinPacker;
pub const SwapChain = @import("swapchain.zig").SwapChain;
pub const Renderer = @import("renderer.zig").Renderer;
const _text = @import("text.zig");
pub const TextMeasure = _text.TextMeasure;
pub const TextMetrics = _text.TextMetrics;
pub const TextGlyphIterator = _text.TextGlyphIterator;
pub const TextLayout = _text.TextLayout;
const FontRendererBackendType = enum(u1) {
/// Default renderer for desktop.
Freetype = 0,
Stbtt = 1,
};
pub const FontRendererBackend: FontRendererBackendType = b: {
break :b .Freetype;
};
const Backend = build_options.GraphicsBackend;
pub const FontId = u32;
// Maybe this should be renamed to FontFamilyId. FontGroup renamed to FontFamily.
pub const FontGroupId = u32;
pub const OpenTypeFont = _ttf.OpenTypeFont;
const font_ = @import("font.zig");
pub const Font = font_.Font;
pub const FontType = font_.FontType;
const font_group_ = @import("font_group.zig");
pub const FontGroup = font_group_.FontGroup;
pub const FontDesc = font_.FontDesc;
pub const BitmapFontStrike = font_.BitmapFontStrike;
pub const canvas = @import("backend/canvas/graphics.zig");
pub const gpu = @import("backend/gpu/graphics.zig");
pub const vk = @import("backend/vk/graphics.zig");
pub const gl = @import("backend/gl/graphics.zig");
pub const testg = @import("backend/test/graphics.zig");
/// Global freetype library handle.
pub var ft_library: ft.FT_Library = undefined;
pub const Graphics = struct {
impl: switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics,
.WasmCanvas => canvas.Graphics,
.Test => testg.Graphics,
else => stdx.unsupported(),
},
alloc: std.mem.Allocator,
path_parser: svg.PathParser,
svg_parser: svg.SvgParser,
text_buf: std.ArrayList(u8),
const Self = @This();
pub fn init(self: *Self, alloc: std.mem.Allocator, dpr: u8) void {
self.initCommon(alloc);
switch (Backend) {
.OpenGL => gpu.Graphics.initGL(&self.impl, alloc, dpr),
.WasmCanvas => canvas.Graphics.init(&self.impl, alloc),
.Test => testg.Graphics.init(&self.impl, alloc),
else => stdx.unsupported(),
}
}
pub fn initVK(self: *Self, alloc: std.mem.Allocator, dpr: u8, vk_ctx: vk.VkContext) void {
self.initCommon(alloc);
gpu.Graphics.initVK(&self.impl, alloc, dpr, vk_ctx);
}
fn initCommon(self: *Self, alloc: std.mem.Allocator) void {
self.* = .{
.alloc = alloc,
.path_parser = svg.PathParser.init(alloc),
.svg_parser = svg.SvgParser.init(alloc),
.text_buf = std.ArrayList(u8).init(alloc),
.impl = undefined,
};
if (FontRendererBackend == .Freetype) {
const err = ft.FT_Init_FreeType(&ft_library);
if (err != 0) {
stdx.panicFmt("freetype error: {}", .{err});
}
}
}
pub fn deinit(self: *Self) void {
self.path_parser.deinit();
self.svg_parser.deinit();
self.text_buf.deinit();
switch (Backend) {
.OpenGL, .Vulkan => self.impl.deinit(),
.WasmCanvas => self.impl.deinit(),
.Test => {},
else => stdx.unsupported(),
}
}
pub fn setCamera(self: *Self, cam: Camera) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.setCamera(&self.impl, cam),
else => stdx.unsupported(),
}
}
/// Shifts origin to x units to the right and y units down.
pub fn translate(self: *Self, x: f32, y: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.translate(&self.impl, x, y),
.WasmCanvas => canvas.Graphics.translate(&self.impl, x, y),
else => stdx.unsupported(),
}
}
pub fn translate3D(self: *Self, x: f32, y: f32, z: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.translate3D(&self.impl, x, y, z),
else => stdx.unsupported(),
}
}
// Scales from origin x units horizontally and y units vertically.
// Negative value flips the axis. Value of 1 does nothing.
pub fn scale(self: *Self, x: f32, y: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.scale(&self.impl, x, y),
.WasmCanvas => canvas.Graphics.scale(&self.impl, x, y),
else => stdx.unsupported(),
}
}
/// Rotates 2D origin by radians clockwise.
pub fn rotate(self: *Self, rad: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.rotateZ(&self.impl, rad),
.WasmCanvas => canvas.Graphics.rotate(&self.impl, rad),
else => stdx.unsupported(),
}
}
pub fn rotateDeg(self: *Self, deg: f32) void {
self.rotate(math.degToRad(deg));
}
pub fn rotateZ(self: *Self, rad: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.rotateZ(&self.impl, rad),
else => stdx.unsupported(),
}
}
pub fn rotateX(self: *Self, rad: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.rotateX(&self.impl, rad),
else => stdx.unsupported(),
}
}
pub fn rotateY(self: *Self, rad: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.rotateY(&self.impl, rad),
else => stdx.unsupported(),
}
}
// Resets the current transform to identity.
pub fn resetTransform(self: *Self) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.resetTransform(&self.impl),
.WasmCanvas => canvas.Graphics.resetTransform(&self.impl),
else => stdx.unsupported(),
}
}
pub inline fn setClearColor(self: *Self, color: Color) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.setClearColor(&self.impl, color),
else => stdx.unsupported(),
}
}
pub inline fn clear(self: Self) void {
switch (Backend) {
.OpenGL => gpu.Graphics.clear(self.impl),
else => stdx.unsupported(),
}
}
pub fn getFillColor(self: Self) Color {
return switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.getFillColor(self.impl),
.WasmCanvas => canvas.Graphics.getFillColor(self.impl),
else => stdx.unsupported(),
};
}
pub fn setFillColor(self: *Self, color: Color) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.setFillColor(&self.impl, color),
.WasmCanvas => canvas.Graphics.setFillColor(&self.impl, color),
else => stdx.unsupported(),
}
}
/// Set a linear gradient fill style.
pub fn setFillGradient(self: *Self, start_x: f32, start_y: f32, start_color: Color, end_x: f32, end_y: f32, end_color: Color) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.setFillGradient(&self.impl, start_x, start_y, start_color, end_x, end_y, end_color),
else => stdx.unsupported(),
}
}
pub fn getStrokeColor(self: Self) Color {
return switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.getStrokeColor(self.impl),
.WasmCanvas => canvas.Graphics.getStrokeColor(self.impl),
else => stdx.unsupported(),
};
}
pub fn setStrokeColor(self: *Self, color: Color) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.setStrokeColor(&self.impl, color),
.WasmCanvas => canvas.Graphics.setStrokeColor(&self.impl, color),
else => stdx.unsupported(),
}
}
pub fn getLineWidth(self: Self) f32 {
return switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.getLineWidth(self.impl),
.WasmCanvas => canvas.Graphics.getLineWidth(self.impl),
else => stdx.unsupported(),
};
}
pub fn setLineWidth(self: *Self, width: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.setLineWidth(&self.impl, width),
.WasmCanvas => canvas.Graphics.setLineWidth(&self.impl, width),
else => stdx.unsupported(),
}
}
pub fn fillRect(self: *Self, x: f32, y: f32, width: f32, height: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.fillRect(&self.impl, x, y, width, height),
.WasmCanvas => canvas.Graphics.fillRect(&self.impl, x, y, width, height),
else => stdx.unsupported(),
}
}
pub fn drawRect(self: *Self, x: f32, y: f32, width: f32, height: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.drawRect(&self.impl, x, y, width, height),
.WasmCanvas => canvas.Graphics.drawRect(&self.impl, x, y, width, height),
else => stdx.unsupported(),
}
}
pub fn fillRoundRect(self: *Self, x: f32, y: f32, width: f32, height: f32, radius: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.fillRoundRect(&self.impl, x, y, width, height, radius),
.WasmCanvas => canvas.Graphics.fillRoundRect(&self.impl, x, y, width, height, radius),
else => stdx.unsupported(),
}
}
pub fn drawRoundRect(self: *Self, x: f32, y: f32, width: f32, height: f32, radius: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.drawRoundRect(&self.impl, x, y, width, height, radius),
.WasmCanvas => canvas.Graphics.drawRoundRect(&self.impl, x, y, width, height, radius),
else => stdx.unsupported(),
}
}
// Radians start at 0 and end at 2pi going clockwise. Negative radians goes counter clockwise.
pub fn fillCircleSector(self: *Self, x: f32, y: f32, radius: f32, start_rad: f32, sweep_rad: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.fillCircleSector(&self.impl, x, y, radius, start_rad, sweep_rad),
.WasmCanvas => canvas.Graphics.fillCircleSector(&self.impl, x, y, radius, start_rad, sweep_rad),
else => stdx.unsupported(),
}
}
pub fn fillCircleSectorDeg(self: *Self, x: f32, y: f32, radius: f32, start_deg: f32, sweep_deg: f32) void {
self.fillCircleSector(x, y, radius, math.degToRad(start_deg), math.degToRad(sweep_deg));
}
// Radians start at 0 and end at 2pi going clockwise. Negative radians goes counter clockwise.
pub fn drawCircleArc(self: *Self, x: f32, y: f32, radius: f32, start_rad: f32, sweep_rad: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.drawCircleArc(&self.impl, x, y, radius, start_rad, sweep_rad),
.WasmCanvas => canvas.Graphics.drawCircleArc(&self.impl, x, y, radius, start_rad, sweep_rad),
else => stdx.unsupported(),
}
}
pub fn drawCircleArcDeg(self: *Self, x: f32, y: f32, radius: f32, start_deg: f32, sweep_deg: f32) void {
self.drawCircleArc(x, y, radius, math.degToRad(start_deg), math.degToRad(sweep_deg));
}
pub fn fillCircle(self: *Self, x: f32, y: f32, radius: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.fillCircle(&self.impl, x, y, radius),
.WasmCanvas => canvas.Graphics.fillCircle(&self.impl, x, y, radius),
else => stdx.unsupported(),
}
}
pub fn drawCircle(self: *Self, x: f32, y: f32, radius: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.drawCircle(&self.impl, x, y, radius),
.WasmCanvas => canvas.Graphics.drawCircle(&self.impl, x, y, radius),
else => stdx.unsupported(),
}
}
pub fn fillEllipse(self: *Self, x: f32, y: f32, h_radius: f32, v_radius: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.fillEllipse(&self.impl, x, y, h_radius, v_radius),
.WasmCanvas => canvas.Graphics.fillEllipse(&self.impl, x, y, h_radius, v_radius),
else => stdx.unsupported(),
}
}
// Radians start at 0 and end at 2pi going clockwise. Negative radians goes counter clockwise.
pub fn fillEllipseSector(self: *Self, x: f32, y: f32, h_radius: f32, v_radius: f32, start_rad: f32, sweep_rad: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.fillEllipseSector(&self.impl, x, y, h_radius, v_radius, start_rad, sweep_rad),
.WasmCanvas => canvas.Graphics.fillEllipseSector(&self.impl, x, y, h_radius, v_radius, start_rad, sweep_rad),
else => stdx.unsupported(),
}
}
pub fn fillEllipseSectorDeg(self: *Self, x: f32, y: f32, h_radius: f32, v_radius: f32, start_deg: f32, sweep_deg: f32) void {
self.fillEllipseSector(x, y, h_radius, v_radius, math.degToRad(start_deg), math.degToRad(sweep_deg));
}
pub fn drawEllipse(self: *Self, x: f32, y: f32, h_radius: f32, v_radius: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.drawEllipse(&self.impl, x, y, h_radius, v_radius),
.WasmCanvas => canvas.Graphics.drawEllipse(&self.impl, x, y, h_radius, v_radius),
else => stdx.unsupported(),
}
}
// Radians start at 0 and end at 2pi going clockwise. Negative radians goes counter clockwise.
pub fn drawEllipseArc(self: *Self, x: f32, y: f32, h_radius: f32, v_radius: f32, start_rad: f32, sweep_rad: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.drawEllipseArc(&self.impl, x, y, h_radius, v_radius, start_rad, sweep_rad),
.WasmCanvas => canvas.Graphics.drawEllipseArc(&self.impl, x, y, h_radius, v_radius, start_rad, sweep_rad),
else => stdx.unsupported(),
}
}
pub fn drawEllipseArcDeg(self: *Self, x: f32, y: f32, h_radius: f32, v_radius: f32, start_deg: f32, sweep_deg: f32) void {
self.drawEllipseArc(x, y, h_radius, v_radius, math.degToRad(start_deg), math.degToRad(sweep_deg));
}
pub fn drawPoint(self: *Self, x: f32, y: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.drawPoint(&self.impl, x, y),
.WasmCanvas => canvas.Graphics.drawPoint(&self.impl, x, y),
else => stdx.unsupported(),
}
}
pub fn drawLine(self: *Self, x1: f32, y1: f32, x2: f32, y2: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.drawLine(&self.impl, x1, y1, x2, y2),
.WasmCanvas => canvas.Graphics.drawLine(&self.impl, x1, y1, x2, y2),
else => stdx.unsupported(),
}
}
pub fn drawCubicBezierCurve(self: *Self, x1: f32, y1: f32, c1x: f32, c1y: f32, c2x: f32, c2y: f32, x2: f32, y2: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.drawCubicBezierCurve(&self.impl, x1, y1, c1x, c1y, c2x, c2y, x2, y2),
.WasmCanvas => canvas.Graphics.drawCubicBezierCurve(&self.impl, x1, y1, c1x, c1y, c2x, c2y, x2, y2),
else => stdx.unsupported(),
}
}
pub fn drawQuadraticBezierCurve(self: *Self, x1: f32, y1: f32, cx: f32, cy: f32, x2: f32, y2: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.drawQuadraticBezierCurve(&self.impl, x1, y1, cx, cy, x2, y2),
.WasmCanvas => canvas.Graphics.drawQuadraticBezierCurve(&self.impl, x1, y1, cx, cy, x2, y2),
else => stdx.unsupported(),
}
}
/// Assumes pts are in ccw order.
pub fn fillTriangle(self: *Self, x1: f32, y1: f32, x2: f32, y2: f32, x3: f32, y3: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.fillTriangle(&self.impl, x1, y1, x2, y2, x3, y3),
.WasmCanvas => canvas.Graphics.fillTriangle(&self.impl, x1, y1, x2, y2, x3, y3),
else => stdx.unsupported(),
}
}
pub fn fillTriangle3D(self: *Self, x1: f32, y1: f32, z1: f32, x2: f32, y2: f32, z2: f32, x3: f32, y3: f32, z3: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.fillTriangle3D(&self.impl, x1, y1, z1, x2, y2, z2, x3, y3, z3),
else => stdx.unsupported(),
}
}
pub fn fillConvexPolygon(self: *Self, pts: []const Vec2) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.fillConvexPolygon(&self.impl, pts),
.WasmCanvas => canvas.Graphics.fillPolygon(&self.impl, pts),
else => stdx.unsupported(),
}
}
pub fn fillPolygon(self: *Self, pts: []const Vec2) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.fillPolygon(&self.impl, pts),
.WasmCanvas => canvas.Graphics.fillPolygon(&self.impl, pts),
else => stdx.unsupported(),
}
}
pub fn drawPolygon(self: *Self, pts: []const Vec2) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.drawPolygon(&self.impl, pts),
.WasmCanvas => canvas.Graphics.drawPolygon(&self.impl, pts),
else => stdx.unsupported(),
}
}
pub fn compileSvgContent(self: *Self, alloc: std.mem.Allocator, str: []const u8) !DrawCommandList {
return try self.svg_parser.parseAlloc(alloc, str);
}
// This is not the recommended way to draw svg content but is available for convenience.
// For small/medium svg content, first parse the svg into a DrawCommandList and reuse that.
// For large svg content, render into an image and then draw the image.
// TODO: allow x, y offset
pub fn drawSvgContent(self: *Self, str: []const u8) !void {
const draw_list = try self.svg_parser.parse(str);
self.executeDrawList(draw_list);
}
// This will be slower since it will parse the text every time.
pub fn fillSvgPathContent(self: *Self, x: f32, y: f32, str: []const u8) !void {
const path = try self.path_parser.parse(str);
self.fillSvgPath(x, y, &path);
}
pub fn drawSvgPathContent(self: *Self, x: f32, y: f32, str: []const u8) !void {
const path = try self.path_parser.parse(str);
self.drawSvgPath(x, y, &path);
}
pub fn fillSvgPath(self: *Self, x: f32, y: f32, path: *const SvgPath) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.fillSvgPath(&self.impl, x, y, path),
.WasmCanvas => canvas.Graphics.fillSvgPath(&self.impl, x, y, path),
else => stdx.unsupported(),
}
}
pub fn drawSvgPath(self: *Self, x: f32, y: f32, path: *const SvgPath) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.strokeSvgPath(&self.impl, x, y, path),
.WasmCanvas => canvas.Graphics.strokeSvgPath(&self.impl, x, y, path),
else => stdx.unsupported(),
}
}
pub fn executeDrawList(self: *Self, _list: DrawCommandList) void {
var list = _list;
for (list.cmds) |ptr| {
switch (ptr.tag) {
.FillColor => {
const cmd = list.getCommand(.FillColor, ptr);
self.setFillColor(Color.fromU32(cmd.rgba));
},
.FillPolygon => {
const cmd = list.getCommand(.FillPolygon, ptr);
const slice = list.getExtraData(cmd.start_vertex_id, cmd.num_vertices * 2);
self.fillPolygon(@ptrCast([*]const Vec2, slice.ptr)[0..cmd.num_vertices]);
},
.FillPath => {
const cmd = list.getCommand(.FillPath, ptr);
var end = cmd.start_path_cmd_id + cmd.num_cmds;
self.fillSvgPath(0, 0, &SvgPath{
.alloc = null,
.data = list.extra_data[cmd.start_data_id..],
.cmds = std.mem.bytesAsSlice(svg.PathCommand, list.sub_cmds)[cmd.start_path_cmd_id..end],
});
},
.FillRect => {
const cmd = list.getCommand(.FillRect, ptr);
self.fillRect(cmd.x, cmd.y, cmd.width, cmd.height);
},
}
}
}
pub fn executeDrawListLyon(self: *Self, _list: DrawCommandList) void {
var list = _list;
for (list.cmds) |ptr| {
switch (ptr.tag) {
.FillColor => {
const cmd = list.getCommand(.FillColor, ptr);
self.setFillColor(Color.fromU32(cmd.rgba));
},
.FillPolygon => {
if (Backend == .OpenGL) {
const cmd = list.getCommand(.FillPolygon, ptr);
const slice = list.getExtraData(cmd.start_vertex_id, cmd.num_vertices * 2);
self.impl.fillPolygonLyon(@ptrCast([*]const Vec2, slice.ptr)[0..cmd.num_vertices]);
}
},
.FillPath => {
if (Backend == .OpenGL) {
const cmd = list.getCommand(.FillPath, ptr);
var end = cmd.start_path_cmd_id + cmd.num_cmds;
self.impl.fillSvgPathLyon(0, 0, &SvgPath{
.alloc = null,
.data = list.extra_data[cmd.start_data_id..],
.cmds = std.mem.bytesAsSlice(svg.PathCommand, list.sub_cmds)[cmd.start_path_cmd_id..end],
});
}
},
.FillRect => {
const cmd = list.getCommand(.FillRect, ptr);
self.fillRect(cmd.x, cmd.y, cmd.width, cmd.height);
},
}
}
}
pub fn executeDrawListTess2(self: *Self, _list: DrawCommandList) void {
var list = _list;
for (list.cmds) |ptr| {
switch (ptr.tag) {
.FillColor => {
const cmd = list.getCommand(.FillColor, ptr);
self.setFillColor(Color.fromU32(cmd.rgba));
},
.FillPolygon => {
if (Backend == .OpenGL) {
const cmd = list.getCommand(.FillPolygon, ptr);
const slice = list.getExtraData(cmd.start_vertex_id, cmd.num_vertices * 2);
self.impl.fillPolygonTess2(@ptrCast([*]const Vec2, slice.ptr)[0..cmd.num_vertices]);
}
},
.FillPath => {
if (Backend == .OpenGL) {
const cmd = list.getCommand(.FillPath, ptr);
var end = cmd.start_path_cmd_id + cmd.num_cmds;
self.impl.fillSvgPathTess2(0, 0, &SvgPath{
.alloc = null,
.data = list.extra_data[cmd.start_data_id..],
.cmds = std.mem.bytesAsSlice(svg.PathCommand, list.sub_cmds)[cmd.start_path_cmd_id..end],
});
}
},
.FillRect => {
const cmd = list.getCommand(.FillRect, ptr);
self.fillRect(cmd.x, cmd.y, cmd.width, cmd.height);
},
}
}
}
pub fn setBlendMode(self: *Self, mode: BlendMode) void {
switch (Backend) {
.OpenGL => return gpu.Graphics.setBlendMode(&self.impl, mode),
.WasmCanvas => return canvas.Graphics.setBlendMode(&self.impl, mode),
else => stdx.unsupported(),
}
}
pub fn createImageFromPathPromise(self: *Self, path: []const u8) stdx.wasm.Promise(Image) {
switch (Backend) {
// Only web wasm is supported.
.WasmCanvas => return canvas.Graphics.createImageFromPathPromise(&self.impl, path),
else => @compileError("unsupported"),
}
}
/// Path can be absolute or relative to cwd.
pub fn createImageFromPath(self: *Self, path: []const u8) !Image {
switch (Backend) {
.OpenGL, .Vulkan => {
const data = try std.fs.cwd().readFileAlloc(self.alloc, path, 30e6);
defer self.alloc.free(data);
return self.createImage(data);
},
.WasmCanvas => stdx.panic("unsupported, use createImageFromPathPromise"),
else => stdx.unsupported(),
}
}
// Loads an image from various data formats.
pub fn createImage(self: *Self, data: []const u8) !Image {
switch (Backend) {
.OpenGL, .Vulkan => return gpu.ImageStore.createImageFromData(&self.impl.image_store, data),
.WasmCanvas => stdx.panic("unsupported, use createImageFromPathPromise"),
else => stdx.unsupported(),
}
}
/// Assumes data is rgba in row major starting from top left of image.
/// If data is null, an empty image will be created. In OpenGL, the empty image will have undefined pixel data.
pub fn createImageFromBitmap(self: *Self, width: usize, height: usize, data: ?[]const u8, linear_filter: bool) ImageId {
switch (Backend) {
.OpenGL, .Vulkan => {
const image = gpu.ImageStore.createImageFromBitmap(&self.impl.image_store, width, height, data, linear_filter);
return image.image_id;
},
else => stdx.unsupported(),
}
}
pub inline fn bindImageBuffer(self: *Self, image_id: ImageId) void {
switch (Backend) {
.OpenGL => gpu.Graphics.bindImageBuffer(&self.impl, image_id),
else => stdx.unsupported(),
}
}
pub fn drawImage(self: *Self, x: f32, y: f32, image_id: ImageId) void {
switch (Backend) {
.OpenGL, .Vulkan => return gpu.Graphics.drawImage(&self.impl, x, y, image_id),
.WasmCanvas => return canvas.Graphics.drawImage(&self.impl, x, y, image_id),
else => stdx.unsupported(),
}
}
pub fn drawImageSized(self: *Self, x: f32, y: f32, width: f32, height: f32, image_id: ImageId) void {
switch (Backend) {
.OpenGL, .Vulkan => return gpu.Graphics.drawImageSized(&self.impl, x, y, width, height, image_id),
.WasmCanvas => return canvas.Graphics.drawImageSized(&self.impl, x, y, width, height, image_id),
else => stdx.unsupported(),
}
}
pub fn drawSubImage(self: *Self, src_x: f32, src_y: f32, src_width: f32, src_height: f32, x: f32, y: f32, width: f32, height: f32, image_id: ImageId) void {
switch (Backend) {
.OpenGL, .Vulkan => return gpu.Graphics.drawSubImage(&self.impl, src_x, src_y, src_width, src_height, x, y, width, height, image_id),
else => stdx.unsupported(),
}
}
pub fn addFallbackFont(self: *Self, font_id: FontId) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.addFallbackFont(&self.impl, font_id),
else => stdx.unsupported(),
}
}
/// Adds .otb bitmap font with data at different font sizes.
pub fn addFontOTB(self: *Self, data: []const BitmapFontData) FontId {
switch (Backend) {
.OpenGL, .Vulkan => return gpu.Graphics.addFontOTB(&self.impl, data),
else => stdx.unsupported(),
}
}
/// Adds outline or color bitmap font from ttf/otf.
pub fn addFontTTF(self: *Self, data: []const u8) FontId {
switch (Backend) {
.OpenGL, .Vulkan => return gpu.Graphics.addFontTTF(&self.impl, data),
.WasmCanvas => stdx.panic("Unsupported for WasmCanvas. Use addTTF_FontPathForName instead."),
else => stdx.unsupported(),
}
}
/// Path can be absolute or relative to cwd.
pub fn addFontFromPathTTF(self: *Self, path: []const u8) !FontId {
const MaxFileSize = 20e6;
const data = try std.fs.cwd().readFileAlloc(self.alloc, path, MaxFileSize);
defer self.alloc.free(data);
return self.addFontTTF(data);
}
/// Wasm/Canvas relies on css to load fonts so it doesn't have access to the font family name.
/// Other backends will just ignore the name arg.
pub fn addFontFromPathCompatTTF(self: *Self, path: []const u8, name: []const u8) !FontId {
switch (Backend) {
.OpenGL, .Vulkan => {
return self.addFontFromPathTTF(path);
},
.WasmCanvas => return canvas.Graphics.addFontFromPathTTF(&self.impl, path, name),
else => stdx.unsupported(),
}
}
pub fn getFontSize(self: *Self) f32 {
switch (Backend) {
.OpenGL, .Vulkan => return gpu.Graphics.getFontSize(self.impl),
else => stdx.unsupported(),
}
}
pub fn setFontSize(self: *Self, font_size: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.setFontSize(&self.impl, font_size),
.WasmCanvas => canvas.Graphics.setFontSize(&self.impl, font_size),
else => stdx.unsupported(),
}
}
pub fn setFont(self: *Self, font_id: FontId, font_size: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => {
gpu.Graphics.setFont(&self.impl, font_id);
gpu.Graphics.setFontSize(&self.impl, font_size);
},
.WasmCanvas => canvas.Graphics.setFont(&self.impl, font_id, font_size),
else => stdx.unsupported(),
}
}
pub fn setFontGroup(self: *Self, font_gid: FontGroupId, font_size: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => {
gpu.Graphics.setFontGroup(&self.impl, font_gid);
gpu.Graphics.setFontSize(&self.impl, font_size);
},
.WasmCanvas => canvas.Graphics.setFontGroup(&self.impl, font_gid, font_size),
else => stdx.unsupported(),
}
}
pub fn setTextAlign(self: *Self, align_: TextAlign) void {
switch (Backend) {
.OpenGL, .Vulkan => {
gpu.Graphics.setTextAlign(&self.impl, align_);
},
else => stdx.unsupported(),
}
}
pub fn setTextBaseline(self: *Self, baseline: TextBaseline) void {
switch (Backend) {
.OpenGL, .Vulkan => {
gpu.Graphics.setTextBaseline(&self.impl, baseline);
},
else => stdx.unsupported(),
}
}
pub fn fillText(self: *Self, x: f32, y: f32, text: []const u8) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.fillText(&self.impl, x, y, text),
.WasmCanvas => canvas.Graphics.fillText(&self.impl, x, y, text),
else => stdx.unsupported(),
}
}
pub fn fillTextFmt(self: *Self, x: f32, y: f32, comptime format: []const u8, args: anytype) void {
self.text_buf.clearRetainingCapacity();
std.fmt.format(self.text_buf.writer(), format, args) catch unreachable;
self.fillText(x, y, self.text_buf.items);
}
/// Measure many text at once.
pub fn measureTextBatch(self: *Self, arr: []*TextMeasure) void {
switch (Backend) {
.OpenGL, .Vulkan => {
for (arr) |measure| {
gpu.Graphics.measureFontText(&self.impl, measure.font_gid, measure.font_size, measure.text, &measure.res);
}
},
.WasmCanvas => canvas.Graphics.measureTexts(&self.impl, arr),
.Test => {},
else => stdx.unsupported(),
}
}
/// Measure the char advance between two codepoints.
pub fn measureCharAdvance(self: *Self, font_gid: FontGroupId, font_size: f32, prev_cp: u21, cp: u21) f32 {
switch (Backend) {
.OpenGL, .Vulkan => return text_renderer.measureCharAdvance(&self.impl.font_cache, &self.impl, font_gid, font_size, prev_cp, cp),
.Test => {
const factor = font_size / self.impl.default_font_size;
return factor * self.impl.default_font_glyph_advance_width;
},
else => stdx.unsupported(),
}
}
/// Measure some text with a given font.
pub fn measureFontText(self: *Self, font_gid: FontGroupId, font_size: f32, str: []const u8, out: *TextMetrics) void {
switch (Backend) {
.OpenGL, .Vulkan => return self.impl.measureFontText(font_gid, font_size, str, out),
else => stdx.unsupported(),
}
}
/// Perform text layout and save the results.
pub fn textLayout(self: *Self, font_gid: FontGroupId, size: f32, str: []const u8, preferred_width: f32, buf: *TextLayout) void {
buf.lines.clearRetainingCapacity();
var iter = self.textGlyphIter(font_gid, size, str);
var y: f32 = 0;
var last_fit_start_idx: u32 = 0;
var last_fit_end_idx: u32 = 0;
var last_fit_x: f32 = 0;
var x: f32 = 0;
var max_width: f32 = 0;
while (iter.nextCodepoint()) {
x += iter.state.kern;
// Assume snapping.
x = @round(x);
x += iter.state.advance_width;
if (iter.state.cp == 10) {
// Line feed. Force new line.
buf.lines.append(.{
.start_idx = last_fit_start_idx,
.end_idx = @intCast(u32, iter.state.end_idx - 1), // Exclude new line.
.height = iter.primary_height,
}) catch @panic("error");
last_fit_start_idx = @intCast(u32, iter.state.end_idx);
last_fit_end_idx = @intCast(u32, iter.state.end_idx);
if (x > max_width) {
max_width = x;
}
x = 0;
y += iter.primary_height;
continue;
}
if (x <= preferred_width) {
if (stdx.unicode.isSpace(iter.state.cp)) {
// Space character indicates the end of a word.
last_fit_end_idx = @intCast(u32, iter.state.end_idx);
}
} else {
if (last_fit_start_idx == last_fit_end_idx) {
// Haven't fit a word yet. Just keep going.
} else {
// Wrap to next line.
buf.lines.append(.{
.start_idx = last_fit_start_idx,
.end_idx = last_fit_end_idx,
.height = iter.primary_height,
}) catch @panic("error");
y += iter.primary_height;
last_fit_start_idx = last_fit_end_idx;
last_fit_x = 0;
if (x > max_width) {
max_width = x;
}
x = 0;
iter.setIndex(last_fit_start_idx);
}
}
}
if (last_fit_end_idx < iter.state.end_idx) {
// Add last line.
buf.lines.append(.{
.start_idx = last_fit_start_idx,
.end_idx = @intCast(u32, iter.state.end_idx),
.height = iter.primary_height,
}) catch @panic("error");
if (x > max_width) {
max_width = x;
}
y += iter.primary_height;
}
buf.width = max_width;
buf.height = y;
}
/// Return a text glyph iterator over UTF-8 string.
pub inline fn textGlyphIter(self: *Self, font_gid: FontGroupId, size: f32, str: []const u8) TextGlyphIterator {
switch (Backend) {
.OpenGL, .Vulkan => {
return gpu.Graphics.textGlyphIter(&self.impl, font_gid, size, str);
},
.Test => {
var iter: TextGlyphIterator = undefined;
iter.inner = testg.TextGlyphIterator.init(str, size, &self.impl);
return iter;
},
else => stdx.unsupported(),
}
}
pub inline fn getPrimaryFontVMetrics(self: *Self, font_gid: FontGroupId, font_size: f32) VMetrics {
switch (Backend) {
.OpenGL, .Vulkan => return FontCache.getPrimaryFontVMetrics(&self.impl.font_cache, font_gid, font_size),
.WasmCanvas => return canvas.Graphics.getPrimaryFontVMetrics(&self.impl, font_gid, font_size),
.Test => {
const factor = font_size / self.impl.default_font_size;
return .{
.ascender = factor * self.impl.default_font_metrics.ascender,
.descender = 0,
.height = factor * self.impl.default_font_metrics.height,
.line_gap = factor * self.impl.default_font_metrics.line_gap,
};
},
else => stdx.unsupported(),
}
}
pub inline fn getFontVMetrics(self: *Self, font_id: FontId, font_size: f32) VMetrics {
switch (Backend) {
.OpenGL, .Vulkan => return FontCache.getFontVMetrics(&self.impl.font_cache, font_id, font_size),
else => stdx.unsupported(),
}
}
pub inline fn getDefaultFontId(self: *Self) FontId {
switch (Backend) {
.OpenGL, .Vulkan => return self.impl.default_font_id,
.Test => return self.impl.default_font_id,
else => stdx.unsupported(),
}
}
pub inline fn getDefaultFontGroupId(self: *Self) FontGroupId {
switch (Backend) {
.OpenGL, .Vulkan => return self.impl.default_font_gid,
.Test => return self.impl.default_font_gid,
else => stdx.unsupported(),
}
}
pub fn getFontByName(self: *Self, name: []const u8) ?FontId {
switch (Backend) {
.OpenGL, .Vulkan => return FontCache.getFontId(&self.impl.font_cache, name),
.WasmCanvas => return canvas.Graphics.getFontByName(&self.impl, name),
else => stdx.unsupported(),
}
}
pub inline fn getFontGroupForSingleFont(self: *Self, font_id: FontId) FontGroupId {
switch (Backend) {
.OpenGL, .Vulkan => return FontCache.getOrLoadFontGroup(&self.impl.font_cache, &.{font_id}),
else => stdx.unsupported(),
}
}
pub fn getFontGroupByFamily(self: *Self, family: FontFamily) FontGroupId {
switch (Backend) {
.OpenGL, .Vulkan => return gpu.Graphics.getOrLoadFontGroupByFamily(&self.impl, family),
else => stdx.unsupported(),
}
}
pub fn getFontGroupBySingleFontName(self: *Self, name: []const u8) FontGroupId {
switch (Backend) {
.OpenGL, .Vulkan => return FontCache.getOrLoadFontGroupByNameSeq(&self.impl.font_cache, &.{name}).?,
.WasmCanvas => stdx.panic("TODO"),
.Test => return testg.Graphics.getFontGroupBySingleFontName(&self.impl, name),
}
}
pub fn getOrLoadFontGroupByNameSeq(self: *Self, names: []const []const u8) ?FontGroupId {
switch (Backend) {
.OpenGL, .Vulkan => return FontCache.getOrLoadFontGroupByNameSeq(&self.impl.font_cache, names),
.Test => return self.impl.default_font_gid,
else => stdx.unsupported(),
}
}
pub fn pushState(self: *Self) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.pushState(&self.impl),
.WasmCanvas => canvas.Graphics.save(&self.impl),
else => stdx.unsupported(),
}
}
pub fn clipRect(self: *Self, x: f32, y: f32, width: f32, height: f32) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.clipRect(&self.impl, x, y, width, height),
.WasmCanvas => canvas.Graphics.clipRect(&self.impl, x, y, width, height),
else => stdx.unsupported(),
}
}
pub fn popState(self: *Self) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.popState(&self.impl),
.WasmCanvas => canvas.Graphics.restore(&self.impl),
else => stdx.unsupported(),
}
}
pub fn getViewTransform(self: Self) Transform {
switch (Backend) {
.OpenGL, .Vulkan => return gpu.Graphics.getViewTransform(self.impl),
else => stdx.unsupported(),
}
}
pub inline fn drawPlane(self: *Self) void {
switch (Backend) {
.Vulkan => gpu.Graphics.drawPlane(&self.impl),
else => stdx.unsupported(),
}
}
/// End the current batched draw command.
/// OpenGL will flush, while Vulkan will record the command.
pub inline fn endCmd(self: *Self) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.endCmd(&self.impl),
.WasmCanvas => {},
else => stdx.unsupported(),
}
}
pub fn loadGLTF(self: Self, buf: []const u8) !HandleGLTF {
_ = self;
var opts = std.mem.zeroInit(cgltf.cgltf_options, .{});
var data: *cgltf.cgltf_data = undefined;
const res = cgltf.parse(&opts, buf.ptr, buf.len, &data);
if (res == cgltf.cgltf_result_success) {
return HandleGLTF{
.data = data,
.loaded_buffers = false,
};
} else {
return error.FailedToLoad;
}
}
/// Pushes the mesh without modifying the vertex data.
pub fn drawMesh3D(self: *Self, xform: Transform, verts: []const gpu.TexShaderVertex, indexes: []const u16) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.drawMesh3D(&self.impl, xform, verts, indexes),
else => unsupported(),
}
}
/// Draws the mesh with the current fill color.
pub fn fillMesh3D(self: *Self, xform: Transform, verts: []const gpu.TexShaderVertex, indexes: []const u16) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.fillMesh3D(&self.impl, xform, verts, indexes),
else => unsupported(),
}
}
/// Draws a wireframe around the mesh with the current stroke color.
pub fn strokeMesh3D(self: *Self, xform: Transform, verts: []const gpu.TexShaderVertex, indexes: []const u16) void {
switch (Backend) {
.OpenGL, .Vulkan => gpu.Graphics.strokeMesh3D(&self.impl, xform, verts, indexes),
else => unsupported(),
}
}
};
pub const LoadBuffersOptionsGLTF = struct {
static_buffer_map: ?std.StringHashMap([]const u8) = null,
root_path: [:0]const u8 = "",
};
pub const HandleGLTF = struct {
data: *cgltf.cgltf_data,
loaded_buffers: bool,
const Self = @This();
pub fn deinit(self: Self) void {
cgltf.cgltf_free(self.data);
}
// pub fn loadBuffers(self: *Self) void {
// if (!self.loaded_buffers) {
// var opts = std.mem.zeroInit(cgltf.cgltf_options, .{});
// const res = cgltf.cgltf_load_buffers(&opts, self.data,);
// // * const char* gltf_path)` can be optionally called to open and read buffer
// self.loaded_buffers = true;
// }
// }
/// Custom loadBuffers since cgltf.cgltf_load_buffers makes it inconvenient to use adhoc embedded buffers.
pub fn loadBuffers(self: *Self, opts: LoadBuffersOptionsGLTF) !void {
// var copts = std.mem.zeroInit(cgltf.cgltf_options, .{});
if (!self.loaded_buffers) {
var i: u32 = 0;
while (i < self.data.buffers_count) : (i += 1) {
if (self.data.buffers[i].data == null) {
const uri = self.data.buffers[i].uri;
if (opts.static_buffer_map) |map| {
const uri_slice = std.mem.span(uri);
if (map.get(uri_slice)) |buf| {
self.data.buffers[i].data = @intToPtr([*c]u8, @ptrToInt(buf.ptr));
// Don't auto free for static buffers.
self.data.buffers[i].data_free_method = cgltf.cgltf_data_free_method_none;
continue;
}
}
// Use default loader.
// const res = cgltf.cgltf_load_buffer_file(copts, self.data.buffers[i].size, uri, opts.root_path, &self.data.buffers[i].data);
// self.data.buffers[i].data_free_method = cgltf.cgltf_data_free_method_file_release;
// if (res != cgltf.cgltf_result_success) {
// return error.FailedToLoadFile;
// }
}
}
self.loaded_buffers = true;
}
}
pub fn loadNode(self: *Self, alloc: std.mem.Allocator, idx: u32) !NodeGLTF {
if (idx >= self.data.nodes_count) {
return error.NoSuchElement;
}
if (!self.loaded_buffers) {
return error.BuffersNotLoaded;
}
_ = alloc;
const node = self.data.nodes[idx];
// For now just look for the first node with a mesh.
if (node.mesh != null) {
unreachable;
} else {
if (node.children_count > 0) {
var i: u32 = 0;
while (i < node.children_count) : (i += 1) {
const child = node.children[i][0];
if (child.mesh != null) {
const mesh = @ptrCast(*cgltf.cgltf_mesh, child.mesh);
if (mesh.primitives_count > 0) {
const primitive = mesh.primitives[0];
const indices = @ptrCast(*cgltf.cgltf_accessor, primitive.indices);
var ii: u32 = 0;
const indexes = alloc.alloc(u16, indices.count) catch fatal();
while (ii < indices.count) : (ii += 1) {
indexes[ii] = @intCast(u16, cgltf.cgltf_accessor_read_index(indices, ii));
}
// Determine number of verts by looking at the first attribute.
var verts: []gpu.TexShaderVertex = undefined;
if (primitive.attributes_count > 0) {
const count = primitive.attributes[0].data[0].count;
verts = alloc.alloc(gpu.TexShaderVertex, count) catch fatal();
} else return error.NoNumVerts;
var ai: u32 = 0;
while (ai < primitive.attributes_count) : (ai += 1) {
const attr = primitive.attributes[ai];
const accessor = @ptrCast(*cgltf.cgltf_accessor, attr.data);
const component_type = accessor.component_type;
if (accessor.count != verts.len) {
return error.NumVertsMismatch;
}
const byte_offset = accessor.offset;
const stride = accessor.stride;
_ = byte_offset;
_ = stride;
switch (attr.@"type") {
cgltf.cgltf_attribute_type_normal => {
const buf_view = accessor.buffer_view[0];
const buf = buf_view.buffer[0];
// Skip for now.
_ = buf_view;
_ = buf;
},
cgltf.cgltf_attribute_type_position => {
if (component_type == cgltf.cgltf_component_type_r_32f) {
const num_component_vals = cgltf.cgltf_num_components(accessor.@"type");
const num_floats = num_component_vals * accessor.count;
const val_buf = alloc.alloc(cgltf.cgltf_float, num_floats) catch fatal();
defer alloc.free(val_buf);
_ = cgltf.cgltf_accessor_unpack_floats(accessor, val_buf.ptr, num_floats);
var vi: u32 = 0;
while (vi < verts.len) : (vi += 1) {
verts[vi].setXYZ(
val_buf[vi * num_component_vals],
val_buf[vi * num_component_vals + 1],
val_buf[vi * num_component_vals + 2],
);
verts[vi].setColor(Color.White);
}
} else {
return error.UnsupportedComponentType;
}
},
else => {},
}
}
return NodeGLTF{
.verts = verts,
.indexes = indexes,
};
}
log.debug("{s}", .{mesh.name});
unreachable;
}
}
}
}
return error.NoMesh;
}
};
pub const NodeGLTF = struct {
verts: []const gpu.TexShaderVertex,
indexes: []const u16,
pub fn deinit(self: NodeGLTF, alloc: std.mem.Allocator) void {
alloc.free(self.verts);
alloc.free(self.indexes);
}
};
// TOOL: https://www.andersriggelsen.dk/glblendfunc.php
pub const BlendMode = enum {
// TODO: Correct alpha blending without premultiplied colors would need to do:
// gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
// Common
StraightAlpha,
PremultipliedAlpha,
Glow,
Additive,
Multiplied,
Add,
Subtract,
Opaque,
// TODO: Porter-Duff
Src,
SrcATop,
SrcOver,
SrcIn,
SrcOut,
Dst,
DstATop,
DstOver,
DstIn,
DstOut,
Clear,
Xor,
// For internal use.
_undefined,
};
// Vertical metrics that have been scaled to client font size scale.
pub const VMetrics = struct {
// max distance above baseline (positive units)
ascender: f32,
// max distance below baseline (negative units)
descender: f32,
// gap between the previous row's descent and current row's ascent.
line_gap: f32,
// Should be ascender + descender.
height: f32,
};
pub const ImageId = u32;
pub const Image = struct {
id: ImageId,
width: usize,
height: usize,
};
pub const TextAlign = enum {
Left,
Center,
Right,
};
pub const TextBaseline = enum {
Top,
Middle,
Alphabetic,
Bottom,
};
pub const BitmapFontData = struct {
data: []const u8,
size: u8,
};
pub const FontFamily = union(enum) {
Name: []const u8,
FontGroup: FontGroupId,
Font: FontId,
Default: void,
};
|
graphics/src/graphics.zig
|
const std = @import("../std.zig");
const debug = std.debug;
const assert = debug.assert;
const testing = std.testing;
const mem = std.mem;
const Allocator = mem.Allocator;
fn never_index_default(name: []const u8) bool {
if (mem.eql(u8, "authorization", name)) return true;
if (mem.eql(u8, "proxy-authorization", name)) return true;
if (mem.eql(u8, "cookie", name)) return true;
if (mem.eql(u8, "set-cookie", name)) return true;
return false;
}
const HeaderEntry = struct {
name: []const u8,
value: []u8,
never_index: bool,
const Self = @This();
fn init(allocator: *Allocator, name: []const u8, value: []const u8, never_index: ?bool) !Self {
return Self{
.name = name, // takes reference
.value = try allocator.dupe(u8, value),
.never_index = never_index orelse never_index_default(name),
};
}
fn deinit(self: Self, allocator: *Allocator) void {
allocator.free(self.value);
}
pub fn modify(self: *Self, allocator: *Allocator, value: []const u8, never_index: ?bool) !void {
const old_len = self.value.len;
if (value.len > old_len) {
self.value = try allocator.realloc(self.value, value.len);
} else if (value.len < old_len) {
self.value = allocator.shrink(self.value, value.len);
}
mem.copy(u8, self.value, value);
self.never_index = never_index orelse never_index_default(self.name);
}
fn compare(context: void, a: HeaderEntry, b: HeaderEntry) bool {
if (a.name.ptr != b.name.ptr and a.name.len != b.name.len) {
// Things beginning with a colon *must* be before others
const a_is_colon = a.name[0] == ':';
const b_is_colon = b.name[0] == ':';
if (a_is_colon and !b_is_colon) {
return true;
} else if (!a_is_colon and b_is_colon) {
return false;
}
// Sort lexicographically on header name
return mem.order(u8, a.name, b.name) == .lt;
}
// Sort lexicographically on header value
if (!mem.eql(u8, a.value, b.value)) {
return mem.order(u8, a.value, b.value) == .lt;
}
// Doesn't matter here; need to pick something for sort consistency
return a.never_index;
}
};
test "HeaderEntry" {
var e = try HeaderEntry.init(testing.allocator, "foo", "bar", null);
defer e.deinit(testing.allocator);
testing.expectEqualSlices(u8, "foo", e.name);
testing.expectEqualSlices(u8, "bar", e.value);
testing.expectEqual(false, e.never_index);
try e.modify(testing.allocator, "longer value", null);
testing.expectEqualSlices(u8, "longer value", e.value);
// shorter value
try e.modify(testing.allocator, "x", null);
testing.expectEqualSlices(u8, "x", e.value);
}
const HeaderList = std.ArrayListUnmanaged(HeaderEntry);
const HeaderIndexList = std.ArrayListUnmanaged(usize);
const HeaderIndex = std.StringHashMapUnmanaged(HeaderIndexList);
pub const Headers = struct {
// the owned header field name is stored in the index as part of the key
allocator: *Allocator,
data: HeaderList,
index: HeaderIndex,
const Self = @This();
pub fn init(allocator: *Allocator) Self {
return Self{
.allocator = allocator,
.data = HeaderList{},
.index = HeaderIndex{},
};
}
pub fn deinit(self: *Self) void {
{
var it = self.index.iterator();
while (it.next()) |entry| {
entry.value.deinit(self.allocator);
self.allocator.free(entry.key);
}
self.index.deinit(self.allocator);
}
{
for (self.data.items) |entry| {
entry.deinit(self.allocator);
}
self.data.deinit(self.allocator);
}
self.* = undefined;
}
pub fn clone(self: Self, allocator: *Allocator) !Self {
var other = Headers.init(allocator);
errdefer other.deinit();
try other.data.ensureCapacity(allocator, self.data.items.len);
try other.index.initCapacity(allocator, self.index.entries.len);
for (self.data.items) |entry| {
try other.append(entry.name, entry.value, entry.never_index);
}
return other;
}
pub fn toSlice(self: Self) []const HeaderEntry {
return self.data.items;
}
pub fn append(self: *Self, name: []const u8, value: []const u8, never_index: ?bool) !void {
const n = self.data.items.len + 1;
try self.data.ensureCapacity(self.allocator, n);
var entry: HeaderEntry = undefined;
if (self.index.getEntry(name)) |kv| {
entry = try HeaderEntry.init(self.allocator, kv.key, value, never_index);
errdefer entry.deinit(self.allocator);
const dex = &kv.value;
try dex.append(self.allocator, n - 1);
} else {
const name_dup = try self.allocator.dupe(u8, name);
errdefer self.allocator.free(name_dup);
entry = try HeaderEntry.init(self.allocator, name_dup, value, never_index);
errdefer entry.deinit(self.allocator);
var dex = HeaderIndexList{};
try dex.append(self.allocator, n - 1);
errdefer dex.deinit(self.allocator);
_ = try self.index.put(self.allocator, name_dup, dex);
}
self.data.appendAssumeCapacity(entry);
}
/// If the header already exists, replace the current value, otherwise append it to the list of headers.
/// If the header has multiple entries then returns an error.
pub fn upsert(self: *Self, name: []const u8, value: []const u8, never_index: ?bool) !void {
if (self.index.get(name)) |kv| {
const dex = kv.value;
if (dex.len != 1)
return error.CannotUpsertMultiValuedField;
var e = &self.data.at(dex.at(0));
try e.modify(value, never_index);
} else {
try self.append(name, value, never_index);
}
}
/// Returns boolean indicating if the field is present.
pub fn contains(self: Self, name: []const u8) bool {
return self.index.contains(name);
}
/// Returns boolean indicating if something was deleted.
pub fn delete(self: *Self, name: []const u8) bool {
if (self.index.remove(name)) |*kv| {
const dex = &kv.value;
// iterate backwards
var i = dex.items.len;
while (i > 0) {
i -= 1;
const data_index = dex.items[i];
const removed = self.data.orderedRemove(data_index);
assert(mem.eql(u8, removed.name, name));
removed.deinit(self.allocator);
}
dex.deinit(self.allocator);
self.allocator.free(kv.key);
self.rebuildIndex();
return true;
} else {
return false;
}
}
/// Removes the element at the specified index.
/// Moves items down to fill the empty space.
/// TODO this implementation can be replaced by adding
/// orderedRemove to the new hash table implementation as an
/// alternative to swapRemove.
pub fn orderedRemove(self: *Self, i: usize) void {
const removed = self.data.orderedRemove(i);
const kv = self.index.getEntry(removed.name).?;
const dex = &kv.value;
if (dex.items.len == 1) {
// was last item; delete the index
dex.deinit(self.allocator);
removed.deinit(self.allocator);
const key = kv.key;
_ = self.index.remove(key); // invalidates `kv` and `dex`
self.allocator.free(key);
} else {
dex.shrink(self.allocator, dex.items.len - 1);
removed.deinit(self.allocator);
}
// if it was the last item; no need to rebuild index
if (i != self.data.items.len) {
self.rebuildIndex();
}
}
/// Removes the element at the specified index.
/// The empty slot is filled from the end of the list.
/// TODO this implementation can be replaced by simply using the
/// new hash table which does swap removal.
pub fn swapRemove(self: *Self, i: usize) void {
const removed = self.data.swapRemove(i);
const kv = self.index.getEntry(removed.name).?;
const dex = &kv.value;
if (dex.items.len == 1) {
// was last item; delete the index
dex.deinit(self.allocator);
removed.deinit(self.allocator);
const key = kv.key;
_ = self.index.remove(key); // invalidates `kv` and `dex`
self.allocator.free(key);
} else {
dex.shrink(self.allocator, dex.items.len - 1);
removed.deinit(self.allocator);
}
// if it was the last item; no need to rebuild index
if (i != self.data.items.len) {
self.rebuildIndex();
}
}
/// Access the header at the specified index.
pub fn at(self: Self, i: usize) HeaderEntry {
return self.data.items[i];
}
/// Returns a list of indices containing headers with the given name.
/// The returned list should not be modified by the caller.
pub fn getIndices(self: Self, name: []const u8) ?HeaderIndexList {
return self.index.get(name);
}
/// Returns a slice containing each header with the given name.
pub fn get(self: Self, allocator: *Allocator, name: []const u8) !?[]const HeaderEntry {
const dex = self.getIndices(name) orelse return null;
const buf = try allocator.alloc(HeaderEntry, dex.items.len);
var n: usize = 0;
for (dex.items) |idx| {
buf[n] = self.data.items[idx];
n += 1;
}
return buf;
}
/// Returns all headers with the given name as a comma separated string.
///
/// Useful for HTTP headers that follow RFC-7230 section 3.2.2:
/// A recipient MAY combine multiple header fields with the same field
/// name into one "field-name: field-value" pair, without changing the
/// semantics of the message, by appending each subsequent field value to
/// the combined field value in order, separated by a comma. The order
/// in which header fields with the same field name are received is
/// therefore significant to the interpretation of the combined field
/// value
pub fn getCommaSeparated(self: Self, allocator: *Allocator, name: []const u8) !?[]u8 {
const dex = self.getIndices(name) orelse return null;
// adapted from mem.join
const total_len = blk: {
var sum: usize = dex.items.len - 1; // space for separator(s)
for (dex.items) |idx|
sum += self.data.items[idx].value.len;
break :blk sum;
};
const buf = try allocator.alloc(u8, total_len);
errdefer allocator.free(buf);
const first_value = self.data.items[dex.items[0]].value;
mem.copy(u8, buf, first_value);
var buf_index: usize = first_value.len;
for (dex.items[1..]) |idx| {
const value = self.data.items[idx].value;
buf[buf_index] = ',';
buf_index += 1;
mem.copy(u8, buf[buf_index..], value);
buf_index += value.len;
}
// No need for shrink since buf is exactly the correct size.
return buf;
}
fn rebuildIndex(self: *Self) void {
// clear out the indexes
var it = self.index.iterator();
while (it.next()) |entry| {
entry.value.shrinkRetainingCapacity(0);
}
// fill up indexes again; we know capacity is fine from before
for (self.data.items) |entry, i| {
self.index.getEntry(entry.name).?.value.appendAssumeCapacity(i);
}
}
pub fn sort(self: *Self) void {
std.sort.sort(HeaderEntry, self.data.items, {}, HeaderEntry.compare);
self.rebuildIndex();
}
pub fn format(
self: Self,
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
out_stream: anytype,
) !void {
for (self.toSlice()) |entry| {
try out_stream.writeAll(entry.name);
try out_stream.writeAll(": ");
try out_stream.writeAll(entry.value);
try out_stream.writeAll("\n");
}
}
};
test "Headers.iterator" {
var h = Headers.init(testing.allocator);
defer h.deinit();
try h.append("foo", "bar", null);
try h.append("cookie", "somevalue", null);
var count: i32 = 0;
for (h.toSlice()) |e| {
if (count == 0) {
testing.expectEqualSlices(u8, "foo", e.name);
testing.expectEqualSlices(u8, "bar", e.value);
testing.expectEqual(false, e.never_index);
} else if (count == 1) {
testing.expectEqualSlices(u8, "cookie", e.name);
testing.expectEqualSlices(u8, "somevalue", e.value);
testing.expectEqual(true, e.never_index);
}
count += 1;
}
testing.expectEqual(@as(i32, 2), count);
}
test "Headers.contains" {
var h = Headers.init(testing.allocator);
defer h.deinit();
try h.append("foo", "bar", null);
try h.append("cookie", "somevalue", null);
testing.expectEqual(true, h.contains("foo"));
testing.expectEqual(false, h.contains("flooble"));
}
test "Headers.delete" {
var h = Headers.init(testing.allocator);
defer h.deinit();
try h.append("foo", "bar", null);
try h.append("baz", "qux", null);
try h.append("cookie", "somevalue", null);
testing.expectEqual(false, h.delete("not-present"));
testing.expectEqual(@as(usize, 3), h.toSlice().len);
testing.expectEqual(true, h.delete("foo"));
testing.expectEqual(@as(usize, 2), h.toSlice().len);
{
const e = h.at(0);
testing.expectEqualSlices(u8, "baz", e.name);
testing.expectEqualSlices(u8, "qux", e.value);
testing.expectEqual(false, e.never_index);
}
{
const e = h.at(1);
testing.expectEqualSlices(u8, "cookie", e.name);
testing.expectEqualSlices(u8, "somevalue", e.value);
testing.expectEqual(true, e.never_index);
}
testing.expectEqual(false, h.delete("foo"));
}
test "Headers.orderedRemove" {
var h = Headers.init(testing.allocator);
defer h.deinit();
try h.append("foo", "bar", null);
try h.append("baz", "qux", null);
try h.append("cookie", "somevalue", null);
h.orderedRemove(0);
testing.expectEqual(@as(usize, 2), h.toSlice().len);
{
const e = h.at(0);
testing.expectEqualSlices(u8, "baz", e.name);
testing.expectEqualSlices(u8, "qux", e.value);
testing.expectEqual(false, e.never_index);
}
{
const e = h.at(1);
testing.expectEqualSlices(u8, "cookie", e.name);
testing.expectEqualSlices(u8, "somevalue", e.value);
testing.expectEqual(true, e.never_index);
}
}
test "Headers.swapRemove" {
var h = Headers.init(testing.allocator);
defer h.deinit();
try h.append("foo", "bar", null);
try h.append("baz", "qux", null);
try h.append("cookie", "somevalue", null);
h.swapRemove(0);
testing.expectEqual(@as(usize, 2), h.toSlice().len);
{
const e = h.at(0);
testing.expectEqualSlices(u8, "cookie", e.name);
testing.expectEqualSlices(u8, "somevalue", e.value);
testing.expectEqual(true, e.never_index);
}
{
const e = h.at(1);
testing.expectEqualSlices(u8, "baz", e.name);
testing.expectEqualSlices(u8, "qux", e.value);
testing.expectEqual(false, e.never_index);
}
}
test "Headers.at" {
var h = Headers.init(testing.allocator);
defer h.deinit();
try h.append("foo", "bar", null);
try h.append("cookie", "somevalue", null);
{
const e = h.at(0);
testing.expectEqualSlices(u8, "foo", e.name);
testing.expectEqualSlices(u8, "bar", e.value);
testing.expectEqual(false, e.never_index);
}
{
const e = h.at(1);
testing.expectEqualSlices(u8, "cookie", e.name);
testing.expectEqualSlices(u8, "somevalue", e.value);
testing.expectEqual(true, e.never_index);
}
}
test "Headers.getIndices" {
var h = Headers.init(testing.allocator);
defer h.deinit();
try h.append("foo", "bar", null);
try h.append("set-cookie", "x=1", null);
try h.append("set-cookie", "y=2", null);
testing.expect(null == h.getIndices("not-present"));
testing.expectEqualSlices(usize, &[_]usize{0}, h.getIndices("foo").?.items);
testing.expectEqualSlices(usize, &[_]usize{ 1, 2 }, h.getIndices("set-cookie").?.items);
}
test "Headers.get" {
var h = Headers.init(testing.allocator);
defer h.deinit();
try h.append("foo", "bar", null);
try h.append("set-cookie", "x=1", null);
try h.append("set-cookie", "y=2", null);
{
const v = try h.get(testing.allocator, "not-present");
testing.expect(null == v);
}
{
const v = (try h.get(testing.allocator, "foo")).?;
defer testing.allocator.free(v);
const e = v[0];
testing.expectEqualSlices(u8, "foo", e.name);
testing.expectEqualSlices(u8, "bar", e.value);
testing.expectEqual(false, e.never_index);
}
{
const v = (try h.get(testing.allocator, "set-cookie")).?;
defer testing.allocator.free(v);
{
const e = v[0];
testing.expectEqualSlices(u8, "set-cookie", e.name);
testing.expectEqualSlices(u8, "x=1", e.value);
testing.expectEqual(true, e.never_index);
}
{
const e = v[1];
testing.expectEqualSlices(u8, "set-cookie", e.name);
testing.expectEqualSlices(u8, "y=2", e.value);
testing.expectEqual(true, e.never_index);
}
}
}
test "Headers.getCommaSeparated" {
var h = Headers.init(testing.allocator);
defer h.deinit();
try h.append("foo", "bar", null);
try h.append("set-cookie", "x=1", null);
try h.append("set-cookie", "y=2", null);
{
const v = try h.getCommaSeparated(testing.allocator, "not-present");
testing.expect(null == v);
}
{
const v = (try h.getCommaSeparated(testing.allocator, "foo")).?;
defer testing.allocator.free(v);
testing.expectEqualSlices(u8, "bar", v);
}
{
const v = (try h.getCommaSeparated(testing.allocator, "set-cookie")).?;
defer testing.allocator.free(v);
testing.expectEqualSlices(u8, "x=1,y=2", v);
}
}
test "Headers.sort" {
var h = Headers.init(testing.allocator);
defer h.deinit();
try h.append("foo", "bar", null);
try h.append("cookie", "somevalue", null);
h.sort();
{
const e = h.at(0);
testing.expectEqualSlices(u8, "cookie", e.name);
testing.expectEqualSlices(u8, "somevalue", e.value);
testing.expectEqual(true, e.never_index);
}
{
const e = h.at(1);
testing.expectEqualSlices(u8, "foo", e.name);
testing.expectEqualSlices(u8, "bar", e.value);
testing.expectEqual(false, e.never_index);
}
}
test "Headers.format" {
var h = Headers.init(testing.allocator);
defer h.deinit();
try h.append("foo", "bar", null);
try h.append("cookie", "somevalue", null);
var buf: [100]u8 = undefined;
testing.expectEqualSlices(u8,
\\foo: bar
\\cookie: somevalue
\\
, try std.fmt.bufPrint(buf[0..], "{}", .{h}));
}
|
lib/std/http/headers.zig
|
const std = @import("std");
const getty = @import("getty");
const assert = std.debug.assert;
const expectEqual = std.testing.expectEqual;
const expectEqualSlices = std.testing.expectEqualSlices;
const Token = @import("common/token.zig").Token;
pub const Serializer = struct {
tokens: []const Token,
const Self = @This();
pub fn init(tokens: []const Token) Self {
return .{ .tokens = tokens };
}
pub fn remaining(self: Self) usize {
return self.tokens.len;
}
pub fn nextTokenOpt(self: *Self) ?Token {
switch (self.remaining()) {
0 => return null,
else => |len| {
const first = self.tokens[0];
self.tokens = if (len == 1) &[_]Token{} else self.tokens[1..];
return first;
},
}
}
pub usingnamespace getty.Serializer(
*Self,
Ok,
Error,
getty.default_st,
getty.default_st,
Map,
Seq,
Struct,
serializeBool,
serializeEnum,
serializeFloat,
serializeInt,
serializeMap,
serializeNull,
serializeSeq,
serializeSome,
serializeString,
serializeStruct,
serializeVoid,
);
const Ok = void;
const Error = std.mem.Allocator.Error || error{TestExpectedEqual};
fn serializeBool(self: *Self, v: bool) Error!Ok {
try assertNextToken(self, Token{ .Bool = v });
}
fn serializeEnum(self: *Self, v: anytype) Error!Ok {
try assertNextToken(self, Token{ .Enum = {} });
try assertNextToken(self, Token{ .String = @tagName(v) });
}
fn serializeFloat(self: *Self, v: anytype) Error!Ok {
var expected = switch (@typeInfo(@TypeOf(v))) {
.ComptimeFloat => Token{ .ComptimeFloat = {} },
.Float => |info| switch (info.bits) {
16 => Token{ .F16 = v },
32 => Token{ .F32 = v },
64 => Token{ .F64 = v },
128 => Token{ .F128 = v },
else => @panic("unexpected float size"),
},
else => @panic("unexpected type"),
};
try assertNextToken(self, expected);
}
fn serializeInt(self: *Self, v: anytype) Error!Ok {
var expected = switch (@typeInfo(@TypeOf(v))) {
.ComptimeInt => Token{ .ComptimeInt = {} },
.Int => |info| switch (info.signedness) {
.signed => switch (info.bits) {
8 => Token{ .I8 = v },
16 => Token{ .I16 = v },
32 => Token{ .I32 = v },
64 => Token{ .I64 = v },
128 => Token{ .I128 = v },
else => @panic("unexpected integer size"),
},
.unsigned => switch (info.bits) {
8 => Token{ .U8 = v },
16 => Token{ .U16 = v },
32 => Token{ .U32 = v },
64 => Token{ .U64 = v },
128 => Token{ .U128 = v },
else => @panic("unexpected integer size"),
},
},
else => @panic("unexpected type"),
};
try assertNextToken(self, expected);
}
fn serializeMap(self: *Self, length: ?usize) Error!Map {
try assertNextToken(self, Token{ .Map = .{ .len = length } });
return Map{ .ser = self };
}
fn serializeNull(self: *Self) Error!Ok {
try assertNextToken(self, Token{ .Null = {} });
}
fn serializeSeq(self: *Self, length: ?usize) Error!Seq {
try assertNextToken(self, Token{ .Seq = .{ .len = length } });
return Seq{ .ser = self };
}
fn serializeSome(self: *Self, v: anytype) Error!Ok {
try assertNextToken(self, Token{ .Some = {} });
try getty.serialize(v, self.serializer());
}
fn serializeString(self: *Self, v: anytype) Error!Ok {
try assertNextToken(self, Token{ .String = v });
}
fn serializeStruct(self: *Self, comptime name: []const u8, length: usize) Error!Struct {
try assertNextToken(self, Token{ .Struct = .{ .name = name, .len = length } });
return Struct{ .ser = self };
}
fn serializeVoid(self: *Self) Error!Ok {
try assertNextToken(self, Token{ .Void = {} });
}
};
const Map = struct {
ser: *Serializer,
const Self = @This();
pub usingnamespace getty.ser.Map(
*Self,
Serializer.Ok,
Serializer.Error,
serializeKey,
serializeValue,
end,
);
fn serializeKey(self: *Self, key: anytype) Serializer.Error!void {
try getty.serialize(key, self.ser.serializer());
}
fn serializeValue(self: *Self, value: anytype) Serializer.Error!void {
try getty.serialize(value, self.ser.serializer());
}
fn end(self: *Self) Serializer.Error!Serializer.Ok {
try assertNextToken(self.ser, Token{ .MapEnd = {} });
}
};
const Seq = struct {
ser: *Serializer,
const Self = @This();
pub usingnamespace getty.ser.Seq(
*Self,
Serializer.Ok,
Serializer.Error,
serializeElement,
end,
);
fn serializeElement(self: *Self, value: anytype) Serializer.Error!void {
try getty.serialize(value, self.ser.serializer());
}
fn end(self: *Self) Serializer.Error!Serializer.Ok {
try assertNextToken(self.ser, Token{ .SeqEnd = {} });
}
};
const Struct = struct {
ser: *Serializer,
const Self = @This();
pub usingnamespace getty.ser.Structure(
*Self,
Serializer.Ok,
Serializer.Error,
serializeField,
end,
);
fn serializeField(self: *Self, comptime key: []const u8, value: anytype) Serializer.Error!void {
try assertNextToken(self.ser, Token{ .String = key });
try getty.serialize(value, self.ser.serializer());
}
fn end(self: *Self) Serializer.Error!Serializer.Ok {
try assertNextToken(self.ser, Token{ .StructEnd = {} });
}
};
fn assertNextToken(ser: *Serializer, expected: Token) !void {
if (ser.nextTokenOpt()) |token| {
const token_tag = std.meta.activeTag(token);
const expected_tag = std.meta.activeTag(expected);
if (token_tag == expected_tag) {
switch (token) {
.Bool => try expectEqual(@field(token, "Bool"), @field(expected, "Bool")),
.ComptimeFloat => try expectEqual(@field(token, "ComptimeFloat"), @field(expected, "ComptimeFloat")),
.ComptimeInt => try expectEqual(@field(token, "ComptimeInt"), @field(expected, "ComptimeInt")),
.Enum => try expectEqual(@field(token, "Enum"), @field(expected, "Enum")),
.F16 => try expectEqual(@field(token, "F16"), @field(expected, "F16")),
.F32 => try expectEqual(@field(token, "F32"), @field(expected, "F32")),
.F64 => try expectEqual(@field(token, "F64"), @field(expected, "F64")),
.F128 => try expectEqual(@field(token, "F128"), @field(expected, "F128")),
.I8 => try expectEqual(@field(token, "I8"), @field(expected, "I8")),
.I16 => try expectEqual(@field(token, "I16"), @field(expected, "I16")),
.I32 => try expectEqual(@field(token, "I32"), @field(expected, "I32")),
.I64 => try expectEqual(@field(token, "I64"), @field(expected, "I64")),
.I128 => try expectEqual(@field(token, "I128"), @field(expected, "I128")),
.Map => try expectEqual(@field(token, "Map"), @field(expected, "Map")),
.MapEnd => try expectEqual(@field(token, "MapEnd"), @field(expected, "MapEnd")),
.Null => try expectEqual(@field(token, "Null"), @field(expected, "Null")),
.Seq => try expectEqual(@field(token, "Seq"), @field(expected, "Seq")),
.SeqEnd => try expectEqual(@field(token, "SeqEnd"), @field(expected, "SeqEnd")),
.Some => try expectEqual(@field(token, "Some"), @field(expected, "Some")),
.String => try expectEqualSlices(u8, @field(token, "String"), @field(expected, "String")),
.Struct => {
const t = @field(token, "Struct");
const e = @field(expected, "Struct");
try expectEqualSlices(u8, t.name, e.name);
try expectEqual(t.len, e.len);
},
.StructEnd => try expectEqual(@field(token, "StructEnd"), @field(expected, "StructEnd")),
.U8 => try expectEqual(@field(token, "U8"), @field(expected, "U8")),
.U16 => try expectEqual(@field(token, "U16"), @field(expected, "U16")),
.U32 => try expectEqual(@field(token, "U32"), @field(expected, "U32")),
.U64 => try expectEqual(@field(token, "U64"), @field(expected, "U64")),
.U128 => try expectEqual(@field(token, "U128"), @field(expected, "U128")),
.Void => try expectEqual(@field(token, "Void"), @field(expected, "Void")),
}
} else {
@panic("expected Token::{} but serialized as {}");
}
} else {
@panic("expected end of tokens, but {} was serialized");
}
}
|
src/tests/ser/serializer.zig
|
const std = @import("std");
const Dependency = @import("Dependency.zig");
const Project = @import("Project.zig");
const utils = @import("utils.zig");
const Engine = @This();
const Allocator = std.mem.Allocator;
const ArenaAllocator = std.heap.ArenaAllocator;
const StructField = std.builtin.TypeInfo.StructField;
const UnionField = std.builtin.TypeInfo.UnionField;
const testing = std.testing;
const assert = std.debug.assert;
pub const DepTable = std.ArrayListUnmanaged(Dependency.Source);
pub const Sources = .{
@import("pkg.zig"),
@import("github.zig"),
@import("local.zig"),
@import("url.zig"),
};
pub const Edge = struct {
const ParentIndex = union(enum) {
root: enum {
normal,
build,
},
index: usize,
};
from: ParentIndex,
to: usize,
alias: []const u8,
pub fn format(
edge: Edge,
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
writer: anytype,
) @TypeOf(writer).Error!void {
_ = fmt;
_ = options;
switch (edge.from) {
.root => |which| switch (which) {
.normal => try writer.print("Edge: deps -> {}: {s}", .{ edge.to, edge.alias }),
.build => try writer.print("Edge: build_deps -> {}: {s}", .{ edge.to, edge.alias }),
},
.index => |idx| try writer.print("Edge: {} -> {}: {s}", .{ idx, edge.to, edge.alias }),
}
}
};
pub const Resolutions = blk: {
var tables_fields: [Sources.len]StructField = undefined;
var edges_fields: [Sources.len]StructField = undefined;
inline for (Sources) |source, i| {
const ResolutionTable = std.ArrayListUnmanaged(source.ResolutionEntry);
tables_fields[i] = StructField{
.name = source.name,
.field_type = ResolutionTable,
.alignment = @alignOf(ResolutionTable),
.is_comptime = false,
.default_value = null,
};
const EdgeTable = std.ArrayListUnmanaged(struct {
dep_idx: usize,
res_idx: usize,
});
edges_fields[i] = StructField{
.name = source.name,
.field_type = EdgeTable,
.alignment = @alignOf(EdgeTable),
.is_comptime = false,
.default_value = null,
};
}
const Tables = @Type(std.builtin.TypeInfo{
.Struct = .{
.layout = .Auto,
.is_tuple = false,
.fields = &tables_fields,
.decls = &.{},
},
});
const Edges = @Type(std.builtin.TypeInfo{
.Struct = .{
.layout = .Auto,
.is_tuple = false,
.fields = &edges_fields,
.decls = &.{},
},
});
break :blk struct {
text: []const u8,
tables: Tables,
edges: Edges,
const Self = @This();
pub fn deinit(self: *Self, allocator: *Allocator) void {
inline for (Sources) |source| {
@field(self.tables, source.name).deinit(allocator);
@field(self.edges, source.name).deinit(allocator);
}
allocator.free(self.text);
}
pub fn fromReader(allocator: *Allocator, reader: anytype) !Self {
var ret = Self{
.text = try reader.readAllAlloc(allocator, std.math.maxInt(usize)),
.tables = undefined,
.edges = undefined,
};
inline for (std.meta.fields(Tables)) |field|
@field(ret.tables, field.name) = field.field_type{};
inline for (std.meta.fields(Edges)) |field|
@field(ret.edges, field.name) = field.field_type{};
errdefer ret.deinit(allocator);
var line_it = std.mem.tokenize(u8, ret.text, "\n");
var count: usize = 0;
iterate: while (line_it.next()) |line| : (count += 1) {
var it = std.mem.tokenize(u8, line, " ");
const first = it.next() orelse return error.EmptyLine;
inline for (Sources) |source| {
if (std.mem.eql(u8, first, source.name)) {
source.deserializeLockfileEntry(
allocator,
&it,
&@field(ret.tables, source.name),
) catch |err| {
std.log.warn(
"invalid lockfile entry on line {}, {s} -- ignoring and removing:\n{s}\n",
.{ count + 1, @errorName(err), line },
);
continue :iterate;
};
break;
}
} else {
std.log.err("unsupported lockfile prefix: {s}", .{first});
return error.Explained;
}
}
return ret;
}
};
};
pub fn MultiQueueImpl(comptime Resolution: type, comptime Error: type) type {
return std.MultiArrayList(struct {
edge: Edge,
thread: ?std.Thread = null,
result: union(enum) {
replace_me: usize,
fill_resolution: usize,
copy_deps: usize,
new_entry: Resolution,
err: Error,
} = undefined,
arena: ArenaAllocator,
path: ?[]const u8 = null,
deps: std.ArrayListUnmanaged(Dependency),
});
}
pub const FetchQueue = blk: {
var fields: [Sources.len]StructField = undefined;
var next_fields: [Sources.len]StructField = undefined;
inline for (Sources) |source, i| {
const MultiQueue = MultiQueueImpl(
source.Resolution,
source.FetchError,
);
fields[i] = StructField{
.name = source.name,
.field_type = MultiQueue,
.alignment = @alignOf(MultiQueue),
.is_comptime = false,
.default_value = null,
};
next_fields[i] = StructField{
.name = source.name,
.field_type = std.ArrayListUnmanaged(Edge),
.alignment = @alignOf(std.ArrayListUnmanaged(Edge)),
.is_comptime = false,
.default_value = null,
};
}
const Tables = @Type(std.builtin.TypeInfo{
.Struct = .{
.layout = .Auto,
.is_tuple = false,
.fields = &fields,
.decls = &.{},
},
});
const NextType = @Type(std.builtin.TypeInfo{
.Struct = .{
.layout = .Auto,
.is_tuple = false,
.fields = &next_fields,
.decls = &.{},
},
});
break :blk struct {
tables: Tables,
const Self = @This();
pub const Next = struct {
tables: NextType,
pub fn init() @This() {
var ret: @This() = undefined;
inline for (Sources) |source|
@field(ret.tables, source.name) = std.ArrayListUnmanaged(Edge){};
return ret;
}
pub fn deinit(self: *@This(), allocator: *Allocator) void {
inline for (Sources) |source|
@field(self.tables, source.name).deinit(allocator);
}
pub fn append(self: *@This(), allocator: *Allocator, src_type: Dependency.SourceType, edge: Edge) !void {
inline for (Sources) |source| {
if (src_type == @field(Dependency.SourceType, source.name)) {
try @field(self.tables, source.name).append(allocator, edge);
break;
}
} else {
std.log.err("unsupported dependency source type: {}", .{src_type});
assert(false);
return error.Explained;
}
}
};
pub fn init() Self {
var ret: Self = undefined;
inline for (std.meta.fields(Tables)) |field|
@field(ret.tables, field.name) = field.field_type{};
return ret;
}
pub fn deinit(self: *Self, allocator: *Allocator) void {
inline for (Sources) |source|
@field(self.tables, source.name).deinit(allocator);
}
pub fn append(
self: *Self,
allocator: *Allocator,
src_type: Dependency.SourceType,
edge: Edge,
) !void {
inline for (Sources) |source| {
if (src_type == @field(Dependency.SourceType, source.name)) {
try @field(self.tables, source.name).append(allocator, .{
.arena = ArenaAllocator.init(allocator),
.edge = edge,
.deps = std.ArrayListUnmanaged(Dependency){},
});
break;
}
} else {
std.log.err("unsupported dependency source type: {}", .{src_type});
assert(false);
return error.Explained;
}
}
pub fn empty(self: Self) bool {
return inline for (Sources) |source| {
if (@field(self.tables, source.name).len != 0) break false;
} else true;
}
pub fn clearAndLoad(self: *Self, arena: *ArenaAllocator, next: Next) !void {
// clear current table
inline for (Sources) |source| {
for (@field(self.tables, source.name).items(.deps)) |*dep| {
dep.deinit(arena.child_allocator);
}
for (@field(self.tables, source.name).items(.arena)) |*thread_arena| {
while (thread_arena.state.buffer_list.popFirst()) |node|
arena.state.buffer_list.prepend(node);
arena.state.end_index += thread_arena.state.end_index;
}
@field(self.tables, source.name).shrinkRetainingCapacity(0);
for (@field(next.tables, source.name).items) |edge| {
try @field(self.tables, source.name).append(arena.child_allocator, .{
.arena = ArenaAllocator.init(arena.child_allocator),
.edge = edge,
.deps = std.ArrayListUnmanaged(Dependency){},
});
}
}
}
pub fn parallelFetch(
self: *Self,
dep_table: DepTable,
resolutions: Resolutions,
) !void {
errdefer inline for (Sources) |source|
for (@field(self.tables, source.name).items(.thread)) |th|
if (th) |t|
t.join();
inline for (Sources) |source| {
for (@field(self.tables, source.name).items(.thread)) |*th, i| {
th.* = try std.Thread.spawn(
.{},
source.dedupeResolveAndFetch,
.{
dep_table.items,
@field(resolutions.tables, source.name).items,
&@field(self.tables, source.name),
i,
},
);
}
}
inline for (Sources) |source|
for (@field(self.tables, source.name).items(.thread)) |th|
th.?.join();
}
pub fn cleanupDeps(self: *Self, allocator: *Allocator) void {
inline for (Sources) |source|
for (@field(self.tables, source.name).items(.deps)) |*deps|
deps.deinit(allocator);
}
};
};
allocator: *Allocator,
arena: ArenaAllocator,
project: *Project,
dep_table: DepTable,
edges: std.ArrayListUnmanaged(Edge),
fetch_queue: FetchQueue,
resolutions: Resolutions,
paths: std.AutoHashMapUnmanaged(usize, []const u8),
pub fn init(
allocator: *Allocator,
project: *Project,
lockfile_reader: anytype,
) !Engine {
const initial_deps = project.deps.items.len + project.build_deps.items.len;
var dep_table = try DepTable.initCapacity(allocator, initial_deps);
errdefer dep_table.deinit(allocator);
var fetch_queue = FetchQueue.init();
errdefer fetch_queue.deinit(allocator);
for (project.deps.items) |dep| {
try dep_table.append(allocator, dep.src);
try fetch_queue.append(allocator, dep.src, .{
.from = .{
.root = .normal,
},
.to = dep_table.items.len - 1,
.alias = dep.alias,
});
}
for (project.build_deps.items) |dep| {
try dep_table.append(allocator, dep.src);
try fetch_queue.append(allocator, dep.src, .{
.from = .{
.root = .build,
},
.to = dep_table.items.len - 1,
.alias = dep.alias,
});
}
const resolutions = try Resolutions.fromReader(allocator, lockfile_reader);
errdefer resolutions.deinit(allocator);
return Engine{
.allocator = allocator,
.arena = ArenaAllocator.init(allocator),
.project = project,
.dep_table = dep_table,
.edges = std.ArrayListUnmanaged(Edge){},
.fetch_queue = fetch_queue,
.resolutions = resolutions,
.paths = std.AutoHashMapUnmanaged(usize, []const u8){},
};
}
pub fn deinit(self: *Engine) void {
self.dep_table.deinit(self.allocator);
self.edges.deinit(self.allocator);
self.fetch_queue.deinit(self.allocator);
self.resolutions.deinit(self.allocator);
self.paths.deinit(self.allocator);
self.arena.deinit();
}
pub fn fetch(self: *Engine) !void {
defer self.fetch_queue.cleanupDeps(self.allocator);
while (!self.fetch_queue.empty()) {
var next = FetchQueue.Next.init();
defer next.deinit(self.allocator);
{
try self.fetch_queue.parallelFetch(self.dep_table, self.resolutions);
// inline for workaround because the compiler wasn't generating the right code for this
for (self.fetch_queue.tables.pkg.items(.result)) |_, i|
try Sources[0].updateResolution(self.allocator, &self.resolutions.tables.pkg, self.dep_table.items, &self.fetch_queue.tables.pkg, i);
for (self.fetch_queue.tables.github.items(.result)) |_, i|
try Sources[1].updateResolution(self.allocator, &self.resolutions.tables.github, self.dep_table.items, &self.fetch_queue.tables.github, i);
for (self.fetch_queue.tables.local.items(.result)) |_, i|
try Sources[2].updateResolution(self.allocator, &self.resolutions.tables.local, self.dep_table.items, &self.fetch_queue.tables.local, i);
for (self.fetch_queue.tables.url.items(.result)) |_, i|
try Sources[3].updateResolution(self.allocator, &self.resolutions.tables.url, self.dep_table.items, &self.fetch_queue.tables.url, i);
inline for (Sources) |source| {
for (@field(self.fetch_queue.tables, source.name).items(.path)) |opt_path, i| {
if (opt_path) |path| {
try self.paths.putNoClobber(
self.allocator,
@field(self.fetch_queue.tables, source.name).items(.edge)[i].to,
path,
);
}
}
// set up next batch of deps to fetch
for (@field(self.fetch_queue.tables, source.name).items(.deps)) |deps, i| {
const dep_index = @field(self.fetch_queue.tables, source.name).items(.edge)[i].to;
for (deps.items) |dep| {
try self.dep_table.append(self.allocator, dep.src);
const edge = Edge{
.from = .{
.index = dep_index,
},
.to = self.dep_table.items.len - 1,
.alias = dep.alias,
};
try next.append(self.allocator, dep.src, edge);
}
}
// copy edges
try self.edges.appendSlice(
self.allocator,
@field(self.fetch_queue.tables, source.name).items(.edge),
);
}
}
try self.fetch_queue.clearAndLoad(&self.arena, next);
}
// TODO: check for circular dependencies
}
pub fn writeLockfile(self: Engine, writer: anytype) !void {
inline for (Sources) |source|
try source.serializeResolutions(@field(self.resolutions.tables, source.name).items, writer);
}
pub fn writeDepBeginRoot(self: *Engine, writer: anytype, indent: usize, edge: Edge) !void {
const escaped = try utils.escape(self.allocator, edge.alias);
defer self.allocator.free(escaped);
try writer.writeByteNTimes(' ', 4 * indent);
try writer.print("pub const {s} = Pkg{{\n", .{escaped});
try writer.writeByteNTimes(' ', 4 * (indent + 1));
try writer.print(".name = \"{s}\",\n", .{edge.alias});
try writer.writeByteNTimes(' ', 4 * (indent + 1));
try writer.print(".path = FileSource{{\n", .{});
const path = if (std.builtin.target.os.tag == .windows)
try std.mem.replaceOwned(u8, self.allocator, self.paths.get(edge.to).?, "\\", "\\\\")
else
self.paths.get(edge.to).?;
defer if (std.builtin.target.os.tag == .windows) self.allocator.free(path);
try writer.writeByteNTimes(' ', 4 * (indent + 2));
try writer.print(".path = \"{s}\",\n", .{path});
try writer.writeByteNTimes(' ', 4 * (indent + 1));
try writer.print("}},\n", .{});
}
pub fn writeDepEndRoot(writer: anytype, indent: usize) !void {
try writer.writeByteNTimes(' ', 4 * (1 + indent));
try writer.print("}},\n", .{});
try writer.writeByteNTimes(' ', 4 * indent);
try writer.print("}};\n\n", .{});
}
pub fn writeDepBegin(self: Engine, writer: anytype, indent: usize, edge: Edge) !void {
try writer.writeByteNTimes(' ', 4 * indent);
try writer.print("Pkg{{\n", .{});
try writer.writeByteNTimes(' ', 4 * (indent + 1));
try writer.print(".name = \"{s}\",\n", .{edge.alias});
try writer.writeByteNTimes(' ', 4 * (indent + 1));
try writer.print(".path = FileSource{{\n", .{});
const path = if (std.builtin.target.os.tag == .windows)
try std.mem.replaceOwned(u8, self.allocator, self.paths.get(edge.to).?, "\\", "\\\\")
else
self.paths.get(edge.to).?;
defer if (std.builtin.target.os.tag == .windows) self.allocator.free(path);
try writer.writeByteNTimes(' ', 4 * (indent + 2));
try writer.print(".path = \"{s}\",\n", .{path});
try writer.writeByteNTimes(' ', 4 * (indent + 1));
try writer.print("}},\n", .{});
_ = self;
}
pub fn writeDepEnd(writer: anytype, indent: usize) !void {
try writer.writeByteNTimes(' ', 4 * (1 + indent));
try writer.print("}},\n", .{});
}
pub fn writeDepsZig(self: *Engine, writer: anytype) !void {
try writer.print(
\\const std = @import("std");
\\const Pkg = std.build.Pkg;
\\const FileSource = std.build.FileSource;
\\
\\pub const pkgs = struct {{
\\
, .{});
for (self.edges.items) |edge| {
switch (edge.from) {
.root => |root| if (root == .normal) {
var stack = std.ArrayList(struct {
current: usize,
edge_idx: usize,
has_deps: bool,
}).init(self.allocator);
defer stack.deinit();
var current = edge.to;
var edge_idx = 1 + edge.to;
var has_deps = false;
try self.writeDepBeginRoot(writer, 1 + stack.items.len, edge);
while (true) {
while (edge_idx < self.edges.items.len) : (edge_idx += 1) {
const root_level = stack.items.len == 0;
switch (self.edges.items[edge_idx].from) {
.index => |idx| if (idx == current) {
if (!has_deps) {
const offset: usize = if (root_level) 2 else 3;
try writer.writeByteNTimes(' ', 4 * (stack.items.len + offset));
try writer.print(".dependencies = &[_]Pkg{{\n", .{});
has_deps = true;
}
try stack.append(.{
.current = current,
.edge_idx = edge_idx,
.has_deps = has_deps,
});
const offset: usize = if (root_level) 2 else 3;
try self.writeDepBegin(writer, offset + stack.items.len, self.edges.items[edge_idx]);
current = edge_idx;
edge_idx += 1;
has_deps = false;
break;
},
else => {},
}
} else if (stack.items.len > 0) {
if (has_deps) {
try writer.writeByteNTimes(' ', 4 * (stack.items.len + 3));
try writer.print("}},\n", .{});
}
const offset: usize = if (stack.items.len == 1) 2 else 3;
try writer.writeByteNTimes(' ', 4 * (stack.items.len + offset));
try writer.print("}},\n", .{});
const pop = stack.pop();
current = pop.current;
edge_idx = 1 + pop.edge_idx;
has_deps = pop.has_deps;
} else {
if (has_deps) {
try writer.writeByteNTimes(' ', 8);
try writer.print("}},\n", .{});
}
break;
}
}
try writer.writeByteNTimes(' ', 4);
try writer.print("}};\n\n", .{});
},
else => {},
}
}
try writer.print(" pub fn addAllTo(artifact: *std.build.LibExeObjStep) void {{\n", .{});
for (self.edges.items) |edge| {
switch (edge.from) {
.root => |root| if (root == .normal) {
try writer.print(" artifact.addPackage(pkgs.{s});\n", .{
try utils.escape(&self.arena.allocator, edge.alias),
});
},
else => {},
}
}
try writer.print(" }}\n", .{});
try writer.print("}};\n", .{});
if (self.project.packages.count() == 0)
return;
try writer.print("\npub const exports = struct {{\n", .{});
var it = self.project.packages.iterator();
while (it.next()) |pkg| {
const path: []const u8 = pkg.value_ptr.root orelse utils.default_root;
try writer.print(
\\ pub const {s} = Pkg{{
\\ .name = "{s}",
\\ .path = "{s}",
\\
, .{
try utils.escape(&self.arena.allocator, pkg.value_ptr.name),
pkg.value_ptr.name,
path,
});
if (self.project.deps.items.len > 0) {
try writer.print(" .dependencies = &[_]Pkg{{\n", .{});
for (self.edges.items) |edge| {
switch (edge.from) {
.root => |root| if (root == .normal) {
try writer.print(" pkgs.{s},\n", .{
edge.alias,
});
},
else => {},
}
}
try writer.print(" }},\n", .{});
}
try writer.print(" }};\n", .{});
}
try writer.print("}};\n", .{});
}
fn recursivePrint(pkg: std.build.Pkg, depth: usize) void {
const stdout = std.io.getStdOut().writer();
stdout.writeByteNTimes(' ', depth) catch {};
stdout.print("{s}\n", .{pkg.name}) catch {};
if (pkg.dependencies) |deps| for (deps) |dep|
recursivePrint(dep, depth + 1);
}
/// arena only stores the arraylists, not text, return slice is allocated in the arena
pub fn genBuildDeps(self: Engine, arena: *ArenaAllocator) !std.ArrayList(std.build.Pkg) {
const allocator = arena.child_allocator;
var ret = std.ArrayList(std.build.Pkg).init(allocator);
errdefer ret.deinit();
for (self.edges.items) |edge| {
switch (edge.from) {
.root => |root| if (root == .build) {
var stack = std.ArrayList(struct {
current: usize,
edge_idx: usize,
deps: std.ArrayListUnmanaged(std.build.Pkg),
}).init(allocator);
defer stack.deinit();
var current = edge.to;
var edge_idx = 1 + edge.to;
var deps = std.ArrayListUnmanaged(std.build.Pkg){};
while (true) {
while (edge_idx < self.edges.items.len) : (edge_idx += 1) {
switch (self.edges.items[edge_idx].from) {
.index => |idx| if (idx == current) {
try deps.append(&arena.allocator, .{
.name = self.edges.items[edge_idx].alias,
.path = .{
.path = self.paths.get(self.edges.items[edge_idx].to).?,
},
});
try stack.append(.{
.current = current,
.edge_idx = edge_idx,
.deps = deps,
});
current = edge_idx;
edge_idx += 1;
deps = std.ArrayListUnmanaged(std.build.Pkg){};
break;
},
else => {},
}
} else if (stack.items.len > 0) {
const pop = stack.pop();
if (deps.items.len > 0)
pop.deps.items[pop.deps.items.len - 1].dependencies = deps.items;
current = pop.current;
edge_idx = 1 + pop.edge_idx;
deps = pop.deps;
} else {
break;
}
}
try ret.append(.{
.name = edge.alias,
.path = .{ .path = self.paths.get(edge.to).? },
.dependencies = deps.items,
});
assert(stack.items.len == 0);
},
else => {},
}
}
for (ret.items) |entry|
recursivePrint(entry, 0);
return ret;
}
test "Resolutions" {
var text = "".*;
var fb = std.io.fixedBufferStream(&text);
var resolutions = try Resolutions.fromReader(testing.allocator, fb.reader());
defer resolutions.deinit(testing.allocator);
}
test "FetchQueue" {
var fetch_queue = FetchQueue.init();
defer fetch_queue.deinit(testing.allocator);
}
test "fetch" {
var text = "".*;
var fb = std.io.fixedBufferStream(&text);
var engine = Engine{
.allocator = testing.allocator,
.arena = ArenaAllocator.init(testing.allocator),
.dep_table = DepTable{},
.edges = std.ArrayListUnmanaged(Edge){},
.fetch_queue = FetchQueue.init(),
.resolutions = try Resolutions.fromReader(testing.allocator, fb.reader()),
};
defer engine.deinit();
try engine.fetch();
}
test "writeLockfile" {
var text = "".*;
var fb = std.io.fixedBufferStream(&text);
var engine = Engine{
.allocator = testing.allocator,
.arena = ArenaAllocator.init(testing.allocator),
.dep_table = DepTable{},
.edges = std.ArrayListUnmanaged(Edge){},
.fetch_queue = FetchQueue.init(),
.resolutions = try Resolutions.fromReader(testing.allocator, fb.reader()),
};
defer engine.deinit();
try engine.writeLockfile(fb.writer());
}
|
src/Engine.zig
|
const std = @import("std");
const mem = std.mem;
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const Value = @import("value.zig").Value;
const Type = @import("type.zig").Type;
const TypedValue = @import("TypedValue.zig");
const zir = @import("zir.zig");
const Module = @import("Module.zig");
const ast = std.zig.ast;
const trace = @import("tracy.zig").trace;
const Scope = Module.Scope;
const InnerError = Module.InnerError;
const BuiltinFn = @import("BuiltinFn.zig");
pub const ResultLoc = union(enum) {
/// The expression is the right-hand side of assignment to `_`. Only the side-effects of the
/// expression should be generated. The result instruction from the expression must
/// be ignored.
discard,
/// The expression has an inferred type, and it will be evaluated as an rvalue.
none,
/// The expression must generate a pointer rather than a value. For example, the left hand side
/// of an assignment uses this kind of result location.
ref,
/// The expression will be coerced into this type, but it will be evaluated as an rvalue.
ty: *zir.Inst,
/// The expression must store its result into this typed pointer. The result instruction
/// from the expression must be ignored.
ptr: *zir.Inst,
/// The expression must store its result into this allocation, which has an inferred type.
/// The result instruction from the expression must be ignored.
inferred_ptr: *zir.Inst.Tag.alloc_inferred.Type(),
/// The expression must store its result into this pointer, which is a typed pointer that
/// has been bitcasted to whatever the expression's type is.
/// The result instruction from the expression must be ignored.
bitcasted_ptr: *zir.Inst.UnOp,
/// There is a pointer for the expression to store its result into, however, its type
/// is inferred based on peer type resolution for a `zir.Inst.Block`.
/// The result instruction from the expression must be ignored.
block_ptr: *Module.Scope.GenZIR,
pub const Strategy = struct {
elide_store_to_block_ptr_instructions: bool,
tag: Tag,
pub const Tag = enum {
/// Both branches will use break_void; result location is used to communicate the
/// result instruction.
break_void,
/// Use break statements to pass the block result value, and call rvalue() at
/// the end depending on rl. Also elide the store_to_block_ptr instructions
/// depending on rl.
break_operand,
};
};
};
pub fn typeExpr(mod: *Module, scope: *Scope, type_node: ast.Node.Index) InnerError!*zir.Inst {
const tree = scope.tree();
const token_starts = tree.tokens.items(.start);
const type_src = token_starts[tree.firstToken(type_node)];
const type_type = try addZIRInstConst(mod, scope, type_src, .{
.ty = Type.initTag(.type),
.val = Value.initTag(.type_type),
});
const type_rl: ResultLoc = .{ .ty = type_type };
return expr(mod, scope, type_rl, type_node);
}
fn lvalExpr(mod: *Module, scope: *Scope, node: ast.Node.Index) InnerError!*zir.Inst {
const tree = scope.tree();
const node_tags = tree.nodes.items(.tag);
const main_tokens = tree.nodes.items(.main_token);
switch (node_tags[node]) {
.root => unreachable,
.@"usingnamespace" => unreachable,
.test_decl => unreachable,
.global_var_decl => unreachable,
.local_var_decl => unreachable,
.simple_var_decl => unreachable,
.aligned_var_decl => unreachable,
.switch_case => unreachable,
.switch_case_one => unreachable,
.container_field_init => unreachable,
.container_field_align => unreachable,
.container_field => unreachable,
.asm_output => unreachable,
.asm_input => unreachable,
.assign,
.assign_bit_and,
.assign_bit_or,
.assign_bit_shift_left,
.assign_bit_shift_right,
.assign_bit_xor,
.assign_div,
.assign_sub,
.assign_sub_wrap,
.assign_mod,
.assign_add,
.assign_add_wrap,
.assign_mul,
.assign_mul_wrap,
.add,
.add_wrap,
.sub,
.sub_wrap,
.mul,
.mul_wrap,
.div,
.mod,
.bit_and,
.bit_or,
.bit_shift_left,
.bit_shift_right,
.bit_xor,
.bang_equal,
.equal_equal,
.greater_than,
.greater_or_equal,
.less_than,
.less_or_equal,
.array_cat,
.array_mult,
.bool_and,
.bool_or,
.@"asm",
.asm_simple,
.string_literal,
.integer_literal,
.call,
.call_comma,
.async_call,
.async_call_comma,
.call_one,
.call_one_comma,
.async_call_one,
.async_call_one_comma,
.unreachable_literal,
.@"return",
.@"if",
.if_simple,
.@"while",
.while_simple,
.while_cont,
.bool_not,
.address_of,
.float_literal,
.undefined_literal,
.true_literal,
.false_literal,
.null_literal,
.optional_type,
.block,
.block_semicolon,
.block_two,
.block_two_semicolon,
.@"break",
.ptr_type_aligned,
.ptr_type_sentinel,
.ptr_type,
.ptr_type_bit_range,
.array_type,
.array_type_sentinel,
.enum_literal,
.multiline_string_literal,
.char_literal,
.@"defer",
.@"errdefer",
.@"catch",
.error_union,
.merge_error_sets,
.switch_range,
.@"await",
.bit_not,
.negation,
.negation_wrap,
.@"resume",
.@"try",
.slice,
.slice_open,
.slice_sentinel,
.array_init_one,
.array_init_one_comma,
.array_init_dot_two,
.array_init_dot_two_comma,
.array_init_dot,
.array_init_dot_comma,
.array_init,
.array_init_comma,
.struct_init_one,
.struct_init_one_comma,
.struct_init_dot_two,
.struct_init_dot_two_comma,
.struct_init_dot,
.struct_init_dot_comma,
.struct_init,
.struct_init_comma,
.@"switch",
.switch_comma,
.@"for",
.for_simple,
.@"suspend",
.@"continue",
.@"anytype",
.fn_proto_simple,
.fn_proto_multi,
.fn_proto_one,
.fn_proto,
.fn_decl,
.anyframe_type,
.anyframe_literal,
.error_set_decl,
.container_decl,
.container_decl_trailing,
.container_decl_two,
.container_decl_two_trailing,
.container_decl_arg,
.container_decl_arg_trailing,
.tagged_union,
.tagged_union_trailing,
.tagged_union_two,
.tagged_union_two_trailing,
.tagged_union_enum_tag,
.tagged_union_enum_tag_trailing,
.@"comptime",
.@"nosuspend",
.error_value,
=> return mod.failNode(scope, node, "invalid left-hand side to assignment", .{}),
.builtin_call,
.builtin_call_comma,
.builtin_call_two,
.builtin_call_two_comma,
=> {
const builtin_token = main_tokens[node];
const builtin_name = tree.tokenSlice(builtin_token);
// If the builtin is an invalid name, we don't cause an error here; instead
// let it pass, and the error will be "invalid builtin function" later.
if (BuiltinFn.list.get(builtin_name)) |info| {
if (!info.allows_lvalue) {
return mod.failNode(scope, node, "invalid left-hand side to assignment", .{});
}
}
},
// These can be assigned to.
.unwrap_optional,
.deref,
.field_access,
.array_access,
.identifier,
.grouped_expression,
.@"orelse",
=> {},
}
return expr(mod, scope, .ref, node);
}
/// Turn Zig AST into untyped ZIR istructions.
/// When `rl` is discard, ptr, inferred_ptr, bitcasted_ptr, or inferred_ptr, the
/// result instruction can be used to inspect whether it is isNoReturn() but that is it,
/// it must otherwise not be used.
pub fn expr(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerError!*zir.Inst {
const tree = scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const token_tags = tree.tokens.items(.tag);
const node_datas = tree.nodes.items(.data);
const node_tags = tree.nodes.items(.tag);
const token_starts = tree.tokens.items(.start);
switch (node_tags[node]) {
.root => unreachable, // Top-level declaration.
.@"usingnamespace" => unreachable, // Top-level declaration.
.test_decl => unreachable, // Top-level declaration.
.container_field_init => unreachable, // Top-level declaration.
.container_field_align => unreachable, // Top-level declaration.
.container_field => unreachable, // Top-level declaration.
.fn_decl => unreachable, // Top-level declaration.
.global_var_decl => unreachable, // Handled in `blockExpr`.
.local_var_decl => unreachable, // Handled in `blockExpr`.
.simple_var_decl => unreachable, // Handled in `blockExpr`.
.aligned_var_decl => unreachable, // Handled in `blockExpr`.
.switch_case => unreachable, // Handled in `switchExpr`.
.switch_case_one => unreachable, // Handled in `switchExpr`.
.switch_range => unreachable, // Handled in `switchExpr`.
.asm_output => unreachable, // Handled in `asmExpr`.
.asm_input => unreachable, // Handled in `asmExpr`.
.assign => return rvalueVoid(mod, scope, rl, node, try assign(mod, scope, node)),
.assign_bit_and => return rvalueVoid(mod, scope, rl, node, try assignOp(mod, scope, node, .bit_and)),
.assign_bit_or => return rvalueVoid(mod, scope, rl, node, try assignOp(mod, scope, node, .bit_or)),
.assign_bit_shift_left => return rvalueVoid(mod, scope, rl, node, try assignOp(mod, scope, node, .shl)),
.assign_bit_shift_right => return rvalueVoid(mod, scope, rl, node, try assignOp(mod, scope, node, .shr)),
.assign_bit_xor => return rvalueVoid(mod, scope, rl, node, try assignOp(mod, scope, node, .xor)),
.assign_div => return rvalueVoid(mod, scope, rl, node, try assignOp(mod, scope, node, .div)),
.assign_sub => return rvalueVoid(mod, scope, rl, node, try assignOp(mod, scope, node, .sub)),
.assign_sub_wrap => return rvalueVoid(mod, scope, rl, node, try assignOp(mod, scope, node, .subwrap)),
.assign_mod => return rvalueVoid(mod, scope, rl, node, try assignOp(mod, scope, node, .mod_rem)),
.assign_add => return rvalueVoid(mod, scope, rl, node, try assignOp(mod, scope, node, .add)),
.assign_add_wrap => return rvalueVoid(mod, scope, rl, node, try assignOp(mod, scope, node, .addwrap)),
.assign_mul => return rvalueVoid(mod, scope, rl, node, try assignOp(mod, scope, node, .mul)),
.assign_mul_wrap => return rvalueVoid(mod, scope, rl, node, try assignOp(mod, scope, node, .mulwrap)),
.add => return simpleBinOp(mod, scope, rl, node, .add),
.add_wrap => return simpleBinOp(mod, scope, rl, node, .addwrap),
.sub => return simpleBinOp(mod, scope, rl, node, .sub),
.sub_wrap => return simpleBinOp(mod, scope, rl, node, .subwrap),
.mul => return simpleBinOp(mod, scope, rl, node, .mul),
.mul_wrap => return simpleBinOp(mod, scope, rl, node, .mulwrap),
.div => return simpleBinOp(mod, scope, rl, node, .div),
.mod => return simpleBinOp(mod, scope, rl, node, .mod_rem),
.bit_and => return simpleBinOp(mod, scope, rl, node, .bit_and),
.bit_or => return simpleBinOp(mod, scope, rl, node, .bit_or),
.bit_shift_left => return simpleBinOp(mod, scope, rl, node, .shl),
.bit_shift_right => return simpleBinOp(mod, scope, rl, node, .shr),
.bit_xor => return simpleBinOp(mod, scope, rl, node, .xor),
.bang_equal => return simpleBinOp(mod, scope, rl, node, .cmp_neq),
.equal_equal => return simpleBinOp(mod, scope, rl, node, .cmp_eq),
.greater_than => return simpleBinOp(mod, scope, rl, node, .cmp_gt),
.greater_or_equal => return simpleBinOp(mod, scope, rl, node, .cmp_gte),
.less_than => return simpleBinOp(mod, scope, rl, node, .cmp_lt),
.less_or_equal => return simpleBinOp(mod, scope, rl, node, .cmp_lte),
.array_cat => return simpleBinOp(mod, scope, rl, node, .array_cat),
.array_mult => return simpleBinOp(mod, scope, rl, node, .array_mul),
.bool_and => return boolBinOp(mod, scope, rl, node, true),
.bool_or => return boolBinOp(mod, scope, rl, node, false),
.bool_not => return rvalue(mod, scope, rl, try boolNot(mod, scope, node)),
.bit_not => return rvalue(mod, scope, rl, try bitNot(mod, scope, node)),
.negation => return rvalue(mod, scope, rl, try negation(mod, scope, node, .sub)),
.negation_wrap => return rvalue(mod, scope, rl, try negation(mod, scope, node, .subwrap)),
.identifier => return identifier(mod, scope, rl, node),
.asm_simple => return asmExpr(mod, scope, rl, tree.asmSimple(node)),
.@"asm" => return asmExpr(mod, scope, rl, tree.asmFull(node)),
.string_literal => return stringLiteral(mod, scope, rl, node),
.multiline_string_literal => return multilineStringLiteral(mod, scope, rl, node),
.integer_literal => return integerLiteral(mod, scope, rl, node),
.builtin_call_two, .builtin_call_two_comma => {
if (node_datas[node].lhs == 0) {
const params = [_]ast.Node.Index{};
return builtinCall(mod, scope, rl, node, ¶ms);
} else if (node_datas[node].rhs == 0) {
const params = [_]ast.Node.Index{node_datas[node].lhs};
return builtinCall(mod, scope, rl, node, ¶ms);
} else {
const params = [_]ast.Node.Index{ node_datas[node].lhs, node_datas[node].rhs };
return builtinCall(mod, scope, rl, node, ¶ms);
}
},
.builtin_call, .builtin_call_comma => {
const params = tree.extra_data[node_datas[node].lhs..node_datas[node].rhs];
return builtinCall(mod, scope, rl, node, params);
},
.call_one, .call_one_comma, .async_call_one, .async_call_one_comma => {
var params: [1]ast.Node.Index = undefined;
return callExpr(mod, scope, rl, tree.callOne(¶ms, node));
},
.call, .call_comma, .async_call, .async_call_comma => {
return callExpr(mod, scope, rl, tree.callFull(node));
},
.unreachable_literal => {
const main_token = main_tokens[node];
const src = token_starts[main_token];
return addZIRNoOp(mod, scope, src, .unreachable_safe);
},
.@"return" => return ret(mod, scope, node),
.field_access => return fieldAccess(mod, scope, rl, node),
.float_literal => return floatLiteral(mod, scope, rl, node),
.if_simple => return ifExpr(mod, scope, rl, tree.ifSimple(node)),
.@"if" => return ifExpr(mod, scope, rl, tree.ifFull(node)),
.while_simple => return whileExpr(mod, scope, rl, tree.whileSimple(node)),
.while_cont => return whileExpr(mod, scope, rl, tree.whileCont(node)),
.@"while" => return whileExpr(mod, scope, rl, tree.whileFull(node)),
.for_simple => return forExpr(mod, scope, rl, tree.forSimple(node)),
.@"for" => return forExpr(mod, scope, rl, tree.forFull(node)),
// TODO handling these separately would actually be simpler & have fewer branches
// once we have a ZIR instruction for each of these 3 cases.
.slice_open => return sliceExpr(mod, scope, rl, tree.sliceOpen(node)),
.slice => return sliceExpr(mod, scope, rl, tree.slice(node)),
.slice_sentinel => return sliceExpr(mod, scope, rl, tree.sliceSentinel(node)),
.deref => {
const lhs = try expr(mod, scope, .none, node_datas[node].lhs);
const src = token_starts[main_tokens[node]];
const result = try addZIRUnOp(mod, scope, src, .deref, lhs);
return rvalue(mod, scope, rl, result);
},
.address_of => {
const result = try expr(mod, scope, .ref, node_datas[node].lhs);
return rvalue(mod, scope, rl, result);
},
.undefined_literal => {
const main_token = main_tokens[node];
const src = token_starts[main_token];
const result = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.@"undefined"),
.val = Value.initTag(.undef),
});
return rvalue(mod, scope, rl, result);
},
.true_literal => {
const main_token = main_tokens[node];
const src = token_starts[main_token];
const result = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.bool),
.val = Value.initTag(.bool_true),
});
return rvalue(mod, scope, rl, result);
},
.false_literal => {
const main_token = main_tokens[node];
const src = token_starts[main_token];
const result = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.bool),
.val = Value.initTag(.bool_false),
});
return rvalue(mod, scope, rl, result);
},
.null_literal => {
const main_token = main_tokens[node];
const src = token_starts[main_token];
const result = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.@"null"),
.val = Value.initTag(.null_value),
});
return rvalue(mod, scope, rl, result);
},
.optional_type => {
const src = token_starts[main_tokens[node]];
const operand = try typeExpr(mod, scope, node_datas[node].lhs);
const result = try addZIRUnOp(mod, scope, src, .optional_type, operand);
return rvalue(mod, scope, rl, result);
},
.unwrap_optional => {
const operand = try expr(mod, scope, rl, node_datas[node].lhs);
const op: zir.Inst.Tag = switch (rl) {
.ref => .optional_payload_safe_ptr,
else => .optional_payload_safe,
};
const src = token_starts[main_tokens[node]];
return addZIRUnOp(mod, scope, src, op, operand);
},
.block_two, .block_two_semicolon => {
const statements = [2]ast.Node.Index{ node_datas[node].lhs, node_datas[node].rhs };
if (node_datas[node].lhs == 0) {
return blockExpr(mod, scope, rl, node, statements[0..0]);
} else if (node_datas[node].rhs == 0) {
return blockExpr(mod, scope, rl, node, statements[0..1]);
} else {
return blockExpr(mod, scope, rl, node, statements[0..2]);
}
},
.block, .block_semicolon => {
const statements = tree.extra_data[node_datas[node].lhs..node_datas[node].rhs];
return blockExpr(mod, scope, rl, node, statements);
},
.enum_literal => {
const ident_token = main_tokens[node];
const name = try mod.identifierTokenString(scope, ident_token);
const src = token_starts[ident_token];
const result = try addZIRInst(mod, scope, src, zir.Inst.EnumLiteral, .{ .name = name }, .{});
return rvalue(mod, scope, rl, result);
},
.error_value => {
const ident_token = node_datas[node].rhs;
const name = try mod.identifierTokenString(scope, ident_token);
const src = token_starts[ident_token];
const result = try addZirInstTag(mod, scope, src, .error_value, .{ .name = name });
return rvalue(mod, scope, rl, result);
},
.error_union => {
const error_set = try typeExpr(mod, scope, node_datas[node].lhs);
const payload = try typeExpr(mod, scope, node_datas[node].rhs);
const src = token_starts[main_tokens[node]];
const result = try addZIRBinOp(mod, scope, src, .error_union_type, error_set, payload);
return rvalue(mod, scope, rl, result);
},
.merge_error_sets => {
const lhs = try typeExpr(mod, scope, node_datas[node].lhs);
const rhs = try typeExpr(mod, scope, node_datas[node].rhs);
const src = token_starts[main_tokens[node]];
const result = try addZIRBinOp(mod, scope, src, .merge_error_sets, lhs, rhs);
return rvalue(mod, scope, rl, result);
},
.anyframe_literal => {
const main_token = main_tokens[node];
const src = token_starts[main_token];
const result = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.type),
.val = Value.initTag(.anyframe_type),
});
return rvalue(mod, scope, rl, result);
},
.anyframe_type => {
const src = token_starts[node_datas[node].lhs];
const return_type = try typeExpr(mod, scope, node_datas[node].rhs);
const result = try addZIRUnOp(mod, scope, src, .anyframe_type, return_type);
return rvalue(mod, scope, rl, result);
},
.@"catch" => {
const catch_token = main_tokens[node];
const payload_token: ?ast.TokenIndex = if (token_tags[catch_token + 1] == .pipe)
catch_token + 2
else
null;
switch (rl) {
.ref => return orelseCatchExpr(
mod,
scope,
rl,
node_datas[node].lhs,
main_tokens[node],
.is_err_ptr,
.err_union_payload_unsafe_ptr,
.err_union_code_ptr,
node_datas[node].rhs,
payload_token,
),
else => return orelseCatchExpr(
mod,
scope,
rl,
node_datas[node].lhs,
main_tokens[node],
.is_err,
.err_union_payload_unsafe,
.err_union_code,
node_datas[node].rhs,
payload_token,
),
}
},
.@"orelse" => switch (rl) {
.ref => return orelseCatchExpr(
mod,
scope,
rl,
node_datas[node].lhs,
main_tokens[node],
.is_null_ptr,
.optional_payload_unsafe_ptr,
undefined,
node_datas[node].rhs,
null,
),
else => return orelseCatchExpr(
mod,
scope,
rl,
node_datas[node].lhs,
main_tokens[node],
.is_null,
.optional_payload_unsafe,
undefined,
node_datas[node].rhs,
null,
),
},
.ptr_type_aligned => return ptrType(mod, scope, rl, tree.ptrTypeAligned(node)),
.ptr_type_sentinel => return ptrType(mod, scope, rl, tree.ptrTypeSentinel(node)),
.ptr_type => return ptrType(mod, scope, rl, tree.ptrType(node)),
.ptr_type_bit_range => return ptrType(mod, scope, rl, tree.ptrTypeBitRange(node)),
.container_decl,
.container_decl_trailing,
=> return containerDecl(mod, scope, rl, tree.containerDecl(node)),
.container_decl_two, .container_decl_two_trailing => {
var buffer: [2]ast.Node.Index = undefined;
return containerDecl(mod, scope, rl, tree.containerDeclTwo(&buffer, node));
},
.container_decl_arg,
.container_decl_arg_trailing,
=> return containerDecl(mod, scope, rl, tree.containerDeclArg(node)),
.tagged_union,
.tagged_union_trailing,
=> return containerDecl(mod, scope, rl, tree.taggedUnion(node)),
.tagged_union_two, .tagged_union_two_trailing => {
var buffer: [2]ast.Node.Index = undefined;
return containerDecl(mod, scope, rl, tree.taggedUnionTwo(&buffer, node));
},
.tagged_union_enum_tag,
.tagged_union_enum_tag_trailing,
=> return containerDecl(mod, scope, rl, tree.taggedUnionEnumTag(node)),
.@"break" => return breakExpr(mod, scope, rl, node),
.@"continue" => return continueExpr(mod, scope, rl, node),
.grouped_expression => return expr(mod, scope, rl, node_datas[node].lhs),
.array_type => return arrayType(mod, scope, rl, node),
.array_type_sentinel => return arrayTypeSentinel(mod, scope, rl, node),
.char_literal => return charLiteral(mod, scope, rl, node),
.error_set_decl => return errorSetDecl(mod, scope, rl, node),
.array_access => return arrayAccess(mod, scope, rl, node),
.@"comptime" => return comptimeExpr(mod, scope, rl, node_datas[node].lhs),
.@"switch", .switch_comma => return switchExpr(mod, scope, rl, node),
.@"defer" => return mod.failNode(scope, node, "TODO implement astgen.expr for .defer", .{}),
.@"errdefer" => return mod.failNode(scope, node, "TODO implement astgen.expr for .errdefer", .{}),
.@"await" => return mod.failNode(scope, node, "TODO implement astgen.expr for .await", .{}),
.@"resume" => return mod.failNode(scope, node, "TODO implement astgen.expr for .resume", .{}),
.@"try" => return mod.failNode(scope, node, "TODO implement astgen.expr for .Try", .{}),
.array_init_one,
.array_init_one_comma,
.array_init_dot_two,
.array_init_dot_two_comma,
.array_init_dot,
.array_init_dot_comma,
.array_init,
.array_init_comma,
=> return mod.failNode(scope, node, "TODO implement astgen.expr for array literals", .{}),
.struct_init_one,
.struct_init_one_comma,
.struct_init_dot_two,
.struct_init_dot_two_comma,
.struct_init_dot,
.struct_init_dot_comma,
.struct_init,
.struct_init_comma,
=> return mod.failNode(scope, node, "TODO implement astgen.expr for struct literals", .{}),
.@"suspend" => return mod.failNode(scope, node, "TODO implement astgen.expr for .suspend", .{}),
.@"anytype" => return mod.failNode(scope, node, "TODO implement astgen.expr for .anytype", .{}),
.fn_proto_simple,
.fn_proto_multi,
.fn_proto_one,
.fn_proto,
=> return mod.failNode(scope, node, "TODO implement astgen.expr for function prototypes", .{}),
.@"nosuspend" => return mod.failNode(scope, node, "TODO implement astgen.expr for .nosuspend", .{}),
}
}
pub fn comptimeExpr(
mod: *Module,
parent_scope: *Scope,
rl: ResultLoc,
node: ast.Node.Index,
) InnerError!*zir.Inst {
// If we are already in a comptime scope, no need to make another one.
if (parent_scope.isComptime()) {
return expr(mod, parent_scope, rl, node);
}
const tree = parent_scope.tree();
const token_starts = tree.tokens.items(.start);
// Make a scope to collect generated instructions in the sub-expression.
var block_scope: Scope.GenZIR = .{
.parent = parent_scope,
.decl = parent_scope.ownerDecl().?,
.arena = parent_scope.arena(),
.force_comptime = true,
.instructions = .{},
};
defer block_scope.instructions.deinit(mod.gpa);
// No need to capture the result here because block_comptime_flat implies that the final
// instruction is the block's result value.
_ = try expr(mod, &block_scope.base, rl, node);
const src = token_starts[tree.firstToken(node)];
const block = try addZIRInstBlock(mod, parent_scope, src, .block_comptime_flat, .{
.instructions = try block_scope.arena.dupe(*zir.Inst, block_scope.instructions.items),
});
return &block.base;
}
fn breakExpr(
mod: *Module,
parent_scope: *Scope,
rl: ResultLoc,
node: ast.Node.Index,
) InnerError!*zir.Inst {
const tree = parent_scope.tree();
const node_datas = tree.nodes.items(.data);
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const src = token_starts[main_tokens[node]];
const break_label = node_datas[node].lhs;
const rhs = node_datas[node].rhs;
// Look for the label in the scope.
var scope = parent_scope;
while (true) {
switch (scope.tag) {
.gen_zir => {
const gen_zir = scope.cast(Scope.GenZIR).?;
const block_inst = blk: {
if (break_label != 0) {
if (gen_zir.label) |*label| {
if (try tokenIdentEql(mod, parent_scope, label.token, break_label)) {
label.used = true;
break :blk label.block_inst;
}
}
} else if (gen_zir.break_block) |inst| {
break :blk inst;
}
scope = gen_zir.parent;
continue;
};
if (rhs == 0) {
const result = try addZirInstTag(mod, parent_scope, src, .break_void, .{
.block = block_inst,
});
return rvalue(mod, parent_scope, rl, result);
}
gen_zir.break_count += 1;
const prev_rvalue_rl_count = gen_zir.rvalue_rl_count;
const operand = try expr(mod, parent_scope, gen_zir.break_result_loc, rhs);
const have_store_to_block = gen_zir.rvalue_rl_count != prev_rvalue_rl_count;
const br = try addZirInstTag(mod, parent_scope, src, .@"break", .{
.block = block_inst,
.operand = operand,
});
if (gen_zir.break_result_loc == .block_ptr) {
try gen_zir.labeled_breaks.append(mod.gpa, br.castTag(.@"break").?);
if (have_store_to_block) {
const inst_list = parent_scope.getGenZIR().instructions.items;
const last_inst = inst_list[inst_list.len - 2];
const store_inst = last_inst.castTag(.store_to_block_ptr).?;
assert(store_inst.positionals.lhs == gen_zir.rl_ptr.?);
try gen_zir.labeled_store_to_block_ptr_list.append(mod.gpa, store_inst);
}
}
return rvalue(mod, parent_scope, rl, br);
},
.local_val => scope = scope.cast(Scope.LocalVal).?.parent,
.local_ptr => scope = scope.cast(Scope.LocalPtr).?.parent,
else => if (break_label != 0) {
const label_name = try mod.identifierTokenString(parent_scope, break_label);
return mod.failTok(parent_scope, break_label, "label not found: '{s}'", .{label_name});
} else {
return mod.failTok(parent_scope, src, "break expression outside loop", .{});
},
}
}
}
fn continueExpr(
mod: *Module,
parent_scope: *Scope,
rl: ResultLoc,
node: ast.Node.Index,
) InnerError!*zir.Inst {
const tree = parent_scope.tree();
const node_datas = tree.nodes.items(.data);
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const src = token_starts[main_tokens[node]];
const break_label = node_datas[node].lhs;
// Look for the label in the scope.
var scope = parent_scope;
while (true) {
switch (scope.tag) {
.gen_zir => {
const gen_zir = scope.cast(Scope.GenZIR).?;
const continue_block = gen_zir.continue_block orelse {
scope = gen_zir.parent;
continue;
};
if (break_label != 0) blk: {
if (gen_zir.label) |*label| {
if (try tokenIdentEql(mod, parent_scope, label.token, break_label)) {
label.used = true;
break :blk;
}
}
// found continue but either it has a different label, or no label
scope = gen_zir.parent;
continue;
}
const result = try addZirInstTag(mod, parent_scope, src, .break_void, .{
.block = continue_block,
});
return rvalue(mod, parent_scope, rl, result);
},
.local_val => scope = scope.cast(Scope.LocalVal).?.parent,
.local_ptr => scope = scope.cast(Scope.LocalPtr).?.parent,
else => if (break_label != 0) {
const label_name = try mod.identifierTokenString(parent_scope, break_label);
return mod.failTok(parent_scope, break_label, "label not found: '{s}'", .{label_name});
} else {
return mod.failTok(parent_scope, src, "continue expression outside loop", .{});
},
}
}
}
pub fn blockExpr(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
block_node: ast.Node.Index,
statements: []const ast.Node.Index,
) InnerError!*zir.Inst {
const tracy = trace(@src());
defer tracy.end();
const tree = scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const token_tags = tree.tokens.items(.tag);
const lbrace = main_tokens[block_node];
if (token_tags[lbrace - 1] == .colon) {
return labeledBlockExpr(mod, scope, rl, block_node, statements, .block);
}
try blockExprStmts(mod, scope, block_node, statements);
return rvalueVoid(mod, scope, rl, block_node, {});
}
fn checkLabelRedefinition(mod: *Module, parent_scope: *Scope, label: ast.TokenIndex) !void {
// Look for the label in the scope.
var scope = parent_scope;
while (true) {
switch (scope.tag) {
.gen_zir => {
const gen_zir = scope.cast(Scope.GenZIR).?;
if (gen_zir.label) |prev_label| {
if (try tokenIdentEql(mod, parent_scope, label, prev_label.token)) {
const tree = parent_scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const label_src = token_starts[label];
const prev_label_src = token_starts[prev_label.token];
const label_name = try mod.identifierTokenString(parent_scope, label);
const msg = msg: {
const msg = try mod.errMsg(
parent_scope,
label_src,
"redefinition of label '{s}'",
.{label_name},
);
errdefer msg.destroy(mod.gpa);
try mod.errNote(
parent_scope,
prev_label_src,
msg,
"previous definition is here",
.{},
);
break :msg msg;
};
return mod.failWithOwnedErrorMsg(parent_scope, msg);
}
}
scope = gen_zir.parent;
},
.local_val => scope = scope.cast(Scope.LocalVal).?.parent,
.local_ptr => scope = scope.cast(Scope.LocalPtr).?.parent,
else => return,
}
}
}
fn labeledBlockExpr(
mod: *Module,
parent_scope: *Scope,
rl: ResultLoc,
block_node: ast.Node.Index,
statements: []const ast.Node.Index,
zir_tag: zir.Inst.Tag,
) InnerError!*zir.Inst {
const tracy = trace(@src());
defer tracy.end();
assert(zir_tag == .block or zir_tag == .block_comptime);
const tree = parent_scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const token_tags = tree.tokens.items(.tag);
const lbrace = main_tokens[block_node];
const label_token = lbrace - 2;
assert(token_tags[label_token] == .identifier);
const src = token_starts[lbrace];
try checkLabelRedefinition(mod, parent_scope, label_token);
// Create the Block ZIR instruction so that we can put it into the GenZIR struct
// so that break statements can reference it.
const gen_zir = parent_scope.getGenZIR();
const block_inst = try gen_zir.arena.create(zir.Inst.Block);
block_inst.* = .{
.base = .{
.tag = zir_tag,
.src = src,
},
.positionals = .{
.body = .{ .instructions = undefined },
},
.kw_args = .{},
};
var block_scope: Scope.GenZIR = .{
.parent = parent_scope,
.decl = parent_scope.ownerDecl().?,
.arena = gen_zir.arena,
.force_comptime = parent_scope.isComptime(),
.instructions = .{},
// TODO @as here is working around a stage1 miscompilation bug :(
.label = @as(?Scope.GenZIR.Label, Scope.GenZIR.Label{
.token = label_token,
.block_inst = block_inst,
}),
};
setBlockResultLoc(&block_scope, rl);
defer block_scope.instructions.deinit(mod.gpa);
defer block_scope.labeled_breaks.deinit(mod.gpa);
defer block_scope.labeled_store_to_block_ptr_list.deinit(mod.gpa);
try blockExprStmts(mod, &block_scope.base, block_node, statements);
if (!block_scope.label.?.used) {
return mod.failTok(parent_scope, label_token, "unused block label", .{});
}
try gen_zir.instructions.append(mod.gpa, &block_inst.base);
const strat = rlStrategy(rl, &block_scope);
switch (strat.tag) {
.break_void => {
// The code took advantage of the result location as a pointer.
// Turn the break instructions into break_void instructions.
for (block_scope.labeled_breaks.items) |br| {
br.base.tag = .break_void;
}
// TODO technically not needed since we changed the tag to break_void but
// would be better still to elide the ones that are in this list.
try copyBodyNoEliding(&block_inst.positionals.body, block_scope);
return &block_inst.base;
},
.break_operand => {
// All break operands are values that did not use the result location pointer.
if (strat.elide_store_to_block_ptr_instructions) {
for (block_scope.labeled_store_to_block_ptr_list.items) |inst| {
inst.base.tag = .void_value;
}
// TODO technically not needed since we changed the tag to void_value but
// would be better still to elide the ones that are in this list.
}
try copyBodyNoEliding(&block_inst.positionals.body, block_scope);
switch (rl) {
.ref => return &block_inst.base,
else => return rvalue(mod, parent_scope, rl, &block_inst.base),
}
},
}
}
fn blockExprStmts(
mod: *Module,
parent_scope: *Scope,
node: ast.Node.Index,
statements: []const ast.Node.Index,
) !void {
const tree = parent_scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const node_tags = tree.nodes.items(.tag);
var block_arena = std.heap.ArenaAllocator.init(mod.gpa);
defer block_arena.deinit();
var scope = parent_scope;
for (statements) |statement| {
const src = token_starts[tree.firstToken(statement)];
_ = try addZIRNoOp(mod, scope, src, .dbg_stmt);
switch (node_tags[statement]) {
.global_var_decl => scope = try varDecl(mod, scope, &block_arena.allocator, tree.globalVarDecl(statement)),
.local_var_decl => scope = try varDecl(mod, scope, &block_arena.allocator, tree.localVarDecl(statement)),
.simple_var_decl => scope = try varDecl(mod, scope, &block_arena.allocator, tree.simpleVarDecl(statement)),
.aligned_var_decl => scope = try varDecl(mod, scope, &block_arena.allocator, tree.alignedVarDecl(statement)),
.assign => try assign(mod, scope, statement),
.assign_bit_and => try assignOp(mod, scope, statement, .bit_and),
.assign_bit_or => try assignOp(mod, scope, statement, .bit_or),
.assign_bit_shift_left => try assignOp(mod, scope, statement, .shl),
.assign_bit_shift_right => try assignOp(mod, scope, statement, .shr),
.assign_bit_xor => try assignOp(mod, scope, statement, .xor),
.assign_div => try assignOp(mod, scope, statement, .div),
.assign_sub => try assignOp(mod, scope, statement, .sub),
.assign_sub_wrap => try assignOp(mod, scope, statement, .subwrap),
.assign_mod => try assignOp(mod, scope, statement, .mod_rem),
.assign_add => try assignOp(mod, scope, statement, .add),
.assign_add_wrap => try assignOp(mod, scope, statement, .addwrap),
.assign_mul => try assignOp(mod, scope, statement, .mul),
.assign_mul_wrap => try assignOp(mod, scope, statement, .mulwrap),
else => {
const possibly_unused_result = try expr(mod, scope, .none, statement);
if (!possibly_unused_result.tag.isNoReturn()) {
_ = try addZIRUnOp(mod, scope, src, .ensure_result_used, possibly_unused_result);
}
},
}
}
}
fn varDecl(
mod: *Module,
scope: *Scope,
block_arena: *Allocator,
var_decl: ast.full.VarDecl,
) InnerError!*Scope {
if (var_decl.comptime_token) |comptime_token| {
return mod.failTok(scope, comptime_token, "TODO implement comptime locals", .{});
}
if (var_decl.ast.align_node != 0) {
return mod.failNode(scope, var_decl.ast.align_node, "TODO implement alignment on locals", .{});
}
const tree = scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const token_tags = tree.tokens.items(.tag);
const name_token = var_decl.ast.mut_token + 1;
const name_src = token_starts[name_token];
const ident_name = try mod.identifierTokenString(scope, name_token);
// Local variables shadowing detection, including function parameters.
{
var s = scope;
while (true) switch (s.tag) {
.local_val => {
const local_val = s.cast(Scope.LocalVal).?;
if (mem.eql(u8, local_val.name, ident_name)) {
const msg = msg: {
const msg = try mod.errMsg(scope, name_src, "redefinition of '{s}'", .{
ident_name,
});
errdefer msg.destroy(mod.gpa);
try mod.errNote(scope, local_val.inst.src, msg, "previous definition is here", .{});
break :msg msg;
};
return mod.failWithOwnedErrorMsg(scope, msg);
}
s = local_val.parent;
},
.local_ptr => {
const local_ptr = s.cast(Scope.LocalPtr).?;
if (mem.eql(u8, local_ptr.name, ident_name)) {
const msg = msg: {
const msg = try mod.errMsg(scope, name_src, "redefinition of '{s}'", .{
ident_name,
});
errdefer msg.destroy(mod.gpa);
try mod.errNote(scope, local_ptr.ptr.src, msg, "previous definition is here", .{});
break :msg msg;
};
return mod.failWithOwnedErrorMsg(scope, msg);
}
s = local_ptr.parent;
},
.gen_zir => s = s.cast(Scope.GenZIR).?.parent,
else => break,
};
}
// Namespace vars shadowing detection
if (mod.lookupDeclName(scope, ident_name)) |_| {
// TODO add note for other definition
return mod.fail(scope, name_src, "redefinition of '{s}'", .{ident_name});
}
if (var_decl.ast.init_node == 0) {
return mod.fail(scope, name_src, "variables must be initialized", .{});
}
switch (token_tags[var_decl.ast.mut_token]) {
.keyword_const => {
// Depending on the type of AST the initialization expression is, we may need an lvalue
// or an rvalue as a result location. If it is an rvalue, we can use the instruction as
// the variable, no memory location needed.
if (!nodeMayNeedMemoryLocation(scope, var_decl.ast.init_node)) {
const result_loc: ResultLoc = if (var_decl.ast.type_node != 0)
.{ .ty = try typeExpr(mod, scope, var_decl.ast.type_node) }
else
.none;
const init_inst = try expr(mod, scope, result_loc, var_decl.ast.init_node);
const sub_scope = try block_arena.create(Scope.LocalVal);
sub_scope.* = .{
.parent = scope,
.gen_zir = scope.getGenZIR(),
.name = ident_name,
.inst = init_inst,
};
return &sub_scope.base;
}
// Detect whether the initialization expression actually uses the
// result location pointer.
var init_scope: Scope.GenZIR = .{
.parent = scope,
.decl = scope.ownerDecl().?,
.arena = scope.arena(),
.force_comptime = scope.isComptime(),
.instructions = .{},
};
defer init_scope.instructions.deinit(mod.gpa);
var resolve_inferred_alloc: ?*zir.Inst = null;
var opt_type_inst: ?*zir.Inst = null;
if (var_decl.ast.type_node != 0) {
const type_inst = try typeExpr(mod, &init_scope.base, var_decl.ast.type_node);
opt_type_inst = type_inst;
init_scope.rl_ptr = try addZIRUnOp(mod, &init_scope.base, name_src, .alloc, type_inst);
} else {
const alloc = try addZIRNoOpT(mod, &init_scope.base, name_src, .alloc_inferred);
resolve_inferred_alloc = &alloc.base;
init_scope.rl_ptr = &alloc.base;
}
const init_result_loc: ResultLoc = .{ .block_ptr = &init_scope };
const init_inst = try expr(mod, &init_scope.base, init_result_loc, var_decl.ast.init_node);
const parent_zir = &scope.getGenZIR().instructions;
if (init_scope.rvalue_rl_count == 1) {
// Result location pointer not used. We don't need an alloc for this
// const local, and type inference becomes trivial.
// Move the init_scope instructions into the parent scope, eliding
// the alloc instruction and the store_to_block_ptr instruction.
const expected_len = parent_zir.items.len + init_scope.instructions.items.len - 2;
try parent_zir.ensureCapacity(mod.gpa, expected_len);
for (init_scope.instructions.items) |src_inst| {
if (src_inst == init_scope.rl_ptr.?) continue;
if (src_inst.castTag(.store_to_block_ptr)) |store| {
if (store.positionals.lhs == init_scope.rl_ptr.?) continue;
}
parent_zir.appendAssumeCapacity(src_inst);
}
assert(parent_zir.items.len == expected_len);
const casted_init = if (opt_type_inst) |type_inst|
try addZIRBinOp(mod, scope, type_inst.src, .as, type_inst, init_inst)
else
init_inst;
const sub_scope = try block_arena.create(Scope.LocalVal);
sub_scope.* = .{
.parent = scope,
.gen_zir = scope.getGenZIR(),
.name = ident_name,
.inst = casted_init,
};
return &sub_scope.base;
}
// The initialization expression took advantage of the result location
// of the const local. In this case we will create an alloc and a LocalPtr for it.
// Move the init_scope instructions into the parent scope, swapping
// store_to_block_ptr for store_to_inferred_ptr.
const expected_len = parent_zir.items.len + init_scope.instructions.items.len;
try parent_zir.ensureCapacity(mod.gpa, expected_len);
for (init_scope.instructions.items) |src_inst| {
if (src_inst.castTag(.store_to_block_ptr)) |store| {
if (store.positionals.lhs == init_scope.rl_ptr.?) {
src_inst.tag = .store_to_inferred_ptr;
}
}
parent_zir.appendAssumeCapacity(src_inst);
}
assert(parent_zir.items.len == expected_len);
if (resolve_inferred_alloc) |inst| {
_ = try addZIRUnOp(mod, scope, name_src, .resolve_inferred_alloc, inst);
}
const sub_scope = try block_arena.create(Scope.LocalPtr);
sub_scope.* = .{
.parent = scope,
.gen_zir = scope.getGenZIR(),
.name = ident_name,
.ptr = init_scope.rl_ptr.?,
};
return &sub_scope.base;
},
.keyword_var => {
var resolve_inferred_alloc: ?*zir.Inst = null;
const var_data: struct {
result_loc: ResultLoc,
alloc: *zir.Inst,
} = if (var_decl.ast.type_node != 0) a: {
const type_inst = try typeExpr(mod, scope, var_decl.ast.type_node);
const alloc = try addZIRUnOp(mod, scope, name_src, .alloc_mut, type_inst);
break :a .{ .alloc = alloc, .result_loc = .{ .ptr = alloc } };
} else a: {
const alloc = try addZIRNoOpT(mod, scope, name_src, .alloc_inferred_mut);
resolve_inferred_alloc = &alloc.base;
break :a .{ .alloc = &alloc.base, .result_loc = .{ .inferred_ptr = alloc } };
};
const init_inst = try expr(mod, scope, var_data.result_loc, var_decl.ast.init_node);
if (resolve_inferred_alloc) |inst| {
_ = try addZIRUnOp(mod, scope, name_src, .resolve_inferred_alloc, inst);
}
const sub_scope = try block_arena.create(Scope.LocalPtr);
sub_scope.* = .{
.parent = scope,
.gen_zir = scope.getGenZIR(),
.name = ident_name,
.ptr = var_data.alloc,
};
return &sub_scope.base;
},
else => unreachable,
}
}
fn assign(mod: *Module, scope: *Scope, infix_node: ast.Node.Index) InnerError!void {
const tree = scope.tree();
const node_datas = tree.nodes.items(.data);
const main_tokens = tree.nodes.items(.main_token);
const node_tags = tree.nodes.items(.tag);
const lhs = node_datas[infix_node].lhs;
const rhs = node_datas[infix_node].rhs;
if (node_tags[lhs] == .identifier) {
// This intentionally does not support `@"_"` syntax.
const ident_name = tree.tokenSlice(main_tokens[lhs]);
if (mem.eql(u8, ident_name, "_")) {
_ = try expr(mod, scope, .discard, rhs);
return;
}
}
const lvalue = try lvalExpr(mod, scope, lhs);
_ = try expr(mod, scope, .{ .ptr = lvalue }, rhs);
}
fn assignOp(
mod: *Module,
scope: *Scope,
infix_node: ast.Node.Index,
op_inst_tag: zir.Inst.Tag,
) InnerError!void {
const tree = scope.tree();
const node_datas = tree.nodes.items(.data);
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const lhs_ptr = try lvalExpr(mod, scope, node_datas[infix_node].lhs);
const lhs = try addZIRUnOp(mod, scope, lhs_ptr.src, .deref, lhs_ptr);
const lhs_type = try addZIRUnOp(mod, scope, lhs_ptr.src, .typeof, lhs);
const rhs = try expr(mod, scope, .{ .ty = lhs_type }, node_datas[infix_node].rhs);
const src = token_starts[main_tokens[infix_node]];
const result = try addZIRBinOp(mod, scope, src, op_inst_tag, lhs, rhs);
_ = try addZIRBinOp(mod, scope, src, .store, lhs_ptr, result);
}
fn boolNot(mod: *Module, scope: *Scope, node: ast.Node.Index) InnerError!*zir.Inst {
const tree = scope.tree();
const node_datas = tree.nodes.items(.data);
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const src = token_starts[main_tokens[node]];
const bool_type = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.type),
.val = Value.initTag(.bool_type),
});
const operand = try expr(mod, scope, .{ .ty = bool_type }, node_datas[node].lhs);
return addZIRUnOp(mod, scope, src, .bool_not, operand);
}
fn bitNot(mod: *Module, scope: *Scope, node: ast.Node.Index) InnerError!*zir.Inst {
const tree = scope.tree();
const node_datas = tree.nodes.items(.data);
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const src = token_starts[main_tokens[node]];
const operand = try expr(mod, scope, .none, node_datas[node].lhs);
return addZIRUnOp(mod, scope, src, .bit_not, operand);
}
fn negation(
mod: *Module,
scope: *Scope,
node: ast.Node.Index,
op_inst_tag: zir.Inst.Tag,
) InnerError!*zir.Inst {
const tree = scope.tree();
const node_datas = tree.nodes.items(.data);
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const src = token_starts[main_tokens[node]];
const lhs = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.comptime_int),
.val = Value.initTag(.zero),
});
const rhs = try expr(mod, scope, .none, node_datas[node].lhs);
return addZIRBinOp(mod, scope, src, op_inst_tag, lhs, rhs);
}
fn ptrType(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
ptr_info: ast.full.PtrType,
) InnerError!*zir.Inst {
const tree = scope.tree();
const token_starts = tree.tokens.items(.start);
const src = token_starts[ptr_info.ast.main_token];
const simple = ptr_info.allowzero_token == null and
ptr_info.ast.align_node == 0 and
ptr_info.volatile_token == null and
ptr_info.ast.sentinel == 0;
if (simple) {
const child_type = try typeExpr(mod, scope, ptr_info.ast.child_type);
const mutable = ptr_info.const_token == null;
const T = zir.Inst.Tag;
const result = try addZIRUnOp(mod, scope, src, switch (ptr_info.size) {
.One => if (mutable) T.single_mut_ptr_type else T.single_const_ptr_type,
.Many => if (mutable) T.many_mut_ptr_type else T.many_const_ptr_type,
.C => if (mutable) T.c_mut_ptr_type else T.c_const_ptr_type,
.Slice => if (mutable) T.mut_slice_type else T.const_slice_type,
}, child_type);
return rvalue(mod, scope, rl, result);
}
var kw_args: std.meta.fieldInfo(zir.Inst.PtrType, .kw_args).field_type = .{};
kw_args.size = ptr_info.size;
kw_args.@"allowzero" = ptr_info.allowzero_token != null;
if (ptr_info.ast.align_node != 0) {
kw_args.@"align" = try expr(mod, scope, .none, ptr_info.ast.align_node);
if (ptr_info.ast.bit_range_start != 0) {
kw_args.align_bit_start = try expr(mod, scope, .none, ptr_info.ast.bit_range_start);
kw_args.align_bit_end = try expr(mod, scope, .none, ptr_info.ast.bit_range_end);
}
}
kw_args.mutable = ptr_info.const_token == null;
kw_args.@"volatile" = ptr_info.volatile_token != null;
const child_type = try typeExpr(mod, scope, ptr_info.ast.child_type);
if (ptr_info.ast.sentinel != 0) {
kw_args.sentinel = try expr(mod, scope, .{ .ty = child_type }, ptr_info.ast.sentinel);
}
const result = try addZIRInst(mod, scope, src, zir.Inst.PtrType, .{ .child_type = child_type }, kw_args);
return rvalue(mod, scope, rl, result);
}
fn arrayType(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !*zir.Inst {
const tree = scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const node_datas = tree.nodes.items(.data);
const token_starts = tree.tokens.items(.start);
const src = token_starts[main_tokens[node]];
const usize_type = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.type),
.val = Value.initTag(.usize_type),
});
const len_node = node_datas[node].lhs;
const elem_node = node_datas[node].rhs;
if (len_node == 0) {
const elem_type = try typeExpr(mod, scope, elem_node);
const result = try addZIRUnOp(mod, scope, src, .mut_slice_type, elem_type);
return rvalue(mod, scope, rl, result);
} else {
// TODO check for [_]T
const len = try expr(mod, scope, .{ .ty = usize_type }, len_node);
const elem_type = try typeExpr(mod, scope, elem_node);
const result = try addZIRBinOp(mod, scope, src, .array_type, len, elem_type);
return rvalue(mod, scope, rl, result);
}
}
fn arrayTypeSentinel(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !*zir.Inst {
const tree = scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const node_datas = tree.nodes.items(.data);
const len_node = node_datas[node].lhs;
const extra = tree.extraData(node_datas[node].rhs, ast.Node.ArrayTypeSentinel);
const src = token_starts[main_tokens[node]];
const usize_type = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.type),
.val = Value.initTag(.usize_type),
});
// TODO check for [_]T
const len = try expr(mod, scope, .{ .ty = usize_type }, len_node);
const sentinel_uncasted = try expr(mod, scope, .none, extra.sentinel);
const elem_type = try typeExpr(mod, scope, extra.elem_type);
const sentinel = try addZIRBinOp(mod, scope, src, .as, elem_type, sentinel_uncasted);
const result = try addZIRInst(mod, scope, src, zir.Inst.ArrayTypeSentinel, .{
.len = len,
.sentinel = sentinel,
.elem_type = elem_type,
}, .{});
return rvalue(mod, scope, rl, result);
}
fn containerField(
mod: *Module,
scope: *Scope,
field: ast.full.ContainerField,
) InnerError!*zir.Inst {
const tree = scope.tree();
const token_starts = tree.tokens.items(.start);
const src = token_starts[field.ast.name_token];
const name = try mod.identifierTokenString(scope, field.ast.name_token);
if (field.comptime_token == null and field.ast.value_expr == 0 and field.ast.align_expr == 0) {
if (field.ast.type_expr != 0) {
const ty = try typeExpr(mod, scope, field.ast.type_expr);
return addZIRInst(mod, scope, src, zir.Inst.ContainerFieldTyped, .{
.bytes = name,
.ty = ty,
}, .{});
} else {
return addZIRInst(mod, scope, src, zir.Inst.ContainerFieldNamed, .{
.bytes = name,
}, .{});
}
}
const ty = if (field.ast.type_expr != 0) try typeExpr(mod, scope, field.ast.type_expr) else null;
// TODO result location should be alignment type
const alignment = if (field.ast.align_expr != 0) try expr(mod, scope, .none, field.ast.align_expr) else null;
// TODO result location should be the field type
const init = if (field.ast.value_expr != 0) try expr(mod, scope, .none, field.ast.value_expr) else null;
return addZIRInst(mod, scope, src, zir.Inst.ContainerField, .{
.bytes = name,
}, .{
.ty = ty,
.init = init,
.alignment = alignment,
.is_comptime = field.comptime_token != null,
});
}
fn containerDecl(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
container_decl: ast.full.ContainerDecl,
) InnerError!*zir.Inst {
const tree = scope.tree();
const token_starts = tree.tokens.items(.start);
const node_tags = tree.nodes.items(.tag);
const token_tags = tree.tokens.items(.tag);
const src = token_starts[container_decl.ast.main_token];
var gen_scope: Scope.GenZIR = .{
.parent = scope,
.decl = scope.ownerDecl().?,
.arena = scope.arena(),
.force_comptime = scope.isComptime(),
.instructions = .{},
};
defer gen_scope.instructions.deinit(mod.gpa);
var fields = std.ArrayList(*zir.Inst).init(mod.gpa);
defer fields.deinit();
for (container_decl.ast.members) |member| {
// TODO just handle these cases differently since they end up with different ZIR
// instructions anyway. It will be simpler & have fewer branches.
const field = switch (node_tags[member]) {
.container_field_init => try containerField(mod, &gen_scope.base, tree.containerFieldInit(member)),
.container_field_align => try containerField(mod, &gen_scope.base, tree.containerFieldAlign(member)),
.container_field => try containerField(mod, &gen_scope.base, tree.containerField(member)),
else => continue,
};
try fields.append(field);
}
var decl_arena = std.heap.ArenaAllocator.init(mod.gpa);
errdefer decl_arena.deinit();
const arena = &decl_arena.allocator;
var layout: std.builtin.TypeInfo.ContainerLayout = .Auto;
if (container_decl.layout_token) |some| switch (token_tags[some]) {
.keyword_extern => layout = .Extern,
.keyword_packed => layout = .Packed,
else => unreachable,
};
// TODO this implementation is incorrect. The types must be created in semantic
// analysis, not astgen, because the same ZIR is re-used for multiple inline function calls,
// comptime function calls, and generic function instantiations, and these
// must result in different instances of container types.
const container_type = switch (token_tags[container_decl.ast.main_token]) {
.keyword_enum => blk: {
const tag_type: ?*zir.Inst = if (container_decl.ast.arg != 0)
try typeExpr(mod, &gen_scope.base, container_decl.ast.arg)
else
null;
const inst = try addZIRInst(mod, &gen_scope.base, src, zir.Inst.EnumType, .{
.fields = try arena.dupe(*zir.Inst, fields.items),
}, .{
.layout = layout,
.tag_type = tag_type,
});
const enum_type = try arena.create(Type.Payload.Enum);
enum_type.* = .{
.analysis = .{
.queued = .{
.body = .{ .instructions = try arena.dupe(*zir.Inst, gen_scope.instructions.items) },
.inst = inst,
},
},
.scope = .{
.file_scope = scope.getFileScope(),
.ty = Type.initPayload(&enum_type.base),
},
};
break :blk Type.initPayload(&enum_type.base);
},
.keyword_struct => blk: {
assert(container_decl.ast.arg == 0);
const inst = try addZIRInst(mod, &gen_scope.base, src, zir.Inst.StructType, .{
.fields = try arena.dupe(*zir.Inst, fields.items),
}, .{
.layout = layout,
});
const struct_type = try arena.create(Type.Payload.Struct);
struct_type.* = .{
.analysis = .{
.queued = .{
.body = .{ .instructions = try arena.dupe(*zir.Inst, gen_scope.instructions.items) },
.inst = inst,
},
},
.scope = .{
.file_scope = scope.getFileScope(),
.ty = Type.initPayload(&struct_type.base),
},
};
break :blk Type.initPayload(&struct_type.base);
},
.keyword_union => blk: {
const init_inst: ?*zir.Inst = if (container_decl.ast.arg != 0)
try typeExpr(mod, &gen_scope.base, container_decl.ast.arg)
else
null;
const has_enum_token = container_decl.ast.enum_token != null;
const inst = try addZIRInst(mod, &gen_scope.base, src, zir.Inst.UnionType, .{
.fields = try arena.dupe(*zir.Inst, fields.items),
}, .{
.layout = layout,
.has_enum_token = has_enum_token,
.init_inst = init_inst,
});
const union_type = try arena.create(Type.Payload.Union);
union_type.* = .{
.analysis = .{
.queued = .{
.body = .{ .instructions = try arena.dupe(*zir.Inst, gen_scope.instructions.items) },
.inst = inst,
},
},
.scope = .{
.file_scope = scope.getFileScope(),
.ty = Type.initPayload(&union_type.base),
},
};
break :blk Type.initPayload(&union_type.base);
},
.keyword_opaque => blk: {
if (fields.items.len > 0) {
return mod.fail(scope, fields.items[0].src, "opaque types cannot have fields", .{});
}
const opaque_type = try arena.create(Type.Payload.Opaque);
opaque_type.* = .{
.scope = .{
.file_scope = scope.getFileScope(),
.ty = Type.initPayload(&opaque_type.base),
},
};
break :blk Type.initPayload(&opaque_type.base);
},
else => unreachable,
};
const val = try Value.Tag.ty.create(arena, container_type);
const decl = try mod.createContainerDecl(scope, container_decl.ast.main_token, &decl_arena, .{
.ty = Type.initTag(.type),
.val = val,
});
if (rl == .ref) {
return addZIRInst(mod, scope, src, zir.Inst.DeclRef, .{ .decl = decl }, .{});
} else {
return rvalue(mod, scope, rl, try addZIRInst(mod, scope, src, zir.Inst.DeclVal, .{
.decl = decl,
}, .{}));
}
}
fn errorSetDecl(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
node: ast.Node.Index,
) InnerError!*zir.Inst {
const tree = scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const token_tags = tree.tokens.items(.tag);
const token_starts = tree.tokens.items(.start);
// Count how many fields there are.
const error_token = main_tokens[node];
const count: usize = count: {
var tok_i = error_token + 2;
var count: usize = 0;
while (true) : (tok_i += 1) {
switch (token_tags[tok_i]) {
.doc_comment, .comma => {},
.identifier => count += 1,
.r_paren => break :count count,
else => unreachable,
}
} else unreachable; // TODO should not need else unreachable here
};
const fields = try scope.arena().alloc([]const u8, count);
{
var tok_i = error_token + 2;
var field_i: usize = 0;
while (true) : (tok_i += 1) {
switch (token_tags[tok_i]) {
.doc_comment, .comma => {},
.identifier => {
fields[field_i] = try mod.identifierTokenString(scope, tok_i);
field_i += 1;
},
.r_paren => break,
else => unreachable,
}
}
}
const src = token_starts[error_token];
const result = try addZIRInst(mod, scope, src, zir.Inst.ErrorSet, .{ .fields = fields }, .{});
return rvalue(mod, scope, rl, result);
}
fn orelseCatchExpr(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
lhs: ast.Node.Index,
op_token: ast.TokenIndex,
cond_op: zir.Inst.Tag,
unwrap_op: zir.Inst.Tag,
unwrap_code_op: zir.Inst.Tag,
rhs: ast.Node.Index,
payload_token: ?ast.TokenIndex,
) InnerError!*zir.Inst {
const tree = scope.tree();
const token_starts = tree.tokens.items(.start);
const src = token_starts[op_token];
var block_scope: Scope.GenZIR = .{
.parent = scope,
.decl = scope.ownerDecl().?,
.arena = scope.arena(),
.force_comptime = scope.isComptime(),
.instructions = .{},
};
setBlockResultLoc(&block_scope, rl);
defer block_scope.instructions.deinit(mod.gpa);
// This could be a pointer or value depending on the `rl` parameter.
block_scope.break_count += 1;
const operand = try expr(mod, &block_scope.base, block_scope.break_result_loc, lhs);
const cond = try addZIRUnOp(mod, &block_scope.base, src, cond_op, operand);
const condbr = try addZIRInstSpecial(mod, &block_scope.base, src, zir.Inst.CondBr, .{
.condition = cond,
.then_body = undefined, // populated below
.else_body = undefined, // populated below
}, .{});
const block = try addZIRInstBlock(mod, scope, src, .block, .{
.instructions = try block_scope.arena.dupe(*zir.Inst, block_scope.instructions.items),
});
var then_scope: Scope.GenZIR = .{
.parent = &block_scope.base,
.decl = block_scope.decl,
.arena = block_scope.arena,
.force_comptime = block_scope.force_comptime,
.instructions = .{},
};
defer then_scope.instructions.deinit(mod.gpa);
var err_val_scope: Scope.LocalVal = undefined;
const then_sub_scope = blk: {
const payload = payload_token orelse break :blk &then_scope.base;
if (mem.eql(u8, tree.tokenSlice(payload), "_")) {
return mod.failTok(&then_scope.base, payload, "discard of error capture; omit it instead", .{});
}
const err_name = try mod.identifierTokenString(scope, payload);
err_val_scope = .{
.parent = &then_scope.base,
.gen_zir = &then_scope,
.name = err_name,
.inst = try addZIRUnOp(mod, &then_scope.base, src, unwrap_code_op, operand),
};
break :blk &err_val_scope.base;
};
block_scope.break_count += 1;
const then_result = try expr(mod, then_sub_scope, block_scope.break_result_loc, rhs);
var else_scope: Scope.GenZIR = .{
.parent = &block_scope.base,
.decl = block_scope.decl,
.arena = block_scope.arena,
.force_comptime = block_scope.force_comptime,
.instructions = .{},
};
defer else_scope.instructions.deinit(mod.gpa);
// This could be a pointer or value depending on `unwrap_op`.
const unwrapped_payload = try addZIRUnOp(mod, &else_scope.base, src, unwrap_op, operand);
return finishThenElseBlock(
mod,
scope,
rl,
&block_scope,
&then_scope,
&else_scope,
&condbr.positionals.then_body,
&condbr.positionals.else_body,
src,
src,
then_result,
unwrapped_payload,
block,
block,
);
}
fn finishThenElseBlock(
mod: *Module,
parent_scope: *Scope,
rl: ResultLoc,
block_scope: *Scope.GenZIR,
then_scope: *Scope.GenZIR,
else_scope: *Scope.GenZIR,
then_body: *zir.Body,
else_body: *zir.Body,
then_src: usize,
else_src: usize,
then_result: *zir.Inst,
else_result: ?*zir.Inst,
main_block: *zir.Inst.Block,
then_break_block: *zir.Inst.Block,
) InnerError!*zir.Inst {
// We now have enough information to decide whether the result instruction should
// be communicated via result location pointer or break instructions.
const strat = rlStrategy(rl, block_scope);
switch (strat.tag) {
.break_void => {
if (!then_result.tag.isNoReturn()) {
_ = try addZirInstTag(mod, &then_scope.base, then_src, .break_void, .{
.block = then_break_block,
});
}
if (else_result) |inst| {
if (!inst.tag.isNoReturn()) {
_ = try addZirInstTag(mod, &else_scope.base, else_src, .break_void, .{
.block = main_block,
});
}
} else {
_ = try addZirInstTag(mod, &else_scope.base, else_src, .break_void, .{
.block = main_block,
});
}
assert(!strat.elide_store_to_block_ptr_instructions);
try copyBodyNoEliding(then_body, then_scope.*);
try copyBodyNoEliding(else_body, else_scope.*);
return &main_block.base;
},
.break_operand => {
if (!then_result.tag.isNoReturn()) {
_ = try addZirInstTag(mod, &then_scope.base, then_src, .@"break", .{
.block = then_break_block,
.operand = then_result,
});
}
if (else_result) |inst| {
if (!inst.tag.isNoReturn()) {
_ = try addZirInstTag(mod, &else_scope.base, else_src, .@"break", .{
.block = main_block,
.operand = inst,
});
}
} else {
_ = try addZirInstTag(mod, &else_scope.base, else_src, .break_void, .{
.block = main_block,
});
}
if (strat.elide_store_to_block_ptr_instructions) {
try copyBodyWithElidedStoreBlockPtr(then_body, then_scope.*);
try copyBodyWithElidedStoreBlockPtr(else_body, else_scope.*);
} else {
try copyBodyNoEliding(then_body, then_scope.*);
try copyBodyNoEliding(else_body, else_scope.*);
}
switch (rl) {
.ref => return &main_block.base,
else => return rvalue(mod, parent_scope, rl, &main_block.base),
}
},
}
}
/// Return whether the identifier names of two tokens are equal. Resolves @""
/// tokens without allocating.
/// OK in theory it could do it without allocating. This implementation
/// allocates when the @"" form is used.
fn tokenIdentEql(mod: *Module, scope: *Scope, token1: ast.TokenIndex, token2: ast.TokenIndex) !bool {
const ident_name_1 = try mod.identifierTokenString(scope, token1);
const ident_name_2 = try mod.identifierTokenString(scope, token2);
return mem.eql(u8, ident_name_1, ident_name_2);
}
pub fn fieldAccess(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerError!*zir.Inst {
const tree = scope.tree();
const token_starts = tree.tokens.items(.start);
const main_tokens = tree.nodes.items(.main_token);
const node_datas = tree.nodes.items(.data);
const dot_token = main_tokens[node];
const src = token_starts[dot_token];
const field_ident = dot_token + 1;
const field_name = try mod.identifierTokenString(scope, field_ident);
if (rl == .ref) {
return addZirInstTag(mod, scope, src, .field_ptr, .{
.object = try expr(mod, scope, .ref, node_datas[node].lhs),
.field_name = field_name,
});
} else {
return rvalue(mod, scope, rl, try addZirInstTag(mod, scope, src, .field_val, .{
.object = try expr(mod, scope, .none, node_datas[node].lhs),
.field_name = field_name,
}));
}
}
fn arrayAccess(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
node: ast.Node.Index,
) InnerError!*zir.Inst {
const tree = scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const node_datas = tree.nodes.items(.data);
const src = token_starts[main_tokens[node]];
const usize_type = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.type),
.val = Value.initTag(.usize_type),
});
const index_rl: ResultLoc = .{ .ty = usize_type };
switch (rl) {
.ref => return addZirInstTag(mod, scope, src, .elem_ptr, .{
.array = try expr(mod, scope, .ref, node_datas[node].lhs),
.index = try expr(mod, scope, index_rl, node_datas[node].rhs),
}),
else => return rvalue(mod, scope, rl, try addZirInstTag(mod, scope, src, .elem_val, .{
.array = try expr(mod, scope, .none, node_datas[node].lhs),
.index = try expr(mod, scope, index_rl, node_datas[node].rhs),
})),
}
}
fn sliceExpr(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
slice: ast.full.Slice,
) InnerError!*zir.Inst {
const tree = scope.tree();
const token_starts = tree.tokens.items(.start);
const src = token_starts[slice.ast.lbracket];
const usize_type = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.type),
.val = Value.initTag(.usize_type),
});
const array_ptr = try expr(mod, scope, .ref, slice.ast.sliced);
const start = try expr(mod, scope, .{ .ty = usize_type }, slice.ast.start);
if (slice.ast.sentinel == 0) {
if (slice.ast.end == 0) {
const result = try addZIRBinOp(mod, scope, src, .slice_start, array_ptr, start);
return rvalue(mod, scope, rl, result);
} else {
const end = try expr(mod, scope, .{ .ty = usize_type }, slice.ast.end);
// TODO a ZIR slice_open instruction
const result = try addZIRInst(mod, scope, src, zir.Inst.Slice, .{
.array_ptr = array_ptr,
.start = start,
}, .{ .end = end });
return rvalue(mod, scope, rl, result);
}
}
const end = try expr(mod, scope, .{ .ty = usize_type }, slice.ast.end);
// TODO pass the proper result loc to this expression using a ZIR instruction
// "get the child element type for a slice target".
const sentinel = try expr(mod, scope, .none, slice.ast.sentinel);
const result = try addZIRInst(mod, scope, src, zir.Inst.Slice, .{
.array_ptr = array_ptr,
.start = start,
}, .{
.end = end,
.sentinel = sentinel,
});
return rvalue(mod, scope, rl, result);
}
fn simpleBinOp(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
infix_node: ast.Node.Index,
op_inst_tag: zir.Inst.Tag,
) InnerError!*zir.Inst {
const tree = scope.tree();
const node_datas = tree.nodes.items(.data);
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const lhs = try expr(mod, scope, .none, node_datas[infix_node].lhs);
const rhs = try expr(mod, scope, .none, node_datas[infix_node].rhs);
const src = token_starts[main_tokens[infix_node]];
const result = try addZIRBinOp(mod, scope, src, op_inst_tag, lhs, rhs);
return rvalue(mod, scope, rl, result);
}
fn boolBinOp(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
infix_node: ast.Node.Index,
is_bool_and: bool,
) InnerError!*zir.Inst {
const tree = scope.tree();
const node_datas = tree.nodes.items(.data);
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const src = token_starts[main_tokens[infix_node]];
const bool_type = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.type),
.val = Value.initTag(.bool_type),
});
var block_scope: Scope.GenZIR = .{
.parent = scope,
.decl = scope.ownerDecl().?,
.arena = scope.arena(),
.force_comptime = scope.isComptime(),
.instructions = .{},
};
defer block_scope.instructions.deinit(mod.gpa);
const lhs = try expr(mod, scope, .{ .ty = bool_type }, node_datas[infix_node].lhs);
const condbr = try addZIRInstSpecial(mod, &block_scope.base, src, zir.Inst.CondBr, .{
.condition = lhs,
.then_body = undefined, // populated below
.else_body = undefined, // populated below
}, .{});
const block = try addZIRInstBlock(mod, scope, src, .block, .{
.instructions = try block_scope.arena.dupe(*zir.Inst, block_scope.instructions.items),
});
var rhs_scope: Scope.GenZIR = .{
.parent = scope,
.decl = block_scope.decl,
.arena = block_scope.arena,
.force_comptime = block_scope.force_comptime,
.instructions = .{},
};
defer rhs_scope.instructions.deinit(mod.gpa);
const rhs = try expr(mod, &rhs_scope.base, .{ .ty = bool_type }, node_datas[infix_node].rhs);
_ = try addZIRInst(mod, &rhs_scope.base, src, zir.Inst.Break, .{
.block = block,
.operand = rhs,
}, .{});
var const_scope: Scope.GenZIR = .{
.parent = scope,
.decl = block_scope.decl,
.arena = block_scope.arena,
.force_comptime = block_scope.force_comptime,
.instructions = .{},
};
defer const_scope.instructions.deinit(mod.gpa);
_ = try addZIRInst(mod, &const_scope.base, src, zir.Inst.Break, .{
.block = block,
.operand = try addZIRInstConst(mod, &const_scope.base, src, .{
.ty = Type.initTag(.bool),
.val = if (is_bool_and) Value.initTag(.bool_false) else Value.initTag(.bool_true),
}),
}, .{});
if (is_bool_and) {
// if lhs // AND
// break rhs
// else
// break false
condbr.positionals.then_body = .{ .instructions = try rhs_scope.arena.dupe(*zir.Inst, rhs_scope.instructions.items) };
condbr.positionals.else_body = .{ .instructions = try const_scope.arena.dupe(*zir.Inst, const_scope.instructions.items) };
} else {
// if lhs // OR
// break true
// else
// break rhs
condbr.positionals.then_body = .{ .instructions = try const_scope.arena.dupe(*zir.Inst, const_scope.instructions.items) };
condbr.positionals.else_body = .{ .instructions = try rhs_scope.arena.dupe(*zir.Inst, rhs_scope.instructions.items) };
}
return rvalue(mod, scope, rl, &block.base);
}
fn ifExpr(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
if_full: ast.full.If,
) InnerError!*zir.Inst {
var block_scope: Scope.GenZIR = .{
.parent = scope,
.decl = scope.ownerDecl().?,
.arena = scope.arena(),
.force_comptime = scope.isComptime(),
.instructions = .{},
};
setBlockResultLoc(&block_scope, rl);
defer block_scope.instructions.deinit(mod.gpa);
const tree = scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const if_src = token_starts[if_full.ast.if_token];
const cond = c: {
// TODO https://github.com/ziglang/zig/issues/7929
if (if_full.error_token) |error_token| {
return mod.failTok(scope, error_token, "TODO implement if error union", .{});
} else if (if_full.payload_token) |payload_token| {
return mod.failTok(scope, payload_token, "TODO implement if optional", .{});
} else {
const bool_type = try addZIRInstConst(mod, &block_scope.base, if_src, .{
.ty = Type.initTag(.type),
.val = Value.initTag(.bool_type),
});
break :c try expr(mod, &block_scope.base, .{ .ty = bool_type }, if_full.ast.cond_expr);
}
};
const condbr = try addZIRInstSpecial(mod, &block_scope.base, if_src, zir.Inst.CondBr, .{
.condition = cond,
.then_body = undefined, // populated below
.else_body = undefined, // populated below
}, .{});
const block = try addZIRInstBlock(mod, scope, if_src, .block, .{
.instructions = try block_scope.arena.dupe(*zir.Inst, block_scope.instructions.items),
});
const then_src = token_starts[tree.lastToken(if_full.ast.then_expr)];
var then_scope: Scope.GenZIR = .{
.parent = scope,
.decl = block_scope.decl,
.arena = block_scope.arena,
.force_comptime = block_scope.force_comptime,
.instructions = .{},
};
defer then_scope.instructions.deinit(mod.gpa);
// declare payload to the then_scope
const then_sub_scope = &then_scope.base;
block_scope.break_count += 1;
const then_result = try expr(mod, then_sub_scope, block_scope.break_result_loc, if_full.ast.then_expr);
// We hold off on the break instructions as well as copying the then/else
// instructions into place until we know whether to keep store_to_block_ptr
// instructions or not.
var else_scope: Scope.GenZIR = .{
.parent = scope,
.decl = block_scope.decl,
.arena = block_scope.arena,
.force_comptime = block_scope.force_comptime,
.instructions = .{},
};
defer else_scope.instructions.deinit(mod.gpa);
const else_node = if_full.ast.else_expr;
const else_info: struct { src: usize, result: ?*zir.Inst } = if (else_node != 0) blk: {
block_scope.break_count += 1;
const sub_scope = &else_scope.base;
break :blk .{
.src = token_starts[tree.lastToken(else_node)],
.result = try expr(mod, sub_scope, block_scope.break_result_loc, else_node),
};
} else .{
.src = token_starts[tree.lastToken(if_full.ast.then_expr)],
.result = null,
};
return finishThenElseBlock(
mod,
scope,
rl,
&block_scope,
&then_scope,
&else_scope,
&condbr.positionals.then_body,
&condbr.positionals.else_body,
then_src,
else_info.src,
then_result,
else_info.result,
block,
block,
);
}
/// Expects to find exactly 1 .store_to_block_ptr instruction.
fn copyBodyWithElidedStoreBlockPtr(body: *zir.Body, scope: Module.Scope.GenZIR) !void {
body.* = .{
.instructions = try scope.arena.alloc(*zir.Inst, scope.instructions.items.len - 1),
};
var dst_index: usize = 0;
for (scope.instructions.items) |src_inst| {
if (src_inst.tag != .store_to_block_ptr) {
body.instructions[dst_index] = src_inst;
dst_index += 1;
}
}
assert(dst_index == body.instructions.len);
}
fn copyBodyNoEliding(body: *zir.Body, scope: Module.Scope.GenZIR) !void {
body.* = .{
.instructions = try scope.arena.dupe(*zir.Inst, scope.instructions.items),
};
}
fn whileExpr(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
while_full: ast.full.While,
) InnerError!*zir.Inst {
if (while_full.label_token) |label_token| {
try checkLabelRedefinition(mod, scope, label_token);
}
if (while_full.inline_token) |inline_token| {
return mod.failTok(scope, inline_token, "TODO inline while", .{});
}
var loop_scope: Scope.GenZIR = .{
.parent = scope,
.decl = scope.ownerDecl().?,
.arena = scope.arena(),
.force_comptime = scope.isComptime(),
.instructions = .{},
};
setBlockResultLoc(&loop_scope, rl);
defer loop_scope.instructions.deinit(mod.gpa);
var continue_scope: Scope.GenZIR = .{
.parent = &loop_scope.base,
.decl = loop_scope.decl,
.arena = loop_scope.arena,
.force_comptime = loop_scope.force_comptime,
.instructions = .{},
};
defer continue_scope.instructions.deinit(mod.gpa);
const tree = scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const while_src = token_starts[while_full.ast.while_token];
const void_type = try addZIRInstConst(mod, scope, while_src, .{
.ty = Type.initTag(.type),
.val = Value.initTag(.void_type),
});
const cond = c: {
// TODO https://github.com/ziglang/zig/issues/7929
if (while_full.error_token) |error_token| {
return mod.failTok(scope, error_token, "TODO implement while error union", .{});
} else if (while_full.payload_token) |payload_token| {
return mod.failTok(scope, payload_token, "TODO implement while optional", .{});
} else {
const bool_type = try addZIRInstConst(mod, &continue_scope.base, while_src, .{
.ty = Type.initTag(.type),
.val = Value.initTag(.bool_type),
});
break :c try expr(mod, &continue_scope.base, .{ .ty = bool_type }, while_full.ast.cond_expr);
}
};
const condbr = try addZIRInstSpecial(mod, &continue_scope.base, while_src, zir.Inst.CondBr, .{
.condition = cond,
.then_body = undefined, // populated below
.else_body = undefined, // populated below
}, .{});
const cond_block = try addZIRInstBlock(mod, &loop_scope.base, while_src, .block, .{
.instructions = try loop_scope.arena.dupe(*zir.Inst, continue_scope.instructions.items),
});
// TODO avoid emitting the continue expr when there
// are no jumps to it. This happens when the last statement of a while body is noreturn
// and there are no `continue` statements.
// The "repeat" at the end of a loop body is implied.
if (while_full.ast.cont_expr != 0) {
_ = try expr(mod, &loop_scope.base, .{ .ty = void_type }, while_full.ast.cont_expr);
}
const loop = try scope.arena().create(zir.Inst.Loop);
loop.* = .{
.base = .{
.tag = .loop,
.src = while_src,
},
.positionals = .{
.body = .{
.instructions = try scope.arena().dupe(*zir.Inst, loop_scope.instructions.items),
},
},
.kw_args = .{},
};
const while_block = try addZIRInstBlock(mod, scope, while_src, .block, .{
.instructions = try scope.arena().dupe(*zir.Inst, &[1]*zir.Inst{&loop.base}),
});
loop_scope.break_block = while_block;
loop_scope.continue_block = cond_block;
if (while_full.label_token) |label_token| {
loop_scope.label = @as(?Scope.GenZIR.Label, Scope.GenZIR.Label{
.token = label_token,
.block_inst = while_block,
});
}
const then_src = token_starts[tree.lastToken(while_full.ast.then_expr)];
var then_scope: Scope.GenZIR = .{
.parent = &continue_scope.base,
.decl = continue_scope.decl,
.arena = continue_scope.arena,
.force_comptime = continue_scope.force_comptime,
.instructions = .{},
};
defer then_scope.instructions.deinit(mod.gpa);
const then_sub_scope = &then_scope.base;
loop_scope.break_count += 1;
const then_result = try expr(mod, then_sub_scope, loop_scope.break_result_loc, while_full.ast.then_expr);
var else_scope: Scope.GenZIR = .{
.parent = &continue_scope.base,
.decl = continue_scope.decl,
.arena = continue_scope.arena,
.force_comptime = continue_scope.force_comptime,
.instructions = .{},
};
defer else_scope.instructions.deinit(mod.gpa);
const else_node = while_full.ast.else_expr;
const else_info: struct { src: usize, result: ?*zir.Inst } = if (else_node != 0) blk: {
loop_scope.break_count += 1;
const sub_scope = &else_scope.base;
break :blk .{
.src = token_starts[tree.lastToken(else_node)],
.result = try expr(mod, sub_scope, loop_scope.break_result_loc, else_node),
};
} else .{
.src = token_starts[tree.lastToken(while_full.ast.then_expr)],
.result = null,
};
if (loop_scope.label) |some| {
if (!some.used) {
return mod.fail(scope, token_starts[some.token], "unused while loop label", .{});
}
}
return finishThenElseBlock(
mod,
scope,
rl,
&loop_scope,
&then_scope,
&else_scope,
&condbr.positionals.then_body,
&condbr.positionals.else_body,
then_src,
else_info.src,
then_result,
else_info.result,
while_block,
cond_block,
);
}
fn forExpr(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
for_full: ast.full.While,
) InnerError!*zir.Inst {
if (for_full.label_token) |label_token| {
try checkLabelRedefinition(mod, scope, label_token);
}
if (for_full.inline_token) |inline_token| {
return mod.failTok(scope, inline_token, "TODO inline for", .{});
}
// Set up variables and constants.
const tree = scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const token_tags = tree.tokens.items(.tag);
const for_src = token_starts[for_full.ast.while_token];
const index_ptr = blk: {
const usize_type = try addZIRInstConst(mod, scope, for_src, .{
.ty = Type.initTag(.type),
.val = Value.initTag(.usize_type),
});
const index_ptr = try addZIRUnOp(mod, scope, for_src, .alloc, usize_type);
// initialize to zero
const zero = try addZIRInstConst(mod, scope, for_src, .{
.ty = Type.initTag(.usize),
.val = Value.initTag(.zero),
});
_ = try addZIRBinOp(mod, scope, for_src, .store, index_ptr, zero);
break :blk index_ptr;
};
const array_ptr = try expr(mod, scope, .ref, for_full.ast.cond_expr);
const cond_src = token_starts[tree.firstToken(for_full.ast.cond_expr)];
const len = try addZIRUnOp(mod, scope, cond_src, .indexable_ptr_len, array_ptr);
var loop_scope: Scope.GenZIR = .{
.parent = scope,
.decl = scope.ownerDecl().?,
.arena = scope.arena(),
.force_comptime = scope.isComptime(),
.instructions = .{},
};
setBlockResultLoc(&loop_scope, rl);
defer loop_scope.instructions.deinit(mod.gpa);
var cond_scope: Scope.GenZIR = .{
.parent = &loop_scope.base,
.decl = loop_scope.decl,
.arena = loop_scope.arena,
.force_comptime = loop_scope.force_comptime,
.instructions = .{},
};
defer cond_scope.instructions.deinit(mod.gpa);
// check condition i < array_expr.len
const index = try addZIRUnOp(mod, &cond_scope.base, cond_src, .deref, index_ptr);
const cond = try addZIRBinOp(mod, &cond_scope.base, cond_src, .cmp_lt, index, len);
const condbr = try addZIRInstSpecial(mod, &cond_scope.base, for_src, zir.Inst.CondBr, .{
.condition = cond,
.then_body = undefined, // populated below
.else_body = undefined, // populated below
}, .{});
const cond_block = try addZIRInstBlock(mod, &loop_scope.base, for_src, .block, .{
.instructions = try loop_scope.arena.dupe(*zir.Inst, cond_scope.instructions.items),
});
// increment index variable
const one = try addZIRInstConst(mod, &loop_scope.base, for_src, .{
.ty = Type.initTag(.usize),
.val = Value.initTag(.one),
});
const index_2 = try addZIRUnOp(mod, &loop_scope.base, cond_src, .deref, index_ptr);
const index_plus_one = try addZIRBinOp(mod, &loop_scope.base, for_src, .add, index_2, one);
_ = try addZIRBinOp(mod, &loop_scope.base, for_src, .store, index_ptr, index_plus_one);
const loop = try scope.arena().create(zir.Inst.Loop);
loop.* = .{
.base = .{
.tag = .loop,
.src = for_src,
},
.positionals = .{
.body = .{
.instructions = try scope.arena().dupe(*zir.Inst, loop_scope.instructions.items),
},
},
.kw_args = .{},
};
const for_block = try addZIRInstBlock(mod, scope, for_src, .block, .{
.instructions = try scope.arena().dupe(*zir.Inst, &[1]*zir.Inst{&loop.base}),
});
loop_scope.break_block = for_block;
loop_scope.continue_block = cond_block;
if (for_full.label_token) |label_token| {
loop_scope.label = @as(?Scope.GenZIR.Label, Scope.GenZIR.Label{
.token = label_token,
.block_inst = for_block,
});
}
// while body
const then_src = token_starts[tree.lastToken(for_full.ast.then_expr)];
var then_scope: Scope.GenZIR = .{
.parent = &cond_scope.base,
.decl = cond_scope.decl,
.arena = cond_scope.arena,
.force_comptime = cond_scope.force_comptime,
.instructions = .{},
};
defer then_scope.instructions.deinit(mod.gpa);
var index_scope: Scope.LocalPtr = undefined;
const then_sub_scope = blk: {
const payload_token = for_full.payload_token.?;
const ident = if (token_tags[payload_token] == .asterisk)
payload_token + 1
else
payload_token;
const is_ptr = ident != payload_token;
const value_name = tree.tokenSlice(ident);
if (!mem.eql(u8, value_name, "_")) {
return mod.failNode(&then_scope.base, ident, "TODO implement for loop value payload", .{});
} else if (is_ptr) {
return mod.failTok(&then_scope.base, payload_token, "pointer modifier invalid on discard", .{});
}
const index_token = if (token_tags[ident + 1] == .comma)
ident + 2
else
break :blk &then_scope.base;
if (mem.eql(u8, tree.tokenSlice(index_token), "_")) {
return mod.failTok(&then_scope.base, index_token, "discard of index capture; omit it instead", .{});
}
const index_name = try mod.identifierTokenString(&then_scope.base, index_token);
index_scope = .{
.parent = &then_scope.base,
.gen_zir = &then_scope,
.name = index_name,
.ptr = index_ptr,
};
break :blk &index_scope.base;
};
loop_scope.break_count += 1;
const then_result = try expr(mod, then_sub_scope, loop_scope.break_result_loc, for_full.ast.then_expr);
// else branch
var else_scope: Scope.GenZIR = .{
.parent = &cond_scope.base,
.decl = cond_scope.decl,
.arena = cond_scope.arena,
.force_comptime = cond_scope.force_comptime,
.instructions = .{},
};
defer else_scope.instructions.deinit(mod.gpa);
const else_node = for_full.ast.else_expr;
const else_info: struct { src: usize, result: ?*zir.Inst } = if (else_node != 0) blk: {
loop_scope.break_count += 1;
const sub_scope = &else_scope.base;
break :blk .{
.src = token_starts[tree.lastToken(else_node)],
.result = try expr(mod, sub_scope, loop_scope.break_result_loc, else_node),
};
} else .{
.src = token_starts[tree.lastToken(for_full.ast.then_expr)],
.result = null,
};
if (loop_scope.label) |some| {
if (!some.used) {
return mod.fail(scope, token_starts[some.token], "unused for loop label", .{});
}
}
return finishThenElseBlock(
mod,
scope,
rl,
&loop_scope,
&then_scope,
&else_scope,
&condbr.positionals.then_body,
&condbr.positionals.else_body,
then_src,
else_info.src,
then_result,
else_info.result,
for_block,
cond_block,
);
}
fn getRangeNode(
node_tags: []const ast.Node.Tag,
node_datas: []const ast.Node.Data,
start_node: ast.Node.Index,
) ?ast.Node.Index {
var node = start_node;
while (true) {
switch (node_tags[node]) {
.switch_range => return node,
.grouped_expression => node = node_datas[node].lhs,
else => return null,
}
}
}
fn switchExpr(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
switch_node: ast.Node.Index,
) InnerError!*zir.Inst {
const tree = scope.tree();
const node_datas = tree.nodes.items(.data);
const main_tokens = tree.nodes.items(.main_token);
const token_tags = tree.tokens.items(.tag);
const token_starts = tree.tokens.items(.start);
const node_tags = tree.nodes.items(.tag);
const switch_token = main_tokens[switch_node];
const target_node = node_datas[switch_node].lhs;
const extra = tree.extraData(node_datas[switch_node].rhs, ast.Node.SubRange);
const case_nodes = tree.extra_data[extra.start..extra.end];
const switch_src = token_starts[switch_token];
var block_scope: Scope.GenZIR = .{
.parent = scope,
.decl = scope.ownerDecl().?,
.arena = scope.arena(),
.force_comptime = scope.isComptime(),
.instructions = .{},
};
setBlockResultLoc(&block_scope, rl);
defer block_scope.instructions.deinit(mod.gpa);
var items = std.ArrayList(*zir.Inst).init(mod.gpa);
defer items.deinit();
// First we gather all the switch items and check else/'_' prongs.
var else_src: ?usize = null;
var underscore_src: ?usize = null;
var first_range: ?*zir.Inst = null;
var simple_case_count: usize = 0;
var any_payload_is_ref = false;
for (case_nodes) |case_node| {
const case = switch (node_tags[case_node]) {
.switch_case_one => tree.switchCaseOne(case_node),
.switch_case => tree.switchCase(case_node),
else => unreachable,
};
if (case.payload_token) |payload_token| {
if (token_tags[payload_token] == .asterisk) {
any_payload_is_ref = true;
}
}
// Check for else/_ prong, those are handled last.
if (case.ast.values.len == 0) {
const case_src = token_starts[case.ast.arrow_token - 1];
if (else_src) |src| {
const msg = msg: {
const msg = try mod.errMsg(
scope,
case_src,
"multiple else prongs in switch expression",
.{},
);
errdefer msg.destroy(mod.gpa);
try mod.errNote(scope, src, msg, "previous else prong is here", .{});
break :msg msg;
};
return mod.failWithOwnedErrorMsg(scope, msg);
}
else_src = case_src;
continue;
} else if (case.ast.values.len == 1 and
node_tags[case.ast.values[0]] == .identifier and
mem.eql(u8, tree.tokenSlice(main_tokens[case.ast.values[0]]), "_"))
{
const case_src = token_starts[case.ast.arrow_token - 1];
if (underscore_src) |src| {
const msg = msg: {
const msg = try mod.errMsg(
scope,
case_src,
"multiple '_' prongs in switch expression",
.{},
);
errdefer msg.destroy(mod.gpa);
try mod.errNote(scope, src, msg, "previous '_' prong is here", .{});
break :msg msg;
};
return mod.failWithOwnedErrorMsg(scope, msg);
}
underscore_src = case_src;
continue;
}
if (else_src) |some_else| {
if (underscore_src) |some_underscore| {
const msg = msg: {
const msg = try mod.errMsg(
scope,
switch_src,
"else and '_' prong in switch expression",
.{},
);
errdefer msg.destroy(mod.gpa);
try mod.errNote(scope, some_else, msg, "else prong is here", .{});
try mod.errNote(scope, some_underscore, msg, "'_' prong is here", .{});
break :msg msg;
};
return mod.failWithOwnedErrorMsg(scope, msg);
}
}
if (case.ast.values.len == 1 and
getRangeNode(node_tags, node_datas, case.ast.values[0]) == null)
{
simple_case_count += 1;
}
// Generate all the switch items as comptime expressions.
for (case.ast.values) |item| {
if (getRangeNode(node_tags, node_datas, item)) |range| {
const start = try comptimeExpr(mod, &block_scope.base, .none, node_datas[range].lhs);
const end = try comptimeExpr(mod, &block_scope.base, .none, node_datas[range].rhs);
const range_src = token_starts[main_tokens[range]];
const range_inst = try addZIRBinOp(mod, &block_scope.base, range_src, .switch_range, start, end);
try items.append(range_inst);
} else {
const item_inst = try comptimeExpr(mod, &block_scope.base, .none, item);
try items.append(item_inst);
}
}
}
var special_prong: zir.Inst.SwitchBr.SpecialProng = .none;
if (else_src != null) special_prong = .@"else";
if (underscore_src != null) special_prong = .underscore;
var cases = try block_scope.arena.alloc(zir.Inst.SwitchBr.Case, simple_case_count);
const rl_and_tag: struct { rl: ResultLoc, tag: zir.Inst.Tag } = if (any_payload_is_ref)
.{
.rl = .ref,
.tag = .switchbr_ref,
}
else
.{
.rl = .none,
.tag = .switchbr,
};
const target = try expr(mod, &block_scope.base, rl_and_tag.rl, target_node);
const switch_inst = try addZirInstT(mod, &block_scope.base, switch_src, zir.Inst.SwitchBr, rl_and_tag.tag, .{
.target = target,
.cases = cases,
.items = try block_scope.arena.dupe(*zir.Inst, items.items),
.else_body = undefined, // populated below
.range = first_range,
.special_prong = special_prong,
});
const block = try addZIRInstBlock(mod, scope, switch_src, .block, .{
.instructions = try block_scope.arena.dupe(*zir.Inst, block_scope.instructions.items),
});
var case_scope: Scope.GenZIR = .{
.parent = scope,
.decl = block_scope.decl,
.arena = block_scope.arena,
.force_comptime = block_scope.force_comptime,
.instructions = .{},
};
defer case_scope.instructions.deinit(mod.gpa);
var else_scope: Scope.GenZIR = .{
.parent = scope,
.decl = case_scope.decl,
.arena = case_scope.arena,
.force_comptime = case_scope.force_comptime,
.instructions = .{},
};
defer else_scope.instructions.deinit(mod.gpa);
// Now generate all but the special cases.
var special_case: ?ast.full.SwitchCase = null;
var items_index: usize = 0;
var case_index: usize = 0;
for (case_nodes) |case_node| {
const case = switch (node_tags[case_node]) {
.switch_case_one => tree.switchCaseOne(case_node),
.switch_case => tree.switchCase(case_node),
else => unreachable,
};
const case_src = token_starts[main_tokens[case_node]];
case_scope.instructions.shrinkRetainingCapacity(0);
// Check for else/_ prong, those are handled last.
if (case.ast.values.len == 0) {
special_case = case;
continue;
} else if (case.ast.values.len == 1 and
node_tags[case.ast.values[0]] == .identifier and
mem.eql(u8, tree.tokenSlice(main_tokens[case.ast.values[0]]), "_"))
{
special_case = case;
continue;
}
// If this is a simple one item prong then it is handled by the switchbr.
if (case.ast.values.len == 1 and
getRangeNode(node_tags, node_datas, case.ast.values[0]) == null)
{
const item = items.items[items_index];
items_index += 1;
try switchCaseExpr(mod, &case_scope.base, block_scope.break_result_loc, block, case, target);
cases[case_index] = .{
.item = item,
.body = .{ .instructions = try scope.arena().dupe(*zir.Inst, case_scope.instructions.items) },
};
case_index += 1;
continue;
}
// Check if the target matches any of the items.
// 1, 2, 3..6 will result in
// target == 1 or target == 2 or (target >= 3 and target <= 6)
// TODO handle multiple items as switch prongs rather than along with ranges.
var any_ok: ?*zir.Inst = null;
for (case.ast.values) |item| {
if (getRangeNode(node_tags, node_datas, item)) |range| {
const range_src = token_starts[main_tokens[range]];
const range_inst = items.items[items_index].castTag(.switch_range).?;
items_index += 1;
// target >= start and target <= end
const range_start_ok = try addZIRBinOp(mod, &else_scope.base, range_src, .cmp_gte, target, range_inst.positionals.lhs);
const range_end_ok = try addZIRBinOp(mod, &else_scope.base, range_src, .cmp_lte, target, range_inst.positionals.rhs);
const range_ok = try addZIRBinOp(mod, &else_scope.base, range_src, .bool_and, range_start_ok, range_end_ok);
if (any_ok) |some| {
any_ok = try addZIRBinOp(mod, &else_scope.base, range_src, .bool_or, some, range_ok);
} else {
any_ok = range_ok;
}
continue;
}
const item_inst = items.items[items_index];
items_index += 1;
const cpm_ok = try addZIRBinOp(mod, &else_scope.base, item_inst.src, .cmp_eq, target, item_inst);
if (any_ok) |some| {
any_ok = try addZIRBinOp(mod, &else_scope.base, item_inst.src, .bool_or, some, cpm_ok);
} else {
any_ok = cpm_ok;
}
}
const condbr = try addZIRInstSpecial(mod, &case_scope.base, case_src, zir.Inst.CondBr, .{
.condition = any_ok.?,
.then_body = undefined, // populated below
.else_body = undefined, // populated below
}, .{});
const cond_block = try addZIRInstBlock(mod, &else_scope.base, case_src, .block, .{
.instructions = try scope.arena().dupe(*zir.Inst, case_scope.instructions.items),
});
// reset cond_scope for then_body
case_scope.instructions.items.len = 0;
try switchCaseExpr(mod, &case_scope.base, block_scope.break_result_loc, block, case, target);
condbr.positionals.then_body = .{
.instructions = try scope.arena().dupe(*zir.Inst, case_scope.instructions.items),
};
// reset cond_scope for else_body
case_scope.instructions.items.len = 0;
_ = try addZIRInst(mod, &case_scope.base, case_src, zir.Inst.BreakVoid, .{
.block = cond_block,
}, .{});
condbr.positionals.else_body = .{
.instructions = try scope.arena().dupe(*zir.Inst, case_scope.instructions.items),
};
}
// Finally generate else block or a break.
if (special_case) |case| {
try switchCaseExpr(mod, &else_scope.base, block_scope.break_result_loc, block, case, target);
} else {
// Not handling all possible cases is a compile error.
_ = try addZIRNoOp(mod, &else_scope.base, switch_src, .unreachable_unsafe);
}
switch_inst.positionals.else_body = .{
.instructions = try block_scope.arena.dupe(*zir.Inst, else_scope.instructions.items),
};
return &block.base;
}
fn switchCaseExpr(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
block: *zir.Inst.Block,
case: ast.full.SwitchCase,
target: *zir.Inst,
) !void {
const tree = scope.tree();
const node_datas = tree.nodes.items(.data);
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const token_tags = tree.tokens.items(.tag);
const case_src = token_starts[case.ast.arrow_token];
const sub_scope = blk: {
const payload_token = case.payload_token orelse break :blk scope;
const ident = if (token_tags[payload_token] == .asterisk)
payload_token + 1
else
payload_token;
const is_ptr = ident != payload_token;
const value_name = tree.tokenSlice(ident);
if (mem.eql(u8, value_name, "_")) {
if (is_ptr) {
return mod.failTok(scope, payload_token, "pointer modifier invalid on discard", .{});
}
break :blk scope;
}
return mod.failTok(scope, ident, "TODO implement switch value payload", .{});
};
const case_body = try expr(mod, sub_scope, rl, case.ast.target_expr);
if (!case_body.tag.isNoReturn()) {
_ = try addZIRInst(mod, sub_scope, case_src, zir.Inst.Break, .{
.block = block,
.operand = case_body,
}, .{});
}
}
fn ret(mod: *Module, scope: *Scope, node: ast.Node.Index) InnerError!*zir.Inst {
const tree = scope.tree();
const node_datas = tree.nodes.items(.data);
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const src = token_starts[main_tokens[node]];
const rhs_node = node_datas[node].lhs;
if (rhs_node != 0) {
if (nodeMayNeedMemoryLocation(scope, rhs_node)) {
const ret_ptr = try addZIRNoOp(mod, scope, src, .ret_ptr);
const operand = try expr(mod, scope, .{ .ptr = ret_ptr }, rhs_node);
return addZIRUnOp(mod, scope, src, .@"return", operand);
} else {
const fn_ret_ty = try addZIRNoOp(mod, scope, src, .ret_type);
const operand = try expr(mod, scope, .{ .ty = fn_ret_ty }, rhs_node);
return addZIRUnOp(mod, scope, src, .@"return", operand);
}
} else {
return addZIRNoOp(mod, scope, src, .return_void);
}
}
fn identifier(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
ident: ast.Node.Index,
) InnerError!*zir.Inst {
const tracy = trace(@src());
defer tracy.end();
const tree = scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const ident_token = main_tokens[ident];
const ident_name = try mod.identifierTokenString(scope, ident_token);
const src = token_starts[ident_token];
if (mem.eql(u8, ident_name, "_")) {
return mod.failNode(scope, ident, "TODO implement '_' identifier", .{});
}
if (simple_types.get(ident_name)) |val_tag| {
const result = try addZIRInstConst(mod, scope, src, TypedValue{
.ty = Type.initTag(.type),
.val = Value.initTag(val_tag),
});
return rvalue(mod, scope, rl, result);
}
if (ident_name.len >= 2) integer: {
const first_c = ident_name[0];
if (first_c == 'i' or first_c == 'u') {
const is_signed = first_c == 'i';
const bit_count = std.fmt.parseInt(u16, ident_name[1..], 10) catch |err| switch (err) {
error.Overflow => return mod.failNode(
scope,
ident,
"primitive integer type '{s}' exceeds maximum bit width of 65535",
.{ident_name},
),
error.InvalidCharacter => break :integer,
};
const val = switch (bit_count) {
8 => if (is_signed) Value.initTag(.i8_type) else Value.initTag(.u8_type),
16 => if (is_signed) Value.initTag(.i16_type) else Value.initTag(.u16_type),
32 => if (is_signed) Value.initTag(.i32_type) else Value.initTag(.u32_type),
64 => if (is_signed) Value.initTag(.i64_type) else Value.initTag(.u64_type),
else => {
return rvalue(mod, scope, rl, try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.type),
.val = try Value.Tag.int_type.create(scope.arena(), .{
.signed = is_signed,
.bits = bit_count,
}),
}));
},
};
const result = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.type),
.val = val,
});
return rvalue(mod, scope, rl, result);
}
}
// Local variables, including function parameters.
{
var s = scope;
while (true) switch (s.tag) {
.local_val => {
const local_val = s.cast(Scope.LocalVal).?;
if (mem.eql(u8, local_val.name, ident_name)) {
return rvalue(mod, scope, rl, local_val.inst);
}
s = local_val.parent;
},
.local_ptr => {
const local_ptr = s.cast(Scope.LocalPtr).?;
if (mem.eql(u8, local_ptr.name, ident_name)) {
if (rl == .ref) return local_ptr.ptr;
const loaded = try addZIRUnOp(mod, scope, src, .deref, local_ptr.ptr);
return rvalue(mod, scope, rl, loaded);
}
s = local_ptr.parent;
},
.gen_zir => s = s.cast(Scope.GenZIR).?.parent,
else => break,
};
}
if (mod.lookupDeclName(scope, ident_name)) |decl| {
if (rl == .ref) {
return addZIRInst(mod, scope, src, zir.Inst.DeclRef, .{ .decl = decl }, .{});
} else {
return rvalue(mod, scope, rl, try addZIRInst(mod, scope, src, zir.Inst.DeclVal, .{
.decl = decl,
}, .{}));
}
}
return mod.failNode(scope, ident, "use of undeclared identifier '{s}'", .{ident_name});
}
fn parseStringLiteral(mod: *Module, scope: *Scope, token: ast.TokenIndex) ![]u8 {
const tree = scope.tree();
const token_tags = tree.tokens.items(.tag);
const token_starts = tree.tokens.items(.start);
assert(token_tags[token] == .string_literal);
const unparsed = tree.tokenSlice(token);
const arena = scope.arena();
var bad_index: usize = undefined;
const bytes = std.zig.parseStringLiteral(arena, unparsed, &bad_index) catch |err| switch (err) {
error.InvalidCharacter => {
const bad_byte = unparsed[bad_index];
const src = token_starts[token];
return mod.fail(scope, src + bad_index, "invalid string literal character: '{c}'", .{
bad_byte,
});
},
else => |e| return e,
};
return bytes;
}
fn stringLiteral(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
str_lit: ast.Node.Index,
) InnerError!*zir.Inst {
const tree = scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const str_lit_token = main_tokens[str_lit];
const bytes = try parseStringLiteral(mod, scope, str_lit_token);
const src = token_starts[str_lit_token];
const str_inst = try addZIRInst(mod, scope, src, zir.Inst.Str, .{ .bytes = bytes }, .{});
return rvalue(mod, scope, rl, str_inst);
}
fn multilineStringLiteral(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
str_lit: ast.Node.Index,
) InnerError!*zir.Inst {
const tree = scope.tree();
const node_datas = tree.nodes.items(.data);
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const start = node_datas[str_lit].lhs;
const end = node_datas[str_lit].rhs;
// Count the number of bytes to allocate.
const len: usize = len: {
var tok_i = start;
var len: usize = end - start + 1;
while (tok_i <= end) : (tok_i += 1) {
// 2 for the '//' + 1 for '\n'
len += tree.tokenSlice(tok_i).len - 3;
}
break :len len;
};
const bytes = try scope.arena().alloc(u8, len);
// First line: do not append a newline.
var byte_i: usize = 0;
var tok_i = start;
{
const slice = tree.tokenSlice(tok_i);
const line_bytes = slice[2 .. slice.len - 1];
mem.copy(u8, bytes[byte_i..], line_bytes);
byte_i += line_bytes.len;
tok_i += 1;
}
// Following lines: each line prepends a newline.
while (tok_i <= end) : (tok_i += 1) {
bytes[byte_i] = '\n';
byte_i += 1;
const slice = tree.tokenSlice(tok_i);
const line_bytes = slice[2 .. slice.len - 1];
mem.copy(u8, bytes[byte_i..], line_bytes);
byte_i += line_bytes.len;
}
const src = token_starts[start];
const str_inst = try addZIRInst(mod, scope, src, zir.Inst.Str, .{ .bytes = bytes }, .{});
return rvalue(mod, scope, rl, str_inst);
}
fn charLiteral(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !*zir.Inst {
const tree = scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const main_token = main_tokens[node];
const token_starts = tree.tokens.items(.start);
const src = token_starts[main_token];
const slice = tree.tokenSlice(main_token);
var bad_index: usize = undefined;
const value = std.zig.parseCharLiteral(slice, &bad_index) catch |err| switch (err) {
error.InvalidCharacter => {
const bad_byte = slice[bad_index];
return mod.fail(scope, src + bad_index, "invalid character: '{c}'\n", .{bad_byte});
},
};
const result = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.comptime_int),
.val = try Value.Tag.int_u64.create(scope.arena(), value),
});
return rvalue(mod, scope, rl, result);
}
fn integerLiteral(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
int_lit: ast.Node.Index,
) InnerError!*zir.Inst {
const arena = scope.arena();
const tree = scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const int_token = main_tokens[int_lit];
const prefixed_bytes = tree.tokenSlice(int_token);
const base: u8 = if (mem.startsWith(u8, prefixed_bytes, "0x"))
16
else if (mem.startsWith(u8, prefixed_bytes, "0o"))
8
else if (mem.startsWith(u8, prefixed_bytes, "0b"))
2
else
@as(u8, 10);
const bytes = if (base == 10)
prefixed_bytes
else
prefixed_bytes[2..];
if (std.fmt.parseInt(u64, bytes, base)) |small_int| {
const src = token_starts[int_token];
const result = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.comptime_int),
.val = try Value.Tag.int_u64.create(arena, small_int),
});
return rvalue(mod, scope, rl, result);
} else |err| {
return mod.failTok(scope, int_token, "TODO implement int literals that don't fit in a u64", .{});
}
}
fn floatLiteral(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
float_lit: ast.Node.Index,
) InnerError!*zir.Inst {
const arena = scope.arena();
const tree = scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const main_token = main_tokens[float_lit];
const bytes = tree.tokenSlice(main_token);
if (bytes.len > 2 and bytes[1] == 'x') {
return mod.failTok(scope, main_token, "TODO implement hex floats", .{});
}
const float_number = std.fmt.parseFloat(f128, bytes) catch |e| switch (e) {
error.InvalidCharacter => unreachable, // validated by tokenizer
};
const src = token_starts[main_token];
const result = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.comptime_float),
.val = try Value.Tag.float_128.create(arena, float_number),
});
return rvalue(mod, scope, rl, result);
}
fn asmExpr(mod: *Module, scope: *Scope, rl: ResultLoc, full: ast.full.Asm) InnerError!*zir.Inst {
const arena = scope.arena();
const tree = scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const node_datas = tree.nodes.items(.data);
if (full.outputs.len != 0) {
return mod.failTok(scope, full.ast.asm_token, "TODO implement asm with an output", .{});
}
const inputs = try arena.alloc([]const u8, full.inputs.len);
const args = try arena.alloc(*zir.Inst, full.inputs.len);
const src = token_starts[full.ast.asm_token];
const str_type = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.type),
.val = Value.initTag(.const_slice_u8_type),
});
const str_type_rl: ResultLoc = .{ .ty = str_type };
for (full.inputs) |input, i| {
// TODO semantically analyze constraints
const constraint_token = main_tokens[input] + 2;
inputs[i] = try parseStringLiteral(mod, scope, constraint_token);
args[i] = try expr(mod, scope, .none, node_datas[input].lhs);
}
const return_type = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.type),
.val = Value.initTag(.void_type),
});
const asm_inst = try addZIRInst(mod, scope, src, zir.Inst.Asm, .{
.asm_source = try expr(mod, scope, str_type_rl, full.ast.template),
.return_type = return_type,
}, .{
.@"volatile" = full.volatile_token != null,
//.clobbers = TODO handle clobbers
.inputs = inputs,
.args = args,
});
return rvalue(mod, scope, rl, asm_inst);
}
fn as(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
builtin_token: ast.TokenIndex,
src: usize,
lhs: ast.Node.Index,
rhs: ast.Node.Index,
) InnerError!*zir.Inst {
const dest_type = try typeExpr(mod, scope, lhs);
switch (rl) {
.none, .discard, .ref, .ty => {
const result = try expr(mod, scope, .{ .ty = dest_type }, rhs);
return rvalue(mod, scope, rl, result);
},
.ptr => |result_ptr| {
return asRlPtr(mod, scope, rl, src, result_ptr, rhs, dest_type);
},
.block_ptr => |block_scope| {
return asRlPtr(mod, scope, rl, src, block_scope.rl_ptr.?, rhs, dest_type);
},
.bitcasted_ptr => |bitcasted_ptr| {
// TODO here we should be able to resolve the inference; we now have a type for the result.
return mod.failTok(scope, builtin_token, "TODO implement @as with result location @bitCast", .{});
},
.inferred_ptr => |result_alloc| {
// TODO here we should be able to resolve the inference; we now have a type for the result.
return mod.failTok(scope, builtin_token, "TODO implement @as with inferred-type result location pointer", .{});
},
}
}
fn asRlPtr(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
src: usize,
result_ptr: *zir.Inst,
operand_node: ast.Node.Index,
dest_type: *zir.Inst,
) InnerError!*zir.Inst {
// Detect whether this expr() call goes into rvalue() to store the result into the
// result location. If it does, elide the coerce_result_ptr instruction
// as well as the store instruction, instead passing the result as an rvalue.
var as_scope: Scope.GenZIR = .{
.parent = scope,
.decl = scope.ownerDecl().?,
.arena = scope.arena(),
.force_comptime = scope.isComptime(),
.instructions = .{},
};
defer as_scope.instructions.deinit(mod.gpa);
as_scope.rl_ptr = try addZIRBinOp(mod, &as_scope.base, src, .coerce_result_ptr, dest_type, result_ptr);
const result = try expr(mod, &as_scope.base, .{ .block_ptr = &as_scope }, operand_node);
const parent_zir = &scope.getGenZIR().instructions;
if (as_scope.rvalue_rl_count == 1) {
// Busted! This expression didn't actually need a pointer.
const expected_len = parent_zir.items.len + as_scope.instructions.items.len - 2;
try parent_zir.ensureCapacity(mod.gpa, expected_len);
for (as_scope.instructions.items) |src_inst| {
if (src_inst == as_scope.rl_ptr.?) continue;
if (src_inst.castTag(.store_to_block_ptr)) |store| {
if (store.positionals.lhs == as_scope.rl_ptr.?) continue;
}
parent_zir.appendAssumeCapacity(src_inst);
}
assert(parent_zir.items.len == expected_len);
const casted_result = try addZIRBinOp(mod, scope, dest_type.src, .as, dest_type, result);
return rvalue(mod, scope, rl, casted_result);
} else {
try parent_zir.appendSlice(mod.gpa, as_scope.instructions.items);
return result;
}
}
fn bitCast(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
builtin_token: ast.TokenIndex,
src: usize,
lhs: ast.Node.Index,
rhs: ast.Node.Index,
) InnerError!*zir.Inst {
const dest_type = try typeExpr(mod, scope, lhs);
switch (rl) {
.none => {
const operand = try expr(mod, scope, .none, rhs);
return addZIRBinOp(mod, scope, src, .bitcast, dest_type, operand);
},
.discard => {
const operand = try expr(mod, scope, .none, rhs);
const result = try addZIRBinOp(mod, scope, src, .bitcast, dest_type, operand);
_ = try addZIRUnOp(mod, scope, result.src, .ensure_result_non_error, result);
return result;
},
.ref => {
const operand = try expr(mod, scope, .ref, rhs);
const result = try addZIRBinOp(mod, scope, src, .bitcast_ref, dest_type, operand);
return result;
},
.ty => |result_ty| {
const result = try expr(mod, scope, .none, rhs);
const bitcasted = try addZIRBinOp(mod, scope, src, .bitcast, dest_type, result);
return addZIRBinOp(mod, scope, src, .as, result_ty, bitcasted);
},
.ptr => |result_ptr| {
const casted_result_ptr = try addZIRUnOp(mod, scope, src, .bitcast_result_ptr, result_ptr);
return expr(mod, scope, .{ .bitcasted_ptr = casted_result_ptr.castTag(.bitcast_result_ptr).? }, rhs);
},
.bitcasted_ptr => |bitcasted_ptr| {
return mod.failTok(scope, builtin_token, "TODO implement @bitCast with result location another @bitCast", .{});
},
.block_ptr => |block_ptr| {
return mod.failTok(scope, builtin_token, "TODO implement @bitCast with result location inferred peer types", .{});
},
.inferred_ptr => |result_alloc| {
// TODO here we should be able to resolve the inference; we now have a type for the result.
return mod.failTok(scope, builtin_token, "TODO implement @bitCast with inferred-type result location pointer", .{});
},
}
}
fn typeOf(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
builtin_token: ast.TokenIndex,
src: usize,
params: []const ast.Node.Index,
) InnerError!*zir.Inst {
if (params.len < 1) {
return mod.failTok(scope, builtin_token, "expected at least 1 argument, found 0", .{});
}
if (params.len == 1) {
return rvalue(mod, scope, rl, try addZIRUnOp(mod, scope, src, .typeof, try expr(mod, scope, .none, params[0])));
}
const arena = scope.arena();
var items = try arena.alloc(*zir.Inst, params.len);
for (params) |param, param_i|
items[param_i] = try expr(mod, scope, .none, param);
return rvalue(mod, scope, rl, try addZIRInst(mod, scope, src, zir.Inst.TypeOfPeer, .{ .items = items }, .{}));
}
fn builtinCall(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
call: ast.Node.Index,
params: []const ast.Node.Index,
) InnerError!*zir.Inst {
const tree = scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const builtin_token = main_tokens[call];
const builtin_name = tree.tokenSlice(builtin_token);
// We handle the different builtins manually because they have different semantics depending
// on the function. For example, `@as` and others participate in result location semantics,
// and `@cImport` creates a special scope that collects a .c source code text buffer.
// Also, some builtins have a variable number of parameters.
const info = BuiltinFn.list.get(builtin_name) orelse {
return mod.failTok(scope, builtin_token, "invalid builtin function: '{s}'", .{
builtin_name,
});
};
if (info.param_count) |expected| {
if (expected != params.len) {
const s = if (expected == 1) "" else "s";
return mod.failTok(scope, builtin_token, "expected {d} parameter{s}, found {d}", .{
expected, s, params.len,
});
}
}
const src = token_starts[builtin_token];
switch (info.tag) {
.ptr_to_int => {
const operand = try expr(mod, scope, .none, params[0]);
const result = try addZIRUnOp(mod, scope, src, .ptrtoint, operand);
return rvalue(mod, scope, rl, result);
},
.float_cast => {
const dest_type = try typeExpr(mod, scope, params[0]);
const rhs = try expr(mod, scope, .none, params[1]);
const result = try addZIRBinOp(mod, scope, src, .floatcast, dest_type, rhs);
return rvalue(mod, scope, rl, result);
},
.int_cast => {
const dest_type = try typeExpr(mod, scope, params[0]);
const rhs = try expr(mod, scope, .none, params[1]);
const result = try addZIRBinOp(mod, scope, src, .intcast, dest_type, rhs);
return rvalue(mod, scope, rl, result);
},
.breakpoint => {
const result = try addZIRNoOp(mod, scope, src, .breakpoint);
return rvalue(mod, scope, rl, result);
},
.import => {
const target = try expr(mod, scope, .none, params[0]);
const result = try addZIRUnOp(mod, scope, src, .import, target);
return rvalue(mod, scope, rl, result);
},
.compile_error => {
const target = try expr(mod, scope, .none, params[0]);
const result = try addZIRUnOp(mod, scope, src, .compile_error, target);
return rvalue(mod, scope, rl, result);
},
.set_eval_branch_quota => {
const u32_type = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.type),
.val = Value.initTag(.u32_type),
});
const quota = try expr(mod, scope, .{ .ty = u32_type }, params[0]);
const result = try addZIRUnOp(mod, scope, src, .set_eval_branch_quota, quota);
return rvalue(mod, scope, rl, result);
},
.compile_log => {
const arena = scope.arena();
var targets = try arena.alloc(*zir.Inst, params.len);
for (params) |param, param_i|
targets[param_i] = try expr(mod, scope, .none, param);
const result = try addZIRInst(mod, scope, src, zir.Inst.CompileLog, .{ .to_log = targets }, .{});
return rvalue(mod, scope, rl, result);
},
.field => {
const string_type = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.type),
.val = Value.initTag(.const_slice_u8_type),
});
const string_rl: ResultLoc = .{ .ty = string_type };
if (rl == .ref) {
return addZirInstTag(mod, scope, src, .field_ptr_named, .{
.object = try expr(mod, scope, .ref, params[0]),
.field_name = try comptimeExpr(mod, scope, string_rl, params[1]),
});
}
return rvalue(mod, scope, rl, try addZirInstTag(mod, scope, src, .field_val_named, .{
.object = try expr(mod, scope, .none, params[0]),
.field_name = try comptimeExpr(mod, scope, string_rl, params[1]),
}));
},
.as => return as(mod, scope, rl, builtin_token, src, params[0], params[1]),
.bit_cast => return bitCast(mod, scope, rl, builtin_token, src, params[0], params[1]),
.TypeOf => return typeOf(mod, scope, rl, builtin_token, src, params),
.add_with_overflow,
.align_cast,
.align_of,
.async_call,
.atomic_load,
.atomic_rmw,
.atomic_store,
.bit_offset_of,
.bool_to_int,
.bit_size_of,
.mul_add,
.byte_swap,
.bit_reverse,
.byte_offset_of,
.call,
.c_define,
.c_import,
.c_include,
.clz,
.cmpxchg_strong,
.cmpxchg_weak,
.ctz,
.c_undef,
.div_exact,
.div_floor,
.div_trunc,
.embed_file,
.enum_to_int,
.error_name,
.error_return_trace,
.error_to_int,
.err_set_cast,
.@"export",
.fence,
.field_parent_ptr,
.float_to_int,
.frame,
.Frame,
.frame_address,
.frame_size,
.has_decl,
.has_field,
.int_to_enum,
.int_to_error,
.int_to_float,
.int_to_ptr,
.memcpy,
.memset,
.wasm_memory_size,
.wasm_memory_grow,
.mod,
.mul_with_overflow,
.panic,
.pop_count,
.ptr_cast,
.rem,
.return_address,
.set_align_stack,
.set_cold,
.set_float_mode,
.set_runtime_safety,
.shl_exact,
.shl_with_overflow,
.shr_exact,
.shuffle,
.size_of,
.splat,
.reduce,
.src,
.sqrt,
.sin,
.cos,
.exp,
.exp2,
.log,
.log2,
.log10,
.fabs,
.floor,
.ceil,
.trunc,
.round,
.sub_with_overflow,
.tag_name,
.This,
.truncate,
.Type,
.type_info,
.type_name,
.union_init,
=> return mod.failTok(scope, builtin_token, "TODO: implement builtin function {s}", .{
builtin_name,
}),
}
}
fn callExpr(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
call: ast.full.Call,
) InnerError!*zir.Inst {
if (call.async_token) |async_token| {
return mod.failTok(scope, async_token, "TODO implement async fn call", .{});
}
const tree = scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const token_starts = tree.tokens.items(.start);
const lhs = try expr(mod, scope, .none, call.ast.fn_expr);
const args = try scope.getGenZIR().arena.alloc(*zir.Inst, call.ast.params.len);
for (call.ast.params) |param_node, i| {
const param_src = token_starts[tree.firstToken(param_node)];
const param_type = try addZIRInst(mod, scope, param_src, zir.Inst.ParamType, .{
.func = lhs,
.arg_index = i,
}, .{});
args[i] = try expr(mod, scope, .{ .ty = param_type }, param_node);
}
const src = token_starts[call.ast.lparen];
const result = try addZIRInst(mod, scope, src, zir.Inst.Call, .{
.func = lhs,
.args = args,
}, .{});
// TODO function call with result location
return rvalue(mod, scope, rl, result);
}
pub const simple_types = std.ComptimeStringMap(Value.Tag, .{
.{ "u8", .u8_type },
.{ "i8", .i8_type },
.{ "isize", .isize_type },
.{ "usize", .usize_type },
.{ "c_short", .c_short_type },
.{ "c_ushort", .c_ushort_type },
.{ "c_int", .c_int_type },
.{ "c_uint", .c_uint_type },
.{ "c_long", .c_long_type },
.{ "c_ulong", .c_ulong_type },
.{ "c_longlong", .c_longlong_type },
.{ "c_ulonglong", .c_ulonglong_type },
.{ "c_longdouble", .c_longdouble_type },
.{ "f16", .f16_type },
.{ "f32", .f32_type },
.{ "f64", .f64_type },
.{ "f128", .f128_type },
.{ "c_void", .c_void_type },
.{ "bool", .bool_type },
.{ "void", .void_type },
.{ "type", .type_type },
.{ "anyerror", .anyerror_type },
.{ "comptime_int", .comptime_int_type },
.{ "comptime_float", .comptime_float_type },
.{ "noreturn", .noreturn_type },
});
fn nodeMayNeedMemoryLocation(scope: *Scope, start_node: ast.Node.Index) bool {
const tree = scope.tree();
const node_tags = tree.nodes.items(.tag);
const node_datas = tree.nodes.items(.data);
const main_tokens = tree.nodes.items(.main_token);
const token_tags = tree.tokens.items(.tag);
var node = start_node;
while (true) {
switch (node_tags[node]) {
.root,
.@"usingnamespace",
.test_decl,
.switch_case,
.switch_case_one,
.container_field_init,
.container_field_align,
.container_field,
.asm_output,
.asm_input,
=> unreachable,
.@"return",
.@"break",
.@"continue",
.bit_not,
.bool_not,
.global_var_decl,
.local_var_decl,
.simple_var_decl,
.aligned_var_decl,
.@"defer",
.@"errdefer",
.address_of,
.optional_type,
.negation,
.negation_wrap,
.@"resume",
.array_type,
.array_type_sentinel,
.ptr_type_aligned,
.ptr_type_sentinel,
.ptr_type,
.ptr_type_bit_range,
.@"suspend",
.@"anytype",
.fn_proto_simple,
.fn_proto_multi,
.fn_proto_one,
.fn_proto,
.fn_decl,
.anyframe_type,
.anyframe_literal,
.integer_literal,
.float_literal,
.enum_literal,
.string_literal,
.multiline_string_literal,
.char_literal,
.true_literal,
.false_literal,
.null_literal,
.undefined_literal,
.unreachable_literal,
.identifier,
.error_set_decl,
.container_decl,
.container_decl_trailing,
.container_decl_two,
.container_decl_two_trailing,
.container_decl_arg,
.container_decl_arg_trailing,
.tagged_union,
.tagged_union_trailing,
.tagged_union_two,
.tagged_union_two_trailing,
.tagged_union_enum_tag,
.tagged_union_enum_tag_trailing,
.@"asm",
.asm_simple,
.add,
.add_wrap,
.array_cat,
.array_mult,
.assign,
.assign_bit_and,
.assign_bit_or,
.assign_bit_shift_left,
.assign_bit_shift_right,
.assign_bit_xor,
.assign_div,
.assign_sub,
.assign_sub_wrap,
.assign_mod,
.assign_add,
.assign_add_wrap,
.assign_mul,
.assign_mul_wrap,
.bang_equal,
.bit_and,
.bit_or,
.bit_shift_left,
.bit_shift_right,
.bit_xor,
.bool_and,
.bool_or,
.div,
.equal_equal,
.error_union,
.greater_or_equal,
.greater_than,
.less_or_equal,
.less_than,
.merge_error_sets,
.mod,
.mul,
.mul_wrap,
.switch_range,
.field_access,
.sub,
.sub_wrap,
.slice,
.slice_open,
.slice_sentinel,
.deref,
.array_access,
.error_value,
.while_simple, // This variant cannot have an else expression.
.while_cont, // This variant cannot have an else expression.
.for_simple, // This variant cannot have an else expression.
.if_simple, // This variant cannot have an else expression.
=> return false,
// Forward the question to the LHS sub-expression.
.grouped_expression,
.@"try",
.@"await",
.@"comptime",
.@"nosuspend",
.unwrap_optional,
=> node = node_datas[node].lhs,
// Forward the question to the RHS sub-expression.
.@"catch",
.@"orelse",
=> node = node_datas[node].rhs,
// True because these are exactly the expressions we need memory locations for.
.array_init_one,
.array_init_one_comma,
.array_init_dot_two,
.array_init_dot_two_comma,
.array_init_dot,
.array_init_dot_comma,
.array_init,
.array_init_comma,
.struct_init_one,
.struct_init_one_comma,
.struct_init_dot_two,
.struct_init_dot_two_comma,
.struct_init_dot,
.struct_init_dot_comma,
.struct_init,
.struct_init_comma,
=> return true,
// True because depending on comptime conditions, sub-expressions
// may be the kind that need memory locations.
.@"while", // This variant always has an else expression.
.@"if", // This variant always has an else expression.
.@"for", // This variant always has an else expression.
.@"switch",
.switch_comma,
.call_one,
.call_one_comma,
.async_call_one,
.async_call_one_comma,
.call,
.call_comma,
.async_call,
.async_call_comma,
=> return true,
.block_two,
.block_two_semicolon,
.block,
.block_semicolon,
=> {
const lbrace = main_tokens[node];
if (token_tags[lbrace - 1] == .colon) {
// Labeled blocks may need a memory location to forward
// to their break statements.
return true;
} else {
return false;
}
},
.builtin_call,
.builtin_call_comma,
.builtin_call_two,
.builtin_call_two_comma,
=> {
const builtin_token = main_tokens[node];
const builtin_name = tree.tokenSlice(builtin_token);
// If the builtin is an invalid name, we don't cause an error here; instead
// let it pass, and the error will be "invalid builtin function" later.
const builtin_info = BuiltinFn.list.get(builtin_name) orelse return false;
return builtin_info.needs_mem_loc;
},
}
}
}
/// Applies `rl` semantics to `inst`. Expressions which do not do their own handling of
/// result locations must call this function on their result.
/// As an example, if the `ResultLoc` is `ptr`, it will write the result to the pointer.
/// If the `ResultLoc` is `ty`, it will coerce the result to the type.
fn rvalue(mod: *Module, scope: *Scope, rl: ResultLoc, result: *zir.Inst) InnerError!*zir.Inst {
switch (rl) {
.none => return result,
.discard => {
// Emit a compile error for discarding error values.
_ = try addZIRUnOp(mod, scope, result.src, .ensure_result_non_error, result);
return result;
},
.ref => {
// We need a pointer but we have a value.
return addZIRUnOp(mod, scope, result.src, .ref, result);
},
.ty => |ty_inst| return addZIRBinOp(mod, scope, result.src, .as, ty_inst, result),
.ptr => |ptr_inst| {
_ = try addZIRBinOp(mod, scope, result.src, .store, ptr_inst, result);
return result;
},
.bitcasted_ptr => |bitcasted_ptr| {
return mod.fail(scope, result.src, "TODO implement rvalue .bitcasted_ptr", .{});
},
.inferred_ptr => |alloc| {
_ = try addZIRBinOp(mod, scope, result.src, .store_to_inferred_ptr, &alloc.base, result);
return result;
},
.block_ptr => |block_scope| {
block_scope.rvalue_rl_count += 1;
_ = try addZIRBinOp(mod, scope, result.src, .store_to_block_ptr, block_scope.rl_ptr.?, result);
return result;
},
}
}
/// TODO when reworking ZIR memory layout, make the void value correspond to a hard coded
/// index; that way this does not actually need to allocate anything.
fn rvalueVoid(
mod: *Module,
scope: *Scope,
rl: ResultLoc,
node: ast.Node.Index,
result: void,
) InnerError!*zir.Inst {
const tree = scope.tree();
const main_tokens = tree.nodes.items(.main_token);
const src = tree.tokens.items(.start)[tree.firstToken(node)];
const void_inst = try addZIRInstConst(mod, scope, src, .{
.ty = Type.initTag(.void),
.val = Value.initTag(.void_value),
});
return rvalue(mod, scope, rl, void_inst);
}
fn rlStrategy(rl: ResultLoc, block_scope: *Scope.GenZIR) ResultLoc.Strategy {
var elide_store_to_block_ptr_instructions = false;
switch (rl) {
// In this branch there will not be any store_to_block_ptr instructions.
.discard, .none, .ty, .ref => return .{
.tag = .break_operand,
.elide_store_to_block_ptr_instructions = false,
},
// The pointer got passed through to the sub-expressions, so we will use
// break_void here.
// In this branch there will not be any store_to_block_ptr instructions.
.ptr => return .{
.tag = .break_void,
.elide_store_to_block_ptr_instructions = false,
},
.inferred_ptr, .bitcasted_ptr, .block_ptr => {
if (block_scope.rvalue_rl_count == block_scope.break_count) {
// Neither prong of the if consumed the result location, so we can
// use break instructions to create an rvalue.
return .{
.tag = .break_operand,
.elide_store_to_block_ptr_instructions = true,
};
} else {
// Allow the store_to_block_ptr instructions to remain so that
// semantic analysis can turn them into bitcasts.
return .{
.tag = .break_void,
.elide_store_to_block_ptr_instructions = false,
};
}
},
}
}
fn setBlockResultLoc(block_scope: *Scope.GenZIR, parent_rl: ResultLoc) void {
// Depending on whether the result location is a pointer or value, different
// ZIR needs to be generated. In the former case we rely on storing to the
// pointer to communicate the result, and use breakvoid; in the latter case
// the block break instructions will have the result values.
// One more complication: when the result location is a pointer, we detect
// the scenario where the result location is not consumed. In this case
// we emit ZIR for the block break instructions to have the result values,
// and then rvalue() on that to pass the value to the result location.
switch (parent_rl) {
.discard, .none, .ty, .ptr, .ref => {
block_scope.break_result_loc = parent_rl;
},
.inferred_ptr => |ptr| {
block_scope.rl_ptr = &ptr.base;
block_scope.break_result_loc = .{ .block_ptr = block_scope };
},
.bitcasted_ptr => |ptr| {
block_scope.rl_ptr = &ptr.base;
block_scope.break_result_loc = .{ .block_ptr = block_scope };
},
.block_ptr => |parent_block_scope| {
block_scope.rl_ptr = parent_block_scope.rl_ptr.?;
block_scope.break_result_loc = .{ .block_ptr = block_scope };
},
}
}
pub fn addZirInstTag(
mod: *Module,
scope: *Scope,
src: usize,
comptime tag: zir.Inst.Tag,
positionals: std.meta.fieldInfo(tag.Type(), .positionals).field_type,
) !*zir.Inst {
const gen_zir = scope.getGenZIR();
try gen_zir.instructions.ensureCapacity(mod.gpa, gen_zir.instructions.items.len + 1);
const inst = try gen_zir.arena.create(tag.Type());
inst.* = .{
.base = .{
.tag = tag,
.src = src,
},
.positionals = positionals,
.kw_args = .{},
};
gen_zir.instructions.appendAssumeCapacity(&inst.base);
return &inst.base;
}
pub fn addZirInstT(
mod: *Module,
scope: *Scope,
src: usize,
comptime T: type,
tag: zir.Inst.Tag,
positionals: std.meta.fieldInfo(T, .positionals).field_type,
) !*T {
const gen_zir = scope.getGenZIR();
try gen_zir.instructions.ensureCapacity(mod.gpa, gen_zir.instructions.items.len + 1);
const inst = try gen_zir.arena.create(T);
inst.* = .{
.base = .{
.tag = tag,
.src = src,
},
.positionals = positionals,
.kw_args = .{},
};
gen_zir.instructions.appendAssumeCapacity(&inst.base);
return inst;
}
pub fn addZIRInstSpecial(
mod: *Module,
scope: *Scope,
src: usize,
comptime T: type,
positionals: std.meta.fieldInfo(T, .positionals).field_type,
kw_args: std.meta.fieldInfo(T, .kw_args).field_type,
) !*T {
const gen_zir = scope.getGenZIR();
try gen_zir.instructions.ensureCapacity(mod.gpa, gen_zir.instructions.items.len + 1);
const inst = try gen_zir.arena.create(T);
inst.* = .{
.base = .{
.tag = T.base_tag,
.src = src,
},
.positionals = positionals,
.kw_args = kw_args,
};
gen_zir.instructions.appendAssumeCapacity(&inst.base);
return inst;
}
pub fn addZIRNoOpT(mod: *Module, scope: *Scope, src: usize, tag: zir.Inst.Tag) !*zir.Inst.NoOp {
const gen_zir = scope.getGenZIR();
try gen_zir.instructions.ensureCapacity(mod.gpa, gen_zir.instructions.items.len + 1);
const inst = try gen_zir.arena.create(zir.Inst.NoOp);
inst.* = .{
.base = .{
.tag = tag,
.src = src,
},
.positionals = .{},
.kw_args = .{},
};
gen_zir.instructions.appendAssumeCapacity(&inst.base);
return inst;
}
pub fn addZIRNoOp(mod: *Module, scope: *Scope, src: usize, tag: zir.Inst.Tag) !*zir.Inst {
const inst = try addZIRNoOpT(mod, scope, src, tag);
return &inst.base;
}
pub fn addZIRUnOp(
mod: *Module,
scope: *Scope,
src: usize,
tag: zir.Inst.Tag,
operand: *zir.Inst,
) !*zir.Inst {
const gen_zir = scope.getGenZIR();
try gen_zir.instructions.ensureCapacity(mod.gpa, gen_zir.instructions.items.len + 1);
const inst = try gen_zir.arena.create(zir.Inst.UnOp);
inst.* = .{
.base = .{
.tag = tag,
.src = src,
},
.positionals = .{
.operand = operand,
},
.kw_args = .{},
};
gen_zir.instructions.appendAssumeCapacity(&inst.base);
return &inst.base;
}
pub fn addZIRBinOp(
mod: *Module,
scope: *Scope,
src: usize,
tag: zir.Inst.Tag,
lhs: *zir.Inst,
rhs: *zir.Inst,
) !*zir.Inst {
const gen_zir = scope.getGenZIR();
try gen_zir.instructions.ensureCapacity(mod.gpa, gen_zir.instructions.items.len + 1);
const inst = try gen_zir.arena.create(zir.Inst.BinOp);
inst.* = .{
.base = .{
.tag = tag,
.src = src,
},
.positionals = .{
.lhs = lhs,
.rhs = rhs,
},
.kw_args = .{},
};
gen_zir.instructions.appendAssumeCapacity(&inst.base);
return &inst.base;
}
pub fn addZIRInstBlock(
mod: *Module,
scope: *Scope,
src: usize,
tag: zir.Inst.Tag,
body: zir.Body,
) !*zir.Inst.Block {
const gen_zir = scope.getGenZIR();
try gen_zir.instructions.ensureCapacity(mod.gpa, gen_zir.instructions.items.len + 1);
const inst = try gen_zir.arena.create(zir.Inst.Block);
inst.* = .{
.base = .{
.tag = tag,
.src = src,
},
.positionals = .{
.body = body,
},
.kw_args = .{},
};
gen_zir.instructions.appendAssumeCapacity(&inst.base);
return inst;
}
pub fn addZIRInst(
mod: *Module,
scope: *Scope,
src: usize,
comptime T: type,
positionals: std.meta.fieldInfo(T, .positionals).field_type,
kw_args: std.meta.fieldInfo(T, .kw_args).field_type,
) !*zir.Inst {
const inst_special = try addZIRInstSpecial(mod, scope, src, T, positionals, kw_args);
return &inst_special.base;
}
/// TODO The existence of this function is a workaround for a bug in stage1.
pub fn addZIRInstConst(mod: *Module, scope: *Scope, src: usize, typed_value: TypedValue) !*zir.Inst {
const P = std.meta.fieldInfo(zir.Inst.Const, .positionals).field_type;
return addZIRInst(mod, scope, src, zir.Inst.Const, P{ .typed_value = typed_value }, .{});
}
/// TODO The existence of this function is a workaround for a bug in stage1.
pub fn addZIRInstLoop(mod: *Module, scope: *Scope, src: usize, body: zir.Body) !*zir.Inst.Loop {
const P = std.meta.fieldInfo(zir.Inst.Loop, .positionals).field_type;
return addZIRInstSpecial(mod, scope, src, zir.Inst.Loop, P{ .body = body }, .{});
}
|
src/astgen.zig
|
const std = @import("../../std.zig");
const linux = std.os.linux;
const socklen_t = linux.socklen_t;
const iovec = linux.iovec;
const iovec_const = linux.iovec_const;
pub const SYS_io_setup = 0;
pub const SYS_io_destroy = 1;
pub const SYS_io_submit = 2;
pub const SYS_io_cancel = 3;
pub const SYS_io_getevents = 4;
pub const SYS_setxattr = 5;
pub const SYS_lsetxattr = 6;
pub const SYS_fsetxattr = 7;
pub const SYS_getxattr = 8;
pub const SYS_lgetxattr = 9;
pub const SYS_fgetxattr = 10;
pub const SYS_listxattr = 11;
pub const SYS_llistxattr = 12;
pub const SYS_flistxattr = 13;
pub const SYS_removexattr = 14;
pub const SYS_lremovexattr = 15;
pub const SYS_fremovexattr = 16;
pub const SYS_getcwd = 17;
pub const SYS_lookup_dcookie = 18;
pub const SYS_eventfd2 = 19;
pub const SYS_epoll_create1 = 20;
pub const SYS_epoll_ctl = 21;
pub const SYS_epoll_pwait = 22;
pub const SYS_dup = 23;
pub const SYS_dup3 = 24;
pub const SYS_fcntl = 25;
pub const SYS_inotify_init1 = 26;
pub const SYS_inotify_add_watch = 27;
pub const SYS_inotify_rm_watch = 28;
pub const SYS_ioctl = 29;
pub const SYS_ioprio_set = 30;
pub const SYS_ioprio_get = 31;
pub const SYS_flock = 32;
pub const SYS_mknodat = 33;
pub const SYS_mkdirat = 34;
pub const SYS_unlinkat = 35;
pub const SYS_symlinkat = 36;
pub const SYS_linkat = 37;
pub const SYS_renameat = 38;
pub const SYS_umount2 = 39;
pub const SYS_mount = 40;
pub const SYS_pivot_root = 41;
pub const SYS_nfsservctl = 42;
pub const SYS_statfs = 43;
pub const SYS_fstatfs = 44;
pub const SYS_truncate = 45;
pub const SYS_ftruncate = 46;
pub const SYS_fallocate = 47;
pub const SYS_faccessat = 48;
pub const SYS_chdir = 49;
pub const SYS_fchdir = 50;
pub const SYS_chroot = 51;
pub const SYS_fchmod = 52;
pub const SYS_fchmodat = 53;
pub const SYS_fchownat = 54;
pub const SYS_fchown = 55;
pub const SYS_openat = 56;
pub const SYS_close = 57;
pub const SYS_vhangup = 58;
pub const SYS_pipe2 = 59;
pub const SYS_quotactl = 60;
pub const SYS_getdents64 = 61;
pub const SYS_lseek = 62;
pub const SYS_read = 63;
pub const SYS_write = 64;
pub const SYS_readv = 65;
pub const SYS_writev = 66;
pub const SYS_pread64 = 67;
pub const SYS_pwrite64 = 68;
pub const SYS_preadv = 69;
pub const SYS_pwritev = 70;
pub const SYS_pselect6 = 72;
pub const SYS_ppoll = 73;
pub const SYS_signalfd4 = 74;
pub const SYS_vmsplice = 75;
pub const SYS_splice = 76;
pub const SYS_tee = 77;
pub const SYS_readlinkat = 78;
pub const SYS_fstatat = 79;
pub const SYS_fstat = 80;
pub const SYS_sync = 81;
pub const SYS_fsync = 82;
pub const SYS_fdatasync = 83;
pub const SYS_sync_file_range2 = 84;
pub const SYS_sync_file_range = 84;
pub const SYS_timerfd_create = 85;
pub const SYS_timerfd_settime = 86;
pub const SYS_timerfd_gettime = 87;
pub const SYS_utimensat = 88;
pub const SYS_acct = 89;
pub const SYS_capget = 90;
pub const SYS_capset = 91;
pub const SYS_personality = 92;
pub const SYS_exit = 93;
pub const SYS_exit_group = 94;
pub const SYS_waitid = 95;
pub const SYS_set_tid_address = 96;
pub const SYS_unshare = 97;
pub const SYS_futex = 98;
pub const SYS_set_robust_list = 99;
pub const SYS_get_robust_list = 100;
pub const SYS_nanosleep = 101;
pub const SYS_getitimer = 102;
pub const SYS_setitimer = 103;
pub const SYS_kexec_load = 104;
pub const SYS_init_module = 105;
pub const SYS_delete_module = 106;
pub const SYS_timer_create = 107;
pub const SYS_timer_gettime = 108;
pub const SYS_timer_getoverrun = 109;
pub const SYS_timer_settime = 110;
pub const SYS_timer_delete = 111;
pub const SYS_clock_settime = 112;
pub const SYS_clock_gettime = 113;
pub const SYS_clock_getres = 114;
pub const SYS_clock_nanosleep = 115;
pub const SYS_syslog = 116;
pub const SYS_ptrace = 117;
pub const SYS_sched_setparam = 118;
pub const SYS_sched_setscheduler = 119;
pub const SYS_sched_getscheduler = 120;
pub const SYS_sched_getparam = 121;
pub const SYS_sched_setaffinity = 122;
pub const SYS_sched_getaffinity = 123;
pub const SYS_sched_yield = 124;
pub const SYS_sched_get_priority_max = 125;
pub const SYS_sched_get_priority_min = 126;
pub const SYS_sched_rr_get_interval = 127;
pub const SYS_restart_syscall = 128;
pub const SYS_kill = 129;
pub const SYS_tkill = 130;
pub const SYS_tgkill = 131;
pub const SYS_sigaltstack = 132;
pub const SYS_rt_sigsuspend = 133;
pub const SYS_rt_sigaction = 134;
pub const SYS_rt_sigprocmask = 135;
pub const SYS_rt_sigpending = 136;
pub const SYS_rt_sigtimedwait = 137;
pub const SYS_rt_sigqueueinfo = 138;
pub const SYS_rt_sigreturn = 139;
pub const SYS_setpriority = 140;
pub const SYS_getpriority = 141;
pub const SYS_reboot = 142;
pub const SYS_setregid = 143;
pub const SYS_setgid = 144;
pub const SYS_setreuid = 145;
pub const SYS_setuid = 146;
pub const SYS_setresuid = 147;
pub const SYS_getresuid = 148;
pub const SYS_setresgid = 149;
pub const SYS_getresgid = 150;
pub const SYS_setfsuid = 151;
pub const SYS_setfsgid = 152;
pub const SYS_times = 153;
pub const SYS_setpgid = 154;
pub const SYS_getpgid = 155;
pub const SYS_getsid = 156;
pub const SYS_setsid = 157;
pub const SYS_getgroups = 158;
pub const SYS_setgroups = 159;
pub const SYS_uname = 160;
pub const SYS_sethostname = 161;
pub const SYS_setdomainname = 162;
pub const SYS_getrlimit = 163;
pub const SYS_setrlimit = 164;
pub const SYS_getrusage = 165;
pub const SYS_umask = 166;
pub const SYS_prctl = 167;
pub const SYS_getcpu = 168;
pub const SYS_gettimeofday = 169;
pub const SYS_settimeofday = 170;
pub const SYS_adjtimex = 171;
pub const SYS_getpid = 172;
pub const SYS_getppid = 173;
pub const SYS_getuid = 174;
pub const SYS_geteuid = 175;
pub const SYS_getgid = 176;
pub const SYS_getegid = 177;
pub const SYS_gettid = 178;
pub const SYS_sysinfo = 179;
pub const SYS_mq_open = 180;
pub const SYS_mq_unlink = 181;
pub const SYS_mq_timedsend = 182;
pub const SYS_mq_timedreceive = 183;
pub const SYS_mq_notify = 184;
pub const SYS_mq_getsetattr = 185;
pub const SYS_msgget = 186;
pub const SYS_msgctl = 187;
pub const SYS_msgrcv = 188;
pub const SYS_msgsnd = 189;
pub const SYS_semget = 190;
pub const SYS_semctl = 191;
pub const SYS_semtimedop = 192;
pub const SYS_semop = 193;
pub const SYS_shmget = 194;
pub const SYS_shmctl = 195;
pub const SYS_shmat = 196;
pub const SYS_shmdt = 197;
pub const SYS_socket = 198;
pub const SYS_socketpair = 199;
pub const SYS_bind = 200;
pub const SYS_listen = 201;
pub const SYS_accept = 202;
pub const SYS_connect = 203;
pub const SYS_getsockname = 204;
pub const SYS_getpeername = 205;
pub const SYS_sendto = 206;
pub const SYS_recvfrom = 207;
pub const SYS_setsockopt = 208;
pub const SYS_getsockopt = 209;
pub const SYS_shutdown = 210;
pub const SYS_sendmsg = 211;
pub const SYS_recvmsg = 212;
pub const SYS_readahead = 213;
pub const SYS_brk = 214;
pub const SYS_munmap = 215;
pub const SYS_mremap = 216;
pub const SYS_add_key = 217;
pub const SYS_request_key = 218;
pub const SYS_keyctl = 219;
pub const SYS_clone = 220;
pub const SYS_execve = 221;
pub const SYS_mmap = 222;
pub const SYS_fadvise64 = 223;
pub const SYS_swapon = 224;
pub const SYS_swapoff = 225;
pub const SYS_mprotect = 226;
pub const SYS_msync = 227;
pub const SYS_mlock = 228;
pub const SYS_munlock = 229;
pub const SYS_mlockall = 230;
pub const SYS_munlockall = 231;
pub const SYS_mincore = 232;
pub const SYS_madvise = 233;
pub const SYS_remap_file_pages = 234;
pub const SYS_mbind = 235;
pub const SYS_get_mempolicy = 236;
pub const SYS_set_mempolicy = 237;
pub const SYS_migrate_pages = 238;
pub const SYS_move_pages = 239;
pub const SYS_rt_tgsigqueueinfo = 240;
pub const SYS_perf_event_open = 241;
pub const SYS_accept4 = 242;
pub const SYS_recvmmsg = 243;
pub const SYS_arch_specific_syscall = 244;
pub const SYS_wait4 = 260;
pub const SYS_prlimit64 = 261;
pub const SYS_fanotify_init = 262;
pub const SYS_fanotify_mark = 263;
pub const SYS_clock_adjtime = 266;
pub const SYS_syncfs = 267;
pub const SYS_setns = 268;
pub const SYS_sendmmsg = 269;
pub const SYS_process_vm_readv = 270;
pub const SYS_process_vm_writev = 271;
pub const SYS_kcmp = 272;
pub const SYS_finit_module = 273;
pub const SYS_sched_setattr = 274;
pub const SYS_sched_getattr = 275;
pub const SYS_renameat2 = 276;
pub const SYS_seccomp = 277;
pub const SYS_getrandom = 278;
pub const SYS_memfd_create = 279;
pub const SYS_bpf = 280;
pub const SYS_execveat = 281;
pub const SYS_userfaultfd = 282;
pub const SYS_membarrier = 283;
pub const SYS_mlock2 = 284;
pub const SYS_copy_file_range = 285;
pub const SYS_preadv2 = 286;
pub const SYS_pwritev2 = 287;
pub const SYS_pkey_mprotect = 288;
pub const SYS_pkey_alloc = 289;
pub const SYS_pkey_free = 290;
pub const SYS_statx = 291;
pub const SYS_io_pgetevents = 292;
pub const SYS_rseq = 293;
pub const SYS_kexec_file_load = 294;
pub const SYS_pidfd_send_signal = 424;
pub const SYS_io_uring_setup = 425;
pub const SYS_io_uring_enter = 426;
pub const SYS_io_uring_register = 427;
pub const SYS_open_tree = 428;
pub const SYS_move_mount = 429;
pub const SYS_fsopen = 430;
pub const SYS_fsconfig = 431;
pub const SYS_fsmount = 432;
pub const SYS_fspick = 433;
pub const O_CREAT = 0o100;
pub const O_EXCL = 0o200;
pub const O_NOCTTY = 0o400;
pub const O_TRUNC = 0o1000;
pub const O_APPEND = 0o2000;
pub const O_NONBLOCK = 0o4000;
pub const O_DSYNC = 0o10000;
pub const O_SYNC = 0o4010000;
pub const O_RSYNC = 0o4010000;
pub const O_DIRECTORY = 0o40000;
pub const O_NOFOLLOW = 0o100000;
pub const O_CLOEXEC = 0o2000000;
pub const O_ASYNC = 0o20000;
pub const O_DIRECT = 0o200000;
pub const O_LARGEFILE = 0o400000;
pub const O_NOATIME = 0o1000000;
pub const O_PATH = 0o10000000;
pub const O_TMPFILE = 0o20040000;
pub const O_NDELAY = O_NONBLOCK;
pub const F_DUPFD = 0;
pub const F_GETFD = 1;
pub const F_SETFD = 2;
pub const F_GETFL = 3;
pub const F_SETFL = 4;
pub const F_SETOWN = 8;
pub const F_GETOWN = 9;
pub const F_SETSIG = 10;
pub const F_GETSIG = 11;
pub const F_GETLK = 5;
pub const F_SETLK = 6;
pub const F_SETLKW = 7;
pub const F_SETOWN_EX = 15;
pub const F_GETOWN_EX = 16;
pub const F_GETOWNER_UIDS = 17;
/// stack-like segment
pub const MAP_GROWSDOWN = 0x0100;
/// ETXTBSY
pub const MAP_DENYWRITE = 0x0800;
/// mark it as an executable
pub const MAP_EXECUTABLE = 0x1000;
/// pages are locked
pub const MAP_LOCKED = 0x2000;
/// don't check for reservations
pub const MAP_NORESERVE = 0x4000;
/// populate (prefault) pagetables
pub const MAP_POPULATE = 0x8000;
/// do not block on IO
pub const MAP_NONBLOCK = 0x10000;
/// give out an address that is best suited for process/thread stacks
pub const MAP_STACK = 0x20000;
/// create a huge page mapping
pub const MAP_HUGETLB = 0x40000;
/// perform synchronous page faults for the mapping
pub const MAP_SYNC = 0x80000;
pub const VDSO_USEFUL = true;
pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
pub const VDSO_CGT_VER = "LINUX_2.6.39";
pub const msghdr = extern struct {
msg_name: ?*sockaddr,
msg_namelen: socklen_t,
msg_iov: [*]iovec,
msg_iovlen: i32,
__pad1: i32,
msg_control: ?*c_void,
msg_controllen: socklen_t,
__pad2: socklen_t,
msg_flags: i32,
};
pub const msghdr_const = extern struct {
msg_name: ?*const sockaddr,
msg_namelen: socklen_t,
msg_iov: [*]iovec_const,
msg_iovlen: i32,
__pad1: i32,
msg_control: ?*c_void,
msg_controllen: socklen_t,
__pad2: socklen_t,
msg_flags: i32,
};
/// Renamed to Stat to not conflict with the stat function.
pub const Stat = extern struct {
dev: u64,
ino: u64,
nlink: usize,
mode: u32,
uid: u32,
gid: u32,
__pad0: u32,
rdev: u64,
size: i64,
blksize: isize,
blocks: i64,
atim: timespec,
mtim: timespec,
ctim: timespec,
__unused: [3]isize,
};
pub const timespec = extern struct {
tv_sec: isize,
tv_nsec: isize,
};
pub const timeval = extern struct {
tv_sec: isize,
tv_usec: isize,
};
pub const timezone = extern struct {
tz_minuteswest: i32,
tz_dsttime: i32,
};
pub const Elf_Symndx = u32;
|
std/os/bits/linux/arm64.zig
|
const std = @import("std");
const mem = std.mem;
const Allocator = mem.Allocator;
const Sha224 = std.crypto.hash.sha2.Sha224;
const Sha384 = std.crypto.hash.sha2.Sha384;
const Sha512 = std.crypto.hash.sha2.Sha512;
const Sha256 = std.crypto.hash.sha2.Sha256;
const Hmac256 = std.crypto.auth.hmac.sha2.HmacSha256;
pub const asn1 = @import("asn1.zig");
pub const x509 = @import("x509.zig");
pub const crypto = @import("crypto.zig");
const ciphers = @import("ciphersuites.zig");
pub const ciphersuites = ciphers.suites;
pub const @"pcks1v1.5" = @import("pcks1-1_5.zig");
comptime {
std.testing.refAllDecls(x509);
std.testing.refAllDecls(asn1);
std.testing.refAllDecls(crypto);
}
fn handshake_record_length(reader: anytype) !usize {
return try record_length(0x16, reader);
}
pub const RecordTagLength = struct {
tag: u8,
length: u16,
};
pub fn record_tag_length(reader: anytype) !RecordTagLength {
const record_tag = try reader.readByte();
var record_header: [4]u8 = undefined;
try reader.readNoEof(&record_header);
if (!mem.eql(u8, record_header[0..2], "\x03\x03") and !mem.eql(u8, record_header[0..2], "\x03\x01"))
return error.ServerInvalidVersion;
const len = mem.readIntSliceBig(u16, record_header[2..4]);
return RecordTagLength{
.tag = record_tag,
.length = len,
};
}
pub fn record_length(t: u8, reader: anytype) !usize {
try check_record_type(t, reader);
var record_header: [4]u8 = undefined;
try reader.readNoEof(&record_header);
if (!mem.eql(u8, record_header[0..2], "\x03\x03") and !mem.eql(u8, record_header[0..2], "\x03\x01"))
return error.ServerInvalidVersion;
return mem.readIntSliceBig(u16, record_header[2..4]);
}
pub const ServerAlert = error{
AlertCloseNotify,
AlertUnexpectedMessage,
AlertBadRecordMAC,
AlertDecryptionFailed,
AlertRecordOverflow,
AlertDecompressionFailure,
AlertHandshakeFailure,
AlertNoCertificate,
AlertBadCertificate,
AlertUnsupportedCertificate,
AlertCertificateRevoked,
AlertCertificateExpired,
AlertCertificateUnknown,
AlertIllegalParameter,
AlertUnknownCA,
AlertAccessDenied,
AlertDecodeError,
AlertDecryptError,
AlertExportRestriction,
AlertProtocolVersion,
AlertInsufficientSecurity,
AlertInternalError,
AlertUserCanceled,
AlertNoRenegotiation,
AlertUnsupportedExtension,
};
fn check_record_type(
expected: u8,
reader: anytype,
) (@TypeOf(reader).Error || ServerAlert || error{ ServerMalformedResponse, EndOfStream })!void {
const record_type = try reader.readByte();
// Alert
if (record_type == 0x15) {
// Skip SSL version, length of record
try reader.skipBytes(4, .{});
const severity = try reader.readByte();
const err_num = try reader.readByte();
return alert_byte_to_error(err_num);
}
if (record_type != expected)
return error.ServerMalformedResponse;
}
pub fn alert_byte_to_error(b: u8) (ServerAlert || error{ServerMalformedResponse}) {
return switch (b) {
0 => error.AlertCloseNotify,
10 => error.AlertUnexpectedMessage,
20 => error.AlertBadRecordMAC,
21 => error.AlertDecryptionFailed,
22 => error.AlertRecordOverflow,
30 => error.AlertDecompressionFailure,
40 => error.AlertHandshakeFailure,
41 => error.AlertNoCertificate,
42 => error.AlertBadCertificate,
43 => error.AlertUnsupportedCertificate,
44 => error.AlertCertificateRevoked,
45 => error.AlertCertificateExpired,
46 => error.AlertCertificateUnknown,
47 => error.AlertIllegalParameter,
48 => error.AlertUnknownCA,
49 => error.AlertAccessDenied,
50 => error.AlertDecodeError,
51 => error.AlertDecryptError,
60 => error.AlertExportRestriction,
70 => error.AlertProtocolVersion,
71 => error.AlertInsufficientSecurity,
80 => error.AlertInternalError,
90 => error.AlertUserCanceled,
100 => error.AlertNoRenegotiation,
110 => error.AlertUnsupportedExtension,
else => error.ServerMalformedResponse,
};
}
// TODO: Now that we keep all the hashes, check the ciphersuite for the hash
// type used and use it where necessary instead of hardcoding sha256
const HashSet = struct {
sha224: Sha224,
sha256: Sha256,
sha384: Sha384,
sha512: Sha512,
fn update(self: *@This(), buf: []const u8) void {
self.sha224.update(buf);
self.sha256.update(buf);
self.sha384.update(buf);
self.sha512.update(buf);
}
};
fn HashingReader(comptime Reader: anytype) type {
const State = struct {
hash_set: *HashSet,
reader: Reader,
};
const S = struct {
pub fn read(state: State, buffer: []u8) Reader.Error!usize {
const amt = try state.reader.read(buffer);
if (amt != 0) {
state.hash_set.update(buffer[0..amt]);
}
return amt;
}
};
return std.io.Reader(State, Reader.Error, S.read);
}
fn make_hashing_reader(hash_set: *HashSet, reader: anytype) HashingReader(@TypeOf(reader)) {
return .{ .context = .{ .hash_set = hash_set, .reader = reader } };
}
fn HashingWriter(comptime Writer: anytype) type {
const State = struct {
hash_set: *HashSet,
writer: Writer,
};
const S = struct {
pub fn write(state: State, buffer: []const u8) Writer.Error!usize {
const amt = try state.writer.write(buffer);
if (amt != 0) {
state.hash_set.update(buffer[0..amt]);
}
return amt;
}
};
return std.io.Writer(State, Writer.Error, S.write);
}
fn make_hashing_writer(hash_set: *HashSet, writer: anytype) HashingWriter(@TypeOf(writer)) {
return .{ .context = .{ .hash_set = hash_set, .writer = writer } };
}
fn CertificateReaderState(comptime Reader: type) type {
return struct {
reader: Reader,
length: usize,
idx: usize = 0,
};
}
fn CertificateReader(comptime Reader: type) type {
const S = struct {
pub fn read(state: *CertificateReaderState(Reader), buffer: []u8) Reader.Error!usize {
const out_bytes = std.math.min(buffer.len, state.length - state.idx);
const res = try state.reader.readAll(buffer[0..out_bytes]);
state.idx += res;
return res;
}
};
return std.io.Reader(*CertificateReaderState(Reader), Reader.Error, S.read);
}
pub const CertificateVerifier = union(enum) {
none,
function: anytype,
default,
};
pub fn CertificateVerifierReader(comptime Reader: type) type {
return CertificateReader(HashingReader(Reader));
}
pub fn ClientConnectError(
comptime verifier: CertificateVerifier,
comptime Reader: type,
comptime Writer: type,
comptime has_client_certs: bool,
) type {
const Additional = error{
ServerInvalidVersion,
ServerMalformedResponse,
EndOfStream,
ServerInvalidCipherSuite,
ServerInvalidCompressionMethod,
ServerInvalidRenegotiationData,
ServerInvalidECPointCompression,
ServerInvalidProtocol,
ServerInvalidExtension,
ServerInvalidCurve,
ServerInvalidSignature,
ServerInvalidSignatureAlgorithm,
ServerAuthenticationFailed,
ServerInvalidVerifyData,
PreMasterGenerationFailed,
OutOfMemory,
};
const err_msg = "Certificate verifier function cannot be generic, use CertificateVerifierReader to get the reader argument type";
return Reader.Error || Writer.Error || ServerAlert || Additional || switch (verifier) {
.none => error{},
.function => |f| @typeInfo(@typeInfo(@TypeOf(f)).Fn.return_type orelse
@compileError(err_msg)).ErrorUnion.error_set || error{CertificateVerificationFailed},
.default => error{CertificateVerificationFailed},
} || (if (has_client_certs) error{ClientCertificateVerifyFailed} else error{});
}
// See http://howardhinnant.github.io/date_algorithms.html
// Timestamp in seconds, only supports A.D. dates
fn unix_timestamp_from_civil_date(year: u16, month: u8, day: u8) i64 {
var y: i64 = year;
if (month <= 2) y -= 1;
const era = @divTrunc(y, 400);
const yoe = y - era * 400; // [0, 399]
const doy = @divTrunc((153 * (month + (if (month > 2) @as(i64, -3) else 9)) + 2), 5) + day - 1; // [0, 365]
const doe = yoe * 365 + @divTrunc(yoe, 4) - @divTrunc(yoe, 100) + doy; // [0, 146096]
return (era * 146097 + doe - 719468) * 86400;
}
fn read_der_utc_timestamp(reader: anytype) !i64 {
var buf: [17]u8 = undefined;
const tag = try reader.readByte();
if (tag != 0x17)
return error.CertificateVerificationFailed;
const len = try asn1.der.parse_length(reader);
if (len > 17)
return error.CertificateVerificationFailed;
try reader.readNoEof(buf[0..len]);
const year = std.fmt.parseUnsigned(u16, buf[0..2], 10) catch
return error.CertificateVerificationFailed;
const month = std.fmt.parseUnsigned(u8, buf[2..4], 10) catch
return error.CertificateVerificationFailed;
const day = std.fmt.parseUnsigned(u8, buf[4..6], 10) catch
return error.CertificateVerificationFailed;
var time = unix_timestamp_from_civil_date(2000 + year, month, day);
time += (std.fmt.parseUnsigned(i64, buf[6..8], 10) catch
return error.CertificateVerificationFailed) * 3600;
time += (std.fmt.parseUnsigned(i64, buf[8..10], 10) catch
return error.CertificateVerificationFailed) * 60;
if (buf[len - 1] == 'Z') {
if (len == 13) {
time += std.fmt.parseUnsigned(u8, buf[10..12], 10) catch
return error.CertificateVerificationFailed;
} else if (len != 11) {
return error.CertificateVerificationFailed;
}
} else {
if (len == 15) {
if (buf[10] != '+' and buf[10] != '-')
return error.CertificateVerificationFailed;
var additional = (std.fmt.parseUnsigned(i64, buf[11..13], 10) catch
return error.CertificateVerificationFailed) * 3600;
additional += (std.fmt.parseUnsigned(i64, buf[13..15], 10) catch
return error.CertificateVerificationFailed) * 60;
time += if (buf[10] == '+') -additional else additional;
} else if (len == 17) {
if (buf[12] != '+' and buf[12] != '-')
return error.CertificateVerificationFailed;
time += std.fmt.parseUnsigned(u8, buf[10..12], 10) catch
return error.CertificateVerificationFailed;
var additional = (std.fmt.parseUnsigned(i64, buf[13..15], 10) catch
return error.CertificateVerificationFailed) * 3600;
additional += (std.fmt.parseUnsigned(i64, buf[15..17], 10) catch
return error.CertificateVerificationFailed) * 60;
time += if (buf[12] == '+') -additional else additional;
} else return error.CertificateVerificationFailed;
}
return time;
}
fn check_cert_timestamp(time: i64, tag_byte: u8, length: usize, reader: anytype) !void {
if (time < (try read_der_utc_timestamp(reader)))
return error.CertificateVerificationFailed;
if (time > (try read_der_utc_timestamp(reader)))
return error.CertificateVerificationFailed;
}
fn add_dn_field(state: *VerifierCaptureState, tag: u8, length: usize, reader: anytype) !void {
const seq_tag = try reader.readByte();
if (seq_tag != 0x30)
return error.CertificateVerificationFailed;
const seq_length = try asn1.der.parse_length(reader);
const oid_tag = try reader.readByte();
if (oid_tag != 0x06)
return error.CertificateVerificationFailed;
const oid_length = try asn1.der.parse_length(reader);
if (oid_length == 3 and (try reader.isBytes("\x55\x04\x03"))) {
// Common name
const common_name_tag = try reader.readByte();
if (common_name_tag != 0x04 and common_name_tag != 0x0c and common_name_tag != 0x13 and common_name_tag != 0x16)
return error.CertificateVerificationFailed;
const common_name_len = try asn1.der.parse_length(reader);
state.list.items[state.list.items.len - 1].common_name = state.fbs.buffer[state.fbs.pos .. state.fbs.pos + common_name_len];
}
}
fn add_cert_subject_dn(state: *VerifierCaptureState, tag: u8, length: usize, reader: anytype) !void {
state.list.items[state.list.items.len - 1].dn = state.fbs.buffer[state.fbs.pos .. state.fbs.pos + length];
const schema = .{
.sequence_of,
.{
.capture, 0, .set,
},
};
const captures = .{
state, add_dn_field,
};
try asn1.der.parse_schema_tag_len(tag, length, schema, captures, reader);
}
fn add_cert_public_key(state: *VerifierCaptureState, _: u8, length: usize, reader: anytype) !void {
state.list.items[state.list.items.len - 1].public_key = x509.parse_public_key(
state.allocator,
reader,
) catch |err| switch (err) {
error.MalformedDER => return error.CertificateVerificationFailed,
else => |e| return e,
};
}
fn add_cert_extensions(state: *VerifierCaptureState, tag: u8, length: usize, reader: anytype) !void {
const schema = .{
.sequence_of,
.{ .capture, 0, .sequence },
};
const captures = .{
state, add_cert_extension,
};
try asn1.der.parse_schema(schema, captures, reader);
}
fn add_cert_extension(state: *VerifierCaptureState, tag: u8, length: usize, reader: anytype) !void {
const start = state.fbs.pos;
// The happy path is allocation free
// TODO: add a preflight check to mandate a specific tag
const object_id = try asn1.der.parse_value(state.allocator, reader);
defer object_id.deinit(state.allocator);
if (object_id != .object_identifier) return error.DoesNotMatchSchema;
if (object_id.object_identifier.len != 4)
return;
const data = object_id.object_identifier.data;
// Prefix == id-ce
if (data[0] != 2 or data[1] != 5 or data[2] != 29)
return;
switch (data[3]) {
17 => {
const san_tag = try reader.readByte();
if (san_tag != @enumToInt(asn1.Tag.octet_string)) return error.DoesNotMatchSchema;
const san_length = try asn1.der.parse_length(reader);
const body_tag = try reader.readByte();
if (body_tag != @enumToInt(asn1.Tag.sequence)) return error.DoesNotMatchSchema;
const body_length = try asn1.der.parse_length(reader);
const total_read = state.fbs.pos - start;
if (total_read + body_length > length) return error.DoesNotMatchSchema;
state.list.items[state.list.items.len - 1].raw_subject_alternative_name = state.fbs.buffer[state.fbs.pos .. state.fbs.pos + body_length];
// Validate to make sure this is iterable later
const ref = state.fbs.pos;
while (state.fbs.pos - ref < body_length) {
const choice = try reader.readByte();
if (choice < 0x80) return error.DoesNotMatchSchema;
const chunk_length = try asn1.der.parse_length(reader);
_ = try reader.skipBytes(chunk_length, .{});
}
},
else => {},
}
}
fn add_server_cert(state: *VerifierCaptureState, tag_byte: u8, length: usize, reader: anytype) !void {
const is_ca = state.list.items.len != 0;
// TODO: Some way to get tag + length buffer directly in the capture callback?
const encoded_length = asn1.der.encode_length(length).slice();
// This is not errdefered since default_cert_verifier call takes care of cleaning up all the certificate data.
// Same for the signature.data
const cert_bytes = try state.allocator.alloc(u8, length + 1 + encoded_length.len);
cert_bytes[0] = tag_byte;
mem.copy(u8, cert_bytes[1 .. 1 + encoded_length.len], encoded_length);
try reader.readNoEof(cert_bytes[1 + encoded_length.len ..]);
(try state.list.addOne(state.allocator)).* = .{
.is_ca = is_ca,
.bytes = cert_bytes,
.dn = undefined,
.common_name = &[0]u8{},
.raw_subject_alternative_name = &[0]u8{},
.public_key = x509.PublicKey.empty,
.signature = asn1.BitString{ .data = &[0]u8{}, .bit_len = 0 },
.signature_algorithm = undefined,
};
const schema = .{
.sequence,
.{
.{ .context_specific, 0 }, // version
.{.int}, // serialNumber
.{.sequence}, // signature
.{.sequence}, // issuer
.{ .capture, 0, .sequence }, // validity
.{ .capture, 1, .sequence }, // subject
.{ .capture, 2, .sequence }, // subjectPublicKeyInfo
.{ .optional, .context_specific, 1 }, // issuerUniqueID
.{ .optional, .context_specific, 2 }, // subjectUniqueID
.{ .capture, 3, .optional, .context_specific, 3 }, // extensions
},
};
const captures = .{
std.time.timestamp(), check_cert_timestamp,
state, add_cert_subject_dn,
state, add_cert_public_key,
state, add_cert_extensions,
};
var fbs = std.io.fixedBufferStream(@as([]const u8, cert_bytes[1 + encoded_length.len ..]));
state.fbs = &fbs;
asn1.der.parse_schema_tag_len(tag_byte, length, schema, captures, fbs.reader()) catch |err| switch (err) {
error.InvalidLength,
error.InvalidTag,
error.InvalidContainerLength,
error.DoesNotMatchSchema,
=> return error.CertificateVerificationFailed,
else => |e| return e,
};
}
fn set_signature_algorithm(state: *VerifierCaptureState, _: u8, length: usize, reader: anytype) !void {
const cert = &state.list.items[state.list.items.len - 1];
cert.signature_algorithm = (try x509.get_signature_algorithm(reader)) orelse return error.CertificateVerificationFailed;
}
fn set_signature_value(state: *VerifierCaptureState, tag: u8, length: usize, reader: anytype) !void {
const unused_bits = try reader.readByte();
const bit_count = (length - 1) * 8 - unused_bits;
const signature_bytes = try state.allocator.alloc(u8, length - 1);
errdefer state.allocator.free(signature_bytes);
try reader.readNoEof(signature_bytes);
state.list.items[state.list.items.len - 1].signature = .{
.data = signature_bytes,
.bit_len = bit_count,
};
}
const ServerCertificate = struct {
bytes: []const u8,
dn: []const u8,
common_name: []const u8,
raw_subject_alternative_name: []const u8,
public_key: x509.PublicKey,
signature: asn1.BitString,
signature_algorithm: x509.Certificate.SignatureAlgorithm,
is_ca: bool,
const GeneralName = enum(u5) {
other_name = 0,
rfc822_name = 1,
dns_name = 2,
x400_address = 3,
directory_name = 4,
edi_party_name = 5,
uniform_resource_identifier = 6,
ip_address = 7,
registered_id = 8,
};
fn iterSAN(self: ServerCertificate, choice: GeneralName) NameIterator {
return .{ .cert = self, .choice = choice };
}
const NameIterator = struct {
cert: ServerCertificate,
choice: GeneralName,
pos: usize = 0,
fn next(self: *NameIterator) ?[]const u8 {
while (self.pos < self.cert.raw_subject_alternative_name.len) {
const choice = self.cert.raw_subject_alternative_name[self.pos];
std.debug.assert(choice >= 0x80);
const len = self.cert.raw_subject_alternative_name[self.pos + 1];
const start = self.pos + 2;
const end = start + len;
self.pos = end;
if (@enumToInt(self.choice) == choice - 0x80) {
return self.cert.raw_subject_alternative_name[start..end];
}
}
return null;
}
};
};
const VerifierCaptureState = struct {
list: std.ArrayListUnmanaged(ServerCertificate),
allocator: *Allocator,
// Used in `add_server_cert` to avoid an extra allocation
fbs: *std.io.FixedBufferStream([]const u8),
};
// @TODO Move out of here
const ReverseSplitIterator = struct {
buffer: []const u8,
index: ?usize,
delimiter: []const u8,
pub fn next(self: *ReverseSplitIterator) ?[]const u8 {
const end = self.index orelse return null;
const start = if (mem.lastIndexOfLinear(u8, self.buffer[0..end], self.delimiter)) |delim_start| blk: {
self.index = delim_start;
break :blk delim_start + self.delimiter.len;
} else blk: {
self.index = null;
break :blk 0;
};
return self.buffer[start..end];
}
};
fn reverse_split(buffer: []const u8, delimiter: []const u8) ReverseSplitIterator {
std.debug.assert(delimiter.len != 0);
return .{
.index = buffer.len,
.buffer = buffer,
.delimiter = delimiter,
};
}
fn cert_name_matches(cert_name: []const u8, hostname: []const u8) bool {
var cert_name_split = reverse_split(cert_name, ".");
var hostname_split = reverse_split(hostname, ".");
while (true) {
const cn_part = cert_name_split.next();
const hn_part = hostname_split.next();
if (cn_part) |cnp| {
if (hn_part == null and cert_name_split.index == null and mem.eql(u8, cnp, "www"))
return true
else if (hn_part) |hnp| {
if (mem.eql(u8, cnp, "*"))
continue;
if (!mem.eql(u8, cnp, hnp))
return false;
}
} else return hn_part == null;
}
}
pub fn default_cert_verifier(
allocator: *mem.Allocator,
reader: anytype,
certs_bytes: usize,
trusted_certificates: []const x509.Certificate,
hostname: []const u8,
) !x509.PublicKey {
var capture_state = VerifierCaptureState{
.list = try std.ArrayListUnmanaged(ServerCertificate).initCapacity(allocator, 3),
.allocator = allocator,
.fbs = undefined,
};
defer {
for (capture_state.list.items) |cert| {
cert.public_key.deinit(allocator);
allocator.free(cert.bytes);
allocator.free(cert.signature.data);
}
capture_state.list.deinit(allocator);
}
const schema = .{
.sequence, .{
// tbsCertificate
.{ .capture, 0, .sequence },
// signatureAlgorithm
.{ .capture, 1, .sequence },
// signatureValue
.{ .capture, 2, .bit_string },
},
};
const captures = .{
&capture_state, add_server_cert,
&capture_state, set_signature_algorithm,
&capture_state, set_signature_value,
};
var bytes_read: u24 = 0;
while (bytes_read < certs_bytes) {
const cert_length = try reader.readIntBig(u24);
asn1.der.parse_schema(schema, captures, reader) catch |err| switch (err) {
error.InvalidLength,
error.InvalidTag,
error.InvalidContainerLength,
error.DoesNotMatchSchema,
=> return error.CertificateVerificationFailed,
else => |e| return e,
};
bytes_read += 3 + cert_length;
}
if (bytes_read != certs_bytes)
return error.CertificateVerificationFailed;
const chain = capture_state.list.items;
if (chain.len == 0) return error.CertificateVerificationFailed;
// Check if the hostname matches one of the leaf certificate's names
name_matched: {
if (cert_name_matches(chain[0].common_name, hostname)) {
break :name_matched;
}
var iter = chain[0].iterSAN(.dns_name);
while (iter.next()) |cert_name| {
if (cert_name_matches(cert_name, hostname)) {
break :name_matched;
}
}
return error.CertificateVerificationFailed;
}
var i: usize = 0;
while (i < chain.len - 1) : (i += 1) {
if (!try @"pcks1v1.5".certificate_verify_signature(
allocator,
chain[i].signature_algorithm,
chain[i].signature,
chain[i].bytes,
chain[i + 1].public_key,
)) {
return error.CertificateVerificationFailed;
}
}
for (chain) |cert| {
for (trusted_certificates) |trusted| {
// Try to find an exact match to a trusted certificate
if (cert.is_ca == trusted.is_ca and mem.eql(u8, cert.dn, trusted.dn) and
cert.public_key.eql(trusted.public_key))
{
const key = chain[0].public_key;
chain[0].public_key = x509.PublicKey.empty;
return key;
}
if (!trusted.is_ca)
continue;
if (try @"pcks1v1.5".certificate_verify_signature(
allocator,
cert.signature_algorithm,
cert.signature,
cert.bytes,
trusted.public_key,
)) {
const key = chain[0].public_key;
chain[0].public_key = x509.PublicKey.empty;
return key;
}
}
}
return error.CertificateVerificationFailed;
}
pub fn extract_cert_public_key(allocator: *Allocator, reader: anytype, length: usize) !x509.PublicKey {
const CaptureState = struct {
pub_key: x509.PublicKey,
allocator: *Allocator,
};
var capture_state = CaptureState{
.pub_key = undefined,
.allocator = allocator,
};
var pub_key: x509.PublicKey = undefined;
const schema = .{
.sequence, .{
// tbsCertificate
.{
.sequence,
.{
.{ .context_specific, 0 }, // version
.{.int}, // serialNumber
.{.sequence}, // signature
.{.sequence}, // issuer
.{.sequence}, // validity
.{.sequence}, // subject
.{ .capture, 0, .sequence }, // subjectPublicKeyInfo
.{ .optional, .context_specific, 1 }, // issuerUniqueID
.{ .optional, .context_specific, 2 }, // subjectUniqueID
.{ .optional, .context_specific, 3 }, // extensions
},
},
// signatureAlgorithm
.{.sequence},
// signatureValue
.{.bit_string},
},
};
const captures = .{
&capture_state, struct {
fn f(state: *CaptureState, tag: u8, _: usize, subreader: anytype) !void {
state.pub_key = x509.parse_public_key(state.allocator, subreader) catch |err| switch (err) {
error.MalformedDER => return error.ServerMalformedResponse,
else => |e| return e,
};
}
}.f,
};
const cert_length = try reader.readIntBig(u24);
asn1.der.parse_schema(schema, captures, reader) catch |err| switch (err) {
error.InvalidLength,
error.InvalidTag,
error.InvalidContainerLength,
error.DoesNotMatchSchema,
=> return error.ServerMalformedResponse,
else => |e| return e,
};
errdefer capture_state.pub_key.deinit(allocator);
try reader.skipBytes(length - cert_length - 3, .{});
return capture_state.pub_key;
}
pub const curves = struct {
pub const x25519 = struct {
pub const name = "x25519";
const tag = 0x001D;
const pub_key_len = 32;
const Keys = std.crypto.dh.X25519.KeyPair;
fn make_key_pair(rand: *std.rand.Random) callconv(.Inline) Keys {
while (true) {
var seed: [32]u8 = undefined;
rand.bytes(&seed);
return std.crypto.dh.X25519.KeyPair.create(seed) catch continue;
} else unreachable;
}
fn make_pre_master_secret(
key_pair: Keys,
pre_master_secret_buf: []u8,
server_public_key: *const [32]u8,
) callconv(.Inline) ![]const u8 {
pre_master_secret_buf[0..32].* = std.crypto.dh.X25519.scalarmult(
key_pair.secret_key,
server_public_key.*,
) catch return error.PreMasterGenerationFailed;
return pre_master_secret_buf[0..32];
}
};
pub const secp384r1 = struct {
pub const name = "secp384r1";
const tag = 0x0018;
const pub_key_len = 97;
const Keys = crypto.ecc.KeyPair(crypto.ecc.SECP384R1);
fn make_key_pair(rand: *std.rand.Random) callconv(.Inline) Keys {
var seed: [48]u8 = undefined;
rand.bytes(&seed);
return crypto.ecc.make_key_pair(crypto.ecc.SECP384R1, seed);
}
fn make_pre_master_secret(
key_pair: Keys,
pre_master_secret_buf: []u8,
server_public_key: *const [97]u8,
) callconv(.Inline) ![]const u8 {
pre_master_secret_buf[0..96].* = crypto.ecc.scalarmult(
crypto.ecc.SECP384R1,
server_public_key[1..].*,
&key_pair.secret_key,
) catch return error.PreMasterGenerationFailed;
return pre_master_secret_buf[0..48];
}
};
pub const secp256r1 = struct {
pub const name = "secp256r1";
const tag = 0x0017;
const pub_key_len = 65;
const Keys = crypto.ecc.KeyPair(crypto.ecc.SECP256R1);
fn make_key_pair(rand: *std.rand.Random) callconv(.Inline) Keys {
var seed: [32]u8 = undefined;
rand.bytes(&seed);
return crypto.ecc.make_key_pair(crypto.ecc.SECP256R1, seed);
}
fn make_pre_master_secret(
key_pair: Keys,
pre_master_secret_buf: []u8,
server_public_key: *const [65]u8,
) callconv(.Inline) ![]const u8 {
pre_master_secret_buf[0..64].* = crypto.ecc.scalarmult(
crypto.ecc.SECP256R1,
server_public_key[1..].*,
&key_pair.secret_key,
) catch return error.PreMasterGenerationFailed;
return pre_master_secret_buf[0..32];
}
};
pub const all = &[_]type{ x25519, secp384r1, secp256r1 };
fn max_pub_key_len(comptime list: anytype) usize {
var max: usize = 0;
for (list) |curve| {
if (curve.pub_key_len > max)
max = curve.pub_key_len;
}
return max;
}
fn max_pre_master_secret_len(comptime list: anytype) usize {
var max: usize = 0;
for (list) |curve| {
const curr = @typeInfo(std.meta.fieldInfo(curve.Keys, .public_key).field_type).Array.len;
if (curr > max)
max = curr;
}
return max;
}
fn KeyPair(comptime list: anytype) type {
var fields: [list.len]std.builtin.TypeInfo.UnionField = undefined;
for (list) |curve, i| {
fields[i] = .{
.name = curve.name,
.field_type = curve.Keys,
.alignment = @alignOf(curve.Keys),
};
}
return @Type(.{
.Union = .{
.layout = .Extern,
.tag_type = null,
.fields = &fields,
.decls = &[0]std.builtin.TypeInfo.Declaration{},
},
});
}
fn make_key_pair(comptime list: anytype, curve_id: u16, rand: *std.rand.Random) callconv(.Inline) KeyPair(list) {
inline for (list) |curve| {
if (curve.tag == curve_id) {
return @unionInit(KeyPair(list), curve.name, curve.make_key_pair(rand));
}
}
unreachable;
}
fn make_pre_master_secret(
comptime list: anytype,
curve_id: u16,
key_pair: KeyPair(list),
pre_master_secret_buf: *[max_pre_master_secret_len(list)]u8,
server_public_key: [max_pub_key_len(list)]u8,
) callconv(.Inline) ![]const u8 {
inline for (list) |curve| {
if (curve.tag == curve_id) {
return try curve.make_pre_master_secret(
@field(key_pair, curve.name),
pre_master_secret_buf,
server_public_key[0..curve.pub_key_len],
);
}
}
unreachable;
}
};
pub fn client_connect(
options: anytype,
hostname: []const u8,
) ClientConnectError(
options.cert_verifier,
@TypeOf(options.reader),
@TypeOf(options.writer),
@hasField(@TypeOf(options), "client_certificates"),
)!Client(
@TypeOf(options.reader),
@TypeOf(options.writer),
if (@hasField(@TypeOf(options), "ciphersuites"))
options.ciphersuites
else
ciphersuites.all,
@hasField(@TypeOf(options), "protocols"),
) {
const Options = @TypeOf(options);
if (@TypeOf(options.cert_verifier) != CertificateVerifier and
@TypeOf(options.cert_verifier) != @Type(.EnumLiteral))
@compileError("cert_verifier should be of type CertificateVerifier");
if (!@hasField(Options, "temp_allocator"))
@compileError("Option tuple is missing field 'temp_allocator'");
if (options.cert_verifier == .default) {
if (!@hasField(Options, "trusted_certificates"))
@compileError("Option tuple is missing field 'trusted_certificates' for .default cert_verifier");
}
const suites = if (!@hasField(Options, "ciphersuites"))
ciphersuites.all
else
options.ciphersuites;
if (suites.len == 0)
@compileError("Must provide at least one ciphersuite type.");
const curvelist = if (!@hasField(Options, "curves"))
curves.all
else
options.curves;
if (curvelist.len == 0)
@compileError("Must provide at least one curve type.");
const has_alpn = comptime @hasField(Options, "protocols");
var handshake_record_hash_set = HashSet{
.sha224 = Sha224.init(.{}),
.sha256 = Sha256.init(.{}),
.sha384 = Sha384.init(.{}),
.sha512 = Sha512.init(.{}),
};
const reader = options.reader;
const writer = options.writer;
const hashing_reader = make_hashing_reader(&handshake_record_hash_set, reader);
const hashing_writer = make_hashing_writer(&handshake_record_hash_set, writer);
var client_random: [32]u8 = undefined;
const rand = if (!@hasField(Options, "rand"))
std.crypto.random
else
options.rand;
rand.bytes(&client_random);
var server_random: [32]u8 = undefined;
const ciphersuite_bytes = 2 * suites.len + 2;
const alpn_bytes = if (has_alpn) blk: {
var sum: usize = 0;
for (options.protocols) |proto| {
sum += proto.len;
}
break :blk 6 + options.protocols.len + sum;
} else 0;
const curvelist_bytes = 2 * curvelist.len;
var protocol: if (has_alpn) []const u8 else void = undefined;
{
const client_hello_start = comptime blk: {
// TODO: We assume the compiler is running in a little endian system
var starting_part: [46]u8 = [_]u8{
// Record header: Handshake record type, protocol version, handshake size
0x16, 0x03, 0x01, undefined, undefined,
// Handshake message type, bytes of client hello
0x01, undefined, undefined, undefined,
// Client version (hardcoded to TLS 1.2 even for TLS 1.3)
0x03,
0x03,
} ++ ([1]u8{undefined} ** 32) ++ [_]u8{
// Session ID
0x00,
} ++ mem.toBytes(@byteSwap(u16, ciphersuite_bytes));
// using .* = mem.asBytes(...).* or mem.writeIntBig didn't work...
// Same as above, couldnt achieve this with a single buffer.
// TLS_EMPTY_RENEGOTIATION_INFO_SCSV
var ciphersuite_buf: []const u8 = &[2]u8{ 0x00, 0x0f };
for (suites) |cs, i| {
// Also check for properties of the ciphersuites here
if (cs.key_exchange != .ecdhe)
@compileError("Non ECDHE key exchange is not supported yet.");
if (cs.hash != .sha256)
@compileError("Non SHA256 hash algorithm is not supported yet.");
ciphersuite_buf = ciphersuite_buf ++ mem.toBytes(@byteSwap(u16, cs.tag));
}
var ending_part: [13]u8 = [_]u8{
// Compression methods (no compression)
0x01, 0x00,
// Extensions length
undefined, undefined,
// Extension: server name
// id, length, length of entry
0x00, 0x00,
undefined, undefined,
undefined, undefined,
// entry type, length of bytes
0x00, undefined,
undefined,
};
break :blk starting_part ++ ciphersuite_buf ++ ending_part;
};
var msg_buf = client_hello_start.ptr[0..client_hello_start.len].*;
mem.writeIntBig(u16, msg_buf[3..5], @intCast(u16, alpn_bytes + hostname.len + 0x55 + ciphersuite_bytes + curvelist_bytes));
mem.writeIntBig(u24, msg_buf[6..9], @intCast(u24, alpn_bytes + hostname.len + 0x51 + ciphersuite_bytes + curvelist_bytes));
mem.copy(u8, msg_buf[11..43], &client_random);
mem.writeIntBig(u16, msg_buf[48 + ciphersuite_bytes ..][0..2], @intCast(u16, alpn_bytes + hostname.len + 0x28 + curvelist_bytes));
mem.writeIntBig(u16, msg_buf[52 + ciphersuite_bytes ..][0..2], @intCast(u16, hostname.len + 5));
mem.writeIntBig(u16, msg_buf[54 + ciphersuite_bytes ..][0..2], @intCast(u16, hostname.len + 3));
mem.writeIntBig(u16, msg_buf[57 + ciphersuite_bytes ..][0..2], @intCast(u16, hostname.len));
try writer.writeAll(msg_buf[0..5]);
try hashing_writer.writeAll(msg_buf[5..]);
}
try hashing_writer.writeAll(hostname);
if (has_alpn) {
var msg_buf = [6]u8{ 0x00, 0x10, undefined, undefined, undefined, undefined };
mem.writeIntBig(u16, msg_buf[2..4], @intCast(u16, alpn_bytes - 4));
mem.writeIntBig(u16, msg_buf[4..6], @intCast(u16, alpn_bytes - 6));
try hashing_writer.writeAll(&msg_buf);
for (options.protocols) |proto| {
try hashing_writer.writeByte(@intCast(u8, proto.len));
try hashing_writer.writeAll(proto);
}
}
// Extension: supported groups
{
var msg_buf = [6]u8{
0x00, 0x0A,
undefined, undefined,
undefined, undefined,
};
mem.writeIntBig(u16, msg_buf[2..4], @intCast(u16, curvelist_bytes + 2));
mem.writeIntBig(u16, msg_buf[4..6], @intCast(u16, curvelist_bytes));
try hashing_writer.writeAll(&msg_buf);
inline for (curvelist) |curve| {
try hashing_writer.writeIntBig(u16, curve.tag);
}
}
try hashing_writer.writeAll(&[25]u8{
// Extension: EC point formats => uncompressed point format
0x00, 0x0B, 0x00, 0x02, 0x01, 0x00,
// Extension: Signature algorithms
// RSA/PKCS1/SHA256, RSA/PKCS1/SHA512
0x00, 0x0D, 0x00, 0x06, 0x00, 0x04,
0x04, 0x01, 0x06, 0x01,
// Extension: Renegotiation Info => new connection
0xFF, 0x01,
0x00, 0x01, 0x00,
// Extension: SCT (signed certificate timestamp)
0x00, 0x12, 0x00,
0x00,
});
// Read server hello
var ciphersuite: u16 = undefined;
{
const length = try handshake_record_length(reader);
if (length < 44)
return error.ServerMalformedResponse;
{
var hs_hdr_and_server_ver: [6]u8 = undefined;
try hashing_reader.readNoEof(&hs_hdr_and_server_ver);
if (hs_hdr_and_server_ver[0] != 0x02)
return error.ServerMalformedResponse;
if (!mem.eql(u8, hs_hdr_and_server_ver[4..6], "\x03\x03"))
return error.ServerInvalidVersion;
}
try hashing_reader.readNoEof(&server_random);
// Just skip the session id for now
const sess_id_len = try hashing_reader.readByte();
if (sess_id_len != 0)
try hashing_reader.skipBytes(sess_id_len, .{});
{
ciphersuite = try hashing_reader.readIntBig(u16);
var found = false;
inline for (suites) |cs| {
if (ciphersuite == cs.tag) {
found = true;
// TODO This segfaults stage1
// break;
}
}
if (!found)
return error.ServerInvalidCipherSuite;
}
// Compression method
if ((try hashing_reader.readByte()) != 0x00)
return error.ServerInvalidCompressionMethod;
const exts_length = try hashing_reader.readIntBig(u16);
var ext_byte_idx: usize = 0;
while (ext_byte_idx < exts_length) {
var ext_tag: [2]u8 = undefined;
try hashing_reader.readNoEof(&ext_tag);
const ext_len = try hashing_reader.readIntBig(u16);
ext_byte_idx += 4 + ext_len;
if (ext_tag[0] == 0xFF and ext_tag[1] == 0x01) {
// Renegotiation info
const renegotiation_info = try hashing_reader.readByte();
if (ext_len != 0x01 or renegotiation_info != 0x00)
return error.ServerInvalidRenegotiationData;
} else if (ext_tag[0] == 0x00 and ext_tag[1] == 0x00) {
// Server name
if (ext_len != 0)
try hashing_reader.skipBytes(ext_len, .{});
} else if (ext_tag[0] == 0x00 and ext_tag[1] == 0x0B) {
const format_count = try hashing_reader.readByte();
var found_uncompressed = false;
var i: usize = 0;
while (i < format_count) : (i += 1) {
const byte = try hashing_reader.readByte();
if (byte == 0x0)
found_uncompressed = true;
}
if (!found_uncompressed)
return error.ServerInvalidECPointCompression;
} else if (has_alpn and ext_tag[0] == 0x00 and ext_tag[1] == 0x10) {
const alpn_ext_len = try hashing_reader.readIntBig(u16);
if (alpn_ext_len != ext_len - 2)
return error.ServerMalformedResponse;
const str_len = try hashing_reader.readByte();
var buf: [256]u8 = undefined;
try hashing_reader.readNoEof(buf[0..str_len]);
const found = for (options.protocols) |proto| {
if (mem.eql(u8, proto, buf[0..str_len])) {
protocol = proto;
break true;
}
} else false;
if (!found)
return error.ServerInvalidProtocol;
try hashing_reader.skipBytes(alpn_ext_len - str_len - 1, .{});
} else return error.ServerInvalidExtension;
}
if (ext_byte_idx != exts_length)
return error.ServerMalformedResponse;
}
// Read server certificates
var certificate_public_key: x509.PublicKey = undefined;
{
const length = try handshake_record_length(reader);
{
var handshake_header: [4]u8 = undefined;
try hashing_reader.readNoEof(&handshake_header);
if (handshake_header[0] != 0x0b)
return error.ServerMalformedResponse;
}
const certs_length = try hashing_reader.readIntBig(u24);
const cert_verifier: CertificateVerifier = options.cert_verifier;
switch (cert_verifier) {
.none => certificate_public_key = try extract_cert_public_key(
options.temp_allocator,
hashing_reader,
certs_length,
),
.function => |f| {
var reader_state = CertificateReaderState(@TypeOf(hashing_reader)){
.reader = hashing_reader,
.length = certs_length,
};
var cert_reader = CertificateReader(@TypeOf(hashing_reader)){ .context = &reader_state };
certificate_public_key = try f(cert_reader);
try hashing_reader.skipBytes(reader_state.length - reader_state.idx, .{});
},
.default => certificate_public_key = try default_cert_verifier(
options.temp_allocator,
hashing_reader,
certs_length,
options.trusted_certificates,
hostname,
),
}
}
errdefer certificate_public_key.deinit(options.temp_allocator);
// Read server ephemeral public key
var server_public_key_buf: [curves.max_pub_key_len(curvelist)]u8 = undefined;
var curve_id: u16 = undefined;
var curve_id_buf: [3]u8 = undefined;
var pub_key_len: u8 = undefined;
{
const length = try handshake_record_length(reader);
{
var handshake_header: [4]u8 = undefined;
try hashing_reader.readNoEof(&handshake_header);
if (handshake_header[0] != 0x0c)
return error.ServerMalformedResponse;
try hashing_reader.readNoEof(&curve_id_buf);
if (curve_id_buf[0] != 0x03)
return error.ServerMalformedResponse;
curve_id = mem.readIntBig(u16, curve_id_buf[1..]);
var found = false;
inline for (curvelist) |curve| {
if (curve.tag == curve_id) {
found = true;
// @TODO This break segfaults stage1
// break;
}
}
if (!found)
return error.ServerInvalidCurve;
}
pub_key_len = try hashing_reader.readByte();
inline for (curvelist) |curve| {
if (curve.tag == curve_id) {
if (curve.pub_key_len != pub_key_len)
return error.ServerMalformedResponse;
// @TODO This break segfaults stage1
// break;
}
}
try hashing_reader.readNoEof(server_public_key_buf[0..pub_key_len]);
if (curve_id != curves.x25519.tag) {
if (server_public_key_buf[0] != 0x04)
return error.ServerMalformedResponse;
}
// Signed public key
const signature_id = try hashing_reader.readIntBig(u16);
const signature_len = try hashing_reader.readIntBig(u16);
var hash_buf: [64]u8 = undefined;
var hash: []const u8 = undefined;
const signature_algoritm: x509.Certificate.SignatureAlgorithm = switch (signature_id) {
// TODO: More
// RSA/PKCS1/SHA256
0x0401 => block: {
var sha256 = Sha256.init(.{});
sha256.update(&client_random);
sha256.update(&server_random);
sha256.update(&curve_id_buf);
sha256.update(&[1]u8{pub_key_len});
sha256.update(server_public_key_buf[0..pub_key_len]);
sha256.final(hash_buf[0..32]);
hash = hash_buf[0..32];
break :block .{ .signature = .rsa, .hash = .sha256 };
},
// RSA/PKCS1/SHA512
0x0601 => block: {
var sha512 = Sha512.init(.{});
sha512.update(&client_random);
sha512.update(&server_random);
sha512.update(&curve_id_buf);
sha512.update(&[1]u8{pub_key_len});
sha512.update(server_public_key_buf[0..pub_key_len]);
sha512.final(hash_buf[0..64]);
hash = hash_buf[0..64];
break :block .{ .signature = .rsa, .hash = .sha512 };
},
else => return error.ServerInvalidSignatureAlgorithm,
};
const signature_bytes = try options.temp_allocator.alloc(u8, signature_len);
defer options.temp_allocator.free(signature_bytes);
try hashing_reader.readNoEof(signature_bytes);
if (!try @"pcks1v1.5".verify_signature(
options.temp_allocator,
signature_algoritm,
.{ .data = signature_bytes, .bit_len = signature_len * 8 },
hash,
certificate_public_key,
))
return error.ServerInvalidSignature;
certificate_public_key.deinit(options.temp_allocator);
certificate_public_key = x509.PublicKey.empty;
}
var client_certificate: ?*const x509.ClientCertificateChain = null;
{
const length = try handshake_record_length(reader);
const record_type = try hashing_reader.readByte();
if (record_type == 14) {
// Server hello done
const is_bytes = try hashing_reader.isBytes("\x00\x00\x00");
if (length != 4 or !is_bytes)
return error.ServerMalformedResponse;
} else if (record_type == 13) {
// Certificate request
const certificate_request_bytes = try hashing_reader.readIntBig(u24);
if (length != certificate_request_bytes + 8)
return error.ServerMalformedResponse;
// TODO: For now, we are ignoring the certificate types, as they have been somewhat
// superceded by the supported_signature_algorithms field
const certificate_types_bytes = try hashing_reader.readByte();
try hashing_reader.skipBytes(certificate_types_bytes, .{});
var chosen_client_certificates = std.ArrayListUnmanaged(*const x509.ClientCertificateChain){};
defer chosen_client_certificates.deinit(options.temp_allocator);
const signature_algorithms_bytes = try hashing_reader.readIntBig(u16);
if (@hasField(Options, "client_certificates")) {
var i: usize = 0;
while (i < signature_algorithms_bytes / 2) : (i += 1) {
var signature_algorithm: [2]u8 = undefined;
try hashing_reader.readNoEof(&signature_algorithm);
for (options.client_certificates) |*cert_chain| {
if (@enumToInt(cert_chain.signature_algorithm.hash) == signature_algorithm[0] and
@enumToInt(cert_chain.signature_algorithm.signature) == signature_algorithm[1])
{
try chosen_client_certificates.append(options.temp_allocator, cert_chain);
}
}
}
} else {
try hashing_reader.skipBytes(signature_algorithms_bytes, .{});
}
const certificate_authorities_bytes = try hashing_reader.readIntBig(u16);
if (chosen_client_certificates.items.len == 0) {
try hashing_reader.skipBytes(certificate_authorities_bytes, .{});
} else {
const dns_buf = try options.temp_allocator.alloc(u8, certificate_authorities_bytes);
defer options.temp_allocator.free(dns_buf);
try hashing_reader.readNoEof(dns_buf);
var fbs = std.io.fixedBufferStream(dns_buf[2..]);
var fbs_reader = fbs.reader();
while (fbs.pos < fbs.buffer.len) {
const start_idx = fbs.pos;
const seq_tag = fbs_reader.readByte() catch return error.ServerMalformedResponse;
if (seq_tag != 0x30)
return error.ServerMalformedResponse;
const seq_length = asn1.der.parse_length(fbs_reader) catch return error.ServerMalformedResponse;
fbs_reader.skipBytes(seq_length, .{}) catch return error.ServerMalformedResponse;
var i: usize = 0;
while (i < chosen_client_certificates.items.len) {
const cert = chosen_client_certificates.items[i];
var cert_idx: usize = 0;
while (cert_idx < cert.cert_len) : (cert_idx += 1) {
if (mem.eql(u8, cert.cert_issuer_dns[cert_idx], fbs.buffer[start_idx..fbs.pos]))
break;
} else {
_ = chosen_client_certificates.swapRemove(i);
continue;
}
i += 1;
}
}
if (fbs.pos != fbs.buffer.len)
return error.ServerMalformedResponse;
}
// Server hello done
// @TODO Will this always be in the same record as the certificate request?
const hello_record_type = try hashing_reader.readByte();
if (hello_record_type != 14)
return error.ServerMalformedResponse;
const is_bytes = try hashing_reader.isBytes("\x00\x00\x00");
if (!is_bytes)
return error.ServerMalformedResponse;
// Send the client certificate message
try writer.writeAll(&[3]u8{ 0x16, 0x03, 0x03 });
if (chosen_client_certificates.items.len != 0) {
client_certificate = chosen_client_certificates.items[0];
const certificate_count = client_certificate.?.cert_len;
// 7 bytes for the record type tag (1), record length (3), certificate list length (3)
// 3 bytes for each certificate length
var total_len: u24 = 7 + 3 * @intCast(u24, certificate_count);
var i: usize = 0;
while (i < certificate_count) : (i += 1) {
total_len += @intCast(u24, client_certificate.?.raw_certs[i].len);
}
try writer.writeIntBig(u16, @intCast(u16, total_len));
var msg_buf: [7]u8 = [1]u8{0x0b} ++ ([1]u8{undefined} ** 6);
mem.writeIntBig(u24, msg_buf[1..4], total_len - 4);
mem.writeIntBig(u24, msg_buf[4..7], total_len - 7);
try hashing_writer.writeAll(&msg_buf);
i = 0;
while (i < certificate_count) : (i += 1) {
try hashing_writer.writeIntBig(u24, @intCast(u24, client_certificate.?.raw_certs[i].len));
try hashing_writer.writeAll(client_certificate.?.raw_certs[i]);
}
} else {
try writer.writeIntBig(u16, 7);
try hashing_writer.writeAll(&[7]u8{ 0x0b, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00 });
}
} else return error.ServerMalformedResponse;
}
// Generate keys for the session
const client_key_pair = curves.make_key_pair(curvelist, curve_id, rand);
// Client key exchange
try writer.writeAll(&[3]u8{ 0x16, 0x03, 0x03 });
try writer.writeIntBig(u16, pub_key_len + 5);
try hashing_writer.writeAll(&[5]u8{ 0x10, 0x00, 0x00, pub_key_len + 1, pub_key_len });
inline for (curvelist) |curve| {
if (curve.tag == curve_id) {
const actual_len = @typeInfo(std.meta.fieldInfo(curve.Keys, .public_key).field_type).Array.len;
if (pub_key_len == actual_len + 1) {
try hashing_writer.writeByte(0x04);
} else {
std.debug.assert(pub_key_len == actual_len);
}
try hashing_writer.writeAll(&@field(client_key_pair, curve.name).public_key);
break;
}
}
// If we have a client certificate, send a certificate verify message
if (@hasField(Options, "client_certificates")) {
if (client_certificate) |client_cert| {
var current_hash_buf: [64]u8 = undefined;
var current_hash: []const u8 = undefined;
const hash_algo = client_cert.signature_algorithm.hash;
// TODO: Making this a switch statement kills stage1
if (hash_algo == .none or hash_algo == .md5 or hash_algo == .sha1)
return error.ClientCertificateVerifyFailed
else if (hash_algo == .sha224) {
var hash_copy = handshake_record_hash_set.sha224;
hash_copy.final(current_hash_buf[0..28]);
current_hash = current_hash_buf[0..28];
} else if (hash_algo == .sha256) {
var hash_copy = handshake_record_hash_set.sha256;
hash_copy.final(current_hash_buf[0..32]);
current_hash = current_hash_buf[0..32];
} else if (hash_algo == .sha384) {
var hash_copy = handshake_record_hash_set.sha384;
hash_copy.final(current_hash_buf[0..48]);
current_hash = current_hash_buf[0..48];
} else {
var hash_copy = handshake_record_hash_set.sha512;
hash_copy.final(¤t_hash_buf);
current_hash = ¤t_hash_buf;
}
const signed = (try @"pcks1v1.5".sign(
options.temp_allocator,
client_cert.signature_algorithm,
current_hash,
client_cert.private_key,
)) orelse return error.ClientCertificateVerifyFailed;
defer options.temp_allocator.free(signed);
try writer.writeAll(&[3]u8{ 0x16, 0x03, 0x03 });
try writer.writeIntBig(u16, @intCast(u16, signed.len + 8));
var msg_buf: [8]u8 = [1]u8{0x0F} ++ ([1]u8{undefined} ** 7);
mem.writeIntBig(u24, msg_buf[1..4], @intCast(u24, signed.len + 4));
msg_buf[4] = @enumToInt(client_cert.signature_algorithm.hash);
msg_buf[5] = @enumToInt(client_cert.signature_algorithm.signature);
mem.writeIntBig(u16, msg_buf[6..8], @intCast(u16, signed.len));
try hashing_writer.writeAll(&msg_buf);
try hashing_writer.writeAll(signed);
}
}
// Client encryption keys calculation for ECDHE_RSA cipher suites with SHA256 hash
var master_secret: [48]u8 = undefined;
var key_data: ciphers.KeyData(suites) = undefined;
{
var pre_master_secret_buf: [curves.max_pre_master_secret_len(curvelist)]u8 = undefined;
const pre_master_secret = try curves.make_pre_master_secret(
curvelist,
curve_id,
client_key_pair,
&pre_master_secret_buf,
server_public_key_buf,
);
var seed: [77]u8 = undefined;
seed[0..13].* = "master secret".*;
seed[13..45].* = client_random;
seed[45..77].* = server_random;
var a1: [32 + seed.len]u8 = undefined;
Hmac256.create(a1[0..32], &seed, pre_master_secret);
var a2: [32 + seed.len]u8 = undefined;
Hmac256.create(a2[0..32], a1[0..32], pre_master_secret);
a1[32..].* = seed;
a2[32..].* = seed;
var p1: [32]u8 = undefined;
Hmac256.create(&p1, &a1, pre_master_secret);
var p2: [32]u8 = undefined;
Hmac256.create(&p2, &a2, pre_master_secret);
master_secret[0..32].* = p1;
master_secret[32..48].* = p2[0..16].*;
// Key expansion
seed[0..13].* = "key expansion".*;
seed[13..45].* = server_random;
seed[45..77].* = client_random;
a1[32..].* = seed;
a2[32..].* = seed;
const KeyExpansionState = struct {
seed: *const [77]u8,
a1: *[32 + seed.len]u8,
a2: *[32 + seed.len]u8,
master_secret: *const [48]u8,
};
const next_32_bytes = struct {
fn f(
state: *KeyExpansionState,
comptime chunk_idx: comptime_int,
chunk: *[32]u8,
) callconv(.Inline) void {
if (chunk_idx == 0) {
Hmac256.create(state.a1[0..32], state.seed, state.master_secret);
Hmac256.create(chunk, state.a1, state.master_secret);
} else if (chunk_idx % 2 == 1) {
Hmac256.create(state.a2[0..32], state.a1[0..32], state.master_secret);
Hmac256.create(chunk, state.a2, state.master_secret);
} else {
Hmac256.create(state.a1[0..32], state.a2[0..32], state.master_secret);
Hmac256.create(chunk, state.a1, state.master_secret);
}
}
}.f;
var state = KeyExpansionState{
.seed = &seed,
.a1 = &a1,
.a2 = &a2,
.master_secret = &master_secret,
};
key_data = ciphers.key_expansion(suites, ciphersuite, &state, next_32_bytes);
}
// Client change cipher spec and client handshake finished
{
try writer.writeAll(&[6]u8{
// Client change cipher spec
0x14, 0x03, 0x03,
0x00, 0x01, 0x01,
});
// The message we need to encrypt is the following:
// 0x14 0x00 0x00 0x0c
// <12 bytes of verify_data>
// seed = "client finished" + SHA256(all handshake messages)
// a1 = HMAC-SHA256(key=MasterSecret, data=seed)
// p1 = HMAC-SHA256(key=MasterSecret, data=a1 + seed)
// verify_data = p1[0..12]
var verify_message: [16]u8 = undefined;
verify_message[0..4].* = "\x14\x00\x00\x0C".*;
{
var seed: [47]u8 = undefined;
seed[0..15].* = "client finished".*;
// We still need to update the hash one time, so we copy
// to get the current digest here.
var hash_copy = handshake_record_hash_set.sha256;
hash_copy.final(seed[15..47]);
var a1: [32 + seed.len]u8 = undefined;
Hmac256.create(a1[0..32], &seed, &master_secret);
a1[32..].* = seed;
var p1: [32]u8 = undefined;
Hmac256.create(&p1, &a1, &master_secret);
verify_message[4..16].* = p1[0..12].*;
}
handshake_record_hash_set.update(&verify_message);
inline for (suites) |cs| {
if (cs.tag == ciphersuite) {
try cs.raw_write(
256,
rand,
&key_data,
writer,
[3]u8{ 0x16, 0x03, 0x03 },
0,
&verify_message,
);
}
}
}
// Server change cipher spec
{
const length = try record_length(0x14, reader);
const next_byte = try reader.readByte();
if (length != 1 or next_byte != 0x01)
return error.ServerMalformedResponse;
}
// Server handshake finished
{
const length = try handshake_record_length(reader);
var verify_message: [16]u8 = undefined;
verify_message[0..4].* = "\x14\x00\x00\x0C".*;
{
var seed: [47]u8 = undefined;
seed[0..15].* = "server finished".*;
handshake_record_hash_set.sha256.final(seed[15..47]);
var a1: [32 + seed.len]u8 = undefined;
Hmac256.create(a1[0..32], &seed, &master_secret);
a1[32..].* = seed;
var p1: [32]u8 = undefined;
Hmac256.create(&p1, &a1, &master_secret);
verify_message[4..16].* = p1[0..12].*;
}
inline for (suites) |cs| {
if (cs.tag == ciphersuite) {
if (!try cs.check_verify_message(&key_data, length, reader, verify_message))
return error.ServerInvalidVerifyData;
}
}
}
return Client(@TypeOf(reader), @TypeOf(writer), suites, has_alpn){
.ciphersuite = ciphersuite,
.key_data = key_data,
.state = ciphers.client_state_default(suites, ciphersuite),
.rand = rand,
.parent_reader = reader,
.parent_writer = writer,
.protocol = protocol,
};
}
pub fn Client(
comptime _Reader: type,
comptime _Writer: type,
comptime _ciphersuites: anytype,
comptime has_protocol: bool,
) type {
return struct {
const ReaderError = _Reader.Error || ServerAlert || error{ ServerMalformedResponse, ServerInvalidVersion };
pub const Reader = std.io.Reader(*@This(), ReaderError, read);
pub const Writer = std.io.Writer(*@This(), _Writer.Error, write);
ciphersuite: u16,
client_seq: u64 = 1,
server_seq: u64 = 1,
key_data: ciphers.KeyData(_ciphersuites),
state: ciphers.ClientState(_ciphersuites),
rand: *std.rand.Random,
parent_reader: _Reader,
parent_writer: _Writer,
protocol: if (has_protocol) []const u8 else void,
pub fn reader(self: *@This()) Reader {
return .{ .context = self };
}
pub fn writer(self: *@This()) Writer {
return .{ .context = self };
}
pub fn read(self: *@This(), buffer: []u8) ReaderError!usize {
inline for (_ciphersuites) |cs| {
if (self.ciphersuite == cs.tag) {
// @TODO Make this buffer size configurable
return try cs.read(
1024,
&@field(self.state, cs.name),
&self.key_data,
self.parent_reader,
&self.server_seq,
buffer,
);
}
}
unreachable;
}
pub fn write(self: *@This(), buffer: []const u8) _Writer.Error!usize {
if (buffer.len == 0) return 0;
inline for (_ciphersuites) |cs| {
if (self.ciphersuite == cs.tag) {
// @TODO Make this buffer size configurable
const curr_bytes = @truncate(u16, std.math.min(buffer.len, 1024));
try cs.raw_write(
1024,
self.rand,
&self.key_data,
self.parent_writer,
[3]u8{ 0x17, 0x03, 0x03 },
self.client_seq,
buffer[0..curr_bytes],
);
self.client_seq += 1;
return curr_bytes;
}
}
unreachable;
}
pub fn close_notify(self: *@This()) !void {
inline for (_ciphersuites) |cs| {
if (self.ciphersuite == cs.tag) {
try cs.raw_write(
1024,
self.rand,
&self.key_data,
self.parent_writer,
[3]u8{ 0x15, 0x03, 0x03 },
self.client_seq,
"\x01\x00",
);
self.client_seq += 1;
return;
}
}
unreachable;
}
};
}
test "HTTPS request on wikipedia main page" {
const sock = try std.net.tcpConnectToHost(std.testing.allocator, "en.wikipedia.org", 443);
defer sock.close();
var fbs = std.io.fixedBufferStream(@embedFile("../test/DigiCertHighAssuranceEVRootCA.crt.pem"));
var trusted_chain = try x509.CertificateChain.from_pem(std.testing.allocator, fbs.reader());
defer trusted_chain.deinit();
// @TODO Remove this once std.crypto.rand works in .evented mode
var rand = blk: {
var seed: [std.rand.DefaultCsprng.secret_seed_length]u8 = undefined;
try std.os.getrandom(&seed);
break :blk &std.rand.DefaultCsprng.init(seed).random;
};
var client = try client_connect(.{
.rand = rand,
.reader = sock.reader(),
.writer = sock.writer(),
.cert_verifier = .default,
.temp_allocator = std.testing.allocator,
.trusted_certificates = trusted_chain.data.items,
.ciphersuites = .{ciphersuites.ECDHE_RSA_Chacha20_Poly1305},
.protocols = &[_][]const u8{"http/1.1"},
.curves = .{curves.x25519},
}, "en.wikipedia.org");
defer client.close_notify() catch {};
std.testing.expectEqualStrings("http/1.1", client.protocol);
try client.writer().writeAll("GET /wiki/Main_Page HTTP/1.1\r\nHost: en.wikipedia.org\r\nAccept: */*\r\n\r\n");
{
const header = try client.reader().readUntilDelimiterAlloc(std.testing.allocator, '\n', std.math.maxInt(usize));
std.testing.expectEqualStrings("HTTP/1.1 200 OK", mem.trim(u8, header, &std.ascii.spaces));
std.testing.allocator.free(header);
}
// Skip the rest of the headers expect for Content-Length
var content_length: ?usize = null;
hdr_loop: while (true) {
const header = try client.reader().readUntilDelimiterAlloc(std.testing.allocator, '\n', std.math.maxInt(usize));
defer std.testing.allocator.free(header);
const hdr_contents = mem.trim(u8, header, &std.ascii.spaces);
if (hdr_contents.len == 0) {
break :hdr_loop;
}
if (mem.startsWith(u8, hdr_contents, "Content-Length: ")) {
content_length = try std.fmt.parseUnsigned(usize, hdr_contents[16..], 10);
}
}
std.testing.expect(content_length != null);
const html_contents = try std.testing.allocator.alloc(u8, content_length.?);
defer std.testing.allocator.free(html_contents);
try client.reader().readNoEof(html_contents);
}
test "HTTPS request on wikipedia alternate name" {
const sock = try std.net.tcpConnectToHost(std.testing.allocator, "en.m.wikipedia.org", 443);
defer sock.close();
var fbs = std.io.fixedBufferStream(@embedFile("../test/DigiCertHighAssuranceEVRootCA.crt.pem"));
var trusted_chain = try x509.CertificateChain.from_pem(std.testing.allocator, fbs.reader());
defer trusted_chain.deinit();
// @TODO Remove this once std.crypto.rand works in .evented mode
var rand = blk: {
var seed: [std.rand.DefaultCsprng.secret_seed_length]u8 = undefined;
try std.os.getrandom(&seed);
break :blk &std.rand.DefaultCsprng.init(seed).random;
};
var client = try client_connect(.{
.rand = rand,
.reader = sock.reader(),
.writer = sock.writer(),
.cert_verifier = .default,
.temp_allocator = std.testing.allocator,
.trusted_certificates = trusted_chain.data.items,
.ciphersuites = .{ciphersuites.ECDHE_RSA_Chacha20_Poly1305},
.protocols = &[_][]const u8{"http/1.1"},
.curves = .{curves.x25519},
}, "en.m.wikipedia.org");
defer client.close_notify() catch {};
}
test "HTTPS request on twitch oath2 endpoint" {
const sock = try std.net.tcpConnectToHost(std.testing.allocator, "id.twitch.tv", 443);
defer sock.close();
// @TODO Remove this once std.crypto.rand works in .evented mode
var rand = blk: {
var seed: [std.rand.DefaultCsprng.secret_seed_length]u8 = undefined;
try std.os.getrandom(&seed);
break :blk &std.rand.DefaultCsprng.init(seed).random;
};
var client = try client_connect(.{
.rand = rand,
.temp_allocator = std.testing.allocator,
.reader = sock.reader(),
.writer = sock.writer(),
.cert_verifier = .none,
.protocols = &[_][]const u8{"http/1.1"},
}, "id.twitch.tv");
std.testing.expectEqualStrings("http/1.1", client.protocol);
defer client.close_notify() catch {};
try client.writer().writeAll("GET /oauth2/validate HTTP/1.1\r\nHost: id.twitch.tv\r\nAccept: */*\r\n\r\n");
var content_length: ?usize = null;
hdr_loop: while (true) {
const header = try client.reader().readUntilDelimiterAlloc(std.testing.allocator, '\n', std.math.maxInt(usize));
defer std.testing.allocator.free(header);
const hdr_contents = mem.trim(u8, header, &std.ascii.spaces);
if (hdr_contents.len == 0) {
break :hdr_loop;
}
if (mem.startsWith(u8, hdr_contents, "Content-Length: ")) {
content_length = try std.fmt.parseUnsigned(usize, hdr_contents[16..], 10);
}
}
std.testing.expect(content_length != null);
const html_contents = try std.testing.allocator.alloc(u8, content_length.?);
defer std.testing.allocator.free(html_contents);
try client.reader().readNoEof(html_contents);
}
test "Connecting to expired.badssl.com returns an error" {
const sock = try std.net.tcpConnectToHost(std.testing.allocator, "expired.badssl.com", 443);
defer sock.close();
var fbs = std.io.fixedBufferStream(@embedFile("../test/DigiCertGlobalRootCA.crt.pem"));
var trusted_chain = try x509.CertificateChain.from_pem(std.testing.allocator, fbs.reader());
defer trusted_chain.deinit();
// @TODO Remove this once std.crypto.rand works in .evented mode
var rand = blk: {
var seed: [std.rand.DefaultCsprng.secret_seed_length]u8 = undefined;
try std.os.getrandom(&seed);
break :blk &std.rand.DefaultCsprng.init(seed).random;
};
std.testing.expectError(error.CertificateVerificationFailed, client_connect(.{
.rand = rand,
.reader = sock.reader(),
.writer = sock.writer(),
.cert_verifier = .default,
.temp_allocator = std.testing.allocator,
.trusted_certificates = trusted_chain.data.items,
}, "expired.badssl.com"));
}
test "Connecting to wrong.host.badssl.com returns an error" {
const sock = try std.net.tcpConnectToHost(std.testing.allocator, "wrong.host.badssl.com", 443);
defer sock.close();
var fbs = std.io.fixedBufferStream(@embedFile("../test/DigiCertGlobalRootCA.crt.pem"));
var trusted_chain = try x509.CertificateChain.from_pem(std.testing.allocator, fbs.reader());
defer trusted_chain.deinit();
// @TODO Remove this once std.crypto.rand works in .evented mode
var rand = blk: {
var seed: [std.rand.DefaultCsprng.secret_seed_length]u8 = undefined;
try std.os.getrandom(&seed);
break :blk &std.rand.DefaultCsprng.init(seed).random;
};
std.testing.expectError(error.CertificateVerificationFailed, client_connect(.{
.rand = rand,
.reader = sock.reader(),
.writer = sock.writer(),
.cert_verifier = .default,
.temp_allocator = std.testing.allocator,
.trusted_certificates = trusted_chain.data.items,
}, "wrong.host.badssl.com"));
}
test "Connecting to self-signed.badssl.com returns an error" {
const sock = try std.net.tcpConnectToHost(std.testing.allocator, "self-signed.badssl.com", 443);
defer sock.close();
var fbs = std.io.fixedBufferStream(@embedFile("../test/DigiCertGlobalRootCA.crt.pem"));
var trusted_chain = try x509.CertificateChain.from_pem(std.testing.allocator, fbs.reader());
defer trusted_chain.deinit();
// @TODO Remove this once std.crypto.rand works in .evented mode
var rand = blk: {
var seed: [std.rand.DefaultCsprng.secret_seed_length]u8 = undefined;
try std.os.getrandom(&seed);
break :blk &std.rand.DefaultCsprng.init(seed).random;
};
std.testing.expectError(error.CertificateVerificationFailed, client_connect(.{
.rand = rand,
.reader = sock.reader(),
.writer = sock.writer(),
.cert_verifier = .default,
.temp_allocator = std.testing.allocator,
.trusted_certificates = trusted_chain.data.items,
}, "self-signed.badssl.com"));
}
test "Connecting to client.badssl.com with a client certificate" {
const sock = try std.net.tcpConnectToHost(std.testing.allocator, "client.badssl.com", 443);
defer sock.close();
var fbs = std.io.fixedBufferStream(@embedFile("../test/DigiCertGlobalRootCA.crt.pem"));
var trusted_chain = try x509.CertificateChain.from_pem(std.testing.allocator, fbs.reader());
defer trusted_chain.deinit();
// @TODO Remove this once std.crypto.rand works in .evented mode
var rand = blk: {
var seed: [std.rand.DefaultCsprng.secret_seed_length]u8 = undefined;
try std.os.getrandom(&seed);
break :blk &std.rand.DefaultCsprng.init(seed).random;
};
var client_cert = try x509.ClientCertificateChain.from_pem(
std.testing.allocator,
std.io.fixedBufferStream(@embedFile("../test/badssl.com-client.pem")).reader(),
);
defer client_cert.deinit(std.testing.allocator);
var client = try client_connect(.{
.rand = rand,
.reader = sock.reader(),
.writer = sock.writer(),
.cert_verifier = .default,
.temp_allocator = std.testing.allocator,
.trusted_certificates = trusted_chain.data.items,
.client_certificates = &[1]x509.ClientCertificateChain{client_cert},
}, "client.badssl.com");
defer client.close_notify() catch {};
try client.writer().writeAll("GET / HTTP/1.1\r\nHost: client.badssl.com\r\nAccept: */*\r\n\r\n");
const line = try client.reader().readUntilDelimiterAlloc(std.testing.allocator, '\n', std.math.maxInt(usize));
defer std.testing.allocator.free(line);
std.testing.expectEqualStrings("HTTP/1.1 200 OK\r", line);
}
|
src/main.zig
|
pub const MAX_ERROR_MESSAGE_CHARS = @as(u32, 512);
pub const CastingSourceInfo_Property_PreferredSourceUriScheme = "PreferredSourceUriScheme";
pub const CastingSourceInfo_Property_CastingTypes = "CastingTypes";
pub const CastingSourceInfo_Property_ProtectedMedia = "ProtectedMedia";
//--------------------------------------------------------------------------------
// Section: Types (59)
//--------------------------------------------------------------------------------
pub const EventRegistrationToken = extern struct {
value: i64,
};
// TODO: this type has a FreeFunc 'WindowsDeleteString', what can Zig do with this information?
pub const HSTRING = *opaque{};
pub const HSTRING_BUFFER = *opaque{};
pub const ROPARAMIIDHANDLE = isize;
pub const APARTMENT_SHUTDOWN_REGISTRATION_COOKIE = isize;
pub const ACTIVATIONTYPE = enum(i32) {
UNCATEGORIZED = 0,
FROM_MONIKER = 1,
FROM_DATA = 2,
FROM_STORAGE = 4,
FROM_STREAM = 8,
FROM_FILE = 16,
};
pub const ACTIVATIONTYPE_UNCATEGORIZED = ACTIVATIONTYPE.UNCATEGORIZED;
pub const ACTIVATIONTYPE_FROM_MONIKER = ACTIVATIONTYPE.FROM_MONIKER;
pub const ACTIVATIONTYPE_FROM_DATA = ACTIVATIONTYPE.FROM_DATA;
pub const ACTIVATIONTYPE_FROM_STORAGE = ACTIVATIONTYPE.FROM_STORAGE;
pub const ACTIVATIONTYPE_FROM_STREAM = ACTIVATIONTYPE.FROM_STREAM;
pub const ACTIVATIONTYPE_FROM_FILE = ACTIVATIONTYPE.FROM_FILE;
// TODO: this type is limited to platform 'windows8.1'
const IID_IAgileReference_Value = Guid.initString("c03f6a43-65a4-9818-987e-e0b810d2a6f2");
pub const IID_IAgileReference = &IID_IAgileReference_Value;
pub const IAgileReference = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Resolve: fn(
self: *const IAgileReference,
riid: ?*const Guid,
ppvObjectReference: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAgileReference_Resolve(self: *const T, riid: ?*const Guid, ppvObjectReference: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IAgileReference.VTable, self.vtable).Resolve(@ptrCast(*const IAgileReference, self), riid, ppvObjectReference);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows8.0'
const IID_IApartmentShutdown_Value = Guid.initString("a2f05a09-27a2-42b5-bc0e-ac163ef49d9b");
pub const IID_IApartmentShutdown = &IID_IApartmentShutdown_Value;
pub const IApartmentShutdown = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
OnUninitialize: fn(
self: *const IApartmentShutdown,
ui64ApartmentIdentifier: u64,
) callconv(@import("std").os.windows.WINAPI) void,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IApartmentShutdown_OnUninitialize(self: *const T, ui64ApartmentIdentifier: u64) callconv(.Inline) void {
return @ptrCast(*const IApartmentShutdown.VTable, self.vtable).OnUninitialize(@ptrCast(*const IApartmentShutdown, self), ui64ApartmentIdentifier);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const ServerInformation = extern struct {
dwServerPid: u32,
dwServerTid: u32,
ui64ServerAddress: u64,
};
pub const AgileReferenceOptions = enum(i32) {
FAULT = 0,
LAYEDMARSHAL = 1,
};
pub const AGILEREFERENCE_DEFAULT = AgileReferenceOptions.FAULT;
pub const AGILEREFERENCE_DELAYEDMARSHAL = AgileReferenceOptions.LAYEDMARSHAL;
// TODO: this type is limited to platform 'windows10.0.15063'
const IID_ISpatialInteractionManagerInterop_Value = Guid.initString("5c4ee536-6a98-4b86-a170-587013d6fd4b");
pub const IID_ISpatialInteractionManagerInterop = &IID_ISpatialInteractionManagerInterop_Value;
pub const ISpatialInteractionManagerInterop = extern struct {
pub const VTable = extern struct {
base: IInspectable.VTable,
GetForWindow: fn(
self: *const ISpatialInteractionManagerInterop,
window: ?HWND,
riid: ?*const Guid,
spatialInteractionManager: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IInspectable.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISpatialInteractionManagerInterop_GetForWindow(self: *const T, window: ?HWND, riid: ?*const Guid, spatialInteractionManager: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const ISpatialInteractionManagerInterop.VTable, self.vtable).GetForWindow(@ptrCast(*const ISpatialInteractionManagerInterop, self), window, riid, spatialInteractionManager);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows10.0.15063'
const IID_IHolographicSpaceInterop_Value = Guid.initString("5c4ee536-6a98-4b86-a170-587013d6fd4b");
pub const IID_IHolographicSpaceInterop = &IID_IHolographicSpaceInterop_Value;
pub const IHolographicSpaceInterop = extern struct {
pub const VTable = extern struct {
base: IInspectable.VTable,
CreateForWindow: fn(
self: *const IHolographicSpaceInterop,
window: ?HWND,
riid: ?*const Guid,
holographicSpace: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IInspectable.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IHolographicSpaceInterop_CreateForWindow(self: *const T, window: ?HWND, riid: ?*const Guid, holographicSpace: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IHolographicSpaceInterop.VTable, self.vtable).CreateForWindow(@ptrCast(*const IHolographicSpaceInterop, self), window, riid, holographicSpace);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const HSTRING_HEADER = extern struct {
Reserved: extern union {
Reserved1: ?*anyopaque,
Reserved2: [24]CHAR,
},
};
pub const TrustLevel = enum(i32) {
BaseTrust = 0,
PartialTrust = 1,
FullTrust = 2,
};
pub const BaseTrust = TrustLevel.BaseTrust;
pub const PartialTrust = TrustLevel.PartialTrust;
pub const FullTrust = TrustLevel.FullTrust;
// TODO: this type is limited to platform 'windows8.0'
const IID_IInspectable_Value = Guid.initString("af86e2e0-b12d-4c6a-9c5a-d7aa65101e90");
pub const IID_IInspectable = &IID_IInspectable_Value;
pub const IInspectable = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetIids: fn(
self: *const IInspectable,
iidCount: ?*u32,
iids: ?[*]?*Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetRuntimeClassName: fn(
self: *const IInspectable,
className: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetTrustLevel: fn(
self: *const IInspectable,
trustLevel: ?*TrustLevel,
) 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 IInspectable_GetIids(self: *const T, iidCount: ?*u32, iids: ?[*]?*Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IInspectable.VTable, self.vtable).GetIids(@ptrCast(*const IInspectable, self), iidCount, iids);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IInspectable_GetRuntimeClassName(self: *const T, className: ?*?HSTRING) callconv(.Inline) HRESULT {
return @ptrCast(*const IInspectable.VTable, self.vtable).GetRuntimeClassName(@ptrCast(*const IInspectable, self), className);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IInspectable_GetTrustLevel(self: *const T, trustLevel: ?*TrustLevel) callconv(.Inline) HRESULT {
return @ptrCast(*const IInspectable.VTable, self.vtable).GetTrustLevel(@ptrCast(*const IInspectable, self), trustLevel);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const PINSPECT_HSTRING_CALLBACK = fn(
context: ?*anyopaque,
readAddress: usize,
length: u32,
buffer: [*:0]u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const PINSPECT_HSTRING_CALLBACK2 = fn(
context: ?*anyopaque,
readAddress: u64,
length: u32,
buffer: [*:0]u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const DISPATCHERQUEUE_THREAD_APARTMENTTYPE = enum(i32) {
NONE = 0,
ASTA = 1,
STA = 2,
};
pub const DQTAT_COM_NONE = DISPATCHERQUEUE_THREAD_APARTMENTTYPE.NONE;
pub const DQTAT_COM_ASTA = DISPATCHERQUEUE_THREAD_APARTMENTTYPE.ASTA;
pub const DQTAT_COM_STA = DISPATCHERQUEUE_THREAD_APARTMENTTYPE.STA;
pub const DISPATCHERQUEUE_THREAD_TYPE = enum(i32) {
DEDICATED = 1,
CURRENT = 2,
};
pub const DQTYPE_THREAD_DEDICATED = DISPATCHERQUEUE_THREAD_TYPE.DEDICATED;
pub const DQTYPE_THREAD_CURRENT = DISPATCHERQUEUE_THREAD_TYPE.CURRENT;
pub const DispatcherQueueOptions = extern struct {
dwSize: u32,
threadType: DISPATCHERQUEUE_THREAD_TYPE,
apartmentType: DISPATCHERQUEUE_THREAD_APARTMENTTYPE,
};
const IID_IAccountsSettingsPaneInterop_Value = Guid.initString("d3ee12ad-3865-4362-9746-b75a682df0e6");
pub const IID_IAccountsSettingsPaneInterop = &IID_IAccountsSettingsPaneInterop_Value;
pub const IAccountsSettingsPaneInterop = extern struct {
pub const VTable = extern struct {
base: IInspectable.VTable,
GetForWindow: fn(
self: *const IAccountsSettingsPaneInterop,
appWindow: ?HWND,
riid: ?*const Guid,
accountsSettingsPane: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ShowManageAccountsForWindowAsync: fn(
self: *const IAccountsSettingsPaneInterop,
appWindow: ?HWND,
riid: ?*const Guid,
asyncAction: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ShowAddAccountForWindowAsync: fn(
self: *const IAccountsSettingsPaneInterop,
appWindow: ?HWND,
riid: ?*const Guid,
asyncAction: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IInspectable.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAccountsSettingsPaneInterop_GetForWindow(self: *const T, appWindow: ?HWND, riid: ?*const Guid, accountsSettingsPane: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IAccountsSettingsPaneInterop.VTable, self.vtable).GetForWindow(@ptrCast(*const IAccountsSettingsPaneInterop, self), appWindow, riid, accountsSettingsPane);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAccountsSettingsPaneInterop_ShowManageAccountsForWindowAsync(self: *const T, appWindow: ?HWND, riid: ?*const Guid, asyncAction: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IAccountsSettingsPaneInterop.VTable, self.vtable).ShowManageAccountsForWindowAsync(@ptrCast(*const IAccountsSettingsPaneInterop, self), appWindow, riid, asyncAction);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAccountsSettingsPaneInterop_ShowAddAccountForWindowAsync(self: *const T, appWindow: ?HWND, riid: ?*const Guid, asyncAction: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IAccountsSettingsPaneInterop.VTable, self.vtable).ShowAddAccountForWindowAsync(@ptrCast(*const IAccountsSettingsPaneInterop, self), appWindow, riid, asyncAction);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IAppServiceConnectionExtendedExecution_Value = Guid.initString("65219584-f9cb-4ae3-81f9-a28a6ca450d9");
pub const IID_IAppServiceConnectionExtendedExecution = &IID_IAppServiceConnectionExtendedExecution_Value;
pub const IAppServiceConnectionExtendedExecution = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
OpenForExtendedExecutionAsync: fn(
self: *const IAppServiceConnectionExtendedExecution,
riid: ?*const Guid,
operation: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAppServiceConnectionExtendedExecution_OpenForExtendedExecutionAsync(self: *const T, riid: ?*const Guid, operation: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IAppServiceConnectionExtendedExecution.VTable, self.vtable).OpenForExtendedExecutionAsync(@ptrCast(*const IAppServiceConnectionExtendedExecution, self), riid, operation);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_ICorrelationVectorSource_Value = Guid.initString("152b8a3b-b9b9-4685-b56e-974847bc7545");
pub const IID_ICorrelationVectorSource = &IID_ICorrelationVectorSource_Value;
pub const ICorrelationVectorSource = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CorrelationVector: fn(
self: *const ICorrelationVectorSource,
cv: ?*?HSTRING,
) 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 ICorrelationVectorSource_get_CorrelationVector(self: *const T, cv: ?*?HSTRING) callconv(.Inline) HRESULT {
return @ptrCast(*const ICorrelationVectorSource.VTable, self.vtable).get_CorrelationVector(@ptrCast(*const ICorrelationVectorSource, self), cv);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const CASTING_CONNECTION_ERROR_STATUS = enum(i32) {
SUCCEEDED = 0,
DEVICE_DID_NOT_RESPOND = 1,
DEVICE_ERROR = 2,
DEVICE_LOCKED = 3,
PROTECTED_PLAYBACK_FAILED = 4,
INVALID_CASTING_SOURCE = 5,
UNKNOWN = 6,
};
pub const CASTING_CONNECTION_ERROR_STATUS_SUCCEEDED = CASTING_CONNECTION_ERROR_STATUS.SUCCEEDED;
pub const CASTING_CONNECTION_ERROR_STATUS_DEVICE_DID_NOT_RESPOND = CASTING_CONNECTION_ERROR_STATUS.DEVICE_DID_NOT_RESPOND;
pub const CASTING_CONNECTION_ERROR_STATUS_DEVICE_ERROR = CASTING_CONNECTION_ERROR_STATUS.DEVICE_ERROR;
pub const CASTING_CONNECTION_ERROR_STATUS_DEVICE_LOCKED = CASTING_CONNECTION_ERROR_STATUS.DEVICE_LOCKED;
pub const CASTING_CONNECTION_ERROR_STATUS_PROTECTED_PLAYBACK_FAILED = CASTING_CONNECTION_ERROR_STATUS.PROTECTED_PLAYBACK_FAILED;
pub const CASTING_CONNECTION_ERROR_STATUS_INVALID_CASTING_SOURCE = CASTING_CONNECTION_ERROR_STATUS.INVALID_CASTING_SOURCE;
pub const CASTING_CONNECTION_ERROR_STATUS_UNKNOWN = CASTING_CONNECTION_ERROR_STATUS.UNKNOWN;
pub const CASTING_CONNECTION_STATE = enum(i32) {
DISCONNECTED = 0,
CONNECTED = 1,
RENDERING = 2,
DISCONNECTING = 3,
CONNECTING = 4,
};
pub const CASTING_CONNECTION_STATE_DISCONNECTED = CASTING_CONNECTION_STATE.DISCONNECTED;
pub const CASTING_CONNECTION_STATE_CONNECTED = CASTING_CONNECTION_STATE.CONNECTED;
pub const CASTING_CONNECTION_STATE_RENDERING = CASTING_CONNECTION_STATE.RENDERING;
pub const CASTING_CONNECTION_STATE_DISCONNECTING = CASTING_CONNECTION_STATE.DISCONNECTING;
pub const CASTING_CONNECTION_STATE_CONNECTING = CASTING_CONNECTION_STATE.CONNECTING;
const IID_ICastingEventHandler_Value = Guid.initString("c79a6cb7-bebd-47a6-a2ad-4d45ad79c7bc");
pub const IID_ICastingEventHandler = &IID_ICastingEventHandler_Value;
pub const ICastingEventHandler = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
OnStateChanged: fn(
self: *const ICastingEventHandler,
newState: CASTING_CONNECTION_STATE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
OnError: fn(
self: *const ICastingEventHandler,
errorStatus: CASTING_CONNECTION_ERROR_STATUS,
errorMessage: ?[*: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 ICastingEventHandler_OnStateChanged(self: *const T, newState: CASTING_CONNECTION_STATE) callconv(.Inline) HRESULT {
return @ptrCast(*const ICastingEventHandler.VTable, self.vtable).OnStateChanged(@ptrCast(*const ICastingEventHandler, self), newState);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICastingEventHandler_OnError(self: *const T, errorStatus: CASTING_CONNECTION_ERROR_STATUS, errorMessage: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICastingEventHandler.VTable, self.vtable).OnError(@ptrCast(*const ICastingEventHandler, self), errorStatus, errorMessage);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_ICastingController_Value = Guid.initString("f0a56423-a664-4fbd-8b43-409a45e8d9a1");
pub const IID_ICastingController = &IID_ICastingController_Value;
pub const ICastingController = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Initialize: fn(
self: *const ICastingController,
castingEngine: ?*IUnknown,
castingSource: ?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Connect: fn(
self: *const ICastingController,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Disconnect: fn(
self: *const ICastingController,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Advise: fn(
self: *const ICastingController,
eventHandler: ?*ICastingEventHandler,
cookie: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
UnAdvise: fn(
self: *const ICastingController,
cookie: 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 ICastingController_Initialize(self: *const T, castingEngine: ?*IUnknown, castingSource: ?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const ICastingController.VTable, self.vtable).Initialize(@ptrCast(*const ICastingController, self), castingEngine, castingSource);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICastingController_Connect(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICastingController.VTable, self.vtable).Connect(@ptrCast(*const ICastingController, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICastingController_Disconnect(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICastingController.VTable, self.vtable).Disconnect(@ptrCast(*const ICastingController, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICastingController_Advise(self: *const T, eventHandler: ?*ICastingEventHandler, cookie: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICastingController.VTable, self.vtable).Advise(@ptrCast(*const ICastingController, self), eventHandler, cookie);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICastingController_UnAdvise(self: *const T, cookie: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICastingController.VTable, self.vtable).UnAdvise(@ptrCast(*const ICastingController, self), cookie);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_ICastingSourceInfo_Value = Guid.initString("45101ab7-7c3a-4bce-9500-12c09024b298");
pub const IID_ICastingSourceInfo = &IID_ICastingSourceInfo_Value;
pub const ICastingSourceInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetController: fn(
self: *const ICastingSourceInfo,
controller: ?*?*ICastingController,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetProperties: fn(
self: *const ICastingSourceInfo,
props: ?*?*INamedPropertyStore,
) 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 ICastingSourceInfo_GetController(self: *const T, controller: ?*?*ICastingController) callconv(.Inline) HRESULT {
return @ptrCast(*const ICastingSourceInfo.VTable, self.vtable).GetController(@ptrCast(*const ICastingSourceInfo, self), controller);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICastingSourceInfo_GetProperties(self: *const T, props: ?*?*INamedPropertyStore) callconv(.Inline) HRESULT {
return @ptrCast(*const ICastingSourceInfo.VTable, self.vtable).GetProperties(@ptrCast(*const ICastingSourceInfo, self), props);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IDragDropManagerInterop_Value = Guid.initString("5ad8cba7-4c01-4dac-9074-827894292d63");
pub const IID_IDragDropManagerInterop = &IID_IDragDropManagerInterop_Value;
pub const IDragDropManagerInterop = extern struct {
pub const VTable = extern struct {
base: IInspectable.VTable,
GetForWindow: fn(
self: *const IDragDropManagerInterop,
hwnd: ?HWND,
riid: ?*const Guid,
ppv: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IInspectable.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDragDropManagerInterop_GetForWindow(self: *const T, hwnd: ?HWND, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IDragDropManagerInterop.VTable, self.vtable).GetForWindow(@ptrCast(*const IDragDropManagerInterop, self), hwnd, riid, ppv);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows10.0.14393'
const IID_IInputPaneInterop_Value = Guid.initString("75cf2c57-9195-4931-8332-f0b409e916af");
pub const IID_IInputPaneInterop = &IID_IInputPaneInterop_Value;
pub const IInputPaneInterop = extern struct {
pub const VTable = extern struct {
base: IInspectable.VTable,
GetForWindow: fn(
self: *const IInputPaneInterop,
appWindow: ?HWND,
riid: ?*const Guid,
inputPane: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IInspectable.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IInputPaneInterop_GetForWindow(self: *const T, appWindow: ?HWND, riid: ?*const Guid, inputPane: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IInputPaneInterop.VTable, self.vtable).GetForWindow(@ptrCast(*const IInputPaneInterop, self), appWindow, riid, inputPane);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows8.0'
const IID_IPlayToManagerInterop_Value = Guid.initString("24394699-1f2c-4eb3-8cd7-0ec1da42a540");
pub const IID_IPlayToManagerInterop = &IID_IPlayToManagerInterop_Value;
pub const IPlayToManagerInterop = extern struct {
pub const VTable = extern struct {
base: IInspectable.VTable,
GetForWindow: fn(
self: *const IPlayToManagerInterop,
appWindow: ?HWND,
riid: ?*const Guid,
playToManager: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ShowPlayToUIForWindow: fn(
self: *const IPlayToManagerInterop,
appWindow: ?HWND,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IInspectable.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPlayToManagerInterop_GetForWindow(self: *const T, appWindow: ?HWND, riid: ?*const Guid, playToManager: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IPlayToManagerInterop.VTable, self.vtable).GetForWindow(@ptrCast(*const IPlayToManagerInterop, self), appWindow, riid, playToManager);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPlayToManagerInterop_ShowPlayToUIForWindow(self: *const T, appWindow: ?HWND) callconv(.Inline) HRESULT {
return @ptrCast(*const IPlayToManagerInterop.VTable, self.vtable).ShowPlayToUIForWindow(@ptrCast(*const IPlayToManagerInterop, self), appWindow);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_ICorrelationVectorInformation_Value = Guid.initString("83c78b3c-d88b-4950-aa6e-22b8d22aabd3");
pub const IID_ICorrelationVectorInformation = &IID_ICorrelationVectorInformation_Value;
pub const ICorrelationVectorInformation = extern struct {
pub const VTable = extern struct {
base: IInspectable.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_LastCorrelationVectorForThread: fn(
self: *const ICorrelationVectorInformation,
cv: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_NextCorrelationVectorForThread: fn(
self: *const ICorrelationVectorInformation,
cv: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_NextCorrelationVectorForThread: fn(
self: *const ICorrelationVectorInformation,
cv: ?HSTRING,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IInspectable.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICorrelationVectorInformation_get_LastCorrelationVectorForThread(self: *const T, cv: ?*?HSTRING) callconv(.Inline) HRESULT {
return @ptrCast(*const ICorrelationVectorInformation.VTable, self.vtable).get_LastCorrelationVectorForThread(@ptrCast(*const ICorrelationVectorInformation, self), cv);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICorrelationVectorInformation_get_NextCorrelationVectorForThread(self: *const T, cv: ?*?HSTRING) callconv(.Inline) HRESULT {
return @ptrCast(*const ICorrelationVectorInformation.VTable, self.vtable).get_NextCorrelationVectorForThread(@ptrCast(*const ICorrelationVectorInformation, self), cv);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICorrelationVectorInformation_put_NextCorrelationVectorForThread(self: *const T, cv: ?HSTRING) callconv(.Inline) HRESULT {
return @ptrCast(*const ICorrelationVectorInformation.VTable, self.vtable).put_NextCorrelationVectorForThread(@ptrCast(*const ICorrelationVectorInformation, self), cv);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IUIViewSettingsInterop_Value = Guid.initString("3694dbf9-8f68-44be-8ff5-195c98ede8a6");
pub const IID_IUIViewSettingsInterop = &IID_IUIViewSettingsInterop_Value;
pub const IUIViewSettingsInterop = extern struct {
pub const VTable = extern struct {
base: IInspectable.VTable,
GetForWindow: fn(
self: *const IUIViewSettingsInterop,
hwnd: ?HWND,
riid: ?*const Guid,
ppv: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IInspectable.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IUIViewSettingsInterop_GetForWindow(self: *const T, hwnd: ?HWND, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IUIViewSettingsInterop.VTable, self.vtable).GetForWindow(@ptrCast(*const IUIViewSettingsInterop, self), hwnd, riid, ppv);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IUserActivityInterop_Value = Guid.initString("1ade314d-0e0a-40d9-824c-9a088a50059f");
pub const IID_IUserActivityInterop = &IID_IUserActivityInterop_Value;
pub const IUserActivityInterop = extern struct {
pub const VTable = extern struct {
base: IInspectable.VTable,
CreateSessionForWindow: fn(
self: *const IUserActivityInterop,
window: ?HWND,
iid: ?*const Guid,
value: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IInspectable.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IUserActivityInterop_CreateSessionForWindow(self: *const T, window: ?HWND, iid: ?*const Guid, value: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IUserActivityInterop.VTable, self.vtable).CreateSessionForWindow(@ptrCast(*const IUserActivityInterop, self), window, iid, value);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IUserActivitySourceHostInterop_Value = Guid.initString("c15df8bc-8844-487a-b85b-7578e0f61419");
pub const IID_IUserActivitySourceHostInterop = &IID_IUserActivitySourceHostInterop_Value;
pub const IUserActivitySourceHostInterop = extern struct {
pub const VTable = extern struct {
base: IInspectable.VTable,
SetActivitySourceHost: fn(
self: *const IUserActivitySourceHostInterop,
activitySourceHost: ?HSTRING,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IInspectable.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IUserActivitySourceHostInterop_SetActivitySourceHost(self: *const T, activitySourceHost: ?HSTRING) callconv(.Inline) HRESULT {
return @ptrCast(*const IUserActivitySourceHostInterop.VTable, self.vtable).SetActivitySourceHost(@ptrCast(*const IUserActivitySourceHostInterop, self), activitySourceHost);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IUserActivityRequestManagerInterop_Value = Guid.initString("dd69f876-9699-4715-9095-e37ea30dfa1b");
pub const IID_IUserActivityRequestManagerInterop = &IID_IUserActivityRequestManagerInterop_Value;
pub const IUserActivityRequestManagerInterop = extern struct {
pub const VTable = extern struct {
base: IInspectable.VTable,
GetForWindow: fn(
self: *const IUserActivityRequestManagerInterop,
window: ?HWND,
iid: ?*const Guid,
value: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IInspectable.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IUserActivityRequestManagerInterop_GetForWindow(self: *const T, window: ?HWND, iid: ?*const Guid, value: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IUserActivityRequestManagerInterop.VTable, self.vtable).GetForWindow(@ptrCast(*const IUserActivityRequestManagerInterop, self), window, iid, value);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IUserConsentVerifierInterop_Value = Guid.initString("39e050c3-4e74-441a-8dc0-b81104df949c");
pub const IID_IUserConsentVerifierInterop = &IID_IUserConsentVerifierInterop_Value;
pub const IUserConsentVerifierInterop = extern struct {
pub const VTable = extern struct {
base: IInspectable.VTable,
RequestVerificationForWindowAsync: fn(
self: *const IUserConsentVerifierInterop,
appWindow: ?HWND,
message: ?HSTRING,
riid: ?*const Guid,
asyncOperation: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IInspectable.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IUserConsentVerifierInterop_RequestVerificationForWindowAsync(self: *const T, appWindow: ?HWND, message: ?HSTRING, riid: ?*const Guid, asyncOperation: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IUserConsentVerifierInterop.VTable, self.vtable).RequestVerificationForWindowAsync(@ptrCast(*const IUserConsentVerifierInterop, self), appWindow, message, riid, asyncOperation);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IWebAuthenticationCoreManagerInterop_Value = Guid.initString("f4b8e804-811e-4436-b69c-44cb67b72084");
pub const IID_IWebAuthenticationCoreManagerInterop = &IID_IWebAuthenticationCoreManagerInterop_Value;
pub const IWebAuthenticationCoreManagerInterop = extern struct {
pub const VTable = extern struct {
base: IInspectable.VTable,
RequestTokenForWindowAsync: fn(
self: *const IWebAuthenticationCoreManagerInterop,
appWindow: ?HWND,
request: ?*IInspectable,
riid: ?*const Guid,
asyncInfo: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
RequestTokenWithWebAccountForWindowAsync: fn(
self: *const IWebAuthenticationCoreManagerInterop,
appWindow: ?HWND,
request: ?*IInspectable,
webAccount: ?*IInspectable,
riid: ?*const Guid,
asyncInfo: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IInspectable.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWebAuthenticationCoreManagerInterop_RequestTokenForWindowAsync(self: *const T, appWindow: ?HWND, request: ?*IInspectable, riid: ?*const Guid, asyncInfo: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IWebAuthenticationCoreManagerInterop.VTable, self.vtable).RequestTokenForWindowAsync(@ptrCast(*const IWebAuthenticationCoreManagerInterop, self), appWindow, request, riid, asyncInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWebAuthenticationCoreManagerInterop_RequestTokenWithWebAccountForWindowAsync(self: *const T, appWindow: ?HWND, request: ?*IInspectable, webAccount: ?*IInspectable, riid: ?*const Guid, asyncInfo: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IWebAuthenticationCoreManagerInterop.VTable, self.vtable).RequestTokenWithWebAccountForWindowAsync(@ptrCast(*const IWebAuthenticationCoreManagerInterop, self), appWindow, request, webAccount, riid, asyncInfo);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows8.0'
const IID_IRestrictedErrorInfo_Value = Guid.initString("82ba7092-4c88-427d-a7bc-16dd93feb67e");
pub const IID_IRestrictedErrorInfo = &IID_IRestrictedErrorInfo_Value;
pub const IRestrictedErrorInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetErrorDetails: fn(
self: *const IRestrictedErrorInfo,
description: ?*?BSTR,
@"error": ?*HRESULT,
restrictedDescription: ?*?BSTR,
capabilitySid: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetReference: fn(
self: *const IRestrictedErrorInfo,
reference: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRestrictedErrorInfo_GetErrorDetails(self: *const T, description: ?*?BSTR, @"error": ?*HRESULT, restrictedDescription: ?*?BSTR, capabilitySid: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IRestrictedErrorInfo.VTable, self.vtable).GetErrorDetails(@ptrCast(*const IRestrictedErrorInfo, self), description, @"error", restrictedDescription, capabilitySid);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRestrictedErrorInfo_GetReference(self: *const T, reference: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IRestrictedErrorInfo.VTable, self.vtable).GetReference(@ptrCast(*const IRestrictedErrorInfo, self), reference);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows8.1'
const IID_ILanguageExceptionErrorInfo_Value = Guid.initString("04a2dbf3-df83-116c-0946-0812abf6e07d");
pub const IID_ILanguageExceptionErrorInfo = &IID_ILanguageExceptionErrorInfo_Value;
pub const ILanguageExceptionErrorInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetLanguageException: fn(
self: *const ILanguageExceptionErrorInfo,
languageException: ?*?*IUnknown,
) 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 ILanguageExceptionErrorInfo_GetLanguageException(self: *const T, languageException: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const ILanguageExceptionErrorInfo.VTable, self.vtable).GetLanguageException(@ptrCast(*const ILanguageExceptionErrorInfo, self), languageException);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows10.0.15063'
const IID_ILanguageExceptionTransform_Value = Guid.initString("feb5a271-a6cd-45ce-880a-696706badc65");
pub const IID_ILanguageExceptionTransform = &IID_ILanguageExceptionTransform_Value;
pub const ILanguageExceptionTransform = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetTransformedRestrictedErrorInfo: fn(
self: *const ILanguageExceptionTransform,
restrictedErrorInfo: ?*?*IRestrictedErrorInfo,
) 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 ILanguageExceptionTransform_GetTransformedRestrictedErrorInfo(self: *const T, restrictedErrorInfo: ?*?*IRestrictedErrorInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const ILanguageExceptionTransform.VTable, self.vtable).GetTransformedRestrictedErrorInfo(@ptrCast(*const ILanguageExceptionTransform, self), restrictedErrorInfo);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows10.0.15063'
const IID_ILanguageExceptionStackBackTrace_Value = Guid.initString("cbe53fb5-f967-4258-8d34-42f5e25833de");
pub const IID_ILanguageExceptionStackBackTrace = &IID_ILanguageExceptionStackBackTrace_Value;
pub const ILanguageExceptionStackBackTrace = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetStackBackTrace: fn(
self: *const ILanguageExceptionStackBackTrace,
maxFramesToCapture: u32,
stackBackTrace: ?*usize,
framesCaptured: ?*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 ILanguageExceptionStackBackTrace_GetStackBackTrace(self: *const T, maxFramesToCapture: u32, stackBackTrace: ?*usize, framesCaptured: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const ILanguageExceptionStackBackTrace.VTable, self.vtable).GetStackBackTrace(@ptrCast(*const ILanguageExceptionStackBackTrace, self), maxFramesToCapture, stackBackTrace, framesCaptured);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows10.0.15063'
const IID_ILanguageExceptionErrorInfo2_Value = Guid.initString("5746e5c4-5b97-424c-b620-2822915734dd");
pub const IID_ILanguageExceptionErrorInfo2 = &IID_ILanguageExceptionErrorInfo2_Value;
pub const ILanguageExceptionErrorInfo2 = extern struct {
pub const VTable = extern struct {
base: ILanguageExceptionErrorInfo.VTable,
GetPreviousLanguageExceptionErrorInfo: fn(
self: *const ILanguageExceptionErrorInfo2,
previousLanguageExceptionErrorInfo: ?*?*ILanguageExceptionErrorInfo2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CapturePropagationContext: fn(
self: *const ILanguageExceptionErrorInfo2,
languageException: ?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetPropagationContextHead: fn(
self: *const ILanguageExceptionErrorInfo2,
propagatedLanguageExceptionErrorInfoHead: ?*?*ILanguageExceptionErrorInfo2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ILanguageExceptionErrorInfo.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ILanguageExceptionErrorInfo2_GetPreviousLanguageExceptionErrorInfo(self: *const T, previousLanguageExceptionErrorInfo: ?*?*ILanguageExceptionErrorInfo2) callconv(.Inline) HRESULT {
return @ptrCast(*const ILanguageExceptionErrorInfo2.VTable, self.vtable).GetPreviousLanguageExceptionErrorInfo(@ptrCast(*const ILanguageExceptionErrorInfo2, self), previousLanguageExceptionErrorInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ILanguageExceptionErrorInfo2_CapturePropagationContext(self: *const T, languageException: ?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const ILanguageExceptionErrorInfo2.VTable, self.vtable).CapturePropagationContext(@ptrCast(*const ILanguageExceptionErrorInfo2, self), languageException);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ILanguageExceptionErrorInfo2_GetPropagationContextHead(self: *const T, propagatedLanguageExceptionErrorInfoHead: ?*?*ILanguageExceptionErrorInfo2) callconv(.Inline) HRESULT {
return @ptrCast(*const ILanguageExceptionErrorInfo2.VTable, self.vtable).GetPropagationContextHead(@ptrCast(*const ILanguageExceptionErrorInfo2, self), propagatedLanguageExceptionErrorInfoHead);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows8.0'
const IID_IActivationFactory_Value = Guid.initString("00000035-0000-0000-c000-000000000046");
pub const IID_IActivationFactory = &IID_IActivationFactory_Value;
pub const IActivationFactory = extern struct {
pub const VTable = extern struct {
base: IInspectable.VTable,
ActivateInstance: fn(
self: *const IActivationFactory,
instance: ?*?*IInspectable,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IInspectable.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IActivationFactory_ActivateInstance(self: *const T, instance: ?*?*IInspectable) callconv(.Inline) HRESULT {
return @ptrCast(*const IActivationFactory.VTable, self.vtable).ActivateInstance(@ptrCast(*const IActivationFactory, self), instance);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const RO_INIT_TYPE = enum(i32) {
SINGLETHREADED = 0,
MULTITHREADED = 1,
};
pub const RO_INIT_SINGLETHREADED = RO_INIT_TYPE.SINGLETHREADED;
pub const RO_INIT_MULTITHREADED = RO_INIT_TYPE.MULTITHREADED;
pub const _RO_REGISTRATION_COOKIE = extern struct {
placeholder: usize, // TODO: why is this type empty?
};
const IID_IBufferByteAccess_Value = Guid.initString("905a0fef-bc53-11df-8c49-001e4fc686da");
pub const IID_IBufferByteAccess = &IID_IBufferByteAccess_Value;
pub const IBufferByteAccess = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Buffer: fn(
self: *const IBufferByteAccess,
value: ?*?*u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IBufferByteAccess_Buffer(self: *const T, value: ?*?*u8) callconv(.Inline) HRESULT {
return @ptrCast(*const IBufferByteAccess.VTable, self.vtable).Buffer(@ptrCast(*const IBufferByteAccess, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const RO_ERROR_REPORTING_FLAGS = enum(u32) {
NONE = 0,
SUPPRESSEXCEPTIONS = 1,
FORCEEXCEPTIONS = 2,
USESETERRORINFO = 4,
SUPPRESSSETERRORINFO = 8,
_,
pub fn initFlags(o: struct {
NONE: u1 = 0,
SUPPRESSEXCEPTIONS: u1 = 0,
FORCEEXCEPTIONS: u1 = 0,
USESETERRORINFO: u1 = 0,
SUPPRESSSETERRORINFO: u1 = 0,
}) RO_ERROR_REPORTING_FLAGS {
return @intToEnum(RO_ERROR_REPORTING_FLAGS,
(if (o.NONE == 1) @enumToInt(RO_ERROR_REPORTING_FLAGS.NONE) else 0)
| (if (o.SUPPRESSEXCEPTIONS == 1) @enumToInt(RO_ERROR_REPORTING_FLAGS.SUPPRESSEXCEPTIONS) else 0)
| (if (o.FORCEEXCEPTIONS == 1) @enumToInt(RO_ERROR_REPORTING_FLAGS.FORCEEXCEPTIONS) else 0)
| (if (o.USESETERRORINFO == 1) @enumToInt(RO_ERROR_REPORTING_FLAGS.USESETERRORINFO) else 0)
| (if (o.SUPPRESSSETERRORINFO == 1) @enumToInt(RO_ERROR_REPORTING_FLAGS.SUPPRESSSETERRORINFO) else 0)
);
}
};
pub const RO_ERROR_REPORTING_NONE = RO_ERROR_REPORTING_FLAGS.NONE;
pub const RO_ERROR_REPORTING_SUPPRESSEXCEPTIONS = RO_ERROR_REPORTING_FLAGS.SUPPRESSEXCEPTIONS;
pub const RO_ERROR_REPORTING_FORCEEXCEPTIONS = RO_ERROR_REPORTING_FLAGS.FORCEEXCEPTIONS;
pub const RO_ERROR_REPORTING_USESETERRORINFO = RO_ERROR_REPORTING_FLAGS.USESETERRORINFO;
pub const RO_ERROR_REPORTING_SUPPRESSSETERRORINFO = RO_ERROR_REPORTING_FLAGS.SUPPRESSSETERRORINFO;
pub const PINSPECT_MEMORY_CALLBACK = fn(
context: ?*anyopaque,
readAddress: usize,
length: u32,
buffer: [*:0]u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const IRoSimpleMetaDataBuilder = extern struct {
pub const VTable = extern struct {
SetWinRtInterface: fn(
self: *const IRoSimpleMetaDataBuilder,
iid: Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetDelegate: fn(
self: *const IRoSimpleMetaDataBuilder,
iid: Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetInterfaceGroupSimpleDefault: fn(
self: *const IRoSimpleMetaDataBuilder,
name: ?[*:0]const u16,
defaultInterfaceName: ?[*:0]const u16,
defaultInterfaceIID: ?*const Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetInterfaceGroupParameterizedDefault: fn(
self: *const IRoSimpleMetaDataBuilder,
name: ?[*:0]const u16,
elementCount: u32,
defaultInterfaceNameElements: [*]?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetRuntimeClassSimpleDefault: fn(
self: *const IRoSimpleMetaDataBuilder,
name: ?[*:0]const u16,
defaultInterfaceName: ?[*:0]const u16,
defaultInterfaceIID: ?*const Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetRuntimeClassParameterizedDefault: fn(
self: *const IRoSimpleMetaDataBuilder,
name: ?[*:0]const u16,
elementCount: u32,
defaultInterfaceNameElements: [*]const ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetStruct: fn(
self: *const IRoSimpleMetaDataBuilder,
name: ?[*:0]const u16,
numFields: u32,
fieldTypeNames: [*]const ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetEnum: fn(
self: *const IRoSimpleMetaDataBuilder,
name: ?[*:0]const u16,
baseType: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetParameterizedInterface: fn(
self: *const IRoSimpleMetaDataBuilder,
piid: Guid,
numArgs: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetParameterizedDelegate: fn(
self: *const IRoSimpleMetaDataBuilder,
piid: Guid,
numArgs: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRoSimpleMetaDataBuilder_SetWinRtInterface(self: *const T, iid: Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IRoSimpleMetaDataBuilder.VTable, self.vtable).SetWinRtInterface(@ptrCast(*const IRoSimpleMetaDataBuilder, self), iid);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRoSimpleMetaDataBuilder_SetDelegate(self: *const T, iid: Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IRoSimpleMetaDataBuilder.VTable, self.vtable).SetDelegate(@ptrCast(*const IRoSimpleMetaDataBuilder, self), iid);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRoSimpleMetaDataBuilder_SetInterfaceGroupSimpleDefault(self: *const T, name: ?[*:0]const u16, defaultInterfaceName: ?[*:0]const u16, defaultInterfaceIID: ?*const Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IRoSimpleMetaDataBuilder.VTable, self.vtable).SetInterfaceGroupSimpleDefault(@ptrCast(*const IRoSimpleMetaDataBuilder, self), name, defaultInterfaceName, defaultInterfaceIID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRoSimpleMetaDataBuilder_SetInterfaceGroupParameterizedDefault(self: *const T, name: ?[*:0]const u16, elementCount: u32, defaultInterfaceNameElements: [*]?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IRoSimpleMetaDataBuilder.VTable, self.vtable).SetInterfaceGroupParameterizedDefault(@ptrCast(*const IRoSimpleMetaDataBuilder, self), name, elementCount, defaultInterfaceNameElements);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRoSimpleMetaDataBuilder_SetRuntimeClassSimpleDefault(self: *const T, name: ?[*:0]const u16, defaultInterfaceName: ?[*:0]const u16, defaultInterfaceIID: ?*const Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IRoSimpleMetaDataBuilder.VTable, self.vtable).SetRuntimeClassSimpleDefault(@ptrCast(*const IRoSimpleMetaDataBuilder, self), name, defaultInterfaceName, defaultInterfaceIID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRoSimpleMetaDataBuilder_SetRuntimeClassParameterizedDefault(self: *const T, name: ?[*:0]const u16, elementCount: u32, defaultInterfaceNameElements: [*]const ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IRoSimpleMetaDataBuilder.VTable, self.vtable).SetRuntimeClassParameterizedDefault(@ptrCast(*const IRoSimpleMetaDataBuilder, self), name, elementCount, defaultInterfaceNameElements);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRoSimpleMetaDataBuilder_SetStruct(self: *const T, name: ?[*:0]const u16, numFields: u32, fieldTypeNames: [*]const ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IRoSimpleMetaDataBuilder.VTable, self.vtable).SetStruct(@ptrCast(*const IRoSimpleMetaDataBuilder, self), name, numFields, fieldTypeNames);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRoSimpleMetaDataBuilder_SetEnum(self: *const T, name: ?[*:0]const u16, baseType: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IRoSimpleMetaDataBuilder.VTable, self.vtable).SetEnum(@ptrCast(*const IRoSimpleMetaDataBuilder, self), name, baseType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRoSimpleMetaDataBuilder_SetParameterizedInterface(self: *const T, piid: Guid, numArgs: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRoSimpleMetaDataBuilder.VTable, self.vtable).SetParameterizedInterface(@ptrCast(*const IRoSimpleMetaDataBuilder, self), piid, numArgs);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRoSimpleMetaDataBuilder_SetParameterizedDelegate(self: *const T, piid: Guid, numArgs: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRoSimpleMetaDataBuilder.VTable, self.vtable).SetParameterizedDelegate(@ptrCast(*const IRoSimpleMetaDataBuilder, self), piid, numArgs);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const IRoMetaDataLocator = extern struct {
pub const VTable = extern struct {
Locate: fn(
self: *const IRoMetaDataLocator,
nameElement: ?[*:0]const u16,
metaDataDestination: ?*IRoSimpleMetaDataBuilder,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRoMetaDataLocator_Locate(self: *const T, nameElement: ?[*:0]const u16, metaDataDestination: ?*IRoSimpleMetaDataBuilder) callconv(.Inline) HRESULT {
return @ptrCast(*const IRoMetaDataLocator.VTable, self.vtable).Locate(@ptrCast(*const IRoMetaDataLocator, self), nameElement, metaDataDestination);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const BSOS_OPTIONS = enum(i32) {
DEFAULT = 0,
PREFERDESTINATIONSTREAM = 1,
};
pub const BSOS_DEFAULT = BSOS_OPTIONS.DEFAULT;
pub const BSOS_PREFERDESTINATIONSTREAM = BSOS_OPTIONS.PREFERDESTINATIONSTREAM;
const IID_IMemoryBufferByteAccess_Value = Guid.initString("5b0d3235-4dba-4d44-865e-8f1d0e4fd04d");
pub const IID_IMemoryBufferByteAccess = &IID_IMemoryBufferByteAccess_Value;
pub const IMemoryBufferByteAccess = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetBuffer: fn(
self: *const IMemoryBufferByteAccess,
value: ?*?*u8,
capacity: ?*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 IMemoryBufferByteAccess_GetBuffer(self: *const T, value: ?*?*u8, capacity: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMemoryBufferByteAccess.VTable, self.vtable).GetBuffer(@ptrCast(*const IMemoryBufferByteAccess, self), value, capacity);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows8.0'
const IID_IWeakReference_Value = Guid.initString("00000037-0000-0000-c000-000000000046");
pub const IID_IWeakReference = &IID_IWeakReference_Value;
pub const IWeakReference = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Resolve: fn(
self: *const IWeakReference,
riid: ?*const Guid,
objectReference: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWeakReference_Resolve(self: *const T, riid: ?*const Guid, objectReference: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IWeakReference.VTable, self.vtable).Resolve(@ptrCast(*const IWeakReference, self), riid, objectReference);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows8.0'
const IID_IWeakReferenceSource_Value = Guid.initString("00000038-0000-0000-c000-000000000046");
pub const IID_IWeakReferenceSource = &IID_IWeakReferenceSource_Value;
pub const IWeakReferenceSource = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetWeakReference: fn(
self: *const IWeakReferenceSource,
weakReference: ?*?*IWeakReference,
) 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 IWeakReferenceSource_GetWeakReference(self: *const T, weakReference: ?*?*IWeakReference) callconv(.Inline) HRESULT {
return @ptrCast(*const IWeakReferenceSource.VTable, self.vtable).GetWeakReference(@ptrCast(*const IWeakReferenceSource, self), weakReference);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_ISystemMediaTransportControlsInterop_Value = Guid.initString("ddb0472d-c911-4a1f-86d9-dc3d71a95f5a");
pub const IID_ISystemMediaTransportControlsInterop = &IID_ISystemMediaTransportControlsInterop_Value;
pub const ISystemMediaTransportControlsInterop = extern struct {
pub const VTable = extern struct {
base: IInspectable.VTable,
GetForWindow: fn(
self: *const ISystemMediaTransportControlsInterop,
appWindow: ?HWND,
riid: ?*const Guid,
mediaTransportControl: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IInspectable.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISystemMediaTransportControlsInterop_GetForWindow(self: *const T, appWindow: ?HWND, riid: ?*const Guid, mediaTransportControl: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const ISystemMediaTransportControlsInterop.VTable, self.vtable).GetForWindow(@ptrCast(*const ISystemMediaTransportControlsInterop, self), appWindow, riid, mediaTransportControl);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IShareWindowCommandEventArgsInterop_Value = Guid.initString("6571a721-643d-43d4-aca4-6b6f5f30f1ad");
pub const IID_IShareWindowCommandEventArgsInterop = &IID_IShareWindowCommandEventArgsInterop_Value;
pub const IShareWindowCommandEventArgsInterop = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetWindow: fn(
self: *const IShareWindowCommandEventArgsInterop,
value: ?*?HWND,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IShareWindowCommandEventArgsInterop_GetWindow(self: *const T, value: ?*?HWND) callconv(.Inline) HRESULT {
return @ptrCast(*const IShareWindowCommandEventArgsInterop.VTable, self.vtable).GetWindow(@ptrCast(*const IShareWindowCommandEventArgsInterop, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IShareWindowCommandSourceInterop_Value = Guid.initString("461a191f-8424-43a6-a0fa-3451a22f56ab");
pub const IID_IShareWindowCommandSourceInterop = &IID_IShareWindowCommandSourceInterop_Value;
pub const IShareWindowCommandSourceInterop = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetForWindow: fn(
self: *const IShareWindowCommandSourceInterop,
appWindow: ?HWND,
riid: ?*const Guid,
shareWindowCommandSource: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IShareWindowCommandSourceInterop_GetForWindow(self: *const T, appWindow: ?HWND, riid: ?*const Guid, shareWindowCommandSource: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IShareWindowCommandSourceInterop.VTable, self.vtable).GetForWindow(@ptrCast(*const IShareWindowCommandSourceInterop, self), appWindow, riid, shareWindowCommandSource);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IMessageDispatcher_Value = Guid.initString("f5f84c8f-cfd0-4cd6-b66b-c5d26ff1689d");
pub const IID_IMessageDispatcher = &IID_IMessageDispatcher_Value;
pub const IMessageDispatcher = extern struct {
pub const VTable = extern struct {
base: IInspectable.VTable,
PumpMessages: fn(
self: *const IMessageDispatcher,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IInspectable.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMessageDispatcher_PumpMessages(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IMessageDispatcher.VTable, self.vtable).PumpMessages(@ptrCast(*const IMessageDispatcher, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
//--------------------------------------------------------------------------------
// Section: Functions (68)
//--------------------------------------------------------------------------------
pub extern "OLE32" fn CoDecodeProxy(
dwClientPid: u32,
ui64ProxyAddress: u64,
pServerInformation: ?*ServerInformation,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.1'
pub extern "OLE32" fn RoGetAgileReference(
options: AgileReferenceOptions,
riid: ?*const Guid,
pUnk: ?*IUnknown,
ppAgileReference: ?*?*IAgileReference,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn HSTRING_UserSize(
param0: ?*u32,
param1: u32,
param2: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn HSTRING_UserMarshal(
param0: ?*u32,
param1: ?*u8,
param2: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) ?*u8;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn HSTRING_UserUnmarshal(
param0: ?*u32,
param1: [*:0]u8,
param2: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) ?*u8;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn HSTRING_UserFree(
param0: ?*u32,
param1: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) void;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn HSTRING_UserSize64(
param0: ?*u32,
param1: u32,
param2: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn HSTRING_UserMarshal64(
param0: ?*u32,
param1: ?*u8,
param2: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) ?*u8;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn HSTRING_UserUnmarshal64(
param0: ?*u32,
param1: [*:0]u8,
param2: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) ?*u8;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn HSTRING_UserFree64(
param0: ?*u32,
param1: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) void;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn WindowsCreateString(
sourceString: ?[*:0]const u16,
length: u32,
string: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn WindowsCreateStringReference(
sourceString: ?[*:0]const u16,
length: u32,
hstringHeader: ?*HSTRING_HEADER,
string: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn WindowsDeleteString(
string: ?HSTRING,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn WindowsDuplicateString(
string: ?HSTRING,
newString: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn WindowsGetStringLen(
string: ?HSTRING,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn WindowsGetStringRawBuffer(
string: ?HSTRING,
length: ?*u32,
) callconv(@import("std").os.windows.WINAPI) ?PWSTR;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn WindowsIsStringEmpty(
string: ?HSTRING,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn WindowsStringHasEmbeddedNull(
string: ?HSTRING,
hasEmbedNull: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn WindowsCompareStringOrdinal(
string1: ?HSTRING,
string2: ?HSTRING,
result: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn WindowsSubstring(
string: ?HSTRING,
startIndex: u32,
newString: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn WindowsSubstringWithSpecifiedLength(
string: ?HSTRING,
startIndex: u32,
length: u32,
newString: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn WindowsConcatString(
string1: ?HSTRING,
string2: ?HSTRING,
newString: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn WindowsReplaceString(
string: ?HSTRING,
stringReplaced: ?HSTRING,
stringReplaceWith: ?HSTRING,
newString: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn WindowsTrimStringStart(
string: ?HSTRING,
trimString: ?HSTRING,
newString: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn WindowsTrimStringEnd(
string: ?HSTRING,
trimString: ?HSTRING,
newString: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn WindowsPreallocateStringBuffer(
length: u32,
charBuffer: ?*?*u16,
bufferHandle: ?*?HSTRING_BUFFER,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn WindowsPromoteStringBuffer(
bufferHandle: ?HSTRING_BUFFER,
string: ?*?HSTRING,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn WindowsDeleteStringBuffer(
bufferHandle: ?HSTRING_BUFFER,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-0" fn WindowsInspectString(
targetHString: usize,
machine: u16,
callback: ?PINSPECT_HSTRING_CALLBACK,
context: ?*anyopaque,
length: ?*u32,
targetStringAddress: ?*usize,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-string-l1-1-1" fn WindowsInspectString2(
targetHString: u64,
machine: u16,
callback: ?PINSPECT_HSTRING_CALLBACK2,
context: ?*anyopaque,
length: ?*u32,
targetStringAddress: ?*u64,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "CoreMessaging" fn CreateDispatcherQueueController(
options: DispatcherQueueOptions,
dispatcherQueueController: ?**struct{comment: []const u8 = "MissingClrType DispatcherQueueController.Windows.System"},
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-l1-1-0" fn RoInitialize(
initType: RO_INIT_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-l1-1-0" fn RoUninitialize(
) callconv(@import("std").os.windows.WINAPI) void;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-l1-1-0" fn RoActivateInstance(
activatableClassId: ?HSTRING,
instance: ?*?*IInspectable,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-l1-1-0" fn RoRegisterActivationFactories(
activatableClassIds: [*]?HSTRING,
activationFactoryCallbacks: [*]isize,
count: u32,
cookie: ?*isize,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-l1-1-0" fn RoRevokeActivationFactories(
cookie: isize,
) callconv(@import("std").os.windows.WINAPI) void;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-l1-1-0" fn RoGetActivationFactory(
activatableClassId: ?HSTRING,
iid: ?*const Guid,
factory: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-l1-1-0" fn RoRegisterForApartmentShutdown(
callbackObject: ?*IApartmentShutdown,
apartmentIdentifier: ?*u64,
regCookie: ?*APARTMENT_SHUTDOWN_REGISTRATION_COOKIE,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-l1-1-0" fn RoUnregisterForApartmentShutdown(
regCookie: APARTMENT_SHUTDOWN_REGISTRATION_COOKIE,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-l1-1-0" fn RoGetApartmentIdentifier(
apartmentIdentifier: ?*u64,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-robuffer-l1-1-0" fn RoGetBufferMarshaler(
bufferMarshaler: ?*?*IMarshal,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-error-l1-1-0" fn RoGetErrorReportingFlags(
pflags: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-error-l1-1-0" fn RoSetErrorReportingFlags(
flags: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-error-l1-1-0" fn RoResolveRestrictedErrorInfoReference(
reference: ?[*:0]const u16,
ppRestrictedErrorInfo: ?*?*IRestrictedErrorInfo,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-error-l1-1-0" fn SetRestrictedErrorInfo(
pRestrictedErrorInfo: ?*IRestrictedErrorInfo,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-error-l1-1-0" fn GetRestrictedErrorInfo(
ppRestrictedErrorInfo: ?*?*IRestrictedErrorInfo,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-error-l1-1-0" fn RoOriginateErrorW(
@"error": HRESULT,
cchMax: u32,
message: ?*[512]u16,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-error-l1-1-0" fn RoOriginateError(
@"error": HRESULT,
message: ?HSTRING,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-error-l1-1-0" fn RoTransformErrorW(
oldError: HRESULT,
newError: HRESULT,
cchMax: u32,
message: ?*[512]u16,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-error-l1-1-0" fn RoTransformError(
oldError: HRESULT,
newError: HRESULT,
message: ?HSTRING,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-error-l1-1-0" fn RoCaptureErrorContext(
hr: HRESULT,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-error-l1-1-0" fn RoFailFastWithErrorContext(
hrError: HRESULT,
) callconv(@import("std").os.windows.WINAPI) void;
// TODO: this type is limited to platform 'windows8.1'
pub extern "api-ms-win-core-winrt-error-l1-1-1" fn RoOriginateLanguageException(
@"error": HRESULT,
message: ?HSTRING,
languageException: ?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.1'
pub extern "api-ms-win-core-winrt-error-l1-1-1" fn RoClearError(
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "api-ms-win-core-winrt-error-l1-1-1" fn RoReportUnhandledError(
pRestrictedErrorInfo: ?*IRestrictedErrorInfo,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.1'
pub extern "api-ms-win-core-winrt-error-l1-1-1" fn RoInspectThreadErrorInfo(
targetTebAddress: usize,
machine: u16,
readMemoryCallback: ?PINSPECT_MEMORY_CALLBACK,
context: ?*anyopaque,
targetErrorInfoAddress: ?*usize,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.1'
pub extern "api-ms-win-core-winrt-error-l1-1-1" fn RoInspectCapturedStackBackTrace(
targetErrorInfoAddress: usize,
machine: u16,
readMemoryCallback: ?PINSPECT_MEMORY_CALLBACK,
context: ?*anyopaque,
frameCount: ?*u32,
targetBackTraceAddress: ?*usize,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "api-ms-win-core-winrt-error-l1-1-1" fn RoGetMatchingRestrictedErrorInfo(
hrIn: HRESULT,
ppRestrictedErrorInfo: ?*?*IRestrictedErrorInfo,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "api-ms-win-core-winrt-error-l1-1-1" fn RoReportFailedDelegate(
punkDelegate: ?*IUnknown,
pRestrictedErrorInfo: ?*IRestrictedErrorInfo,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-error-l1-1-1" fn IsErrorPropagationEnabled(
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "RoMetadata" fn MetaDataGetDispenser(
rclsid: ?*const Guid,
riid: ?*const Guid,
ppv: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-roparameterizediid-l1-1-0" fn RoGetParameterizedTypeInstanceIID(
nameElementCount: u32,
nameElements: [*]?PWSTR,
metaDataLocator: ?*IRoMetaDataLocator,
iid: ?*Guid,
pExtra: ?*ROPARAMIIDHANDLE,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-roparameterizediid-l1-1-0" fn RoFreeParameterizedTypeExtra(
extra: ROPARAMIIDHANDLE,
) callconv(@import("std").os.windows.WINAPI) void;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-roparameterizediid-l1-1-0" fn RoParameterizedTypeExtraGetTypeSignature(
extra: ROPARAMIIDHANDLE,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-core-winrt-registration-l1-1-0" fn RoGetServerActivatableClasses(
serverName: ?HSTRING,
activatableClassIds: ?*?*?HSTRING,
count: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-shcore-stream-winrt-l1-1-0" fn CreateRandomAccessStreamOnFile(
filePath: ?[*:0]const u16,
accessMode: u32,
riid: ?*const Guid,
ppv: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-shcore-stream-winrt-l1-1-0" fn CreateRandomAccessStreamOverStream(
stream: ?*IStream,
options: BSOS_OPTIONS,
riid: ?*const Guid,
ppv: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "api-ms-win-shcore-stream-winrt-l1-1-0" fn CreateStreamOverRandomAccessStream(
randomAccessStream: ?*IUnknown,
riid: ?*const Guid,
ppv: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
//--------------------------------------------------------------------------------
// Section: Unicode Aliases (0)
//--------------------------------------------------------------------------------
const thismodule = @This();
pub usingnamespace switch (@import("../zig.zig").unicode_mode) {
.ansi => struct {
},
.wide => struct {
},
.unspecified => if (@import("builtin").is_test) struct {
} else struct {
},
};
//--------------------------------------------------------------------------------
// Section: Imports (12)
//--------------------------------------------------------------------------------
const Guid = @import("../zig.zig").Guid;
const BOOL = @import("../foundation.zig").BOOL;
const BSTR = @import("../foundation.zig").BSTR;
const CHAR = @import("../foundation.zig").CHAR;
const HRESULT = @import("../foundation.zig").HRESULT;
const HWND = @import("../foundation.zig").HWND;
const IMarshal = @import("../system/com/marshal.zig").IMarshal;
const INamedPropertyStore = @import("../ui/shell/properties_system.zig").INamedPropertyStore;
const IStream = @import("../system/com.zig").IStream;
const IUnknown = @import("../system/com.zig").IUnknown;
const PSTR = @import("../foundation.zig").PSTR;
const PWSTR = @import("../foundation.zig").PWSTR;
test {
// The following '_ = <FuncPtrType>' lines are a workaround for https://github.com/ziglang/zig/issues/4476
if (@hasDecl(@This(), "PINSPECT_HSTRING_CALLBACK")) { _ = PINSPECT_HSTRING_CALLBACK; }
if (@hasDecl(@This(), "PINSPECT_HSTRING_CALLBACK2")) { _ = PINSPECT_HSTRING_CALLBACK2; }
if (@hasDecl(@This(), "PINSPECT_MEMORY_CALLBACK")) { _ = PINSPECT_MEMORY_CALLBACK; }
@setEvalBranchQuota(
@import("std").meta.declarations(@This()).len * 3
);
// reference all the pub declarations
if (!@import("builtin").is_test) return;
inline for (@import("std").meta.declarations(@This())) |decl| {
if (decl.is_pub) {
_ = decl;
}
}
}
//--------------------------------------------------------------------------------
// Section: SubModules (15)
//--------------------------------------------------------------------------------
pub const all_joyn = @import("win_rt/all_joyn.zig");
pub const composition = @import("win_rt/composition.zig");
pub const core_input_view = @import("win_rt/core_input_view.zig");
pub const direct3d11 = @import("win_rt/direct3d11.zig");
pub const display = @import("win_rt/display.zig");
pub const graphics = @import("win_rt/graphics.zig");
pub const holographic = @import("win_rt/holographic.zig");
pub const isolation = @import("win_rt/isolation.zig");
pub const media = @import("win_rt/media.zig");
pub const ml = @import("win_rt/ml.zig");
pub const pdf = @import("win_rt/pdf.zig");
pub const printing = @import("win_rt/printing.zig");
pub const shell = @import("win_rt/shell.zig");
pub const storage = @import("win_rt/storage.zig");
pub const xaml = @import("win_rt/xaml.zig");
|
win32/system/win_rt.zig
|
const sg = @import("gfx.zig");
// helper function to convert "anything" to a Range struct
pub fn asRange(val: anytype) Range {
const type_info = @typeInfo(@TypeOf(val));
switch (type_info) {
.Pointer => {
switch (type_info.Pointer.size) {
.One => return .{ .ptr = val, .size = @sizeOf(type_info.Pointer.child) },
.Slice => return .{ .ptr = val.ptr, .size = @sizeOf(type_info.Pointer.child) * val.len },
else => @compileError("FIXME: Pointer type!"),
}
},
.Struct, .Array => {
return .{ .ptr = &val, .size = @sizeOf(@TypeOf(val)) };
},
else => {
@compileError("Cannot convert to range!");
}
}
}
// std.fmt compatible Writer
pub const Writer = struct {
pub const Error = error { };
pub fn writeAll(self: Writer, bytes: []const u8) Error!void {
for (bytes) |byte| {
putc(byte);
}
}
pub fn writeByteNTimes(self: Writer, byte: u8, n: u64) Error!void {
var i: u64 = 0;
while (i < n): (i += 1) {
putc(byte);
}
}
};
// std.fmt-style formatted print
pub fn print(comptime fmt: anytype, args: anytype) void {
var writer: Writer = .{};
@import("std").fmt.format(writer, fmt, args) catch {};
}
pub const Context = extern struct {
id: u32 = 0,
};
pub const Range = extern struct {
ptr: ?*const c_void = null,
size: usize = 0,
};
pub const FontDesc = extern struct {
data: Range = .{ },
first_char: u8 = 0,
last_char: u8 = 0,
};
pub const ContextDesc = extern struct {
char_buf_size: u32 = 0,
canvas_width: f32 = 0.0,
canvas_height: f32 = 0.0,
tab_width: i32 = 0,
color_format: sg.PixelFormat = .DEFAULT,
depth_format: sg.PixelFormat = .DEFAULT,
sample_count: i32 = 0,
};
pub const Desc = extern struct {
context_pool_size: u32 = 0,
printf_buf_size: u32 = 0,
fonts: [8]FontDesc = [_]FontDesc{.{}} ** 8,
context: ContextDesc = .{ },
};
pub extern fn sdtx_setup([*c]const Desc) void;
pub inline fn setup(desc: Desc) void {
sdtx_setup(&desc);
}
pub extern fn sdtx_shutdown() void;
pub inline fn shutdown() void {
sdtx_shutdown();
}
pub extern fn sdtx_font_kc853() FontDesc;
pub inline fn fontKc853() FontDesc {
return sdtx_font_kc853();
}
pub extern fn sdtx_font_kc854() FontDesc;
pub inline fn fontKc854() FontDesc {
return sdtx_font_kc854();
}
pub extern fn sdtx_font_z1013() FontDesc;
pub inline fn fontZ1013() FontDesc {
return sdtx_font_z1013();
}
pub extern fn sdtx_font_cpc() FontDesc;
pub inline fn fontCpc() FontDesc {
return sdtx_font_cpc();
}
pub extern fn sdtx_font_c64() FontDesc;
pub inline fn fontC64() FontDesc {
return sdtx_font_c64();
}
pub extern fn sdtx_font_oric() FontDesc;
pub inline fn fontOric() FontDesc {
return sdtx_font_oric();
}
pub extern fn sdtx_make_context([*c]const ContextDesc) Context;
pub inline fn makeContext(desc: ContextDesc) Context {
return sdtx_make_context(&desc);
}
pub extern fn sdtx_destroy_context(Context) void;
pub inline fn destroyContext(ctx: Context) void {
sdtx_destroy_context(ctx);
}
pub extern fn sdtx_set_context(Context) void;
pub inline fn setContext(ctx: Context) void {
sdtx_set_context(ctx);
}
pub extern fn sdtx_get_context() Context;
pub inline fn getContext() Context {
return sdtx_get_context();
}
pub extern fn sdtx_draw() void;
pub inline fn draw() void {
sdtx_draw();
}
pub extern fn sdtx_font(u32) void;
pub inline fn font(font_index: u32) void {
sdtx_font(font_index);
}
pub extern fn sdtx_canvas(f32, f32) void;
pub inline fn canvas(w: f32, h: f32) void {
sdtx_canvas(w, h);
}
pub extern fn sdtx_origin(f32, f32) void;
pub inline fn origin(x: f32, y: f32) void {
sdtx_origin(x, y);
}
pub extern fn sdtx_home() void;
pub inline fn home() void {
sdtx_home();
}
pub extern fn sdtx_pos(f32, f32) void;
pub inline fn pos(x: f32, y: f32) void {
sdtx_pos(x, y);
}
pub extern fn sdtx_pos_x(f32) void;
pub inline fn posX(x: f32) void {
sdtx_pos_x(x);
}
pub extern fn sdtx_pos_y(f32) void;
pub inline fn posY(y: f32) void {
sdtx_pos_y(y);
}
pub extern fn sdtx_move(f32, f32) void;
pub inline fn move(dx: f32, dy: f32) void {
sdtx_move(dx, dy);
}
pub extern fn sdtx_move_x(f32) void;
pub inline fn moveX(dx: f32) void {
sdtx_move_x(dx);
}
pub extern fn sdtx_move_y(f32) void;
pub inline fn moveY(dy: f32) void {
sdtx_move_y(dy);
}
pub extern fn sdtx_crlf() void;
pub inline fn crlf() void {
sdtx_crlf();
}
pub extern fn sdtx_color3b(u8, u8, u8) void;
pub inline fn color3b(r: u8, g: u8, b: u8) void {
sdtx_color3b(r, g, b);
}
pub extern fn sdtx_color3f(f32, f32, f32) void;
pub inline fn color3f(r: f32, g: f32, b: f32) void {
sdtx_color3f(r, g, b);
}
pub extern fn sdtx_color4b(u8, u8, u8, u8) void;
pub inline fn color4b(r: u8, g: u8, b: u8, a: u8) void {
sdtx_color4b(r, g, b, a);
}
pub extern fn sdtx_color4f(f32, f32, f32, f32) void;
pub inline fn color4f(r: f32, g: f32, b: f32, a: f32) void {
sdtx_color4f(r, g, b, a);
}
pub extern fn sdtx_color1i(u32) void;
pub inline fn color1i(rgba: u32) void {
sdtx_color1i(rgba);
}
pub extern fn sdtx_putc(u8) void;
pub inline fn putc(c: u8) void {
sdtx_putc(c);
}
pub extern fn sdtx_puts([*c]const u8) void;
pub inline fn puts(str: [:0]const u8) void {
sdtx_puts(@ptrCast([*c]const u8,str));
}
pub extern fn sdtx_putr([*c]const u8, u32) void;
pub inline fn putr(str: [:0]const u8, len: u32) void {
sdtx_putr(@ptrCast([*c]const u8,str), len);
}
|
src/sokol/debugtext.zig
|
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const File = std.fs.File;
const bufferedWriter = std.io.bufferedWriter;
const Linenoise = @import("main.zig").Linenoise;
const History = @import("history.zig").History;
const unicode = @import("unicode.zig");
const width = unicode.width;
const term = @import("term.zig");
const getColumns = term.getColumns;
const key_tab = 9;
const key_esc = 27;
pub const LinenoiseState = struct {
allocator: *Allocator,
ln: *Linenoise,
stdin: File,
stdout: File,
buf: ArrayList(u8),
prompt: []const u8,
pos: usize,
old_pos: usize,
size: usize,
cols: usize,
max_rows: usize,
const Self = @This();
pub fn init(ln: *Linenoise, in: File, out: File, prompt: []const u8) Self {
return Self{
.allocator = ln.allocator,
.ln = ln,
.stdin = in,
.stdout = out,
.prompt = prompt,
.buf = ArrayList(u8).init(ln.allocator),
.pos = 0,
.old_pos = 0,
.size = 0,
.cols = getColumns(in, out),
.max_rows = 0,
};
}
pub fn clearScreen(self: *Self) !void {
try self.stdout.writeAll("\x1b[H\x1b[2J");
try self.refreshLine();
}
pub fn beep(self: *Self) !void {
const stderr = std.io.getStdErr();
try stderr.writeAll("\x07");
}
pub fn browseCompletions(self: *Self) !?u8 {
var input_buf: [1]u8 = undefined;
var c: ?u8 = null;
const fun = self.ln.completions_callback orelse return null;
const completions = try fun(self.allocator, self.buf.items);
defer {
for (completions) |x| self.allocator.free(x);
self.allocator.free(completions);
}
if (completions.len == 0) {
try self.beep();
} else {
var finished = false;
var i: usize = 0;
while (!finished) {
if (i < completions.len) {
// Change to completion nr. i
// First, save buffer so we can restore it later
const old_buf_allocator = self.buf.allocator;
const old_buf = self.buf.toOwnedSlice();
const old_pos = self.pos;
// Show suggested completion
self.buf.deinit();
self.buf = ArrayList(u8).init(old_buf_allocator);
try self.buf.appendSlice(completions[i]);
self.pos = self.buf.items.len;
try self.refreshLine();
// Restore original buffer into state
self.buf.deinit();
self.buf = ArrayList(u8).fromOwnedSlice(old_buf_allocator, old_buf);
self.pos = old_pos;
} else {
// Return to original line
try self.refreshLine();
}
// Read next key
const nread = try self.stdin.read(&input_buf);
c = if (nread == 1) input_buf[0] else return error.NothingRead;
switch (c.?) {
key_tab => {
// Next completion
i = (i + 1) % (completions.len + 1);
if (i == completions.len) try self.beep();
},
key_esc => {
// Stop browsing completions, return to buffer displayed
// prior to browsing completions
if (i < completions.len) try self.refreshLine();
finished = true;
},
else => {
// Stop browsing completions, potentially use suggested
// completion
if (i < completions.len) {
// Replace buffer with text in the selected
// completion
const old_buf_allocator = self.buf.allocator;
self.buf.deinit();
self.buf = ArrayList(u8).init(old_buf_allocator);
try self.buf.appendSlice(completions[i]);
self.pos = self.buf.items.len;
}
finished = true;
},
}
}
}
return c;
}
fn getHint(self: *Self) !?[]const u8 {
if (self.ln.hints_callback) |fun| {
return try fun(self.allocator, self.buf.items);
}
return null;
}
fn refreshSingleLine(self: *Self) !void {
var buf = bufferedWriter(self.stdout.writer());
var writer = buf.writer();
const hint = try self.getHint();
defer if (hint) |str| self.allocator.free(str);
// Trim buffer if it is too long
const prompt_width = width(self.prompt);
const hint_width = if (hint) |str| width(str) else 0;
const avail_space = self.cols - prompt_width - hint_width - 1;
const start = if (self.pos > avail_space) self.pos - avail_space else 0;
const end = if (start + avail_space < self.buf.items.len) start + avail_space else self.buf.items.len;
const trimmed_buf = self.buf.items[start..end];
// Move cursor to left edge
try writer.writeAll("\r");
// Write prompt
try writer.writeAll(self.prompt);
// Write current buffer content
if (self.ln.mask_mode) {
for (trimmed_buf) |_| {
try writer.writeAll("*");
}
} else {
try writer.writeAll(trimmed_buf);
}
// Show hints
if (hint) |str| {
try writer.writeAll(str);
}
// Erase to the right
try writer.writeAll("\x1b[0K");
// Move cursor to original position
const pos = if (self.pos > avail_space) self.cols - hint_width - 1 else prompt_width + self.pos;
try writer.print("\r\x1b[{}C", .{pos});
// Write buffer
try buf.flush();
}
fn refreshMultiLine(self: *Self) !void {
var buf = bufferedWriter(self.stdout.writer());
var writer = buf.writer();
const hint = try self.getHint();
defer if (hint) |str| self.allocator.free(str);
const prompt_width = width(self.prompt);
const hint_width = if (hint) |str| width(str) else 0;
const total_width = prompt_width + self.buf.items.len + hint_width;
var rows = (total_width + self.cols - 1) / self.cols;
var rpos = (prompt_width + self.old_pos + self.cols) / self.cols;
const old_rows = self.max_rows;
if (rows > self.max_rows) {
self.max_rows = rows;
}
// Go to the last row
if (old_rows > rpos) {
try writer.print("\x1B[{}B", .{old_rows - rpos});
}
// Clear every row
if (old_rows > 0) {
var j: usize = 0;
while (j < old_rows - 1) : (j += 1) {
try writer.writeAll("\r\x1B[0K\x1B[1A");
}
}
// Clear the top line
try writer.writeAll("\r\x1B[0K");
// Write prompt
try writer.writeAll(self.prompt);
// Write current buffer content
if (self.ln.mask_mode) {
for (self.buf.items) |_| {
try writer.writeAll("*");
}
} else {
try writer.writeAll(self.buf.items);
}
// Show hints if applicable
if (hint) |str| {
try writer.writeAll(str);
}
// Reserve a newline if we filled all columns
if (self.pos > 0 and self.pos == self.buf.items.len and total_width % self.cols == 0) {
try writer.writeAll("\n\r");
rows += 1;
if (rows > self.max_rows) {
self.max_rows = rows;
}
}
// Move cursor to right position:
const rpos2 = (prompt_width + self.pos + self.cols) / self.cols;
// First, y position
if (rows > rpos2) {
try writer.print("\x1B[{}A", .{rows - rpos2});
}
// Then, x position
const col = (prompt_width + self.pos) % self.cols;
if (col > 0) {
try writer.print("\r\x1B[{}C", .{col});
} else {
try writer.writeAll("\r");
}
self.old_pos = self.pos;
try buf.flush();
}
pub fn refreshLine(self: *Self) !void {
if (self.ln.multiline_mode) {
try self.refreshMultiLine();
} else {
try self.refreshSingleLine();
}
}
pub fn editInsert(self: *Self, c: []const u8) !void {
try self.buf.resize(self.buf.items.len + c.len);
if (self.buf.items.len > 0 and self.pos < self.buf.items.len - c.len) {
std.mem.copyBackwards(
u8,
self.buf.items[self.pos + c.len .. self.buf.items.len],
self.buf.items[self.pos .. self.buf.items.len - c.len],
);
}
std.mem.copy(
u8,
self.buf.items[self.pos .. self.pos + c.len],
c,
);
self.pos += c.len;
try self.refreshLine();
}
fn prevCodepointLen(self: *Self, pos: usize) usize {
if (pos >= 1 and @clz(u8, ~self.buf.items[pos - 1]) == 0) {
return 1;
} else if (pos >= 2 and @clz(u8, ~self.buf.items[pos - 2]) == 2) {
return 2;
} else if (pos >= 3 and @clz(u8, ~self.buf.items[pos - 3]) == 3) {
return 3;
} else if (pos >= 4 and @clz(u8, ~self.buf.items[pos - 4]) == 4) {
return 4;
} else {
return 0;
}
}
pub fn editMoveLeft(self: *Self) !void {
if (self.pos == 0) return;
self.pos -= self.prevCodepointLen(self.pos);
try self.refreshLine();
}
pub fn editMoveRight(self: *Self) !void {
if (self.pos < self.buf.items.len) {
const utf8_len = std.unicode.utf8CodepointSequenceLength(self.buf.items[self.pos]) catch 1;
self.pos += utf8_len;
try self.refreshLine();
}
}
pub fn editMoveWordEnd(self: *Self) !void {
if (self.pos < self.buf.items.len) {
while (self.pos < self.buf.items.len and self.buf.items[self.pos] == ' ')
self.pos += 1;
while (self.pos < self.buf.items.len and self.buf.items[self.pos] != ' ')
self.pos += 1;
try self.refreshLine();
}
}
pub fn editMoveWordStart(self: *Self) !void {
if (self.buf.items.len > 0 and self.pos > 0) {
while (self.pos > 0 and self.buf.items[self.pos - 1] == ' ')
self.pos -= 1;
while (self.pos > 0 and self.buf.items[self.pos - 1] != ' ')
self.pos -= 1;
try self.refreshLine();
}
}
pub fn editMoveHome(self: *Self) !void {
if (self.pos > 0) {
self.pos = 0;
try self.refreshLine();
}
}
pub fn editMoveEnd(self: *Self) !void {
if (self.pos < self.buf.items.len) {
self.pos = self.buf.items.len;
try self.refreshLine();
}
}
pub const HistoryDirection = enum {
next,
prev,
};
pub fn editHistoryNext(self: *Self, dir: HistoryDirection) !void {
if (self.ln.history.hist.items.len > 0) {
// Update the current history with the current line
const old_index = self.ln.history.current;
const current_entry = self.ln.history.hist.items[old_index];
self.ln.history.allocator.free(current_entry);
self.ln.history.hist.items[old_index] = try self.ln.history.allocator.dupe(u8, self.buf.items);
// Update history index
const new_index = switch (dir) {
.next => if (old_index < self.ln.history.hist.items.len - 1) old_index + 1 else self.ln.history.hist.items.len - 1,
.prev => if (old_index > 0) old_index - 1 else 0,
};
self.ln.history.current = new_index;
// Copy history entry to the current line buffer
self.buf.deinit();
self.buf = ArrayList(u8).init(self.allocator);
try self.buf.appendSlice(self.ln.history.hist.items[new_index]);
self.pos = self.buf.items.len;
try self.refreshLine();
}
}
pub fn editDelete(self: *Self) !void {
if (self.buf.items.len > 0 and self.pos < self.buf.items.len) {
const utf8_len = std.unicode.utf8CodepointSequenceLength(self.buf.items[self.pos]) catch 1;
std.mem.copy(u8, self.buf.items[self.pos..], self.buf.items[self.pos + utf8_len ..]);
try self.buf.resize(self.buf.items.len - utf8_len);
try self.refreshLine();
}
}
pub fn editBackspace(self: *Self) !void {
if (self.buf.items.len == 0 or self.pos == 0) return;
const len = self.prevCodepointLen(self.pos);
std.mem.copy(u8, self.buf.items[self.pos - len ..], self.buf.items[self.pos..]);
self.pos -= len;
try self.buf.resize(self.buf.items.len - len);
try self.refreshLine();
}
pub fn editSwapPrev(self: *Self) !void {
const prev_len = self.prevCodepointLen(self.pos);
const prevprev_len = self.prevCodepointLen(self.pos - prev_len);
if (prev_len == 0 or prevprev_len == 0) return;
var tmp: [4]u8 = undefined;
std.mem.copy(u8, &tmp, self.buf.items[self.pos - (prev_len + prevprev_len) .. self.pos - prev_len]);
std.mem.copy(u8, self.buf.items[self.pos - (prev_len + prevprev_len) ..], self.buf.items[self.pos - prev_len .. self.pos]);
std.mem.copy(u8, self.buf.items[self.pos - prevprev_len ..], tmp[0..prevprev_len]);
try self.refreshLine();
}
pub fn editDeletePrevWord(self: *Self) !void {
if (self.buf.items.len > 0 and self.pos > 0) {
const old_pos = self.pos;
while (self.pos > 0 and self.buf.items[self.pos - 1] == ' ')
self.pos -= 1;
while (self.pos > 0 and self.buf.items[self.pos - 1] != ' ')
self.pos -= 1;
const diff = old_pos - self.pos;
const new_len = self.buf.items.len - diff;
std.mem.copy(u8, self.buf.items[self.pos..new_len], self.buf.items[old_pos..]);
try self.buf.resize(new_len);
try self.refreshLine();
}
}
pub fn editKillLineForward(self: *Self) !void {
try self.buf.resize(self.pos);
try self.refreshLine();
}
pub fn editKillLineBackward(self: *Self) !void {
const new_len = self.buf.items.len - self.pos;
std.mem.copy(u8, self.buf.items, self.buf.items[self.pos..]);
self.pos = 0;
try self.buf.resize(new_len);
try self.refreshLine();
}
};
|
src/state.zig
|
const std = @import("index.zig");
const io = std.io;
const DefaultPrng = std.rand.DefaultPrng;
const assert = std.debug.assert;
const assertError = std.debug.assertError;
const mem = std.mem;
const os = std.os;
const builtin = @import("builtin");
test "write a file, read it, then delete it" {
var raw_bytes: [200 * 1024]u8 = undefined;
var allocator = &std.heap.FixedBufferAllocator.init(raw_bytes[0..]).allocator;
var data: [1024]u8 = undefined;
var prng = DefaultPrng.init(1234);
prng.random.bytes(data[0..]);
const tmp_file_name = "temp_test_file.txt";
{
var file = try os.File.openWrite(tmp_file_name);
defer file.close();
var file_out_stream = file.outStream();
var buf_stream = io.BufferedOutStream(os.File.WriteError).init(&file_out_stream.stream);
const st = &buf_stream.stream;
try st.print("begin");
try st.write(data[0..]);
try st.print("end");
try buf_stream.flush();
}
{
var file = try os.File.openRead(tmp_file_name);
defer file.close();
const file_size = try file.getEndPos();
const expected_file_size = "begin".len + data.len + "end".len;
assert(file_size == expected_file_size);
var file_in_stream = file.inStream();
var buf_stream = io.BufferedInStream(os.File.ReadError).init(&file_in_stream.stream);
const st = &buf_stream.stream;
const contents = try st.readAllAlloc(allocator, 2 * 1024);
defer allocator.free(contents);
assert(mem.eql(u8, contents[0.."begin".len], "begin"));
assert(mem.eql(u8, contents["begin".len .. contents.len - "end".len], data));
assert(mem.eql(u8, contents[contents.len - "end".len ..], "end"));
}
try os.deleteFile(tmp_file_name);
}
test "BufferOutStream" {
var bytes: [100]u8 = undefined;
var allocator = &std.heap.FixedBufferAllocator.init(bytes[0..]).allocator;
var buffer = try std.Buffer.initSize(allocator, 0);
var buf_stream = &std.io.BufferOutStream.init(&buffer).stream;
const x: i32 = 42;
const y: i32 = 1234;
try buf_stream.print("x: {}\ny: {}\n", x, y);
assert(mem.eql(u8, buffer.toSlice(), "x: 42\ny: 1234\n"));
}
test "SliceInStream" {
const bytes = []const u8{ 1, 2, 3, 4, 5, 6, 7 };
var ss = io.SliceInStream.init(bytes);
var dest: [4]u8 = undefined;
var read = try ss.stream.read(dest[0..4]);
assert(read == 4);
assert(mem.eql(u8, dest[0..4], bytes[0..4]));
read = try ss.stream.read(dest[0..4]);
assert(read == 3);
assert(mem.eql(u8, dest[0..3], bytes[4..7]));
read = try ss.stream.read(dest[0..4]);
assert(read == 0);
}
test "PeekStream" {
const bytes = []const u8{ 1, 2, 3, 4, 5, 6, 7, 8 };
var ss = io.SliceInStream.init(bytes);
var ps = io.PeekStream(2, io.SliceInStream.Error).init(&ss.stream);
var dest: [4]u8 = undefined;
ps.putBackByte(9);
ps.putBackByte(10);
var read = try ps.stream.read(dest[0..4]);
assert(read == 4);
assert(dest[0] == 10);
assert(dest[1] == 9);
assert(mem.eql(u8, dest[2..4], bytes[0..2]));
read = try ps.stream.read(dest[0..4]);
assert(read == 4);
assert(mem.eql(u8, dest[0..4], bytes[2..6]));
read = try ps.stream.read(dest[0..4]);
assert(read == 2);
assert(mem.eql(u8, dest[0..2], bytes[6..8]));
ps.putBackByte(11);
ps.putBackByte(12);
read = try ps.stream.read(dest[0..4]);
assert(read == 2);
assert(dest[0] == 12);
assert(dest[1] == 11);
}
test "SliceOutStream" {
var buffer: [10]u8 = undefined;
var ss = io.SliceOutStream.init(buffer[0..]);
try ss.stream.write("Hello");
assert(mem.eql(u8, ss.getWritten(), "Hello"));
try ss.stream.write("world");
assert(mem.eql(u8, ss.getWritten(), "Helloworld"));
assertError(ss.stream.write("!"), error.OutOfSpace);
assert(mem.eql(u8, ss.getWritten(), "Helloworld"));
ss.reset();
assert(ss.getWritten().len == 0);
assertError(ss.stream.write("Hello world!"), error.OutOfSpace);
assert(mem.eql(u8, ss.getWritten(), "Hello worl"));
}
|
std/io_test.zig
|
const std = @import("std");
const fs = std.fs;
const log = std.log;
const allocator = std.heap.c_allocator;
const c = @import("c.zig");
// Consts
const rgb_space: u32 = 16777216;
const conflict_lookup = [_][7]u8{
[_]u8{ 1, 4, 5, 2, 3, 6, 7 },
[_]u8{ 0, 5, 4, 3, 2, 7, 6 },
[_]u8{ 3, 6, 7, 0, 1, 4, 5 },
[_]u8{ 2, 7, 6, 1, 0, 5, 4 },
[_]u8{ 5, 0, 1, 6, 7, 2, 3 },
[_]u8{ 4, 1, 0, 7, 6, 3, 2 },
[_]u8{ 7, 2, 3, 4, 5, 0, 1 },
[_]u8{ 6, 3, 2, 5, 4, 1, 0 },
};
// Structs
const Octree = struct {
refs: u32,
children: [8]?*Octree,
};
const Image = struct {
nchannels: u32,
pngcolortype: c.LodePNGColorType,
bitdepth: c_uint,
w: c_uint = undefined,
h: c_uint = undefined,
data: ?[*]u8 = undefined,
};
const Color = struct {
r: u8 = 0,
g: u8 = 0,
b: u8 = 0,
a: u8 = 255,
pub fn getStep(self: *Color, i: u3) u8 {
const mask: u8 = std.math.pow(u8, 2, i);
return (((self.r & mask) >> i) << 2) +
(((self.g & mask) >> i) << 1) +
((self.b & mask) >> i);
}
pub fn setStep(self: *Color, step: u8, i: u3) void {
const mask = @intCast(u8, 1) << i;
// red
const r_bit = ((step & 4) >> 2);
if (r_bit == 1) { // set
self.r |= mask;
} else { // clear
self.r &= ~mask;
}
// green
const g_bit = ((step & 2) >> 1);
if (g_bit == 1) { // set
self.g |= mask;
} else { // clear
self.g &= ~mask;
}
// blue
const b_bit = (step & 1);
if (b_bit == 1) { // set
self.b |= mask;
} else { // clear
self.b &= ~mask;
}
}
};
fn fillTree(n: *Octree, cnt: u32, allocator_inner: *std.mem.Allocator) void {
const next_cnt: u32 = cnt / 8;
var new_nodes: []Octree = allocator_inner.alloc(Octree, 8) catch {
log.crit("Alloc error", .{});
return;
};
var i: u8 = 0;
while (i < 8) : (i += 1) {
new_nodes[i].refs = next_cnt;
new_nodes[i].children = [8]?*Octree{ null, null, null, null, null, null, null, null };
n.children[i] = &new_nodes[i];
if (next_cnt > 0)
fillTree(&new_nodes[i], next_cnt, allocator_inner);
}
}
fn loadImage(filename: [*:0]const u8) Image {
var img = Image{
.nchannels = 4,
.pngcolortype = c.LodePNGColorType.LCT_RGBA,
.bitdepth = 8,
};
if (c.lodepng_decode_file(&img.data, &img.w, &img.h, filename, img.pngcolortype, img.bitdepth) != 0) {
log.err("Can't load the image {s}.", .{filename});
std.process.exit(1);
}
log.info("Loaded {}x{} image with {} channels", .{ img.w, img.h, img.nchannels });
if (img.w * img.h > rgb_space) {
log.err("The image has more pixels than the RGB space: {} > {}.", .{ img.w * img.h, rgb_space });
std.process.exit(1);
} else if (img.w * img.h < rgb_space) {
log.warn("The image has less pixels than the RGB space: {} < {}.", .{ img.w * img.h, rgb_space });
}
return img;
}
fn genIndexPermutation(color_n: u32, do_random: bool) []u32 {
// prepare shuffled indexes
var indexes = allocator.alloc(u32, color_n) catch {
log.crit("Memory alloc for indexes failed.", .{});
std.process.exit(1);
};
var i: u32 = 0;
while (i < indexes.len) : (i += 1)
indexes[i] = i;
// shuffle
if (do_random) {
// random number generator
var prng = std.rand.DefaultPrng.init(blk: {
var seed: u64 = undefined;
std.os.getrandom(std.mem.asBytes(&seed)) catch {
log.emerg("Os getRandom failed.", .{});
std.process.exit(1);
};
break :blk seed;
});
const rand = &prng.random;
i = 0;
while (i < indexes.len - 1) : (i += 1) {
const new_i: u32 = rand.intRangeLessThan(u32, i + 1, @intCast(u32, indexes.len));
const temp: u32 = indexes[i];
indexes[i] = indexes[new_i];
indexes[new_i] = temp;
}
log.info("Shuffled indexes", .{});
} else {
log.info("Indexes were not shuffled", .{});
}
return indexes;
}
fn getColorConflict0(curr_node: *Octree, sel_i: *u8, sel: **Octree) bool {
var found: bool = false;
const lookup_array: [7]u8 = conflict_lookup[sel_i.*];
var j: u8 = 0;
while (j < 8) : (j += 1) {
sel_i.* = lookup_array[j];
sel.* = curr_node.children[sel_i.*].?;
if (sel.*.refs > 0) {
found = true;
break;
}
}
return found;
}
fn redmean(c1: *Color, c2: *Color) f32 {
const c1r: f32 = @intToFloat(f32, c1.r);
const c1g: f32 = @intToFloat(f32, c1.g);
const c1b: f32 = @intToFloat(f32, c1.b);
const c2r: f32 = @intToFloat(f32, c2.r);
const c2g: f32 = @intToFloat(f32, c2.g);
const c2b: f32 = @intToFloat(f32, c2.b);
const rm: f32 = (c1r + c2r) / 2;
return std.math.sqrt((2 + rm / 256) * std.math.pow(f32, c2r - c1r, 2) +
4 * std.math.pow(f32, c2g - c1g, 2) +
(2 + (255 - rm) / 256) * std.math.pow(f32, c2b - c1b, 2));
}
fn getColorConflict1(curr_node: *Octree, color: *Color, i: u3, sel_i: *u8, sel: **Octree) bool {
var color_copy: Color = color.*;
var best_dist: ?f32 = null;
var found: bool = false;
var j: u8 = 0;
while (j < 8) : (j += 1) {
const child = curr_node.children[j].?;
if (child.refs == 0) continue;
color_copy.setStep(j, i);
const child_dist = redmean(color, &color_copy);
if (best_dist == null or best_dist.? > child_dist) {
found = true;
best_dist = child_dist;
sel_i.* = j;
sel.* = child;
}
}
return found;
}
fn getColor(root: *Octree, color: *Color, algorithm: i32) Color {
var curr_node: *Octree = root;
var ret = Color{ .a = color.a };
var i: i8 = 7;
while (i >= 0) : (i -= 1) {
if (curr_node.refs == 0) {
log.emerg("Color selection selected a repeated color. Aborting.", .{});
std.process.exit(1);
}
curr_node.refs -= 1;
var sel_i = color.getStep(@intCast(u3, i));
var sel: *Octree = curr_node.children[sel_i].?;
if (sel.refs == 0) {
switch (algorithm) {
0 => {
if (!getColorConflict0(curr_node, &sel_i, &sel))
log.crit("Something went wrong while selecting colors: no available colors. Will repeat a color.", .{});
},
1 => {
if (!getColorConflict1(curr_node, color, @intCast(u3, i), &sel_i, &sel))
log.crit("Something went wrong while selecting colors: no available colors. Will repeat a color.", .{});
},
else => {
log.emerg("Unknown algorithm.", .{});
std.process.exit(1);
},
}
}
ret.setStep(sel_i, @intCast(u3, i));
curr_node = sel;
}
// use selected leaf
if (curr_node.refs == 0) {
log.emerg("Color selection selected a repeated color. Aborting.", .{});
std.process.exit(1);
}
curr_node.refs -= 1;
return ret;
}
fn check(root_node: *Octree) u32 {
var ret: u32 = root_node.refs;
for (root_node.children) |child| {
if (child != null)
ret += check(child.?);
}
return ret;
}
fn convertImg(img: *Image, do_random: bool, algorithm: i32, do_check: bool, noise: f32) void {
// prepare octree
// TODO lazy allocations?
var root_node = Octree{
.refs = rgb_space,
.children = [8]?*Octree{ null, null, null, null, null, null, null, null },
};
var arena = std.heap.ArenaAllocator.init(allocator);
defer arena.deinit();
fillTree(&root_node, rgb_space, &arena.allocator);
log.info("Tree is done", .{});
// prepare shuffled indexes
const indexes = genIndexPermutation(img.w * img.h, do_random);
defer allocator.free(indexes);
// random number generator for noise
var prng = std.rand.DefaultPrng.init(blk: {
var seed: u64 = undefined;
std.os.getrandom(std.mem.asBytes(&seed)) catch {
log.emerg("Os getRandom failed.", .{});
std.process.exit(1);
};
break :blk seed;
});
const rand = &prng.random;
// convert image
log.info("Applying {}% noise to the image.", .{@floatToInt(u32, noise * 100)});
log.info("Using algorithm {} for color selection.", .{algorithm});
const noise2: f32 = noise * 2.0;
var i: u32 = 0;
while (i < indexes.len) : (i += 1) {
const ind: u32 = indexes[i] * img.nchannels;
var color = Color{
.r = img.data.?[ind],
.g = img.data.?[ind + 1],
.b = img.data.?[ind + 2],
.a = img.data.?[ind + 3], // ignored
};
if (noise > 0) { // adding noise to image produces better results
var new_r: f32 = @intToFloat(f32, color.r) * (1.0 + rand.float(f32) * noise2 - noise);
if (new_r < 0) {
new_r = 0;
} else if (new_r > 255) {
new_r = 255;
}
var new_g: f32 = @intToFloat(f32, color.g) * (1.0 + rand.float(f32) * noise2 - noise);
if (new_g < 0) {
new_g = 0;
} else if (new_g > 255) {
new_g = 255;
}
var new_b: f32 = @intToFloat(f32, color.b) * (1.0 + rand.float(f32) * noise2 - noise);
if (new_b < 0) {
new_b = 0;
} else if (new_b > 255) {
new_b = 255;
}
color.r = @floatToInt(u8, new_r);
color.g = @floatToInt(u8, new_g);
color.b = @floatToInt(u8, new_b);
}
color = getColor(&root_node, &color, algorithm);
img.data.?[ind] = color.r;
img.data.?[ind + 1] = color.g;
img.data.?[ind + 2] = color.b;
img.data.?[ind + 3] = color.a;
}
const used_colors: u32 = rgb_space - root_node.refs;
log.info("Used {} different colors", .{used_colors});
if (do_check) {
log.info("Checking...", .{});
log.info("Check returned {} refs.", .{check(&root_node)});
}
}
fn usage() void {
log.info("./allrgb [--no_random] [--slow] [--do_check] [--noise <int>] [-o <out.png>] <filename.png>", .{});
std.process.exit(1);
}
pub fn main() !void {
const proc_args = try std.process.argsAlloc(allocator);
const args = proc_args[1..];
if (args.len == 0) usage();
var filename: ?[*:0]const u8 = null;
var outfile: [*:0]const u8 = "out.png";
var do_random: bool = true;
var algorithm: i32 = 0;
var do_check: bool = false;
var noise: f32 = 0.10;
var arg_i: usize = 0;
while (arg_i < args.len) : (arg_i += 1) {
const arg = args[arg_i];
if (std.mem.eql(u8, arg, "--no_random")) {
do_random = false;
} else if (std.mem.eql(u8, arg, "-o")) {
arg_i += 1;
outfile = args[arg_i];
} else if (std.mem.eql(u8, arg, "--slow")) {
algorithm = 1;
} else if (std.mem.eql(u8, arg, "--do_check")) {
do_check = true;
} else if (std.mem.eql(u8, arg, "--noise")) {
arg_i += 1;
const parsed: c_long = c.strtol(args[arg_i], null, 10);
noise = @intToFloat(f32, parsed) / 100.0;
} else {
filename = arg;
}
}
if (filename == null) usage();
// load image
var img = loadImage(filename.?);
convertImg(&img, do_random, algorithm, do_check, noise);
log.info("Image is converted. Writting...", .{});
if (c.lodepng_encode_file(outfile, img.data, img.w, img.h, img.pngcolortype, img.bitdepth) != 0) {
log.crit("Failed to write img", .{});
}
}
|
src/allrgb.zig
|
const std = @import("std");
const upaya = @import("upaya");
const Item = struct {
/// copy of the data before it was modified
data: []u8 = undefined,
/// pointer to data
ptr: usize = undefined,
/// size in bytes
size: usize = undefined,
};
var history = struct {
undo: std.ArrayList(Item) = undefined,
redo: std.ArrayList(Item) = undefined,
temp: std.ArrayList(Item) = undefined,
pub fn init(self: *@This()) void {
self.undo = std.ArrayList(Item).init(upaya.mem.allocator);
self.redo = std.ArrayList(Item).init(upaya.mem.allocator);
self.temp = std.ArrayList(Item).init(upaya.mem.allocator);
}
pub fn deinit(self: @This()) void {
self.undo.deinit();
self.redo.deinit();
self.temp.deinit();
}
pub fn reset(self: *@This()) void {
for (self.undo.items) |item| {
if (item.size > 0) {
upaya.mem.allocator.free(item.data);
}
}
for (self.redo.items) |item| {
if (item.size > 0) {
upaya.mem.allocator.free(item.data);
}
}
for (self.temp.items) |item| {
if (item.size > 0) {
upaya.mem.allocator.free(item.data);
}
}
self.undo.items.len = 0;
self.redo.items.len = 0;
self.temp.items.len = 0;
}
}{};
pub fn init() void {
history.init();
}
pub fn deinit() void {
history.undo.deinit();
history.redo.deinit();
history.temp.deinit();
}
pub fn push(slice: []u8) void {
// see if we already have this pointer on our temp stack
for (history.temp.items) |temp| {
if (temp.ptr == @ptrToInt(slice.ptr)) return;
}
history.temp.append(.{
.data = std.mem.dupe(upaya.mem.allocator, u8, slice) catch unreachable,
.ptr = @ptrToInt(slice.ptr),
.size = slice.len,
}) catch unreachable;
}
pub fn commit() void {
var added_commit_boundary = false;
while (history.temp.popOrNull()) |item| {
var src = @intToPtr([*]u8, item.ptr);
if (std.mem.eql(u8, src[0..item.size], item.data)) {
upaya.mem.allocator.free(item.data);
} else {
if (!added_commit_boundary) {
history.undo.append(.{ .ptr = 0, .size = 0 }) catch unreachable;
added_commit_boundary = true;
}
history.undo.append(item) catch unreachable;
}
}
}
pub fn undo() void {
var added_commit_boundary = false;
var last_ptr: usize = 0;
while (history.undo.popOrNull()) |item| {
if (item.ptr == 0) {
break;
}
if (!added_commit_boundary) {
history.redo.append(.{ .ptr = 0, .size = 0 }) catch unreachable;
added_commit_boundary = true;
}
var dst = @intToPtr([*]u8, item.ptr);
// dupe the data currently in the pointer and copy it to our Item so that we can use it for a redo later
const tmp = std.mem.dupe(upaya.mem.tmp_allocator, u8, dst[0..item.size]) catch unreachable;
std.mem.copy(u8, dst[0..item.size], item.data);
std.mem.copy(u8, item.data, tmp);
history.redo.append(item) catch unreachable;
}
}
pub fn redo() void {
var added_commit_boundary = false;
while (history.redo.popOrNull()) |item| {
if (item.ptr == 0) {
return;
}
if (!added_commit_boundary) {
history.undo.append(.{ .ptr = 0, .size = 0 }) catch unreachable;
added_commit_boundary = true;
}
var dst = @intToPtr([*]u8, item.ptr);
// dupe the data currently in the pointer and copy it to our Item so that we can use it for a undo later
const tmp = std.mem.dupe(upaya.mem.tmp_allocator, u8, dst[0..item.size]) catch unreachable;
std.mem.copy(u8, dst[0..item.size], item.data);
std.mem.copy(u8, item.data, tmp);
history.undo.append(item) catch unreachable;
}
}
pub fn reset() void {
history.reset();
}
|
tilescript/history.zig
|
const std = @import("std");
const Allocator = std.mem.Allocator;
pub const UrlError = error {
EmptyString,
MissingScheme,
InvalidPort,
TooLong
};
pub const Url = struct {
scheme: []const u8,
host: []const u8,
port: ?u16,
path: []const u8,
query: ?[]const u8,
allocator: ?*Allocator = null,
const MAX_LENGTH = 1024;
pub fn parse(text: []const u8) !Url {
const schemePos = std.mem.indexOf(u8, text, "://") orelse return UrlError.MissingScheme;
if (schemePos == 0) return UrlError.MissingScheme;
const scheme = text[0..schemePos];
var portPos = std.mem.indexOfPos(u8, text, schemePos+3, ":");
const pathPos = std.mem.indexOfPos(u8, text, schemePos+3, "/") orelse text.len;
if (portPos) |pos| {
if (pos > pathPos) portPos = null;
}
var port: ?u16 = null;
if (portPos) |pos| {
port = std.fmt.parseUnsigned(u16, text[pos+1..pathPos], 10) catch return UrlError.InvalidPort;
}
const host = text[schemePos+3..(portPos orelse pathPos)];
var path = text[pathPos..];
if (path.len == 0) path = "/";
return Url {
.scheme = scheme,
.host = host,
.port = port,
.path = path,
.query = null
};
}
pub fn combine(self: *const Url, allocator: *Allocator, part: []const u8) !Url {
if (part.len == 0) return UrlError.EmptyString;
if (part.len >= 2 and part[0] == '/' and part[1] != '/') {
return Url {
.scheme = try allocator.dupe(u8, self.scheme),
.host = try allocator.dupe(u8, self.host),
.port = self.port,
.path = try allocator.dupe(u8, part),
.query = null,
.allocator = allocator,
};
} else if (part[0] == '?') {
return Url {
.scheme = self.scheme,
.host = self.host,
.port = self.port,
.path = self.path,
.query = try allocator.dupe(u8, part[1..])
};
} else {
const nSchemePos = std.mem.indexOf(u8, part, "//");
var cond = true;
if (std.mem.indexOfScalar(u8, part, '?')) |q| {
cond = if (nSchemePos) |pos| pos < q else true;
}
if (nSchemePos != null and cond) {
const schemePos = nSchemePos.?;
if (schemePos != 0) {
// todo, handle urls like "://example.com/test"
return try (try Url.parse(part)).dupe(allocator);
} else {
const full = try std.fmt.allocPrint(allocator, "{s}:{s}", .{self.scheme, part});
defer allocator.free(full);
return try (try Url.parse(full)).dupe(allocator);
}
} else {
if (part.len + 1 > Url.MAX_LENGTH) return UrlError.TooLong;
const lastSlash = std.mem.lastIndexOfScalar(u8, self.path, '/') orelse 0;
const path = if (part[0] == '/') try allocator.dupe(u8, part)
else try std.fmt.allocPrint(allocator, "{s}/{s}", .{self.path[0..lastSlash], part});
return Url {
.scheme = try allocator.dupe(u8, self.scheme),
.host = try allocator.dupe(u8, self.host), .port = self.port,
.path = path, .query = null,
.allocator = allocator
};
}
}
}
pub fn dupe(self: *const Url, allocator: *Allocator) !Url {
return Url {
.scheme = try allocator.dupe(u8, self.scheme),
.host = try allocator.dupe(u8, self.host),
.port = self.port,
.path = try allocator.dupe(u8, self.path),
.query = null, // TODO
.allocator = allocator
};
}
pub fn deinit(self: *const Url) void {
if (self.allocator) |allocator| {
allocator.free(self.path);
allocator.free(self.host);
allocator.free(self.scheme);
}
}
pub fn format(self: *const Url, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
_ = fmt;
_ = options;
try writer.print("{s}://{s}", .{self.scheme, self.host});
if (self.port) |port| {
try writer.print(":{}", .{port});
}
try writer.writeAll(self.path);
if (self.query) |query| {
try writer.print("?{s}", .{query});
}
}
};
|
zervo/url.zig
|
const Bool = c_int;
pub const Fixed_32_32 = extern enum(i64) { _ };
pub const Fixed_48_16 = extern enum(i64) { _ };
pub const Fixed_1_31 = extern enum(u32) { _ };
pub const Fixed_1_16 = extern enum(u32) { _ };
pub const Fixed_16_16 = extern enum(i32) { _ };
pub const Fixed = Fixed_16_16;
pub const PointFixed = extern struct {
x: Fixed,
y: Fixed,
};
pub const LineFixed = extern struct {
p1: PointFixed,
p2: PointFixed,
};
pub const Vector = extern struct {
vector: [3]Fixed,
};
pub const Transform = extern struct {
matrix: [3][3]Fixed,
extern fn pixman_transform_init_identity(matrix: *Transform) void;
pub const initIdentity = pixman_transform_init_identity;
extern fn pixman_transform_point_3d(transform: *const Transform, vector: *Vector) Bool;
pub fn point3d(transform: *const Transform, vector: *Vector) bool {
return pixman_transform_point_3d(transform, vector) != 0;
}
extern fn pixman_transform_point(transform: *const Transform, vector: *Vector) Bool;
pub fn point(transform: *const Transform, vector: *Vector) bool {
return pixman_transform_point(transform, vector) != 0;
}
extern fn pixman_transform_multiply(dst: *Transform, l: *const Transform, r: *const Transform) Bool;
pub fn multiply(dst: *Transform, l: *const Transform, r: *const Transform) bool {
return pixman_transform_multiply(dst, l, r) != 0;
}
extern fn pixman_transform_init_scale(t: *Transform, sx: Fixed, sy: Fixed) void;
pub const initScale = pixman_transform_init_scale;
extern fn pixman_transform_scale(forward: *Transform, reverse: *Transform, sx: Fixed, sy: Fixed) Bool;
pub fn scale(forward: *Transform, reverse: *Transform, sx: Fixed, sy: Fixed) bool {
return pixman_transform_scale(forward, reverse, sx, sy) != 0;
}
extern fn pixman_transform_init_rotate(t: *Transform, cos: Fixed, sin: Fixed) void;
pub const initRotate = pixman_transform_init_rotate;
extern fn pixman_transform_rotate(forward: *Transform, reverse: *Transform, c: Fixed, s: Fixed) Bool;
pub fn rotate(forward: *Transform, reverse: *Transform, c: Fixed, s: Fixed) bool {
return pixman_transform_rotate(forward, reverse, c, s) != 0;
}
extern fn pixman_transform_init_translate(t: *Transform, tx: Fixed, ty: Fixed) void;
pub const initTranslate = pixman_transform_init_translate;
extern fn pixman_transform_translate(forward: *Transform, reverse: *Transform, tx: Fixed, ty: Fixed) Bool;
pub fn translate(forward: *Transform, reverse: *Transform, tx: Fixed, ty: Fixed) bool {
return pixman_transform_translate(forward, reverse, tx, ty) != 0;
}
extern fn pixman_transform_bounds(matrix: *const Transform, b: *Box16) Bool;
pub fn bounds(matrix: *const Transform, b: *Box16) bool {
return pixman_transform_bounds(matrix, b) != 0;
}
extern fn pixman_transform_invert(dst: *Transform, src: *const Transform) Bool;
pub fn invert(dst: *Transform, src: *const Transform) bool {
return pixman_transform_invert(dst, src) != 0;
}
extern fn pixman_transform_is_identity(t: *const Transform) Bool;
pub fn isIdentity(t: *const Transform) bool {
return pixman_transform_is_identity(t) != 0;
}
extern fn pixman_transform_is_scale(t: *const Transform) Bool;
pub fn isScale(t: *const Transform) bool {
return pixman_transform_is_scale(t) != 0;
}
extern fn pixman_transform_is_int_translate(t: *const Transform) Bool;
pub fn isIntTranslate(t: *const Transform) bool {
return pixman_transform_is_int_translate(t) != 0;
}
extern fn pixman_transform_is_inverse(a: *const Transform, b: *const Transform) Bool;
pub fn isInverse(a: *const Transform, b: *const Transform) bool {
return pixman_transform_is_inverse(a, b) != 0;
}
extern fn pixman_transform_from_pixman_f_transform(t: *Transform, ft: *const FTransform) Bool;
pub fn fromFTransform(t: *Transform, ft: *const FTransform) bool {
return pixman_transform_from_pixman_f_transform(t, ft) != 0;
}
};
pub const FVector = extern struct {
vector: [3]f64,
};
pub const FTransform = extern struct {
matrix: [3][3]f64,
extern fn pixman_f_transform_from_pixman_transform(ft: *FTransform, t: *const Transform) void;
pub const fromPixmanTransform = pixman_f_transform_from_pixman_transform;
extern fn pixman_f_transform_invert(dst: *FTransform, src: *const FTransform) Bool;
pub fn invert(dst: *FTransform, src: *const FTransform) bool {
return pixman_f_transform_invert(dst, src) != 0;
}
extern fn pixman_f_transform_point(t: *const FTransform, v: FVector) Bool;
pub fn point(t: *const FTransform, v: FVector) bool {
return pixman_f_transform_point(t, v) != 0;
}
extern fn pixman_f_transform_point_3d(t: *const FTransform, v: FVector) void;
pub const point3d = pixman_f_transform_point_3d;
extern fn pixman_f_transform_multiply(dst: *FTransform, l: *const FTransform, r: *const FTransform) void;
pub const multiply = pixman_f_transform_multiply;
extern fn pixman_f_transform_init_scale(t: *FTransform, sx: f64, sy: f64) void;
pub const initScale = pixman_f_transform_init_scale;
extern fn pixman_f_transform_scale(forward: *FTransform, reverse: *FTransform, sx: f64, sy: f64) Bool;
pub fn scale(forward: *FTransform, reverse: *FTransform, sx: f64, sy: f64) bool {
return pixman_f_transform_scale(forward, reverse, sx, sy) != 0;
}
extern fn pixman_f_transform_init_rotate(t: *FTransform, cos: f64, sin: f64) void;
pub const initRotate = pixman_f_transform_init_rotate;
extern fn pixman_f_transform_rotate(forward: *FTransform, reverse: *FTransform, c: f64, s: f64) Bool;
pub fn rotate(forward: *FTransform, reverse: *FTransform, c: f64, s: f64) bool {
return pixman_f_transform_rotate(forward, reverse, c, s) != 0;
}
extern fn pixman_f_transform_init_translate(t: *FTransform, tx: f64, ty: f64) void;
pub const initTranslate = pixman_f_transform_init_translate;
extern fn pixman_f_transform_translate(forward: *FTransform, reverse: *FTransform, tx: f64, ty: f64) Bool;
pub fn translate(forward: *FTransform, reverse: *FTransform, tx: f64, ty: f64) bool {
return pixman_f_transform_translate(forward, reverse, tx, ty) != 0;
}
extern fn pixman_f_transform_bounds(t: *const FTransform, b: *Box16) Bool;
pub fn bounds(t: *const FTransform, b: *Box16) bool {
return pixman_f_transform_bounds(t, b) != 0;
}
extern fn pixman_f_transform_init_identity(t: *FTransform) void;
pub const initIdentity = pixman_f_transform_init_identity;
};
pub const RegionOverlap = extern enum {
out,
in,
part,
};
pub const Region16Data = extern struct {
size: c_long,
num_rects: c_long,
// In memory but not explicity declared
//rects: [size]Box16,
};
pub const Rectangle16 = extern struct {
x: i16,
y: i16,
width: u16,
height: u16,
};
pub const Box16 = extern struct {
x1: i16,
y1: i16,
x2: i16,
y2: i16,
};
pub const Region16 = extern struct {
extents: Box16,
data: ?*Region16Data,
extern fn pixman_region_init(region: *Region16) void;
pub const init = pixman_region_init;
extern fn pixman_region_init_rect(region: *Region16, x: c_int, y: c_int, width: c_uint, height: c_uint) void;
pub const initRect = pixman_region_init_rect;
extern fn pixman_region_init_rects(region: *Region16, boxes: *const Box16, count: c_int) Bool;
pub fn initRects(region: *Region16, boxes: *const Box16, count: c_int) bool {
return pixman_region_init_rects(region, boxes, count) != 0;
}
extern fn pixman_region_init_with_extents(region: *Region16, extents: *Box16) void;
pub const initWithExtents = pixman_region_init_with_extents;
// TODO
extern fn pixman_region_init_from_image(region: *Region16, image: ?*Image) void;
pub const initFromImage = pixman_region_init_from_image;
extern fn pixman_region_fini(region: *Region16) void;
pub const deinit = pixman_region_fini;
extern fn pixman_region_translate(region: *Region16, x: c_int, y: c_int) void;
pub const translate = pixman_region_translate;
extern fn pixman_region_copy(dest: *Region16, source: *Region16) Bool;
pub fn copy(dest: *Region16, source: *Region16) bool {
return pixman_region_copy(dest, source) != 0;
}
extern fn pixman_region_intersect(new_reg: *Region16, reg1: *Region16, reg2: *Region16) Bool;
pub fn intersect(new_reg: *Region16, reg1: *Region16, reg2: *Region16) bool {
return pixman_region_intersect(new_reg, reg1, reg2) != 0;
}
extern fn pixman_region_union(new_reg: *Region16, reg1: *Region16, reg2: *Region16) Bool;
pub fn @"union"(new_reg: *Region16, reg1: *Region16, reg2: *Region16) bool {
return pixman_region_union(new_reg, reg1, reg2) != 0;
}
extern fn pixman_region_union_rect(dest: *Region16, source: *Region16, x: c_int, y: c_int, width: c_uint, height: c_uint) Bool;
pub fn unionRect(dest: *Region16, source: *Region16, x: c_int, y: c_int, width: c_uint, height: c_uint) bool {
return pixman_region_union_rect(dest, source, x, y, width, height) != 0;
}
extern fn pixman_region_intersect_rect(dest: *Region16, source: *Region16, x: c_int, y: c_int, width: c_uint, height: c_uint) Bool;
pub fn intersectRect(dest: *Region16, source: *Region16, x: c_int, y: c_int, width: c_uint, height: c_uint) bool {
return pixman_region_intersect_rect(dest, source, x, y, width, height) != 0;
}
extern fn pixman_region_subtract(reg_d: *Region16, reg_m: *Region16, reg_s: *Region16) Bool;
pub fn subtract(reg_d: *Region16, reg_m: *Region16, reg_s: *Region16) bool {
return pixman_region_subtract(reg_d, reg_m, reg_s) != 0;
}
extern fn pixman_region_inverse(new_reg: *Region16, reg1: *Region16, inv_rect: *Box16) Bool;
pub fn inverse(new_reg: *Region16, reg1: *Region16, inv_rect: *Box16) bool {
return pixman_region_inverse(new_reg, reg1, inv_rect) != 0;
}
extern fn pixman_region_contains_point(region: *Region16, x: c_int, y: c_int, box: ?*Box16) Bool;
pub fn containsPoint(region: *Region16, x: c_int, y: c_int, box: ?*Box16) bool {
return pixman_region_contains_point(region, x, y, box) != 0;
}
extern fn pixman_region_contains_rectangle(region: *Region16, prect: *Box16) RegionOverlap;
pub const containsRectangle = pixman_region_contains_rectangle;
extern fn pixman_region_not_empty(region: *Region16) Bool;
pub fn notEmpty(region: *Region16) bool {
return pixman_region_not_empty(region) != 0;
}
extern fn pixman_region_extents(region: *Region16) *Box16;
pub const extents = pixman_region_extents;
extern fn pixman_region_n_rects(region: *Region16) c_int;
pub const nRects = pixman_region_n_rects;
extern fn pixman_region_rectangles(region: *Region16, n_rects: *c_int) [*]Box16;
pub fn rectangles(region: *Region16) []Box16 {
var n_rects: c_int = undefined;
const rects = pixman_region_rectangles(region, &n_rects);
return rects[0..@intCast(usize, n_rects)];
}
extern fn pixman_region_equal(region1: *Region16, region2: *Region16) Bool;
pub fn equal(region1: *Region16, region2: *Region16) bool {
return pixman_region_equal(region1, region2) != 0;
}
extern fn pixman_region_selfcheck(region: *Region16) Bool;
pub fn selfcheck(region: *Region16) bool {
return pixman_region_selfcheck(region) != 0;
}
extern fn pixman_region_reset(region: *Region16, box: *Box16) void;
pub const reset = pixman_region_reset;
extern fn pixman_region_clear(region: *Region16) void;
pub const clear = pixman_region_clear;
};
pub const Region32Data = extern struct {
size: c_long,
num_rects: c_long,
// In memory but not explicity declared
//rects: [size]Box32,
};
pub const Rectangle32 = extern struct {
x: i32,
y: i32,
width: u32,
height: u32,
};
pub const Box32 = extern struct {
x1: i32,
y1: i32,
x2: i32,
y2: i32,
};
pub const Region32 = extern struct {
extents: Box32,
data: ?*Region32Data,
extern fn pixman_region32_init(region: *Region32) void;
pub const init = pixman_region32_init;
extern fn pixman_region32_init_rect(region: *Region32, x: c_int, y: c_int, width: c_uint, height: c_uint) void;
pub const initRect = pixman_region32_init_rect;
extern fn pixman_region32_init_rects(region: *Region32, boxes: *const Box32, count: c_int) Bool;
pub fn initRects(region: *Region32, boxes: *const Box32, count: c_int) bool {
return pixman_region32_init_rects(region, boxes, count) != 0;
}
extern fn pixman_region32_init_with_extents(region: *Region32, extents: *Box32) void;
pub const initWithExtents = pixman_region32_init_with_extents;
extern fn pixman_region32_init_from_image(region: *Region32, image: ?*Image) void;
pub const initFromImage = pixman_region32_init_from_image;
extern fn pixman_region32_fini(region: *Region32) void;
pub const deinit = pixman_region32_fini;
extern fn pixman_region32_translate(region: *Region32, x: c_int, y: c_int) void;
pub const translate = pixman_region32_translate;
extern fn pixman_region32_copy(dest: *Region32, source: *Region32) Bool;
pub fn copy(dest: *Region32, source: *Region32) bool {
return pixman_region32_copy(dest, source) != 0;
}
extern fn pixman_region32_intersect(new_reg: *Region32, reg1: *Region32, reg2: *Region32) Bool;
pub fn intersect(new_reg: *Region32, reg1: *Region32, reg2: *Region32) bool {
return pixman_region32_intersect(new_reg, reg1, reg2) != 0;
}
extern fn pixman_region32_union(new_reg: *Region32, reg1: *Region32, reg2: *Region32) Bool;
pub fn @"union"(new_reg: *Region32, reg1: *Region32, reg2: *Region32) bool {
return pixman_region32_union(new_reg, reg1, reg2) != 0;
}
extern fn pixman_region32_intersect_rect(dest: *Region32, source: *Region32, x: c_int, y: c_int, width: c_uint, height: c_uint) Bool;
pub fn intersectRect(dest: *Region32, source: *Region32, x: c_int, y: c_int, width: c_uint, height: c_uint) bool {
return pixman_region32_intersect_rect(dest, source, x, y, width, height) != 0;
}
extern fn pixman_region32_union_rect(dest: *Region32, source: *Region32, x: c_int, y: c_int, width: c_uint, height: c_uint) Bool;
pub fn unionRect(dest: *Region32, source: *Region32, x: c_int, y: c_int, width: c_uint, height: c_uint) bool {
return pixman_region32_union_rect(dest, source, x, y, width, height) != 0;
}
extern fn pixman_region32_subtract(reg_d: *Region32, reg_m: *Region32, reg_s: *Region32) Bool;
pub fn subtract(reg_d: *Region32, reg_m: *Region32, reg_s: *Region32) bool {
return pixman_region32_subtract(reg_d, reg_m, reg_s) != 0;
}
extern fn pixman_region32_inverse(new_reg: *Region32, reg1: *Region32, inv_rect: *Box32) Bool;
pub fn inverse(new_reg: *Region32, reg1: *Region32, inv_rect: *Box32) bool {
return pixman_region32_inverse(new_reg, reg1, inv_rect) != 0;
}
extern fn pixman_region32_contains_point(region: *Region32, x: c_int, y: c_int, box: ?*Box32) Bool;
pub fn containsPoint(region: *Region32, x: c_int, y: c_int, box: ?*Box32) bool {
return pixman_region32_contains_point(region, x, y, box) != 0;
}
extern fn pixman_region32_contains_rectangle(region: *Region32, prect: *Box32) RegionOverlap;
pub const containsRectangle = pixman_region32_contains_rectangle;
extern fn pixman_region32_not_empty(region: *Region32) Bool;
pub fn notEmpty(region: *Region32) bool {
return pixman_region32_not_empty(region) != 0;
}
extern fn pixman_region32_extents(region: *Region32) *Box32;
pub const extents = pixman_region32_extents;
extern fn pixman_region32_n_rects(region: *Region32) c_int;
pub const nRects = pixman_region32_n_rects;
extern fn pixman_region32_rectangles(region: *Region32, n_rects: *c_int) [*]Box32;
pub fn rectangles(region: *Region32) []Box32 {
var n_rects: c_int = undefined;
const rects = pixman_region32_rectangles(region, &n_rects);
return rects[0..@intCast(usize, n_rects)];
}
extern fn pixman_region32_equal(region1: *Region32, region2: *Region32) Bool;
pub fn equal(region1: *Region32, region2: *Region32) bool {
return pixman_region32_equal(region1, region2) != 0;
}
extern fn pixman_region32_selfcheck(region: *Region32) Bool;
pub fn selfcheck(region: *Region32) bool {
return pixman_region32_selfcheck(region) != 0;
}
extern fn pixman_region32_reset(region: *Region32, box: *Box32) void;
pub const reset = pixman_region32_reset;
extern fn pixman_region32_clear(region: *Region32) void;
pub const clear = pixman_region32_clear;
};
extern fn pixman_blt(
src_bits: [*]u32,
dst_bits: [*]u32,
src_stride: c_int,
dst_stride: c_int,
src_bpp: c_int,
dst_bpp: c_int,
src_x: c_int,
src_y: c_int,
dest_x: c_int,
dest_y: c_int,
width: c_int,
height: c_int,
) Bool;
pub fn blt(
src_bits: [*]u32,
dst_bits: [*]u32,
src_stride: c_int,
dst_stride: c_int,
src_bpp: c_int,
dst_bpp: c_int,
src_x: c_int,
src_y: c_int,
dest_x: c_int,
dest_y: c_int,
width: c_int,
height: c_int,
) bool {
return pixman_blt(
src_bits,
dst_bits,
src_stride,
dst_stride,
src_bpp,
dst_bpp,
src_x,
src_y,
dest_x,
dest_y,
width,
height,
) != 0;
}
extern fn pixman_fill(
bits: [*]u32,
stride: c_int,
bpp: c_int,
x: c_int,
y: c_int,
width: c_int,
height: c_int,
_xor: u32,
) Bool;
pub fn fill(
bits: [*]u32,
stride: c_int,
bpp: c_int,
x: c_int,
y: c_int,
width: c_int,
height: c_int,
_xor: u32,
) bool {
return pixman_fill(bits, stride, bpp, x, y, width, height, _xor) != 0;
}
extern fn pixman_version() c_int;
pub const version = pixman_version;
extern fn pixman_version_string() [*:0]const u8;
pub const versionString = pixman_version_string;
pub const Color = extern struct {
red: u16,
green: u16,
blue: u16,
alpha: u16,
};
pub const GradientStop = extern struct {
x: Fixed,
color: Color,
};
pub const Indexed = extern struct {
color: Bool,
rgba: [256]u32,
ent: [32768]u8,
};
fn format(
comptime bpp: u32,
comptime _type: Type,
comptime a: u32,
comptime r: u32,
comptime g: u32,
comptime b: u32,
) comptime_int {
return (bpp << 24) | (@as(u32, @enumToInt(_type)) << 16) |
(a << 12) | (r << 8) | (g << 4) | b;
}
fn formatByte(
comptime bpp: u32,
comptime _type: Type,
comptime a: u32,
comptime r: u32,
comptime g: u32,
comptime b: u32,
) comptime_int {
return ((bpp >> 3) << 24) |
(3 << 22) | (@as(u32, @enumToInt(_type)) << 16) |
((a >> 3) << 12) |
((r >> 3) << 8) |
((g >> 3) << 4) |
(b >> 3);
}
/// These are the PIXMAN_TYPE_FOO defines
pub const Type = enum {
other = 0,
a = 1,
argb = 2,
abgr = 3,
color = 4,
gray = 5,
yuy2 = 6,
yv12 = 7,
bgra = 8,
rgba = 9,
argb_srgb = 10,
rgba_float = 11,
};
pub const FormatCode = extern enum {
// 128bpp formats
rgba_float = formatByte(128, .rgba_float, 32, 32, 32, 32),
// 96bpp formats
rgb_float = formatByte(96, .rgba_float, 0, 32, 32, 32),
// 32bpp formats
a8r8g8b8 = format(32, .argb, 8, 8, 8, 8),
x8r8g8b8 = format(32, .argb, 0, 8, 8, 8),
a8b8g8r8 = format(32, .abgr, 8, 8, 8, 8),
x8b8g8r8 = format(32, .abgr, 0, 8, 8, 8),
b8g8r8a8 = format(32, .bgra, 8, 8, 8, 8),
b8g8r8x8 = format(32, .bgra, 0, 8, 8, 8),
r8g8b8a8 = format(32, .rgba, 8, 8, 8, 8),
r8g8b8x8 = format(32, .rgba, 0, 8, 8, 8),
x14r6g6b6 = format(32, .argb, 0, 6, 6, 6),
x2r10g10b10 = format(32, .argb, 0, 10, 10, 10),
a2r10g10b10 = format(32, .argb, 2, 10, 10, 10),
x2b10g10r10 = format(32, .abgr, 0, 10, 10, 10),
a2b10g10r10 = format(32, .abgr, 2, 10, 10, 10),
// sRGB formats
a8r8g8b8_sRGB = format(32, .argb_srgb, 8, 8, 8, 8),
// 24bpp formats
r8g8b8 = format(24, .argb, 0, 8, 8, 8),
b8g8r8 = format(24, .abgr, 0, 8, 8, 8),
// 16bpp formats
r5g6b5 = format(16, .argb, 0, 5, 6, 5),
b5g6r5 = format(16, .abgr, 0, 5, 6, 5),
a1r5g5b5 = format(16, .argb, 1, 5, 5, 5),
x1r5g5b5 = format(16, .argb, 0, 5, 5, 5),
a1b5g5r5 = format(16, .abgr, 1, 5, 5, 5),
x1b5g5r5 = format(16, .abgr, 0, 5, 5, 5),
a4r4g4b4 = format(16, .argb, 4, 4, 4, 4),
x4r4g4b4 = format(16, .argb, 0, 4, 4, 4),
a4b4g4r4 = format(16, .abgr, 4, 4, 4, 4),
x4b4g4r4 = format(16, .abgr, 0, 4, 4, 4),
// 8bpp formats
a8 = format(8, .a, 8, 0, 0, 0),
r3g3b2 = format(8, .argb, 0, 3, 3, 2),
b2g3r3 = format(8, .abgr, 0, 3, 3, 2),
a2r2g2b2 = format(8, .argb, 2, 2, 2, 2),
a2b2g2r2 = format(8, .abgr, 2, 2, 2, 2),
c8 = format(8, .color, 0, 0, 0, 0),
g8 = format(8, .gray, 0, 0, 0, 0),
x4a4 = format(8, .a, 4, 0, 0, 0),
x4c4 = format(8, .color, 0, 0, 0, 0),
x4g4 = format(8, .gray, 0, 0, 0, 0),
// 4bpp formats
a4 = format(4, .a, 4, 0, 0, 0),
r1g2b1 = format(4, .argb, 0, 1, 2, 1),
b1g2r1 = format(4, .abgr, 0, 1, 2, 1),
a1r1g1b1 = format(4, .argb, 1, 1, 1, 1),
a1b1g1r1 = format(4, .abgr, 1, 1, 1, 1),
c4 = format(4, .color, 0, 0, 0, 0),
g4 = format(4, .gray, 0, 0, 0, 0),
// 1bpp formats
a1 = format(1, .a, 1, 0, 0, 0),
g1 = format(1, .gray, 0, 0, 0, 0),
// YUV formats
yuy2 = format(16, .yuy2, 0, 0, 0, 0),
yv12 = format(12, .yv12, 0, 0, 0, 0),
extern fn pixman_format_supported_destination(format: FormatCode) Bool;
pub fn supportedDestination(format: FormatCode) bool {
return pixman_format_supported_destination(format) != 0;
}
extern fn pixman_format_supported_source(format: FormatCode) Bool;
pub fn supportedSource(format: FormatCode) bool {
return pixman_format_supported_source(format) != 0;
}
};
pub const Repeat = extern enum {
none,
normal,
pad,
reflect,
};
pub const Dither = extern enum {
none,
fast,
good,
best,
ordered_bayer_8,
ordered_blue_noise_64,
};
pub const Filter = extern enum {
fast,
good,
best,
nearest,
bilinear,
convolution,
separable_convolution,
extern fn pixman_filter_create_separable_convolution(
n_values: *c_int,
scale_x: Fixed,
scale_y: Fixed,
reconstruct_x: Kernel,
reconstruct_y: Kernel,
sample_x: Kernel,
sample_y: Kernel,
subsample_bits_x: c_int,
subsample_bits_y: c_int,
) [*]Fixed;
pub const createSeparableConvolution = pixman_filter_create_separable_convolution;
};
pub const Kernel = extern enum {
impulse,
box,
linear,
cubic,
gaussian,
lanczos2,
lanczos3,
lanczos3_stretched,
};
pub const Op = extern enum {
clear = 0x00,
src = 0x01,
dst = 0x02,
over = 0x03,
over_reverse = 0x04,
in = 0x05,
in_reverse = 0x06,
out = 0x07,
out_reverse = 0x08,
atop = 0x09,
atop_reverse = 0x0a,
xor = 0x0b,
add = 0x0c,
saturate = 0x0d,
disjoint_clear = 0x10,
disjoint_src = 0x11,
disjoint_dst = 0x12,
disjoint_over = 0x13,
disjoint_over_reverse = 0x14,
disjoint_in = 0x15,
disjoint_in_reverse = 0x16,
disjoint_out = 0x17,
disjoint_out_reverse = 0x18,
disjoint_atop = 0x19,
disjoint_atop_reverse = 0x1a,
disjoint_xor = 0x1b,
conjoint_clear = 0x20,
conjoint_src = 0x21,
conjoint_dst = 0x22,
conjoint_over = 0x23,
conjoint_over_reverse = 0x24,
conjoint_in = 0x25,
conjoint_in_reverse = 0x26,
conjoint_out = 0x27,
conjoint_out_reverse = 0x28,
conjoint_atop = 0x29,
conjoint_atop_reverse = 0x2a,
conjoint_xor = 0x2b,
multiply = 0x30,
screen = 0x31,
overlay = 0x32,
darken = 0x33,
lighten = 0x34,
color_dodge = 0x35,
color_burn = 0x36,
hard_light = 0x37,
soft_light = 0x38,
difference = 0x39,
exclusion = 0x3a,
hsl_hue = 0x3b,
hsl_saturation = 0x3c,
hsl_color = 0x3d,
hsl_luminosity = 0x3e,
};
pub const Image = opaque {
extern fn pixman_image_create_solid_fill(color: *const Color) ?*Image;
pub const createSolidFill = pixman_image_create_solid_fill;
extern fn pixman_image_create_linear_gradient(p1: *const PointFixed, p2: *const PointFixed, stops: *const GradientStop, n_stops: c_int) ?*Image;
pub const createLinearGradient = pixman_image_create_linear_gradient;
extern fn pixman_image_create_radial_gradient(inner: *const PointFixed, outer: *const PointFixed, inner_radius: Fixed, outer_radius: Fixed, stops: *const GradientStop, n_stops: c_int) ?*Image;
pub const createRadialGradient = pixman_image_create_radial_gradient;
extern fn pixman_image_create_conical_gradient(center: *const PointFixed, angle: Fixed, stops: *const GradientStop, n_stops: c_int) ?*Image;
pub const createConicalGradient = pixman_image_create_conical_gradient;
extern fn pixman_image_create_bits(format: FormatCode, width: c_int, height: c_int, bits: ?[*]u32, rowstride_bytes: c_int) ?*Image;
pub const createBits = pixman_image_create_bits;
extern fn pixman_image_create_bits_no_clear(format: FormatCode, width: c_int, height: c_int, bits: [*c]u32, rowstride_bytes: c_int) ?*Image;
pub const createBitsNoClear = pixman_image_create_bits_no_clear;
extern fn pixman_image_ref(image: *Image) *Image;
pub const ref = pixman_image_ref;
extern fn pixman_image_unref(image: *Image) Bool;
pub fn unref(image: *Image) bool {
return pixman_image_unref(image) != 0;
}
extern fn pixman_image_set_destroy_function(image: *Image, function: fn (*Image, ?*c_void) void, data: ?*c_void) void;
pub const setDestroyFunction = pixman_image_set_destroy_function;
extern fn pixman_image_get_destroy_data(image: *Image) ?*c_void;
pub const getDestroyData = pixman_image_get_destroy_data;
extern fn pixman_image_set_clip_region(image: *Image, region: *Region16) Bool;
pub fn setClipRegion(image: *Image, region: *Region16) bool {
return pixman_image_set_clip_region(image, region) != 0;
}
extern fn pixman_image_set_clip_region32(image: *Image, region: *Region32) Bool;
pub fn setClipRegion32(image: *Image, region: *Region32) bool {
return pixman_image_set_clip_region32(image, region) != 0;
}
extern fn pixman_image_set_has_client_clip(image: *Image, client_clip: Bool) void;
pub fn setHasClientClip(image: *Image, client_clip: bool) void {
pixman_image_set_has_client_clip(Image, @boolToInt(client_clip));
}
extern fn pixman_image_set_transform(image: *Image, transform: *const Transform) Bool;
pub fn setTransform(image: *Image, transform: *const Transform) bool {
return pixman_image_set_transform(image, transform) != 0;
}
extern fn pixman_image_set_repeat(image: *Image, repeat: Repeat) void;
pub const setRepeat = pixman_image_set_repeat;
extern fn pixman_image_set_dither(image: *Image, dither: Dither) void;
pub const setDither = pixman_image_set_dither;
extern fn pixman_image_set_dither_offset(image: *Image, offset_x: c_int, offset_y: c_int) void;
pub const setDitherOffset = pixman_image_set_dither_offset;
extern fn pixman_image_set_filter(image: *Image, filter: Filter, filter_params: [*]const Fixed, n_filter_params: c_int) Bool;
pub fn setFilter(image: *Image, filter: Filter, filter_params: [*]const Fixed, n_filter_params: c_int) bool {
return pixman_image_set_filter(image, filter, filter_params, n_filter_params) != 0;
}
extern fn pixman_image_set_source_clipping(image: *Image, source_clipping: Bool) void;
pub fn setSourceClipping(image: *Image, source_clipping: bool) void {
pixman_image_set_source_clipping(image, @boolToInt(source_clipping));
}
extern fn pixman_image_set_alpha_map(image: *Image, alpha_map: ?*Image, x: i16, y: i16) void;
pub const setAlphaMap = pixman_image_set_alpha_map;
extern fn pixman_image_set_component_alpha(image: *Image, component_alpha: Bool) void;
pub fn setComponentAlpha(image: *Image, component_alpha: bool) void {
pixman_image_set_component_alpha(image, @boolToInt(component_alpha));
}
extern fn pixman_image_get_component_alpha(image: *Image) Bool;
pub fn getComponentAlpha(image: *Image) bool {
return pixman_image_get_component_alpha(image) != 0;
}
extern fn pixman_image_set_accessors(image: *Image, read_func: fn (src: *const c_void, size: c_int) u32, write_func: fn (dst: *c_void, value: u32, size: c_int) void) void;
pub const setAccessors = pixman_image_set_accessors;
extern fn pixman_image_set_indexed(image: *Image, indexed: *const Indexed) void;
pub const setIndexed = pixman_image_set_indexed;
extern fn pixman_image_get_data(image: *Image) ?[*]u32;
pub const getData = pixman_image_get_data;
extern fn pixman_image_get_width(image: *Image) c_int;
pub const getWidth = pixman_image_get_width;
extern fn pixman_image_get_height(image: *Image) c_int;
pub const getHeight = pixman_image_get_height;
extern fn pixman_image_get_stride(image: *Image) c_int;
pub const getStride = pixman_image_get_stride;
extern fn pixman_image_get_depth(image: *Image) c_int;
pub const getDepth = pixman_image_get_depth;
extern fn pixman_image_get_format(image: *Image) FormatCode;
pub const getFormat = pixman_image_get_format;
extern fn pixman_image_fill_rectangles(op: Op, image: *Image, color: *const Color, n_rects: c_int, rects: [*]const Rectangle16) Bool;
pub fn fillRectangles(op: Op, image: *Image, color: *const Color, n_rects: c_int, rects: [*]const Rectangle16) bool {
return pixman_image_fill_rectangles(op, image, color, n_rects, rects) != 0;
}
extern fn pixman_image_fill_boxes(op: Op, dest: *Image, color: *const Color, n_boxes: c_int, boxes: [*]const Box32) Bool;
pub fn fillBoxes(op: Op, dest: *Image, color: *const Color, n_boxes: c_int, boxes: [*]const Box32) bool {
return pixman_image_fill_boxes(op, dest, color, n_boxes, boxes) != 0;
}
extern fn pixman_image_composite(op: Op, src: *Image, mask: ?*Image, dest: *Image, src_x: i16, src_y: i16, mask_x: i16, mask_y: i16, dest_x: i16, dest_y: i16, width: u16, height: u16) void;
pub const composite = pixman_image_composite;
extern fn pixman_image_composite32(op: Op, src: *Image, mask: ?*Image, dest: *Image, src_x: i32, src_y: i32, mask_x: i32, mask_y: i32, dest_x: i32, dest_y: i32, width: i32, height: i32) void;
pub const composite32 = pixman_image_composite32;
extern fn pixman_rasterize_edges(image: *Image, l: *Edge, r: *Edge, t: Fixed, b: Fixed) void;
pub const rasterizeEdges = pixman_rasterize_edges;
extern fn pixman_add_traps(image: *Image, x_off: i16, y_off: i16, ntrap: c_int, traps: [*]const Trap) void;
pub const addTraps = pixman_add_traps;
extern fn pixman_add_trapezoids(image: *Image, x_off: i16, y_off: c_int, ntraps: c_int, traps: [*]const Trapezoid) void;
pub const addTrapezoids = pixman_add_trapezoids;
extern fn pixman_rasterize_trapezoid(image: *Image, trap: [*]const Trapezoid, x_off: c_int, y_off: c_int) void;
pub const rasterizeTrapezoid = pixman_rasterize_trapezoid;
extern fn pixman_add_triangles(image: *Image, x_off: i32, y_off: i32, n_tris: c_int, tris: [*]const Triangle) void;
pub const addTriangles = pixman_add_triangles;
};
pub const Glyph = extern struct {
x: c_int,
y: c_int,
glyph: ?*const c_void,
extern fn pixman_glyph_get_extents(cache: ?*GlyphCache, n_glyphs: c_int, glyphs: [*]pixman_glyph_t, extents: [*]pixman_box32_t) void;
pub const getExtents = pixman_glyph_get_extents;
extern fn pixman_glyph_get_mask_format(cache: ?*GlyphCache, n_glyphs: c_int, glyphs: [*]const pixman_glyph_t) FormatCode;
pub const getMaskFormat = pixman_glyph_get_mask_format;
};
pub const GlyphCache = opaque {
extern fn pixman_glyph_cache_create() ?*GlyphCache;
pub const create = pixman_glyph_cache_create;
extern fn pixman_glyph_cache_destroy(cache: *GlyphCache) void;
pub const destroy = pixman_glyph_cache_destroy;
extern fn pixman_glyph_cache_freeze(cache: *GlyphCache) void;
pub const freeze = pixman_glyph_cache_freeze;
extern fn pixman_glyph_cache_thaw(cache: *GlyphCache) void;
pub const thaw = pixman_glyph_cache_thaw;
extern fn pixman_glyph_cache_lookup(cache: *GlyphCache, font_key: ?*c_void, glyph_key: ?*c_void) ?*const c_void;
pub const lookup = pixman_glyph_cache_lookup;
extern fn pixman_glyph_cache_insert(cache: *GlyphCache, font_key: ?*c_void, glyph_key: ?*c_void, origin_x: c_int, origin_y: c_int, glyph_image: *Image) ?*const c_void;
pub const insert = pixman_glyph_cache_insert;
extern fn pixman_glyph_cache_remove(cache: *GlyphCache, font_key: ?*c_void, glyph_key: ?*c_void) void;
pub const remove = pixman_glyph_cache_remove;
};
extern fn pixman_composite_glyphs(
op: Op,
src: *Image,
dest: *Image,
mask_format: FormatCode,
src_x: i32,
src_y: i32,
mask_x: i32,
mask_y: i32,
dest_x: i32,
dest_y: i32,
width: i32,
height: i32,
cache: *GlyphCache,
n_glyphs: c_int,
glyphs: [*]const Glyph,
) void;
pub const compositeGlyphs = pixman_composite_glyphs;
extern fn pixman_composite_glyphs_no_mask(
op: Op,
src: *Image,
dest: *Image,
src_x: i32,
src_y: i32,
dest_x: i32,
dest_y: i32,
cache: *GlyphCache,
n_glyphs: c_int,
glyphs: [*]const Glyph,
) void;
pub const compositeGlyphsNoMask = pixman_composite_glyphs_no_mask;
pub const Edge = extern struct {
x: Fixed,
e: Fixed,
stepx: Fixed,
signdx: Fixed,
dy: Fixed,
dx: Fixed,
stepx_small: Fixed,
stepx_big: Fixed,
dx_small: Fixed,
dx_big: Fixed,
extern fn pixman_edge_init(e: *Edge, bpp: c_int, y_start: Fixed, x_top: Fixed, y_top: Fixed, x_bot: Fixed, y_bot: Fixed) void;
pub const init = pixman_edge_init;
extern fn pixman_line_fixed_edge_init(e: *Edge, bpp: c_int, y: Fixed, line: *const LineFixed, x_off: c_int, y_off: c_int) void;
pub const initFromLineFixed = pixman_line_fixed_edge_init;
extern fn pixman_edge_step(e: *Edge, n: c_int) void;
pub const step = pixman_edge_step;
};
pub const Trapezoid = extern struct {
top: Fixed,
bottom: Fixed,
left: LineFixed,
right: LineFixed,
pub fn valid(t: Trapezoid) bool {
return t.left.p1.y != t.left.p2.y and
t.right.p1.y != t.right.p2.y and
t.bottom > t.top;
}
};
pub const Trap = extern struct {
top: SpanFix,
bot: SpanFix,
};
pub const SpanFix = extern struct {
l: Fixed,
r: Fixed,
y: Fixed,
};
pub const Triangle = extern struct {
p1: PointFixed,
p2: PointFixed,
p3: PointFixed,
};
extern fn pixman_sample_ceil_y(y: Fixed, bpp: c_int) Fixed;
pub const sampleCeilY = pixman_sample_ceil_y;
extern fn pixman_sample_floor_y(y: Fixed, bpp: c_int) Fixed;
pub const sampleFloorY = pixman_sample_floor_y;
extern fn pixman_composite_trapezoids(
op: Op,
src: *Image,
dst: *Image,
mask_format: FormatCode,
x_src: c_int,
y_src: c_int,
x_dst: c_int,
y_dst: c_int,
n_traps: c_int,
traps: [*c]const Trapezoid,
) void;
pub const compositeTrapezoids = pixman_composite_trapezoids;
extern fn pixman_composite_triangles(
op: Op,
src: *Image,
dst: *Image,
mask_format: FormatCode,
x_src: c_int,
y_src: c_int,
x_dst: c_int,
y_dst: c_int,
n_tris: c_int,
tris: [*c]const Triangle,
) void;
pub const compositeTriangles = pixman_composite_triangles;
test "" {
@import("std").testing.refAllDecls(@This());
}
|
pixman.zig
|
const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const Timer = std.time.Timer;
const data = @embedFile("data/day01.txt");
const EntriesList = std.ArrayList(i16);
const vec_len = 16;
const Vec = std.meta.Vector(vec_len, i16);
const Mask = std.meta.Vector(vec_len, bool);
const ShuffleMask = std.meta.Vector(vec_len, i32);
/// Returns a mask which rotates a simd vector `rot` slots left.
fn rotate_mask(comptime rot: usize) ShuffleMask {
comptime {
var vec: ShuffleMask = undefined;
var c: usize = 0;
while (c < vec_len) : (c += 1) {
vec[c] = (c + rot) % vec_len;
}
return vec;
}
}
fn find_result1(a: Vec, b: Vec, mask: Mask) i64 {
@setCold(true);
var result: i64 = -1;
comptime var ti = 0;
inline while (ti < vec_len) : (ti += 1) {
if (mask[ti]) {
result = @as(i64, a[ti]) * @as(i64, b[ti]);
}
}
return result;
}
fn find_result2(a: Vec, b: Vec, c: Vec, mask: Mask) i64 {
@setCold(true);
var result: i64 = -1;
comptime var ti = 0;
inline while (ti < vec_len) : (ti += 1) {
if (mask[ti]) {
result = @as(i64, a[ti]) * @as(i64, b[ti]) * @as(i64, c[ti]);
}
}
return result;
}
pub fn main() !void {
var lines = std.mem.tokenize(data, "\r\n");
var timer = try Timer.start();
var buffer: [1<<13]u8 align(@alignOf(Vec)) = undefined;
var fba = std.heap.FixedBufferAllocator.init(&buffer);
var entries = EntriesList.init(&fba.allocator);
try entries.ensureCapacity(400);
while (lines.next()) |line| {
if (line.len == 0) continue;
const num = try std.fmt.parseInt(i16, line, 10);
try entries.append(num);
}
while (entries.items.len % vec_len != 0) {
try entries.append(entries.items[0]);
}
var parse_time = timer.lap();
const items = entries.items;
const vec_items = @ptrCast([*]Vec, @alignCast(@alignOf(Vec), items.ptr))[0..@divExact(items.len, vec_len)];
var result1: i64 = -1;
//part1:
{
var found = false;
var c: usize = 0;
while (c < vec_items.len) : (c += 1) {
var cv = vec_items[c];
var d: usize = c + 1;
while (d < vec_items.len) : (d += 1) {
var dvv = vec_items[d];
comptime var do = 0;
inline while (do < vec_len) : (do += 1) {
var dv = @shuffle(i16, dvv, undefined, comptime rotate_mask(do));
var mask = (cv + dv == @splat(vec_len, @as(i16, 2020)));
if (@reduce(.Or, mask) != false) {
result1 = find_result1(cv, dv, mask);
found = true;
}
}
//if (found) break :part1;
}
}
}
var p1_time = timer.lap();
var result2: i64 = -1;
//part2:
{
var found = false;
var c: usize = 0;
while (c < vec_items.len) : (c += 1) {
var cv = vec_items[c];
var d: usize = c + 1;
while (d < vec_items.len) : (d += 1) {
var dvv = vec_items[d];
var e: usize = d + 1;
while (e < vec_items.len) : (e += 1) {
var evv = vec_items[e];
@setEvalBranchQuota(100000);
comptime var do = 0;
inline while (do < vec_len) : (do += 1) {
var dv = @shuffle(i16, dvv, undefined, comptime rotate_mask(do));
var cdv = cv + dv;
comptime var eo = 0;
inline while (eo < vec_len) : (eo += 1) {
var ev = @shuffle(i16, evv, undefined, comptime rotate_mask(eo));
var mask = (cdv + ev == @splat(vec_len, @as(i16, 2020)));
if (@reduce(.Or, mask) != false) {
result2 = find_result2(cv, dv, ev, mask);
found = true;
}
}
}
//if (found) break :part2;
}
}
}
}
var p2_time = timer.lap();
print("part1: {}, part2: {}\n", .{result1, result2});
var print_time = timer.lap();
const total = parse_time + p1_time + p2_time + print_time;
print(
\\done, total time: {:>9}
\\ parse: {:>9}
\\ p1 : {:>9}
\\ p2 : {:>9}
\\ print: {:>9}
\\
, .{total, parse_time, p1_time, p2_time, print_time});
}
|
src/day01.zig
|
const std = @import("std");
const Allocator = std.mem.Allocator;
const odbc = @import("odbc");
pub const Column = struct {
table_category: ?[]const u8,
table_schema: ?[]const u8,
table_name: []const u8,
column_name: []const u8,
data_type: u16,
type_name: []const u8,
column_size: ?u32,
buffer_length: ?u32,
decimal_digits: ?u16,
num_prec_radix: ?u16,
nullable: odbc.Types.Nullable,
remarks: ?[]const u8,
column_def: ?[]const u8,
sql_data_type: odbc.Types.SqlType,
sql_datetime_sub: ?u16,
char_octet_length: ?u32,
ordinal_position: u32,
is_nullable: ?[]const u8,
pub fn deinit(self: *Column, allocator: Allocator) void {
if (self.table_category) |tc| allocator.free(tc);
if (self.table_schema) |ts| allocator.free(ts);
allocator.free(self.table_name);
allocator.free(self.column_name);
allocator.free(self.type_name);
if (self.remarks) |r| allocator.free(r);
if (self.column_def) |cd| allocator.free(cd);
if (self.is_nullable) |in| allocator.free(in);
}
pub fn format(self: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
_ = fmt;
_ = options;
try writer.print("{s}{{\n", .{@typeName(@TypeOf(self))});
inline for (std.meta.fields(@TypeOf(self))) |field| {
const field_info = @typeInfo(field.field_type);
const target_type = if (field_info == .Optional) field_info.Optional.child else field.field_type;
switch (@typeInfo(target_type)) {
.Enum => try writer.print(" {s}: {s}\n", .{field.name, @tagName(@field(self, field.name))}),
else => {
const format_string = comptime if (std.meta.trait.isZigString(target_type)) " {s}: {s}\n" else " {s}: {}\n";
try writer.print(format_string, .{field.name, @field(self, field.name)});
}
}
}
try writer.writeAll("}");
}
};
pub const Table = struct {
catalog: ?[]const u8,
schema: ?[]const u8,
name: ?[]const u8,
table_type: ?[]const u8,
remarks: ?[]const u8,
pub fn deinit(self: *Table, allocator: Allocator) void {
if (self.catalog) |cat| allocator.free(cat);
if (self.schema) |schema| allocator.free(schema);
if (self.name) |name| allocator.free(name);
if (self.table_type) |table_type| allocator.free(table_type);
if (self.remarks) |remarks| allocator.free(remarks);
}
pub fn format(self: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
_ = fmt;
_ = options;
try writer.print("{s}{{\n", .{@typeName(@TypeOf(self))});
inline for (std.meta.fields(@TypeOf(self))) |field| {
const field_info = @typeInfo(field.field_type);
const target_type = if (field_info == .Optional) field_info.Optional.child else field.field_type;
switch (@typeInfo(target_type)) {
.Enum => try writer.print(" {s}: {s}\n", .{field.name, @tagName(@field(self, field.name))}),
else => {
const format_string = comptime if (std.meta.trait.isZigString(target_type)) " {s}: {s}\n" else " {s}: {}\n";
try writer.print(format_string, .{field.name, @field(self, field.name)});
}
}
}
try writer.writeAll("}");
}
};
pub const TablePrivileges = struct {
category: ?[]const u8,
schema: ?[]const u8,
name: []const u8,
grantor: ?[]const u8,
grantee: []const u8,
privilege: []const u8,
is_grantable: ?[]const u8,
pub fn deinit(self: *TablePrivileges, allocator: Allocator) void {
if (self.category) |category| allocator.free(category);
if (self.schema) |schema| allocator.free(schema);
if (self.grantor) |grantor| allocator.free(grantor);
if (self.is_grantable) |is_grantable| allocator.free(is_grantable);
allocator.free(self.name);
allocator.free(self.grantee);
allocator.free(self.privilege);
}
pub fn format(self: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
_ = fmt;
_ = options;
try writer.print("{s}{{\n", .{@typeName(@TypeOf(self))});
inline for (std.meta.fields(@TypeOf(self))) |field| {
const field_info = @typeInfo(field.field_type);
const target_type = if (field_info == .Optional) field_info.Optional.child else field.field_type;
switch (@typeInfo(target_type)) {
.Enum => try writer.print(" {s}: {s}\n", .{field.name, @tagName(@field(self, field.name))}),
else => {
const format_string = comptime if (std.meta.trait.isZigString(target_type)) " {s}: {s}\n" else " {s}: {}\n";
try writer.print(format_string, .{field.name, @field(self, field.name)});
}
}
}
try writer.writeAll("}");
}
};
|
src/catalog.zig
|
const std = @import("std");
var allocator = &@import("allocator.zig").fixed.allocator;
// Old String -> Integer
//export fn atof(str: ?*const u8) f64 {
// unreachable;
//}
export fn atoi(str: [*]const u8) c_int {
const buf = std.cstr.toSliceConst(str);
return std.fmt.parseInt(c_int, buf, 10) catch 0;
}
export fn atol(str: [*]const u8) c_long {
const buf = std.cstr.toSliceConst(str);
return std.fmt.parseInt(c_long, buf, 10) catch 0;
}
export fn atoll(str: [*]const u8) c_longlong {
const buf = std.cstr.toSliceConst(str);
return std.fmt.parseInt(c_longlong, buf, 10) catch 0;
}
// C99 String -> Integer
// C99
export fn strtol(noalias str: [*]const u8, noalias str_end: ?[*]u8, base: c_int) c_long {
// TODO: Actually set str_end
// TODO: Set errno on failure
const buf = std.cstr.toSliceConst(str);
return std.fmt.parseInt(c_long, buf, @intCast(u8, base)) catch 0;
}
// C99
export fn strtoll(noalias str: [*]const u8, noalias str_end: ?[*]u8, base: c_int) c_longlong {
// TODO: Actually set str_end
// TODO: Set errno on failure
const buf = std.cstr.toSliceConst(str);
return std.fmt.parseInt(c_longlong, buf, @intCast(u8, base)) catch 0;
}
// C99
export fn strtoul(noalias str: [*]const u8, noalias str_end: ?[*]u8, base: c_int) c_ulong {
// TODO: Actually set str_end
// TODO: Set errno on failure
const buf = std.cstr.toSliceConst(str);
return std.fmt.parseUnsigned(c_ulong, buf, @intCast(u8, base)) catch 0;
}
// C99
export fn strtoull(noalias str: [*]const u8, noalias str_end: ?[*]u8, base: c_int) c_ulonglong {
// TODO: Actually set str_end
// TODO: Set errno on failure
const buf = std.cstr.toSliceConst(str);
return std.fmt.parseUnsigned(c_ulonglong, buf, @intCast(u8, base)) catch 0;
}
// String -> Float
// C99
//export fn strtof(str: ?*const u8, str_end: ?*u8) f32 {
// unreachable;
//}
// C99
//export fn strtod(str: ?*const u8, str_end: ?*u8) f64 {
// unreachable;
//}
// C99
//export fn strtold(str: ?*const u8, str_end: ?*u8) c_longdouble {
// unreachable;
//}
// Random
var prng = std.rand.DefaultPrng.init(0);
export fn rand() c_int {
return @bitCast(c_int, prng.random.scalar(c_uint));
}
export fn srand(seed: c_uint) void {
prng.seed(seed);
}
// Memory allocation
export fn malloc(size: usize) ?*c_void {
// TODO: Need to embed size of memory before the returned pointer
var m = allocator.alloc(u8, size) catch return null;
return @ptrCast(?*c_void, m.ptr);
}
export fn calloc(num: usize, size: usize) ?*c_void {
const m = allocator.alloc(u8, size) catch return null;
std.mem.set(u8, m, 0);
return @ptrCast(?*c_void, m.ptr);
}
export fn realloc(ptr: ?*c_void, new_size: usize) ?*c_void {
const old_len = 0; // (ptr - 4)[0];
const old_mem = @ptrCast([*]u8, ptr)[0..old_len];
var m = allocator.realloc(u8, old_mem, new_size) catch return null;
return @ptrCast(?*c_void, m.ptr);
}
export fn free(ptr: ?*c_void) void {
const old_len = 0; // (ptr - 4)[0];
const old_mem = @ptrCast([*]u8, ptr)[0..old_len];
allocator.free(old_mem);
}
// C11
export fn aligned_alloc(alignment: usize, size: usize) ?*c_void {
// TODO: alignment parameter is comptime for zig but is not here, may need to just overallocate
// and align manually here.
return malloc(size);
}
// Program termination
export fn abort() noreturn {
unreachable;
}
// TODO: extern fn requires support in get_c_type in src/codegen.cpp.
const ExitFunc = extern fn () void;
var exit_funcs = []?ExitFunc{null} ** 32;
var quick_exit_funcs = []?ExitFunc{null} ** 32;
export fn atexit() c_int { // func: ExitFunc) c_int {
// TODO: Must be thread-safe.
for (exit_funcs) |*mf| {
if (mf.*) |*f| {
//f.* = func;
return 0;
}
}
return 1;
}
export fn exit(exit_code: c_int) noreturn {
// TODO: Must be thread-safe.
// TODO: Call this from end of main as well to run these handlers
var ri: usize = 0;
while (ri < exit_funcs.len) : (ri += 1) {
const i = exit_funcs.len - ri - 1;
if (exit_funcs[i]) |f| {
f();
}
}
std.os.exit(@truncate(u8, @bitCast(c_uint, exit_code)));
}
// C11
export fn at_quick_exit() c_int { // func: ExitFunc) c_int {
// TODO: Must be thread-safe.
for (quick_exit_funcs) |*mf| {
if (mf.*) |*f| {
//f.* = func;
return 0;
}
}
return 1;
}
// C11
export fn quick_exit(exit_code: c_int) noreturn {
// TODO: Must be thread-safe.
var ri: usize = 0;
while (ri < quick_exit_funcs.len) : (ri += 1) {
const i = quick_exit_funcs.len - ri - 1;
if (quick_exit_funcs[i]) |f| {
f();
}
}
std.os.exit(@truncate(u8, @bitCast(c_uint, exit_code)));
}
// Environment/Os
//export fn getenv(name: ?*const u8) ?*const u8 {
// unreachable;
//}
// C11 - unimplemented in musl
//export fn getenv_s(len: ?*usize, value: ?*u8, valuesz: usize, name: ?*const u8) c_int {
// unreachable;
//}
const Term = std.os.ChildProcess.Term;
export fn system(command: [*]const u8) c_int {
// TODO: Spit command by string and perform escaping
const argv = []const []const u8{std.cstr.toSliceConst(command)};
var process = std.os.ChildProcess.init(argv, allocator) catch return -1;
defer process.deinit();
const term = process.spawnAndWait() catch return -1;
return switch (term) {
Term.Exited => |code| code,
Term.Signal => |code| code,
Term.Stopped => |code| code,
Term.Unknown => |code| code,
};
}
// Search functions
//export fn bsearch(key: ?&c_void, ptr: ?&c_void, count: usize, size: usize,
// comp: extern fn(?&c_void, ?&c_void) c_int) ?&c_void
//{
// unreachable;
//}
//export fn qsort(ptr: ?&c_void, count: usize, size: usize,
// comp: extern fn(?&c_void, ?&c_void) c_int) void
//{
// unreachable;
//}
// Math functions
export fn abs(n: c_int) c_int {
return if (n < 0) -n else n;
}
export fn labs(n: c_int) c_long {
return if (n < 0) -n else n;
}
// C99
export fn llabs(n: c_int) c_longlong {
return if (n < 0) -n else n;
}
fn DivType(comptime T: type) type {
return packed struct {
quot: T,
rem: T,
};
}
export const div_t = DivType(c_int);
export fn div(x: c_int, y: c_int) div_t {
return div_t{
.quot = @divTrunc(x, y),
.rem = @rem(x, y),
};
}
export const ldiv_t = DivType(c_long);
export fn ldiv(x: c_long, y: c_long) ldiv_t {
return ldiv_t{
.quot = @divTrunc(x, y),
.rem = @rem(x, y),
};
}
// C99
export const lldiv_t = DivType(c_longlong);
export fn lldiv(x: c_longlong, y: c_longlong) lldiv_t {
return lldiv_t{
.quot = @divTrunc(x, y),
.rem = @rem(x, y),
};
}
// NOTE: Omitted multibyte functions
// NOTE: Ommitted posix/gnu extension functions
export fn getenv(name: [*]const u8) ?[*]const u8 {
// TODO: non-posix environment
if (std.os.getEnvPosix(std.cstr.toSliceConst(name))) |ok| {
return ok[0..].ptr;
} else {
return null;
}
}
|
src/stdlib.zig
|
const std = @import("std");
const zp = @import("zplay");
const dig = zp.deps.dig;
const alg = zp.deps.alg;
const Vec3 = alg.Vec3;
const Vec4 = alg.Vec4;
const Mat4 = alg.Mat4;
const Framebuffer = zp.graphics.common.Framebuffer;
const TextureUnit = zp.graphics.common.Texture.TextureUnit;
const TextureCube = zp.graphics.texture.TextureCube;
const Skybox = zp.graphics.@"3d".Skybox;
const Renderer = zp.graphics.@"3d".Renderer;
const EnvMappingRenderer = zp.graphics.@"3d".EnvMappingRenderer;
const Material = zp.graphics.@"3d".Material;
const Model = zp.graphics.@"3d".Model;
const Camera = zp.graphics.@"3d".Camera;
var skybox: Skybox = undefined;
var cubemap: TextureCube = undefined;
var skybox_material: Material = undefined;
var refract_air_material: Material = undefined;
var refract_water_material: Material = undefined;
var refract_ice_material: Material = undefined;
var refract_glass_material: Material = undefined;
var refract_diamond_material: Material = undefined;
var current_renderer: Renderer = undefined;
var current_material: Material = undefined;
var reflect_renderer: EnvMappingRenderer = undefined;
var refract_renderer: EnvMappingRenderer = undefined;
var model: Model = undefined;
var camera = Camera.fromPositionAndTarget(
Vec3.new(0, 0, 3),
Vec3.zero(),
null,
);
fn init(ctx: *zp.Context) anyerror!void {
std.log.info("game init", .{});
// init imgui
try dig.init(ctx.window);
// allocate materials
cubemap = try TextureCube.fromFilePath(
std.testing.allocator,
"assets/skybox/right.jpg",
"assets/skybox/left.jpg",
"assets/skybox/top.jpg",
"assets/skybox/bottom.jpg",
"assets/skybox/front.jpg",
"assets/skybox/back.jpg",
);
skybox_material = Material.init(.{
.single_cubemap = cubemap,
});
refract_air_material = Material.init(.{
.refract_mapping = .{
.cubemap = cubemap,
.ratio = 1.0,
},
});
refract_water_material = Material.init(.{
.refract_mapping = .{
.cubemap = cubemap,
.ratio = 1.33,
},
});
refract_ice_material = Material.init(.{
.refract_mapping = .{
.cubemap = cubemap,
.ratio = 1.309,
},
});
refract_glass_material = Material.init(.{
.refract_mapping = .{
.cubemap = cubemap,
.ratio = 1.52,
},
});
refract_diamond_material = Material.init(.{
.refract_mapping = .{
.cubemap = cubemap,
.ratio = 2.42,
},
});
current_material = skybox_material;
// alloc renderers
skybox = Skybox.init();
reflect_renderer = EnvMappingRenderer.init(.reflect);
refract_renderer = EnvMappingRenderer.init(.refract);
current_renderer = reflect_renderer.renderer();
// load model
model = try Model.fromGLTF(std.testing.allocator, "assets/SciFiHelmet/SciFiHelmet.gltf", false, null);
// alloc texture unit
_ = skybox_material.allocTextureUnit(0);
// enable depth test
ctx.graphics.toggleCapability(.depth_test, true);
}
fn loop(ctx: *zp.Context) void {
const S = struct {
var frame: f32 = 0;
var current_mapping: c_int = 0;
var refract_material: c_int = 0;
};
S.frame += 1;
// camera movement
const distance = ctx.delta_tick * camera.move_speed;
if (ctx.isKeyPressed(.w)) {
camera.move(.forward, distance);
}
if (ctx.isKeyPressed(.s)) {
camera.move(.backward, distance);
}
if (ctx.isKeyPressed(.a)) {
camera.move(.left, distance);
}
if (ctx.isKeyPressed(.d)) {
camera.move(.right, distance);
}
if (ctx.isKeyPressed(.left)) {
camera.rotate(0, -1);
}
if (ctx.isKeyPressed(.right)) {
camera.rotate(0, 1);
}
if (ctx.isKeyPressed(.up)) {
camera.rotate(1, 0);
}
if (ctx.isKeyPressed(.down)) {
camera.rotate(-1, 0);
}
while (ctx.pollEvent()) |e| {
_ = dig.processEvent(e);
switch (e) {
.window_event => |we| {
switch (we.data) {
.resized => |size| {
ctx.graphics.setViewport(0, 0, size.width, size.height);
},
else => {},
}
},
.keyboard_event => |key| {
if (key.trigger_type == .up) {
switch (key.scan_code) {
.escape => ctx.kill(),
.f1 => ctx.toggleFullscreeen(null),
else => {},
}
}
},
.quit_event => ctx.kill(),
else => {},
}
}
var width: u32 = undefined;
var height: u32 = undefined;
ctx.graphics.getDrawableSize(ctx.window, &width, &height);
ctx.graphics.clear(true, true, true, [4]f32{ 0.2, 0.3, 0.3, 1.0 });
// draw model
const projection = alg.Mat4.perspective(
camera.zoom,
@intToFloat(f32, width) / @intToFloat(f32, height),
0.1,
100,
);
current_renderer.begin();
model.render(
current_renderer,
Mat4.fromTranslate(Vec3.new(0.0, 0, 0))
.scale(Vec3.set(0.6))
.mult(Mat4.fromRotation(ctx.tick * 10, Vec3.up())),
projection,
camera,
current_material,
null,
) catch unreachable;
current_renderer.end();
// draw skybox
skybox.draw(&ctx.graphics, projection, camera, skybox_material);
// rendering settings
dig.beginFrame();
defer dig.endFrame();
{
dig.setNextWindowPos(
.{ .x = @intToFloat(f32, width) - 10, .y = 50 },
.{
.cond = dig.c.ImGuiCond_Always,
.pivot = .{ .x = 1, .y = 0 },
},
);
if (dig.begin(
"settings",
null,
dig.c.ImGuiWindowFlags_NoMove |
dig.c.ImGuiWindowFlags_NoResize |
dig.c.ImGuiWindowFlags_AlwaysAutoResize,
)) {
_ = dig.combo_Str(
"environment mapping",
&S.current_mapping,
"reflect\x00refract",
null,
);
if (S.current_mapping == 1) {
current_renderer = refract_renderer.renderer();
_ = dig.combo_Str(
"refract ratio",
&S.refract_material,
"air\x00water\x00ice\x00glass\x00diamond",
null,
);
current_material = switch (S.refract_material) {
0 => refract_air_material,
1 => refract_water_material,
2 => refract_ice_material,
3 => refract_glass_material,
4 => refract_diamond_material,
else => unreachable,
};
} else {
current_renderer = reflect_renderer.renderer();
current_material = skybox_material; // reflect material is same as skybox
}
}
dig.end();
}
}
fn quit(ctx: *zp.Context) void {
_ = ctx;
std.log.info("game quit", .{});
}
pub fn main() anyerror!void {
try zp.run(.{
.initFn = init,
.loopFn = loop,
.width = 1600,
.height = 900,
.quitFn = quit,
});
}
|
examples/environment_mapping.zig
|
const pc_keyboard = @import("../../pc_keyboard.zig");
pub fn mapKeycode(keycode: pc_keyboard.KeyCode, modifiers: pc_keyboard.Modifiers, handle_ctrl: pc_keyboard.HandleControl) pc_keyboard.DecodedKey {
const map_to_unicode = handle_ctrl == .MapLettersToUnicode;
switch (keycode) {
.BackTick => return pc_keyboard.DecodedKey{ .Unicode = "²" },
.Escape => return pc_keyboard.DecodedKey{ .Unicode = "\x1B" },
.HashTilde => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "*" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "µ" };
}
},
.Key1 => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "1" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "&" };
}
},
.Key2 => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "2" };
} else if (modifiers.alt_gr) {
return pc_keyboard.DecodedKey{ .Unicode = "~" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "é" };
}
},
.Key3 => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "3" };
} else if (modifiers.alt_gr) {
return pc_keyboard.DecodedKey{ .Unicode = "#" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "\"" };
}
},
.Key4 => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "4" };
} else if (modifiers.alt_gr) {
return pc_keyboard.DecodedKey{ .Unicode = "{" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "'" };
}
},
.Key5 => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "5" };
} else if (modifiers.alt_gr) {
return pc_keyboard.DecodedKey{ .Unicode = "[" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "(" };
}
},
.Key6 => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "6" };
} else if (modifiers.alt_gr) {
return pc_keyboard.DecodedKey{ .Unicode = "|" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "-" };
}
},
.Key7 => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "7" };
} else if (modifiers.alt_gr) {
return pc_keyboard.DecodedKey{ .Unicode = "`" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "è" };
}
},
.Key8 => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "8" };
} else if (modifiers.alt_gr) {
return pc_keyboard.DecodedKey{ .Unicode = "\\" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "_" };
}
},
.Key9 => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "9" };
} else if (modifiers.alt_gr) {
return pc_keyboard.DecodedKey{ .Unicode = "^" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "ç" };
}
},
.Key0 => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "0" };
} else if (modifiers.alt_gr) {
return pc_keyboard.DecodedKey{ .Unicode = "@" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "à" };
}
},
.Minus => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "°" };
} else if (modifiers.alt_gr) {
return pc_keyboard.DecodedKey{ .Unicode = "]" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = ")" };
}
},
.Equals => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "+" };
} else if (modifiers.alt_gr) {
return pc_keyboard.DecodedKey{ .Unicode = "}" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "=" };
}
},
.Backspace => return pc_keyboard.DecodedKey{ .Unicode = "\x08" },
.Tab => return pc_keyboard.DecodedKey{ .Unicode = "\t" },
.Q => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{0011}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "A" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "a" };
}
},
.W => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{0017}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "Z" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "z" };
}
},
.E => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{0005}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "E" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "e" };
}
},
.R => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{0012}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "R" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "r" };
}
},
.T => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{0014}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "T" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "t" };
}
},
.Y => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{0019}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "Y" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "y" };
}
},
.U => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{0015}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "U" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "u" };
}
},
.I => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{0009}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "I" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "i" };
}
},
.O => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{000F}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "O" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "o" };
}
},
.P => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{0010}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "P" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "p" };
}
},
.BracketSquareLeft => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "¨" };
} else if (modifiers.alt_gr) {
return pc_keyboard.DecodedKey{ .Unicode = "ˇ" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "^" };
}
},
.BracketSquareRight => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "£" };
} else if (modifiers.alt_gr) {
return pc_keyboard.DecodedKey{ .Unicode = "¤" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "$" };
}
},
.BackSlash => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "µ" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "*" };
}
},
.A => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{0001}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "Q" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "q" };
}
},
.S => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{0013}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "S" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "s" };
}
},
.D => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{0004}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "D" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "d" };
}
},
.F => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{0006}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "F" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "f" };
}
},
.G => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{0007}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "G" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "g" };
}
},
.H => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{0008}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "H" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "h" };
}
},
.J => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{000A}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "J" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "j" };
}
},
.K => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{000B}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "K" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "k" };
}
},
.L => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{000C}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "L" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "l" };
}
},
.SemiColon => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "M" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "m" };
}
},
.Quote => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "%" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "ù" };
}
},
// Enter gives LF, not CRLF or CR
.Enter => return pc_keyboard.DecodedKey{ .Unicode = "\n" },
.Z => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{001A}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "W" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "w" };
}
},
.X => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{0018}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "X" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "x" };
}
},
.C => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{0003}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "C" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "c" };
}
},
.V => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{0016}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "V" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "v" };
}
},
.B => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{0002}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "B" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "b" };
}
},
.N => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{000E}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "N" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "n" };
}
},
.M => {
if (map_to_unicode and modifiers.isCtrl()) {
return pc_keyboard.DecodedKey{ .Unicode = "\u{000D}" };
} else if (modifiers.isCaps()) {
return pc_keyboard.DecodedKey{ .Unicode = "?" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "," };
}
},
.Comma => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "." };
} else {
return pc_keyboard.DecodedKey{ .Unicode = ";" };
}
},
.Fullstop => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "/" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = ":" };
}
},
.Slash => {
if (modifiers.isShifted()) {
return pc_keyboard.DecodedKey{ .Unicode = "§" };
} else {
return pc_keyboard.DecodedKey{ .Unicode = "!" };
}
},
.Spacebar => return pc_keyboard.DecodedKey{ .Unicode = " " },
.Delete => return pc_keyboard.DecodedKey{ .Unicode = "\x7F" },
.NumpadSlash => return pc_keyboard.DecodedKey{ .Unicode = "/" },
.NumpadStar => return pc_keyboard.DecodedKey{ .Unicode = "*" },
.NumpadMinus => return pc_keyboard.DecodedKey{ .Unicode = "-" },
.Numpad7 => {
if (modifiers.numlock) return pc_keyboard.DecodedKey{ .Unicode = "7" } else return pc_keyboard.DecodedKey{ .RawKey = .Home };
},
.Numpad8 => {
if (modifiers.numlock) return pc_keyboard.DecodedKey{ .Unicode = "8" } else return pc_keyboard.DecodedKey{ .RawKey = .ArrowUp };
},
.Numpad9 => {
if (modifiers.numlock) return pc_keyboard.DecodedKey{ .Unicode = "9" } else return pc_keyboard.DecodedKey{ .RawKey = .PageUp };
},
.NumpadPlus => return pc_keyboard.DecodedKey{ .Unicode = "+" },
.Numpad4 => {
if (modifiers.numlock) return pc_keyboard.DecodedKey{ .Unicode = "4" } else return pc_keyboard.DecodedKey{ .RawKey = .ArrowLeft };
},
.Numpad5 => return pc_keyboard.DecodedKey{ .Unicode = "5" },
.Numpad6 => {
if (modifiers.numlock) return pc_keyboard.DecodedKey{ .Unicode = "6" } else return pc_keyboard.DecodedKey{ .RawKey = .ArrowRight };
},
.Numpad1 => {
if (modifiers.numlock) return pc_keyboard.DecodedKey{ .Unicode = "1" } else return pc_keyboard.DecodedKey{ .RawKey = .End };
},
.Numpad2 => {
if (modifiers.numlock) return pc_keyboard.DecodedKey{ .Unicode = "2" } else return pc_keyboard.DecodedKey{ .RawKey = .ArrowDown };
},
.Numpad3 => {
if (modifiers.numlock) return pc_keyboard.DecodedKey{ .Unicode = "3" } else return pc_keyboard.DecodedKey{ .RawKey = .PageDown };
},
.Numpad0 => {
if (modifiers.numlock) return pc_keyboard.DecodedKey{ .Unicode = "0" } else return pc_keyboard.DecodedKey{ .RawKey = .Insert };
},
.NumpadPeriod => {
if (modifiers.numlock) return pc_keyboard.DecodedKey{ .Unicode = "." } else return pc_keyboard.DecodedKey{ .Unicode = "\x7F" };
},
.NumpadEnter => return pc_keyboard.DecodedKey{ .Unicode = "\n" },
.ShiftLeft => return pc_keyboard.DecodedKey{ .Unicode = "<" },
else => return pc_keyboard.DecodedKey{ .RawKey = keycode },
}
}
comptime {
@import("std").testing.refAllDecls(@This());
}
|
src/keycode/layouts/azerty.zig
|
const std = @import("std");
const debug = std.debug;
const mem = std.mem;
const testing = std.testing;
/// Returns a set of type `Out` which contains the intersection of `a` and `b`.
pub fn intersect(comptime Out: type, allocator: mem.Allocator, a: anytype, b: anytype) !Out {
var res = Out.init(allocator);
try intersectInline(&res, a, b);
return res;
}
/// Stores the intersection of `a` and `b` in `out`.
pub fn intersectInline(out: anytype, a: anytype, b: anytype) !void {
var it = a.iterator();
while (it.next()) |entry| {
if (b.get(entry.key_ptr.*) != null)
_ = try out.put(entry.key_ptr.*, {});
}
}
test "intersect" {
const Set = std.AutoHashMap(u8, void);
for ([_][3][]const u8{
.{ "abc", "abc", "abc" },
.{ "abc", "bcd", "bc" },
.{ "abc", "def", "" },
}) |test_case| {
var a = try initWithMembers(Set, testing.allocator, test_case[0]);
defer a.deinit();
var b = try initWithMembers(Set, testing.allocator, test_case[1]);
defer b.deinit();
var expect = try initWithMembers(Set, testing.allocator, test_case[2]);
defer expect.deinit();
var res_a = try intersect(Set, testing.allocator, a, b);
defer res_a.deinit();
var res_b = try intersect(Set, testing.allocator, b, a);
defer res_b.deinit();
try expectEqual(expect, res_a);
try expectEqual(expect, res_b);
}
}
/// Puts all items of a slice/array into `set`.
pub fn putMany(set: anytype, members: anytype) !void {
for (members) |member|
_ = try set.put(member, {});
}
/// Initializes a set of type `Set` with the members contained in the array/slice
/// `members`.
pub fn initWithMembers(comptime Set: type, allocator: mem.Allocator, members: anytype) !Set {
var set = Set.init(allocator);
errdefer set.deinit();
try putMany(&set, members);
return set;
}
/// Checks that the two sets `a` and `b` contains the exact same members.
pub fn eql(a: anytype, b: anytype) bool {
if (a.count() != b.count())
return false;
var it = a.iterator();
while (it.next()) |entry| {
if (b.get(entry.key_ptr.*) == null)
return false;
}
return true;
}
/// Tests that the set `actual` is equal to the set `expect`.
pub fn expectEqual(expect: anytype, actual: anytype) !void {
try testing.expect(eql(expect, actual));
}
|
src/common/set.zig
|
const std = @import("std");
const assert = std.debug.assert;
const mem = std.mem;
const Allocator = std.mem.Allocator;
const MeasuredAllocator = @This();
allocator: Allocator,
child_allocator: Allocator,
state: State,
/// Inner state of MeasuredAllocator. Can be stored rather than the entire MeasuredAllocator as a
/// memory-saving optimization.
pub const State = struct {
peak_memory_usage_bytes: usize = 0,
current_memory_usage_bytes: usize = 0,
pub fn promote(self: State, child_allocator: Allocator) MeasuredAllocator {
return .{
.allocator = Allocator{
.allocFn = alloc,
.resizeFn = resize,
},
.child_allocator = child_allocator,
.state = self,
};
}
};
const BufNode = std.SinglyLinkedList([]u8).Node;
pub fn init(child_allocator: Allocator) MeasuredAllocator {
return (State{}).promote(child_allocator);
}
fn alloc(allocator: Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) ![]u8 {
const self = @fieldParentPtr(MeasuredAllocator, "allocator", allocator);
const m = try self.child_allocator.allocFn(self.child_allocator, n, ptr_align, len_align, ra);
self.state.current_memory_usage_bytes += n;
if (self.state.current_memory_usage_bytes > self.state.peak_memory_usage_bytes) self.state.peak_memory_usage_bytes = self.state.current_memory_usage_bytes;
return m;
}
fn resize(allocator: Allocator, buf: []u8, buf_align: u29, new_len: usize, len_align: u29, ret_addr: usize) Allocator.Error!usize {
const self = @fieldParentPtr(MeasuredAllocator, "allocator", allocator);
const final_len = try self.child_allocator.resizeFn(self.child_allocator, buf, buf_align, new_len, len_align, ret_addr);
self.state.current_memory_usage_bytes -= buf.len - new_len;
if (self.state.current_memory_usage_bytes > self.state.peak_memory_usage_bytes) self.state.peak_memory_usage_bytes = self.state.current_memory_usage_bytes;
return final_len;
}
|
src/MeasuredAllocator.zig
|
pub const CVT_SECONDS = @as(u32, 1);
pub const CRYPTPROTECT_PROMPT_ON_UNPROTECT = @as(u32, 1);
pub const CRYPTPROTECT_PROMPT_ON_PROTECT = @as(u32, 2);
pub const CRYPTPROTECT_PROMPT_RESERVED = @as(u32, 4);
pub const CRYPTPROTECT_PROMPT_STRONG = @as(u32, 8);
pub const CRYPTPROTECT_PROMPT_REQUIRE_STRONG = @as(u32, 16);
pub const CRYPTPROTECT_UI_FORBIDDEN = @as(u32, 1);
pub const CRYPTPROTECT_LOCAL_MACHINE = @as(u32, 4);
pub const CRYPTPROTECT_CRED_SYNC = @as(u32, 8);
pub const CRYPTPROTECT_AUDIT = @as(u32, 16);
pub const CRYPTPROTECT_NO_RECOVERY = @as(u32, 32);
pub const CRYPTPROTECT_VERIFY_PROTECTION = @as(u32, 64);
pub const CRYPTPROTECT_CRED_REGENERATE = @as(u32, 128);
pub const CRYPTPROTECT_FIRST_RESERVED_FLAGVAL = @as(u32, 268435455);
pub const CRYPTPROTECT_LAST_RESERVED_FLAGVAL = @as(u32, 4294967295);
pub const CRYPTPROTECTMEMORY_BLOCK_SIZE = @as(u32, 16);
pub const CRYPTPROTECTMEMORY_SAME_PROCESS = @as(u32, 0);
pub const CRYPTPROTECTMEMORY_CROSS_PROCESS = @as(u32, 1);
pub const CRYPTPROTECTMEMORY_SAME_LOGON = @as(u32, 2);
pub const DSSI_READ_ONLY = @as(u32, 1);
pub const DSSI_NO_ACCESS_CHECK = @as(u32, 2);
pub const DSSI_NO_EDIT_SACL = @as(u32, 4);
pub const DSSI_NO_EDIT_OWNER = @as(u32, 8);
pub const DSSI_IS_ROOT = @as(u32, 16);
pub const DSSI_NO_FILTER = @as(u32, 32);
pub const DSSI_NO_READONLY_MESSAGE = @as(u32, 64);
pub const CRYPTCAT_MAX_MEMBERTAG = @as(u32, 64);
pub const CRYPTCAT_MEMBER_SORTED = @as(u32, 1073741824);
pub const CRYPTCAT_ATTR_AUTHENTICATED = @as(u32, 268435456);
pub const CRYPTCAT_ATTR_UNAUTHENTICATED = @as(u32, 536870912);
pub const CRYPTCAT_ATTR_NAMEASCII = @as(u32, 1);
pub const CRYPTCAT_ATTR_NAMEOBJID = @as(u32, 2);
pub const CRYPTCAT_ATTR_DATAASCII = @as(u32, 65536);
pub const CRYPTCAT_ATTR_DATABASE64 = @as(u32, 131072);
pub const CRYPTCAT_ATTR_DATAREPLACE = @as(u32, 262144);
pub const CRYPTCAT_ATTR_NO_AUTO_COMPAT_ENTRY = @as(u32, 16777216);
pub const CRYPTCAT_E_AREA_HEADER = @as(u32, 0);
pub const CRYPTCAT_E_AREA_MEMBER = @as(u32, 65536);
pub const CRYPTCAT_E_AREA_ATTRIBUTE = @as(u32, 131072);
pub const CRYPTCAT_E_CDF_UNSUPPORTED = @as(u32, 1);
pub const CRYPTCAT_E_CDF_DUPLICATE = @as(u32, 2);
pub const CRYPTCAT_E_CDF_TAGNOTFOUND = @as(u32, 4);
pub const CRYPTCAT_E_CDF_MEMBER_FILE_PATH = @as(u32, 65537);
pub const CRYPTCAT_E_CDF_MEMBER_INDIRECTDATA = @as(u32, 65538);
pub const CRYPTCAT_E_CDF_MEMBER_FILENOTFOUND = @as(u32, 65540);
pub const CRYPTCAT_E_CDF_BAD_GUID_CONV = @as(u32, 131073);
pub const CRYPTCAT_E_CDF_ATTR_TOOFEWVALUES = @as(u32, 131074);
pub const CRYPTCAT_E_CDF_ATTR_TYPECOMBO = @as(u32, 131076);
pub const CRYPTCAT_ADDCATALOG_NONE = @as(u32, 0);
pub const CRYPTCAT_ADDCATALOG_HARDLINK = @as(u32, 1);
pub const MSSIP_FLAGS_PROHIBIT_RESIZE_ON_CREATE = @as(u32, 65536);
pub const MSSIP_FLAGS_USE_CATALOG = @as(u32, 131072);
pub const MSSIP_FLAGS_MULTI_HASH = @as(u32, 262144);
pub const SPC_INC_PE_RESOURCES_FLAG = @as(u32, 128);
pub const SPC_INC_PE_DEBUG_INFO_FLAG = @as(u32, 64);
pub const SPC_INC_PE_IMPORT_ADDR_TABLE_FLAG = @as(u32, 32);
pub const SPC_EXC_PE_PAGE_HASHES_FLAG = @as(u32, 16);
pub const SPC_INC_PE_PAGE_HASHES_FLAG = @as(u32, 256);
pub const SPC_DIGEST_GENERATE_FLAG = @as(u32, 512);
pub const SPC_DIGEST_SIGN_FLAG = @as(u32, 1024);
pub const SPC_DIGEST_SIGN_EX_FLAG = @as(u32, 16384);
pub const SPC_RELAXED_PE_MARKER_CHECK = @as(u32, 2048);
pub const SPC_MARKER_CHECK_SKIP_SIP_INDIRECT_DATA_FLAG = @as(u32, 1);
pub const SIP_CAP_SET_VERSION_2 = @as(u32, 2);
pub const SIP_CAP_SET_VERSION_3 = @as(u32, 3);
pub const SIP_CAP_SET_CUR_VER = @as(u32, 3);
pub const SIP_CAP_FLAG_SEALING = @as(u32, 1);
pub const SIP_MAX_MAGIC_NUMBER = @as(u32, 4);
pub const cNodetypeSceTemplateServices = Guid.initString("24a7f717-1f0c-11d1-affb-00c04fb984f9");
pub const cNodetypeSceAnalysisServices = Guid.initString("678050c7-1ff8-11d1-affb-00c04fb984f9");
pub const cNodetypeSceEventLog = Guid.initString("2ce06698-4bf3-11d1-8c30-00c04fb984f9");
pub const SCESTATUS_SUCCESS = @as(i32, 0);
pub const SCESTATUS_INVALID_PARAMETER = @as(i32, 1);
pub const SCESTATUS_RECORD_NOT_FOUND = @as(i32, 2);
pub const SCESTATUS_INVALID_DATA = @as(i32, 3);
pub const SCESTATUS_OBJECT_EXIST = @as(i32, 4);
pub const SCESTATUS_BUFFER_TOO_SMALL = @as(i32, 5);
pub const SCESTATUS_PROFILE_NOT_FOUND = @as(i32, 6);
pub const SCESTATUS_BAD_FORMAT = @as(i32, 7);
pub const SCESTATUS_NOT_ENOUGH_RESOURCE = @as(i32, 8);
pub const SCESTATUS_ACCESS_DENIED = @as(i32, 9);
pub const SCESTATUS_CANT_DELETE = @as(i32, 10);
pub const SCESTATUS_PREFIX_OVERFLOW = @as(i32, 11);
pub const SCESTATUS_OTHER_ERROR = @as(i32, 12);
pub const SCESTATUS_ALREADY_RUNNING = @as(i32, 13);
pub const SCESTATUS_SERVICE_NOT_SUPPORT = @as(i32, 14);
pub const SCESTATUS_MOD_NOT_FOUND = @as(i32, 15);
pub const SCESTATUS_EXCEPTION_IN_SERVER = @as(i32, 16);
pub const SCESTATUS_NO_TEMPLATE_GIVEN = @as(i32, 17);
pub const SCESTATUS_NO_MAPPING = @as(i32, 18);
pub const SCESTATUS_TRUST_FAIL = @as(i32, 19);
pub const SCESVC_ENUMERATION_MAX = @as(i32, 100);
pub const TPMVSC_DEFAULT_ADMIN_ALGORITHM_ID = @as(u32, 130);
pub const SAFER_SCOPEID_MACHINE = @as(u32, 1);
pub const SAFER_SCOPEID_USER = @as(u32, 2);
pub const SAFER_LEVELID_FULLYTRUSTED = @as(u32, 262144);
pub const SAFER_LEVELID_NORMALUSER = @as(u32, 131072);
pub const SAFER_LEVELID_CONSTRAINED = @as(u32, 65536);
pub const SAFER_LEVELID_UNTRUSTED = @as(u32, 4096);
pub const SAFER_LEVELID_DISALLOWED = @as(u32, 0);
pub const SAFER_LEVEL_OPEN = @as(u32, 1);
pub const SAFER_MAX_FRIENDLYNAME_SIZE = @as(u32, 256);
pub const SAFER_MAX_DESCRIPTION_SIZE = @as(u32, 256);
pub const SAFER_MAX_HASH_SIZE = @as(u32, 64);
pub const SAFER_CRITERIA_IMAGEPATH = @as(u32, 1);
pub const SAFER_CRITERIA_NOSIGNEDHASH = @as(u32, 2);
pub const SAFER_CRITERIA_IMAGEHASH = @as(u32, 4);
pub const SAFER_CRITERIA_AUTHENTICODE = @as(u32, 8);
pub const SAFER_CRITERIA_URLZONE = @as(u32, 16);
pub const SAFER_CRITERIA_APPX_PACKAGE = @as(u32, 32);
pub const SAFER_CRITERIA_IMAGEPATH_NT = @as(u32, 4096);
pub const SAFER_POLICY_JOBID_MASK = @as(u32, 4278190080);
pub const SAFER_POLICY_JOBID_CONSTRAINED = @as(u32, 67108864);
pub const SAFER_POLICY_JOBID_UNTRUSTED = @as(u32, 50331648);
pub const SAFER_POLICY_ONLY_EXES = @as(u32, 65536);
pub const SAFER_POLICY_SANDBOX_INERT = @as(u32, 131072);
pub const SAFER_POLICY_HASH_DUPLICATE = @as(u32, 262144);
pub const SAFER_POLICY_ONLY_AUDIT = @as(u32, 4096);
pub const SAFER_POLICY_BLOCK_CLIENT_UI = @as(u32, 8192);
pub const SAFER_POLICY_UIFLAGS_MASK = @as(u32, 255);
pub const SAFER_POLICY_UIFLAGS_INFORMATION_PROMPT = @as(u32, 1);
pub const SAFER_POLICY_UIFLAGS_OPTION_PROMPT = @as(u32, 2);
pub const SAFER_POLICY_UIFLAGS_HIDDEN = @as(u32, 4);
pub const WINTRUST_MAX_HEADER_BYTES_TO_MAP_DEFAULT = @as(u32, 10485760);
pub const WINTRUST_MAX_HASH_BYTES_TO_MAP_DEFAULT = @as(u32, 1048576);
pub const WSS_VERIFY_SEALING = @as(u32, 4);
pub const WSS_INPUT_FLAG_MASK = @as(u32, 7);
pub const WSS_OUT_SEALING_STATUS_VERIFIED = @as(u32, 2147483648);
pub const WSS_OUT_HAS_SEALING_INTENT = @as(u32, 1073741824);
pub const WSS_OUT_FILE_SUPPORTS_SEAL = @as(u32, 536870912);
pub const WSS_OUTPUT_FLAG_MASK = @as(u32, 3758096384);
pub const TRUSTERROR_STEP_WVTPARAMS = @as(u32, 0);
pub const TRUSTERROR_STEP_FILEIO = @as(u32, 2);
pub const TRUSTERROR_STEP_SIP = @as(u32, 3);
pub const TRUSTERROR_STEP_SIPSUBJINFO = @as(u32, 5);
pub const TRUSTERROR_STEP_CATALOGFILE = @as(u32, 6);
pub const TRUSTERROR_STEP_CERTSTORE = @as(u32, 7);
pub const TRUSTERROR_STEP_MESSAGE = @as(u32, 8);
pub const TRUSTERROR_STEP_MSG_SIGNERCOUNT = @as(u32, 9);
pub const TRUSTERROR_STEP_MSG_INNERCNTTYPE = @as(u32, 10);
pub const TRUSTERROR_STEP_MSG_INNERCNT = @as(u32, 11);
pub const TRUSTERROR_STEP_MSG_STORE = @as(u32, 12);
pub const TRUSTERROR_STEP_MSG_SIGNERINFO = @as(u32, 13);
pub const TRUSTERROR_STEP_MSG_SIGNERCERT = @as(u32, 14);
pub const TRUSTERROR_STEP_MSG_CERTCHAIN = @as(u32, 15);
pub const TRUSTERROR_STEP_MSG_COUNTERSIGINFO = @as(u32, 16);
pub const TRUSTERROR_STEP_MSG_COUNTERSIGCERT = @as(u32, 17);
pub const TRUSTERROR_STEP_VERIFY_MSGHASH = @as(u32, 18);
pub const TRUSTERROR_STEP_VERIFY_MSGINDIRECTDATA = @as(u32, 19);
pub const TRUSTERROR_STEP_FINAL_WVTINIT = @as(u32, 30);
pub const TRUSTERROR_STEP_FINAL_INITPROV = @as(u32, 31);
pub const TRUSTERROR_STEP_FINAL_OBJPROV = @as(u32, 32);
pub const TRUSTERROR_STEP_FINAL_SIGPROV = @as(u32, 33);
pub const TRUSTERROR_STEP_FINAL_CERTPROV = @as(u32, 34);
pub const TRUSTERROR_STEP_FINAL_CERTCHKPROV = @as(u32, 35);
pub const TRUSTERROR_STEP_FINAL_POLICYPROV = @as(u32, 36);
pub const TRUSTERROR_STEP_FINAL_UIPROV = @as(u32, 37);
pub const TRUSTERROR_MAX_STEPS = @as(u32, 38);
pub const WSS_OBJTRUST_SUPPORT = @as(u32, 1);
pub const WSS_SIGTRUST_SUPPORT = @as(u32, 2);
pub const WSS_CERTTRUST_SUPPORT = @as(u32, 4);
pub const WT_CURRENT_VERSION = @as(u32, 512);
pub const WT_ADD_ACTION_ID_RET_RESULT_FLAG = @as(u32, 1);
pub const SPC_UUID_LENGTH = @as(u32, 16);
pub const WIN_CERT_REVISION_1_0 = @as(u32, 256);
pub const WIN_CERT_REVISION_2_0 = @as(u32, 512);
pub const WIN_CERT_TYPE_X509 = @as(u32, 1);
pub const WIN_CERT_TYPE_PKCS_SIGNED_DATA = @as(u32, 2);
pub const WIN_CERT_TYPE_RESERVED_1 = @as(u32, 3);
pub const WIN_CERT_TYPE_TS_STACK_SIGNED = @as(u32, 4);
pub const WT_TRUSTDBDIALOG_NO_UI_FLAG = @as(u32, 1);
pub const WT_TRUSTDBDIALOG_ONLY_PUB_TAB_FLAG = @as(u32, 2);
pub const WT_TRUSTDBDIALOG_WRITE_LEGACY_REG_FLAG = @as(u32, 256);
pub const WT_TRUSTDBDIALOG_WRITE_IEAK_STORE_FLAG = @as(u32, 512);
pub const WLX_VERSION_1_0 = @as(u32, 65536);
pub const WLX_VERSION_1_1 = @as(u32, 65537);
pub const WLX_VERSION_1_2 = @as(u32, 65538);
pub const WLX_VERSION_1_3 = @as(u32, 65539);
pub const WLX_VERSION_1_4 = @as(u32, 65540);
pub const WLX_SAS_TYPE_TIMEOUT = @as(u32, 0);
pub const WLX_SAS_TYPE_CTRL_ALT_DEL = @as(u32, 1);
pub const WLX_SAS_TYPE_SCRNSVR_TIMEOUT = @as(u32, 2);
pub const WLX_SAS_TYPE_SCRNSVR_ACTIVITY = @as(u32, 3);
pub const WLX_SAS_TYPE_USER_LOGOFF = @as(u32, 4);
pub const WLX_SAS_TYPE_SC_INSERT = @as(u32, 5);
pub const WLX_SAS_TYPE_SC_REMOVE = @as(u32, 6);
pub const WLX_SAS_TYPE_AUTHENTICATED = @as(u32, 7);
pub const WLX_SAS_TYPE_SC_FIRST_READER_ARRIVED = @as(u32, 8);
pub const WLX_SAS_TYPE_SC_LAST_READER_REMOVED = @as(u32, 9);
pub const WLX_SAS_TYPE_SWITCHUSER = @as(u32, 10);
pub const WLX_SAS_TYPE_MAX_MSFT_VALUE = @as(u32, 127);
pub const WLX_LOGON_OPT_NO_PROFILE = @as(u32, 1);
pub const WLX_PROFILE_TYPE_V1_0 = @as(u32, 1);
pub const WLX_PROFILE_TYPE_V2_0 = @as(u32, 2);
pub const WLX_SAS_ACTION_LOGON = @as(u32, 1);
pub const WLX_SAS_ACTION_NONE = @as(u32, 2);
pub const WLX_SAS_ACTION_LOCK_WKSTA = @as(u32, 3);
pub const WLX_SAS_ACTION_LOGOFF = @as(u32, 4);
pub const WLX_SAS_ACTION_PWD_CHANGED = @as(u32, 6);
pub const WLX_SAS_ACTION_TASKLIST = @as(u32, 7);
pub const WLX_SAS_ACTION_UNLOCK_WKSTA = @as(u32, 8);
pub const WLX_SAS_ACTION_FORCE_LOGOFF = @as(u32, 9);
pub const WLX_SAS_ACTION_SHUTDOWN_SLEEP = @as(u32, 12);
pub const WLX_SAS_ACTION_SHUTDOWN_SLEEP2 = @as(u32, 13);
pub const WLX_SAS_ACTION_SHUTDOWN_HIBERNATE = @as(u32, 14);
pub const WLX_SAS_ACTION_RECONNECTED = @as(u32, 15);
pub const WLX_SAS_ACTION_DELAYED_FORCE_LOGOFF = @as(u32, 16);
pub const WLX_SAS_ACTION_SWITCH_CONSOLE = @as(u32, 17);
pub const WLX_WM_SAS = @as(u32, 1625);
pub const WLX_DLG_SAS = @as(u32, 101);
pub const WLX_DLG_INPUT_TIMEOUT = @as(u32, 102);
pub const WLX_DLG_SCREEN_SAVER_TIMEOUT = @as(u32, 103);
pub const WLX_DLG_USER_LOGOFF = @as(u32, 104);
pub const WLX_DIRECTORY_LENGTH = @as(u32, 256);
pub const WLX_CREDENTIAL_TYPE_V1_0 = @as(u32, 1);
pub const WLX_CREDENTIAL_TYPE_V2_0 = @as(u32, 2);
pub const WLX_CONSOLESWITCHCREDENTIAL_TYPE_V1_0 = @as(u32, 1);
pub const STATUSMSG_OPTION_NOANIMATION = @as(u32, 1);
pub const STATUSMSG_OPTION_SETFOREGROUND = @as(u32, 2);
pub const WLX_DESKTOP_NAME = @as(u32, 1);
pub const WLX_DESKTOP_HANDLE = @as(u32, 2);
pub const WLX_CREATE_INSTANCE_ONLY = @as(u32, 1);
pub const WLX_CREATE_USER = @as(u32, 2);
pub const WLX_OPTION_USE_CTRL_ALT_DEL = @as(u32, 1);
pub const WLX_OPTION_CONTEXT_POINTER = @as(u32, 2);
pub const WLX_OPTION_USE_SMART_CARD = @as(u32, 3);
pub const WLX_OPTION_FORCE_LOGOFF_TIME = @as(u32, 4);
pub const WLX_OPTION_IGNORE_AUTO_LOGON = @as(u32, 8);
pub const WLX_OPTION_NO_SWITCH_ON_SAS = @as(u32, 9);
pub const WLX_OPTION_SMART_CARD_PRESENT = @as(u32, 65537);
pub const WLX_OPTION_SMART_CARD_INFO = @as(u32, 65538);
pub const WLX_OPTION_DISPATCH_TABLE_SIZE = @as(u32, 65539);
//--------------------------------------------------------------------------------
// Section: Types (303)
//--------------------------------------------------------------------------------
pub const TOKEN_PRIVILEGES_ATTRIBUTES = enum(u32) {
ENABLED = 2,
ENABLED_BY_DEFAULT = 1,
REMOVED = 4,
USED_FOR_ACCESS = 2147483648,
_,
pub fn initFlags(o: struct {
ENABLED: u1 = 0,
ENABLED_BY_DEFAULT: u1 = 0,
REMOVED: u1 = 0,
USED_FOR_ACCESS: u1 = 0,
}) TOKEN_PRIVILEGES_ATTRIBUTES {
return @intToEnum(TOKEN_PRIVILEGES_ATTRIBUTES,
(if (o.ENABLED == 1) @enumToInt(TOKEN_PRIVILEGES_ATTRIBUTES.ENABLED) else 0)
| (if (o.ENABLED_BY_DEFAULT == 1) @enumToInt(TOKEN_PRIVILEGES_ATTRIBUTES.ENABLED_BY_DEFAULT) else 0)
| (if (o.REMOVED == 1) @enumToInt(TOKEN_PRIVILEGES_ATTRIBUTES.REMOVED) else 0)
| (if (o.USED_FOR_ACCESS == 1) @enumToInt(TOKEN_PRIVILEGES_ATTRIBUTES.USED_FOR_ACCESS) else 0)
);
}
};
pub const SE_PRIVILEGE_ENABLED = TOKEN_PRIVILEGES_ATTRIBUTES.ENABLED;
pub const SE_PRIVILEGE_ENABLED_BY_DEFAULT = TOKEN_PRIVILEGES_ATTRIBUTES.ENABLED_BY_DEFAULT;
pub const SE_PRIVILEGE_REMOVED = TOKEN_PRIVILEGES_ATTRIBUTES.REMOVED;
pub const SE_PRIVILEGE_USED_FOR_ACCESS = TOKEN_PRIVILEGES_ATTRIBUTES.USED_FOR_ACCESS;
pub const LOGON32_PROVIDER = enum(u32) {
DEFAULT = 0,
WINNT50 = 3,
WINNT40 = 2,
};
pub const LOGON32_PROVIDER_DEFAULT = LOGON32_PROVIDER.DEFAULT;
pub const LOGON32_PROVIDER_WINNT50 = LOGON32_PROVIDER.WINNT50;
pub const LOGON32_PROVIDER_WINNT40 = LOGON32_PROVIDER.WINNT40;
pub const SCE_LOG_ERR_LEVEL = enum(u32) {
ALWAYS = 0,
ERROR = 1,
DETAIL = 2,
DEBUG = 3,
};
pub const SCE_LOG_LEVEL_ALWAYS = SCE_LOG_ERR_LEVEL.ALWAYS;
pub const SCE_LOG_LEVEL_ERROR = SCE_LOG_ERR_LEVEL.ERROR;
pub const SCE_LOG_LEVEL_DETAIL = SCE_LOG_ERR_LEVEL.DETAIL;
pub const SCE_LOG_LEVEL_DEBUG = SCE_LOG_ERR_LEVEL.DEBUG;
pub const CREATE_RESTRICTED_TOKEN_FLAGS = enum(u32) {
DISABLE_MAX_PRIVILEGE = 1,
SANDBOX_INERT = 2,
LUA_TOKEN = 4,
WRITE_RESTRICTED = 8,
_,
pub fn initFlags(o: struct {
DISABLE_MAX_PRIVILEGE: u1 = 0,
SANDBOX_INERT: u1 = 0,
LUA_TOKEN: u1 = 0,
WRITE_RESTRICTED: u1 = 0,
}) CREATE_RESTRICTED_TOKEN_FLAGS {
return @intToEnum(CREATE_RESTRICTED_TOKEN_FLAGS,
(if (o.DISABLE_MAX_PRIVILEGE == 1) @enumToInt(CREATE_RESTRICTED_TOKEN_FLAGS.DISABLE_MAX_PRIVILEGE) else 0)
| (if (o.SANDBOX_INERT == 1) @enumToInt(CREATE_RESTRICTED_TOKEN_FLAGS.SANDBOX_INERT) else 0)
| (if (o.LUA_TOKEN == 1) @enumToInt(CREATE_RESTRICTED_TOKEN_FLAGS.LUA_TOKEN) else 0)
| (if (o.WRITE_RESTRICTED == 1) @enumToInt(CREATE_RESTRICTED_TOKEN_FLAGS.WRITE_RESTRICTED) else 0)
);
}
};
pub const DISABLE_MAX_PRIVILEGE = CREATE_RESTRICTED_TOKEN_FLAGS.DISABLE_MAX_PRIVILEGE;
pub const SANDBOX_INERT = CREATE_RESTRICTED_TOKEN_FLAGS.SANDBOX_INERT;
pub const LUA_TOKEN = CREATE_RESTRICTED_TOKEN_FLAGS.LUA_TOKEN;
pub const WRITE_RESTRICTED = CREATE_RESTRICTED_TOKEN_FLAGS.WRITE_RESTRICTED;
pub const LOGON32_LOGON = enum(u32) {
BATCH = 4,
INTERACTIVE = 2,
NETWORK = 3,
NETWORK_CLEARTEXT = 8,
NEW_CREDENTIALS = 9,
SERVICE = 5,
UNLOCK = 7,
};
pub const LOGON32_LOGON_BATCH = LOGON32_LOGON.BATCH;
pub const LOGON32_LOGON_INTERACTIVE = LOGON32_LOGON.INTERACTIVE;
pub const LOGON32_LOGON_NETWORK = LOGON32_LOGON.NETWORK;
pub const LOGON32_LOGON_NETWORK_CLEARTEXT = LOGON32_LOGON.NETWORK_CLEARTEXT;
pub const LOGON32_LOGON_NEW_CREDENTIALS = LOGON32_LOGON.NEW_CREDENTIALS;
pub const LOGON32_LOGON_SERVICE = LOGON32_LOGON.SERVICE;
pub const LOGON32_LOGON_UNLOCK = LOGON32_LOGON.UNLOCK;
pub const ACE_FLAGS = enum(u32) {
CONTAINER_INHERIT_ACE = 2,
FAILED_ACCESS_ACE_FLAG = 128,
INHERIT_ONLY_ACE = 8,
INHERITED_ACE = 16,
NO_PROPAGATE_INHERIT_ACE = 4,
OBJECT_INHERIT_ACE = 1,
SUCCESSFUL_ACCESS_ACE_FLAG = 64,
SUB_CONTAINERS_AND_OBJECTS_INHERIT = 3,
// SUB_CONTAINERS_ONLY_INHERIT = 2, this enum value conflicts with CONTAINER_INHERIT_ACE
// SUB_OBJECTS_ONLY_INHERIT = 1, this enum value conflicts with OBJECT_INHERIT_ACE
// INHERIT_NO_PROPAGATE = 4, this enum value conflicts with NO_PROPAGATE_INHERIT_ACE
// INHERIT_ONLY = 8, this enum value conflicts with INHERIT_ONLY_ACE
NO_INHERITANCE = 0,
// INHERIT_ONLY_ACE_ = 8, this enum value conflicts with INHERIT_ONLY_ACE
_,
pub fn initFlags(o: struct {
CONTAINER_INHERIT_ACE: u1 = 0,
FAILED_ACCESS_ACE_FLAG: u1 = 0,
INHERIT_ONLY_ACE: u1 = 0,
INHERITED_ACE: u1 = 0,
NO_PROPAGATE_INHERIT_ACE: u1 = 0,
OBJECT_INHERIT_ACE: u1 = 0,
SUCCESSFUL_ACCESS_ACE_FLAG: u1 = 0,
SUB_CONTAINERS_AND_OBJECTS_INHERIT: u1 = 0,
NO_INHERITANCE: u1 = 0,
}) ACE_FLAGS {
return @intToEnum(ACE_FLAGS,
(if (o.CONTAINER_INHERIT_ACE == 1) @enumToInt(ACE_FLAGS.CONTAINER_INHERIT_ACE) else 0)
| (if (o.FAILED_ACCESS_ACE_FLAG == 1) @enumToInt(ACE_FLAGS.FAILED_ACCESS_ACE_FLAG) else 0)
| (if (o.INHERIT_ONLY_ACE == 1) @enumToInt(ACE_FLAGS.INHERIT_ONLY_ACE) else 0)
| (if (o.INHERITED_ACE == 1) @enumToInt(ACE_FLAGS.INHERITED_ACE) else 0)
| (if (o.NO_PROPAGATE_INHERIT_ACE == 1) @enumToInt(ACE_FLAGS.NO_PROPAGATE_INHERIT_ACE) else 0)
| (if (o.OBJECT_INHERIT_ACE == 1) @enumToInt(ACE_FLAGS.OBJECT_INHERIT_ACE) else 0)
| (if (o.SUCCESSFUL_ACCESS_ACE_FLAG == 1) @enumToInt(ACE_FLAGS.SUCCESSFUL_ACCESS_ACE_FLAG) else 0)
| (if (o.SUB_CONTAINERS_AND_OBJECTS_INHERIT == 1) @enumToInt(ACE_FLAGS.SUB_CONTAINERS_AND_OBJECTS_INHERIT) else 0)
| (if (o.NO_INHERITANCE == 1) @enumToInt(ACE_FLAGS.NO_INHERITANCE) else 0)
);
}
};
pub const CONTAINER_INHERIT_ACE = ACE_FLAGS.CONTAINER_INHERIT_ACE;
pub const FAILED_ACCESS_ACE_FLAG = ACE_FLAGS.FAILED_ACCESS_ACE_FLAG;
pub const INHERIT_ONLY_ACE = ACE_FLAGS.INHERIT_ONLY_ACE;
pub const INHERITED_ACE = ACE_FLAGS.INHERITED_ACE;
pub const NO_PROPAGATE_INHERIT_ACE = ACE_FLAGS.NO_PROPAGATE_INHERIT_ACE;
pub const OBJECT_INHERIT_ACE = ACE_FLAGS.OBJECT_INHERIT_ACE;
pub const SUCCESSFUL_ACCESS_ACE_FLAG = ACE_FLAGS.SUCCESSFUL_ACCESS_ACE_FLAG;
pub const SUB_CONTAINERS_AND_OBJECTS_INHERIT = ACE_FLAGS.SUB_CONTAINERS_AND_OBJECTS_INHERIT;
pub const SUB_CONTAINERS_ONLY_INHERIT = ACE_FLAGS.CONTAINER_INHERIT_ACE;
pub const SUB_OBJECTS_ONLY_INHERIT = ACE_FLAGS.OBJECT_INHERIT_ACE;
pub const INHERIT_NO_PROPAGATE = ACE_FLAGS.NO_PROPAGATE_INHERIT_ACE;
pub const INHERIT_ONLY = ACE_FLAGS.INHERIT_ONLY_ACE;
pub const NO_INHERITANCE = ACE_FLAGS.NO_INHERITANCE;
pub const INHERIT_ONLY_ACE_ = ACE_FLAGS.INHERIT_ONLY_ACE;
pub const SECURITY_AUTO_INHERIT_FLAGS = enum(u32) {
AVOID_OWNER_CHECK = 16,
AVOID_OWNER_RESTRICTION = 4096,
AVOID_PRIVILEGE_CHECK = 8,
DACL_AUTO_INHERIT = 1,
DEFAULT_DESCRIPTOR_FOR_OBJECT = 4,
DEFAULT_GROUP_FROM_PARENT = 64,
DEFAULT_OWNER_FROM_PARENT = 32,
MACL_NO_EXECUTE_UP = 1024,
MACL_NO_READ_UP = 512,
MACL_NO_WRITE_UP = 256,
SACL_AUTO_INHERIT = 2,
_,
pub fn initFlags(o: struct {
AVOID_OWNER_CHECK: u1 = 0,
AVOID_OWNER_RESTRICTION: u1 = 0,
AVOID_PRIVILEGE_CHECK: u1 = 0,
DACL_AUTO_INHERIT: u1 = 0,
DEFAULT_DESCRIPTOR_FOR_OBJECT: u1 = 0,
DEFAULT_GROUP_FROM_PARENT: u1 = 0,
DEFAULT_OWNER_FROM_PARENT: u1 = 0,
MACL_NO_EXECUTE_UP: u1 = 0,
MACL_NO_READ_UP: u1 = 0,
MACL_NO_WRITE_UP: u1 = 0,
SACL_AUTO_INHERIT: u1 = 0,
}) SECURITY_AUTO_INHERIT_FLAGS {
return @intToEnum(SECURITY_AUTO_INHERIT_FLAGS,
(if (o.AVOID_OWNER_CHECK == 1) @enumToInt(SECURITY_AUTO_INHERIT_FLAGS.AVOID_OWNER_CHECK) else 0)
| (if (o.AVOID_OWNER_RESTRICTION == 1) @enumToInt(SECURITY_AUTO_INHERIT_FLAGS.AVOID_OWNER_RESTRICTION) else 0)
| (if (o.AVOID_PRIVILEGE_CHECK == 1) @enumToInt(SECURITY_AUTO_INHERIT_FLAGS.AVOID_PRIVILEGE_CHECK) else 0)
| (if (o.DACL_AUTO_INHERIT == 1) @enumToInt(SECURITY_AUTO_INHERIT_FLAGS.DACL_AUTO_INHERIT) else 0)
| (if (o.DEFAULT_DESCRIPTOR_FOR_OBJECT == 1) @enumToInt(SECURITY_AUTO_INHERIT_FLAGS.DEFAULT_DESCRIPTOR_FOR_OBJECT) else 0)
| (if (o.DEFAULT_GROUP_FROM_PARENT == 1) @enumToInt(SECURITY_AUTO_INHERIT_FLAGS.DEFAULT_GROUP_FROM_PARENT) else 0)
| (if (o.DEFAULT_OWNER_FROM_PARENT == 1) @enumToInt(SECURITY_AUTO_INHERIT_FLAGS.DEFAULT_OWNER_FROM_PARENT) else 0)
| (if (o.MACL_NO_EXECUTE_UP == 1) @enumToInt(SECURITY_AUTO_INHERIT_FLAGS.MACL_NO_EXECUTE_UP) else 0)
| (if (o.MACL_NO_READ_UP == 1) @enumToInt(SECURITY_AUTO_INHERIT_FLAGS.MACL_NO_READ_UP) else 0)
| (if (o.MACL_NO_WRITE_UP == 1) @enumToInt(SECURITY_AUTO_INHERIT_FLAGS.MACL_NO_WRITE_UP) else 0)
| (if (o.SACL_AUTO_INHERIT == 1) @enumToInt(SECURITY_AUTO_INHERIT_FLAGS.SACL_AUTO_INHERIT) else 0)
);
}
};
pub const SEF_AVOID_OWNER_CHECK = SECURITY_AUTO_INHERIT_FLAGS.AVOID_OWNER_CHECK;
pub const SEF_AVOID_OWNER_RESTRICTION = SECURITY_AUTO_INHERIT_FLAGS.AVOID_OWNER_RESTRICTION;
pub const SEF_AVOID_PRIVILEGE_CHECK = SECURITY_AUTO_INHERIT_FLAGS.AVOID_PRIVILEGE_CHECK;
pub const SEF_DACL_AUTO_INHERIT = SECURITY_AUTO_INHERIT_FLAGS.DACL_AUTO_INHERIT;
pub const SEF_DEFAULT_DESCRIPTOR_FOR_OBJECT = SECURITY_AUTO_INHERIT_FLAGS.DEFAULT_DESCRIPTOR_FOR_OBJECT;
pub const SEF_DEFAULT_GROUP_FROM_PARENT = SECURITY_AUTO_INHERIT_FLAGS.DEFAULT_GROUP_FROM_PARENT;
pub const SEF_DEFAULT_OWNER_FROM_PARENT = SECURITY_AUTO_INHERIT_FLAGS.DEFAULT_OWNER_FROM_PARENT;
pub const SEF_MACL_NO_EXECUTE_UP = SECURITY_AUTO_INHERIT_FLAGS.MACL_NO_EXECUTE_UP;
pub const SEF_MACL_NO_READ_UP = SECURITY_AUTO_INHERIT_FLAGS.MACL_NO_READ_UP;
pub const SEF_MACL_NO_WRITE_UP = SECURITY_AUTO_INHERIT_FLAGS.MACL_NO_WRITE_UP;
pub const SEF_SACL_AUTO_INHERIT = SECURITY_AUTO_INHERIT_FLAGS.SACL_AUTO_INHERIT;
pub const SAFER_COMPUTE_TOKEN_FROM_LEVEL_FLAGS = enum(u32) {
NULL_IF_EQUAL = 1,
COMPARE_ONLY = 2,
MAKE_INERT = 4,
WANT_FLAGS = 8,
_,
pub fn initFlags(o: struct {
NULL_IF_EQUAL: u1 = 0,
COMPARE_ONLY: u1 = 0,
MAKE_INERT: u1 = 0,
WANT_FLAGS: u1 = 0,
}) SAFER_COMPUTE_TOKEN_FROM_LEVEL_FLAGS {
return @intToEnum(SAFER_COMPUTE_TOKEN_FROM_LEVEL_FLAGS,
(if (o.NULL_IF_EQUAL == 1) @enumToInt(SAFER_COMPUTE_TOKEN_FROM_LEVEL_FLAGS.NULL_IF_EQUAL) else 0)
| (if (o.COMPARE_ONLY == 1) @enumToInt(SAFER_COMPUTE_TOKEN_FROM_LEVEL_FLAGS.COMPARE_ONLY) else 0)
| (if (o.MAKE_INERT == 1) @enumToInt(SAFER_COMPUTE_TOKEN_FROM_LEVEL_FLAGS.MAKE_INERT) else 0)
| (if (o.WANT_FLAGS == 1) @enumToInt(SAFER_COMPUTE_TOKEN_FROM_LEVEL_FLAGS.WANT_FLAGS) else 0)
);
}
};
pub const SAFER_TOKEN_NULL_IF_EQUAL = SAFER_COMPUTE_TOKEN_FROM_LEVEL_FLAGS.NULL_IF_EQUAL;
pub const SAFER_TOKEN_COMPARE_ONLY = SAFER_COMPUTE_TOKEN_FROM_LEVEL_FLAGS.COMPARE_ONLY;
pub const SAFER_TOKEN_MAKE_INERT = SAFER_COMPUTE_TOKEN_FROM_LEVEL_FLAGS.MAKE_INERT;
pub const SAFER_TOKEN_WANT_FLAGS = SAFER_COMPUTE_TOKEN_FROM_LEVEL_FLAGS.WANT_FLAGS;
pub const WINTRUST_GET_DEFAULT_FOR_USAGE_ACTION = enum(u32) {
ALLOCANDFILL = 1,
FREE = 2,
};
pub const DWACTION_ALLOCANDFILL = WINTRUST_GET_DEFAULT_FOR_USAGE_ACTION.ALLOCANDFILL;
pub const DWACTION_FREE = WINTRUST_GET_DEFAULT_FOR_USAGE_ACTION.FREE;
pub const ACE_REVISION = enum(u32) {
N = 2,
_DS = 4,
};
pub const ACL_REVISION = ACE_REVISION.N;
pub const ACL_REVISION_DS = ACE_REVISION._DS;
pub const WINTRUST_POLICY_FLAGS = enum(u32) {
TRUSTTEST = 32,
TESTCANBEVALID = 128,
IGNOREEXPIRATION = 256,
IGNOREREVOKATION = 512,
OFFLINEOK_IND = 1024,
OFFLINEOK_COM = 2048,
OFFLINEOKNBU_IND = 4096,
OFFLINEOKNBU_COM = 8192,
VERIFY_V1_OFF = 65536,
IGNOREREVOCATIONONTS = 131072,
ALLOWONLYPERTRUST = 262144,
_,
pub fn initFlags(o: struct {
TRUSTTEST: u1 = 0,
TESTCANBEVALID: u1 = 0,
IGNOREEXPIRATION: u1 = 0,
IGNOREREVOKATION: u1 = 0,
OFFLINEOK_IND: u1 = 0,
OFFLINEOK_COM: u1 = 0,
OFFLINEOKNBU_IND: u1 = 0,
OFFLINEOKNBU_COM: u1 = 0,
VERIFY_V1_OFF: u1 = 0,
IGNOREREVOCATIONONTS: u1 = 0,
ALLOWONLYPERTRUST: u1 = 0,
}) WINTRUST_POLICY_FLAGS {
return @intToEnum(WINTRUST_POLICY_FLAGS,
(if (o.TRUSTTEST == 1) @enumToInt(WINTRUST_POLICY_FLAGS.TRUSTTEST) else 0)
| (if (o.TESTCANBEVALID == 1) @enumToInt(WINTRUST_POLICY_FLAGS.TESTCANBEVALID) else 0)
| (if (o.IGNOREEXPIRATION == 1) @enumToInt(WINTRUST_POLICY_FLAGS.IGNOREEXPIRATION) else 0)
| (if (o.IGNOREREVOKATION == 1) @enumToInt(WINTRUST_POLICY_FLAGS.IGNOREREVOKATION) else 0)
| (if (o.OFFLINEOK_IND == 1) @enumToInt(WINTRUST_POLICY_FLAGS.OFFLINEOK_IND) else 0)
| (if (o.OFFLINEOK_COM == 1) @enumToInt(WINTRUST_POLICY_FLAGS.OFFLINEOK_COM) else 0)
| (if (o.OFFLINEOKNBU_IND == 1) @enumToInt(WINTRUST_POLICY_FLAGS.OFFLINEOKNBU_IND) else 0)
| (if (o.OFFLINEOKNBU_COM == 1) @enumToInt(WINTRUST_POLICY_FLAGS.OFFLINEOKNBU_COM) else 0)
| (if (o.VERIFY_V1_OFF == 1) @enumToInt(WINTRUST_POLICY_FLAGS.VERIFY_V1_OFF) else 0)
| (if (o.IGNOREREVOCATIONONTS == 1) @enumToInt(WINTRUST_POLICY_FLAGS.IGNOREREVOCATIONONTS) else 0)
| (if (o.ALLOWONLYPERTRUST == 1) @enumToInt(WINTRUST_POLICY_FLAGS.ALLOWONLYPERTRUST) else 0)
);
}
};
pub const WTPF_TRUSTTEST = WINTRUST_POLICY_FLAGS.TRUSTTEST;
pub const WTPF_TESTCANBEVALID = WINTRUST_POLICY_FLAGS.TESTCANBEVALID;
pub const WTPF_IGNOREEXPIRATION = WINTRUST_POLICY_FLAGS.IGNOREEXPIRATION;
pub const WTPF_IGNOREREVOKATION = WINTRUST_POLICY_FLAGS.IGNOREREVOKATION;
pub const WTPF_OFFLINEOK_IND = WINTRUST_POLICY_FLAGS.OFFLINEOK_IND;
pub const WTPF_OFFLINEOK_COM = WINTRUST_POLICY_FLAGS.OFFLINEOK_COM;
pub const WTPF_OFFLINEOKNBU_IND = WINTRUST_POLICY_FLAGS.OFFLINEOKNBU_IND;
pub const WTPF_OFFLINEOKNBU_COM = WINTRUST_POLICY_FLAGS.OFFLINEOKNBU_COM;
pub const WTPF_VERIFY_V1_OFF = WINTRUST_POLICY_FLAGS.VERIFY_V1_OFF;
pub const WTPF_IGNOREREVOCATIONONTS = WINTRUST_POLICY_FLAGS.IGNOREREVOCATIONONTS;
pub const WTPF_ALLOWONLYPERTRUST = WINTRUST_POLICY_FLAGS.ALLOWONLYPERTRUST;
pub const WLX_SHUTDOWN_TYPE = enum(u32) {
N = 5,
_REBOOT = 11,
_POWER_OFF = 10,
};
pub const WLX_SAS_ACTION_SHUTDOWN = WLX_SHUTDOWN_TYPE.N;
pub const WLX_SAS_ACTION_SHUTDOWN_REBOOT = WLX_SHUTDOWN_TYPE._REBOOT;
pub const WLX_SAS_ACTION_SHUTDOWN_POWER_OFF = WLX_SHUTDOWN_TYPE._POWER_OFF;
pub const CRYPTCAT_VERSION = enum(u32) {
@"1" = 256,
@"2" = 512,
};
pub const CRYPTCAT_VERSION_1 = CRYPTCAT_VERSION.@"1";
pub const CRYPTCAT_VERSION_2 = CRYPTCAT_VERSION.@"2";
pub const CRYPTCAT_OPEN_FLAGS = enum(u32) {
ALWAYS = 2,
CREATENEW = 1,
EXISTING = 4,
EXCLUDE_PAGE_HASHES = 65536,
INCLUDE_PAGE_HASHES = 131072,
VERIFYSIGHASH = 268435456,
NO_CONTENT_HCRYPTMSG = 536870912,
SORTED = 1073741824,
FLAGS_MASK = 4294901760,
_,
pub fn initFlags(o: struct {
ALWAYS: u1 = 0,
CREATENEW: u1 = 0,
EXISTING: u1 = 0,
EXCLUDE_PAGE_HASHES: u1 = 0,
INCLUDE_PAGE_HASHES: u1 = 0,
VERIFYSIGHASH: u1 = 0,
NO_CONTENT_HCRYPTMSG: u1 = 0,
SORTED: u1 = 0,
FLAGS_MASK: u1 = 0,
}) CRYPTCAT_OPEN_FLAGS {
return @intToEnum(CRYPTCAT_OPEN_FLAGS,
(if (o.ALWAYS == 1) @enumToInt(CRYPTCAT_OPEN_FLAGS.ALWAYS) else 0)
| (if (o.CREATENEW == 1) @enumToInt(CRYPTCAT_OPEN_FLAGS.CREATENEW) else 0)
| (if (o.EXISTING == 1) @enumToInt(CRYPTCAT_OPEN_FLAGS.EXISTING) else 0)
| (if (o.EXCLUDE_PAGE_HASHES == 1) @enumToInt(CRYPTCAT_OPEN_FLAGS.EXCLUDE_PAGE_HASHES) else 0)
| (if (o.INCLUDE_PAGE_HASHES == 1) @enumToInt(CRYPTCAT_OPEN_FLAGS.INCLUDE_PAGE_HASHES) else 0)
| (if (o.VERIFYSIGHASH == 1) @enumToInt(CRYPTCAT_OPEN_FLAGS.VERIFYSIGHASH) else 0)
| (if (o.NO_CONTENT_HCRYPTMSG == 1) @enumToInt(CRYPTCAT_OPEN_FLAGS.NO_CONTENT_HCRYPTMSG) else 0)
| (if (o.SORTED == 1) @enumToInt(CRYPTCAT_OPEN_FLAGS.SORTED) else 0)
| (if (o.FLAGS_MASK == 1) @enumToInt(CRYPTCAT_OPEN_FLAGS.FLAGS_MASK) else 0)
);
}
};
pub const CRYPTCAT_OPEN_ALWAYS = CRYPTCAT_OPEN_FLAGS.ALWAYS;
pub const CRYPTCAT_OPEN_CREATENEW = CRYPTCAT_OPEN_FLAGS.CREATENEW;
pub const CRYPTCAT_OPEN_EXISTING = CRYPTCAT_OPEN_FLAGS.EXISTING;
pub const CRYPTCAT_OPEN_EXCLUDE_PAGE_HASHES = CRYPTCAT_OPEN_FLAGS.EXCLUDE_PAGE_HASHES;
pub const CRYPTCAT_OPEN_INCLUDE_PAGE_HASHES = CRYPTCAT_OPEN_FLAGS.INCLUDE_PAGE_HASHES;
pub const CRYPTCAT_OPEN_VERIFYSIGHASH = CRYPTCAT_OPEN_FLAGS.VERIFYSIGHASH;
pub const CRYPTCAT_OPEN_NO_CONTENT_HCRYPTMSG = CRYPTCAT_OPEN_FLAGS.NO_CONTENT_HCRYPTMSG;
pub const CRYPTCAT_OPEN_SORTED = CRYPTCAT_OPEN_FLAGS.SORTED;
pub const CRYPTCAT_OPEN_FLAGS_MASK = CRYPTCAT_OPEN_FLAGS.FLAGS_MASK;
pub const TOKEN_MANDATORY_POLICY_ID = enum(u32) {
OFF = 0,
NO_WRITE_UP = 1,
NEW_PROCESS_MIN = 2,
VALID_MASK = 3,
};
pub const TOKEN_MANDATORY_POLICY_OFF = TOKEN_MANDATORY_POLICY_ID.OFF;
pub const TOKEN_MANDATORY_POLICY_NO_WRITE_UP = TOKEN_MANDATORY_POLICY_ID.NO_WRITE_UP;
pub const TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN = TOKEN_MANDATORY_POLICY_ID.NEW_PROCESS_MIN;
pub const TOKEN_MANDATORY_POLICY_VALID_MASK = TOKEN_MANDATORY_POLICY_ID.VALID_MASK;
pub const SYSTEM_AUDIT_OBJECT_ACE_FLAGS = enum(u32) {
OBJECT_TYPE_PRESENT = 1,
INHERITED_OBJECT_TYPE_PRESENT = 2,
_,
pub fn initFlags(o: struct {
OBJECT_TYPE_PRESENT: u1 = 0,
INHERITED_OBJECT_TYPE_PRESENT: u1 = 0,
}) SYSTEM_AUDIT_OBJECT_ACE_FLAGS {
return @intToEnum(SYSTEM_AUDIT_OBJECT_ACE_FLAGS,
(if (o.OBJECT_TYPE_PRESENT == 1) @enumToInt(SYSTEM_AUDIT_OBJECT_ACE_FLAGS.OBJECT_TYPE_PRESENT) else 0)
| (if (o.INHERITED_OBJECT_TYPE_PRESENT == 1) @enumToInt(SYSTEM_AUDIT_OBJECT_ACE_FLAGS.INHERITED_OBJECT_TYPE_PRESENT) else 0)
);
}
};
pub const ACE_OBJECT_TYPE_PRESENT = SYSTEM_AUDIT_OBJECT_ACE_FLAGS.OBJECT_TYPE_PRESENT;
pub const ACE_INHERITED_OBJECT_TYPE_PRESENT = SYSTEM_AUDIT_OBJECT_ACE_FLAGS.INHERITED_OBJECT_TYPE_PRESENT;
pub const CLAIM_SECURITY_ATTRIBUTE_FLAGS = enum(u32) {
NON_INHERITABLE = 1,
VALUE_CASE_SENSITIVE = 2,
USE_FOR_DENY_ONLY = 4,
DISABLED_BY_DEFAULT = 8,
DISABLED = 16,
MANDATORY = 32,
_,
pub fn initFlags(o: struct {
NON_INHERITABLE: u1 = 0,
VALUE_CASE_SENSITIVE: u1 = 0,
USE_FOR_DENY_ONLY: u1 = 0,
DISABLED_BY_DEFAULT: u1 = 0,
DISABLED: u1 = 0,
MANDATORY: u1 = 0,
}) CLAIM_SECURITY_ATTRIBUTE_FLAGS {
return @intToEnum(CLAIM_SECURITY_ATTRIBUTE_FLAGS,
(if (o.NON_INHERITABLE == 1) @enumToInt(CLAIM_SECURITY_ATTRIBUTE_FLAGS.NON_INHERITABLE) else 0)
| (if (o.VALUE_CASE_SENSITIVE == 1) @enumToInt(CLAIM_SECURITY_ATTRIBUTE_FLAGS.VALUE_CASE_SENSITIVE) else 0)
| (if (o.USE_FOR_DENY_ONLY == 1) @enumToInt(CLAIM_SECURITY_ATTRIBUTE_FLAGS.USE_FOR_DENY_ONLY) else 0)
| (if (o.DISABLED_BY_DEFAULT == 1) @enumToInt(CLAIM_SECURITY_ATTRIBUTE_FLAGS.DISABLED_BY_DEFAULT) else 0)
| (if (o.DISABLED == 1) @enumToInt(CLAIM_SECURITY_ATTRIBUTE_FLAGS.DISABLED) else 0)
| (if (o.MANDATORY == 1) @enumToInt(CLAIM_SECURITY_ATTRIBUTE_FLAGS.MANDATORY) else 0)
);
}
};
pub const CLAIM_SECURITY_ATTRIBUTE_NON_INHERITABLE = CLAIM_SECURITY_ATTRIBUTE_FLAGS.NON_INHERITABLE;
pub const CLAIM_SECURITY_ATTRIBUTE_VALUE_CASE_SENSITIVE = CLAIM_SECURITY_ATTRIBUTE_FLAGS.VALUE_CASE_SENSITIVE;
pub const CLAIM_SECURITY_ATTRIBUTE_USE_FOR_DENY_ONLY = CLAIM_SECURITY_ATTRIBUTE_FLAGS.USE_FOR_DENY_ONLY;
pub const CLAIM_SECURITY_ATTRIBUTE_DISABLED_BY_DEFAULT = CLAIM_SECURITY_ATTRIBUTE_FLAGS.DISABLED_BY_DEFAULT;
pub const CLAIM_SECURITY_ATTRIBUTE_DISABLED = CLAIM_SECURITY_ATTRIBUTE_FLAGS.DISABLED;
pub const CLAIM_SECURITY_ATTRIBUTE_MANDATORY = CLAIM_SECURITY_ATTRIBUTE_FLAGS.MANDATORY;
pub const WINTRUST_DATA_UICHOICE = enum(u32) {
ALL = 1,
NONE = 2,
NOBAD = 3,
NOGOOD = 4,
};
pub const WTD_UI_ALL = WINTRUST_DATA_UICHOICE.ALL;
pub const WTD_UI_NONE = WINTRUST_DATA_UICHOICE.NONE;
pub const WTD_UI_NOBAD = WINTRUST_DATA_UICHOICE.NOBAD;
pub const WTD_UI_NOGOOD = WINTRUST_DATA_UICHOICE.NOGOOD;
pub const WINTRUST_SIGNATURE_SETTINGS_FLAGS = enum(u32) {
VERIFY_SPECIFIC = 1,
GET_SECONDARY_SIG_COUNT = 2,
};
pub const WSS_VERIFY_SPECIFIC = WINTRUST_SIGNATURE_SETTINGS_FLAGS.VERIFY_SPECIFIC;
pub const WSS_GET_SECONDARY_SIG_COUNT = WINTRUST_SIGNATURE_SETTINGS_FLAGS.GET_SECONDARY_SIG_COUNT;
pub const WINTRUST_DATA_STATE_ACTION = enum(u32) {
IGNORE = 0,
VERIFY = 1,
CLOSE = 2,
AUTO_CACHE = 3,
AUTO_CACHE_FLUSH = 4,
};
pub const WTD_STATEACTION_IGNORE = WINTRUST_DATA_STATE_ACTION.IGNORE;
pub const WTD_STATEACTION_VERIFY = WINTRUST_DATA_STATE_ACTION.VERIFY;
pub const WTD_STATEACTION_CLOSE = WINTRUST_DATA_STATE_ACTION.CLOSE;
pub const WTD_STATEACTION_AUTO_CACHE = WINTRUST_DATA_STATE_ACTION.AUTO_CACHE;
pub const WTD_STATEACTION_AUTO_CACHE_FLUSH = WINTRUST_DATA_STATE_ACTION.AUTO_CACHE_FLUSH;
pub const CLAIM_SECURITY_ATTRIBUTE_VALUE_TYPE = enum(u16) {
INT64 = 1,
UINT64 = 2,
STRING = 3,
OCTET_STRING = 16,
FQBN = 4,
SID = 5,
BOOLEAN = 6,
};
pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_INT64 = CLAIM_SECURITY_ATTRIBUTE_VALUE_TYPE.INT64;
pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_UINT64 = CLAIM_SECURITY_ATTRIBUTE_VALUE_TYPE.UINT64;
pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_STRING = CLAIM_SECURITY_ATTRIBUTE_VALUE_TYPE.STRING;
pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_OCTET_STRING = CLAIM_SECURITY_ATTRIBUTE_VALUE_TYPE.OCTET_STRING;
pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_FQBN = CLAIM_SECURITY_ATTRIBUTE_VALUE_TYPE.FQBN;
pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_SID = CLAIM_SECURITY_ATTRIBUTE_VALUE_TYPE.SID;
pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_BOOLEAN = CLAIM_SECURITY_ATTRIBUTE_VALUE_TYPE.BOOLEAN;
pub const WINTRUST_DATA_UNION_CHOICE = enum(u32) {
FILE = 1,
CATALOG = 2,
BLOB = 3,
SIGNER = 4,
CERT = 5,
};
pub const WTD_CHOICE_FILE = WINTRUST_DATA_UNION_CHOICE.FILE;
pub const WTD_CHOICE_CATALOG = WINTRUST_DATA_UNION_CHOICE.CATALOG;
pub const WTD_CHOICE_BLOB = WINTRUST_DATA_UNION_CHOICE.BLOB;
pub const WTD_CHOICE_SIGNER = WINTRUST_DATA_UNION_CHOICE.SIGNER;
pub const WTD_CHOICE_CERT = WINTRUST_DATA_UNION_CHOICE.CERT;
pub const WINTRUST_DATA_REVOCATION_CHECKS = enum(u32) {
NONE = 0,
WHOLECHAIN = 1,
};
pub const WTD_REVOKE_NONE = WINTRUST_DATA_REVOCATION_CHECKS.NONE;
pub const WTD_REVOKE_WHOLECHAIN = WINTRUST_DATA_REVOCATION_CHECKS.WHOLECHAIN;
pub const WINTRUST_DATA_UICONTEXT = enum(u32) {
EXECUTE = 0,
INSTALL = 1,
};
pub const WTD_UICONTEXT_EXECUTE = WINTRUST_DATA_UICONTEXT.EXECUTE;
pub const WTD_UICONTEXT_INSTALL = WINTRUST_DATA_UICONTEXT.INSTALL;
pub const PLSA_AP_CALL_PACKAGE_UNTRUSTED = fn(
ClientRequest: ?*?*c_void,
// TODO: what to do with BytesParamIndex 3?
ProtocolSubmitBuffer: ?*c_void,
ClientBufferBase: ?*c_void,
SubmitBufferLength: u32,
ProtocolReturnBuffer: ?*?*c_void,
ReturnBufferLength: ?*u32,
ProtocolStatus: ?*i32,
) callconv(@import("std").os.windows.WINAPI) NTSTATUS;
pub const SEC_THREAD_START = fn(
lpThreadParameter: ?*c_void,
) callconv(@import("std").os.windows.WINAPI) u32;
pub const TOKEN_ACCESS_MASK = enum(u32) {
DELETE = 65536,
READ_CONTROL = 131072,
WRITE_DAC = 262144,
WRITE_OWNER = 524288,
ACCESS_SYSTEM_SECURITY = 16777216,
ASSIGN_PRIMARY = 1,
DUPLICATE = 2,
IMPERSONATE = 4,
QUERY = 8,
QUERY_SOURCE = 16,
ADJUST_PRIVILEGES = 32,
ADJUST_GROUPS = 64,
ADJUST_DEFAULT = 128,
ADJUST_SESSIONID = 256,
ALL_ACCESS = 983295,
_,
pub fn initFlags(o: struct {
DELETE: u1 = 0,
READ_CONTROL: u1 = 0,
WRITE_DAC: u1 = 0,
WRITE_OWNER: u1 = 0,
ACCESS_SYSTEM_SECURITY: u1 = 0,
ASSIGN_PRIMARY: u1 = 0,
DUPLICATE: u1 = 0,
IMPERSONATE: u1 = 0,
QUERY: u1 = 0,
QUERY_SOURCE: u1 = 0,
ADJUST_PRIVILEGES: u1 = 0,
ADJUST_GROUPS: u1 = 0,
ADJUST_DEFAULT: u1 = 0,
ADJUST_SESSIONID: u1 = 0,
ALL_ACCESS: u1 = 0,
}) TOKEN_ACCESS_MASK {
return @intToEnum(TOKEN_ACCESS_MASK,
(if (o.DELETE == 1) @enumToInt(TOKEN_ACCESS_MASK.DELETE) else 0)
| (if (o.READ_CONTROL == 1) @enumToInt(TOKEN_ACCESS_MASK.READ_CONTROL) else 0)
| (if (o.WRITE_DAC == 1) @enumToInt(TOKEN_ACCESS_MASK.WRITE_DAC) else 0)
| (if (o.WRITE_OWNER == 1) @enumToInt(TOKEN_ACCESS_MASK.WRITE_OWNER) else 0)
| (if (o.ACCESS_SYSTEM_SECURITY == 1) @enumToInt(TOKEN_ACCESS_MASK.ACCESS_SYSTEM_SECURITY) else 0)
| (if (o.ASSIGN_PRIMARY == 1) @enumToInt(TOKEN_ACCESS_MASK.ASSIGN_PRIMARY) else 0)
| (if (o.DUPLICATE == 1) @enumToInt(TOKEN_ACCESS_MASK.DUPLICATE) else 0)
| (if (o.IMPERSONATE == 1) @enumToInt(TOKEN_ACCESS_MASK.IMPERSONATE) else 0)
| (if (o.QUERY == 1) @enumToInt(TOKEN_ACCESS_MASK.QUERY) else 0)
| (if (o.QUERY_SOURCE == 1) @enumToInt(TOKEN_ACCESS_MASK.QUERY_SOURCE) else 0)
| (if (o.ADJUST_PRIVILEGES == 1) @enumToInt(TOKEN_ACCESS_MASK.ADJUST_PRIVILEGES) else 0)
| (if (o.ADJUST_GROUPS == 1) @enumToInt(TOKEN_ACCESS_MASK.ADJUST_GROUPS) else 0)
| (if (o.ADJUST_DEFAULT == 1) @enumToInt(TOKEN_ACCESS_MASK.ADJUST_DEFAULT) else 0)
| (if (o.ADJUST_SESSIONID == 1) @enumToInt(TOKEN_ACCESS_MASK.ADJUST_SESSIONID) else 0)
| (if (o.ALL_ACCESS == 1) @enumToInt(TOKEN_ACCESS_MASK.ALL_ACCESS) else 0)
);
}
};
pub const TOKEN_DELETE = TOKEN_ACCESS_MASK.DELETE;
pub const TOKEN_READ_CONTROL = TOKEN_ACCESS_MASK.READ_CONTROL;
pub const TOKEN_WRITE_DAC = TOKEN_ACCESS_MASK.WRITE_DAC;
pub const TOKEN_WRITE_OWNER = TOKEN_ACCESS_MASK.WRITE_OWNER;
pub const TOKEN_ACCESS_SYSTEM_SECURITY = TOKEN_ACCESS_MASK.ACCESS_SYSTEM_SECURITY;
pub const TOKEN_ASSIGN_PRIMARY = TOKEN_ACCESS_MASK.ASSIGN_PRIMARY;
pub const TOKEN_DUPLICATE = TOKEN_ACCESS_MASK.DUPLICATE;
pub const TOKEN_IMPERSONATE = TOKEN_ACCESS_MASK.IMPERSONATE;
pub const TOKEN_QUERY = TOKEN_ACCESS_MASK.QUERY;
pub const TOKEN_QUERY_SOURCE = TOKEN_ACCESS_MASK.QUERY_SOURCE;
pub const TOKEN_ADJUST_PRIVILEGES = TOKEN_ACCESS_MASK.ADJUST_PRIVILEGES;
pub const TOKEN_ADJUST_GROUPS = TOKEN_ACCESS_MASK.ADJUST_GROUPS;
pub const TOKEN_ADJUST_DEFAULT = TOKEN_ACCESS_MASK.ADJUST_DEFAULT;
pub const TOKEN_ADJUST_SESSIONID = TOKEN_ACCESS_MASK.ADJUST_SESSIONID;
pub const TOKEN_ALL_ACCESS = TOKEN_ACCESS_MASK.ALL_ACCESS;
pub const HDIAGNOSTIC_DATA_QUERY_SESSION = isize;
pub const HDIAGNOSTIC_REPORT = isize;
pub const HDIAGNOSTIC_EVENT_TAG_DESCRIPTION = isize;
pub const HDIAGNOSTIC_EVENT_PRODUCER_DESCRIPTION = isize;
pub const HDIAGNOSTIC_EVENT_CATEGORY_DESCRIPTION = isize;
pub const HDIAGNOSTIC_RECORD = isize;
pub const NCRYPT_DESCRIPTOR_HANDLE = isize;
pub const NCRYPT_STREAM_HANDLE = isize;
pub const SAFER_LEVEL_HANDLE = isize;
pub const SC_HANDLE = isize;
pub const GENERIC_MAPPING = extern struct {
GenericRead: u32,
GenericWrite: u32,
GenericExecute: u32,
GenericAll: u32,
};
pub const LUID_AND_ATTRIBUTES = extern struct {
Luid: LUID,
Attributes: TOKEN_PRIVILEGES_ATTRIBUTES,
};
pub const SID_IDENTIFIER_AUTHORITY = extern struct {
Value: [6]u8,
};
pub const SID = extern struct {
Revision: u8,
SubAuthorityCount: u8,
IdentifierAuthority: SID_IDENTIFIER_AUTHORITY,
SubAuthority: [1]u32,
};
pub const SID_NAME_USE = enum(i32) {
User = 1,
Group = 2,
Domain = 3,
Alias = 4,
WellKnownGroup = 5,
DeletedAccount = 6,
Invalid = 7,
Unknown = 8,
Computer = 9,
Label = 10,
LogonSession = 11,
};
pub const SidTypeUser = SID_NAME_USE.User;
pub const SidTypeGroup = SID_NAME_USE.Group;
pub const SidTypeDomain = SID_NAME_USE.Domain;
pub const SidTypeAlias = SID_NAME_USE.Alias;
pub const SidTypeWellKnownGroup = SID_NAME_USE.WellKnownGroup;
pub const SidTypeDeletedAccount = SID_NAME_USE.DeletedAccount;
pub const SidTypeInvalid = SID_NAME_USE.Invalid;
pub const SidTypeUnknown = SID_NAME_USE.Unknown;
pub const SidTypeComputer = SID_NAME_USE.Computer;
pub const SidTypeLabel = SID_NAME_USE.Label;
pub const SidTypeLogonSession = SID_NAME_USE.LogonSession;
pub const SID_AND_ATTRIBUTES = extern struct {
Sid: ?PSID,
Attributes: u32,
};
pub const SID_AND_ATTRIBUTES_HASH = extern struct {
SidCount: u32,
SidAttr: ?*SID_AND_ATTRIBUTES,
Hash: [32]usize,
};
pub const WELL_KNOWN_SID_TYPE = enum(i32) {
NullSid = 0,
WorldSid = 1,
LocalSid = 2,
CreatorOwnerSid = 3,
CreatorGroupSid = 4,
CreatorOwnerServerSid = 5,
CreatorGroupServerSid = 6,
NtAuthoritySid = 7,
DialupSid = 8,
NetworkSid = 9,
BatchSid = 10,
InteractiveSid = 11,
ServiceSid = 12,
AnonymousSid = 13,
ProxySid = 14,
EnterpriseControllersSid = 15,
SelfSid = 16,
AuthenticatedUserSid = 17,
RestrictedCodeSid = 18,
TerminalServerSid = 19,
RemoteLogonIdSid = 20,
LogonIdsSid = 21,
LocalSystemSid = 22,
LocalServiceSid = 23,
NetworkServiceSid = 24,
BuiltinDomainSid = 25,
BuiltinAdministratorsSid = 26,
BuiltinUsersSid = 27,
BuiltinGuestsSid = 28,
BuiltinPowerUsersSid = 29,
BuiltinAccountOperatorsSid = 30,
BuiltinSystemOperatorsSid = 31,
BuiltinPrintOperatorsSid = 32,
BuiltinBackupOperatorsSid = 33,
BuiltinReplicatorSid = 34,
BuiltinPreWindows2000CompatibleAccessSid = 35,
BuiltinRemoteDesktopUsersSid = 36,
BuiltinNetworkConfigurationOperatorsSid = 37,
AccountAdministratorSid = 38,
AccountGuestSid = 39,
AccountKrbtgtSid = 40,
AccountDomainAdminsSid = 41,
AccountDomainUsersSid = 42,
AccountDomainGuestsSid = 43,
AccountComputersSid = 44,
AccountControllersSid = 45,
AccountCertAdminsSid = 46,
AccountSchemaAdminsSid = 47,
AccountEnterpriseAdminsSid = 48,
AccountPolicyAdminsSid = 49,
AccountRasAndIasServersSid = 50,
NTLMAuthenticationSid = 51,
DigestAuthenticationSid = 52,
SChannelAuthenticationSid = 53,
ThisOrganizationSid = 54,
OtherOrganizationSid = 55,
BuiltinIncomingForestTrustBuildersSid = 56,
BuiltinPerfMonitoringUsersSid = 57,
BuiltinPerfLoggingUsersSid = 58,
BuiltinAuthorizationAccessSid = 59,
BuiltinTerminalServerLicenseServersSid = 60,
BuiltinDCOMUsersSid = 61,
BuiltinIUsersSid = 62,
IUserSid = 63,
BuiltinCryptoOperatorsSid = 64,
UntrustedLabelSid = 65,
LowLabelSid = 66,
MediumLabelSid = 67,
HighLabelSid = 68,
SystemLabelSid = 69,
WriteRestrictedCodeSid = 70,
CreatorOwnerRightsSid = 71,
CacheablePrincipalsGroupSid = 72,
NonCacheablePrincipalsGroupSid = 73,
EnterpriseReadonlyControllersSid = 74,
AccountReadonlyControllersSid = 75,
BuiltinEventLogReadersGroup = 76,
NewEnterpriseReadonlyControllersSid = 77,
BuiltinCertSvcDComAccessGroup = 78,
MediumPlusLabelSid = 79,
LocalLogonSid = 80,
ConsoleLogonSid = 81,
ThisOrganizationCertificateSid = 82,
ApplicationPackageAuthoritySid = 83,
BuiltinAnyPackageSid = 84,
CapabilityInternetClientSid = 85,
CapabilityInternetClientServerSid = 86,
CapabilityPrivateNetworkClientServerSid = 87,
CapabilityPicturesLibrarySid = 88,
CapabilityVideosLibrarySid = 89,
CapabilityMusicLibrarySid = 90,
CapabilityDocumentsLibrarySid = 91,
CapabilitySharedUserCertificatesSid = 92,
CapabilityEnterpriseAuthenticationSid = 93,
CapabilityRemovableStorageSid = 94,
BuiltinRDSRemoteAccessServersSid = 95,
BuiltinRDSEndpointServersSid = 96,
BuiltinRDSManagementServersSid = 97,
UserModeDriversSid = 98,
BuiltinHyperVAdminsSid = 99,
AccountCloneableControllersSid = 100,
BuiltinAccessControlAssistanceOperatorsSid = 101,
BuiltinRemoteManagementUsersSid = 102,
AuthenticationAuthorityAssertedSid = 103,
AuthenticationServiceAssertedSid = 104,
LocalAccountSid = 105,
LocalAccountAndAdministratorSid = 106,
AccountProtectedUsersSid = 107,
CapabilityAppointmentsSid = 108,
CapabilityContactsSid = 109,
AccountDefaultSystemManagedSid = 110,
BuiltinDefaultSystemManagedGroupSid = 111,
BuiltinStorageReplicaAdminsSid = 112,
AccountKeyAdminsSid = 113,
AccountEnterpriseKeyAdminsSid = 114,
AuthenticationKeyTrustSid = 115,
AuthenticationKeyPropertyMFASid = 116,
AuthenticationKeyPropertyAttestationSid = 117,
AuthenticationFreshKeyAuthSid = 118,
BuiltinDeviceOwnersSid = 119,
};
pub const WinNullSid = WELL_KNOWN_SID_TYPE.NullSid;
pub const WinWorldSid = WELL_KNOWN_SID_TYPE.WorldSid;
pub const WinLocalSid = WELL_KNOWN_SID_TYPE.LocalSid;
pub const WinCreatorOwnerSid = WELL_KNOWN_SID_TYPE.CreatorOwnerSid;
pub const WinCreatorGroupSid = WELL_KNOWN_SID_TYPE.CreatorGroupSid;
pub const WinCreatorOwnerServerSid = WELL_KNOWN_SID_TYPE.CreatorOwnerServerSid;
pub const WinCreatorGroupServerSid = WELL_KNOWN_SID_TYPE.CreatorGroupServerSid;
pub const WinNtAuthoritySid = WELL_KNOWN_SID_TYPE.NtAuthoritySid;
pub const WinDialupSid = WELL_KNOWN_SID_TYPE.DialupSid;
pub const WinNetworkSid = WELL_KNOWN_SID_TYPE.NetworkSid;
pub const WinBatchSid = WELL_KNOWN_SID_TYPE.BatchSid;
pub const WinInteractiveSid = WELL_KNOWN_SID_TYPE.InteractiveSid;
pub const WinServiceSid = WELL_KNOWN_SID_TYPE.ServiceSid;
pub const WinAnonymousSid = WELL_KNOWN_SID_TYPE.AnonymousSid;
pub const WinProxySid = WELL_KNOWN_SID_TYPE.ProxySid;
pub const WinEnterpriseControllersSid = WELL_KNOWN_SID_TYPE.EnterpriseControllersSid;
pub const WinSelfSid = WELL_KNOWN_SID_TYPE.SelfSid;
pub const WinAuthenticatedUserSid = WELL_KNOWN_SID_TYPE.AuthenticatedUserSid;
pub const WinRestrictedCodeSid = WELL_KNOWN_SID_TYPE.RestrictedCodeSid;
pub const WinTerminalServerSid = WELL_KNOWN_SID_TYPE.TerminalServerSid;
pub const WinRemoteLogonIdSid = WELL_KNOWN_SID_TYPE.RemoteLogonIdSid;
pub const WinLogonIdsSid = WELL_KNOWN_SID_TYPE.LogonIdsSid;
pub const WinLocalSystemSid = WELL_KNOWN_SID_TYPE.LocalSystemSid;
pub const WinLocalServiceSid = WELL_KNOWN_SID_TYPE.LocalServiceSid;
pub const WinNetworkServiceSid = WELL_KNOWN_SID_TYPE.NetworkServiceSid;
pub const WinBuiltinDomainSid = WELL_KNOWN_SID_TYPE.BuiltinDomainSid;
pub const WinBuiltinAdministratorsSid = WELL_KNOWN_SID_TYPE.BuiltinAdministratorsSid;
pub const WinBuiltinUsersSid = WELL_KNOWN_SID_TYPE.BuiltinUsersSid;
pub const WinBuiltinGuestsSid = WELL_KNOWN_SID_TYPE.BuiltinGuestsSid;
pub const WinBuiltinPowerUsersSid = WELL_KNOWN_SID_TYPE.BuiltinPowerUsersSid;
pub const WinBuiltinAccountOperatorsSid = WELL_KNOWN_SID_TYPE.BuiltinAccountOperatorsSid;
pub const WinBuiltinSystemOperatorsSid = WELL_KNOWN_SID_TYPE.BuiltinSystemOperatorsSid;
pub const WinBuiltinPrintOperatorsSid = WELL_KNOWN_SID_TYPE.BuiltinPrintOperatorsSid;
pub const WinBuiltinBackupOperatorsSid = WELL_KNOWN_SID_TYPE.BuiltinBackupOperatorsSid;
pub const WinBuiltinReplicatorSid = WELL_KNOWN_SID_TYPE.BuiltinReplicatorSid;
pub const WinBuiltinPreWindows2000CompatibleAccessSid = WELL_KNOWN_SID_TYPE.BuiltinPreWindows2000CompatibleAccessSid;
pub const WinBuiltinRemoteDesktopUsersSid = WELL_KNOWN_SID_TYPE.BuiltinRemoteDesktopUsersSid;
pub const WinBuiltinNetworkConfigurationOperatorsSid = WELL_KNOWN_SID_TYPE.BuiltinNetworkConfigurationOperatorsSid;
pub const WinAccountAdministratorSid = WELL_KNOWN_SID_TYPE.AccountAdministratorSid;
pub const WinAccountGuestSid = WELL_KNOWN_SID_TYPE.AccountGuestSid;
pub const WinAccountKrbtgtSid = WELL_KNOWN_SID_TYPE.AccountKrbtgtSid;
pub const WinAccountDomainAdminsSid = WELL_KNOWN_SID_TYPE.AccountDomainAdminsSid;
pub const WinAccountDomainUsersSid = WELL_KNOWN_SID_TYPE.AccountDomainUsersSid;
pub const WinAccountDomainGuestsSid = WELL_KNOWN_SID_TYPE.AccountDomainGuestsSid;
pub const WinAccountComputersSid = WELL_KNOWN_SID_TYPE.AccountComputersSid;
pub const WinAccountControllersSid = WELL_KNOWN_SID_TYPE.AccountControllersSid;
pub const WinAccountCertAdminsSid = WELL_KNOWN_SID_TYPE.AccountCertAdminsSid;
pub const WinAccountSchemaAdminsSid = WELL_KNOWN_SID_TYPE.AccountSchemaAdminsSid;
pub const WinAccountEnterpriseAdminsSid = WELL_KNOWN_SID_TYPE.AccountEnterpriseAdminsSid;
pub const WinAccountPolicyAdminsSid = WELL_KNOWN_SID_TYPE.AccountPolicyAdminsSid;
pub const WinAccountRasAndIasServersSid = WELL_KNOWN_SID_TYPE.AccountRasAndIasServersSid;
pub const WinNTLMAuthenticationSid = WELL_KNOWN_SID_TYPE.NTLMAuthenticationSid;
pub const WinDigestAuthenticationSid = WELL_KNOWN_SID_TYPE.DigestAuthenticationSid;
pub const WinSChannelAuthenticationSid = WELL_KNOWN_SID_TYPE.SChannelAuthenticationSid;
pub const WinThisOrganizationSid = WELL_KNOWN_SID_TYPE.ThisOrganizationSid;
pub const WinOtherOrganizationSid = WELL_KNOWN_SID_TYPE.OtherOrganizationSid;
pub const WinBuiltinIncomingForestTrustBuildersSid = WELL_KNOWN_SID_TYPE.BuiltinIncomingForestTrustBuildersSid;
pub const WinBuiltinPerfMonitoringUsersSid = WELL_KNOWN_SID_TYPE.BuiltinPerfMonitoringUsersSid;
pub const WinBuiltinPerfLoggingUsersSid = WELL_KNOWN_SID_TYPE.BuiltinPerfLoggingUsersSid;
pub const WinBuiltinAuthorizationAccessSid = WELL_KNOWN_SID_TYPE.BuiltinAuthorizationAccessSid;
pub const WinBuiltinTerminalServerLicenseServersSid = WELL_KNOWN_SID_TYPE.BuiltinTerminalServerLicenseServersSid;
pub const WinBuiltinDCOMUsersSid = WELL_KNOWN_SID_TYPE.BuiltinDCOMUsersSid;
pub const WinBuiltinIUsersSid = WELL_KNOWN_SID_TYPE.BuiltinIUsersSid;
pub const WinIUserSid = WELL_KNOWN_SID_TYPE.IUserSid;
pub const WinBuiltinCryptoOperatorsSid = WELL_KNOWN_SID_TYPE.BuiltinCryptoOperatorsSid;
pub const WinUntrustedLabelSid = WELL_KNOWN_SID_TYPE.UntrustedLabelSid;
pub const WinLowLabelSid = WELL_KNOWN_SID_TYPE.LowLabelSid;
pub const WinMediumLabelSid = WELL_KNOWN_SID_TYPE.MediumLabelSid;
pub const WinHighLabelSid = WELL_KNOWN_SID_TYPE.HighLabelSid;
pub const WinSystemLabelSid = WELL_KNOWN_SID_TYPE.SystemLabelSid;
pub const WinWriteRestrictedCodeSid = WELL_KNOWN_SID_TYPE.WriteRestrictedCodeSid;
pub const WinCreatorOwnerRightsSid = WELL_KNOWN_SID_TYPE.CreatorOwnerRightsSid;
pub const WinCacheablePrincipalsGroupSid = WELL_KNOWN_SID_TYPE.CacheablePrincipalsGroupSid;
pub const WinNonCacheablePrincipalsGroupSid = WELL_KNOWN_SID_TYPE.NonCacheablePrincipalsGroupSid;
pub const WinEnterpriseReadonlyControllersSid = WELL_KNOWN_SID_TYPE.EnterpriseReadonlyControllersSid;
pub const WinAccountReadonlyControllersSid = WELL_KNOWN_SID_TYPE.AccountReadonlyControllersSid;
pub const WinBuiltinEventLogReadersGroup = WELL_KNOWN_SID_TYPE.BuiltinEventLogReadersGroup;
pub const WinNewEnterpriseReadonlyControllersSid = WELL_KNOWN_SID_TYPE.NewEnterpriseReadonlyControllersSid;
pub const WinBuiltinCertSvcDComAccessGroup = WELL_KNOWN_SID_TYPE.BuiltinCertSvcDComAccessGroup;
pub const WinMediumPlusLabelSid = WELL_KNOWN_SID_TYPE.MediumPlusLabelSid;
pub const WinLocalLogonSid = WELL_KNOWN_SID_TYPE.LocalLogonSid;
pub const WinConsoleLogonSid = WELL_KNOWN_SID_TYPE.ConsoleLogonSid;
pub const WinThisOrganizationCertificateSid = WELL_KNOWN_SID_TYPE.ThisOrganizationCertificateSid;
pub const WinApplicationPackageAuthoritySid = WELL_KNOWN_SID_TYPE.ApplicationPackageAuthoritySid;
pub const WinBuiltinAnyPackageSid = WELL_KNOWN_SID_TYPE.BuiltinAnyPackageSid;
pub const WinCapabilityInternetClientSid = WELL_KNOWN_SID_TYPE.CapabilityInternetClientSid;
pub const WinCapabilityInternetClientServerSid = WELL_KNOWN_SID_TYPE.CapabilityInternetClientServerSid;
pub const WinCapabilityPrivateNetworkClientServerSid = WELL_KNOWN_SID_TYPE.CapabilityPrivateNetworkClientServerSid;
pub const WinCapabilityPicturesLibrarySid = WELL_KNOWN_SID_TYPE.CapabilityPicturesLibrarySid;
pub const WinCapabilityVideosLibrarySid = WELL_KNOWN_SID_TYPE.CapabilityVideosLibrarySid;
pub const WinCapabilityMusicLibrarySid = WELL_KNOWN_SID_TYPE.CapabilityMusicLibrarySid;
pub const WinCapabilityDocumentsLibrarySid = WELL_KNOWN_SID_TYPE.CapabilityDocumentsLibrarySid;
pub const WinCapabilitySharedUserCertificatesSid = WELL_KNOWN_SID_TYPE.CapabilitySharedUserCertificatesSid;
pub const WinCapabilityEnterpriseAuthenticationSid = WELL_KNOWN_SID_TYPE.CapabilityEnterpriseAuthenticationSid;
pub const WinCapabilityRemovableStorageSid = WELL_KNOWN_SID_TYPE.CapabilityRemovableStorageSid;
pub const WinBuiltinRDSRemoteAccessServersSid = WELL_KNOWN_SID_TYPE.BuiltinRDSRemoteAccessServersSid;
pub const WinBuiltinRDSEndpointServersSid = WELL_KNOWN_SID_TYPE.BuiltinRDSEndpointServersSid;
pub const WinBuiltinRDSManagementServersSid = WELL_KNOWN_SID_TYPE.BuiltinRDSManagementServersSid;
pub const WinUserModeDriversSid = WELL_KNOWN_SID_TYPE.UserModeDriversSid;
pub const WinBuiltinHyperVAdminsSid = WELL_KNOWN_SID_TYPE.BuiltinHyperVAdminsSid;
pub const WinAccountCloneableControllersSid = WELL_KNOWN_SID_TYPE.AccountCloneableControllersSid;
pub const WinBuiltinAccessControlAssistanceOperatorsSid = WELL_KNOWN_SID_TYPE.BuiltinAccessControlAssistanceOperatorsSid;
pub const WinBuiltinRemoteManagementUsersSid = WELL_KNOWN_SID_TYPE.BuiltinRemoteManagementUsersSid;
pub const WinAuthenticationAuthorityAssertedSid = WELL_KNOWN_SID_TYPE.AuthenticationAuthorityAssertedSid;
pub const WinAuthenticationServiceAssertedSid = WELL_KNOWN_SID_TYPE.AuthenticationServiceAssertedSid;
pub const WinLocalAccountSid = WELL_KNOWN_SID_TYPE.LocalAccountSid;
pub const WinLocalAccountAndAdministratorSid = WELL_KNOWN_SID_TYPE.LocalAccountAndAdministratorSid;
pub const WinAccountProtectedUsersSid = WELL_KNOWN_SID_TYPE.AccountProtectedUsersSid;
pub const WinCapabilityAppointmentsSid = WELL_KNOWN_SID_TYPE.CapabilityAppointmentsSid;
pub const WinCapabilityContactsSid = WELL_KNOWN_SID_TYPE.CapabilityContactsSid;
pub const WinAccountDefaultSystemManagedSid = WELL_KNOWN_SID_TYPE.AccountDefaultSystemManagedSid;
pub const WinBuiltinDefaultSystemManagedGroupSid = WELL_KNOWN_SID_TYPE.BuiltinDefaultSystemManagedGroupSid;
pub const WinBuiltinStorageReplicaAdminsSid = WELL_KNOWN_SID_TYPE.BuiltinStorageReplicaAdminsSid;
pub const WinAccountKeyAdminsSid = WELL_KNOWN_SID_TYPE.AccountKeyAdminsSid;
pub const WinAccountEnterpriseKeyAdminsSid = WELL_KNOWN_SID_TYPE.AccountEnterpriseKeyAdminsSid;
pub const WinAuthenticationKeyTrustSid = WELL_KNOWN_SID_TYPE.AuthenticationKeyTrustSid;
pub const WinAuthenticationKeyPropertyMFASid = WELL_KNOWN_SID_TYPE.AuthenticationKeyPropertyMFASid;
pub const WinAuthenticationKeyPropertyAttestationSid = WELL_KNOWN_SID_TYPE.AuthenticationKeyPropertyAttestationSid;
pub const WinAuthenticationFreshKeyAuthSid = WELL_KNOWN_SID_TYPE.AuthenticationFreshKeyAuthSid;
pub const WinBuiltinDeviceOwnersSid = WELL_KNOWN_SID_TYPE.BuiltinDeviceOwnersSid;
pub const ACL = extern struct {
AclRevision: u8,
Sbz1: u8,
AclSize: u16,
AceCount: u16,
Sbz2: u16,
};
pub const ACE_HEADER = extern struct {
AceType: u8,
AceFlags: u8,
AceSize: u16,
};
pub const ACCESS_ALLOWED_ACE = extern struct {
Header: ACE_HEADER,
Mask: u32,
SidStart: u32,
};
pub const ACCESS_DENIED_ACE = extern struct {
Header: ACE_HEADER,
Mask: u32,
SidStart: u32,
};
pub const SYSTEM_AUDIT_ACE = extern struct {
Header: ACE_HEADER,
Mask: u32,
SidStart: u32,
};
pub const SYSTEM_ALARM_ACE = extern struct {
Header: ACE_HEADER,
Mask: u32,
SidStart: u32,
};
pub const SYSTEM_RESOURCE_ATTRIBUTE_ACE = extern struct {
Header: ACE_HEADER,
Mask: u32,
SidStart: u32,
};
pub const SYSTEM_SCOPED_POLICY_ID_ACE = extern struct {
Header: ACE_HEADER,
Mask: u32,
SidStart: u32,
};
pub const SYSTEM_MANDATORY_LABEL_ACE = extern struct {
Header: ACE_HEADER,
Mask: u32,
SidStart: u32,
};
pub const ACCESS_ALLOWED_OBJECT_ACE = extern struct {
Header: ACE_HEADER,
Mask: u32,
Flags: SYSTEM_AUDIT_OBJECT_ACE_FLAGS,
ObjectType: Guid,
InheritedObjectType: Guid,
SidStart: u32,
};
pub const ACCESS_DENIED_OBJECT_ACE = extern struct {
Header: ACE_HEADER,
Mask: u32,
Flags: SYSTEM_AUDIT_OBJECT_ACE_FLAGS,
ObjectType: Guid,
InheritedObjectType: Guid,
SidStart: u32,
};
pub const SYSTEM_AUDIT_OBJECT_ACE = extern struct {
Header: ACE_HEADER,
Mask: u32,
Flags: SYSTEM_AUDIT_OBJECT_ACE_FLAGS,
ObjectType: Guid,
InheritedObjectType: Guid,
SidStart: u32,
};
pub const SYSTEM_ALARM_OBJECT_ACE = extern struct {
Header: ACE_HEADER,
Mask: u32,
Flags: u32,
ObjectType: Guid,
InheritedObjectType: Guid,
SidStart: u32,
};
pub const ACCESS_ALLOWED_CALLBACK_ACE = extern struct {
Header: ACE_HEADER,
Mask: u32,
SidStart: u32,
};
pub const ACCESS_DENIED_CALLBACK_ACE = extern struct {
Header: ACE_HEADER,
Mask: u32,
SidStart: u32,
};
pub const SYSTEM_AUDIT_CALLBACK_ACE = extern struct {
Header: ACE_HEADER,
Mask: u32,
SidStart: u32,
};
pub const SYSTEM_ALARM_CALLBACK_ACE = extern struct {
Header: ACE_HEADER,
Mask: u32,
SidStart: u32,
};
pub const ACCESS_ALLOWED_CALLBACK_OBJECT_ACE = extern struct {
Header: ACE_HEADER,
Mask: u32,
Flags: SYSTEM_AUDIT_OBJECT_ACE_FLAGS,
ObjectType: Guid,
InheritedObjectType: Guid,
SidStart: u32,
};
pub const ACCESS_DENIED_CALLBACK_OBJECT_ACE = extern struct {
Header: ACE_HEADER,
Mask: u32,
Flags: SYSTEM_AUDIT_OBJECT_ACE_FLAGS,
ObjectType: Guid,
InheritedObjectType: Guid,
SidStart: u32,
};
pub const SYSTEM_AUDIT_CALLBACK_OBJECT_ACE = extern struct {
Header: ACE_HEADER,
Mask: u32,
Flags: SYSTEM_AUDIT_OBJECT_ACE_FLAGS,
ObjectType: Guid,
InheritedObjectType: Guid,
SidStart: u32,
};
pub const SYSTEM_ALARM_CALLBACK_OBJECT_ACE = extern struct {
Header: ACE_HEADER,
Mask: u32,
Flags: SYSTEM_AUDIT_OBJECT_ACE_FLAGS,
ObjectType: Guid,
InheritedObjectType: Guid,
SidStart: u32,
};
pub const ACL_INFORMATION_CLASS = enum(i32) {
RevisionInformation = 1,
SizeInformation = 2,
};
pub const AclRevisionInformation = ACL_INFORMATION_CLASS.RevisionInformation;
pub const AclSizeInformation = ACL_INFORMATION_CLASS.SizeInformation;
pub const ACL_REVISION_INFORMATION = extern struct {
AclRevision: u32,
};
pub const ACL_SIZE_INFORMATION = extern struct {
AceCount: u32,
AclBytesInUse: u32,
AclBytesFree: u32,
};
pub const SECURITY_DESCRIPTOR = extern struct {
Revision: u8,
Sbz1: u8,
Control: u16,
Owner: ?PSID,
Group: ?PSID,
Sacl: ?*ACL,
Dacl: ?*ACL,
};
pub const OBJECT_TYPE_LIST = extern struct {
Level: u16,
Sbz: u16,
ObjectType: ?*Guid,
};
pub const AUDIT_EVENT_TYPE = enum(i32) {
ObjectAccess = 0,
DirectoryServiceAccess = 1,
};
pub const AuditEventObjectAccess = AUDIT_EVENT_TYPE.ObjectAccess;
pub const AuditEventDirectoryServiceAccess = AUDIT_EVENT_TYPE.DirectoryServiceAccess;
pub const PRIVILEGE_SET = extern struct {
PrivilegeCount: u32,
Control: u32,
Privilege: [1]LUID_AND_ATTRIBUTES,
};
pub const SECURITY_IMPERSONATION_LEVEL = enum(i32) {
Anonymous = 0,
Identification = 1,
Impersonation = 2,
Delegation = 3,
};
pub const SecurityAnonymous = SECURITY_IMPERSONATION_LEVEL.Anonymous;
pub const SecurityIdentification = SECURITY_IMPERSONATION_LEVEL.Identification;
pub const SecurityImpersonation = SECURITY_IMPERSONATION_LEVEL.Impersonation;
pub const SecurityDelegation = SECURITY_IMPERSONATION_LEVEL.Delegation;
pub const TOKEN_TYPE = enum(i32) {
Primary = 1,
Impersonation = 2,
};
pub const TokenPrimary = TOKEN_TYPE.Primary;
pub const TokenImpersonation = TOKEN_TYPE.Impersonation;
pub const TOKEN_ELEVATION_TYPE = enum(i32) {
Default = 1,
Full = 2,
Limited = 3,
};
pub const TokenElevationTypeDefault = TOKEN_ELEVATION_TYPE.Default;
pub const TokenElevationTypeFull = TOKEN_ELEVATION_TYPE.Full;
pub const TokenElevationTypeLimited = TOKEN_ELEVATION_TYPE.Limited;
pub const TOKEN_INFORMATION_CLASS = enum(i32) {
TokenUser = 1,
TokenGroups = 2,
TokenPrivileges = 3,
TokenOwner = 4,
TokenPrimaryGroup = 5,
TokenDefaultDacl = 6,
TokenSource = 7,
TokenType = 8,
TokenImpersonationLevel = 9,
TokenStatistics = 10,
TokenRestrictedSids = 11,
TokenSessionId = 12,
TokenGroupsAndPrivileges = 13,
TokenSessionReference = 14,
TokenSandBoxInert = 15,
TokenAuditPolicy = 16,
TokenOrigin = 17,
TokenElevationType = 18,
TokenLinkedToken = 19,
TokenElevation = 20,
TokenHasRestrictions = 21,
TokenAccessInformation = 22,
TokenVirtualizationAllowed = 23,
TokenVirtualizationEnabled = 24,
TokenIntegrityLevel = 25,
TokenUIAccess = 26,
TokenMandatoryPolicy = 27,
TokenLogonSid = 28,
TokenIsAppContainer = 29,
TokenCapabilities = 30,
TokenAppContainerSid = 31,
TokenAppContainerNumber = 32,
TokenUserClaimAttributes = 33,
TokenDeviceClaimAttributes = 34,
TokenRestrictedUserClaimAttributes = 35,
TokenRestrictedDeviceClaimAttributes = 36,
TokenDeviceGroups = 37,
TokenRestrictedDeviceGroups = 38,
TokenSecurityAttributes = 39,
TokenIsRestricted = 40,
TokenProcessTrustLevel = 41,
TokenPrivateNameSpace = 42,
TokenSingletonAttributes = 43,
TokenBnoIsolation = 44,
TokenChildProcessFlags = 45,
TokenIsLessPrivilegedAppContainer = 46,
TokenIsSandboxed = 47,
TokenOriginatingProcessTrustLevel = 48,
MaxTokenInfoClass = 49,
};
pub const TokenUser = TOKEN_INFORMATION_CLASS.TokenUser;
pub const TokenGroups = TOKEN_INFORMATION_CLASS.TokenGroups;
pub const TokenPrivileges = TOKEN_INFORMATION_CLASS.TokenPrivileges;
pub const TokenOwner = TOKEN_INFORMATION_CLASS.TokenOwner;
pub const TokenPrimaryGroup = TOKEN_INFORMATION_CLASS.TokenPrimaryGroup;
pub const TokenDefaultDacl = TOKEN_INFORMATION_CLASS.TokenDefaultDacl;
pub const TokenSource = TOKEN_INFORMATION_CLASS.TokenSource;
pub const TokenType = TOKEN_INFORMATION_CLASS.TokenType;
pub const TokenImpersonationLevel = TOKEN_INFORMATION_CLASS.TokenImpersonationLevel;
pub const TokenStatistics = TOKEN_INFORMATION_CLASS.TokenStatistics;
pub const TokenRestrictedSids = TOKEN_INFORMATION_CLASS.TokenRestrictedSids;
pub const TokenSessionId = TOKEN_INFORMATION_CLASS.TokenSessionId;
pub const TokenGroupsAndPrivileges = TOKEN_INFORMATION_CLASS.TokenGroupsAndPrivileges;
pub const TokenSessionReference = TOKEN_INFORMATION_CLASS.TokenSessionReference;
pub const TokenSandBoxInert = TOKEN_INFORMATION_CLASS.TokenSandBoxInert;
pub const TokenAuditPolicy = TOKEN_INFORMATION_CLASS.TokenAuditPolicy;
pub const TokenOrigin = TOKEN_INFORMATION_CLASS.TokenOrigin;
pub const TokenElevationType = TOKEN_INFORMATION_CLASS.TokenElevationType;
pub const TokenLinkedToken = TOKEN_INFORMATION_CLASS.TokenLinkedToken;
pub const TokenElevation = TOKEN_INFORMATION_CLASS.TokenElevation;
pub const TokenHasRestrictions = TOKEN_INFORMATION_CLASS.TokenHasRestrictions;
pub const TokenAccessInformation = TOKEN_INFORMATION_CLASS.TokenAccessInformation;
pub const TokenVirtualizationAllowed = TOKEN_INFORMATION_CLASS.TokenVirtualizationAllowed;
pub const TokenVirtualizationEnabled = TOKEN_INFORMATION_CLASS.TokenVirtualizationEnabled;
pub const TokenIntegrityLevel = TOKEN_INFORMATION_CLASS.TokenIntegrityLevel;
pub const TokenUIAccess = TOKEN_INFORMATION_CLASS.TokenUIAccess;
pub const TokenMandatoryPolicy = TOKEN_INFORMATION_CLASS.TokenMandatoryPolicy;
pub const TokenLogonSid = TOKEN_INFORMATION_CLASS.TokenLogonSid;
pub const TokenIsAppContainer = TOKEN_INFORMATION_CLASS.TokenIsAppContainer;
pub const TokenCapabilities = TOKEN_INFORMATION_CLASS.TokenCapabilities;
pub const TokenAppContainerSid = TOKEN_INFORMATION_CLASS.TokenAppContainerSid;
pub const TokenAppContainerNumber = TOKEN_INFORMATION_CLASS.TokenAppContainerNumber;
pub const TokenUserClaimAttributes = TOKEN_INFORMATION_CLASS.TokenUserClaimAttributes;
pub const TokenDeviceClaimAttributes = TOKEN_INFORMATION_CLASS.TokenDeviceClaimAttributes;
pub const TokenRestrictedUserClaimAttributes = TOKEN_INFORMATION_CLASS.TokenRestrictedUserClaimAttributes;
pub const TokenRestrictedDeviceClaimAttributes = TOKEN_INFORMATION_CLASS.TokenRestrictedDeviceClaimAttributes;
pub const TokenDeviceGroups = TOKEN_INFORMATION_CLASS.TokenDeviceGroups;
pub const TokenRestrictedDeviceGroups = TOKEN_INFORMATION_CLASS.TokenRestrictedDeviceGroups;
pub const TokenSecurityAttributes = TOKEN_INFORMATION_CLASS.TokenSecurityAttributes;
pub const TokenIsRestricted = TOKEN_INFORMATION_CLASS.TokenIsRestricted;
pub const TokenProcessTrustLevel = TOKEN_INFORMATION_CLASS.TokenProcessTrustLevel;
pub const TokenPrivateNameSpace = TOKEN_INFORMATION_CLASS.TokenPrivateNameSpace;
pub const TokenSingletonAttributes = TOKEN_INFORMATION_CLASS.TokenSingletonAttributes;
pub const TokenBnoIsolation = TOKEN_INFORMATION_CLASS.TokenBnoIsolation;
pub const TokenChildProcessFlags = TOKEN_INFORMATION_CLASS.TokenChildProcessFlags;
pub const TokenIsLessPrivilegedAppContainer = TOKEN_INFORMATION_CLASS.TokenIsLessPrivilegedAppContainer;
pub const TokenIsSandboxed = TOKEN_INFORMATION_CLASS.TokenIsSandboxed;
pub const TokenOriginatingProcessTrustLevel = TOKEN_INFORMATION_CLASS.TokenOriginatingProcessTrustLevel;
pub const MaxTokenInfoClass = TOKEN_INFORMATION_CLASS.MaxTokenInfoClass;
pub const TOKEN_USER = extern struct {
User: SID_AND_ATTRIBUTES,
};
pub const TOKEN_GROUPS = extern struct {
GroupCount: u32,
Groups: [1]SID_AND_ATTRIBUTES,
};
pub const TOKEN_PRIVILEGES = extern struct {
PrivilegeCount: u32,
Privileges: [1]LUID_AND_ATTRIBUTES,
};
pub const TOKEN_OWNER = extern struct {
Owner: ?PSID,
};
pub const TOKEN_PRIMARY_GROUP = extern struct {
PrimaryGroup: ?PSID,
};
pub const TOKEN_DEFAULT_DACL = extern struct {
DefaultDacl: ?*ACL,
};
pub const TOKEN_USER_CLAIMS = extern struct {
UserClaims: ?*c_void,
};
pub const TOKEN_DEVICE_CLAIMS = extern struct {
DeviceClaims: ?*c_void,
};
pub const TOKEN_GROUPS_AND_PRIVILEGES = extern struct {
SidCount: u32,
SidLength: u32,
Sids: ?*SID_AND_ATTRIBUTES,
RestrictedSidCount: u32,
RestrictedSidLength: u32,
RestrictedSids: ?*SID_AND_ATTRIBUTES,
PrivilegeCount: u32,
PrivilegeLength: u32,
Privileges: ?*LUID_AND_ATTRIBUTES,
AuthenticationId: LUID,
};
pub const TOKEN_LINKED_TOKEN = extern struct {
LinkedToken: ?HANDLE,
};
pub const TOKEN_ELEVATION = extern struct {
TokenIsElevated: u32,
};
pub const TOKEN_MANDATORY_LABEL = extern struct {
Label: SID_AND_ATTRIBUTES,
};
pub const TOKEN_MANDATORY_POLICY = extern struct {
Policy: TOKEN_MANDATORY_POLICY_ID,
};
pub const TOKEN_ACCESS_INFORMATION = extern struct {
SidHash: ?*SID_AND_ATTRIBUTES_HASH,
RestrictedSidHash: ?*SID_AND_ATTRIBUTES_HASH,
Privileges: ?*TOKEN_PRIVILEGES,
AuthenticationId: LUID,
TokenType: TOKEN_TYPE,
ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL,
MandatoryPolicy: TOKEN_MANDATORY_POLICY,
Flags: u32,
AppContainerNumber: u32,
PackageSid: ?PSID,
CapabilitiesHash: ?*SID_AND_ATTRIBUTES_HASH,
TrustLevelSid: ?PSID,
SecurityAttributes: ?*c_void,
};
pub const TOKEN_AUDIT_POLICY = extern struct {
PerUserPolicy: [30]u8,
};
pub const TOKEN_SOURCE = extern struct {
SourceName: [8]CHAR,
SourceIdentifier: LUID,
};
pub const TOKEN_STATISTICS = extern struct {
TokenId: LUID,
AuthenticationId: LUID,
ExpirationTime: LARGE_INTEGER,
TokenType: TOKEN_TYPE,
ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL,
DynamicCharged: u32,
DynamicAvailable: u32,
GroupCount: u32,
PrivilegeCount: u32,
ModifiedId: LUID,
};
pub const TOKEN_CONTROL = extern struct {
TokenId: LUID,
AuthenticationId: LUID,
ModifiedId: LUID,
TokenSource: TOKEN_SOURCE,
};
pub const TOKEN_ORIGIN = extern struct {
OriginatingLogonSession: LUID,
};
pub const MANDATORY_LEVEL = enum(i32) {
Untrusted = 0,
Low = 1,
Medium = 2,
High = 3,
System = 4,
SecureProcess = 5,
Count = 6,
};
pub const MandatoryLevelUntrusted = MANDATORY_LEVEL.Untrusted;
pub const MandatoryLevelLow = MANDATORY_LEVEL.Low;
pub const MandatoryLevelMedium = MANDATORY_LEVEL.Medium;
pub const MandatoryLevelHigh = MANDATORY_LEVEL.High;
pub const MandatoryLevelSystem = MANDATORY_LEVEL.System;
pub const MandatoryLevelSecureProcess = MANDATORY_LEVEL.SecureProcess;
pub const MandatoryLevelCount = MANDATORY_LEVEL.Count;
pub const TOKEN_APPCONTAINER_INFORMATION = extern struct {
TokenAppContainer: ?PSID,
};
pub const CLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE = extern struct {
Version: u64,
Name: ?PWSTR,
};
pub const CLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE = extern struct {
pValue: ?*c_void,
ValueLength: u32,
};
pub const CLAIM_SECURITY_ATTRIBUTE_V1 = extern struct {
Name: ?PWSTR,
ValueType: CLAIM_SECURITY_ATTRIBUTE_VALUE_TYPE,
Reserved: u16,
Flags: u32,
ValueCount: u32,
Values: extern union {
pInt64: ?*i64,
pUint64: ?*u64,
ppString: ?*?PWSTR,
pFqbn: ?*CLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE,
pOctetString: ?*CLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE,
},
};
pub const CLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1 = extern struct {
Name: u32,
ValueType: CLAIM_SECURITY_ATTRIBUTE_VALUE_TYPE,
Reserved: u16,
Flags: CLAIM_SECURITY_ATTRIBUTE_FLAGS,
ValueCount: u32,
Values: extern union {
pInt64: [1]u32,
pUint64: [1]u32,
ppString: [1]u32,
pFqbn: [1]u32,
pOctetString: [1]u32,
},
};
pub const CLAIM_SECURITY_ATTRIBUTES_INFORMATION = extern struct {
Version: u16,
Reserved: u16,
AttributeCount: u32,
Attribute: extern union {
pAttributeV1: ?*CLAIM_SECURITY_ATTRIBUTE_V1,
},
};
pub const SECURITY_QUALITY_OF_SERVICE = extern struct {
Length: u32,
ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL,
ContextTrackingMode: u8,
EffectiveOnly: BOOLEAN,
};
pub const SECURITY_CAPABILITIES = extern struct {
AppContainerSid: ?PSID,
Capabilities: ?*SID_AND_ATTRIBUTES,
CapabilityCount: u32,
Reserved: u32,
};
pub const QUOTA_LIMITS = extern struct {
PagedPoolLimit: usize,
NonPagedPoolLimit: usize,
MinimumWorkingSetSize: usize,
MaximumWorkingSetSize: usize,
PagefileLimit: usize,
TimeLimit: LARGE_INTEGER,
};
pub const SECURITY_ATTRIBUTES = extern struct {
nLength: u32,
lpSecurityDescriptor: ?*c_void,
bInheritHandle: BOOL,
};
pub const CRYPTPROTECT_PROMPTSTRUCT = extern struct {
cbSize: u32,
dwPromptFlags: u32,
hwndApp: ?HWND,
szPrompt: ?[*:0]const u16,
};
pub const WLX_SC_NOTIFICATION_INFO = extern struct {
pszCard: ?PWSTR,
pszReader: ?PWSTR,
pszContainer: ?PWSTR,
pszCryptoProvider: ?PWSTR,
};
pub const WLX_PROFILE_V1_0 = extern struct {
dwType: u32,
pszProfile: ?PWSTR,
};
pub const WLX_PROFILE_V2_0 = extern struct {
dwType: u32,
pszProfile: ?PWSTR,
pszPolicy: ?PWSTR,
pszNetworkDefaultUserProfile: ?PWSTR,
pszServerName: ?PWSTR,
pszEnvironment: ?PWSTR,
};
pub const WLX_MPR_NOTIFY_INFO = extern struct {
pszUserName: ?PWSTR,
pszDomain: ?PWSTR,
pszPassword: ?PWSTR,
pszOldPassword: ?PWSTR,
};
pub const WLX_TERMINAL_SERVICES_DATA = extern struct {
ProfilePath: [257]u16,
HomeDir: [257]u16,
HomeDirDrive: [4]u16,
};
pub const WLX_CLIENT_CREDENTIALS_INFO_V1_0 = extern struct {
dwType: u32,
pszUserName: ?PWSTR,
pszDomain: ?PWSTR,
pszPassword: ?<PASSWORD>,
fPromptForPassword: BOOL,
};
pub const WLX_CLIENT_CREDENTIALS_INFO_V2_0 = extern struct {
dwType: u32,
pszUserName: ?PWSTR,
pszDomain: ?PWSTR,
pszPassword: ?PWSTR,
fPromptForPassword: BOOL,
fDisconnectOnLogonFailure: BOOL,
};
pub const WLX_CONSOLESWITCH_CREDENTIALS_INFO_V1_0 = extern struct {
dwType: u32,
UserToken: ?HANDLE,
LogonId: LUID,
Quotas: QUOTA_LIMITS,
UserName: ?PWSTR,
Domain: ?PWSTR,
LogonTime: LARGE_INTEGER,
SmartCardLogon: BOOL,
ProfileLength: u32,
MessageType: u32,
LogonCount: u16,
BadPasswordCount: u16,
ProfileLogonTime: LARGE_INTEGER,
LogoffTime: LARGE_INTEGER,
KickOffTime: LARGE_INTEGER,
PasswordLastSet: LARGE_INTEGER,
PasswordCanChange: LARGE_INTEGER,
PasswordMustChange: LARGE_INTEGER,
LogonScript: ?PWSTR,
HomeDirectory: ?PWSTR,
FullName: ?PWSTR,
ProfilePath: ?PWSTR,
HomeDirectoryDrive: ?PWSTR,
LogonServer: ?PWSTR,
UserFlags: u32,
PrivateDataLen: u32,
PrivateData: ?*u8,
};
pub const WLX_DESKTOP = extern struct {
Size: u32,
Flags: u32,
hDesktop: ?HDESK,
pszDesktopName: ?PWSTR,
};
pub const PWLX_USE_CTRL_ALT_DEL = fn(
hWlx: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) void;
pub const PWLX_SET_CONTEXT_POINTER = fn(
hWlx: ?HANDLE,
pWlxContext: ?*c_void,
) callconv(@import("std").os.windows.WINAPI) void;
pub const PWLX_SAS_NOTIFY = fn(
hWlx: ?HANDLE,
dwSasType: u32,
) callconv(@import("std").os.windows.WINAPI) void;
pub const PWLX_SET_TIMEOUT = fn(
hWlx: ?HANDLE,
Timeout: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const PWLX_ASSIGN_SHELL_PROTECTION = fn(
hWlx: ?HANDLE,
hToken: ?HANDLE,
hProcess: ?HANDLE,
hThread: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) i32;
pub const PWLX_MESSAGE_BOX = fn(
hWlx: ?HANDLE,
hwndOwner: ?HWND,
lpszText: ?PWSTR,
lpszTitle: ?PWSTR,
fuStyle: u32,
) callconv(@import("std").os.windows.WINAPI) i32;
pub const PWLX_DIALOG_BOX = fn(
hWlx: ?HANDLE,
hInst: ?HANDLE,
lpszTemplate: ?PWSTR,
hwndOwner: ?HWND,
dlgprc: ?DLGPROC,
) callconv(@import("std").os.windows.WINAPI) i32;
pub const PWLX_DIALOG_BOX_INDIRECT = fn(
hWlx: ?HANDLE,
hInst: ?HANDLE,
hDialogTemplate: ?*DLGTEMPLATE,
hwndOwner: ?HWND,
dlgprc: ?DLGPROC,
) callconv(@import("std").os.windows.WINAPI) i32;
pub const PWLX_DIALOG_BOX_PARAM = fn(
hWlx: ?HANDLE,
hInst: ?HANDLE,
lpszTemplate: ?PWSTR,
hwndOwner: ?HWND,
dlgprc: ?DLGPROC,
dwInitParam: LPARAM,
) callconv(@import("std").os.windows.WINAPI) i32;
pub const PWLX_DIALOG_BOX_INDIRECT_PARAM = fn(
hWlx: ?HANDLE,
hInst: ?HANDLE,
hDialogTemplate: ?*DLGTEMPLATE,
hwndOwner: ?HWND,
dlgprc: ?DLGPROC,
dwInitParam: LPARAM,
) callconv(@import("std").os.windows.WINAPI) i32;
pub const PWLX_SWITCH_DESKTOP_TO_USER = fn(
hWlx: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) i32;
pub const PWLX_SWITCH_DESKTOP_TO_WINLOGON = fn(
hWlx: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) i32;
pub const PWLX_CHANGE_PASSWORD_NOTIFY = fn(
hWlx: ?HANDLE,
pMprInfo: ?*WLX_MPR_NOTIFY_INFO,
dwChangeInfo: u32,
) callconv(@import("std").os.windows.WINAPI) i32;
pub const PWLX_GET_SOURCE_DESKTOP = fn(
hWlx: ?HANDLE,
ppDesktop: ?*?*WLX_DESKTOP,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const PWLX_SET_RETURN_DESKTOP = fn(
hWlx: ?HANDLE,
pDesktop: ?*WLX_DESKTOP,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const PWLX_CREATE_USER_DESKTOP = fn(
hWlx: ?HANDLE,
hToken: ?HANDLE,
Flags: u32,
pszDesktopName: ?PWSTR,
ppDesktop: ?*?*WLX_DESKTOP,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const PWLX_CHANGE_PASSWORD_NOTIFY_EX = fn(
hWlx: ?HANDLE,
pMprInfo: ?*WLX_MPR_NOTIFY_INFO,
dwChangeInfo: u32,
ProviderName: ?PWSTR,
Reserved: ?*c_void,
) callconv(@import("std").os.windows.WINAPI) i32;
pub const PWLX_CLOSE_USER_DESKTOP = fn(
hWlx: ?HANDLE,
pDesktop: ?*WLX_DESKTOP,
hToken: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const PWLX_SET_OPTION = fn(
hWlx: ?HANDLE,
Option: u32,
Value: usize,
OldValue: ?*usize,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const PWLX_GET_OPTION = fn(
hWlx: ?HANDLE,
Option: u32,
Value: ?*usize,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const PWLX_WIN31_MIGRATE = fn(
hWlx: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) void;
pub const PWLX_QUERY_CLIENT_CREDENTIALS = fn(
pCred: ?*WLX_CLIENT_CREDENTIALS_INFO_V1_0,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const PWLX_QUERY_IC_CREDENTIALS = fn(
pCred: ?*WLX_CLIENT_CREDENTIALS_INFO_V1_0,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const PWLX_QUERY_TS_LOGON_CREDENTIALS = fn(
pCred: ?*WLX_CLIENT_CREDENTIALS_INFO_V2_0,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const PWLX_DISCONNECT = fn(
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const PWLX_QUERY_TERMINAL_SERVICES_DATA = fn(
hWlx: ?HANDLE,
pTSData: ?*WLX_TERMINAL_SERVICES_DATA,
UserName: ?PWSTR,
Domain: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) u32;
pub const PWLX_QUERY_CONSOLESWITCH_CREDENTIALS = fn(
pCred: ?*WLX_CONSOLESWITCH_CREDENTIALS_INFO_V1_0,
) callconv(@import("std").os.windows.WINAPI) u32;
pub const WLX_DISPATCH_VERSION_1_0 = extern struct {
WlxUseCtrlAltDel: ?PWLX_USE_CTRL_ALT_DEL,
WlxSetContextPointer: ?PWLX_SET_CONTEXT_POINTER,
WlxSasNotify: ?PWLX_SAS_NOTIFY,
WlxSetTimeout: ?PWLX_SET_TIMEOUT,
WlxAssignShellProtection: ?PWLX_ASSIGN_SHELL_PROTECTION,
WlxMessageBox: ?PWLX_MESSAGE_BOX,
WlxDialogBox: ?PWLX_DIALOG_BOX,
WlxDialogBoxParam: ?PWLX_DIALOG_BOX_PARAM,
WlxDialogBoxIndirect: ?PWLX_DIALOG_BOX_INDIRECT,
WlxDialogBoxIndirectParam: ?PWLX_DIALOG_BOX_INDIRECT_PARAM,
WlxSwitchDesktopToUser: ?PWLX_SWITCH_DESKTOP_TO_USER,
WlxSwitchDesktopToWinlogon: ?PWLX_SWITCH_DESKTOP_TO_WINLOGON,
WlxChangePasswordNotify: ?PWLX_CHANGE_PASSWORD_NOTIFY,
};
pub const WLX_DISPATCH_VERSION_1_1 = extern struct {
WlxUseCtrlAltDel: ?PWLX_USE_CTRL_ALT_DEL,
WlxSetContextPointer: ?PWLX_SET_CONTEXT_POINTER,
WlxSasNotify: ?PWLX_SAS_NOTIFY,
WlxSetTimeout: ?PWLX_SET_TIMEOUT,
WlxAssignShellProtection: ?PWLX_ASSIGN_SHELL_PROTECTION,
WlxMessageBox: ?PWLX_MESSAGE_BOX,
WlxDialogBox: ?PWLX_DIALOG_BOX,
WlxDialogBoxParam: ?PWLX_DIALOG_BOX_PARAM,
WlxDialogBoxIndirect: ?PWLX_DIALOG_BOX_INDIRECT,
WlxDialogBoxIndirectParam: ?PWLX_DIALOG_BOX_INDIRECT_PARAM,
WlxSwitchDesktopToUser: ?PWLX_SWITCH_DESKTOP_TO_USER,
WlxSwitchDesktopToWinlogon: ?PWLX_SWITCH_DESKTOP_TO_WINLOGON,
WlxChangePasswordNotify: ?PWLX_CHANGE_PASSWORD_NOTIFY,
WlxGetSourceDesktop: ?PWLX_GET_SOURCE_DESKTOP,
WlxSetReturnDesktop: ?PWLX_SET_RETURN_DESKTOP,
WlxCreateUserDesktop: ?PWLX_CREATE_USER_DESKTOP,
WlxChangePasswordNotifyEx: ?PWLX_CHANGE_PASSWORD_NOTIFY_EX,
};
pub const WLX_DISPATCH_VERSION_1_2 = extern struct {
WlxUseCtrlAltDel: ?PWLX_USE_CTRL_ALT_DEL,
WlxSetContextPointer: ?PWLX_SET_CONTEXT_POINTER,
WlxSasNotify: ?PWLX_SAS_NOTIFY,
WlxSetTimeout: ?PWLX_SET_TIMEOUT,
WlxAssignShellProtection: ?PWLX_ASSIGN_SHELL_PROTECTION,
WlxMessageBox: ?PWLX_MESSAGE_BOX,
WlxDialogBox: ?PWLX_DIALOG_BOX,
WlxDialogBoxParam: ?PWLX_DIALOG_BOX_PARAM,
WlxDialogBoxIndirect: ?PWLX_DIALOG_BOX_INDIRECT,
WlxDialogBoxIndirectParam: ?PWLX_DIALOG_BOX_INDIRECT_PARAM,
WlxSwitchDesktopToUser: ?PWLX_SWITCH_DESKTOP_TO_USER,
WlxSwitchDesktopToWinlogon: ?PWLX_SWITCH_DESKTOP_TO_WINLOGON,
WlxChangePasswordNotify: ?PWLX_CHANGE_PASSWORD_NOTIFY,
WlxGetSourceDesktop: ?PWLX_GET_SOURCE_DESKTOP,
WlxSetReturnDesktop: ?PWLX_SET_RETURN_DESKTOP,
WlxCreateUserDesktop: ?PWLX_CREATE_USER_DESKTOP,
WlxChangePasswordNotifyEx: ?PWLX_CHANGE_PASSWORD_NOTIFY_EX,
WlxCloseUserDesktop: ?PWLX_CLOSE_USER_DESKTOP,
};
pub const WLX_DISPATCH_VERSION_1_3 = extern struct {
WlxUseCtrlAltDel: ?PWLX_USE_CTRL_ALT_DEL,
WlxSetContextPointer: ?PWLX_SET_CONTEXT_POINTER,
WlxSasNotify: ?PWLX_SAS_NOTIFY,
WlxSetTimeout: ?PWLX_SET_TIMEOUT,
WlxAssignShellProtection: ?PWLX_ASSIGN_SHELL_PROTECTION,
WlxMessageBox: ?PWLX_MESSAGE_BOX,
WlxDialogBox: ?PWLX_DIALOG_BOX,
WlxDialogBoxParam: ?PWLX_DIALOG_BOX_PARAM,
WlxDialogBoxIndirect: ?PWLX_DIALOG_BOX_INDIRECT,
WlxDialogBoxIndirectParam: ?PWLX_DIALOG_BOX_INDIRECT_PARAM,
WlxSwitchDesktopToUser: ?PWLX_SWITCH_DESKTOP_TO_USER,
WlxSwitchDesktopToWinlogon: ?PWLX_SWITCH_DESKTOP_TO_WINLOGON,
WlxChangePasswordNotify: ?PWLX_CHANGE_PASSWORD_NOTIFY,
WlxGetSourceDesktop: ?PWLX_GET_SOURCE_DESKTOP,
WlxSetReturnDesktop: ?PWLX_SET_RETURN_DESKTOP,
WlxCreateUserDesktop: ?PWLX_CREATE_USER_DESKTOP,
WlxChangePasswordNotifyEx: ?PWLX_CHANGE_PASSWORD_NOTIFY_EX,
WlxCloseUserDesktop: ?PWLX_CLOSE_USER_DESKTOP,
WlxSetOption: ?PWLX_SET_OPTION,
WlxGetOption: ?PWLX_GET_OPTION,
WlxWin31Migrate: ?PWLX_WIN31_MIGRATE,
WlxQueryClientCredentials: ?PWLX_QUERY_CLIENT_CREDENTIALS,
WlxQueryInetConnectorCredentials: ?PWLX_QUERY_IC_CREDENTIALS,
WlxDisconnect: ?PWLX_DISCONNECT,
WlxQueryTerminalServicesData: ?PWLX_QUERY_TERMINAL_SERVICES_DATA,
};
pub const WLX_DISPATCH_VERSION_1_4 = extern struct {
WlxUseCtrlAltDel: ?PWLX_USE_CTRL_ALT_DEL,
WlxSetContextPointer: ?PWLX_SET_CONTEXT_POINTER,
WlxSasNotify: ?PWLX_SAS_NOTIFY,
WlxSetTimeout: ?PWLX_SET_TIMEOUT,
WlxAssignShellProtection: ?PWLX_ASSIGN_SHELL_PROTECTION,
WlxMessageBox: ?PWLX_MESSAGE_BOX,
WlxDialogBox: ?PWLX_DIALOG_BOX,
WlxDialogBoxParam: ?PWLX_DIALOG_BOX_PARAM,
WlxDialogBoxIndirect: ?PWLX_DIALOG_BOX_INDIRECT,
WlxDialogBoxIndirectParam: ?PWLX_DIALOG_BOX_INDIRECT_PARAM,
WlxSwitchDesktopToUser: ?PWLX_SWITCH_DESKTOP_TO_USER,
WlxSwitchDesktopToWinlogon: ?PWLX_SWITCH_DESKTOP_TO_WINLOGON,
WlxChangePasswordNotify: ?PWLX_CHANGE_PASSWORD_NOTIFY,
WlxGetSourceDesktop: ?PWLX_GET_SOURCE_DESKTOP,
WlxSetReturnDesktop: ?PWLX_SET_RETURN_DESKTOP,
WlxCreateUserDesktop: ?PWLX_CREATE_USER_DESKTOP,
WlxChangePasswordNotifyEx: ?PWLX_CHANGE_PASSWORD_NOTIFY_EX,
WlxCloseUserDesktop: ?PWLX_CLOSE_USER_DESKTOP,
WlxSetOption: ?PWLX_SET_OPTION,
WlxGetOption: ?PWLX_GET_OPTION,
WlxWin31Migrate: ?PWLX_WIN31_MIGRATE,
WlxQueryClientCredentials: ?PWLX_QUERY_CLIENT_CREDENTIALS,
WlxQueryInetConnectorCredentials: ?PWLX_QUERY_IC_CREDENTIALS,
WlxDisconnect: ?PWLX_DISCONNECT,
WlxQueryTerminalServicesData: ?PWLX_QUERY_TERMINAL_SERVICES_DATA,
WlxQueryConsoleSwitchCredentials: ?PWLX_QUERY_CONSOLESWITCH_CREDENTIALS,
WlxQueryTsLogonCredentials: ?PWLX_QUERY_TS_LOGON_CREDENTIALS,
};
pub const PFNMSGECALLBACK = fn(
bVerbose: BOOL,
lpMessage: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) u32;
pub const WLX_NOTIFICATION_INFO = extern struct {
Size: u32,
Flags: u32,
UserName: ?PWSTR,
Domain: ?PWSTR,
WindowStation: ?PWSTR,
hToken: ?HANDLE,
hDesktop: ?HDESK,
pStatusCallback: ?PFNMSGECALLBACK,
};
const CLSID_TpmVirtualSmartCardManager_Value = @import("zig.zig").Guid.initString("16a18e86-7f6e-4c20-ad89-4ffc0db7a96a");
pub const CLSID_TpmVirtualSmartCardManager = &CLSID_TpmVirtualSmartCardManager_Value;
const CLSID_RemoteTpmVirtualSmartCardManager_Value = @import("zig.zig").Guid.initString("152ea2a8-70dc-4c59-8b2a-32aa3ca0dcac");
pub const CLSID_RemoteTpmVirtualSmartCardManager = &CLSID_RemoteTpmVirtualSmartCardManager_Value;
pub const TPMVSC_ATTESTATION_TYPE = enum(i32) {
NONE = 0,
AIK_ONLY = 1,
AIK_AND_CERTIFICATE = 2,
};
pub const TPMVSC_ATTESTATION_NONE = TPMVSC_ATTESTATION_TYPE.NONE;
pub const TPMVSC_ATTESTATION_AIK_ONLY = TPMVSC_ATTESTATION_TYPE.AIK_ONLY;
pub const TPMVSC_ATTESTATION_AIK_AND_CERTIFICATE = TPMVSC_ATTESTATION_TYPE.AIK_AND_CERTIFICATE;
pub const TPMVSCMGR_STATUS = enum(i32) {
VTPMSMARTCARD_INITIALIZING = 0,
VTPMSMARTCARD_CREATING = 1,
VTPMSMARTCARD_DESTROYING = 2,
VGIDSSIMULATOR_INITIALIZING = 3,
VGIDSSIMULATOR_CREATING = 4,
VGIDSSIMULATOR_DESTROYING = 5,
VREADER_INITIALIZING = 6,
VREADER_CREATING = 7,
VREADER_DESTROYING = 8,
GENERATE_WAITING = 9,
GENERATE_AUTHENTICATING = 10,
GENERATE_RUNNING = 11,
CARD_CREATED = 12,
CARD_DESTROYED = 13,
};
pub const TPMVSCMGR_STATUS_VTPMSMARTCARD_INITIALIZING = TPMVSCMGR_STATUS.VTPMSMARTCARD_INITIALIZING;
pub const TPMVSCMGR_STATUS_VTPMSMARTCARD_CREATING = TPMVSCMGR_STATUS.VTPMSMARTCARD_CREATING;
pub const TPMVSCMGR_STATUS_VTPMSMARTCARD_DESTROYING = TPMVSCMGR_STATUS.VTPMSMARTCARD_DESTROYING;
pub const TPMVSCMGR_STATUS_VGIDSSIMULATOR_INITIALIZING = TPMVSCMGR_STATUS.VGIDSSIMULATOR_INITIALIZING;
pub const TPMVSCMGR_STATUS_VGIDSSIMULATOR_CREATING = TPMVSCMGR_STATUS.VGIDSSIMULATOR_CREATING;
pub const TPMVSCMGR_STATUS_VGIDSSIMULATOR_DESTROYING = TPMVSCMGR_STATUS.VGIDSSIMULATOR_DESTROYING;
pub const TPMVSCMGR_STATUS_VREADER_INITIALIZING = TPMVSCMGR_STATUS.VREADER_INITIALIZING;
pub const TPMVSCMGR_STATUS_VREADER_CREATING = TPMVSCMGR_STATUS.VREADER_CREATING;
pub const TPMVSCMGR_STATUS_VREADER_DESTROYING = TPMVSCMGR_STATUS.VREADER_DESTROYING;
pub const TPMVSCMGR_STATUS_GENERATE_WAITING = TPMVSCMGR_STATUS.GENERATE_WAITING;
pub const TPMVSCMGR_STATUS_GENERATE_AUTHENTICATING = TPMVSCMGR_STATUS.GENERATE_AUTHENTICATING;
pub const TPMVSCMGR_STATUS_GENERATE_RUNNING = TPMVSCMGR_STATUS.GENERATE_RUNNING;
pub const TPMVSCMGR_STATUS_CARD_CREATED = TPMVSCMGR_STATUS.CARD_CREATED;
pub const TPMVSCMGR_STATUS_CARD_DESTROYED = TPMVSCMGR_STATUS.CARD_DESTROYED;
pub const TPMVSCMGR_ERROR = enum(i32) {
IMPERSONATION = 0,
PIN_COMPLEXITY = 1,
READER_COUNT_LIMIT = 2,
TERMINAL_SERVICES_SESSION = 3,
VTPMSMARTCARD_INITIALIZE = 4,
VTPMSMARTCARD_CREATE = 5,
VTPMSMARTCARD_DESTROY = 6,
VGIDSSIMULATOR_INITIALIZE = 7,
VGIDSSIMULATOR_CREATE = 8,
VGIDSSIMULATOR_DESTROY = 9,
VGIDSSIMULATOR_WRITE_PROPERTY = 10,
VGIDSSIMULATOR_READ_PROPERTY = 11,
VREADER_INITIALIZE = 12,
VREADER_CREATE = 13,
VREADER_DESTROY = 14,
GENERATE_LOCATE_READER = 15,
GENERATE_FILESYSTEM = 16,
CARD_CREATE = 17,
CARD_DESTROY = 18,
};
pub const TPMVSCMGR_ERROR_IMPERSONATION = TPMVSCMGR_ERROR.IMPERSONATION;
pub const TPMVSCMGR_ERROR_PIN_COMPLEXITY = TPMVSCMGR_ERROR.PIN_COMPLEXITY;
pub const TPMVSCMGR_ERROR_READER_COUNT_LIMIT = TPMVSCMGR_ERROR.READER_COUNT_LIMIT;
pub const TPMVSCMGR_ERROR_TERMINAL_SERVICES_SESSION = TPMVSCMGR_ERROR.TERMINAL_SERVICES_SESSION;
pub const TPMVSCMGR_ERROR_VTPMSMARTCARD_INITIALIZE = TPMVSCMGR_ERROR.VTPMSMARTCARD_INITIALIZE;
pub const TPMVSCMGR_ERROR_VTPMSMARTCARD_CREATE = TPMVSCMGR_ERROR.VTPMSMARTCARD_CREATE;
pub const TPMVSCMGR_ERROR_VTPMSMARTCARD_DESTROY = TPMVSCMGR_ERROR.VTPMSMARTCARD_DESTROY;
pub const TPMVSCMGR_ERROR_VGIDSSIMULATOR_INITIALIZE = TPMVSCMGR_ERROR.VGIDSSIMULATOR_INITIALIZE;
pub const TPMVSCMGR_ERROR_VGIDSSIMULATOR_CREATE = TPMVSCMGR_ERROR.VGIDSSIMULATOR_CREATE;
pub const TPMVSCMGR_ERROR_VGIDSSIMULATOR_DESTROY = TPMVSCMGR_ERROR.VGIDSSIMULATOR_DESTROY;
pub const TPMVSCMGR_ERROR_VGIDSSIMULATOR_WRITE_PROPERTY = TPMVSCMGR_ERROR.VGIDSSIMULATOR_WRITE_PROPERTY;
pub const TPMVSCMGR_ERROR_VGIDSSIMULATOR_READ_PROPERTY = TPMVSCMGR_ERROR.VGIDSSIMULATOR_READ_PROPERTY;
pub const TPMVSCMGR_ERROR_VREADER_INITIALIZE = TPMVSCMGR_ERROR.VREADER_INITIALIZE;
pub const TPMVSCMGR_ERROR_VREADER_CREATE = TPMVSCMGR_ERROR.VREADER_CREATE;
pub const TPMVSCMGR_ERROR_VREADER_DESTROY = TPMVSCMGR_ERROR.VREADER_DESTROY;
pub const TPMVSCMGR_ERROR_GENERATE_LOCATE_READER = TPMVSCMGR_ERROR.GENERATE_LOCATE_READER;
pub const TPMVSCMGR_ERROR_GENERATE_FILESYSTEM = TPMVSCMGR_ERROR.GENERATE_FILESYSTEM;
pub const TPMVSCMGR_ERROR_CARD_CREATE = TPMVSCMGR_ERROR.CARD_CREATE;
pub const TPMVSCMGR_ERROR_CARD_DESTROY = TPMVSCMGR_ERROR.CARD_DESTROY;
// TODO: this type is limited to platform 'windows8.0'
const IID_ITpmVirtualSmartCardManagerStatusCallback_Value = @import("zig.zig").Guid.initString("1a1bb35f-abb8-451c-a1ae-33d98f1bef4a");
pub const IID_ITpmVirtualSmartCardManagerStatusCallback = &IID_ITpmVirtualSmartCardManagerStatusCallback_Value;
pub const ITpmVirtualSmartCardManagerStatusCallback = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
ReportProgress: fn(
self: *const ITpmVirtualSmartCardManagerStatusCallback,
Status: TPMVSCMGR_STATUS,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ReportError: fn(
self: *const ITpmVirtualSmartCardManagerStatusCallback,
Error: TPMVSCMGR_ERROR,
) 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 ITpmVirtualSmartCardManagerStatusCallback_ReportProgress(self: *const T, Status: TPMVSCMGR_STATUS) callconv(.Inline) HRESULT {
return @ptrCast(*const ITpmVirtualSmartCardManagerStatusCallback.VTable, self.vtable).ReportProgress(@ptrCast(*const ITpmVirtualSmartCardManagerStatusCallback, self), Status);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ITpmVirtualSmartCardManagerStatusCallback_ReportError(self: *const T, Error: TPMVSCMGR_ERROR) callconv(.Inline) HRESULT {
return @ptrCast(*const ITpmVirtualSmartCardManagerStatusCallback.VTable, self.vtable).ReportError(@ptrCast(*const ITpmVirtualSmartCardManagerStatusCallback, self), Error);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows8.0'
const IID_ITpmVirtualSmartCardManager_Value = @import("zig.zig").Guid.initString("112b1dff-d9dc-41f7-869f-d67fee7cb591");
pub const IID_ITpmVirtualSmartCardManager = &IID_ITpmVirtualSmartCardManager_Value;
pub const ITpmVirtualSmartCardManager = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
CreateVirtualSmartCard: fn(
self: *const ITpmVirtualSmartCardManager,
pszFriendlyName: ?[*:0]const u16,
bAdminAlgId: u8,
pbAdminKey: [*:0]const u8,
cbAdminKey: u32,
pbAdminKcv: [*:0]const u8,
cbAdminKcv: u32,
pbPuk: [*:0]const u8,
cbPuk: u32,
pbPin: [*:0]const u8,
cbPin: u32,
fGenerate: BOOL,
pStatusCallback: ?*ITpmVirtualSmartCardManagerStatusCallback,
ppszInstanceId: ?*?PWSTR,
pfNeedReboot: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
DestroyVirtualSmartCard: fn(
self: *const ITpmVirtualSmartCardManager,
pszInstanceId: ?[*:0]const u16,
pStatusCallback: ?*ITpmVirtualSmartCardManagerStatusCallback,
pfNeedReboot: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ITpmVirtualSmartCardManager_CreateVirtualSmartCard(self: *const T, pszFriendlyName: ?[*:0]const u16, bAdminAlgId: u8, pbAdminKey: [*:0]const u8, cbAdminKey: u32, pbAdminKcv: [*:0]const u8, cbAdminKcv: u32, pbPuk: [*:0]const u8, cbPuk: u32, pbPin: [*:0]const u8, cbPin: u32, fGenerate: BOOL, pStatusCallback: ?*ITpmVirtualSmartCardManagerStatusCallback, ppszInstanceId: ?*?PWSTR, pfNeedReboot: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ITpmVirtualSmartCardManager.VTable, self.vtable).CreateVirtualSmartCard(@ptrCast(*const ITpmVirtualSmartCardManager, self), pszFriendlyName, bAdminAlgId, pbAdminKey, cbAdminKey, pbAdminKcv, cbAdminKcv, pbPuk, cbPuk, pbPin, cbPin, fGenerate, pStatusCallback, ppszInstanceId, pfNeedReboot);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ITpmVirtualSmartCardManager_DestroyVirtualSmartCard(self: *const T, pszInstanceId: ?[*:0]const u16, pStatusCallback: ?*ITpmVirtualSmartCardManagerStatusCallback, pfNeedReboot: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ITpmVirtualSmartCardManager.VTable, self.vtable).DestroyVirtualSmartCard(@ptrCast(*const ITpmVirtualSmartCardManager, self), pszInstanceId, pStatusCallback, pfNeedReboot);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_ITpmVirtualSmartCardManager2_Value = @import("zig.zig").Guid.initString("fdf8a2b9-02de-47f4-bc26-aa85ab5e5267");
pub const IID_ITpmVirtualSmartCardManager2 = &IID_ITpmVirtualSmartCardManager2_Value;
pub const ITpmVirtualSmartCardManager2 = extern struct {
pub const VTable = extern struct {
base: ITpmVirtualSmartCardManager.VTable,
CreateVirtualSmartCardWithPinPolicy: fn(
self: *const ITpmVirtualSmartCardManager2,
pszFriendlyName: ?[*:0]const u16,
bAdminAlgId: u8,
pbAdminKey: [*:0]const u8,
cbAdminKey: u32,
pbAdminKcv: [*:0]const u8,
cbAdminKcv: u32,
pbPuk: [*:0]const u8,
cbPuk: u32,
pbPin: [*:0]const u8,
cbPin: u32,
pbPinPolicy: [*:0]const u8,
cbPinPolicy: u32,
fGenerate: BOOL,
pStatusCallback: ?*ITpmVirtualSmartCardManagerStatusCallback,
ppszInstanceId: ?*?PWSTR,
pfNeedReboot: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ITpmVirtualSmartCardManager.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ITpmVirtualSmartCardManager2_CreateVirtualSmartCardWithPinPolicy(self: *const T, pszFriendlyName: ?[*:0]const u16, bAdminAlgId: u8, pbAdminKey: [*:0]const u8, cbAdminKey: u32, pbAdminKcv: [*:0]const u8, cbAdminKcv: u32, pbPuk: [*:0]const u8, cbPuk: u32, pbPin: [*:0]const u8, cbPin: u32, pbPinPolicy: [*:0]const u8, cbPinPolicy: u32, fGenerate: BOOL, pStatusCallback: ?*ITpmVirtualSmartCardManagerStatusCallback, ppszInstanceId: ?*?PWSTR, pfNeedReboot: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ITpmVirtualSmartCardManager2.VTable, self.vtable).CreateVirtualSmartCardWithPinPolicy(@ptrCast(*const ITpmVirtualSmartCardManager2, self), pszFriendlyName, bAdminAlgId, pbAdminKey, cbAdminKey, pbAdminKcv, cbAdminKcv, pbPuk, cbPuk, pbPin, cbPin, pbPinPolicy, cbPinPolicy, fGenerate, pStatusCallback, ppszInstanceId, pfNeedReboot);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_ITpmVirtualSmartCardManager3_Value = @import("zig.zig").Guid.initString("3c745a97-f375-4150-be17-5950f694c699");
pub const IID_ITpmVirtualSmartCardManager3 = &IID_ITpmVirtualSmartCardManager3_Value;
pub const ITpmVirtualSmartCardManager3 = extern struct {
pub const VTable = extern struct {
base: ITpmVirtualSmartCardManager2.VTable,
CreateVirtualSmartCardWithAttestation: fn(
self: *const ITpmVirtualSmartCardManager3,
pszFriendlyName: ?[*:0]const u16,
bAdminAlgId: u8,
pbAdminKey: [*:0]const u8,
cbAdminKey: u32,
pbAdminKcv: [*:0]const u8,
cbAdminKcv: u32,
pbPuk: [*:0]const u8,
cbPuk: u32,
pbPin: [*:0]const u8,
cbPin: u32,
pbPinPolicy: [*:0]const u8,
cbPinPolicy: u32,
attestationType: TPMVSC_ATTESTATION_TYPE,
fGenerate: BOOL,
pStatusCallback: ?*ITpmVirtualSmartCardManagerStatusCallback,
ppszInstanceId: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace ITpmVirtualSmartCardManager2.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ITpmVirtualSmartCardManager3_CreateVirtualSmartCardWithAttestation(self: *const T, pszFriendlyName: ?[*:0]const u16, bAdminAlgId: u8, pbAdminKey: [*:0]const u8, cbAdminKey: u32, pbAdminKcv: [*:0]const u8, cbAdminKcv: u32, pbPuk: [*:0]const u8, cbPuk: u32, pbPin: [*:0]const u8, cbPin: u32, pbPinPolicy: [*:0]const u8, cbPinPolicy: u32, attestationType: TPMVSC_ATTESTATION_TYPE, fGenerate: BOOL, pStatusCallback: ?*ITpmVirtualSmartCardManagerStatusCallback, ppszInstanceId: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ITpmVirtualSmartCardManager3.VTable, self.vtable).CreateVirtualSmartCardWithAttestation(@ptrCast(*const ITpmVirtualSmartCardManager3, self), pszFriendlyName, bAdminAlgId, pbAdminKey, cbAdminKey, pbAdminKcv, cbAdminKcv, pbPuk, cbPuk, pbPin, cbPin, pbPinPolicy, cbPinPolicy, attestationType, fGenerate, pStatusCallback, ppszInstanceId);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const PFNREADOBJECTSECURITY = fn(
param0: ?[*:0]const u16,
param1: u32,
param2: ?*?*SECURITY_DESCRIPTOR,
param3: LPARAM,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const PFNWRITEOBJECTSECURITY = fn(
param0: ?[*:0]const u16,
param1: u32,
param2: ?*SECURITY_DESCRIPTOR,
param3: LPARAM,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const PFNDSCREATEISECINFO = fn(
param0: ?[*:0]const u16,
param1: ?[*:0]const u16,
param2: u32,
param3: ?*?*ISecurityInformation,
param4: ?PFNREADOBJECTSECURITY,
param5: ?PFNWRITEOBJECTSECURITY,
param6: LPARAM,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const PFNDSCREATEISECINFOEX = fn(
param0: ?[*:0]const u16,
param1: ?[*:0]const u16,
param2: ?[*:0]const u16,
param3: ?[*:0]const u16,
param4: ?[*:0]const u16,
param5: u32,
param6: ?*?*ISecurityInformation,
param7: ?PFNREADOBJECTSECURITY,
param8: ?PFNWRITEOBJECTSECURITY,
param9: LPARAM,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const PFNDSCREATESECPAGE = fn(
param0: ?[*:0]const u16,
param1: ?[*:0]const u16,
param2: u32,
param3: ?*?HPROPSHEETPAGE,
param4: ?PFNREADOBJECTSECURITY,
param5: ?PFNWRITEOBJECTSECURITY,
param6: LPARAM,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const PFNDSEDITSECURITY = fn(
param0: ?HWND,
param1: ?[*:0]const u16,
param2: ?[*:0]const u16,
param3: u32,
param4: ?[*:0]const u16,
param5: ?PFNREADOBJECTSECURITY,
param6: ?PFNWRITEOBJECTSECURITY,
param7: LPARAM,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
const CLSID_CCertSrvSetupKeyInformation_Value = @import("zig.zig").Guid.initString("<KEY>");
pub const CLSID_CCertSrvSetupKeyInformation = &CLSID_CCertSrvSetupKeyInformation_Value;
const CLSID_CCertSrvSetup_Value = @import("zig.zig").Guid.initString("961f180f-f55c-413d-a9b3-7d2af4d8e42f");
pub const CLSID_CCertSrvSetup = &CLSID_CCertSrvSetup_Value;
const CLSID_CMSCEPSetup_Value = @import("zig.zig").Guid.initString("aa4f5c02-8e7c-49c4-94fa-67a5cc5eadb4");
pub const CLSID_CMSCEPSetup = &CLSID_CMSCEPSetup_Value;
const CLSID_CCertificateEnrollmentServerSetup_Value = @import("zig.zig").Guid.initString("9902f3bc-88af-4cf8-ae62-7140531552b6");
pub const CLSID_CCertificateEnrollmentServerSetup = &CLSID_CCertificateEnrollmentServerSetup_Value;
const CLSID_CCertificateEnrollmentPolicyServerSetup_Value = @import("zig.zig").Guid.initString("afe2fa32-41b1-459d-a5de-49add8a72182");
pub const CLSID_CCertificateEnrollmentPolicyServerSetup = &CLSID_CCertificateEnrollmentPolicyServerSetup_Value;
// TODO: this type is limited to platform 'windowsServer2008'
const IID_ICertSrvSetupKeyInformation_Value = @import("zig.zig").Guid.initString("6ba73778-36da-4c39-8a85-bcfa7d000793");
pub const IID_ICertSrvSetupKeyInformation = &IID_ICertSrvSetupKeyInformation_Value;
pub const ICertSrvSetupKeyInformation = 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 ICertSrvSetupKeyInformation,
pVal: ?*?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 ICertSrvSetupKeyInformation,
bstrVal: ?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 ICertSrvSetupKeyInformation,
pVal: ?*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 ICertSrvSetupKeyInformation,
lVal: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Existing: fn(
self: *const ICertSrvSetupKeyInformation,
pVal: ?*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 ICertSrvSetupKeyInformation,
bVal: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ContainerName: fn(
self: *const ICertSrvSetupKeyInformation,
pVal: ?*?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 ICertSrvSetupKeyInformation,
bstrVal: ?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 ICertSrvSetupKeyInformation,
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 ICertSrvSetupKeyInformation,
bstrVal: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ExistingCACertificate: fn(
self: *const ICertSrvSetupKeyInformation,
pVal: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ExistingCACertificate: fn(
self: *const ICertSrvSetupKeyInformation,
varVal: 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 ICertSrvSetupKeyInformation_get_ProviderName(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetupKeyInformation.VTable, self.vtable).get_ProviderName(@ptrCast(*const ICertSrvSetupKeyInformation, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetupKeyInformation_put_ProviderName(self: *const T, bstrVal: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetupKeyInformation.VTable, self.vtable).put_ProviderName(@ptrCast(*const ICertSrvSetupKeyInformation, self), bstrVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetupKeyInformation_get_Length(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetupKeyInformation.VTable, self.vtable).get_Length(@ptrCast(*const ICertSrvSetupKeyInformation, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetupKeyInformation_put_Length(self: *const T, lVal: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetupKeyInformation.VTable, self.vtable).put_Length(@ptrCast(*const ICertSrvSetupKeyInformation, self), lVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetupKeyInformation_get_Existing(self: *const T, pVal: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetupKeyInformation.VTable, self.vtable).get_Existing(@ptrCast(*const ICertSrvSetupKeyInformation, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetupKeyInformation_put_Existing(self: *const T, bVal: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetupKeyInformation.VTable, self.vtable).put_Existing(@ptrCast(*const ICertSrvSetupKeyInformation, self), bVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetupKeyInformation_get_ContainerName(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetupKeyInformation.VTable, self.vtable).get_ContainerName(@ptrCast(*const ICertSrvSetupKeyInformation, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetupKeyInformation_put_ContainerName(self: *const T, bstrVal: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetupKeyInformation.VTable, self.vtable).put_ContainerName(@ptrCast(*const ICertSrvSetupKeyInformation, self), bstrVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetupKeyInformation_get_HashAlgorithm(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetupKeyInformation.VTable, self.vtable).get_HashAlgorithm(@ptrCast(*const ICertSrvSetupKeyInformation, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetupKeyInformation_put_HashAlgorithm(self: *const T, bstrVal: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetupKeyInformation.VTable, self.vtable).put_HashAlgorithm(@ptrCast(*const ICertSrvSetupKeyInformation, self), bstrVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetupKeyInformation_get_ExistingCACertificate(self: *const T, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetupKeyInformation.VTable, self.vtable).get_ExistingCACertificate(@ptrCast(*const ICertSrvSetupKeyInformation, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetupKeyInformation_put_ExistingCACertificate(self: *const T, varVal: VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetupKeyInformation.VTable, self.vtable).put_ExistingCACertificate(@ptrCast(*const ICertSrvSetupKeyInformation, self), varVal);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windowsServer2008'
const IID_ICertSrvSetupKeyInformationCollection_Value = @import("zig.zig").Guid.initString("e65c8b00-e58f-41f9-a9ec-a28d7427c844");
pub const IID_ICertSrvSetupKeyInformationCollection = &IID_ICertSrvSetupKeyInformationCollection_Value;
pub const ICertSrvSetupKeyInformationCollection = 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 ICertSrvSetupKeyInformationCollection,
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 ICertSrvSetupKeyInformationCollection,
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 ICertSrvSetupKeyInformationCollection,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const ICertSrvSetupKeyInformationCollection,
pIKeyInformation: ?*ICertSrvSetupKeyInformation,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetupKeyInformationCollection_get__NewEnum(self: *const T, ppVal: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetupKeyInformationCollection.VTable, self.vtable).get__NewEnum(@ptrCast(*const ICertSrvSetupKeyInformationCollection, self), ppVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetupKeyInformationCollection_get_Item(self: *const T, Index: i32, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetupKeyInformationCollection.VTable, self.vtable).get_Item(@ptrCast(*const ICertSrvSetupKeyInformationCollection, self), Index, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetupKeyInformationCollection_get_Count(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetupKeyInformationCollection.VTable, self.vtable).get_Count(@ptrCast(*const ICertSrvSetupKeyInformationCollection, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetupKeyInformationCollection_Add(self: *const T, pIKeyInformation: ?*ICertSrvSetupKeyInformation) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetupKeyInformationCollection.VTable, self.vtable).Add(@ptrCast(*const ICertSrvSetupKeyInformationCollection, self), pIKeyInformation);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const CASetupProperty = enum(i32) {
INVALID = -1,
CATYPE = 0,
CAKEYINFORMATION = 1,
INTERACTIVE = 2,
CANAME = 3,
CADSSUFFIX = 4,
VALIDITYPERIOD = 5,
VALIDITYPERIODUNIT = 6,
EXPIRATIONDATE = 7,
PRESERVEDATABASE = 8,
DATABASEDIRECTORY = 9,
LOGDIRECTORY = 10,
SHAREDFOLDER = 11,
PARENTCAMACHINE = 12,
PARENTCANAME = 13,
REQUESTFILE = 14,
WEBCAMACHINE = 15,
WEBCANAME = 16,
};
pub const ENUM_SETUPPROP_INVALID = CASetupProperty.INVALID;
pub const ENUM_SETUPPROP_CATYPE = CASetupProperty.CATYPE;
pub const ENUM_SETUPPROP_CAKEYINFORMATION = CASetupProperty.CAKEYINFORMATION;
pub const ENUM_SETUPPROP_INTERACTIVE = CASetupProperty.INTERACTIVE;
pub const ENUM_SETUPPROP_CANAME = CASetupProperty.CANAME;
pub const ENUM_SETUPPROP_CADSSUFFIX = CASetupProperty.CADSSUFFIX;
pub const ENUM_SETUPPROP_VALIDITYPERIOD = CASetupProperty.VALIDITYPERIOD;
pub const ENUM_SETUPPROP_VALIDITYPERIODUNIT = CASetupProperty.VALIDITYPERIODUNIT;
pub const ENUM_SETUPPROP_EXPIRATIONDATE = CASetupProperty.EXPIRATIONDATE;
pub const ENUM_SETUPPROP_PRESERVEDATABASE = CASetupProperty.PRESERVEDATABASE;
pub const ENUM_SETUPPROP_DATABASEDIRECTORY = CASetupProperty.DATABASEDIRECTORY;
pub const ENUM_SETUPPROP_LOGDIRECTORY = CASetupProperty.LOGDIRECTORY;
pub const ENUM_SETUPPROP_SHAREDFOLDER = CASetupProperty.SHAREDFOLDER;
pub const ENUM_SETUPPROP_PARENTCAMACHINE = CASetupProperty.PARENTCAMACHINE;
pub const ENUM_SETUPPROP_PARENTCANAME = CASetupProperty.PARENTCANAME;
pub const ENUM_SETUPPROP_REQUESTFILE = CASetupProperty.REQUESTFILE;
pub const ENUM_SETUPPROP_WEBCAMACHINE = CASetupProperty.WEBCAMACHINE;
pub const ENUM_SETUPPROP_WEBCANAME = CASetupProperty.WEBCANAME;
// TODO: this type is limited to platform 'windowsServer2008'
const IID_ICertSrvSetup_Value = @import("zig.zig").Guid.initString("b760a1bb-4784-44c0-8f12-555f0780ff25");
pub const IID_ICertSrvSetup = &IID_ICertSrvSetup_Value;
pub const ICertSrvSetup = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CAErrorId: fn(
self: *const ICertSrvSetup,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CAErrorString: fn(
self: *const ICertSrvSetup,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDefaults: fn(
self: *const ICertSrvSetup,
bServer: i16,
bClient: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetCASetupProperty: fn(
self: *const ICertSrvSetup,
propertyId: CASetupProperty,
pPropertyValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetCASetupProperty: fn(
self: *const ICertSrvSetup,
propertyId: CASetupProperty,
pPropertyValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
IsPropertyEditable: fn(
self: *const ICertSrvSetup,
propertyId: CASetupProperty,
pbEditable: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetSupportedCATypes: fn(
self: *const ICertSrvSetup,
pCATypes: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetProviderNameList: fn(
self: *const ICertSrvSetup,
pVal: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetKeyLengthList: fn(
self: *const ICertSrvSetup,
bstrProviderName: ?BSTR,
pVal: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetHashAlgorithmList: fn(
self: *const ICertSrvSetup,
bstrProviderName: ?BSTR,
pVal: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetPrivateKeyContainerList: fn(
self: *const ICertSrvSetup,
bstrProviderName: ?BSTR,
pVal: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetExistingCACertificates: fn(
self: *const ICertSrvSetup,
ppVal: ?*?*ICertSrvSetupKeyInformationCollection,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CAImportPFX: fn(
self: *const ICertSrvSetup,
bstrFileName: ?BSTR,
bstrPasswd: ?BSTR,
bOverwriteExistingKey: i16,
ppVal: ?*?*ICertSrvSetupKeyInformation,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetCADistinguishedName: fn(
self: *const ICertSrvSetup,
bstrCADN: ?BSTR,
bIgnoreUnicode: i16,
bOverwriteExistingKey: i16,
bOverwriteExistingCAInDS: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetDatabaseInformation: fn(
self: *const ICertSrvSetup,
bstrDBDirectory: ?BSTR,
bstrLogDirectory: ?BSTR,
bstrSharedFolder: ?BSTR,
bForceOverwrite: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetParentCAInformation: fn(
self: *const ICertSrvSetup,
bstrCAConfiguration: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetWebCAInformation: fn(
self: *const ICertSrvSetup,
bstrCAConfiguration: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Install: fn(
self: *const ICertSrvSetup,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
PreUnInstall: fn(
self: *const ICertSrvSetup,
bClientOnly: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
PostUnInstall: fn(
self: *const ICertSrvSetup,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_get_CAErrorId(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).get_CAErrorId(@ptrCast(*const ICertSrvSetup, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_get_CAErrorString(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).get_CAErrorString(@ptrCast(*const ICertSrvSetup, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_InitializeDefaults(self: *const T, bServer: i16, bClient: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).InitializeDefaults(@ptrCast(*const ICertSrvSetup, self), bServer, bClient);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_GetCASetupProperty(self: *const T, propertyId: CASetupProperty, pPropertyValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).GetCASetupProperty(@ptrCast(*const ICertSrvSetup, self), propertyId, pPropertyValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_SetCASetupProperty(self: *const T, propertyId: CASetupProperty, pPropertyValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).SetCASetupProperty(@ptrCast(*const ICertSrvSetup, self), propertyId, pPropertyValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_IsPropertyEditable(self: *const T, propertyId: CASetupProperty, pbEditable: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).IsPropertyEditable(@ptrCast(*const ICertSrvSetup, self), propertyId, pbEditable);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_GetSupportedCATypes(self: *const T, pCATypes: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).GetSupportedCATypes(@ptrCast(*const ICertSrvSetup, self), pCATypes);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_GetProviderNameList(self: *const T, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).GetProviderNameList(@ptrCast(*const ICertSrvSetup, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_GetKeyLengthList(self: *const T, bstrProviderName: ?BSTR, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).GetKeyLengthList(@ptrCast(*const ICertSrvSetup, self), bstrProviderName, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_GetHashAlgorithmList(self: *const T, bstrProviderName: ?BSTR, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).GetHashAlgorithmList(@ptrCast(*const ICertSrvSetup, self), bstrProviderName, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_GetPrivateKeyContainerList(self: *const T, bstrProviderName: ?BSTR, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).GetPrivateKeyContainerList(@ptrCast(*const ICertSrvSetup, self), bstrProviderName, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_GetExistingCACertificates(self: *const T, ppVal: ?*?*ICertSrvSetupKeyInformationCollection) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).GetExistingCACertificates(@ptrCast(*const ICertSrvSetup, self), ppVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_CAImportPFX(self: *const T, bstrFileName: ?BSTR, bstrPasswd: ?BSTR, bOverwriteExistingKey: i16, ppVal: ?*?*ICertSrvSetupKeyInformation) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).CAImportPFX(@ptrCast(*const ICertSrvSetup, self), bstrFileName, bstrPasswd, bOverwriteExistingKey, ppVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_SetCADistinguishedName(self: *const T, bstrCADN: ?BSTR, bIgnoreUnicode: i16, bOverwriteExistingKey: i16, bOverwriteExistingCAInDS: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).SetCADistinguishedName(@ptrCast(*const ICertSrvSetup, self), bstrCADN, bIgnoreUnicode, bOverwriteExistingKey, bOverwriteExistingCAInDS);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_SetDatabaseInformation(self: *const T, bstrDBDirectory: ?BSTR, bstrLogDirectory: ?BSTR, bstrSharedFolder: ?BSTR, bForceOverwrite: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).SetDatabaseInformation(@ptrCast(*const ICertSrvSetup, self), bstrDBDirectory, bstrLogDirectory, bstrSharedFolder, bForceOverwrite);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_SetParentCAInformation(self: *const T, bstrCAConfiguration: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).SetParentCAInformation(@ptrCast(*const ICertSrvSetup, self), bstrCAConfiguration);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_SetWebCAInformation(self: *const T, bstrCAConfiguration: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).SetWebCAInformation(@ptrCast(*const ICertSrvSetup, self), bstrCAConfiguration);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_Install(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).Install(@ptrCast(*const ICertSrvSetup, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_PreUnInstall(self: *const T, bClientOnly: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).PreUnInstall(@ptrCast(*const ICertSrvSetup, self), bClientOnly);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertSrvSetup_PostUnInstall(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertSrvSetup.VTable, self.vtable).PostUnInstall(@ptrCast(*const ICertSrvSetup, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const MSCEPSetupProperty = enum(i32) {
USELOCALSYSTEM = 0,
USECHALLENGE = 1,
RANAME_CN = 2,
RANAME_EMAIL = 3,
RANAME_COMPANY = 4,
RANAME_DEPT = 5,
RANAME_CITY = 6,
RANAME_STATE = 7,
RANAME_COUNTRY = 8,
SIGNINGKEYINFORMATION = 9,
EXCHANGEKEYINFORMATION = 10,
CAINFORMATION = 11,
MSCEPURL = 12,
CHALLENGEURL = 13,
};
pub const ENUM_CEPSETUPPROP_USELOCALSYSTEM = MSCEPSetupProperty.USELOCALSYSTEM;
pub const ENUM_CEPSETUPPROP_USECHALLENGE = MSCEPSetupProperty.USECHALLENGE;
pub const ENUM_CEPSETUPPROP_RANAME_CN = MSCEPSetupProperty.RANAME_CN;
pub const ENUM_CEPSETUPPROP_RANAME_EMAIL = MSCEPSetupProperty.RANAME_EMAIL;
pub const ENUM_CEPSETUPPROP_RANAME_COMPANY = MSCEPSetupProperty.RANAME_COMPANY;
pub const ENUM_CEPSETUPPROP_RANAME_DEPT = MSCEPSetupProperty.RANAME_DEPT;
pub const ENUM_CEPSETUPPROP_RANAME_CITY = MSCEPSetupProperty.RANAME_CITY;
pub const ENUM_CEPSETUPPROP_RANAME_STATE = MSCEPSetupProperty.RANAME_STATE;
pub const ENUM_CEPSETUPPROP_RANAME_COUNTRY = MSCEPSetupProperty.RANAME_COUNTRY;
pub const ENUM_CEPSETUPPROP_SIGNINGKEYINFORMATION = MSCEPSetupProperty.SIGNINGKEYINFORMATION;
pub const ENUM_CEPSETUPPROP_EXCHANGEKEYINFORMATION = MSCEPSetupProperty.EXCHANGEKEYINFORMATION;
pub const ENUM_CEPSETUPPROP_CAINFORMATION = MSCEPSetupProperty.CAINFORMATION;
pub const ENUM_CEPSETUPPROP_MSCEPURL = MSCEPSetupProperty.MSCEPURL;
pub const ENUM_CEPSETUPPROP_CHALLENGEURL = MSCEPSetupProperty.CHALLENGEURL;
// TODO: this type is limited to platform 'windowsServer2008'
const IID_IMSCEPSetup_Value = @import("zig.zig").Guid.initString("4f7761bb-9f3b-4592-9ee0-9a73259c313e");
pub const IID_IMSCEPSetup = &IID_IMSCEPSetup_Value;
pub const IMSCEPSetup = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MSCEPErrorId: fn(
self: *const IMSCEPSetup,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MSCEPErrorString: fn(
self: *const IMSCEPSetup,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDefaults: fn(
self: *const IMSCEPSetup,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetMSCEPSetupProperty: fn(
self: *const IMSCEPSetup,
propertyId: MSCEPSetupProperty,
pVal: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetMSCEPSetupProperty: fn(
self: *const IMSCEPSetup,
propertyId: MSCEPSetupProperty,
pPropertyValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetAccountInformation: fn(
self: *const IMSCEPSetup,
bstrUserName: ?BSTR,
bstrPassword: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
IsMSCEPStoreEmpty: fn(
self: *const IMSCEPSetup,
pbEmpty: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetProviderNameList: fn(
self: *const IMSCEPSetup,
bExchange: i16,
pVal: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetKeyLengthList: fn(
self: *const IMSCEPSetup,
bExchange: i16,
bstrProviderName: ?BSTR,
pVal: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Install: fn(
self: *const IMSCEPSetup,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
PreUnInstall: fn(
self: *const IMSCEPSetup,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
PostUnInstall: fn(
self: *const IMSCEPSetup,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSCEPSetup_get_MSCEPErrorId(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSCEPSetup.VTable, self.vtable).get_MSCEPErrorId(@ptrCast(*const IMSCEPSetup, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSCEPSetup_get_MSCEPErrorString(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSCEPSetup.VTable, self.vtable).get_MSCEPErrorString(@ptrCast(*const IMSCEPSetup, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSCEPSetup_InitializeDefaults(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSCEPSetup.VTable, self.vtable).InitializeDefaults(@ptrCast(*const IMSCEPSetup, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSCEPSetup_GetMSCEPSetupProperty(self: *const T, propertyId: MSCEPSetupProperty, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSCEPSetup.VTable, self.vtable).GetMSCEPSetupProperty(@ptrCast(*const IMSCEPSetup, self), propertyId, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSCEPSetup_SetMSCEPSetupProperty(self: *const T, propertyId: MSCEPSetupProperty, pPropertyValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSCEPSetup.VTable, self.vtable).SetMSCEPSetupProperty(@ptrCast(*const IMSCEPSetup, self), propertyId, pPropertyValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSCEPSetup_SetAccountInformation(self: *const T, bstrUserName: ?BSTR, bstrPassword: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSCEPSetup.VTable, self.vtable).SetAccountInformation(@ptrCast(*const IMSCEPSetup, self), bstrUserName, bstrPassword);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSCEPSetup_IsMSCEPStoreEmpty(self: *const T, pbEmpty: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSCEPSetup.VTable, self.vtable).IsMSCEPStoreEmpty(@ptrCast(*const IMSCEPSetup, self), pbEmpty);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSCEPSetup_GetProviderNameList(self: *const T, bExchange: i16, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSCEPSetup.VTable, self.vtable).GetProviderNameList(@ptrCast(*const IMSCEPSetup, self), bExchange, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSCEPSetup_GetKeyLengthList(self: *const T, bExchange: i16, bstrProviderName: ?BSTR, pVal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSCEPSetup.VTable, self.vtable).GetKeyLengthList(@ptrCast(*const IMSCEPSetup, self), bExchange, bstrProviderName, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSCEPSetup_Install(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSCEPSetup.VTable, self.vtable).Install(@ptrCast(*const IMSCEPSetup, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSCEPSetup_PreUnInstall(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSCEPSetup.VTable, self.vtable).PreUnInstall(@ptrCast(*const IMSCEPSetup, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSCEPSetup_PostUnInstall(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSCEPSetup.VTable, self.vtable).PostUnInstall(@ptrCast(*const IMSCEPSetup, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const CESSetupProperty = enum(i32) {
USE_IISAPPPOOLIDENTITY = 0,
CACONFIG = 1,
AUTHENTICATION = 2,
SSLCERTHASH = 3,
URL = 4,
RENEWALONLY = 5,
ALLOW_KEYBASED_RENEWAL = 6,
};
pub const ENUM_CESSETUPPROP_USE_IISAPPPOOLIDENTITY = CESSetupProperty.USE_IISAPPPOOLIDENTITY;
pub const ENUM_CESSETUPPROP_CACONFIG = CESSetupProperty.CACONFIG;
pub const ENUM_CESSETUPPROP_AUTHENTICATION = CESSetupProperty.AUTHENTICATION;
pub const ENUM_CESSETUPPROP_SSLCERTHASH = CESSetupProperty.SSLCERTHASH;
pub const ENUM_CESSETUPPROP_URL = CESSetupProperty.URL;
pub const ENUM_CESSETUPPROP_RENEWALONLY = CESSetupProperty.RENEWALONLY;
pub const ENUM_CESSETUPPROP_ALLOW_KEYBASED_RENEWAL = CESSetupProperty.ALLOW_KEYBASED_RENEWAL;
// TODO: this type is limited to platform 'windows6.1'
const IID_ICertificateEnrollmentServerSetup_Value = @import("zig.zig").Guid.initString("70027fdb-9dd9-4921-8944-b35cb31bd2ec");
pub const IID_ICertificateEnrollmentServerSetup = &IID_ICertificateEnrollmentServerSetup_Value;
pub const ICertificateEnrollmentServerSetup = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ErrorString: fn(
self: *const ICertificateEnrollmentServerSetup,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeInstallDefaults: fn(
self: *const ICertificateEnrollmentServerSetup,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetProperty: fn(
self: *const ICertificateEnrollmentServerSetup,
propertyId: CESSetupProperty,
pPropertyValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetProperty: fn(
self: *const ICertificateEnrollmentServerSetup,
propertyId: CESSetupProperty,
pPropertyValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetApplicationPoolCredentials: fn(
self: *const ICertificateEnrollmentServerSetup,
bstrUsername: ?BSTR,
bstrPassword: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Install: fn(
self: *const ICertificateEnrollmentServerSetup,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
UnInstall: fn(
self: *const ICertificateEnrollmentServerSetup,
pCAConfig: ?*VARIANT,
pAuthentication: ?*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 ICertificateEnrollmentServerSetup_get_ErrorString(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificateEnrollmentServerSetup.VTable, self.vtable).get_ErrorString(@ptrCast(*const ICertificateEnrollmentServerSetup, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificateEnrollmentServerSetup_InitializeInstallDefaults(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificateEnrollmentServerSetup.VTable, self.vtable).InitializeInstallDefaults(@ptrCast(*const ICertificateEnrollmentServerSetup, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificateEnrollmentServerSetup_GetProperty(self: *const T, propertyId: CESSetupProperty, pPropertyValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificateEnrollmentServerSetup.VTable, self.vtable).GetProperty(@ptrCast(*const ICertificateEnrollmentServerSetup, self), propertyId, pPropertyValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificateEnrollmentServerSetup_SetProperty(self: *const T, propertyId: CESSetupProperty, pPropertyValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificateEnrollmentServerSetup.VTable, self.vtable).SetProperty(@ptrCast(*const ICertificateEnrollmentServerSetup, self), propertyId, pPropertyValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificateEnrollmentServerSetup_SetApplicationPoolCredentials(self: *const T, bstrUsername: ?BSTR, bstrPassword: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificateEnrollmentServerSetup.VTable, self.vtable).SetApplicationPoolCredentials(@ptrCast(*const ICertificateEnrollmentServerSetup, self), bstrUsername, bstrPassword);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificateEnrollmentServerSetup_Install(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificateEnrollmentServerSetup.VTable, self.vtable).Install(@ptrCast(*const ICertificateEnrollmentServerSetup, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificateEnrollmentServerSetup_UnInstall(self: *const T, pCAConfig: ?*VARIANT, pAuthentication: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificateEnrollmentServerSetup.VTable, self.vtable).UnInstall(@ptrCast(*const ICertificateEnrollmentServerSetup, self), pCAConfig, pAuthentication);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const CEPSetupProperty = enum(i32) {
AUTHENTICATION = 0,
SSLCERTHASH = 1,
URL = 2,
KEYBASED_RENEWAL = 3,
};
pub const ENUM_CEPSETUPPROP_AUTHENTICATION = CEPSetupProperty.AUTHENTICATION;
pub const ENUM_CEPSETUPPROP_SSLCERTHASH = CEPSetupProperty.SSLCERTHASH;
pub const ENUM_CEPSETUPPROP_URL = CEPSetupProperty.URL;
pub const ENUM_CEPSETUPPROP_KEYBASED_RENEWAL = CEPSetupProperty.KEYBASED_RENEWAL;
// TODO: this type is limited to platform 'windows6.1'
const IID_ICertificateEnrollmentPolicyServerSetup_Value = @import("zig.zig").Guid.initString("859252cc-238c-4a88-b8fd-a37e7d04e68b");
pub const IID_ICertificateEnrollmentPolicyServerSetup = &IID_ICertificateEnrollmentPolicyServerSetup_Value;
pub const ICertificateEnrollmentPolicyServerSetup = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ErrorString: fn(
self: *const ICertificateEnrollmentPolicyServerSetup,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeInstallDefaults: fn(
self: *const ICertificateEnrollmentPolicyServerSetup,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetProperty: fn(
self: *const ICertificateEnrollmentPolicyServerSetup,
propertyId: CEPSetupProperty,
pPropertyValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetProperty: fn(
self: *const ICertificateEnrollmentPolicyServerSetup,
propertyId: CEPSetupProperty,
pPropertyValue: ?*VARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Install: fn(
self: *const ICertificateEnrollmentPolicyServerSetup,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
UnInstall: fn(
self: *const ICertificateEnrollmentPolicyServerSetup,
pAuthKeyBasedRenewal: ?*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 ICertificateEnrollmentPolicyServerSetup_get_ErrorString(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificateEnrollmentPolicyServerSetup.VTable, self.vtable).get_ErrorString(@ptrCast(*const ICertificateEnrollmentPolicyServerSetup, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificateEnrollmentPolicyServerSetup_InitializeInstallDefaults(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificateEnrollmentPolicyServerSetup.VTable, self.vtable).InitializeInstallDefaults(@ptrCast(*const ICertificateEnrollmentPolicyServerSetup, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificateEnrollmentPolicyServerSetup_GetProperty(self: *const T, propertyId: CEPSetupProperty, pPropertyValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificateEnrollmentPolicyServerSetup.VTable, self.vtable).GetProperty(@ptrCast(*const ICertificateEnrollmentPolicyServerSetup, self), propertyId, pPropertyValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificateEnrollmentPolicyServerSetup_SetProperty(self: *const T, propertyId: CEPSetupProperty, pPropertyValue: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificateEnrollmentPolicyServerSetup.VTable, self.vtable).SetProperty(@ptrCast(*const ICertificateEnrollmentPolicyServerSetup, self), propertyId, pPropertyValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificateEnrollmentPolicyServerSetup_Install(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificateEnrollmentPolicyServerSetup.VTable, self.vtable).Install(@ptrCast(*const ICertificateEnrollmentPolicyServerSetup, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ICertificateEnrollmentPolicyServerSetup_UnInstall(self: *const T, pAuthKeyBasedRenewal: ?*VARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const ICertificateEnrollmentPolicyServerSetup.VTable, self.vtable).UnInstall(@ptrCast(*const ICertificateEnrollmentPolicyServerSetup, self), pAuthKeyBasedRenewal);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const ENUM_PERIOD = enum(i32) {
INVALID = -1,
SECONDS = 0,
MINUTES = 1,
HOURS = 2,
DAYS = 3,
WEEKS = 4,
MONTHS = 5,
YEARS = 6,
};
pub const ENUM_PERIOD_INVALID = ENUM_PERIOD.INVALID;
pub const ENUM_PERIOD_SECONDS = ENUM_PERIOD.SECONDS;
pub const ENUM_PERIOD_MINUTES = ENUM_PERIOD.MINUTES;
pub const ENUM_PERIOD_HOURS = ENUM_PERIOD.HOURS;
pub const ENUM_PERIOD_DAYS = ENUM_PERIOD.DAYS;
pub const ENUM_PERIOD_WEEKS = ENUM_PERIOD.WEEKS;
pub const ENUM_PERIOD_MONTHS = ENUM_PERIOD.MONTHS;
pub const ENUM_PERIOD_YEARS = ENUM_PERIOD.YEARS;
pub const LLFILETIME = extern struct {
Anonymous: extern union {
ll: i64,
ft: FILETIME,
},
};
pub const SIP_SUBJECTINFO = extern struct {
cbSize: u32,
pgSubjectType: ?*Guid,
hFile: ?HANDLE,
pwsFileName: ?[*:0]const u16,
pwsDisplayName: ?[*:0]const u16,
dwReserved1: u32,
dwIntVersion: u32,
hProv: usize,
DigestAlgorithm: CRYPT_ALGORITHM_IDENTIFIER,
dwFlags: u32,
dwEncodingType: u32,
dwReserved2: u32,
fdwCAPISettings: u32,
fdwSecuritySettings: u32,
dwIndex: u32,
dwUnionChoice: u32,
Anonymous: extern union {
psFlat: ?*MS_ADDINFO_FLAT,
psCatMember: ?*MS_ADDINFO_CATALOGMEMBER,
psBlob: ?*MS_ADDINFO_BLOB,
},
pClientData: ?*c_void,
};
pub const MS_ADDINFO_FLAT = extern struct {
cbStruct: u32,
pIndirectData: ?*SIP_INDIRECT_DATA,
};
pub const MS_ADDINFO_CATALOGMEMBER = extern struct {
cbStruct: u32,
pStore: ?*CRYPTCATSTORE,
pMember: ?*CRYPTCATMEMBER,
};
pub const MS_ADDINFO_BLOB = extern struct {
cbStruct: u32,
cbMemObject: u32,
pbMemObject: ?*u8,
cbMemSignedMsg: u32,
pbMemSignedMsg: ?*u8,
};
pub const SIP_CAP_SET_V2 = extern struct {
cbSize: u32,
dwVersion: u32,
isMultiSign: BOOL,
dwReserved: u32,
};
pub const SIP_CAP_SET_V3 = extern struct {
cbSize: u32,
dwVersion: u32,
isMultiSign: BOOL,
Anonymous: extern union {
dwFlags: u32,
dwReserved: u32,
},
};
pub const SIP_INDIRECT_DATA = extern struct {
Data: CRYPT_ATTRIBUTE_TYPE_VALUE,
DigestAlgorithm: CRYPT_ALGORITHM_IDENTIFIER,
Digest: CRYPTOAPI_BLOB,
};
pub const pCryptSIPGetSignedDataMsg = fn(
pSubjectInfo: ?*SIP_SUBJECTINFO,
pdwEncodingType: ?*u32,
dwIndex: u32,
pcbSignedDataMsg: ?*u32,
pbSignedDataMsg: ?*u8,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const pCryptSIPPutSignedDataMsg = fn(
pSubjectInfo: ?*SIP_SUBJECTINFO,
dwEncodingType: u32,
pdwIndex: ?*u32,
cbSignedDataMsg: u32,
pbSignedDataMsg: ?*u8,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const pCryptSIPCreateIndirectData = fn(
pSubjectInfo: ?*SIP_SUBJECTINFO,
pcbIndirectData: ?*u32,
pIndirectData: ?*SIP_INDIRECT_DATA,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const pCryptSIPVerifyIndirectData = fn(
pSubjectInfo: ?*SIP_SUBJECTINFO,
pIndirectData: ?*SIP_INDIRECT_DATA,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const pCryptSIPRemoveSignedDataMsg = fn(
pSubjectInfo: ?*SIP_SUBJECTINFO,
dwIndex: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const SIP_DISPATCH_INFO = extern struct {
cbSize: u32,
hSIP: ?HANDLE,
pfGet: ?pCryptSIPGetSignedDataMsg,
pfPut: ?pCryptSIPPutSignedDataMsg,
pfCreate: ?pCryptSIPCreateIndirectData,
pfVerify: ?pCryptSIPVerifyIndirectData,
pfRemove: ?pCryptSIPRemoveSignedDataMsg,
};
pub const pfnIsFileSupported = fn(
hFile: ?HANDLE,
pgSubject: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const pfnIsFileSupportedName = fn(
pwszFileName: ?PWSTR,
pgSubject: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const SIP_ADD_NEWPROVIDER = extern struct {
cbStruct: u32,
pgSubject: ?*Guid,
pwszDLLFileName: ?PWSTR,
pwszMagicNumber: ?PWSTR,
pwszIsFunctionName: ?PWSTR,
pwszGetFuncName: ?PWSTR,
pwszPutFuncName: ?PWSTR,
pwszCreateFuncName: ?PWSTR,
pwszVerifyFuncName: ?PWSTR,
pwszRemoveFuncName: ?PWSTR,
pwszIsFunctionNameFmt2: ?PWSTR,
pwszGetCapFuncName: ?PWSTR,
};
pub const pCryptSIPGetCaps = fn(
pSubjInfo: ?*SIP_SUBJECTINFO,
pCaps: ?*SIP_CAP_SET_V3,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const pCryptSIPGetSealedDigest = fn(
pSubjectInfo: ?*SIP_SUBJECTINFO,
pSig: ?[*:0]const u8,
dwSig: u32,
pbDigest: ?[*:0]u8,
pcbDigest: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const CRYPTCATSTORE = extern struct {
cbStruct: u32,
dwPublicVersion: u32,
pwszP7File: ?PWSTR,
hProv: usize,
dwEncodingType: u32,
fdwStoreFlags: CRYPTCAT_OPEN_FLAGS,
hReserved: ?HANDLE,
hAttrs: ?HANDLE,
hCryptMsg: ?*c_void,
hSorted: ?HANDLE,
};
pub const CRYPTCATMEMBER = extern struct {
cbStruct: u32,
pwszReferenceTag: ?PWSTR,
pwszFileName: ?PWSTR,
gSubjectType: Guid,
fdwMemberFlags: u32,
pIndirectData: ?*SIP_INDIRECT_DATA,
dwCertVersion: u32,
dwReserved: u32,
hReserved: ?HANDLE,
sEncodedIndirectData: CRYPTOAPI_BLOB,
sEncodedMemberInfo: CRYPTOAPI_BLOB,
};
pub const CRYPTCATATTRIBUTE = extern struct {
cbStruct: u32,
pwszReferenceTag: ?PWSTR,
dwAttrTypeAndAction: u32,
cbValue: u32,
pbValue: ?*u8,
dwReserved: u32,
};
pub const CRYPTCATCDF = extern struct {
cbStruct: u32,
hFile: ?HANDLE,
dwCurFilePos: u32,
dwLastMemberOffset: u32,
fEOF: BOOL,
pwszResultDir: ?PWSTR,
hCATStore: ?HANDLE,
};
pub const CATALOG_INFO = extern struct {
cbStruct: u32,
wszCatalogFile: [260]u16,
};
pub const PFN_CDF_PARSE_ERROR_CALLBACK = fn(
dwErrorArea: u32,
dwLocalError: u32,
pwszLine: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) void;
pub const WINTRUST_DATA = extern struct {
cbStruct: u32,
pPolicyCallbackData: ?*c_void,
pSIPClientData: ?*c_void,
dwUIChoice: WINTRUST_DATA_UICHOICE,
fdwRevocationChecks: WINTRUST_DATA_REVOCATION_CHECKS,
dwUnionChoice: WINTRUST_DATA_UNION_CHOICE,
Anonymous: extern union {
pFile: ?*WINTRUST_FILE_INFO,
pCatalog: ?*WINTRUST_CATALOG_INFO,
pBlob: ?*WINTRUST_BLOB_INFO,
pSgnr: ?*WINTRUST_SGNR_INFO,
pCert: ?*WINTRUST_CERT_INFO,
},
dwStateAction: WINTRUST_DATA_STATE_ACTION,
hWVTStateData: ?HANDLE,
pwszURLReference: ?PWSTR,
dwProvFlags: u32,
dwUIContext: WINTRUST_DATA_UICONTEXT,
pSignatureSettings: ?*WINTRUST_SIGNATURE_SETTINGS,
};
pub const WINTRUST_SIGNATURE_SETTINGS = extern struct {
cbStruct: u32,
dwIndex: u32,
dwFlags: WINTRUST_SIGNATURE_SETTINGS_FLAGS,
cSecondarySigs: u32,
dwVerifiedSigIndex: u32,
pCryptoPolicy: ?*CERT_STRONG_SIGN_PARA,
};
pub const WINTRUST_FILE_INFO = extern struct {
cbStruct: u32,
pcwszFilePath: ?[*:0]const u16,
hFile: ?HANDLE,
pgKnownSubject: ?*Guid,
};
pub const WINTRUST_CATALOG_INFO = extern struct {
cbStruct: u32,
dwCatalogVersion: u32,
pcwszCatalogFilePath: ?[*:0]const u16,
pcwszMemberTag: ?[*:0]const u16,
pcwszMemberFilePath: ?[*:0]const u16,
hMemberFile: ?HANDLE,
pbCalculatedFileHash: ?*u8,
cbCalculatedFileHash: u32,
pcCatalogContext: ?*CTL_CONTEXT,
hCatAdmin: isize,
};
pub const WINTRUST_BLOB_INFO = extern struct {
cbStruct: u32,
gSubject: Guid,
pcwszDisplayName: ?[*:0]const u16,
cbMemObject: u32,
pbMemObject: ?*u8,
cbMemSignedMsg: u32,
pbMemSignedMsg: ?*u8,
};
pub const WINTRUST_SGNR_INFO = extern struct {
cbStruct: u32,
pcwszDisplayName: ?[*:0]const u16,
psSignerInfo: ?*CMSG_SIGNER_INFO,
chStores: u32,
pahStores: ?*?*c_void,
};
pub const WINTRUST_CERT_INFO = extern struct {
cbStruct: u32,
pcwszDisplayName: ?[*:0]const u16,
psCertContext: ?*CERT_CONTEXT,
chStores: u32,
pahStores: ?*?*c_void,
dwFlags: u32,
psftVerifyAsOf: ?*FILETIME,
};
pub const PFN_CPD_MEM_ALLOC = fn(
cbSize: u32,
) callconv(@import("std").os.windows.WINAPI) ?*c_void;
pub const PFN_CPD_MEM_FREE = fn(
pvMem2Free: ?*c_void,
) callconv(@import("std").os.windows.WINAPI) void;
pub const PFN_CPD_ADD_STORE = fn(
pProvData: ?*CRYPT_PROVIDER_DATA,
hStore2Add: ?*c_void,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const PFN_CPD_ADD_SGNR = fn(
pProvData: ?*CRYPT_PROVIDER_DATA,
fCounterSigner: BOOL,
idxSigner: u32,
pSgnr2Add: ?*CRYPT_PROVIDER_SGNR,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const PFN_CPD_ADD_CERT = fn(
pProvData: ?*CRYPT_PROVIDER_DATA,
idxSigner: u32,
fCounterSigner: BOOL,
idxCounterSigner: u32,
pCert2Add: ?*const CERT_CONTEXT,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const PFN_CPD_ADD_PRIVDATA = fn(
pProvData: ?*CRYPT_PROVIDER_DATA,
pPrivData2Add: ?*CRYPT_PROVIDER_PRIVDATA,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const PFN_PROVIDER_INIT_CALL = fn(
pProvData: ?*CRYPT_PROVIDER_DATA,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const PFN_PROVIDER_OBJTRUST_CALL = fn(
pProvData: ?*CRYPT_PROVIDER_DATA,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const PFN_PROVIDER_SIGTRUST_CALL = fn(
pProvData: ?*CRYPT_PROVIDER_DATA,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const PFN_PROVIDER_CERTTRUST_CALL = fn(
pProvData: ?*CRYPT_PROVIDER_DATA,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const PFN_PROVIDER_FINALPOLICY_CALL = fn(
pProvData: ?*CRYPT_PROVIDER_DATA,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const PFN_PROVIDER_TESTFINALPOLICY_CALL = fn(
pProvData: ?*CRYPT_PROVIDER_DATA,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const PFN_PROVIDER_CLEANUP_CALL = fn(
pProvData: ?*CRYPT_PROVIDER_DATA,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const PFN_PROVIDER_CERTCHKPOLICY_CALL = fn(
pProvData: ?*CRYPT_PROVIDER_DATA,
idxSigner: u32,
fCounterSignerChain: BOOL,
idxCounterSigner: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const CRYPT_PROVIDER_DATA = extern struct {
cbStruct: u32,
pWintrustData: ?*WINTRUST_DATA,
fOpenedFile: BOOL,
hWndParent: ?HWND,
pgActionID: ?*Guid,
hProv: usize,
dwError: u32,
dwRegSecuritySettings: u32,
dwRegPolicySettings: u32,
psPfns: ?*CRYPT_PROVIDER_FUNCTIONS,
cdwTrustStepErrors: u32,
padwTrustStepErrors: ?*u32,
chStores: u32,
pahStores: ?*?*c_void,
dwEncoding: u32,
hMsg: ?*c_void,
csSigners: u32,
pasSigners: ?*CRYPT_PROVIDER_SGNR,
csProvPrivData: u32,
pasProvPrivData: ?*CRYPT_PROVIDER_PRIVDATA,
dwSubjectChoice: u32,
Anonymous: extern union {
pPDSip: ?*PROVDATA_SIP,
},
pszUsageOID: ?PSTR,
fRecallWithState: BOOL,
sftSystemTime: FILETIME,
pszCTLSignerUsageOID: ?PSTR,
dwProvFlags: u32,
dwFinalError: u32,
pRequestUsage: ?*CERT_USAGE_MATCH,
dwTrustPubSettings: u32,
dwUIStateFlags: u32,
pSigState: ?*CRYPT_PROVIDER_SIGSTATE,
pSigSettings: ?*WINTRUST_SIGNATURE_SETTINGS,
};
pub const CRYPT_PROVIDER_SIGSTATE = extern struct {
cbStruct: u32,
rhSecondarySigs: ?*?*c_void,
hPrimarySig: ?*c_void,
fFirstAttemptMade: BOOL,
fNoMoreSigs: BOOL,
cSecondarySigs: u32,
dwCurrentIndex: u32,
fSupportMultiSig: BOOL,
dwCryptoPolicySupport: u32,
iAttemptCount: u32,
fCheckedSealing: BOOL,
pSealingSignature: ?*SEALING_SIGNATURE_ATTRIBUTE,
};
pub const CRYPT_PROVIDER_FUNCTIONS = extern struct {
cbStruct: u32,
pfnAlloc: ?PFN_CPD_MEM_ALLOC,
pfnFree: ?PFN_CPD_MEM_FREE,
pfnAddStore2Chain: ?PFN_CPD_ADD_STORE,
pfnAddSgnr2Chain: ?PFN_CPD_ADD_SGNR,
pfnAddCert2Chain: ?PFN_CPD_ADD_CERT,
pfnAddPrivData2Chain: ?PFN_CPD_ADD_PRIVDATA,
pfnInitialize: ?PFN_PROVIDER_INIT_CALL,
pfnObjectTrust: ?PFN_PROVIDER_OBJTRUST_CALL,
pfnSignatureTrust: ?PFN_PROVIDER_SIGTRUST_CALL,
pfnCertificateTrust: ?PFN_PROVIDER_CERTTRUST_CALL,
pfnFinalPolicy: ?PFN_PROVIDER_FINALPOLICY_CALL,
pfnCertCheckPolicy: ?PFN_PROVIDER_CERTCHKPOLICY_CALL,
pfnTestFinalPolicy: ?PFN_PROVIDER_TESTFINALPOLICY_CALL,
psUIpfns: ?*CRYPT_PROVUI_FUNCS,
pfnCleanupPolicy: ?PFN_PROVIDER_CLEANUP_CALL,
};
pub const PFN_PROVUI_CALL = fn(
hWndSecurityDialog: ?HWND,
pProvData: ?*CRYPT_PROVIDER_DATA,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const CRYPT_PROVUI_FUNCS = extern struct {
cbStruct: u32,
psUIData: ?*CRYPT_PROVUI_DATA,
pfnOnMoreInfoClick: ?PFN_PROVUI_CALL,
pfnOnMoreInfoClickDefault: ?PFN_PROVUI_CALL,
pfnOnAdvancedClick: ?PFN_PROVUI_CALL,
pfnOnAdvancedClickDefault: ?PFN_PROVUI_CALL,
};
pub const CRYPT_PROVUI_DATA = extern struct {
cbStruct: u32,
dwFinalError: u32,
pYesButtonText: ?PWSTR,
pNoButtonText: ?PWSTR,
pMoreInfoButtonText: ?PWSTR,
pAdvancedLinkText: ?PWSTR,
pCopyActionText: ?PWSTR,
pCopyActionTextNoTS: ?PWSTR,
pCopyActionTextNotSigned: ?PWSTR,
};
pub const CRYPT_PROVIDER_SGNR = extern struct {
cbStruct: u32,
sftVerifyAsOf: FILETIME,
csCertChain: u32,
pasCertChain: ?*CRYPT_PROVIDER_CERT,
dwSignerType: u32,
psSigner: ?*CMSG_SIGNER_INFO,
dwError: u32,
csCounterSigners: u32,
pasCounterSigners: ?*CRYPT_PROVIDER_SGNR,
pChainContext: ?*CERT_CHAIN_CONTEXT,
};
pub const CRYPT_PROVIDER_CERT = extern struct {
cbStruct: u32,
pCert: ?*const CERT_CONTEXT,
fCommercial: BOOL,
fTrustedRoot: BOOL,
fSelfSigned: BOOL,
fTestCert: BOOL,
dwRevokedReason: u32,
dwConfidence: u32,
dwError: u32,
pTrustListContext: ?*CTL_CONTEXT,
fTrustListSignerCert: BOOL,
pCtlContext: ?*CTL_CONTEXT,
dwCtlError: u32,
fIsCyclic: BOOL,
pChainElement: ?*CERT_CHAIN_ELEMENT,
};
pub const CRYPT_PROVIDER_PRIVDATA = extern struct {
cbStruct: u32,
gProviderID: Guid,
cbProvData: u32,
pvProvData: ?*c_void,
};
pub const PROVDATA_SIP = extern struct {
cbStruct: u32,
gSubject: Guid,
pSip: ?*SIP_DISPATCH_INFO,
pCATSip: ?*SIP_DISPATCH_INFO,
psSipSubjectInfo: ?*SIP_SUBJECTINFO,
psSipCATSubjectInfo: ?*SIP_SUBJECTINFO,
psIndirectData: ?*SIP_INDIRECT_DATA,
};
pub const CRYPT_TRUST_REG_ENTRY = extern struct {
cbStruct: u32,
pwszDLLName: ?PWSTR,
pwszFunctionName: ?PWSTR,
};
pub const CRYPT_REGISTER_ACTIONID = extern struct {
cbStruct: u32,
sInitProvider: CRYPT_TRUST_REG_ENTRY,
sObjectProvider: CRYPT_TRUST_REG_ENTRY,
sSignatureProvider: CRYPT_TRUST_REG_ENTRY,
sCertificateProvider: CRYPT_TRUST_REG_ENTRY,
sCertificatePolicyProvider: CRYPT_TRUST_REG_ENTRY,
sFinalPolicyProvider: CRYPT_TRUST_REG_ENTRY,
sTestPolicyProvider: CRYPT_TRUST_REG_ENTRY,
sCleanupProvider: CRYPT_TRUST_REG_ENTRY,
};
pub const PFN_ALLOCANDFILLDEFUSAGE = fn(
pszUsageOID: ?[*:0]const u8,
psDefUsage: ?*CRYPT_PROVIDER_DEFUSAGE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const PFN_FREEDEFUSAGE = fn(
pszUsageOID: ?[*:0]const u8,
psDefUsage: ?*CRYPT_PROVIDER_DEFUSAGE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const CRYPT_PROVIDER_REGDEFUSAGE = extern struct {
cbStruct: u32,
pgActionID: ?*Guid,
pwszDllName: ?PWSTR,
pwszLoadCallbackDataFunctionName: ?PSTR,
pwszFreeCallbackDataFunctionName: ?PSTR,
};
pub const CRYPT_PROVIDER_DEFUSAGE = extern struct {
cbStruct: u32,
gActionID: Guid,
pDefPolicyCallbackData: ?*c_void,
pDefSIPClientData: ?*c_void,
};
pub const SPC_SERIALIZED_OBJECT = extern struct {
ClassId: [16]u8,
SerializedData: CRYPTOAPI_BLOB,
};
pub const SPC_SIGINFO = extern struct {
dwSipVersion: u32,
gSIPGuid: Guid,
dwReserved1: u32,
dwReserved2: u32,
dwReserved3: u32,
dwReserved4: u32,
dwReserved5: u32,
};
pub const SPC_LINK = extern struct {
dwLinkChoice: u32,
Anonymous: extern union {
pwszUrl: ?PWSTR,
Moniker: SPC_SERIALIZED_OBJECT,
pwszFile: ?PWSTR,
},
};
pub const SPC_PE_IMAGE_DATA = extern struct {
Flags: CRYPT_BIT_BLOB,
pFile: ?*SPC_LINK,
};
pub const SPC_INDIRECT_DATA_CONTENT = extern struct {
Data: CRYPT_ATTRIBUTE_TYPE_VALUE,
DigestAlgorithm: CRYPT_ALGORITHM_IDENTIFIER,
Digest: CRYPTOAPI_BLOB,
};
pub const SPC_FINANCIAL_CRITERIA = extern struct {
fFinancialInfoAvailable: BOOL,
fMeetsCriteria: BOOL,
};
pub const SPC_IMAGE = extern struct {
pImageLink: ?*SPC_LINK,
Bitmap: CRYPTOAPI_BLOB,
Metafile: CRYPTOAPI_BLOB,
EnhancedMetafile: CRYPTOAPI_BLOB,
GifFile: CRYPTOAPI_BLOB,
};
pub const SPC_SP_AGENCY_INFO = extern struct {
pPolicyInformation: ?*SPC_LINK,
pwszPolicyDisplayText: ?PWSTR,
pLogoImage: ?*SPC_IMAGE,
pLogoLink: ?*SPC_LINK,
};
pub const SPC_STATEMENT_TYPE = extern struct {
cKeyPurposeId: u32,
rgpszKeyPurposeId: ?*?PSTR,
};
pub const SPC_SP_OPUS_INFO = extern struct {
pwszProgramName: ?[*:0]const u16,
pMoreInfo: ?*SPC_LINK,
pPublisherInfo: ?*SPC_LINK,
};
pub const CAT_NAMEVALUE = extern struct {
pwszTag: ?PWSTR,
fdwFlags: u32,
Value: CRYPTOAPI_BLOB,
};
pub const CAT_MEMBERINFO = extern struct {
pwszSubjGuid: ?PWSTR,
dwCertVersion: u32,
};
pub const CAT_MEMBERINFO2 = extern struct {
SubjectGuid: Guid,
dwCertVersion: u32,
};
pub const INTENT_TO_SEAL_ATTRIBUTE = extern struct {
version: u32,
seal: BOOLEAN,
};
pub const SEALING_SIGNATURE_ATTRIBUTE = extern struct {
version: u32,
signerIndex: u32,
signatureAlgorithm: CRYPT_ALGORITHM_IDENTIFIER,
encryptedDigest: CRYPTOAPI_BLOB,
};
pub const SEALING_TIMESTAMP_ATTRIBUTE = extern struct {
version: u32,
signerIndex: u32,
sealTimeStampToken: CRYPTOAPI_BLOB,
};
pub const WIN_CERTIFICATE = extern struct {
dwLength: u32,
wRevision: u16,
wCertificateType: u16,
bCertificate: [1]u8,
};
pub const WIN_TRUST_ACTDATA_CONTEXT_WITH_SUBJECT = extern struct {
hClientToken: ?HANDLE,
SubjectType: ?*Guid,
Subject: ?*c_void,
};
pub const WIN_TRUST_ACTDATA_SUBJECT_ONLY = extern struct {
SubjectType: ?*Guid,
Subject: ?*c_void,
};
pub const WIN_TRUST_SUBJECT_FILE = extern struct {
hFile: ?HANDLE,
lpPath: ?[*:0]const u16,
};
pub const WIN_TRUST_SUBJECT_FILE_AND_DISPLAY = extern struct {
hFile: ?HANDLE,
lpPath: ?[*:0]const u16,
lpDisplayName: ?[*:0]const u16,
};
pub const WIN_SPUB_TRUSTED_PUBLISHER_DATA = extern struct {
hClientToken: ?HANDLE,
lpCertificate: ?*WIN_CERTIFICATE,
};
pub const SCESVC_CONFIGURATION_LINE = extern struct {
Key: ?*i8,
Value: ?*i8,
ValueLen: u32,
};
pub const SCESVC_CONFIGURATION_INFO = extern struct {
Count: u32,
Lines: ?*SCESVC_CONFIGURATION_LINE,
};
pub const SCESVC_INFO_TYPE = enum(i32) {
ConfigurationInfo = 0,
MergedPolicyInfo = 1,
AnalysisInfo = 2,
InternalUse = 3,
};
pub const SceSvcConfigurationInfo = SCESVC_INFO_TYPE.ConfigurationInfo;
pub const SceSvcMergedPolicyInfo = SCESVC_INFO_TYPE.MergedPolicyInfo;
pub const SceSvcAnalysisInfo = SCESVC_INFO_TYPE.AnalysisInfo;
pub const SceSvcInternalUse = SCESVC_INFO_TYPE.InternalUse;
pub const SCESVC_ANALYSIS_LINE = extern struct {
Key: ?*i8,
Value: ?*u8,
ValueLen: u32,
};
pub const SCESVC_ANALYSIS_INFO = extern struct {
Count: u32,
Lines: ?*SCESVC_ANALYSIS_LINE,
};
pub const PFSCE_QUERY_INFO = fn(
sceHandle: ?*c_void,
sceType: SCESVC_INFO_TYPE,
lpPrefix: ?*i8,
bExact: BOOL,
ppvInfo: ?*?*c_void,
psceEnumHandle: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
pub const PFSCE_SET_INFO = fn(
sceHandle: ?*c_void,
sceType: SCESVC_INFO_TYPE,
lpPrefix: ?*i8,
bExact: BOOL,
pvInfo: ?*c_void,
) callconv(@import("std").os.windows.WINAPI) u32;
pub const PFSCE_FREE_INFO = fn(
pvServiceInfo: ?*c_void,
) callconv(@import("std").os.windows.WINAPI) u32;
pub const PFSCE_LOG_INFO = fn(
ErrLevel: SCE_LOG_ERR_LEVEL,
Win32rc: u32,
pErrFmt: ?*i8,
) callconv(@import("std").os.windows.WINAPI) u32;
pub const SCESVC_CALLBACK_INFO = extern struct {
sceHandle: ?*c_void,
pfQueryInfo: ?PFSCE_QUERY_INFO,
pfSetInfo: ?PFSCE_SET_INFO,
pfFreeInfo: ?PFSCE_FREE_INFO,
pfLogInfo: ?PFSCE_LOG_INFO,
};
pub const PF_ConfigAnalyzeService = fn(
pSceCbInfo: ?*SCESVC_CALLBACK_INFO,
) callconv(@import("std").os.windows.WINAPI) u32;
pub const PF_UpdateService = fn(
pSceCbInfo: ?*SCESVC_CALLBACK_INFO,
ServiceInfo: ?*SCESVC_CONFIGURATION_INFO,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_ISceSvcAttachmentPersistInfo_Value = @import("zig.zig").Guid.initString("6d90e0d0-200d-11d1-affb-00c04fb984f9");
pub const IID_ISceSvcAttachmentPersistInfo = &IID_ISceSvcAttachmentPersistInfo_Value;
pub const ISceSvcAttachmentPersistInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Save: fn(
self: *const ISceSvcAttachmentPersistInfo,
lpTemplateName: ?*i8,
scesvcHandle: ?*?*c_void,
ppvData: ?*?*c_void,
pbOverwriteAll: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
IsDirty: fn(
self: *const ISceSvcAttachmentPersistInfo,
lpTemplateName: ?*i8,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
FreeBuffer: fn(
self: *const ISceSvcAttachmentPersistInfo,
pvData: ?*c_void,
) 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 ISceSvcAttachmentPersistInfo_Save(self: *const T, lpTemplateName: ?*i8, scesvcHandle: ?*?*c_void, ppvData: ?*?*c_void, pbOverwriteAll: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const ISceSvcAttachmentPersistInfo.VTable, self.vtable).Save(@ptrCast(*const ISceSvcAttachmentPersistInfo, self), lpTemplateName, scesvcHandle, ppvData, pbOverwriteAll);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISceSvcAttachmentPersistInfo_IsDirty(self: *const T, lpTemplateName: ?*i8) callconv(.Inline) HRESULT {
return @ptrCast(*const ISceSvcAttachmentPersistInfo.VTable, self.vtable).IsDirty(@ptrCast(*const ISceSvcAttachmentPersistInfo, self), lpTemplateName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISceSvcAttachmentPersistInfo_FreeBuffer(self: *const T, pvData: ?*c_void) callconv(.Inline) HRESULT {
return @ptrCast(*const ISceSvcAttachmentPersistInfo.VTable, self.vtable).FreeBuffer(@ptrCast(*const ISceSvcAttachmentPersistInfo, self), pvData);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_ISceSvcAttachmentData_Value = @import("zig.zig").Guid.initString("17c35fde-200d-11d1-affb-00c04fb984f9");
pub const IID_ISceSvcAttachmentData = &IID_ISceSvcAttachmentData_Value;
pub const ISceSvcAttachmentData = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetData: fn(
self: *const ISceSvcAttachmentData,
scesvcHandle: ?*c_void,
sceType: SCESVC_INFO_TYPE,
ppvData: ?*?*c_void,
psceEnumHandle: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Initialize: fn(
self: *const ISceSvcAttachmentData,
lpServiceName: ?*i8,
lpTemplateName: ?*i8,
lpSceSvcPersistInfo: ?*ISceSvcAttachmentPersistInfo,
pscesvcHandle: ?*?*c_void,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
FreeBuffer: fn(
self: *const ISceSvcAttachmentData,
pvData: ?*c_void,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CloseHandle: fn(
self: *const ISceSvcAttachmentData,
scesvcHandle: ?*c_void,
) 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 ISceSvcAttachmentData_GetData(self: *const T, scesvcHandle: ?*c_void, sceType: SCESVC_INFO_TYPE, ppvData: ?*?*c_void, psceEnumHandle: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const ISceSvcAttachmentData.VTable, self.vtable).GetData(@ptrCast(*const ISceSvcAttachmentData, self), scesvcHandle, sceType, ppvData, psceEnumHandle);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISceSvcAttachmentData_Initialize(self: *const T, lpServiceName: ?*i8, lpTemplateName: ?*i8, lpSceSvcPersistInfo: ?*ISceSvcAttachmentPersistInfo, pscesvcHandle: ?*?*c_void) callconv(.Inline) HRESULT {
return @ptrCast(*const ISceSvcAttachmentData.VTable, self.vtable).Initialize(@ptrCast(*const ISceSvcAttachmentData, self), lpServiceName, lpTemplateName, lpSceSvcPersistInfo, pscesvcHandle);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISceSvcAttachmentData_FreeBuffer(self: *const T, pvData: ?*c_void) callconv(.Inline) HRESULT {
return @ptrCast(*const ISceSvcAttachmentData.VTable, self.vtable).FreeBuffer(@ptrCast(*const ISceSvcAttachmentData, self), pvData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn ISceSvcAttachmentData_CloseHandle(self: *const T, scesvcHandle: ?*c_void) callconv(.Inline) HRESULT {
return @ptrCast(*const ISceSvcAttachmentData.VTable, self.vtable).CloseHandle(@ptrCast(*const ISceSvcAttachmentData, self), scesvcHandle);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const SAFER_CODE_PROPERTIES_V1 = extern struct {
cbSize: u32,
dwCheckFlags: u32,
ImagePath: ?[*:0]const u16,
hImageFileHandle: ?HANDLE,
UrlZoneId: u32,
ImageHash: [64]u8,
dwImageHashSize: u32,
ImageSize: LARGE_INTEGER,
HashAlgorithm: u32,
pByteBlock: ?*u8,
hWndParent: ?HWND,
dwWVTUIChoice: u32,
};
pub const SAFER_CODE_PROPERTIES_V2 = extern struct {
cbSize: u32,
dwCheckFlags: u32,
ImagePath: ?[*:0]const u16,
hImageFileHandle: ?HANDLE,
UrlZoneId: u32,
ImageHash: [64]u8,
dwImageHashSize: u32,
ImageSize: LARGE_INTEGER,
HashAlgorithm: u32,
pByteBlock: ?*u8,
hWndParent: ?HWND,
dwWVTUIChoice: u32,
PackageMoniker: ?[*:0]const u16,
PackagePublisher: ?[*:0]const u16,
PackageName: ?[*:0]const u16,
PackageVersion: u64,
PackageIsFramework: BOOL,
};
pub const SAFER_POLICY_INFO_CLASS = enum(i32) {
LevelList = 1,
EnableTransparentEnforcement = 2,
DefaultLevel = 3,
EvaluateUserScope = 4,
ScopeFlags = 5,
DefaultLevelFlags = 6,
AuthenticodeEnabled = 7,
};
pub const SaferPolicyLevelList = SAFER_POLICY_INFO_CLASS.LevelList;
pub const SaferPolicyEnableTransparentEnforcement = SAFER_POLICY_INFO_CLASS.EnableTransparentEnforcement;
pub const SaferPolicyDefaultLevel = SAFER_POLICY_INFO_CLASS.DefaultLevel;
pub const SaferPolicyEvaluateUserScope = SAFER_POLICY_INFO_CLASS.EvaluateUserScope;
pub const SaferPolicyScopeFlags = SAFER_POLICY_INFO_CLASS.ScopeFlags;
pub const SaferPolicyDefaultLevelFlags = SAFER_POLICY_INFO_CLASS.DefaultLevelFlags;
pub const SaferPolicyAuthenticodeEnabled = SAFER_POLICY_INFO_CLASS.AuthenticodeEnabled;
pub const SAFER_OBJECT_INFO_CLASS = enum(i32) {
LevelId = 1,
ScopeId = 2,
FriendlyName = 3,
Description = 4,
Builtin = 5,
Disallowed = 6,
DisableMaxPrivilege = 7,
InvertDeletedPrivileges = 8,
DeletedPrivileges = 9,
DefaultOwner = 10,
SidsToDisable = 11,
RestrictedSidsInverted = 12,
RestrictedSidsAdded = 13,
AllIdentificationGuids = 14,
SingleIdentification = 15,
ExtendedError = 16,
};
pub const SaferObjectLevelId = SAFER_OBJECT_INFO_CLASS.LevelId;
pub const SaferObjectScopeId = SAFER_OBJECT_INFO_CLASS.ScopeId;
pub const SaferObjectFriendlyName = SAFER_OBJECT_INFO_CLASS.FriendlyName;
pub const SaferObjectDescription = SAFER_OBJECT_INFO_CLASS.Description;
pub const SaferObjectBuiltin = SAFER_OBJECT_INFO_CLASS.Builtin;
pub const SaferObjectDisallowed = SAFER_OBJECT_INFO_CLASS.Disallowed;
pub const SaferObjectDisableMaxPrivilege = SAFER_OBJECT_INFO_CLASS.DisableMaxPrivilege;
pub const SaferObjectInvertDeletedPrivileges = SAFER_OBJECT_INFO_CLASS.InvertDeletedPrivileges;
pub const SaferObjectDeletedPrivileges = SAFER_OBJECT_INFO_CLASS.DeletedPrivileges;
pub const SaferObjectDefaultOwner = SAFER_OBJECT_INFO_CLASS.DefaultOwner;
pub const SaferObjectSidsToDisable = SAFER_OBJECT_INFO_CLASS.SidsToDisable;
pub const SaferObjectRestrictedSidsInverted = SAFER_OBJECT_INFO_CLASS.RestrictedSidsInverted;
pub const SaferObjectRestrictedSidsAdded = SAFER_OBJECT_INFO_CLASS.RestrictedSidsAdded;
pub const SaferObjectAllIdentificationGuids = SAFER_OBJECT_INFO_CLASS.AllIdentificationGuids;
pub const SaferObjectSingleIdentification = SAFER_OBJECT_INFO_CLASS.SingleIdentification;
pub const SaferObjectExtendedError = SAFER_OBJECT_INFO_CLASS.ExtendedError;
pub const SAFER_IDENTIFICATION_TYPES = enum(i32) {
Default = 0,
TypeImageName = 1,
TypeImageHash = 2,
TypeUrlZone = 3,
TypeCertificate = 4,
};
pub const SaferIdentityDefault = SAFER_IDENTIFICATION_TYPES.Default;
pub const SaferIdentityTypeImageName = SAFER_IDENTIFICATION_TYPES.TypeImageName;
pub const SaferIdentityTypeImageHash = SAFER_IDENTIFICATION_TYPES.TypeImageHash;
pub const SaferIdentityTypeUrlZone = SAFER_IDENTIFICATION_TYPES.TypeUrlZone;
pub const SaferIdentityTypeCertificate = SAFER_IDENTIFICATION_TYPES.TypeCertificate;
pub const SAFER_IDENTIFICATION_HEADER = extern struct {
dwIdentificationType: SAFER_IDENTIFICATION_TYPES,
cbStructSize: u32,
IdentificationGuid: Guid,
lastModified: FILETIME,
};
pub const SAFER_PATHNAME_IDENTIFICATION = extern struct {
header: SAFER_IDENTIFICATION_HEADER,
Description: [256]u16,
ImageName: ?[*]u16,
dwSaferFlags: u32,
};
pub const SAFER_HASH_IDENTIFICATION = extern struct {
header: SAFER_IDENTIFICATION_HEADER,
Description: [256]u16,
FriendlyName: [256]u16,
HashSize: u32,
ImageHash: [64]u8,
HashAlgorithm: u32,
ImageSize: LARGE_INTEGER,
dwSaferFlags: u32,
};
pub const SAFER_HASH_IDENTIFICATION2 = extern struct {
hashIdentification: SAFER_HASH_IDENTIFICATION,
HashSize: u32,
ImageHash: [64]u8,
HashAlgorithm: u32,
};
pub const SAFER_URLZONE_IDENTIFICATION = extern struct {
header: SAFER_IDENTIFICATION_HEADER,
UrlZoneId: u32,
dwSaferFlags: u32,
};
pub const DdqAccessLevel = enum(i32) {
NoData = 0,
CurrentUserData = 1,
AllUserData = 2,
};
pub const NoData = DdqAccessLevel.NoData;
pub const CurrentUserData = DdqAccessLevel.CurrentUserData;
pub const AllUserData = DdqAccessLevel.AllUserData;
pub const DIAGNOSTIC_DATA_RECORD = extern struct {
rowId: i64,
timestamp: u64,
eventKeywords: u64,
fullEventName: ?PWSTR,
providerGroupGuid: ?PWSTR,
producerName: ?PWSTR,
privacyTags: ?*i32,
privacyTagCount: u32,
categoryIds: ?*i32,
categoryIdCount: u32,
isCoreData: BOOL,
extra1: ?PWSTR,
extra2: ?PWSTR,
extra3: ?PWSTR,
};
pub const DIAGNOSTIC_DATA_SEARCH_CRITERIA = extern struct {
producerNames: ?*?PWSTR,
producerNameCount: u32,
textToMatch: ?[*:0]const u16,
categoryIds: ?*const i32,
categoryIdCount: u32,
privacyTags: ?*const i32,
privacyTagCount: u32,
coreDataOnly: BOOL,
};
pub const DIAGNOSTIC_DATA_EVENT_TAG_DESCRIPTION = extern struct {
privacyTag: i32,
name: ?PWSTR,
description: ?PWSTR,
};
pub const DIAGNOSTIC_DATA_EVENT_PRODUCER_DESCRIPTION = extern struct {
name: ?PWSTR,
};
pub const DIAGNOSTIC_DATA_EVENT_CATEGORY_DESCRIPTION = extern struct {
id: i32,
name: ?PWSTR,
};
pub const DIAGNOSTIC_DATA_EVENT_TAG_STATS = extern struct {
privacyTag: i32,
eventCount: u32,
};
pub const DIAGNOSTIC_DATA_EVENT_BINARY_STATS = extern struct {
moduleName: ?PWSTR,
friendlyModuleName: ?PWSTR,
eventCount: u32,
uploadSizeBytes: u64,
};
pub const DIAGNOSTIC_DATA_GENERAL_STATS = extern struct {
optInLevel: u32,
transcriptSizeBytes: u64,
oldestEventTimestamp: u64,
totalEventCountLast24Hours: u32,
averageDailyEvents: f32,
};
pub const DIAGNOSTIC_DATA_EVENT_TRANSCRIPT_CONFIGURATION = extern struct {
hoursOfHistoryToKeep: u32,
maxStoreMegabytes: u32,
requestedMaxStoreMegabytes: u32,
};
pub const DIAGNOSTIC_REPORT_PARAMETER = extern struct {
name: [129]u16,
value: [260]u16,
};
pub const DIAGNOSTIC_REPORT_SIGNATURE = extern struct {
eventName: [65]u16,
parameters: [10]DIAGNOSTIC_REPORT_PARAMETER,
};
pub const DIAGNOSTIC_REPORT_DATA = extern struct {
signature: DIAGNOSTIC_REPORT_SIGNATURE,
bucketId: Guid,
reportId: Guid,
creationTime: FILETIME,
sizeInBytes: u64,
cabId: ?PWSTR,
reportStatus: u32,
reportIntegratorId: Guid,
fileNames: ?*?PWSTR,
fileCount: u32,
friendlyEventName: ?PWSTR,
applicationName: ?PWSTR,
applicationPath: ?PWSTR,
description: ?PWSTR,
bucketIdString: ?PWSTR,
legacyBucketId: u64,
reportKey: ?PWSTR,
};
//--------------------------------------------------------------------------------
// Section: Functions (250)
//--------------------------------------------------------------------------------
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "USER32" fn SetUserObjectSecurity(
hObj: ?HANDLE,
pSIRequested: ?*OBJECT_SECURITY_INFORMATION,
pSID: ?*SECURITY_DESCRIPTOR,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "USER32" fn GetUserObjectSecurity(
hObj: ?HANDLE,
pSIRequested: ?*u32,
// TODO: what to do with BytesParamIndex 3?
pSID: ?*SECURITY_DESCRIPTOR,
nLength: u32,
lpnLengthNeeded: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AccessCheck(
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
ClientToken: ?HANDLE,
DesiredAccess: u32,
GenericMapping: ?*GENERIC_MAPPING,
// TODO: what to do with BytesParamIndex 5?
PrivilegeSet: ?*PRIVILEGE_SET,
PrivilegeSetLength: ?*u32,
GrantedAccess: ?*u32,
AccessStatus: ?*i32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "ADVAPI32" fn AccessCheckAndAuditAlarmW(
SubsystemName: ?[*:0]const u16,
HandleId: ?*c_void,
ObjectTypeName: ?PWSTR,
ObjectName: ?PWSTR,
SecurityDescriptor: ?*SECURITY_DESCRIPTOR,
DesiredAccess: u32,
GenericMapping: ?*GENERIC_MAPPING,
ObjectCreation: BOOL,
GrantedAccess: ?*u32,
AccessStatus: ?*i32,
pfGenerateOnClose: ?*i32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AccessCheckByType(
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
PrincipalSelfSid: ?PSID,
ClientToken: ?HANDLE,
DesiredAccess: u32,
ObjectTypeList: ?[*]OBJECT_TYPE_LIST,
ObjectTypeListLength: u32,
GenericMapping: ?*GENERIC_MAPPING,
// TODO: what to do with BytesParamIndex 8?
PrivilegeSet: ?*PRIVILEGE_SET,
PrivilegeSetLength: ?*u32,
GrantedAccess: ?*u32,
AccessStatus: ?*i32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AccessCheckByTypeResultList(
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
PrincipalSelfSid: ?PSID,
ClientToken: ?HANDLE,
DesiredAccess: u32,
ObjectTypeList: ?[*]OBJECT_TYPE_LIST,
ObjectTypeListLength: u32,
GenericMapping: ?*GENERIC_MAPPING,
// TODO: what to do with BytesParamIndex 8?
PrivilegeSet: ?*PRIVILEGE_SET,
PrivilegeSetLength: ?*u32,
GrantedAccessList: [*]u32,
AccessStatusList: [*]u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "ADVAPI32" fn AccessCheckByTypeAndAuditAlarmW(
SubsystemName: ?[*:0]const u16,
HandleId: ?*c_void,
ObjectTypeName: ?[*:0]const u16,
ObjectName: ?[*:0]const u16,
SecurityDescriptor: ?*SECURITY_DESCRIPTOR,
PrincipalSelfSid: ?PSID,
DesiredAccess: u32,
AuditType: AUDIT_EVENT_TYPE,
Flags: u32,
ObjectTypeList: ?[*]OBJECT_TYPE_LIST,
ObjectTypeListLength: u32,
GenericMapping: ?*GENERIC_MAPPING,
ObjectCreation: BOOL,
GrantedAccess: ?*u32,
AccessStatus: ?*i32,
pfGenerateOnClose: ?*i32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "ADVAPI32" fn AccessCheckByTypeResultListAndAuditAlarmW(
SubsystemName: ?[*:0]const u16,
HandleId: ?*c_void,
ObjectTypeName: ?[*:0]const u16,
ObjectName: ?[*:0]const u16,
SecurityDescriptor: ?*SECURITY_DESCRIPTOR,
PrincipalSelfSid: ?PSID,
DesiredAccess: u32,
AuditType: AUDIT_EVENT_TYPE,
Flags: u32,
ObjectTypeList: ?[*]OBJECT_TYPE_LIST,
ObjectTypeListLength: u32,
GenericMapping: ?*GENERIC_MAPPING,
ObjectCreation: BOOL,
GrantedAccessList: [*]u32,
AccessStatusList: [*]u32,
pfGenerateOnClose: ?*i32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "ADVAPI32" fn AccessCheckByTypeResultListAndAuditAlarmByHandleW(
SubsystemName: ?[*:0]const u16,
HandleId: ?*c_void,
ClientToken: ?HANDLE,
ObjectTypeName: ?[*:0]const u16,
ObjectName: ?[*:0]const u16,
SecurityDescriptor: ?*SECURITY_DESCRIPTOR,
PrincipalSelfSid: ?PSID,
DesiredAccess: u32,
AuditType: AUDIT_EVENT_TYPE,
Flags: u32,
ObjectTypeList: ?[*]OBJECT_TYPE_LIST,
ObjectTypeListLength: u32,
GenericMapping: ?*GENERIC_MAPPING,
ObjectCreation: BOOL,
GrantedAccessList: [*]u32,
AccessStatusList: [*]u32,
pfGenerateOnClose: ?*i32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AddAccessAllowedAce(
pAcl: ?*ACL,
dwAceRevision: u32,
AccessMask: u32,
pSid: ?PSID,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AddAccessAllowedAceEx(
pAcl: ?*ACL,
dwAceRevision: u32,
AceFlags: ACE_FLAGS,
AccessMask: u32,
pSid: ?PSID,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AddAccessAllowedObjectAce(
pAcl: ?*ACL,
dwAceRevision: u32,
AceFlags: ACE_FLAGS,
AccessMask: u32,
ObjectTypeGuid: ?*Guid,
InheritedObjectTypeGuid: ?*Guid,
pSid: ?PSID,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AddAccessDeniedAce(
pAcl: ?*ACL,
dwAceRevision: u32,
AccessMask: u32,
pSid: ?PSID,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AddAccessDeniedAceEx(
pAcl: ?*ACL,
dwAceRevision: u32,
AceFlags: ACE_FLAGS,
AccessMask: u32,
pSid: ?PSID,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AddAccessDeniedObjectAce(
pAcl: ?*ACL,
dwAceRevision: u32,
AceFlags: ACE_FLAGS,
AccessMask: u32,
ObjectTypeGuid: ?*Guid,
InheritedObjectTypeGuid: ?*Guid,
pSid: ?PSID,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AddAce(
pAcl: ?*ACL,
dwAceRevision: u32,
dwStartingAceIndex: u32,
// TODO: what to do with BytesParamIndex 4?
pAceList: ?*c_void,
nAceListLength: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AddAuditAccessAce(
pAcl: ?*ACL,
dwAceRevision: u32,
dwAccessMask: u32,
pSid: ?PSID,
bAuditSuccess: BOOL,
bAuditFailure: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AddAuditAccessAceEx(
pAcl: ?*ACL,
dwAceRevision: u32,
AceFlags: ACE_FLAGS,
dwAccessMask: u32,
pSid: ?PSID,
bAuditSuccess: BOOL,
bAuditFailure: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AddAuditAccessObjectAce(
pAcl: ?*ACL,
dwAceRevision: u32,
AceFlags: ACE_FLAGS,
AccessMask: u32,
ObjectTypeGuid: ?*Guid,
InheritedObjectTypeGuid: ?*Guid,
pSid: ?PSID,
bAuditSuccess: BOOL,
bAuditFailure: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "ADVAPI32" fn AddMandatoryAce(
pAcl: ?*ACL,
dwAceRevision: ACE_REVISION,
AceFlags: ACE_FLAGS,
MandatoryPolicy: u32,
pLabelSid: ?PSID,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "KERNEL32" fn AddResourceAttributeAce(
pAcl: ?*ACL,
dwAceRevision: u32,
AceFlags: ACE_FLAGS,
AccessMask: u32,
pSid: ?PSID,
pAttributeInfo: ?*CLAIM_SECURITY_ATTRIBUTES_INFORMATION,
pReturnLength: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "KERNEL32" fn AddScopedPolicyIDAce(
pAcl: ?*ACL,
dwAceRevision: u32,
AceFlags: ACE_FLAGS,
AccessMask: u32,
pSid: ?PSID,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AdjustTokenGroups(
TokenHandle: ?HANDLE,
ResetToDefault: BOOL,
NewState: ?*TOKEN_GROUPS,
BufferLength: u32,
// TODO: what to do with BytesParamIndex 3?
PreviousState: ?*TOKEN_GROUPS,
ReturnLength: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AdjustTokenPrivileges(
TokenHandle: ?HANDLE,
DisableAllPrivileges: BOOL,
NewState: ?*TOKEN_PRIVILEGES,
BufferLength: u32,
// TODO: what to do with BytesParamIndex 3?
PreviousState: ?*TOKEN_PRIVILEGES,
ReturnLength: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AllocateAndInitializeSid(
pIdentifierAuthority: ?*SID_IDENTIFIER_AUTHORITY,
nSubAuthorityCount: u8,
nSubAuthority0: u32,
nSubAuthority1: u32,
nSubAuthority2: u32,
nSubAuthority3: u32,
nSubAuthority4: u32,
nSubAuthority5: u32,
nSubAuthority6: u32,
nSubAuthority7: u32,
pSid: ?*?PSID,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AllocateLocallyUniqueId(
Luid: ?*LUID,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AreAllAccessesGranted(
GrantedAccess: u32,
DesiredAccess: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AreAnyAccessesGranted(
GrantedAccess: u32,
DesiredAccess: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn CheckTokenMembership(
TokenHandle: ?HANDLE,
SidToCheck: ?PSID,
IsMember: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "KERNEL32" fn CheckTokenCapability(
TokenHandle: ?HANDLE,
CapabilitySidToCheck: ?PSID,
HasCapability: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "KERNEL32" fn GetAppContainerAce(
Acl: ?*ACL,
StartingAceIndex: u32,
AppContainerAce: ?*?*c_void,
AppContainerAceIndex: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "KERNEL32" fn CheckTokenMembershipEx(
TokenHandle: ?HANDLE,
SidToCheck: ?PSID,
Flags: u32,
IsMember: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn ConvertToAutoInheritPrivateObjectSecurity(
ParentDescriptor: ?*SECURITY_DESCRIPTOR,
CurrentSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
NewSecurityDescriptor: ?*?*SECURITY_DESCRIPTOR,
ObjectType: ?*Guid,
IsDirectoryObject: BOOLEAN,
GenericMapping: ?*GENERIC_MAPPING,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn CopySid(
nDestinationSidLength: u32,
// TODO: what to do with BytesParamIndex 0?
pDestinationSid: ?PSID,
pSourceSid: ?PSID,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn CreatePrivateObjectSecurity(
ParentDescriptor: ?*SECURITY_DESCRIPTOR,
CreatorDescriptor: ?*SECURITY_DESCRIPTOR,
NewDescriptor: ?*?*SECURITY_DESCRIPTOR,
IsDirectoryObject: BOOL,
Token: ?HANDLE,
GenericMapping: ?*GENERIC_MAPPING,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn CreatePrivateObjectSecurityEx(
ParentDescriptor: ?*SECURITY_DESCRIPTOR,
CreatorDescriptor: ?*SECURITY_DESCRIPTOR,
NewDescriptor: ?*?*SECURITY_DESCRIPTOR,
ObjectType: ?*Guid,
IsContainerObject: BOOL,
AutoInheritFlags: SECURITY_AUTO_INHERIT_FLAGS,
Token: ?HANDLE,
GenericMapping: ?*GENERIC_MAPPING,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn CreatePrivateObjectSecurityWithMultipleInheritance(
ParentDescriptor: ?*SECURITY_DESCRIPTOR,
CreatorDescriptor: ?*SECURITY_DESCRIPTOR,
NewDescriptor: ?*?*SECURITY_DESCRIPTOR,
ObjectTypes: ?[*]?*Guid,
GuidCount: u32,
IsContainerObject: BOOL,
AutoInheritFlags: SECURITY_AUTO_INHERIT_FLAGS,
Token: ?HANDLE,
GenericMapping: ?*GENERIC_MAPPING,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn CreateRestrictedToken(
ExistingTokenHandle: ?HANDLE,
Flags: CREATE_RESTRICTED_TOKEN_FLAGS,
DisableSidCount: u32,
SidsToDisable: ?[*]SID_AND_ATTRIBUTES,
DeletePrivilegeCount: u32,
PrivilegesToDelete: ?[*]LUID_AND_ATTRIBUTES,
RestrictedSidCount: u32,
SidsToRestrict: ?[*]SID_AND_ATTRIBUTES,
NewTokenHandle: ?*?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn CreateWellKnownSid(
WellKnownSidType: WELL_KNOWN_SID_TYPE,
DomainSid: ?PSID,
// TODO: what to do with BytesParamIndex 3?
pSid: ?PSID,
cbSid: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn EqualDomainSid(
pSid1: ?PSID,
pSid2: ?PSID,
pfEqual: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn DeleteAce(
pAcl: ?*ACL,
dwAceIndex: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn DestroyPrivateObjectSecurity(
ObjectDescriptor: ?*?*SECURITY_DESCRIPTOR,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn DuplicateToken(
ExistingTokenHandle: ?HANDLE,
ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL,
DuplicateTokenHandle: ?*?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn DuplicateTokenEx(
hExistingToken: ?HANDLE,
dwDesiredAccess: TOKEN_ACCESS_MASK,
lpTokenAttributes: ?*SECURITY_ATTRIBUTES,
ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL,
TokenType: TOKEN_TYPE,
phNewToken: ?*?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn EqualPrefixSid(
pSid1: ?PSID,
pSid2: ?PSID,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn EqualSid(
pSid1: ?PSID,
pSid2: ?PSID,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn FindFirstFreeAce(
pAcl: ?*ACL,
pAce: ?*?*c_void,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn FreeSid(
pSid: ?PSID,
) callconv(@import("std").os.windows.WINAPI) ?*c_void;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn GetAce(
pAcl: ?*ACL,
dwAceIndex: u32,
pAce: ?*?*c_void,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn GetAclInformation(
pAcl: ?*ACL,
// TODO: what to do with BytesParamIndex 2?
pAclInformation: ?*c_void,
nAclInformationLength: u32,
dwAclInformationClass: ACL_INFORMATION_CLASS,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "ADVAPI32" fn GetFileSecurityW(
lpFileName: ?[*:0]const u16,
RequestedInformation: u32,
// TODO: what to do with BytesParamIndex 3?
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
nLength: u32,
lpnLengthNeeded: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn GetKernelObjectSecurity(
Handle: ?HANDLE,
RequestedInformation: u32,
// TODO: what to do with BytesParamIndex 3?
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
nLength: u32,
lpnLengthNeeded: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn GetLengthSid(
pSid: ?PSID,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn GetPrivateObjectSecurity(
ObjectDescriptor: ?*SECURITY_DESCRIPTOR,
SecurityInformation: u32,
// TODO: what to do with BytesParamIndex 3?
ResultantDescriptor: ?*SECURITY_DESCRIPTOR,
DescriptorLength: u32,
ReturnLength: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn GetSecurityDescriptorControl(
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
pControl: ?*u16,
lpdwRevision: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn GetSecurityDescriptorDacl(
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
lpbDaclPresent: ?*i32,
pDacl: ?*?*ACL,
lpbDaclDefaulted: ?*i32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn GetSecurityDescriptorGroup(
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
pGroup: ?*?PSID,
lpbGroupDefaulted: ?*i32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn GetSecurityDescriptorLength(
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn GetSecurityDescriptorOwner(
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
pOwner: ?*?PSID,
lpbOwnerDefaulted: ?*i32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn GetSecurityDescriptorRMControl(
SecurityDescriptor: ?*SECURITY_DESCRIPTOR,
RMControl: ?*u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn GetSecurityDescriptorSacl(
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
lpbSaclPresent: ?*i32,
pSacl: ?*?*ACL,
lpbSaclDefaulted: ?*i32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn GetSidIdentifierAuthority(
pSid: ?PSID,
) callconv(@import("std").os.windows.WINAPI) ?*SID_IDENTIFIER_AUTHORITY;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn GetSidLengthRequired(
nSubAuthorityCount: u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn GetSidSubAuthority(
pSid: ?PSID,
nSubAuthority: u32,
) callconv(@import("std").os.windows.WINAPI) ?*u32;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn GetSidSubAuthorityCount(
pSid: ?PSID,
) callconv(@import("std").os.windows.WINAPI) ?*u8;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn GetTokenInformation(
TokenHandle: ?HANDLE,
TokenInformationClass: TOKEN_INFORMATION_CLASS,
// TODO: what to do with BytesParamIndex 3?
TokenInformation: ?*c_void,
TokenInformationLength: u32,
ReturnLength: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn GetWindowsAccountDomainSid(
pSid: ?PSID,
// TODO: what to do with BytesParamIndex 2?
pDomainSid: ?PSID,
cbDomainSid: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn ImpersonateAnonymousToken(
ThreadHandle: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn ImpersonateLoggedOnUser(
hToken: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn ImpersonateSelf(
ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn InitializeAcl(
// TODO: what to do with BytesParamIndex 1?
pAcl: ?*ACL,
nAclLength: u32,
dwAclRevision: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn InitializeSecurityDescriptor(
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
dwRevision: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn InitializeSid(
Sid: ?PSID,
pIdentifierAuthority: ?*SID_IDENTIFIER_AUTHORITY,
nSubAuthorityCount: u8,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn IsTokenRestricted(
TokenHandle: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn IsValidAcl(
pAcl: ?*ACL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn IsValidSecurityDescriptor(
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn IsValidSid(
pSid: ?PSID,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn IsWellKnownSid(
pSid: ?PSID,
WellKnownSidType: WELL_KNOWN_SID_TYPE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn MakeAbsoluteSD(
pSelfRelativeSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
// TODO: what to do with BytesParamIndex 2?
pAbsoluteSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
lpdwAbsoluteSecurityDescriptorSize: ?*u32,
// TODO: what to do with BytesParamIndex 4?
pDacl: ?*ACL,
lpdwDaclSize: ?*u32,
// TODO: what to do with BytesParamIndex 6?
pSacl: ?*ACL,
lpdwSaclSize: ?*u32,
// TODO: what to do with BytesParamIndex 8?
pOwner: ?PSID,
lpdwOwnerSize: ?*u32,
// TODO: what to do with BytesParamIndex 10?
pPrimaryGroup: ?PSID,
lpdwPrimaryGroupSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn MakeSelfRelativeSD(
pAbsoluteSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
// TODO: what to do with BytesParamIndex 2?
pSelfRelativeSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
lpdwBufferLength: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn MapGenericMask(
AccessMask: ?*u32,
GenericMapping: ?*GENERIC_MAPPING,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "ADVAPI32" fn ObjectCloseAuditAlarmW(
SubsystemName: ?[*:0]const u16,
HandleId: ?*c_void,
GenerateOnClose: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "ADVAPI32" fn ObjectDeleteAuditAlarmW(
SubsystemName: ?[*:0]const u16,
HandleId: ?*c_void,
GenerateOnClose: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "ADVAPI32" fn ObjectOpenAuditAlarmW(
SubsystemName: ?[*:0]const u16,
HandleId: ?*c_void,
ObjectTypeName: ?PWSTR,
ObjectName: ?PWSTR,
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
ClientToken: ?HANDLE,
DesiredAccess: u32,
GrantedAccess: u32,
Privileges: ?*PRIVILEGE_SET,
ObjectCreation: BOOL,
AccessGranted: BOOL,
GenerateOnClose: ?*i32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "ADVAPI32" fn ObjectPrivilegeAuditAlarmW(
SubsystemName: ?[*:0]const u16,
HandleId: ?*c_void,
ClientToken: ?HANDLE,
DesiredAccess: u32,
Privileges: ?*PRIVILEGE_SET,
AccessGranted: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn PrivilegeCheck(
ClientToken: ?HANDLE,
RequiredPrivileges: ?*PRIVILEGE_SET,
pfResult: ?*i32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "ADVAPI32" fn PrivilegedServiceAuditAlarmW(
SubsystemName: ?[*:0]const u16,
ServiceName: ?[*:0]const u16,
ClientToken: ?HANDLE,
Privileges: ?*PRIVILEGE_SET,
AccessGranted: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "ADVAPI32" fn QuerySecurityAccessMask(
SecurityInformation: u32,
DesiredAccess: ?*u32,
) callconv(@import("std").os.windows.WINAPI) void;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn RevertToSelf(
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SetAclInformation(
pAcl: ?*ACL,
// TODO: what to do with BytesParamIndex 2?
pAclInformation: ?*c_void,
nAclInformationLength: u32,
dwAclInformationClass: ACL_INFORMATION_CLASS,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "ADVAPI32" fn SetFileSecurityW(
lpFileName: ?[*:0]const u16,
SecurityInformation: u32,
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SetKernelObjectSecurity(
Handle: ?HANDLE,
SecurityInformation: u32,
SecurityDescriptor: ?*SECURITY_DESCRIPTOR,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SetPrivateObjectSecurity(
SecurityInformation: u32,
ModificationDescriptor: ?*SECURITY_DESCRIPTOR,
ObjectsSecurityDescriptor: ?*?*SECURITY_DESCRIPTOR,
GenericMapping: ?*GENERIC_MAPPING,
Token: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SetPrivateObjectSecurityEx(
SecurityInformation: u32,
ModificationDescriptor: ?*SECURITY_DESCRIPTOR,
ObjectsSecurityDescriptor: ?*?*SECURITY_DESCRIPTOR,
AutoInheritFlags: SECURITY_AUTO_INHERIT_FLAGS,
GenericMapping: ?*GENERIC_MAPPING,
Token: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "ADVAPI32" fn SetSecurityAccessMask(
SecurityInformation: u32,
DesiredAccess: ?*u32,
) callconv(@import("std").os.windows.WINAPI) void;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SetSecurityDescriptorControl(
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
ControlBitsOfInterest: u16,
ControlBitsToSet: u16,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SetSecurityDescriptorDacl(
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
bDaclPresent: BOOL,
pDacl: ?*ACL,
bDaclDefaulted: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SetSecurityDescriptorGroup(
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
pGroup: ?PSID,
bGroupDefaulted: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SetSecurityDescriptorOwner(
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
pOwner: ?PSID,
bOwnerDefaulted: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SetSecurityDescriptorRMControl(
SecurityDescriptor: ?*SECURITY_DESCRIPTOR,
RMControl: ?*u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SetSecurityDescriptorSacl(
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
bSaclPresent: BOOL,
pSacl: ?*ACL,
bSaclDefaulted: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SetTokenInformation(
TokenHandle: ?HANDLE,
TokenInformationClass: TOKEN_INFORMATION_CLASS,
// TODO: what to do with BytesParamIndex 3?
TokenInformation: ?*c_void,
TokenInformationLength: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "KERNEL32" fn SetCachedSigningLevel(
SourceFiles: [*]?HANDLE,
SourceFileCount: u32,
Flags: u32,
TargetFile: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "KERNEL32" fn GetCachedSigningLevel(
File: ?HANDLE,
Flags: ?*u32,
SigningLevel: ?*u32,
// TODO: what to do with BytesParamIndex 4?
Thumbprint: ?*u8,
ThumbprintSize: ?*u32,
ThumbprintAlgorithm: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "api-ms-win-security-base-l1-2-2" fn DeriveCapabilitySidsFromName(
CapName: ?[*:0]const u16,
CapabilityGroupSids: ?*?*?PSID,
CapabilityGroupSidCount: ?*u32,
CapabilitySids: ?*?*?PSID,
CapabilitySidCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "CRYPT32" fn CryptProtectData(
pDataIn: ?*CRYPTOAPI_BLOB,
szDataDescr: ?[*:0]const u16,
pOptionalEntropy: ?*CRYPTOAPI_BLOB,
pvReserved: ?*c_void,
pPromptStruct: ?*CRYPTPROTECT_PROMPTSTRUCT,
dwFlags: u32,
pDataOut: ?*CRYPTOAPI_BLOB,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "CRYPT32" fn CryptUnprotectData(
pDataIn: ?*CRYPTOAPI_BLOB,
ppszDataDescr: ?*?PWSTR,
pOptionalEntropy: ?*CRYPTOAPI_BLOB,
pvReserved: ?*c_void,
pPromptStruct: ?*CRYPTPROTECT_PROMPTSTRUCT,
dwFlags: u32,
pDataOut: ?*CRYPTOAPI_BLOB,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "CRYPT32" fn CryptUpdateProtectedState(
pOldSid: ?PSID,
pwszOldPassword: ?[*:0]const u16,
dwFlags: u32,
pdwSuccessCount: ?*u32,
pdwFailureCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "CRYPT32" fn CryptProtectMemory(
pDataIn: ?*c_void,
cbDataIn: u32,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "CRYPT32" fn CryptUnprotectMemory(
pDataIn: ?*c_void,
cbDataIn: u32,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windowsServer2008'
pub extern "DSSEC" fn DSCreateISecurityInfoObject(
pwszObjectPath: ?[*:0]const u16,
pwszObjectClass: ?[*:0]const u16,
dwFlags: u32,
ppSI: ?*?*ISecurityInformation,
pfnReadSD: ?PFNREADOBJECTSECURITY,
pfnWriteSD: ?PFNWRITEOBJECTSECURITY,
lpContext: LPARAM,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windowsServer2008'
pub extern "DSSEC" fn DSCreateISecurityInfoObjectEx(
pwszObjectPath: ?[*:0]const u16,
pwszObjectClass: ?[*:0]const u16,
pwszServer: ?[*:0]const u16,
pwszUserName: ?[*:0]const u16,
pwszPassword: ?[*:0]const u16,
dwFlags: u32,
ppSI: ?*?*ISecurityInformation,
pfnReadSD: ?PFNREADOBJECTSECURITY,
pfnWriteSD: ?PFNWRITEOBJECTSECURITY,
lpContext: LPARAM,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windowsServer2003'
pub extern "DSSEC" fn DSCreateSecurityPage(
pwszObjectPath: ?[*:0]const u16,
pwszObjectClass: ?[*:0]const u16,
dwFlags: u32,
phPage: ?*?HPROPSHEETPAGE,
pfnReadSD: ?PFNREADOBJECTSECURITY,
pfnWriteSD: ?PFNWRITEOBJECTSECURITY,
lpContext: LPARAM,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windowsServer2008'
pub extern "DSSEC" fn DSEditSecurity(
hwndOwner: ?HWND,
pwszObjectPath: ?[*:0]const u16,
pwszObjectClass: ?[*:0]const u16,
dwFlags: u32,
pwszCaption: ?[*:0]const u16,
pfnReadSD: ?PFNREADOBJECTSECURITY,
pfnWriteSD: ?PFNWRITEOBJECTSECURITY,
lpContext: LPARAM,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptSIPGetSignedDataMsg(
pSubjectInfo: ?*SIP_SUBJECTINFO,
pdwEncodingType: ?*CERT_QUERY_ENCODING_TYPE,
dwIndex: u32,
pcbSignedDataMsg: ?*u32,
pbSignedDataMsg: ?*u8,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptSIPPutSignedDataMsg(
pSubjectInfo: ?*SIP_SUBJECTINFO,
dwEncodingType: CERT_QUERY_ENCODING_TYPE,
pdwIndex: ?*u32,
cbSignedDataMsg: u32,
pbSignedDataMsg: ?*u8,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptSIPCreateIndirectData(
pSubjectInfo: ?*SIP_SUBJECTINFO,
pcbIndirectData: ?*u32,
pIndirectData: ?*SIP_INDIRECT_DATA,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptSIPVerifyIndirectData(
pSubjectInfo: ?*SIP_SUBJECTINFO,
pIndirectData: ?*SIP_INDIRECT_DATA,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptSIPRemoveSignedDataMsg(
pSubjectInfo: ?*SIP_SUBJECTINFO,
dwIndex: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "CRYPT32" fn CryptSIPLoad(
pgSubject: ?*const Guid,
dwFlags: u32,
pSipDispatch: ?*SIP_DISPATCH_INFO,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "CRYPT32" fn CryptSIPRetrieveSubjectGuid(
FileName: ?[*:0]const u16,
hFileIn: ?HANDLE,
pgSubject: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "CRYPT32" fn CryptSIPRetrieveSubjectGuidForCatalogFile(
FileName: ?[*:0]const u16,
hFileIn: ?HANDLE,
pgSubject: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "CRYPT32" fn CryptSIPAddProvider(
psNewProv: ?*SIP_ADD_NEWPROVIDER,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "CRYPT32" fn CryptSIPRemoveProvider(
pgProv: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "WINTRUST" fn CryptSIPGetCaps(
pSubjInfo: ?*SIP_SUBJECTINFO,
pCaps: ?*SIP_CAP_SET_V3,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "WINTRUST" fn CryptSIPGetSealedDigest(
pSubjectInfo: ?*SIP_SUBJECTINFO,
pSig: ?[*:0]const u8,
dwSig: u32,
pbDigest: ?[*:0]u8,
pcbDigest: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATOpen(
pwszFileName: ?PWSTR,
fdwOpenFlags: CRYPTCAT_OPEN_FLAGS,
hProv: usize,
dwPublicVersion: CRYPTCAT_VERSION,
dwEncodingType: u32,
) callconv(@import("std").os.windows.WINAPI) ?HANDLE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATClose(
hCatalog: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATStoreFromHandle(
hCatalog: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATSTORE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATHandleFromStore(
pCatStore: ?*CRYPTCATSTORE,
) callconv(@import("std").os.windows.WINAPI) ?HANDLE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATPersistStore(
hCatalog: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "WINTRUST" fn CryptCATGetCatAttrInfo(
hCatalog: ?HANDLE,
pwszReferenceTag: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATATTRIBUTE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATPutCatAttrInfo(
hCatalog: ?HANDLE,
pwszReferenceTag: ?PWSTR,
dwAttrTypeAndAction: u32,
cbData: u32,
pbData: ?*u8,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATATTRIBUTE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATEnumerateCatAttr(
hCatalog: ?HANDLE,
pPrevAttr: ?*CRYPTCATATTRIBUTE,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATATTRIBUTE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATGetMemberInfo(
hCatalog: ?HANDLE,
pwszReferenceTag: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATMEMBER;
pub extern "WINTRUST" fn CryptCATAllocSortedMemberInfo(
hCatalog: ?HANDLE,
pwszReferenceTag: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATMEMBER;
pub extern "WINTRUST" fn CryptCATFreeSortedMemberInfo(
hCatalog: ?HANDLE,
pCatMember: ?*CRYPTCATMEMBER,
) callconv(@import("std").os.windows.WINAPI) void;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATGetAttrInfo(
hCatalog: ?HANDLE,
pCatMember: ?*CRYPTCATMEMBER,
pwszReferenceTag: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATATTRIBUTE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATPutMemberInfo(
hCatalog: ?HANDLE,
pwszFileName: ?PWSTR,
pwszReferenceTag: ?PWSTR,
pgSubjectType: ?*Guid,
dwCertVersion: u32,
cbSIPIndirectData: u32,
pbSIPIndirectData: ?*u8,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATMEMBER;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATPutAttrInfo(
hCatalog: ?HANDLE,
pCatMember: ?*CRYPTCATMEMBER,
pwszReferenceTag: ?PWSTR,
dwAttrTypeAndAction: u32,
cbData: u32,
pbData: ?*u8,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATATTRIBUTE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATEnumerateMember(
hCatalog: ?HANDLE,
pPrevMember: ?*CRYPTCATMEMBER,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATMEMBER;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATEnumerateAttr(
hCatalog: ?HANDLE,
pCatMember: ?*CRYPTCATMEMBER,
pPrevAttr: ?*CRYPTCATATTRIBUTE,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATATTRIBUTE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATCDFOpen(
pwszFilePath: ?PWSTR,
pfnParseError: ?PFN_CDF_PARSE_ERROR_CALLBACK,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATCDF;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATCDFClose(
pCDF: ?*CRYPTCATCDF,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATCDFEnumCatAttributes(
pCDF: ?*CRYPTCATCDF,
pPrevAttr: ?*CRYPTCATATTRIBUTE,
pfnParseError: ?PFN_CDF_PARSE_ERROR_CALLBACK,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATATTRIBUTE;
pub extern "WINTRUST" fn CryptCATCDFEnumMembers(
pCDF: ?*CRYPTCATCDF,
pPrevMember: ?*CRYPTCATMEMBER,
pfnParseError: ?PFN_CDF_PARSE_ERROR_CALLBACK,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATMEMBER;
pub extern "WINTRUST" fn CryptCATCDFEnumAttributes(
pCDF: ?*CRYPTCATCDF,
pMember: ?*CRYPTCATMEMBER,
pPrevAttr: ?*CRYPTCATATTRIBUTE,
pfnParseError: ?PFN_CDF_PARSE_ERROR_CALLBACK,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATATTRIBUTE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn IsCatalogFile(
hFile: ?HANDLE,
pwszFileName: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATAdminAcquireContext(
phCatAdmin: ?*isize,
pgSubsystem: ?*const Guid,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "WINTRUST" fn CryptCATAdminAcquireContext2(
phCatAdmin: ?*isize,
pgSubsystem: ?*const Guid,
pwszHashAlgorithm: ?[*:0]const u16,
pStrongHashPolicy: ?*CERT_STRONG_SIGN_PARA,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATAdminReleaseContext(
hCatAdmin: isize,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATAdminReleaseCatalogContext(
hCatAdmin: isize,
hCatInfo: isize,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATAdminEnumCatalogFromHash(
hCatAdmin: isize,
// TODO: what to do with BytesParamIndex 2?
pbHash: ?*u8,
cbHash: u32,
dwFlags: u32,
phPrevCatInfo: ?*isize,
) callconv(@import("std").os.windows.WINAPI) isize;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATAdminCalcHashFromFileHandle(
hFile: ?HANDLE,
pcbHash: ?*u32,
// TODO: what to do with BytesParamIndex 1?
pbHash: ?*u8,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "WINTRUST" fn CryptCATAdminCalcHashFromFileHandle2(
hCatAdmin: isize,
hFile: ?HANDLE,
pcbHash: ?*u32,
// TODO: what to do with BytesParamIndex 2?
pbHash: ?*u8,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATAdminAddCatalog(
hCatAdmin: isize,
pwszCatalogFile: ?PWSTR,
pwszSelectBaseName: ?PWSTR,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) isize;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATAdminRemoveCatalog(
hCatAdmin: isize,
pwszCatalogFile: ?[*:0]const u16,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATCatalogInfoFromContext(
hCatInfo: isize,
psCatInfo: ?*CATALOG_INFO,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATAdminResolveCatalogPath(
hCatAdmin: isize,
pwszCatalogFile: ?PWSTR,
psCatInfo: ?*CATALOG_INFO,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "WINTRUST" fn CryptCATAdminPauseServiceForBackup(
dwFlags: u32,
fResume: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn WinVerifyTrust(
hwnd: ?HWND,
pgActionID: ?*Guid,
pWVTData: ?*c_void,
) callconv(@import("std").os.windows.WINAPI) i32;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn WinVerifyTrustEx(
hwnd: ?HWND,
pgActionID: ?*Guid,
pWinTrustData: ?*WINTRUST_DATA,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn WintrustGetRegPolicyFlags(
pdwPolicyFlags: ?*WINTRUST_POLICY_FLAGS,
) callconv(@import("std").os.windows.WINAPI) void;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn WintrustSetRegPolicyFlags(
dwPolicyFlags: WINTRUST_POLICY_FLAGS,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn WintrustAddActionID(
pgActionID: ?*Guid,
fdwFlags: u32,
psProvInfo: ?*CRYPT_REGISTER_ACTIONID,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn WintrustRemoveActionID(
pgActionID: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn WintrustLoadFunctionPointers(
pgActionID: ?*Guid,
pPfns: ?*CRYPT_PROVIDER_FUNCTIONS,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn WintrustAddDefaultForUsage(
pszUsageOID: ?[*:0]const u8,
psDefUsage: ?*CRYPT_PROVIDER_REGDEFUSAGE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn WintrustGetDefaultForUsage(
dwAction: WINTRUST_GET_DEFAULT_FOR_USAGE_ACTION,
pszUsageOID: ?[*:0]const u8,
psUsage: ?*CRYPT_PROVIDER_DEFUSAGE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn WTHelperGetProvSignerFromChain(
pProvData: ?*CRYPT_PROVIDER_DATA,
idxSigner: u32,
fCounterSigner: BOOL,
idxCounterSigner: u32,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPT_PROVIDER_SGNR;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn WTHelperGetProvCertFromChain(
pSgnr: ?*CRYPT_PROVIDER_SGNR,
idxCert: u32,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPT_PROVIDER_CERT;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn WTHelperProvDataFromStateData(
hStateData: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPT_PROVIDER_DATA;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn WTHelperGetProvPrivateDataFromChain(
pProvData: ?*CRYPT_PROVIDER_DATA,
pgProviderID: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPT_PROVIDER_PRIVDATA;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn WTHelperCertIsSelfSigned(
dwEncoding: u32,
pCert: ?*CERT_INFO,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "WINTRUST" fn WTHelperCertCheckValidSignature(
pProvData: ?*CRYPT_PROVIDER_DATA,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn OpenPersonalTrustDBDialogEx(
hwndParent: ?HWND,
dwFlags: u32,
pvReserved: ?*?*c_void,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn OpenPersonalTrustDBDialog(
hwndParent: ?HWND,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "WINTRUST" fn WintrustSetDefaultIncludePEPageHashes(
fIncludePEPageHashes: BOOL,
) callconv(@import("std").os.windows.WINAPI) void;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SaferGetPolicyInformation(
dwScopeId: u32,
SaferPolicyInfoClass: SAFER_POLICY_INFO_CLASS,
InfoBufferSize: u32,
// TODO: what to do with BytesParamIndex 2?
InfoBuffer: ?*c_void,
InfoBufferRetSize: ?*u32,
lpReserved: ?*c_void,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SaferSetPolicyInformation(
dwScopeId: u32,
SaferPolicyInfoClass: SAFER_POLICY_INFO_CLASS,
InfoBufferSize: u32,
// TODO: what to do with BytesParamIndex 2?
InfoBuffer: ?*c_void,
lpReserved: ?*c_void,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SaferCreateLevel(
dwScopeId: u32,
dwLevelId: u32,
OpenFlags: u32,
pLevelHandle: ?*SAFER_LEVEL_HANDLE,
lpReserved: ?*c_void,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SaferCloseLevel(
hLevelHandle: SAFER_LEVEL_HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SaferIdentifyLevel(
dwNumProperties: u32,
pCodeProperties: ?[*]SAFER_CODE_PROPERTIES_V2,
pLevelHandle: ?*SAFER_LEVEL_HANDLE,
lpReserved: ?*c_void,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SaferComputeTokenFromLevel(
LevelHandle: SAFER_LEVEL_HANDLE,
InAccessToken: ?HANDLE,
OutAccessToken: ?*?HANDLE,
dwFlags: SAFER_COMPUTE_TOKEN_FROM_LEVEL_FLAGS,
lpReserved: ?*c_void,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SaferGetLevelInformation(
LevelHandle: SAFER_LEVEL_HANDLE,
dwInfoType: SAFER_OBJECT_INFO_CLASS,
// TODO: what to do with BytesParamIndex 3?
lpQueryBuffer: ?*c_void,
dwInBufferSize: u32,
lpdwOutBufferSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SaferSetLevelInformation(
LevelHandle: SAFER_LEVEL_HANDLE,
dwInfoType: SAFER_OBJECT_INFO_CLASS,
// TODO: what to do with BytesParamIndex 3?
lpQueryBuffer: ?*c_void,
dwInBufferSize: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SaferRecordEventLogEntry(
hLevel: SAFER_LEVEL_HANDLE,
szTargetPath: ?[*:0]const u16,
lpReserved: ?*c_void,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SaferiIsExecutableFileType(
szFullPathname: ?[*:0]const u16,
bFromShellExecute: BOOLEAN,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqCreateSession(
accessLevel: DdqAccessLevel,
hSession: ?*HDIAGNOSTIC_DATA_QUERY_SESSION,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqCloseSession(
hSession: HDIAGNOSTIC_DATA_QUERY_SESSION,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetSessionAccessLevel(
hSession: HDIAGNOSTIC_DATA_QUERY_SESSION,
accessLevel: ?*DdqAccessLevel,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticDataAccessLevelAllowed(
accessLevel: ?*DdqAccessLevel,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticRecordStats(
hSession: HDIAGNOSTIC_DATA_QUERY_SESSION,
searchCriteria: ?*const DIAGNOSTIC_DATA_SEARCH_CRITERIA,
recordCount: ?*u32,
minRowId: ?*i64,
maxRowId: ?*i64,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticRecordPayload(
hSession: HDIAGNOSTIC_DATA_QUERY_SESSION,
rowId: i64,
payload: ?*?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticRecordLocaleTags(
hSession: HDIAGNOSTIC_DATA_QUERY_SESSION,
locale: ?[*:0]const u16,
hTagDescription: ?*HDIAGNOSTIC_EVENT_TAG_DESCRIPTION,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqFreeDiagnosticRecordLocaleTags(
hTagDescription: HDIAGNOSTIC_EVENT_TAG_DESCRIPTION,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticRecordLocaleTagAtIndex(
hTagDescription: HDIAGNOSTIC_EVENT_TAG_DESCRIPTION,
index: u32,
tagDescription: ?*DIAGNOSTIC_DATA_EVENT_TAG_DESCRIPTION,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticRecordLocaleTagCount(
hTagDescription: HDIAGNOSTIC_EVENT_TAG_DESCRIPTION,
tagDescriptionCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticRecordProducers(
hSession: HDIAGNOSTIC_DATA_QUERY_SESSION,
hProducerDescription: ?*HDIAGNOSTIC_EVENT_PRODUCER_DESCRIPTION,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqFreeDiagnosticRecordProducers(
hProducerDescription: HDIAGNOSTIC_EVENT_PRODUCER_DESCRIPTION,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticRecordProducerAtIndex(
hProducerDescription: HDIAGNOSTIC_EVENT_PRODUCER_DESCRIPTION,
index: u32,
producerDescription: ?*DIAGNOSTIC_DATA_EVENT_PRODUCER_DESCRIPTION,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticRecordProducerCount(
hProducerDescription: HDIAGNOSTIC_EVENT_PRODUCER_DESCRIPTION,
producerDescriptionCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticRecordProducerCategories(
hSession: HDIAGNOSTIC_DATA_QUERY_SESSION,
producerName: ?[*:0]const u16,
hCategoryDescription: ?*HDIAGNOSTIC_EVENT_CATEGORY_DESCRIPTION,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqFreeDiagnosticRecordProducerCategories(
hCategoryDescription: HDIAGNOSTIC_EVENT_CATEGORY_DESCRIPTION,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticRecordCategoryAtIndex(
hCategoryDescription: HDIAGNOSTIC_EVENT_CATEGORY_DESCRIPTION,
index: u32,
categoryDescription: ?*DIAGNOSTIC_DATA_EVENT_CATEGORY_DESCRIPTION,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticRecordCategoryCount(
hCategoryDescription: HDIAGNOSTIC_EVENT_CATEGORY_DESCRIPTION,
categoryDescriptionCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqIsDiagnosticRecordSampledIn(
hSession: HDIAGNOSTIC_DATA_QUERY_SESSION,
providerGroup: ?*const Guid,
providerId: ?*const Guid,
providerName: ?[*:0]const u16,
eventId: ?*const u32,
eventName: ?[*:0]const u16,
eventVersion: ?*const u32,
eventKeywords: ?*const u64,
isSampledIn: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticRecordPage(
hSession: HDIAGNOSTIC_DATA_QUERY_SESSION,
searchCriteria: ?*DIAGNOSTIC_DATA_SEARCH_CRITERIA,
offset: u32,
pageRecordCount: u32,
baseRowId: i64,
hRecord: ?*HDIAGNOSTIC_RECORD,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqFreeDiagnosticRecordPage(
hRecord: HDIAGNOSTIC_RECORD,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticRecordAtIndex(
hRecord: HDIAGNOSTIC_RECORD,
index: u32,
record: ?*DIAGNOSTIC_DATA_RECORD,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticRecordCount(
hRecord: HDIAGNOSTIC_RECORD,
recordCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticReportStoreReportCount(
hSession: HDIAGNOSTIC_DATA_QUERY_SESSION,
reportStoreType: u32,
reportCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqCancelDiagnosticRecordOperation(
hSession: HDIAGNOSTIC_DATA_QUERY_SESSION,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticReport(
hSession: HDIAGNOSTIC_DATA_QUERY_SESSION,
reportStoreType: u32,
hReport: ?*HDIAGNOSTIC_REPORT,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqFreeDiagnosticReport(
hReport: HDIAGNOSTIC_REPORT,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticReportAtIndex(
hReport: HDIAGNOSTIC_REPORT,
index: u32,
report: ?*DIAGNOSTIC_REPORT_DATA,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticReportCount(
hReport: HDIAGNOSTIC_REPORT,
reportCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqExtractDiagnosticReport(
hSession: HDIAGNOSTIC_DATA_QUERY_SESSION,
reportStoreType: u32,
reportKey: ?[*:0]const u16,
destinationPath: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticRecordTagDistribution(
hSession: HDIAGNOSTIC_DATA_QUERY_SESSION,
producerNames: [*]?PWSTR,
producerNameCount: u32,
tagStats: [*]?*DIAGNOSTIC_DATA_EVENT_TAG_STATS,
statCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticRecordBinaryDistribution(
hSession: HDIAGNOSTIC_DATA_QUERY_SESSION,
producerNames: [*]?PWSTR,
producerNameCount: u32,
topNBinaries: u32,
binaryStats: [*]?*DIAGNOSTIC_DATA_EVENT_BINARY_STATS,
statCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetDiagnosticRecordSummary(
hSession: HDIAGNOSTIC_DATA_QUERY_SESSION,
producerNames: [*]const ?[*:0]const u16,
producerNameCount: u32,
generalStats: ?*DIAGNOSTIC_DATA_GENERAL_STATS,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqSetTranscriptConfiguration(
hSession: HDIAGNOSTIC_DATA_QUERY_SESSION,
desiredConfig: ?*const DIAGNOSTIC_DATA_EVENT_TRANSCRIPT_CONFIGURATION,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows10.0.19041'
pub extern "DiagnosticDataQuery" fn DdqGetTranscriptConfiguration(
hSession: HDIAGNOSTIC_DATA_QUERY_SESSION,
currentConfig: ?*DIAGNOSTIC_DATA_EVENT_TRANSCRIPT_CONFIGURATION,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AccessCheckAndAuditAlarmA(
SubsystemName: ?[*:0]const u8,
HandleId: ?*c_void,
ObjectTypeName: ?PSTR,
ObjectName: ?PSTR,
SecurityDescriptor: ?*SECURITY_DESCRIPTOR,
DesiredAccess: u32,
GenericMapping: ?*GENERIC_MAPPING,
ObjectCreation: BOOL,
GrantedAccess: ?*u32,
AccessStatus: ?*i32,
pfGenerateOnClose: ?*i32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AccessCheckByTypeAndAuditAlarmA(
SubsystemName: ?[*:0]const u8,
HandleId: ?*c_void,
ObjectTypeName: ?[*:0]const u8,
ObjectName: ?[*:0]const u8,
SecurityDescriptor: ?*SECURITY_DESCRIPTOR,
PrincipalSelfSid: ?PSID,
DesiredAccess: u32,
AuditType: AUDIT_EVENT_TYPE,
Flags: u32,
ObjectTypeList: ?[*]OBJECT_TYPE_LIST,
ObjectTypeListLength: u32,
GenericMapping: ?*GENERIC_MAPPING,
ObjectCreation: BOOL,
GrantedAccess: ?*u32,
AccessStatus: ?*i32,
pfGenerateOnClose: ?*i32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AccessCheckByTypeResultListAndAuditAlarmA(
SubsystemName: ?[*:0]const u8,
HandleId: ?*c_void,
ObjectTypeName: ?[*:0]const u8,
ObjectName: ?[*:0]const u8,
SecurityDescriptor: ?*SECURITY_DESCRIPTOR,
PrincipalSelfSid: ?PSID,
DesiredAccess: u32,
AuditType: AUDIT_EVENT_TYPE,
Flags: u32,
ObjectTypeList: ?[*]OBJECT_TYPE_LIST,
ObjectTypeListLength: u32,
GenericMapping: ?*GENERIC_MAPPING,
ObjectCreation: BOOL,
GrantedAccess: [*]u32,
AccessStatusList: [*]u32,
pfGenerateOnClose: ?*i32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn AccessCheckByTypeResultListAndAuditAlarmByHandleA(
SubsystemName: ?[*:0]const u8,
HandleId: ?*c_void,
ClientToken: ?HANDLE,
ObjectTypeName: ?[*:0]const u8,
ObjectName: ?[*:0]const u8,
SecurityDescriptor: ?*SECURITY_DESCRIPTOR,
PrincipalSelfSid: ?PSID,
DesiredAccess: u32,
AuditType: AUDIT_EVENT_TYPE,
Flags: u32,
ObjectTypeList: ?[*]OBJECT_TYPE_LIST,
ObjectTypeListLength: u32,
GenericMapping: ?*GENERIC_MAPPING,
ObjectCreation: BOOL,
GrantedAccess: [*]u32,
AccessStatusList: [*]u32,
pfGenerateOnClose: ?*i32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn ObjectOpenAuditAlarmA(
SubsystemName: ?[*:0]const u8,
HandleId: ?*c_void,
ObjectTypeName: ?PSTR,
ObjectName: ?PSTR,
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
ClientToken: ?HANDLE,
DesiredAccess: u32,
GrantedAccess: u32,
Privileges: ?*PRIVILEGE_SET,
ObjectCreation: BOOL,
AccessGranted: BOOL,
GenerateOnClose: ?*i32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn ObjectPrivilegeAuditAlarmA(
SubsystemName: ?[*:0]const u8,
HandleId: ?*c_void,
ClientToken: ?HANDLE,
DesiredAccess: u32,
Privileges: ?*PRIVILEGE_SET,
AccessGranted: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn ObjectCloseAuditAlarmA(
SubsystemName: ?[*:0]const u8,
HandleId: ?*c_void,
GenerateOnClose: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn ObjectDeleteAuditAlarmA(
SubsystemName: ?[*:0]const u8,
HandleId: ?*c_void,
GenerateOnClose: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn PrivilegedServiceAuditAlarmA(
SubsystemName: ?[*:0]const u8,
ServiceName: ?[*:0]const u8,
ClientToken: ?HANDLE,
Privileges: ?*PRIVILEGE_SET,
AccessGranted: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.1'
pub extern "ADVAPI32" fn AddConditionalAce(
pAcl: ?*ACL,
dwAceRevision: u32,
AceFlags: ACE_FLAGS,
AceType: u8,
AccessMask: u32,
pSid: ?PSID,
ConditionStr: ?[*]u16,
ReturnLength: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn SetFileSecurityA(
lpFileName: ?[*:0]const u8,
SecurityInformation: u32,
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn GetFileSecurityA(
lpFileName: ?[*:0]const u8,
RequestedInformation: u32,
// TODO: what to do with BytesParamIndex 3?
pSecurityDescriptor: ?*SECURITY_DESCRIPTOR,
nLength: u32,
lpnLengthNeeded: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn LookupAccountSidA(
lpSystemName: ?[*:0]const u8,
Sid: ?PSID,
Name: ?[*:0]u8,
cchName: ?*u32,
ReferencedDomainName: ?[*:0]u8,
cchReferencedDomainName: ?*u32,
peUse: ?*SID_NAME_USE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn LookupAccountSidW(
lpSystemName: ?[*:0]const u16,
Sid: ?PSID,
Name: ?[*:0]u16,
cchName: ?*u32,
ReferencedDomainName: ?[*:0]u16,
cchReferencedDomainName: ?*u32,
peUse: ?*SID_NAME_USE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn LookupAccountNameA(
lpSystemName: ?[*:0]const u8,
lpAccountName: ?[*:0]const u8,
// TODO: what to do with BytesParamIndex 3?
Sid: ?PSID,
cbSid: ?*u32,
ReferencedDomainName: ?[*:0]u8,
cchReferencedDomainName: ?*u32,
peUse: ?*SID_NAME_USE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn LookupAccountNameW(
lpSystemName: ?[*:0]const u16,
lpAccountName: ?[*:0]const u16,
// TODO: what to do with BytesParamIndex 3?
Sid: ?PSID,
cbSid: ?*u32,
ReferencedDomainName: ?[*:0]u16,
cchReferencedDomainName: ?*u32,
peUse: ?*SID_NAME_USE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn LookupPrivilegeValueA(
lpSystemName: ?[*:0]const u8,
lpName: ?[*:0]const u8,
lpLuid: ?*LUID,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn LookupPrivilegeValueW(
lpSystemName: ?[*:0]const u16,
lpName: ?[*:0]const u16,
lpLuid: ?*LUID,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn LookupPrivilegeNameA(
lpSystemName: ?[*:0]const u8,
lpLuid: ?*LUID,
lpName: ?[*:0]u8,
cchName: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn LookupPrivilegeNameW(
lpSystemName: ?[*:0]const u16,
lpLuid: ?*LUID,
lpName: ?[*:0]u16,
cchName: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn LookupPrivilegeDisplayNameA(
lpSystemName: ?[*:0]const u8,
lpName: ?[*:0]const u8,
lpDisplayName: ?[*:0]u8,
cchDisplayName: ?*u32,
lpLanguageId: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn LookupPrivilegeDisplayNameW(
lpSystemName: ?[*:0]const u16,
lpName: ?[*:0]const u16,
lpDisplayName: ?[*:0]u16,
cchDisplayName: ?*u32,
lpLanguageId: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn LogonUserA(
lpszUsername: ?[*:0]const u8,
lpszDomain: ?[*:0]const u8,
lpszPassword: ?[*:0]const u8,
dwLogonType: LOGON32_LOGON,
dwLogonProvider: LOGON32_PROVIDER,
phToken: ?*?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn LogonUserW(
lpszUsername: ?[*:0]const u16,
lpszDomain: ?[*:0]const u16,
lpszPassword: ?[*:0]const u16,
dwLogonType: LOGON32_LOGON,
dwLogonProvider: LOGON32_PROVIDER,
phToken: ?*?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn LogonUserExA(
lpszUsername: ?[*:0]const u8,
lpszDomain: ?[*:0]const u8,
lpszPassword: ?[*:0]const u8,
dwLogonType: LOGON32_LOGON,
dwLogonProvider: LOGON32_PROVIDER,
phToken: ?*?HANDLE,
ppLogonSid: ?*?PSID,
// TODO: what to do with BytesParamIndex 8?
ppProfileBuffer: ?*?*c_void,
pdwProfileLength: ?*u32,
pQuotaLimits: ?*QUOTA_LIMITS,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ADVAPI32" fn LogonUserExW(
lpszUsername: ?[*:0]const u16,
lpszDomain: ?[*:0]const u16,
lpszPassword: ?[*:0]const u16,
dwLogonType: LOGON32_LOGON,
dwLogonProvider: LOGON32_PROVIDER,
phToken: ?*?HANDLE,
ppLogonSid: ?*?PSID,
// TODO: what to do with BytesParamIndex 8?
ppProfileBuffer: ?*?*c_void,
pdwProfileLength: ?*u32,
pQuotaLimits: ?*QUOTA_LIMITS,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "ntdll" fn RtlConvertSidToUnicodeString(
UnicodeString: ?*UNICODE_STRING,
Sid: ?PSID,
AllocateDestinationString: BOOLEAN,
) callconv(@import("std").os.windows.WINAPI) NTSTATUS;
//--------------------------------------------------------------------------------
// Section: Unicode Aliases (18)
//--------------------------------------------------------------------------------
const thismodule = @This();
pub usingnamespace switch (@import("zig.zig").unicode_mode) {
.ansi => struct {
pub const AccessCheckAndAuditAlarm = thismodule.AccessCheckAndAuditAlarmA;
pub const AccessCheckByTypeAndAuditAlarm = thismodule.AccessCheckByTypeAndAuditAlarmA;
pub const AccessCheckByTypeResultListAndAuditAlarm = thismodule.AccessCheckByTypeResultListAndAuditAlarmA;
pub const AccessCheckByTypeResultListAndAuditAlarmByHandle = thismodule.AccessCheckByTypeResultListAndAuditAlarmByHandleA;
pub const GetFileSecurity = thismodule.GetFileSecurityA;
pub const ObjectCloseAuditAlarm = thismodule.ObjectCloseAuditAlarmA;
pub const ObjectDeleteAuditAlarm = thismodule.ObjectDeleteAuditAlarmA;
pub const ObjectOpenAuditAlarm = thismodule.ObjectOpenAuditAlarmA;
pub const ObjectPrivilegeAuditAlarm = thismodule.ObjectPrivilegeAuditAlarmA;
pub const PrivilegedServiceAuditAlarm = thismodule.PrivilegedServiceAuditAlarmA;
pub const SetFileSecurity = thismodule.SetFileSecurityA;
pub const LookupAccountSid = thismodule.LookupAccountSidA;
pub const LookupAccountName = thismodule.LookupAccountNameA;
pub const LookupPrivilegeValue = thismodule.LookupPrivilegeValueA;
pub const LookupPrivilegeName = thismodule.LookupPrivilegeNameA;
pub const LookupPrivilegeDisplayName = thismodule.LookupPrivilegeDisplayNameA;
pub const LogonUser = thismodule.LogonUserA;
pub const LogonUserEx = thismodule.LogonUserExA;
},
.wide => struct {
pub const AccessCheckAndAuditAlarm = thismodule.AccessCheckAndAuditAlarmW;
pub const AccessCheckByTypeAndAuditAlarm = thismodule.AccessCheckByTypeAndAuditAlarmW;
pub const AccessCheckByTypeResultListAndAuditAlarm = thismodule.AccessCheckByTypeResultListAndAuditAlarmW;
pub const AccessCheckByTypeResultListAndAuditAlarmByHandle = thismodule.AccessCheckByTypeResultListAndAuditAlarmByHandleW;
pub const GetFileSecurity = thismodule.GetFileSecurityW;
pub const ObjectCloseAuditAlarm = thismodule.ObjectCloseAuditAlarmW;
pub const ObjectDeleteAuditAlarm = thismodule.ObjectDeleteAuditAlarmW;
pub const ObjectOpenAuditAlarm = thismodule.ObjectOpenAuditAlarmW;
pub const ObjectPrivilegeAuditAlarm = thismodule.ObjectPrivilegeAuditAlarmW;
pub const PrivilegedServiceAuditAlarm = thismodule.PrivilegedServiceAuditAlarmW;
pub const SetFileSecurity = thismodule.SetFileSecurityW;
pub const LookupAccountSid = thismodule.LookupAccountSidW;
pub const LookupAccountName = thismodule.LookupAccountNameW;
pub const LookupPrivilegeValue = thismodule.LookupPrivilegeValueW;
pub const LookupPrivilegeName = thismodule.LookupPrivilegeNameW;
pub const LookupPrivilegeDisplayName = thismodule.LookupPrivilegeDisplayNameW;
pub const LogonUser = thismodule.LogonUserW;
pub const LogonUserEx = thismodule.LogonUserExW;
},
.unspecified => if (@import("builtin").is_test) struct {
pub const AccessCheckAndAuditAlarm = *opaque{};
pub const AccessCheckByTypeAndAuditAlarm = *opaque{};
pub const AccessCheckByTypeResultListAndAuditAlarm = *opaque{};
pub const AccessCheckByTypeResultListAndAuditAlarmByHandle = *opaque{};
pub const GetFileSecurity = *opaque{};
pub const ObjectCloseAuditAlarm = *opaque{};
pub const ObjectDeleteAuditAlarm = *opaque{};
pub const ObjectOpenAuditAlarm = *opaque{};
pub const ObjectPrivilegeAuditAlarm = *opaque{};
pub const PrivilegedServiceAuditAlarm = *opaque{};
pub const SetFileSecurity = *opaque{};
pub const LookupAccountSid = *opaque{};
pub const LookupAccountName = *opaque{};
pub const LookupPrivilegeValue = *opaque{};
pub const LookupPrivilegeName = *opaque{};
pub const LookupPrivilegeDisplayName = *opaque{};
pub const LogonUser = *opaque{};
pub const LogonUserEx = *opaque{};
} else struct {
pub const AccessCheckAndAuditAlarm = @compileError("'AccessCheckAndAuditAlarm' requires that UNICODE be set to true or false in the root module");
pub const AccessCheckByTypeAndAuditAlarm = @compileError("'AccessCheckByTypeAndAuditAlarm' requires that UNICODE be set to true or false in the root module");
pub const AccessCheckByTypeResultListAndAuditAlarm = @compileError("'AccessCheckByTypeResultListAndAuditAlarm' requires that UNICODE be set to true or false in the root module");
pub const AccessCheckByTypeResultListAndAuditAlarmByHandle = @compileError("'AccessCheckByTypeResultListAndAuditAlarmByHandle' requires that UNICODE be set to true or false in the root module");
pub const GetFileSecurity = @compileError("'GetFileSecurity' requires that UNICODE be set to true or false in the root module");
pub const ObjectCloseAuditAlarm = @compileError("'ObjectCloseAuditAlarm' requires that UNICODE be set to true or false in the root module");
pub const ObjectDeleteAuditAlarm = @compileError("'ObjectDeleteAuditAlarm' requires that UNICODE be set to true or false in the root module");
pub const ObjectOpenAuditAlarm = @compileError("'ObjectOpenAuditAlarm' requires that UNICODE be set to true or false in the root module");
pub const ObjectPrivilegeAuditAlarm = @compileError("'ObjectPrivilegeAuditAlarm' requires that UNICODE be set to true or false in the root module");
pub const PrivilegedServiceAuditAlarm = @compileError("'PrivilegedServiceAuditAlarm' requires that UNICODE be set to true or false in the root module");
pub const SetFileSecurity = @compileError("'SetFileSecurity' requires that UNICODE be set to true or false in the root module");
pub const LookupAccountSid = @compileError("'LookupAccountSid' requires that UNICODE be set to true or false in the root module");
pub const LookupAccountName = @compileError("'LookupAccountName' requires that UNICODE be set to true or false in the root module");
pub const LookupPrivilegeValue = @compileError("'LookupPrivilegeValue' requires that UNICODE be set to true or false in the root module");
pub const LookupPrivilegeName = @compileError("'LookupPrivilegeName' requires that UNICODE be set to true or false in the root module");
pub const LookupPrivilegeDisplayName = @compileError("'LookupPrivilegeDisplayName' requires that UNICODE be set to true or false in the root module");
pub const LogonUser = @compileError("'LogonUser' requires that UNICODE be set to true or false in the root module");
pub const LogonUserEx = @compileError("'LogonUserEx' requires that UNICODE be set to true or false in the root module");
},
};
//--------------------------------------------------------------------------------
// Section: Imports (39)
//--------------------------------------------------------------------------------
const Guid = @import("zig.zig").Guid;
const BOOL = @import("foundation.zig").BOOL;
const BOOLEAN = @import("foundation.zig").BOOLEAN;
const BSTR = @import("foundation.zig").BSTR;
const CERT_CHAIN_CONTEXT = @import("security/cryptography/core.zig").CERT_CHAIN_CONTEXT;
const CERT_CHAIN_ELEMENT = @import("security/cryptography/core.zig").CERT_CHAIN_ELEMENT;
const CERT_CONTEXT = @import("security/cryptography/core.zig").CERT_CONTEXT;
const CERT_INFO = @import("security/cryptography/core.zig").CERT_INFO;
const CERT_QUERY_ENCODING_TYPE = @import("security/cryptography/core.zig").CERT_QUERY_ENCODING_TYPE;
const CERT_STRONG_SIGN_PARA = @import("security/cryptography/core.zig").CERT_STRONG_SIGN_PARA;
const CERT_USAGE_MATCH = @import("security/cryptography/core.zig").CERT_USAGE_MATCH;
const CHAR = @import("system/system_services.zig").CHAR;
const CMSG_SIGNER_INFO = @import("security/cryptography/core.zig").CMSG_SIGNER_INFO;
const CRYPT_ALGORITHM_IDENTIFIER = @import("security/cryptography/core.zig").CRYPT_ALGORITHM_IDENTIFIER;
const CRYPT_ATTRIBUTE_TYPE_VALUE = @import("security/cryptography/core.zig").CRYPT_ATTRIBUTE_TYPE_VALUE;
const CRYPT_BIT_BLOB = @import("security/cryptography/core.zig").CRYPT_BIT_BLOB;
const CRYPTOAPI_BLOB = @import("security/cryptography/core.zig").CRYPTOAPI_BLOB;
const CTL_CONTEXT = @import("security/cryptography/core.zig").CTL_CONTEXT;
const DLGPROC = @import("ui/windows_and_messaging.zig").DLGPROC;
const DLGTEMPLATE = @import("ui/windows_and_messaging.zig").DLGTEMPLATE;
const FILETIME = @import("foundation.zig").FILETIME;
const HANDLE = @import("foundation.zig").HANDLE;
const HDESK = @import("system/stations_and_desktops.zig").HDESK;
const HPROPSHEETPAGE = @import("ui/controls.zig").HPROPSHEETPAGE;
const HRESULT = @import("foundation.zig").HRESULT;
const HWND = @import("foundation.zig").HWND;
const IDispatch = @import("system/ole_automation.zig").IDispatch;
const ISecurityInformation = @import("security/authorization.zig").ISecurityInformation;
const IUnknown = @import("system/com.zig").IUnknown;
const LARGE_INTEGER = @import("system/system_services.zig").LARGE_INTEGER;
const LPARAM = @import("foundation.zig").LPARAM;
const LUID = @import("system/system_services.zig").LUID;
const NTSTATUS = @import("foundation.zig").NTSTATUS;
const OBJECT_SECURITY_INFORMATION = @import("security/authorization.zig").OBJECT_SECURITY_INFORMATION;
const PSID = @import("foundation.zig").PSID;
const PSTR = @import("foundation.zig").PSTR;
const PWSTR = @import("foundation.zig").PWSTR;
const UNICODE_STRING = @import("system/kernel.zig").UNICODE_STRING;
const VARIANT = @import("system/ole_automation.zig").VARIANT;
test {
// The following '_ = <FuncPtrType>' lines are a workaround for https://github.com/ziglang/zig/issues/4476
if (@hasDecl(@This(), "PLSA_AP_CALL_PACKAGE_UNTRUSTED")) { _ = PLSA_AP_CALL_PACKAGE_UNTRUSTED; }
if (@hasDecl(@This(), "SEC_THREAD_START")) { _ = SEC_THREAD_START; }
if (@hasDecl(@This(), "PWLX_USE_CTRL_ALT_DEL")) { _ = PWLX_USE_CTRL_ALT_DEL; }
if (@hasDecl(@This(), "PWLX_SET_CONTEXT_POINTER")) { _ = PWLX_SET_CONTEXT_POINTER; }
if (@hasDecl(@This(), "PWLX_SAS_NOTIFY")) { _ = PWLX_SAS_NOTIFY; }
if (@hasDecl(@This(), "PWLX_SET_TIMEOUT")) { _ = PWLX_SET_TIMEOUT; }
if (@hasDecl(@This(), "PWLX_ASSIGN_SHELL_PROTECTION")) { _ = PWLX_ASSIGN_SHELL_PROTECTION; }
if (@hasDecl(@This(), "PWLX_MESSAGE_BOX")) { _ = PWLX_MESSAGE_BOX; }
if (@hasDecl(@This(), "PWLX_DIALOG_BOX")) { _ = PWLX_DIALOG_BOX; }
if (@hasDecl(@This(), "PWLX_DIALOG_BOX_INDIRECT")) { _ = PWLX_DIALOG_BOX_INDIRECT; }
if (@hasDecl(@This(), "PWLX_DIALOG_BOX_PARAM")) { _ = PWLX_DIALOG_BOX_PARAM; }
if (@hasDecl(@This(), "PWLX_DIALOG_BOX_INDIRECT_PARAM")) { _ = PWLX_DIALOG_BOX_INDIRECT_PARAM; }
if (@hasDecl(@This(), "PWLX_SWITCH_DESKTOP_TO_USER")) { _ = PWLX_SWITCH_DESKTOP_TO_USER; }
if (@hasDecl(@This(), "PWLX_SWITCH_DESKTOP_TO_WINLOGON")) { _ = PWLX_SWITCH_DESKTOP_TO_WINLOGON; }
if (@hasDecl(@This(), "PWLX_CHANGE_PASSWORD_NOTIFY")) { _ = PWLX_CHANGE_PASSWORD_NOTIFY; }
if (@hasDecl(@This(), "PWLX_GET_SOURCE_DESKTOP")) { _ = PWLX_GET_SOURCE_DESKTOP; }
if (@hasDecl(@This(), "PWLX_SET_RETURN_DESKTOP")) { _ = PWLX_SET_RETURN_DESKTOP; }
if (@hasDecl(@This(), "PWLX_CREATE_USER_DESKTOP")) { _ = PWLX_CREATE_USER_DESKTOP; }
if (@hasDecl(@This(), "PWLX_CHANGE_PASSWORD_NOTIFY_EX")) { _ = PWLX_CHANGE_PASSWORD_NOTIFY_EX; }
if (@hasDecl(@This(), "PWLX_CLOSE_USER_DESKTOP")) { _ = PWLX_CLOSE_USER_DESKTOP; }
if (@hasDecl(@This(), "PWLX_SET_OPTION")) { _ = PWLX_SET_OPTION; }
if (@hasDecl(@This(), "PWLX_GET_OPTION")) { _ = PWLX_GET_OPTION; }
if (@hasDecl(@This(), "PWLX_WIN31_MIGRATE")) { _ = PWLX_WIN31_MIGRATE; }
if (@hasDecl(@This(), "PWLX_QUERY_CLIENT_CREDENTIALS")) { _ = PWLX_QUERY_CLIENT_CREDENTIALS; }
if (@hasDecl(@This(), "PWLX_QUERY_IC_CREDENTIALS")) { _ = PWLX_QUERY_IC_CREDENTIALS; }
if (@hasDecl(@This(), "PWLX_QUERY_TS_LOGON_CREDENTIALS")) { _ = PWLX_QUERY_TS_LOGON_CREDENTIALS; }
if (@hasDecl(@This(), "PWLX_DISCONNECT")) { _ = PWLX_DISCONNECT; }
if (@hasDecl(@This(), "PWLX_QUERY_TERMINAL_SERVICES_DATA")) { _ = PWLX_QUERY_TERMINAL_SERVICES_DATA; }
if (@hasDecl(@This(), "PWLX_QUERY_CONSOLESWITCH_CREDENTIALS")) { _ = PWLX_QUERY_CONSOLESWITCH_CREDENTIALS; }
if (@hasDecl(@This(), "PFNMSGECALLBACK")) { _ = PFNMSGECALLBACK; }
if (@hasDecl(@This(), "PFNREADOBJECTSECURITY")) { _ = PFNREADOBJECTSECURITY; }
if (@hasDecl(@This(), "PFNWRITEOBJECTSECURITY")) { _ = PFNWRITEOBJECTSECURITY; }
if (@hasDecl(@This(), "PFNDSCREATEISECINFO")) { _ = PFNDSCREATEISECINFO; }
if (@hasDecl(@This(), "PFNDSCREATEISECINFOEX")) { _ = PFNDSCREATEISECINFOEX; }
if (@hasDecl(@This(), "PFNDSCREATESECPAGE")) { _ = PFNDSCREATESECPAGE; }
if (@hasDecl(@This(), "PFNDSEDITSECURITY")) { _ = PFNDSEDITSECURITY; }
if (@hasDecl(@This(), "pCryptSIPGetSignedDataMsg")) { _ = pCryptSIPGetSignedDataMsg; }
if (@hasDecl(@This(), "pCryptSIPPutSignedDataMsg")) { _ = pCryptSIPPutSignedDataMsg; }
if (@hasDecl(@This(), "pCryptSIPCreateIndirectData")) { _ = pCryptSIPCreateIndirectData; }
if (@hasDecl(@This(), "pCryptSIPVerifyIndirectData")) { _ = pCryptSIPVerifyIndirectData; }
if (@hasDecl(@This(), "pCryptSIPRemoveSignedDataMsg")) { _ = pCryptSIPRemoveSignedDataMsg; }
if (@hasDecl(@This(), "pfnIsFileSupported")) { _ = pfnIsFileSupported; }
if (@hasDecl(@This(), "pfnIsFileSupportedName")) { _ = pfnIsFileSupportedName; }
if (@hasDecl(@This(), "pCryptSIPGetCaps")) { _ = pCryptSIPGetCaps; }
if (@hasDecl(@This(), "pCryptSIPGetSealedDigest")) { _ = pCryptSIPGetSealedDigest; }
if (@hasDecl(@This(), "PFN_CDF_PARSE_ERROR_CALLBACK")) { _ = PFN_CDF_PARSE_ERROR_CALLBACK; }
if (@hasDecl(@This(), "PFN_CPD_MEM_ALLOC")) { _ = PFN_CPD_MEM_ALLOC; }
if (@hasDecl(@This(), "PFN_CPD_MEM_FREE")) { _ = PFN_CPD_MEM_FREE; }
if (@hasDecl(@This(), "PFN_CPD_ADD_STORE")) { _ = PFN_CPD_ADD_STORE; }
if (@hasDecl(@This(), "PFN_CPD_ADD_SGNR")) { _ = PFN_CPD_ADD_SGNR; }
if (@hasDecl(@This(), "PFN_CPD_ADD_CERT")) { _ = PFN_CPD_ADD_CERT; }
if (@hasDecl(@This(), "PFN_CPD_ADD_PRIVDATA")) { _ = PFN_CPD_ADD_PRIVDATA; }
if (@hasDecl(@This(), "PFN_PROVIDER_INIT_CALL")) { _ = PFN_PROVIDER_INIT_CALL; }
if (@hasDecl(@This(), "PFN_PROVIDER_OBJTRUST_CALL")) { _ = PFN_PROVIDER_OBJTRUST_CALL; }
if (@hasDecl(@This(), "PFN_PROVIDER_SIGTRUST_CALL")) { _ = PFN_PROVIDER_SIGTRUST_CALL; }
if (@hasDecl(@This(), "PFN_PROVIDER_CERTTRUST_CALL")) { _ = PFN_PROVIDER_CERTTRUST_CALL; }
if (@hasDecl(@This(), "PFN_PROVIDER_FINALPOLICY_CALL")) { _ = PFN_PROVIDER_FINALPOLICY_CALL; }
if (@hasDecl(@This(), "PFN_PROVIDER_TESTFINALPOLICY_CALL")) { _ = PFN_PROVIDER_TESTFINALPOLICY_CALL; }
if (@hasDecl(@This(), "PFN_PROVIDER_CLEANUP_CALL")) { _ = PFN_PROVIDER_CLEANUP_CALL; }
if (@hasDecl(@This(), "PFN_PROVIDER_CERTCHKPOLICY_CALL")) { _ = PFN_PROVIDER_CERTCHKPOLICY_CALL; }
if (@hasDecl(@This(), "PFN_PROVUI_CALL")) { _ = PFN_PROVUI_CALL; }
if (@hasDecl(@This(), "PFN_ALLOCANDFILLDEFUSAGE")) { _ = PFN_ALLOCANDFILLDEFUSAGE; }
if (@hasDecl(@This(), "PFN_FREEDEFUSAGE")) { _ = PFN_FREEDEFUSAGE; }
if (@hasDecl(@This(), "PFSCE_QUERY_INFO")) { _ = PFSCE_QUERY_INFO; }
if (@hasDecl(@This(), "PFSCE_SET_INFO")) { _ = PFSCE_SET_INFO; }
if (@hasDecl(@This(), "PFSCE_FREE_INFO")) { _ = PFSCE_FREE_INFO; }
if (@hasDecl(@This(), "PFSCE_LOG_INFO")) { _ = PFSCE_LOG_INFO; }
if (@hasDecl(@This(), "PF_ConfigAnalyzeService")) { _ = PF_ConfigAnalyzeService; }
if (@hasDecl(@This(), "PF_UpdateService")) { _ = PF_UpdateService; }
@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;
}
}
}
//--------------------------------------------------------------------------------
// Section: SubModules (7)
//--------------------------------------------------------------------------------
pub const authentication = @import("security/authentication.zig");
pub const authorization = @import("security/authorization.zig");
pub const credentials = @import("security/credentials.zig");
pub const cryptography = @import("security/cryptography.zig");
pub const enterprise_data = @import("security/enterprise_data.zig");
pub const extensible_authentication_protocol = @import("security/extensible_authentication_protocol.zig");
pub const isolation = @import("security/isolation.zig");
|
deps/zigwin32/win32/security.zig
|
const std = @import("std");
const log = std.log.scoped(.@"brucelib.audio");
const Sound = @import("Sound.zig");
const SoundBuffer = @import("common.zig").SoundBuffer;
const sin = std.math.sin;
const pi = std.math.pi;
const tao = 2 * pi;
pub const wav = @import("wav.zig");
pub const BufferedSound = struct {
buffer: SoundBuffer,
loop: bool = false,
cursor: usize = 0,
pub fn sound(self: *@This(), priority: Sound.Priority) Sound {
return Sound.init(self, @This().sample, self.buffer.channels, priority);
}
pub fn sample(self: *BufferedSound, sample_rate: u32, buffer: []f32) usize {
// TODO(hazeycode): resampling. probably not here, but in the loader
// see https://github.com/hazeycode/brucelib/issues/12
_ = sample_rate;
//std.debug.assert(sample_rate == self.buffer.sample_rate);
if (self.loop and self.cursor >= self.buffer.samples.len) {
self.cursor = 0;
}
const remaining_samples = self.buffer.samples[self.cursor..];
const num_samples = std.math.min(buffer.len, remaining_samples.len);
std.mem.copy(
f32,
buffer,
self.buffer.samples[self.cursor..(self.cursor + num_samples)],
);
self.cursor += num_samples;
return num_samples;
}
};
pub const SineWave = struct {
freq: f32,
cursor: usize = 0,
pub fn sound(self: *@This(), priority: Sound.Priority) Sound {
return Sound.init(self, @This().sample, 1, priority);
}
pub fn sample(self: *SineWave, sample_rate: u32, buffer: []f32) usize {
for (buffer) |*s, i| {
s.* = 0.5 * sin(
@intToFloat(f32, self.cursor + i) * (tao * self.freq) / @intToFloat(f32, sample_rate),
);
}
self.cursor += buffer.len;
return buffer.len;
}
};
/// Provides an interface for mixing multiple sounds together into an output buffer
// TODO(hazeycode): support for channel configs other than stereo, see https://github.com/hazeycode/brucelib/issues/14
pub const Mixer = struct {
// TODO(hazeycode): comptime Mixer params
const num_inputs = 16;
const input_buf_len = 2048;
inputs: [num_inputs]Input,
mutex: std.Thread.Mutex = .{},
/// Represents an input channel that can be mixed with others
const Input = struct {
sound: ?Sound = null,
gain: f32 = 0.67, // 0.0...1.0
sends: [2]f32 = .{ 1.0, 1.0 }, // 0.0...1.0
buffer: [input_buf_len]f32 = .{0} ** input_buf_len,
};
pub fn init() @This() {
var res: @This() = .{ .inputs = undefined };
for (res.inputs) |*input| input.* = .{};
return res;
}
/// Play a sound
/// Binds the sound to a free input channel or overrides a lower priority one
/// Will be unbound if&when `sample_fn` writes no samples or when the user calls `stop` or `stopAll`
/// Returns the input channel index that was bound or null if sound can't be played
pub fn play(
self: *@This(),
sound_source: anytype,
priority: Sound.Priority,
gain: f32,
) ?u32 {
std.debug.assert(@typeInfo(@TypeOf(sound_source)) == .Pointer);
if (self.bindInput(sound_source, priority)) |input_channel_idx| {
self.inputs[input_channel_idx].gain = gain;
return input_channel_idx;
} else {
log.warn("No free mixer channels to play sound", .{});
std.debug.assert(priority != .high);
}
return null;
}
/// Stop a playing sound by input channel index
pub fn stop(self: *@This(), channel: u32) void {
self.inputs[channel].sound = null;
std.mem.set(f32, &self.inputs[channel].buffer, 0);
log.debug("Stopped playing sound on mixer channel {}", .{channel});
}
/// Stop all playing sounds
pub fn stopAll(self: *@This()) void {
var i: usize = 0;
while (i < self.inputs.len) : (i += 1) {
self.stop(i);
}
}
/// Sets the input gain for a given sound source, if it's bound
/// Returns true if the sound is bound to a channel, otherwise false
pub fn setInputSourceGain(self: *@This(), sound_source: anytype, gain: f32) bool {
std.debug.assert(@typeInfo(@TypeOf(sound_source)) == .Pointer);
self.mutex.lock();
defer self.mutex.unlock();
for (self.inputs) |*input| {
if (input.sound) |sound| {
if (sound.ptr == @ptrCast(*anyopaque, sound_source)) {
input.gain = gain;
return true;
}
}
}
return false;
}
/// Mixes all input channel and write to the given buffer
pub fn mix(
self: *@This(),
num_frames: u32,
out_channels: u32,
sample_rate: u32,
sample_buf: []f32,
) void {
self.mutex.lock();
defer self.mutex.unlock();
// buffer up input samples
for (self.inputs) |*input, i| {
if (input.sound) |*sound| {
const max_samples = num_frames * sound.channels;
const read_samples = sound.sample(
sample_rate,
input.buffer[0..max_samples],
);
// unbind if no samples were written
if (read_samples == 0) {
stop(self, @intCast(u32, i));
}
// fill any remaining space in buffer with silence
for (input.buffer[read_samples..]) |*sample| sample.* = 0.0;
}
}
const frames = num_frames;
var n: u32 = 0;
while (n < frames) : (n += 1) {
var samples: [2]f32 = .{ 0, 0 };
for (self.inputs) |input| {
if (input.sound) |sound| {
switch (sound.channels) {
1 => {
samples[0] += input.sends[0] * input.gain * input.buffer[n];
samples[1] += input.sends[1] * input.gain * input.buffer[n];
},
2 => {
samples[0] += input.sends[0] * input.gain * input.buffer[n * 2 + 0];
samples[1] += input.sends[1] * input.gain * input.buffer[n * 2 + 1];
},
else => std.debug.panic(
"Input has unsupported number of channels: {}",
.{sound.channels},
),
}
}
}
sample_buf[n * out_channels + 0] = samples[0];
sample_buf[n * out_channels + 1] = samples[1];
}
}
/// Binds the sound to a free mixer channel or overrides a lower priority one
/// Will be unbound if&when `sample_fn` writes no samples
/// Returns the mixer channel index that was bound
fn bindInput(self: *@This(), sound_source: anytype, priority: Sound.Priority) ?u32 {
std.debug.assert(@typeInfo(@TypeOf(sound_source)) == .Pointer);
self.mutex.lock();
defer self.mutex.unlock();
for (self.inputs) |*input, i| {
if (input.sound == null) {
input.sound = sound_source.sound(priority);
return @intCast(u32, i);
}
}
// If the sound is high priority, see if there is a lower priority sound
// that we can swap it for
if (priority == .high) {
for (self.inputs) |*input, i| {
if (input.sound.?.priority == .low) {
input.sound = sound_source.sound(priority);
return @intCast(u32, i);
}
}
}
return null;
}
};
test {
std.testing.refAllDecls(@This());
}
|
modules/audio/src/main.zig
|
const std = @import("std");
const builtin = std.builtin;
// set log level to debug in Debug mode, info otherwise
pub const log_level: std.log.Level = switch (builtin.mode) {
.Debug => .debug,
.ReleaseSafe, .ReleaseSmall, .ReleaseFast => .info,
};
// Define root.log to override the std implementation
pub fn log(
comptime level: std.log.Level,
comptime scope: @TypeOf(.EnumLiteral),
comptime format: []const u8,
args: anytype,
) void {
// Ignore all non-error logging from sources other than
// .ft and .default
const scope_prefix = "(" ++
switch (scope) {
.ft, .default => @tagName(scope),
else =>
if (@enumToInt(level) <= @enumToInt(std.log.Level.err))
@tagName(scope)
else
return,
} ++
"): ";
const prefix = "[" ++ level.asText() ++ "] " ++ scope_prefix;
// Print the message to stderr, silently ignoring any errors
std.debug.getStderrMutex().lock();
defer std.debug.getStderrMutex().unlock();
const stderr = std.io.getStdErr().writer();
nosuspend stderr.print(prefix ++ format ++ "\n", args) catch return;
}
// pub fn main() void {
// // Using the default scope:
// std.log.debug("A borderline useless debug log message", .{}); // Won't be printed as log_level is .info
// std.log.info("Flux capacitor is starting to overheat", .{});
// // Using scoped logging:
// const my_project_log = std.log.scoped(.my_project);
// const nice_library_log = std.log.scoped(.nice_library);
// const verbose_lib_log = std.log.scoped(.verbose_lib);
// my_project_log.debug("Starting up", .{}); // Won't be printed as log_level is .info
// nice_library_log.warn("Something went very wrong, sorry", .{});
// verbose_lib_log.warn("Added 1 + 1: {}", .{1 + 1}); // Won't be printed as it gets filtered out by our log function
// }
// ```
// Which produces the following output:
// ```
// [info] (default): Flux capacitor is starting to overheat
// [warning] (nice_library): Something went very wrong, sorry
// ```
|
src/log.zig
|
usingnamespace @import("../engine/engine.zig");
const Literal = @import("../parser/literal.zig").Literal;
const LiteralValue = @import("../parser/literal.zig").LiteralValue;
const std = @import("std");
const testing = std.testing;
const mem = std.mem;
pub fn RepeatedContext(comptime Payload: type, comptime Value: type) type {
return struct {
/// The parser which should be repeatedly parsed.
parser: *Parser(Payload, Value),
/// The minimum number of times the parser must successfully match.
min: usize,
/// The maximum number of times the parser can match, or -1 for unlimited.
max: isize,
};
}
/// Represents a single value in the stream of repeated values.
///
/// In the case of a non-ambiguous grammar, a `Repeated` combinator will yield:
///
/// ```
/// stream(value1, value2)
/// ```
///
/// In the case of an ambiguous grammar, it would yield a stream with only the first parse path.
/// Use RepeatedAmbiguous if ambiguou parse paths are desirable.
pub fn RepeatedValue(comptime Value: type) type {
return struct {
results: *ResultStream(Result(Value)),
pub fn deinit(self: *const @This(), allocator: *mem.Allocator) void {
self.results.deinit();
allocator.destroy(self.results);
}
};
}
/// Matches the `input` repeatedly, between `[min, max]` times (inclusive.) If ambiguous parse paths
/// are desirable, use RepeatedAmbiguous.
///
/// The `input` parsers must remain alive for as long as the `Repeated` parser will be used.
pub fn Repeated(comptime Payload: type, comptime Value: type) type {
return struct {
parser: Parser(Payload, RepeatedValue(Value)) = Parser(Payload, RepeatedValue(Value)).init(parse, nodeName, deinit),
input: RepeatedContext(Payload, Value),
const Self = @This();
pub fn init(input: RepeatedContext(Payload, Value)) Self {
return Self{ .input = input };
}
pub fn deinit(parser: *Parser(Payload, RepeatedValue(Value)), allocator: *mem.Allocator) void {
const self = @fieldParentPtr(Self, "parser", parser);
self.input.parser.deinit(allocator);
}
pub fn nodeName(parser: *const Parser(Payload, RepeatedValue(Value)), node_name_cache: *std.AutoHashMap(usize, ParserNodeName)) Error!u64 {
const self = @fieldParentPtr(Self, "parser", parser);
var v = std.hash_map.hashString("Repeated");
v +%= try self.input.parser.nodeName(node_name_cache);
v +%= std.hash_map.getAutoHashFn(usize, void)({}, self.input.min);
v +%= std.hash_map.getAutoHashFn(isize, void)({}, self.input.max);
return v;
}
pub fn parse(parser: *const Parser(Payload, RepeatedValue(Value)), in_ctx: *const Context(Payload, RepeatedValue(Value))) callconv(.Async) Error!void {
const self = @fieldParentPtr(Self, "parser", parser);
var ctx = in_ctx.with(self.input);
defer ctx.results.close();
// Invoke the child parser repeatedly to produce each of our results. Each time we ask
// the child parser to parse, it can produce a set of results (its result stream) which
// are varying parse paths / interpretations, we take the first successful one.
// Return early if we're not trying to parse anything (stream close signals to the
// consumer there were no matches).
if (ctx.input.max == 0) {
return;
}
var buffer = try ctx.allocator.create(ResultStream(Result(Value)));
errdefer ctx.allocator.destroy(buffer);
errdefer buffer.deinit();
buffer.* = try ResultStream(Result(Value)).init(ctx.allocator, ctx.key);
var num_values: usize = 0;
var offset: usize = ctx.offset;
while (true) {
const child_node_name = try self.input.parser.nodeName(&in_ctx.memoizer.node_name_cache);
var child_ctx = try in_ctx.initChild(Value, child_node_name, offset);
defer child_ctx.deinitChild();
if (!child_ctx.existing_results) try self.input.parser.parse(&child_ctx);
var num_local_values: usize = 0;
var sub = child_ctx.subscribe();
while (sub.next()) |next| {
switch (next.result) {
.err => {
offset = next.offset;
if (num_values < ctx.input.min) {
buffer.close();
buffer.deinit();
ctx.allocator.destroy(buffer);
try ctx.results.add(Result(RepeatedValue(Value)).initError(next.offset, next.result.err));
return;
}
buffer.close();
try ctx.results.add(Result(RepeatedValue(Value)).init(offset, .{ .results = buffer }));
return;
},
else => {
// TODO(slimsag): need path committal functionality
if (num_local_values == 0) {
offset = next.offset;
// TODO(slimsag): if no consumption, could get stuck forever!
try buffer.add(next.toUnowned());
}
num_local_values += 1;
},
}
}
num_values += 1;
if (num_values >= ctx.input.max and ctx.input.max != -1) break;
}
buffer.close();
try ctx.results.add(Result(RepeatedValue(Value)).init(offset, .{ .results = buffer }));
}
};
}
test "repeated" {
nosuspend {
const allocator = testing.allocator;
const Payload = void;
const ctx = try Context(Payload, RepeatedValue(LiteralValue)).init(allocator, "abcabcabc123abc", {});
defer ctx.deinit();
var abcInfinity = Repeated(Payload, LiteralValue).init(.{
.parser = (&Literal(Payload).init("abc").parser).ref(),
.min = 0,
.max = -1,
});
try abcInfinity.parser.parse(&ctx);
var sub = ctx.subscribe();
var repeated = sub.next().?.result.value;
try testing.expect(sub.next() == null); // stream closed
var repeatedSub = repeated.results.subscribe(ctx.key, ctx.path, Result(LiteralValue).initError(ctx.offset, "matches only the empty language"));
try testing.expectEqual(@as(usize, 3), repeatedSub.next().?.offset);
try testing.expectEqual(@as(usize, 6), repeatedSub.next().?.offset);
try testing.expectEqual(@as(usize, 9), repeatedSub.next().?.offset);
try testing.expect(repeatedSub.next() == null); // stream closed
}
}
|
src/combn/combinator/repeated.zig
|
const kernel = @import("kernel.zig");
const log = kernel.log.scoped(.AVL);
pub fn Tree(comptime T: type) type {
return struct {
root: ?*Item = null,
/// This is always refering to the tree
const Self = @This();
// TODO: add more keys?
const Key = u64;
pub const SearchMode = enum {
exact,
smallest_above_or_equal,
largest_below_or_equal,
};
pub const DuplicateKeyPolicy = enum {
panic,
allow,
fail,
};
pub fn insert(self: *@This(), item: *Item, item_value: ?*T, key: Key, duplicate_key_policy: DuplicateKeyPolicy) bool {
//log.debug("Validating before insertion of {*} with key 0x{x}", .{ item, key });
self.validate();
//log.debug("Validated before insertion of {*} with key 0x{x}", .{ item, key });
if (item.tree != null) {
kernel.panic("item with key 0x{x} already in tree {*}", .{ key, item.tree });
}
item.tree = self;
item.key = key;
item.children[0] = null;
item.children[1] = null;
item.value = item_value;
item.height = 1;
var link = &self.root;
var parent: ?*Item = null;
while (true) {
if (link.*) |node| {
if (item.compare(node) == 0) {
if (duplicate_key_policy == .panic) @panic("avl duplicate panic") else if (duplicate_key_policy == .fail) return false;
}
const child_index = @boolToInt(item.compare(node) > 0);
link = &node.children[child_index];
parent = node;
} else {
link.* = item;
item.parent = parent;
break;
}
}
var fake_root = kernel.zeroes(Item);
self.root.?.parent = &fake_root;
fake_root.tree = self;
fake_root.children[0] = self.root;
var item_it = item.parent.?;
while (item_it != &fake_root) {
const left_height = if (item_it.children[0]) |left| left.height else 0;
const right_height = if (item_it.children[1]) |right| right.height else 0;
const balance = left_height - right_height;
item_it.height = 1 + if (balance > 0) left_height else right_height;
var new_root: ?*Item = null;
var old_parent = item_it.parent.?;
if (balance > 1 and Item.compare_keys(key, item_it.children[0].?.key) <= 0) {
const right_rotation = item_it.rotate_right();
new_root = right_rotation;
const old_parent_child_index = @boolToInt(old_parent.children[1] == item_it);
old_parent.children[old_parent_child_index] = right_rotation;
} else if (balance > 1 and Item.compare_keys(key, item_it.children[0].?.key) > 0 and item_it.children[0].?.children[1] != null) {
item_it.children[0] = item_it.children[0].?.rotate_left();
item_it.children[0].?.parent = item_it;
const right_rotation = item_it.rotate_right();
new_root = right_rotation;
const old_parent_child_index = @boolToInt(old_parent.children[1] == item_it);
old_parent.children[old_parent_child_index] = right_rotation;
} else if (balance < -1 and Item.compare_keys(key, item_it.children[1].?.key) > 0) {
const left_rotation = item_it.rotate_left();
new_root = left_rotation;
const old_parent_child_index = @boolToInt(old_parent.children[1] == item_it);
old_parent.children[old_parent_child_index] = left_rotation;
} else if (balance < -1 and Item.compare_keys(key, item_it.children[1].?.key) <= 0 and item_it.children[1].?.children[0] != null) {
item_it.children[1] = item_it.children[1].?.rotate_right();
item_it.children[1].?.parent = item_it;
const left_rotation = item_it.rotate_left();
new_root = left_rotation;
const old_parent_child_index = @boolToInt(old_parent.children[1] == item_it);
old_parent.children[old_parent_child_index] = left_rotation;
}
if (new_root) |new_root_unwrapped| new_root_unwrapped.parent = old_parent;
item_it = old_parent;
}
self.root = fake_root.children[0];
self.root.?.parent = null;
self.validate();
return true;
}
pub fn find(self: *@This(), key: Key, search_mode: SearchMode) ?*Item {
if (self.modcheck) @panic("concurrent access");
self.validate();
return self.find_recursive(self.root, key, search_mode);
}
pub fn find_recursive(self: *@This(), maybe_root: ?*Item, key: Key, search_mode: SearchMode) ?*Item {
if (maybe_root) |root| {
if (Item.compare_keys(root.key, key) == 0) return root;
switch (search_mode) {
.exact => return self.find_recursive(root.children[0], key, search_mode),
.smallest_above_or_equal => {
if (Item.compare_keys(root.key, key) > 0) {
if (self.find_recursive(root.children[0], key, search_mode)) |item| return item else return root;
} else return self.find_recursive(root.children[1], key, search_mode);
},
.largest_below_or_equal => {
if (Item.compare_keys(root.key, key) < 0) {
if (self.find_recursive(root.children[1], key, search_mode)) |item| return item else return root;
} else return self.find_recursive(root.children[0], key, search_mode);
},
}
} else {
return null;
}
}
pub fn remove(self: *@This(), item: *Item) void {
if (self.modcheck) @panic("concurrent modification");
self.modcheck = true;
defer self.modcheck = false;
self.validate();
if (item.tree != self) @panic("item not in tree");
var fake_root = kernel.zeroes(Item);
self.root.?.parent = &fake_root;
fake_root.tree = self;
fake_root.children[0] = self.root;
if (item.children[0] != null and item.children[1] != null) {
const smallest = 0;
const a = self.find_recursive(item.children[1], smallest, .smallest_above_or_equal).?;
const b = item;
a.swap(b);
}
var link = &item.parent.?.children[@boolToInt(item.parent.?.children[1] == item)];
link.* = if (item.children[0]) |left| left else item.children[1];
item.tree = null;
var item_it = blk: {
if (link.*) |link_u| {
link_u.parent = item.parent;
break :blk link.*.?;
} else break :blk item.parent.?;
};
while (item_it != &fake_root) {
const left_height = if (item_it.children[0]) |left| left.height else 0;
const right_height = if (item_it.children[1]) |right| right.height else 0;
const balance = left_height - right_height;
item_it.height = 1 + if (balance > 0) left_height else right_height;
var new_root: ?*Item = null;
var old_parent = item_it.parent.?;
if (balance > 1) {
const left_balance = if (item_it.children[0]) |left| left.get_balance() else 0;
if (left_balance >= 0) {
const right_rotation = item_it.rotate_right();
new_root = right_rotation;
const old_parent_child_index = @boolToInt(old_parent.children[1] == item_it);
old_parent.children[old_parent_child_index] = right_rotation;
} else {
item_it.children[0] = item_it.children[0].?.rotate_left();
item_it.children[0].?.parent = item_it;
const right_rotation = item_it.rotate_right();
new_root = right_rotation;
const old_parent_child_index = @boolToInt(old_parent.children[1] == item_it);
old_parent.children[old_parent_child_index] = right_rotation;
}
} else if (balance < -1) {
const right_balance = if (item_it.children[1]) |left| left.get_balance() else 0;
if (right_balance <= 0) {
const left_rotation = item_it.rotate_left();
new_root = left_rotation;
const old_parent_child_index = @boolToInt(old_parent.children[1] == item_it);
old_parent.children[old_parent_child_index] = left_rotation;
} else {
item_it.children[1] = item_it.children[1].?.rotate_right();
item_it.children[1].?.parent = item_it;
const left_rotation = item_it.rotate_left();
new_root = left_rotation;
const old_parent_child_index = @boolToInt(old_parent.children[1] == item_it);
old_parent.children[old_parent_child_index] = left_rotation;
}
}
if (new_root) |new_root_unwrapped| new_root_unwrapped.parent = old_parent;
item_it = old_parent;
}
self.root = fake_root.children[0];
if (self.root) |root| {
if (root.parent != &fake_root) @panic("incorrect root parent");
root.parent = null;
}
self.validate();
}
fn validate(self: *@This()) void {
//log.debug("Validating tree: {*}", .{self});
if (self.root) |root| {
//log.debug("Root: {*}", .{root});
_ = root.validate(self, null);
}
//log.debug("Validated tree: {*}", .{self});
}
pub const Item = struct {
value: ?*T = null,
children: [2]?*Item = [_]?*Item{ null, null },
parent: ?*Item = null,
tree: ?*Self = null,
key: Key = 0,
height: i32 = 0,
fn rotate_left(self: *@This()) *Item {
const x = self;
const y = x.children[1].?;
const maybe_t = y.children[0];
y.children[0] = x;
x.children[1] = maybe_t;
x.parent = y;
if (maybe_t) |t| t.parent = x;
{
const left_height = if (x.children[0]) |left| left.height else 0;
const right_height = if (x.children[1]) |right| right.height else 0;
const balance = left_height - right_height;
x.height = 1 + if (balance > 0) left_height else right_height;
}
{
const left_height = if (y.children[0]) |left| left.height else 0;
const right_height = if (y.children[1]) |right| right.height else 0;
const balance = left_height - right_height;
y.height = 1 + if (balance > 0) left_height else right_height;
}
return y;
}
fn rotate_right(self: *@This()) *Item {
const y = self;
const x = y.children[0].?;
const maybe_t = x.children[1];
x.children[1] = y;
y.children[0] = maybe_t;
y.parent = x;
if (maybe_t) |t| t.parent = y;
{
const left_height = if (y.children[0]) |left| left.height else 0;
const right_height = if (y.children[1]) |right| right.height else 0;
const balance = left_height - right_height;
y.height = 1 + if (balance > 0) left_height else right_height;
}
{
const left_height = if (x.children[0]) |left| left.height else 0;
const right_height = if (x.children[1]) |right| right.height else 0;
const balance = left_height - right_height;
x.height = 1 + if (balance > 0) left_height else right_height;
}
return x;
}
fn swap(self: *@This(), other: *@This()) void {
self.parent.?.children[@boolToInt(self.parent.?.children[1] == self)] = other;
other.parent.?.children[@boolToInt(other.parent.?.children[1] == other)] = self;
var temporal_self = self.*;
var temporal_other = other.*;
self.parent = temporal_other.parent;
other.parent = temporal_self.parent;
self.height = temporal_other.height;
other.height = temporal_self.height;
self.children[0] = temporal_other.children[0];
self.children[1] = temporal_other.children[1];
other.children[0] = temporal_self.children[0];
other.children[1] = temporal_self.children[1];
if (self.children[0]) |a_left| a_left.parent = self;
if (self.children[1]) |a_right| a_right.parent = self;
if (other.children[0]) |b_left| b_left.parent = other;
if (other.children[1]) |b_right| b_right.parent = other;
}
fn get_balance(self: *@This()) i32 {
const left_height = if (self.children[0]) |left| left.height else 0;
const right_height = if (self.children[1]) |right| right.height else 0;
return left_height - right_height;
}
fn validate(self: *@This(), tree: *Self, parent: ?*@This()) i32 {
//log.debug("Validating node with key 0x{x}", .{self.key});
if (self.parent != parent) kernel.panic("Expected parent: {*}, got parent: {*}", .{ parent, self.parent });
if (self.tree != tree) kernel.panic("Expected tree: {*}, got tree: {*}", .{ tree, self.tree });
const left_height = blk: {
if (self.children[0]) |left| {
if (left.compare(self) > 0) @panic("invalid tree");
break :blk left.validate(tree, self);
} else {
break :blk @as(i32, 0);
}
};
const right_height = blk: {
if (self.children[1]) |right| {
if (right.compare(self) < 0) @panic("invalid tree");
break :blk right.validate(tree, self);
} else {
break :blk @as(i32, 0);
}
};
const height = 1 + if (left_height > right_height) left_height else right_height;
if (height != self.height) @panic("invalid tree");
//log.debug("Validated node {*}", .{self});
return height;
}
fn compare(self: *@This(), other: *@This()) i32 {
return compare_keys(self.key, other.key);
}
fn compare_keys(key1: u64, key2: u64) i32 {
if (key1 < key2) return -1;
if (key1 > key2) return 1;
return 0;
}
};
};
}
|
src/kernel/avl.zig
|
const std = @import("std");
const assert = std.debug.assert;
const io = std.io;
const mem = std.mem;
const os = std.os;
const build_options = @import("build_options");
const builtin = @import("builtin");
const Lock = @import("Lock.zig");
const flags = @import("flags.zig");
const usage =
\\usage: waylock [options]
\\
\\ -h Print this help message and exit.
\\ -version Print the version number and exit.
\\ -log-level <level> Set the log level to error, warning, info, or debug.
\\
\\ -init-color 0xRRGGBB Set the initial color.
\\ -input-color 0xRRGGBB Set the color used after input.
\\ -fail-color 0xRRGGBB Set the color used on authentication failure.
\\
;
pub fn main() void {
// TODO clean up these two lines after zig 0.10
const argv = os.argv;
const args = if (argv.len != 0) argv[1..] else @as([][*:0]const u8, &[_][*:0]const u8{});
const result = flags.parse(args, &[_]flags.Flag{
.{ .name = "-h", .kind = .boolean },
.{ .name = "-version", .kind = .boolean },
.{ .name = "-log-level", .kind = .arg },
.{ .name = "-init-color", .kind = .arg },
.{ .name = "-input-color", .kind = .arg },
.{ .name = "-fail-color", .kind = .arg },
}) catch {
io.getStdErr().writeAll(usage) catch {};
os.exit(1);
};
if (result.boolFlag("-h")) {
io.getStdOut().writeAll(usage) catch os.exit(1);
os.exit(0);
}
if (result.args.len != 0) {
std.log.err("unknown option '{s}'", .{result.args[0]});
io.getStdErr().writeAll(usage) catch {};
os.exit(1);
}
if (result.boolFlag("-version")) {
io.getStdOut().writeAll(build_options.version ++ "\n") catch os.exit(1);
os.exit(0);
}
if (result.argFlag("-log-level")) |level| {
if (mem.eql(u8, level, "error")) {
runtime_log_level = .err;
} else if (mem.eql(u8, level, "warning")) {
runtime_log_level = .warn;
} else if (mem.eql(u8, level, "info")) {
runtime_log_level = .info;
} else if (mem.eql(u8, level, "debug")) {
runtime_log_level = .debug;
} else {
std.log.err("invalid log level '{s}'", .{level});
os.exit(1);
}
}
var options: Lock.Options = .{};
if (result.argFlag("-init-color")) |raw| options.init_color = parse_color(raw);
if (result.argFlag("-input-color")) |raw| options.input_color = parse_color(raw);
if (result.argFlag("-fail-color")) |raw| options.fail_color = parse_color(raw);
Lock.run(options);
}
fn parse_color(raw: []const u8) u32 {
if (raw.len != 8) fatal_bad_color(raw);
if (!mem.eql(u8, raw[0..2], "0x")) fatal_bad_color(raw);
const rgb = std.fmt.parseUnsigned(u32, raw[2..], 16) catch fatal_bad_color(raw);
const argb = 0xff000000 | rgb;
return argb;
}
fn fatal_bad_color(raw: []const u8) noreturn {
std.log.err("invalid color '{s}', expected format '0xRRGGBB'", .{raw});
os.exit(1);
}
/// Tell std.log to leave all log level filtering to us.
pub const log_level: std.log.Level = .debug;
/// Set the default log level based on the build mode.
var runtime_log_level: std.log.Level = switch (builtin.mode) {
.Debug => .debug,
.ReleaseSafe, .ReleaseFast, .ReleaseSmall => .err,
};
pub fn log(
comptime level: std.log.Level,
comptime scope: @TypeOf(.EnumLiteral),
comptime format: []const u8,
args: anytype,
) void {
// waylock is small enough that we don't need scopes
comptime assert(scope == .default);
if (@enumToInt(level) > @enumToInt(runtime_log_level)) return;
const stderr = io.getStdErr().writer();
stderr.print(level.asText() ++ ": " ++ format ++ "\n", args) catch {};
}
|
src/main.zig
|
const std = @import("std");
const ehdr = @import("../data-structures/ehdr.zig");
const ELF = @import("../elf.zig");
fn ehdrParse64(elf: ELF.ELF) !ehdr.Ehdr {
try elf.file.seekableStream().seekTo(0x00);
var ehdr1: std.elf.Elf64_Ehdr = undefined;
const stream = elf.file.reader();
try stream.readNoEof(std.mem.asBytes(&ehdr1));
// return try parse_source.reader().readstruct(std.elf.elf64_ehdr);
var a = @enumToInt(ehdr1.e_type);
var b = @enumToInt(ehdr1.e_machine);
return ehdr.Ehdr{
.identity = ehdr1.e_ident,
.etype = @intToEnum(ehdr.e_type, a),
.machine = @intToEnum(ehdr.e_machine, b),
.version = ehdr1.e_version,
.entry = ehdr1.e_entry,
.phoff = ehdr1.e_phoff,
.shoff = ehdr1.e_shoff,
.flags = ehdr1.e_flags,
.ehsize = ehdr1.e_ehsize,
.phentsize = ehdr1.e_phentsize,
.phnum = ehdr1.e_phnum,
.shentsize = ehdr1.e_shentsize,
.shnum = ehdr1.e_shnum,
.shstrndx = ehdr1.e_shstrndx,
};
}
fn ehdrParse32(elf: ELF.ELF) !ehdr.Ehdr {
try elf.file.seekableStream().seekTo(0x00);
var ehdr1: std.elf.Elf32_Ehdr = undefined;
const stream = elf.file.reader();
try stream.readNoEof(std.mem.asBytes(&ehdr));
// return try parse_source.reader().readstruct(std.elf.elf64_ehdr);
var a = @enumToInt(ehdr1.e_type);
var b = @enumToInt(ehdr1.e_machine);
return ehdr.Ehdr{
.identity = ehdr1.e_ident,
.etype = @intToEnum(ehdr.Elf64_Ehdr.e_type, a),
.machine = @intToEnum(ehdr.Elf64_Ehdr.e_machine, b),
.version = ehdr1.e_version,
.entry = ehdr1.e_entry,
.phoff = ehdr1.e_phoff,
.shoff = ehdr1.e_shoff,
.flags = ehdr1.e_flags,
.ehsize = ehdr1.e_ehsize,
.phentsize = ehdr1.e_phentsize,
.phnum = ehdr1.e_phnum,
.shentsize = ehdr1.e_shentsize,
.shnum = ehdr1.e_shnum,
.shstrndx = ehdr1.e_shstrndx,
};
}
pub fn ehdrParse(elf: ELF.ELF) !ehdr.Ehdr {
if (!elf.is32) {
return ehdrParse64(elf);
} else {
return ehdrParse64(elf);
}
}
// convert high level ehdr to packed struct, easy writing! Am i stupid? possibly
fn ehdrToPacked32(a: ELF.ELF) ehdr.Elf32_Ehdr {
var ehdr2: ehdr.Elf32_Ehdr = undefined;
ehdr2.e_ident = a.ehdr.identity;
ehdr2.e_type = a.ehdr.etype;
ehdr2.e_machine = a.ehdr.machine;
ehdr2.e_version = @intCast(std.elf.Elf32_Word, a.ehdr.version);
ehdr2.e_entry = @intCast(std.elf.Elf32_Addr, a.ehdr.entry);
ehdr2.e_phoff = @intCast(std.elf.Elf32_Off, a.ehdr.phoff);
ehdr2.e_shoff = @intCast(std.elf.Elf32_Off, a.ehdr.shoff);
ehdr2.e_flags = @intCast(std.elf.Elf32_Word, a.ehdr.flags);
ehdr2.e_ehsize = @intCast(std.elf.Elf32_Half, a.ehdr.ehsize);
ehdr2.e_phentsize = @intCast(std.elf.Elf32_Half, a.ehdr.phentsize);
ehdr2.e_phnum = @intCast(std.elf.Elf32_Half, ehdr2.e_phnum);
ehdr2.e_shentsize = @intCast(std.elf.Elf32_Half, a.ehdr.shentsize);
ehdr2.e_shnum = @intCast(std.elf.Elf32_Half, a.ehdr.shnum);
ehdr2.e_shstrndx = @intCast(std.elf.Elf32_Half, ehdr2.e_shstrndx);
return ehdr2;
}
fn ehdrToPacked64(a: ELF.ELF) ehdr.Elf64_Ehdr {
var ehdr2: ehdr.Elf64_Ehdr = undefined;
ehdr2.e_ident = a.ehdr.identity;
ehdr2.e_type = a.ehdr.etype;
ehdr2.e_machine = a.ehdr.machine;
ehdr2.e_version = @intCast(std.elf.Elf64_Word, a.ehdr.version);
ehdr2.e_entry = @intCast(std.elf.Elf64_Addr, a.ehdr.entry);
ehdr2.e_phoff = @intCast(std.elf.Elf64_Off, a.ehdr.phoff);
ehdr2.e_shoff = @intCast(std.elf.Elf64_Off, a.ehdr.shoff);
ehdr2.e_flags = @intCast(std.elf.Elf64_Word, a.ehdr.flags);
ehdr2.e_ehsize = @intCast(std.elf.Elf64_Half, a.ehdr.ehsize);
ehdr2.e_phentsize = @intCast(std.elf.Elf64_Half, a.ehdr.phentsize);
ehdr2.e_phnum = @intCast(std.elf.Elf64_Half, a.ehdr.phnum);
ehdr2.e_shentsize = @intCast(std.elf.Elf64_Half, a.ehdr.shentsize);
ehdr2.e_shnum = @intCast(std.elf.Elf64_Half, a.ehdr.shnum);
ehdr2.e_shstrndx = @intCast(std.elf.Elf64_Half, a.ehdr.shstrndx);
return ehdr2;
}
pub fn writeEhdr(a: ELF.ELF) !void {
try a.file.seekableStream().seekTo(0x00);
// ehdr to ;acked struct
if (!a.is32) {
var ehdr2 = ehdrToPacked64(a);
std.log.info("ehdr2{}\n", .{ehdr2});
try a.file.writer().writeStruct(ehdr2);
} else {
var ehdr2 = ehdrToPacked32(a);
std.log.info("ehdr2{}\n", .{ehdr2});
try a.file.writer().writeStruct(ehdr2);
}
}
|
src/functions/ehdr.zig
|
const std = @import("std");
const Allocator = std.mem.Allocator;
const List = std.ArrayList;
const Map = std.AutoHashMap;
const StrMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
const Str = []const u8;
const Set = Map(usize, void);
const util = @import("util.zig");
const gpa = util.gpa;
// const data = @embedFile("../data/day15-tst.txt");
const data = @embedFile("../data/day15.txt");
var grid: List(u8) = undefined;
var width: usize = 0;
var height: usize = 0;
pub fn main() !void {
var initial_grid = List(u8).init(gpa);
var it = tokenize(u8, data, "\r\n");
width = 0;
height = 0;
while (it.next()) |line| : (height += 1) {
width = line.len;
for (line) |c| {
try initial_grid.append(c - '0');
}
}
// Part1
// grid = expandMap(initial_grid.items[0..], &width, &height, 1);
// Part2
grid = expandMap(initial_grid.items[0..], &width, &height, 5);
// Dijkstra
var visited = Set.init(gpa);
var queue = std.PriorityQueue([2]usize, lessThan).init(gpa);
try queue.add([2]usize{ 0, 0 });
while (queue.count() > 0) {
var nextv = queue.remove();
var next = nextv[0];
var cost = nextv[1];
if (visited.contains(next)) continue;
try visited.put(next, {});
if (next == (width * height - 1)) {
print("{}\n", .{cost});
break;
}
var buffer = [_]usize{0} ** 4;
var neighbors = util.getNeighborIndices(next, width, height, buffer[0..]);
for (neighbors) |idx| {
var neighbor_cost = grid.items[idx];
try queue.add([2]usize{ idx, cost + neighbor_cost });
}
}
}
fn nextToVisit(distances: []usize, visitable: Set, visited: Set) usize {
var minv: usize = std.math.maxInt(usize);
var mini: usize = 0;
var it = visitable.keyIterator();
while (it.next()) |i| {
if (!visited.contains(i.*) and minv > distances[i.*]) {
mini = i.*;
minv = distances[i.*];
}
}
return mini;
}
fn lessThan(a: [2]usize, b: [2]usize) std.math.Order {
return std.math.order(a[1], b[1]);
}
fn expandMap(initial_grid: []u8, w: *usize, h: *usize, mult: usize) List(u8) {
var new_w = w.* * mult;
var new_h = h.* * mult;
var new_grid = List(u8).init(gpa);
new_grid.resize(new_w * new_h) catch unreachable;
var j: usize = 0;
while (j < h.*) : (j += 1) {
var i: usize = 0;
while (i < w.*) : (i += 1) {
var value = initial_grid[i + j * w.*];
for (util.range(mult)) |_, n| {
var new_value_y = value + @intCast(u8, n);
if (new_value_y > 9) new_value_y = @mod(new_value_y, 10) + 1;
for (util.range(mult)) |_, m| {
var new_value_x = new_value_y + @intCast(u8, m);
if (new_value_x > 9) new_value_x = @mod(new_value_x, 10) + 1;
var x = i + m * w.*;
var y = j + n * h.*;
new_grid.items[x + y * new_w] = new_value_x;
}
}
}
}
w.* = new_w;
h.* = new_h;
return new_grid;
}
// Useful stdlib functions
const tokenize = std.mem.tokenize;
const split = std.mem.split;
const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear;
const lastIndexOf = std.mem.lastIndexOfScalar;
const lastIndexOfAny = std.mem.lastIndexOfAny;
const lastIndexOfStr = std.mem.lastIndexOfLinear;
const trim = std.mem.trim;
const sliceMin = std.mem.min;
const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat;
const min = std.math.min;
const min3 = std.math.min3;
const max = std.math.max;
const max3 = std.math.max3;
const print = std.debug.print;
const assert = std.debug.assert;
const sort = std.sort.sort;
const asc = std.sort.asc;
const desc = std.sort.desc;
|
src/day15.zig
|
const std = @import("std");
const Map = @import("./map.zig").Map;
pub fn main() !void {
const out = std.io.getStdOut().writer();
const inp = std.io.getStdIn().reader();
var buf: [20480]u8 = undefined;
var count: u32 = 0;
while (try inp.readUntilDelimiterOrEof(&buf, '\n')) |line| {
count += 1;
var map = Map.init(0, 50, 100, 100, line);
defer map.deinit();
var p: Map.Pos = undefined;
var t: Map.Tile = undefined;
var yl: usize = 100;
var xl = map.find_first_pulled(yl);
p = Map.Pos.init(xl + 99, yl - 99);
t = map.run_for_one_point(p);
std.debug.warn("L: {} {} -- opposite {} {} {}\n", .{ xl, yl, p.x, p.y, t });
var yh: usize = 1500;
var xh = map.find_first_pulled(yh);
p = Map.Pos.init(xh + 99, yh - 99);
t = map.run_for_one_point(p);
std.debug.warn("H: {} {} -- opposite {} {} {}\n", .{ xh, yh, p.x, p.y, t });
while (yl <= yh) {
var ym: usize = (yl + yh) / 2;
var xm = map.find_first_pulled(ym);
p = Map.Pos.init(xm + 99, ym - 99);
t = map.run_for_one_point(p);
std.debug.warn("M: {} {} -- opposite {} {} {}\n", .{ xm, ym, p.x, p.y, t });
if (t == Map.Tile.Pulled) {
yh = ym - 1;
} else {
yl = ym + 1;
}
}
// if (t != Map.Tile.Pulled) yl += 1;
xl = map.find_first_pulled(yl);
p = Map.Pos.init(xl, yl);
t = map.run_for_one_point(p);
std.debug.warn("BL: {} {} {}\n", .{ p.x, p.y, t });
p = Map.Pos.init(xl + 99, yl - 99);
t = map.run_for_one_point(p);
std.debug.warn("TR: {} {} {}\n", .{ p.x, p.y, t });
p = Map.Pos.init(xl + 99, yl);
t = map.run_for_one_point(p);
std.debug.warn("BR: {} {} {}\n", .{ p.x, p.y, t });
p = Map.Pos.init(xl, yl - 99);
t = map.run_for_one_point(p);
std.debug.warn("TL: {} {} {}\n", .{ p.x, p.y, t });
p = Map.Pos.init(xl, yl - 99);
std.debug.warn("TL encoded: {}\n", .{p.x * 10000 + p.y});
}
try out.print("Read {} lines\n", .{count});
}
|
2019/p19/p19b.zig
|
const std = @import("std");
const fs = std.fs;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = &gpa.allocator;
const input = try fs.cwd().readFileAlloc(allocator, "data/input_13_1.txt", std.math.maxInt(usize));
var lines = std.mem.tokenize(input, "\n");
var times = std.ArrayList(u64).init(allocator);
var diffs = std.ArrayList(u64).init(allocator);
defer times.deinit();
const timestamp = try std.fmt.parseInt(u64, std.mem.trim(u8, (lines.next().?), " \r\n"), 10);
{
const times_line = std.mem.trim(u8, (lines.next().?), " \r\n");
var times_it = std.mem.tokenize(times_line, ",");
var diff: u64 = 0;
while (times_it.next()) |it| {
diff += 1;
if (it.len == 1 and it[0] == 'x') continue;
try times.append(try std.fmt.parseInt(u64, it, 10));
try diffs.append(diff - 1);
}
}
{ // Solution 1
var closest_time = timestamp;
outer: while (true) {
for (times.items) |id| {
const mod = @mod(closest_time, id);
if (mod == 0) {
const wait = closest_time - timestamp;
std.debug.print("Day 13 - Solution 1: {}\n", .{wait * id});
break :outer;
}
}
closest_time += 1;
}
}
{ // Solution 2
var offset: usize = 0;
var mul: usize = 1;
var result: usize = 0;
{ var i: usize = 1; while (true) : (i += 1) {
var count: usize = 1;
while (true) {
result = times.items[0] * (offset + mul * count);
if (@mod(result + diffs.items[i], times.items[i]) == 0) {
break;
}
count += 1;
}
if (i < times.items.len - 1) {
offset += count * mul;
mul *= times.items[i];
} else break;
}}
std.debug.print("Day 13 - Solution 2: {}\n", .{result});
}
}
|
2020/src/day_13.zig
|
const std = @import("std");
const sdl = @import("sdl");
const imgui = @import("imgui");
const imgui_impl = @import("imgui/implementation.zig");
pub const input_types = @import("input_types.zig");
pub const renderkit = @import("renderkit");
pub const utils = @import("utils/utils.zig");
pub const math = @import("math/math.zig");
const Gfx = @import("gfx.zig").Gfx;
const Window = @import("window.zig").Window;
pub const WindowConfig = @import("window.zig").WindowConfig;
const Input = @import("input.zig").Input;
const Time = @import("time.zig").Time;
pub const Config = struct {
init: fn () anyerror!void,
update: ?fn () anyerror!void = null,
render: fn () anyerror!void,
shutdown: ?fn () anyerror!void = null,
window: WindowConfig = WindowConfig{},
update_rate: f64 = 60, // desired fps
imgui_icon_font: bool = true,
imgui_viewports: bool = false, // whether imgui viewports should be enabled
imgui_docking: bool = true, // whether imgui docking should be enabled
};
// search path: root.build_options, root.enable_imgui, default to false
pub const enable_imgui: bool = if (@hasDecl(@import("root"), "build_options"))
blk: {
break :blk @field(@import("root"), "build_options").enable_imgui;
} else if (@hasDecl(@import("root"), "enable_imgui"))
blk: {
break :blk @field(@import("root"), "enable_imgui");
} else blk: {
break :blk false;
};
pub const gfx = @import("gfx.zig");
pub var window: Window = undefined;
pub var time: Time = undefined;
pub var input: Input = undefined;
pub fn run(config: Config) !void {
window = try Window.init(config.window);
var metal_setup = renderkit.MetalSetup{};
if (renderkit.current_renderer == .metal) {
var metal_view = sdl.SDL_Metal_CreateView(window.sdl_window);
metal_setup.ca_layer = sdl.SDL_Metal_GetLayer(metal_view);
}
var allocator = std.testing.allocator;
renderkit.renderer.setup(.{
.allocator = &allocator,
.gl_loader = sdl.SDL_GL_GetProcAddress,
.disable_vsync = config.window.disable_vsync,
.metal = metal_setup,
});
gfx.init();
time = Time.init(config.update_rate);
input = Input.init(window.scale());
if (enable_imgui) imgui_impl.init(window.sdl_window, config.imgui_docking, config.imgui_viewports, config.imgui_icon_font);
try config.init();
while (!pollEvents()) {
time.tick();
if (config.update) |update| try update();
try config.render();
if (enable_imgui) {
gfx.beginPass(.{ .color_action = .load });
imgui_impl.render();
gfx.endPass();
if (renderkit.current_renderer == .opengl) _ = sdl.SDL_GL_MakeCurrent(window.sdl_window, window.gl_ctx);
}
if (renderkit.current_renderer == .opengl) sdl.SDL_GL_SwapWindow(window.sdl_window);
gfx.commitFrame();
input.newFrame();
}
if (enable_imgui) imgui_impl.deinit();
if (config.shutdown) |shutdown| try shutdown();
gfx.deinit();
renderkit.renderer.shutdown();
window.deinit();
sdl.SDL_Quit();
}
fn pollEvents() bool {
var event: sdl.SDL_Event = undefined;
while (sdl.SDL_PollEvent(&event) != 0) {
if (enable_imgui and imgui_impl.handleEvent(&event)) continue;
switch (event.type) {
sdl.SDL_QUIT => return true,
sdl.SDL_WINDOWEVENT => {
if (event.window.windowID == window.id) {
if (event.window.event == sdl.SDL_WINDOWEVENT_CLOSE) return true;
window.handleEvent(&event.window);
}
},
else => input.handleEvent(&event),
}
}
// if ImGui is running we force a timer resync every frame. This ensures we get exactly one update call and one render call
// each frame which prevents ImGui from flickering due to skipped/doubled update calls.
if (enable_imgui) {
imgui_impl.newFrame();
time.resync();
}
return false;
}
|
gamekit/gamekit.zig
|
pub const ADMINDATA_MAX_NAME_LEN = @as(u32, 256);
pub const CLSID_MSAdminBase_W = Guid.initString("a9e69610-b80d-11d0-b9b9-00a0c922e750");
pub const IMGCHG_SIZE = @as(u32, 1);
pub const IMGCHG_VIEW = @as(u32, 2);
pub const IMGCHG_COMPLETE = @as(u32, 4);
pub const IMGCHG_ANIMATE = @as(u32, 8);
pub const IMGCHG_MASK = @as(u32, 15);
pub const IMGLOAD_NOTLOADED = @as(u32, 1048576);
pub const IMGLOAD_LOADING = @as(u32, 2097152);
pub const IMGLOAD_STOPPED = @as(u32, 4194304);
pub const IMGLOAD_ERROR = @as(u32, 8388608);
pub const IMGLOAD_COMPLETE = @as(u32, 16777216);
pub const IMGLOAD_MASK = @as(u32, 32505856);
pub const IMGBITS_NONE = @as(u32, 33554432);
pub const IMGBITS_PARTIAL = @as(u32, 67108864);
pub const IMGBITS_TOTAL = @as(u32, 134217728);
pub const IMGBITS_MASK = @as(u32, 234881024);
pub const IMGANIM_ANIMATED = @as(u32, 268435456);
pub const IMGANIM_MASK = @as(u32, 268435456);
pub const IMGTRANS_OPAQUE = @as(u32, 536870912);
pub const IMGTRANS_MASK = @as(u32, 536870912);
pub const DWN_COLORMODE = @as(u32, 63);
pub const DWN_DOWNLOADONLY = @as(u32, 64);
pub const DWN_FORCEDITHER = @as(u32, 128);
pub const DWN_RAWIMAGE = @as(u32, 256);
pub const DWN_MIRRORIMAGE = @as(u32, 512);
pub const CLSID_IImgCtx = Guid.initString("3050f3d6-98b5-11cf-bb82-00aa00bdce0b");
pub const IIS_MD_ADSI_METAID_BEGIN = @as(u32, 130000);
pub const IIS_MD_UT_SERVER = @as(u32, 1);
pub const IIS_MD_UT_FILE = @as(u32, 2);
pub const IIS_MD_UT_WAM = @as(u32, 100);
pub const ASP_MD_UT_APP = @as(u32, 101);
pub const IIS_MD_UT_END_RESERVED = @as(u32, 2000);
pub const IIS_MD_ID_BEGIN_RESERVED = @as(u32, 1);
pub const IIS_MD_ID_END_RESERVED = @as(u32, 32767);
pub const ASP_MD_ID_BEGIN_RESERVED = @as(u32, 28672);
pub const ASP_MD_ID_END_RESERVED = @as(u32, 29951);
pub const WAM_MD_ID_BEGIN_RESERVED = @as(u32, 29952);
pub const WAM_MD_ID_END_RESERVED = @as(u32, 32767);
pub const FP_MD_ID_BEGIN_RESERVED = @as(u32, 32768);
pub const FP_MD_ID_END_RESERVED = @as(u32, 36863);
pub const SMTP_MD_ID_BEGIN_RESERVED = @as(u32, 36864);
pub const SMTP_MD_ID_END_RESERVED = @as(u32, 40959);
pub const POP3_MD_ID_BEGIN_RESERVED = @as(u32, 40960);
pub const POP3_MD_ID_END_RESERVED = @as(u32, 45055);
pub const NNTP_MD_ID_BEGIN_RESERVED = @as(u32, 45056);
pub const NNTP_MD_ID_END_RESERVED = @as(u32, 49151);
pub const IMAP_MD_ID_BEGIN_RESERVED = @as(u32, 49152);
pub const IMAP_MD_ID_END_RESERVED = @as(u32, 53247);
pub const MSCS_MD_ID_BEGIN_RESERVED = @as(u32, 53248);
pub const MSCS_MD_ID_END_RESERVED = @as(u32, 57343);
pub const APPCTR_MD_ID_BEGIN_RESERVED = @as(u32, 57344);
pub const APPCTR_MD_ID_END_RESERVED = @as(u32, 61439);
pub const USER_MD_ID_BASE_RESERVED = @as(u32, 65535);
pub const IIS_MD_SERVER_BASE = @as(u32, 1000);
pub const MD_MAX_BANDWIDTH = @as(u32, 1000);
pub const MD_KEY_TYPE = @as(u32, 1002);
pub const MD_MAX_BANDWIDTH_BLOCKED = @as(u32, 1003);
pub const MD_SCHEMA_METAID = @as(u32, 1004);
pub const MD_SERVER_COMMAND = @as(u32, 1012);
pub const MD_CONNECTION_TIMEOUT = @as(u32, 1013);
pub const MD_MAX_CONNECTIONS = @as(u32, 1014);
pub const MD_SERVER_COMMENT = @as(u32, 1015);
pub const MD_SERVER_STATE = @as(u32, 1016);
pub const MD_SERVER_AUTOSTART = @as(u32, 1017);
pub const MD_SERVER_SIZE = @as(u32, 1018);
pub const MD_SERVER_LISTEN_BACKLOG = @as(u32, 1019);
pub const MD_SERVER_LISTEN_TIMEOUT = @as(u32, 1020);
pub const MD_DOWNLEVEL_ADMIN_INSTANCE = @as(u32, 1021);
pub const MD_LEVELS_TO_SCAN = @as(u32, 1022);
pub const MD_SERVER_BINDINGS = @as(u32, 1023);
pub const MD_MAX_ENDPOINT_CONNECTIONS = @as(u32, 1024);
pub const MD_SERVER_CONFIGURATION_INFO = @as(u32, 1027);
pub const MD_IISADMIN_EXTENSIONS = @as(u32, 1028);
pub const MD_DISABLE_SOCKET_POOLING = @as(u32, 1029);
pub const MD_METADATA_ID_REGISTRATION = @as(u32, 1030);
pub const IIS_MD_HTTP_BASE = @as(u32, 2000);
pub const MD_SECURE_BINDINGS = @as(u32, 2021);
pub const MD_BINDINGS = @as(u32, 2022);
pub const MD_ENABLEDPROTOCOLS = @as(u32, 2023);
pub const MD_FILTER_LOAD_ORDER = @as(u32, 2040);
pub const MD_FILTER_IMAGE_PATH = @as(u32, 2041);
pub const MD_FILTER_STATE = @as(u32, 2042);
pub const MD_FILTER_ENABLED = @as(u32, 2043);
pub const MD_FILTER_FLAGS = @as(u32, 2044);
pub const MD_FILTER_DESCRIPTION = @as(u32, 2045);
pub const MD_FILTER_ENABLE_CACHE = @as(u32, 2046);
pub const MD_ADV_NOTIFY_PWD_EXP_IN_DAYS = @as(u32, 2063);
pub const MD_ADV_CACHE_TTL = @as(u32, 2064);
pub const MD_NET_LOGON_WKS = @as(u32, 2065);
pub const MD_USE_HOST_NAME = @as(u32, 2066);
pub const MD_AUTH_CHANGE_FLAGS = @as(u32, 2068);
pub const MD_PROCESS_NTCR_IF_LOGGED_ON = @as(u32, 2070);
pub const MD_FRONTPAGE_WEB = @as(u32, 2072);
pub const MD_IN_PROCESS_ISAPI_APPS = @as(u32, 2073);
pub const MD_AUTH_CHANGE_URL = @as(u32, 2060);
pub const MD_AUTH_EXPIRED_URL = @as(u32, 2061);
pub const MD_AUTH_EXPIRED_UNSECUREURL = @as(u32, 2067);
pub const MD_ALLOW_PATH_INFO_FOR_SCRIPT_MAPPINGS = @as(u32, 2095);
pub const MD_APP_FRIENDLY_NAME = @as(u32, 2102);
pub const MD_APP_ROOT = @as(u32, 2103);
pub const MD_APP_ISOLATED = @as(u32, 2104);
pub const MD_APP_WAM_CLSID = @as(u32, 2105);
pub const MD_APP_PACKAGE_ID = @as(u32, 2106);
pub const MD_APP_PACKAGE_NAME = @as(u32, 2107);
pub const MD_APP_OOP_RECOVER_LIMIT = @as(u32, 2110);
pub const MD_APP_PERIODIC_RESTART_TIME = @as(u32, 2111);
pub const MD_APP_PERIODIC_RESTART_REQUESTS = @as(u32, 2112);
pub const MD_APP_PERIODIC_RESTART_SCHEDULE = @as(u32, 2113);
pub const MD_APP_SHUTDOWN_TIME_LIMIT = @as(u32, 2114);
pub const MD_ADMIN_INSTANCE = @as(u32, 2115);
pub const MD_NOT_DELETABLE = @as(u32, 2116);
pub const MD_APP_TRACE_URL_LIST = @as(u32, 2118);
pub const MD_CENTRAL_W3C_LOGGING_ENABLED = @as(u32, 2119);
pub const MD_CUSTOM_ERROR_DESC = @as(u32, 2120);
pub const MD_CAL_VC_PER_CONNECT = @as(u32, 2130);
pub const MD_CAL_AUTH_RESERVE_TIMEOUT = @as(u32, 2131);
pub const MD_CAL_SSL_RESERVE_TIMEOUT = @as(u32, 2132);
pub const MD_CAL_W3_ERROR = @as(u32, 2133);
pub const MD_CPU_CGI_ENABLED = @as(u32, 2140);
pub const MD_CPU_APP_ENABLED = @as(u32, 2141);
pub const MD_CPU_LIMITS_ENABLED = @as(u32, 2143);
pub const MD_CPU_RESET_INTERVAL = @as(u32, 2144);
pub const MD_CPU_LOGGING_INTERVAL = @as(u32, 2145);
pub const MD_CPU_LOGGING_OPTIONS = @as(u32, 2146);
pub const MD_CPU_CGI_LIMIT = @as(u32, 2148);
pub const MD_CPU_LIMIT_LOGEVENT = @as(u32, 2149);
pub const MD_CPU_LIMIT_PRIORITY = @as(u32, 2150);
pub const MD_CPU_LIMIT_PROCSTOP = @as(u32, 2151);
pub const MD_CPU_LIMIT_PAUSE = @as(u32, 2152);
pub const MD_SET_HOST_NAME = @as(u32, 2154);
pub const MD_CPU_DISABLE_ALL_LOGGING = @as(u32, 0);
pub const MD_CPU_ENABLE_ALL_PROC_LOGGING = @as(u32, 1);
pub const MD_CPU_ENABLE_CGI_LOGGING = @as(u32, 2);
pub const MD_CPU_ENABLE_APP_LOGGING = @as(u32, 4);
pub const MD_CPU_ENABLE_EVENT = @as(u32, 1);
pub const MD_CPU_ENABLE_PROC_TYPE = @as(u32, 2);
pub const MD_CPU_ENABLE_USER_TIME = @as(u32, 4);
pub const MD_CPU_ENABLE_KERNEL_TIME = @as(u32, 8);
pub const MD_CPU_ENABLE_PAGE_FAULTS = @as(u32, 16);
pub const MD_CPU_ENABLE_TOTAL_PROCS = @as(u32, 32);
pub const MD_CPU_ENABLE_ACTIVE_PROCS = @as(u32, 64);
pub const MD_CPU_ENABLE_TERMINATED_PROCS = @as(u32, 128);
pub const MD_CPU_ENABLE_LOGGING = @as(u32, 2147483648);
pub const MD_ISAPI_RESTRICTION_LIST = @as(u32, 2163);
pub const MD_CGI_RESTRICTION_LIST = @as(u32, 2164);
pub const MD_RESTRICTION_LIST_CUSTOM_DESC = @as(u32, 2165);
pub const MD_SECURITY_SETUP_REQUIRED = @as(u32, 2166);
pub const MD_APP_DEPENDENCIES = @as(u32, 2167);
pub const MD_WEB_SVC_EXT_RESTRICTION_LIST = @as(u32, 2168);
pub const MD_MD_SERVER_SS_AUTH_MAPPING = @as(u32, 2200);
pub const MD_CERT_NO_REVOC_CHECK = @as(u32, 1);
pub const MD_CERT_CACHE_RETRIEVAL_ONLY = @as(u32, 2);
pub const MD_CERT_CHECK_REVOCATION_FRESHNESS_TIME = @as(u32, 4);
pub const MD_CERT_NO_USAGE_CHECK = @as(u32, 65536);
pub const MD_HC_COMPRESSION_DIRECTORY = @as(u32, 2210);
pub const MD_HC_CACHE_CONTROL_HEADER = @as(u32, 2211);
pub const MD_HC_EXPIRES_HEADER = @as(u32, 2212);
pub const MD_HC_DO_DYNAMIC_COMPRESSION = @as(u32, 2213);
pub const MD_HC_DO_STATIC_COMPRESSION = @as(u32, 2214);
pub const MD_HC_DO_ON_DEMAND_COMPRESSION = @as(u32, 2215);
pub const MD_HC_DO_DISK_SPACE_LIMITING = @as(u32, 2216);
pub const MD_HC_NO_COMPRESSION_FOR_HTTP_10 = @as(u32, 2217);
pub const MD_HC_NO_COMPRESSION_FOR_PROXIES = @as(u32, 2218);
pub const MD_HC_NO_COMPRESSION_FOR_RANGE = @as(u32, 2219);
pub const MD_HC_SEND_CACHE_HEADERS = @as(u32, 2220);
pub const MD_HC_MAX_DISK_SPACE_USAGE = @as(u32, 2221);
pub const MD_HC_IO_BUFFER_SIZE = @as(u32, 2222);
pub const MD_HC_COMPRESSION_BUFFER_SIZE = @as(u32, 2223);
pub const MD_HC_MAX_QUEUE_LENGTH = @as(u32, 2224);
pub const MD_HC_FILES_DELETED_PER_DISK_FREE = @as(u32, 2225);
pub const MD_HC_MIN_FILE_SIZE_FOR_COMP = @as(u32, 2226);
pub const MD_HC_COMPRESSION_DLL = @as(u32, 2237);
pub const MD_HC_FILE_EXTENSIONS = @as(u32, 2238);
pub const MD_HC_MIME_TYPE = @as(u32, 2239);
pub const MD_HC_PRIORITY = @as(u32, 2240);
pub const MD_HC_DYNAMIC_COMPRESSION_LEVEL = @as(u32, 2241);
pub const MD_HC_ON_DEMAND_COMP_LEVEL = @as(u32, 2242);
pub const MD_HC_CREATE_FLAGS = @as(u32, 2243);
pub const MD_HC_SCRIPT_FILE_EXTENSIONS = @as(u32, 2244);
pub const MD_HC_DO_NAMESPACE_DYNAMIC_COMPRESSION = @as(u32, 2255);
pub const MD_HC_DO_NAMESPACE_STATIC_COMPRESSION = @as(u32, 2256);
pub const MD_WIN32_ERROR = @as(u32, 1099);
pub const IIS_MD_VR_BASE = @as(u32, 3000);
pub const MD_VR_PATH = @as(u32, 3001);
pub const MD_VR_USERNAME = @as(u32, 3002);
pub const MD_VR_PASSWORD = <PASSWORD>(u32, 3003);
pub const MD_VR_PASSTHROUGH = @as(u32, 3006);
pub const MD_VR_NO_CACHE = @as(u32, 3007);
pub const MD_VR_IGNORE_TRANSLATE = @as(u32, 3008);
pub const IIS_MD_LOG_BASE = @as(u32, 4000);
pub const MD_LOG_TYPE = @as(u32, 4000);
pub const MD_LOGFILE_DIRECTORY = @as(u32, 4001);
pub const MD_LOG_UNUSED1 = @as(u32, 4002);
pub const MD_LOGFILE_PERIOD = @as(u32, 4003);
pub const MD_LOGFILE_TRUNCATE_SIZE = @as(u32, 4004);
pub const MD_LOG_PLUGIN_MOD_ID = @as(u32, 4005);
pub const MD_LOG_PLUGIN_UI_ID = @as(u32, 4006);
pub const MD_LOGSQL_DATA_SOURCES = @as(u32, 4007);
pub const MD_LOGSQL_TABLE_NAME = @as(u32, 4008);
pub const MD_LOGSQL_USER_NAME = @as(u32, 4009);
pub const MD_LOGSQL_PASSWORD = @as(u32, 4010);
pub const MD_LOG_PLUGIN_ORDER = @as(u32, 4011);
pub const MD_LOG_PLUGINS_AVAILABLE = @as(u32, 4012);
pub const MD_LOGEXT_FIELD_MASK = @as(u32, 4013);
pub const MD_LOGEXT_FIELD_MASK2 = @as(u32, 4014);
pub const MD_LOGFILE_LOCALTIME_ROLLOVER = @as(u32, 4015);
pub const IIS_MD_LOG_LAST = @as(u32, 4015);
pub const MD_GLOBAL_BINARY_LOGGING_ENABLED = @as(u32, 4016);
pub const MD_LOG_TYPE_DISABLED = @as(u32, 0);
pub const MD_LOG_TYPE_ENABLED = @as(u32, 1);
pub const MD_LOGFILE_PERIOD_NONE = @as(u32, 0);
pub const MD_LOGFILE_PERIOD_MAXSIZE = @as(u32, 0);
pub const MD_LOGFILE_PERIOD_DAILY = @as(u32, 1);
pub const MD_LOGFILE_PERIOD_WEEKLY = @as(u32, 2);
pub const MD_LOGFILE_PERIOD_MONTHLY = @as(u32, 3);
pub const MD_LOGFILE_PERIOD_HOURLY = @as(u32, 4);
pub const MD_EXTLOG_DATE = @as(u32, 1);
pub const MD_EXTLOG_TIME = @as(u32, 2);
pub const MD_EXTLOG_CLIENT_IP = @as(u32, 4);
pub const MD_EXTLOG_USERNAME = @as(u32, 8);
pub const MD_EXTLOG_SITE_NAME = @as(u32, 16);
pub const MD_EXTLOG_COMPUTER_NAME = @as(u32, 32);
pub const MD_EXTLOG_SERVER_IP = @as(u32, 64);
pub const MD_EXTLOG_METHOD = @as(u32, 128);
pub const MD_EXTLOG_URI_STEM = @as(u32, 256);
pub const MD_EXTLOG_URI_QUERY = @as(u32, 512);
pub const MD_EXTLOG_HTTP_STATUS = @as(u32, 1024);
pub const MD_EXTLOG_WIN32_STATUS = @as(u32, 2048);
pub const MD_EXTLOG_BYTES_SENT = @as(u32, 4096);
pub const MD_EXTLOG_BYTES_RECV = @as(u32, 8192);
pub const MD_EXTLOG_TIME_TAKEN = @as(u32, 16384);
pub const MD_EXTLOG_SERVER_PORT = @as(u32, 32768);
pub const MD_EXTLOG_USER_AGENT = @as(u32, 65536);
pub const MD_EXTLOG_COOKIE = @as(u32, 131072);
pub const MD_EXTLOG_REFERER = @as(u32, 262144);
pub const MD_EXTLOG_PROTOCOL_VERSION = @as(u32, 524288);
pub const MD_EXTLOG_HOST = @as(u32, 1048576);
pub const MD_EXTLOG_HTTP_SUB_STATUS = @as(u32, 2097152);
pub const IIS_MD_LOGCUSTOM_BASE = @as(u32, 4500);
pub const MD_LOGCUSTOM_PROPERTY_NAME = @as(u32, 4501);
pub const MD_LOGCUSTOM_PROPERTY_HEADER = @as(u32, 4502);
pub const MD_LOGCUSTOM_PROPERTY_ID = @as(u32, 4503);
pub const MD_LOGCUSTOM_PROPERTY_MASK = @as(u32, 4504);
pub const MD_LOGCUSTOM_PROPERTY_DATATYPE = @as(u32, 4505);
pub const MD_LOGCUSTOM_SERVICES_STRING = @as(u32, 4506);
pub const MD_CPU_LOGGING_MASK = @as(u32, 4507);
pub const MD_LOGCUSTOM_PROPERTY_NODE_ID = @as(u32, 4508);
pub const IIS_MD_LOGCUSTOM_LAST = @as(u32, 4508);
pub const MD_LOGCUSTOM_DATATYPE_INT = @as(u32, 0);
pub const MD_LOGCUSTOM_DATATYPE_UINT = @as(u32, 1);
pub const MD_LOGCUSTOM_DATATYPE_LONG = @as(u32, 2);
pub const MD_LOGCUSTOM_DATATYPE_ULONG = @as(u32, 3);
pub const MD_LOGCUSTOM_DATATYPE_FLOAT = @as(u32, 4);
pub const MD_LOGCUSTOM_DATATYPE_DOUBLE = @as(u32, 5);
pub const MD_LOGCUSTOM_DATATYPE_LPSTR = @as(u32, 6);
pub const MD_LOGCUSTOM_DATATYPE_LPWSTR = @as(u32, 7);
pub const MD_NOTIFY_SECURE_PORT = @as(u32, 1);
pub const MD_NOTIFY_NONSECURE_PORT = @as(u32, 2);
pub const MD_NOTIFY_READ_RAW_DATA = @as(u32, 32768);
pub const MD_NOTIFY_PREPROC_HEADERS = @as(u32, 16384);
pub const MD_NOTIFY_AUTHENTICATION = @as(u32, 8192);
pub const MD_NOTIFY_URL_MAP = @as(u32, 4096);
pub const MD_NOTIFY_ACCESS_DENIED = @as(u32, 2048);
pub const MD_NOTIFY_SEND_RESPONSE = @as(u32, 64);
pub const MD_NOTIFY_SEND_RAW_DATA = @as(u32, 1024);
pub const MD_NOTIFY_LOG = @as(u32, 512);
pub const MD_NOTIFY_END_OF_REQUEST = @as(u32, 128);
pub const MD_NOTIFY_END_OF_NET_SESSION = @as(u32, 256);
pub const MD_NOTIFY_AUTH_COMPLETE = @as(u32, 67108864);
pub const MD_NOTIFY_ORDER_HIGH = @as(u32, 524288);
pub const MD_NOTIFY_ORDER_MEDIUM = @as(u32, 262144);
pub const MD_NOTIFY_ORDER_LOW = @as(u32, 131072);
pub const MD_NOTIFY_ORDER_DEFAULT = @as(u32, 131072);
pub const IIS_MD_FTP_BASE = @as(u32, 5000);
pub const MD_EXIT_MESSAGE = @as(u32, 5001);
pub const MD_GREETING_MESSAGE = @as(u32, 5002);
pub const MD_MAX_CLIENTS_MESSAGE = @as(u32, 5003);
pub const MD_MSDOS_DIR_OUTPUT = @as(u32, 5004);
pub const MD_ALLOW_ANONYMOUS = @as(u32, 5005);
pub const MD_ANONYMOUS_ONLY = @as(u32, 5006);
pub const MD_LOG_ANONYMOUS = @as(u32, 5007);
pub const MD_LOG_NONANONYMOUS = @as(u32, 5008);
pub const MD_ALLOW_REPLACE_ON_RENAME = @as(u32, 5009);
pub const MD_SHOW_4_DIGIT_YEAR = @as(u32, 5010);
pub const MD_BANNER_MESSAGE = @as(u32, 5011);
pub const MD_USER_ISOLATION = @as(u32, 5012);
pub const MD_FTP_LOG_IN_UTF_8 = @as(u32, 5013);
pub const MD_AD_CONNECTIONS_USERNAME = @as(u32, 5014);
pub const MD_AD_CONNECTIONS_PASSWORD = @as(u32, 5<PASSWORD>);
pub const MD_PASSIVE_PORT_RANGE = @as(u32, 5016);
pub const MD_SUPPRESS_DEFAULT_BANNER = @as(u32, 5017);
pub const MD_FTP_PASV_RESPONSE_IP = @as(u32, 5018);
pub const MD_FTP_KEEP_PARTIAL_UPLOADS = @as(u32, 5019);
pub const MD_FTP_UTF8_FILE_NAMES = @as(u32, 5020);
pub const MD_FTPS_SECURE_CONTROL_CHANNEL = @as(u32, 5050);
pub const MD_FTPS_SECURE_DATA_CHANNEL = @as(u32, 5051);
pub const MD_FTPS_SECURE_ANONYMOUS = @as(u32, 5052);
pub const MD_FTPS_128_BITS = @as(u32, 5053);
pub const MD_FTPS_ALLOW_CCC = @as(u32, 5054);
pub const IIS_MD_SSL_BASE = @as(u32, 5500);
pub const MD_SSL_PUBLIC_KEY = @as(u32, 5500);
pub const MD_SSL_PRIVATE_KEY = @as(u32, 5501);
pub const MD_SSL_KEY_PASSWORD = @as(u32, 5502);
pub const MD_SSL_KEY_REQUEST = @as(u32, 5503);
pub const MD_SSL_USE_DS_MAPPER = @as(u32, 5519);
pub const MD_SSL_ALWAYS_NEGO_CLIENT_CERT = @as(u32, 5521);
pub const IIS_MD_FILE_PROP_BASE = @as(u32, 6000);
pub const MD_AUTHORIZATION = @as(u32, 6000);
pub const MD_REALM = @as(u32, 6001);
pub const MD_HTTP_EXPIRES = @as(u32, 6002);
pub const MD_HTTP_PICS = @as(u32, 6003);
pub const MD_HTTP_CUSTOM = @as(u32, 6004);
pub const MD_DIRECTORY_BROWSING = @as(u32, 6005);
pub const MD_DEFAULT_LOAD_FILE = @as(u32, 6006);
pub const MD_CUSTOM_ERROR = @as(u32, 6008);
pub const MD_FOOTER_DOCUMENT = @as(u32, 6009);
pub const MD_FOOTER_ENABLED = @as(u32, 6010);
pub const MD_HTTP_REDIRECT = @as(u32, 6011);
pub const MD_DEFAULT_LOGON_DOMAIN = @as(u32, 6012);
pub const MD_LOGON_METHOD = @as(u32, 6013);
pub const MD_SCRIPT_MAPS = @as(u32, 6014);
pub const MD_MIME_MAP = @as(u32, 6015);
pub const MD_ACCESS_PERM = @as(u32, 6016);
pub const MD_IP_SEC = @as(u32, 6019);
pub const MD_ANONYMOUS_USER_NAME = @as(u32, 6020);
pub const MD_ANONYMOUS_PWD = @as(u32, 6021);
pub const MD_ANONYMOUS_USE_SUBAUTH = @as(u32, 6022);
pub const MD_DONT_LOG = @as(u32, 6023);
pub const MD_ADMIN_ACL = @as(u32, 6027);
pub const MD_SSI_EXEC_DISABLED = @as(u32, 6028);
pub const MD_DO_REVERSE_DNS = @as(u32, 6029);
pub const MD_SSL_ACCESS_PERM = @as(u32, 6030);
pub const MD_AUTHORIZATION_PERSISTENCE = @as(u32, 6031);
pub const MD_NTAUTHENTICATION_PROVIDERS = @as(u32, 6032);
pub const MD_SCRIPT_TIMEOUT = @as(u32, 6033);
pub const MD_CACHE_EXTENSIONS = @as(u32, 6034);
pub const MD_CREATE_PROCESS_AS_USER = @as(u32, 6035);
pub const MD_CREATE_PROC_NEW_CONSOLE = @as(u32, 6036);
pub const MD_POOL_IDC_TIMEOUT = @as(u32, 6037);
pub const MD_ALLOW_KEEPALIVES = @as(u32, 6038);
pub const MD_IS_CONTENT_INDEXED = @as(u32, 6039);
pub const MD_CC_NO_CACHE = @as(u32, 6041);
pub const MD_CC_MAX_AGE = @as(u32, 6042);
pub const MD_CC_OTHER = @as(u32, 6043);
pub const MD_REDIRECT_HEADERS = @as(u32, 6044);
pub const MD_UPLOAD_READAHEAD_SIZE = @as(u32, 6045);
pub const MD_PUT_READ_SIZE = @as(u32, 6046);
pub const MD_USE_DIGEST_SSP = @as(u32, 6047);
pub const MD_ENABLE_URL_AUTHORIZATION = @as(u32, 6048);
pub const MD_URL_AUTHORIZATION_STORE_NAME = @as(u32, 6049);
pub const MD_URL_AUTHORIZATION_SCOPE_NAME = @as(u32, 6050);
pub const MD_MAX_REQUEST_ENTITY_ALLOWED = @as(u32, 6051);
pub const MD_PASSPORT_REQUIRE_AD_MAPPING = @as(u32, 6052);
pub const MD_URL_AUTHORIZATION_IMPERSONATION_LEVEL = @as(u32, 6053);
pub const MD_HTTP_FORWARDER_CUSTOM = @as(u32, 6054);
pub const MD_CUSTOM_DEPLOYMENT_DATA = @as(u32, 6055);
pub const MD_HTTPERRORS_EXISTING_RESPONSE = @as(u32, 6056);
pub const ASP_MD_SERVER_BASE = @as(u32, 7000);
pub const MD_ASP_BUFFERINGON = @as(u32, 7000);
pub const MD_ASP_LOGERRORREQUESTS = @as(u32, 7001);
pub const MD_ASP_SCRIPTERRORSSENTTOBROWSER = @as(u32, 7002);
pub const MD_ASP_SCRIPTERRORMESSAGE = @as(u32, 7003);
pub const MD_ASP_SCRIPTFILECACHESIZE = @as(u32, 7004);
pub const MD_ASP_SCRIPTENGINECACHEMAX = @as(u32, 7005);
pub const MD_ASP_SCRIPTTIMEOUT = @as(u32, 7006);
pub const MD_ASP_SESSIONTIMEOUT = @as(u32, 7007);
pub const MD_ASP_ENABLEPARENTPATHS = @as(u32, 7008);
pub const MD_ASP_MEMFREEFACTOR = @as(u32, 7009);
pub const MD_ASP_MINUSEDBLOCKS = @as(u32, 7010);
pub const MD_ASP_ALLOWSESSIONSTATE = @as(u32, 7011);
pub const MD_ASP_SCRIPTLANGUAGE = @as(u32, 7012);
pub const MD_ASP_QUEUETIMEOUT = @as(u32, 7013);
pub const MD_ASP_ALLOWOUTOFPROCCOMPONENTS = @as(u32, 7014);
pub const MD_ASP_ALLOWOUTOFPROCCMPNTS = @as(u32, 7014);
pub const MD_ASP_EXCEPTIONCATCHENABLE = @as(u32, 7015);
pub const MD_ASP_CODEPAGE = @as(u32, 7016);
pub const MD_ASP_SCRIPTLANGUAGELIST = @as(u32, 7017);
pub const MD_ASP_ENABLESERVERDEBUG = @as(u32, 7018);
pub const MD_ASP_ENABLECLIENTDEBUG = @as(u32, 7019);
pub const MD_ASP_TRACKTHREADINGMODEL = @as(u32, 7020);
pub const MD_ASP_ENABLEASPHTMLFALLBACK = @as(u32, 7021);
pub const MD_ASP_ENABLECHUNKEDENCODING = @as(u32, 7022);
pub const MD_ASP_ENABLETYPELIBCACHE = @as(u32, 7023);
pub const MD_ASP_ERRORSTONTLOG = @as(u32, 7024);
pub const MD_ASP_PROCESSORTHREADMAX = @as(u32, 7025);
pub const MD_ASP_REQEUSTQUEUEMAX = @as(u32, 7026);
pub const MD_ASP_ENABLEAPPLICATIONRESTART = @as(u32, 7027);
pub const MD_ASP_QUEUECONNECTIONTESTTIME = @as(u32, 7028);
pub const MD_ASP_SESSIONMAX = @as(u32, 7029);
pub const MD_ASP_THREADGATEENABLED = @as(u32, 7030);
pub const MD_ASP_THREADGATETIMESLICE = @as(u32, 7031);
pub const MD_ASP_THREADGATESLEEPDELAY = @as(u32, 7032);
pub const MD_ASP_THREADGATESLEEPMAX = @as(u32, 7033);
pub const MD_ASP_THREADGATELOADLOW = @as(u32, 7034);
pub const MD_ASP_THREADGATELOADHIGH = @as(u32, 7035);
pub const MD_ASP_DISKTEMPLATECACHEDIRECTORY = @as(u32, 7036);
pub const MD_ASP_MAXDISKTEMPLATECACHEFILES = @as(u32, 7040);
pub const MD_ASP_EXECUTEINMTA = @as(u32, 7041);
pub const MD_ASP_LCID = @as(u32, 7042);
pub const MD_ASP_KEEPSESSIONIDSECURE = @as(u32, 7043);
pub const MD_ASP_SERVICE_FLAGS = @as(u32, 7044);
pub const MD_ASP_SERVICE_FLAG_TRACKER = @as(u32, 7045);
pub const MD_ASP_SERVICE_FLAG_FUSION = @as(u32, 7046);
pub const MD_ASP_SERVICE_FLAG_PARTITIONS = @as(u32, 7047);
pub const MD_ASP_SERVICE_PARTITION_ID = @as(u32, 7048);
pub const MD_ASP_SERVICE_SXS_NAME = @as(u32, 7049);
pub const MD_ASP_SERVICE_ENABLE_TRACKER = @as(u32, 1);
pub const MD_ASP_SERVICE_ENABLE_SXS = @as(u32, 2);
pub const MD_ASP_SERVICE_USE_PARTITION = @as(u32, 4);
pub const MD_ASP_CALCLINENUMBER = @as(u32, 7050);
pub const MD_ASP_RUN_ONEND_ANON = @as(u32, 7051);
pub const MD_ASP_BUFFER_LIMIT = @as(u32, 7052);
pub const MD_ASP_MAX_REQUEST_ENTITY_ALLOWED = @as(u32, 7053);
pub const MD_ASP_MAXREQUESTENTITY = @as(u32, 7053);
pub const MD_ASP_ID_LAST = @as(u32, 7053);
pub const WAM_MD_SERVER_BASE = @as(u32, 7500);
pub const MD_WAM_USER_NAME = @as(u32, 7501);
pub const MD_WAM_PWD = @as(u32, 7502);
pub const WEBDAV_MD_SERVER_BASE = @as(u32, 8500);
pub const MD_WEBDAV_MAX_ATTRIBUTES_PER_ELEMENT = @as(u32, 8501);
pub const IIS_MD_APPPOOL_BASE = @as(u32, 9000);
pub const MD_APPPOOL_PERIODIC_RESTART_TIME = @as(u32, 9001);
pub const MD_APPPOOL_PERIODIC_RESTART_REQUEST_COUNT = @as(u32, 9002);
pub const MD_APPPOOL_MAX_PROCESS_COUNT = @as(u32, 9003);
pub const MD_APPPOOL_PINGING_ENABLED = @as(u32, 9004);
pub const MD_APPPOOL_IDLE_TIMEOUT = @as(u32, 9005);
pub const MD_APPPOOL_RAPID_FAIL_PROTECTION_ENABLED = @as(u32, 9006);
pub const MD_APPPOOL_SMP_AFFINITIZED = @as(u32, 9007);
pub const MD_APPPOOL_SMP_AFFINITIZED_PROCESSOR_MASK = @as(u32, 9008);
pub const MD_APPPOOL_ORPHAN_PROCESSES_FOR_DEBUGGING = @as(u32, 9009);
pub const MD_APPPOOL_STARTUP_TIMELIMIT = @as(u32, 9011);
pub const MD_APPPOOL_SHUTDOWN_TIMELIMIT = @as(u32, 9012);
pub const MD_APPPOOL_PING_INTERVAL = @as(u32, 9013);
pub const MD_APPPOOL_PING_RESPONSE_TIMELIMIT = @as(u32, 9014);
pub const MD_APPPOOL_DISALLOW_OVERLAPPING_ROTATION = @as(u32, 9015);
pub const MD_APPPOOL_UL_APPPOOL_QUEUE_LENGTH = @as(u32, 9017);
pub const MD_APPPOOL_DISALLOW_ROTATION_ON_CONFIG_CHANGE = @as(u32, 9018);
pub const MD_APPPOOL_PERIODIC_RESTART_SCHEDULE = @as(u32, 9020);
pub const MD_APPPOOL_IDENTITY_TYPE = @as(u32, 9021);
pub const MD_CPU_ACTION = @as(u32, 9022);
pub const MD_CPU_LIMIT = @as(u32, 9023);
pub const MD_APPPOOL_PERIODIC_RESTART_MEMORY = @as(u32, 9024);
pub const MD_APPPOOL_COMMAND = @as(u32, 9026);
pub const MD_APPPOOL_STATE = @as(u32, 9027);
pub const MD_APPPOOL_AUTO_START = @as(u32, 9028);
pub const MD_RAPID_FAIL_PROTECTION_INTERVAL = @as(u32, 9029);
pub const MD_RAPID_FAIL_PROTECTION_MAX_CRASHES = @as(u32, 9030);
pub const MD_APPPOOL_ORPHAN_ACTION_EXE = @as(u32, 9031);
pub const MD_APPPOOL_ORPHAN_ACTION_PARAMS = @as(u32, 9032);
pub const MB_DONT_IMPERSONATE = @as(u32, 9033);
pub const MD_LOAD_BALANCER_CAPABILITIES = @as(u32, 9034);
pub const MD_APPPOOL_AUTO_SHUTDOWN_EXE = @as(u32, 9035);
pub const MD_APPPOOL_AUTO_SHUTDOWN_PARAMS = @as(u32, 9036);
pub const MD_APP_POOL_LOG_EVENT_ON_RECYCLE = @as(u32, 9037);
pub const MD_APPPOOL_PERIODIC_RESTART_PRIVATE_MEMORY = @as(u32, 9038);
pub const MD_APPPOOL_MANAGED_RUNTIME_VERSION = @as(u32, 9039);
pub const MD_APPPOOL_32_BIT_APP_ON_WIN64 = @as(u32, 9040);
pub const MD_APPPOOL_MANAGED_PIPELINE_MODE = @as(u32, 9041);
pub const MD_APP_POOL_LOG_EVENT_ON_PROCESSMODEL = @as(u32, 9042);
pub const MD_APP_POOL_PROCESSMODEL_IDLE_TIMEOUT = @as(u32, 1);
pub const MD_APP_POOL_RECYCLE_TIME = @as(u32, 1);
pub const MD_APP_POOL_RECYCLE_REQUESTS = @as(u32, 2);
pub const MD_APP_POOL_RECYCLE_SCHEDULE = @as(u32, 4);
pub const MD_APP_POOL_RECYCLE_MEMORY = @as(u32, 8);
pub const MD_APP_POOL_RECYCLE_ISAPI_UNHEALTHY = @as(u32, 16);
pub const MD_APP_POOL_RECYCLE_ON_DEMAND = @as(u32, 32);
pub const MD_APP_POOL_RECYCLE_CONFIG_CHANGE = @as(u32, 64);
pub const MD_APP_POOL_RECYCLE_PRIVATE_MEMORY = @as(u32, 128);
pub const MD_CPU_NO_ACTION = @as(u32, 0);
pub const MD_CPU_KILL_W3WP = @as(u32, 1);
pub const MD_CPU_TRACE = @as(u32, 2);
pub const MD_CPU_THROTTLE = @as(u32, 3);
pub const MD_APPPOOL_COMMAND_START = @as(u32, 1);
pub const MD_APPPOOL_COMMAND_STOP = @as(u32, 2);
pub const MD_APPPOOL_STATE_STARTING = @as(u32, 1);
pub const MD_APPPOOL_STATE_STARTED = @as(u32, 2);
pub const MD_APPPOOL_STATE_STOPPING = @as(u32, 3);
pub const MD_APPPOOL_STATE_STOPPED = @as(u32, 4);
pub const MD_APPPOOL_IDENTITY_TYPE_LOCALSYSTEM = @as(u32, 0);
pub const MD_APPPOOL_IDENTITY_TYPE_LOCALSERVICE = @as(u32, 1);
pub const MD_APPPOOL_IDENTITY_TYPE_NETWORKSERVICE = @as(u32, 2);
pub const MD_APPPOOL_IDENTITY_TYPE_SPECIFICUSER = @as(u32, 3);
pub const MD_LOAD_BALANCER_CAPABILITIES_BASIC = @as(u32, 1);
pub const MD_LOAD_BALANCER_CAPABILITIES_SOPHISTICATED = @as(u32, 2);
pub const IIS_MD_APP_BASE = @as(u32, 9100);
pub const MD_APP_APPPOOL_ID = @as(u32, 9101);
pub const MD_APP_ALLOW_TRANSIENT_REGISTRATION = @as(u32, 9102);
pub const MD_APP_AUTO_START = @as(u32, 9103);
pub const MD_APPPOOL_PERIODIC_RESTART_CONNECTIONS = @as(u32, 9104);
pub const MD_APPPOOL_APPPOOL_ID = @as(u32, 9201);
pub const MD_APPPOOL_ALLOW_TRANSIENT_REGISTRATION = @as(u32, 9202);
pub const IIS_MD_GLOBAL_BASE = @as(u32, 9200);
pub const MD_MAX_GLOBAL_BANDWIDTH = @as(u32, 9201);
pub const MD_MAX_GLOBAL_CONNECTIONS = @as(u32, 9202);
pub const MD_GLOBAL_STANDARD_APP_MODE_ENABLED = @as(u32, 9203);
pub const MD_HEADER_WAIT_TIMEOUT = @as(u32, 9204);
pub const MD_MIN_FILE_BYTES_PER_SEC = @as(u32, 9205);
pub const MD_GLOBAL_LOG_IN_UTF_8 = @as(u32, 9206);
pub const MD_DEMAND_START_THRESHOLD = @as(u32, 9207);
pub const MD_GLOBAL_SESSIONKEY = @as(u32, 9999);
pub const MD_ROOT_ENABLE_EDIT_WHILE_RUNNING = @as(u32, 9998);
pub const MD_GLOBAL_CHANGE_NUMBER = @as(u32, 9997);
pub const MD_ROOT_ENABLE_HISTORY = @as(u32, 9996);
pub const MD_ROOT_MAX_HISTORY_FILES = @as(u32, 9995);
pub const MD_GLOBAL_EDIT_WHILE_RUNNING_MAJOR_VERSION_NUMBER = @as(u32, 9994);
pub const MD_GLOBAL_EDIT_WHILE_RUNNING_MINOR_VERSION_NUMBER = @as(u32, 9993);
pub const MD_GLOBAL_XMLSCHEMATIMESTAMP = @as(u32, 9992);
pub const MD_GLOBAL_BINSCHEMATIMESTAMP = @as(u32, 9991);
pub const MD_COMMENTS = @as(u32, 9990);
pub const MD_LOCATION = @as(u32, 9989);
pub const MD_MAX_ERROR_FILES = @as(u32, 9988);
pub const MD_STOP_LISTENING = @as(u32, 9987);
pub const MD_AUTH_ANONYMOUS = @as(u32, 1);
pub const MD_AUTH_BASIC = @as(u32, 2);
pub const MD_AUTH_NT = @as(u32, 4);
pub const MD_AUTH_MD5 = @as(u32, 16);
pub const MD_AUTH_PASSPORT = @as(u32, 64);
pub const MD_AUTH_SINGLEREQUEST = @as(u32, 64);
pub const MD_AUTH_SINGLEREQUESTIFPROXY = @as(u32, 128);
pub const MD_AUTH_SINGLEREQUESTALWAYSIFPROXY = @as(u32, 256);
pub const MD_ACCESS_READ = @as(u32, 1);
pub const MD_ACCESS_WRITE = @as(u32, 2);
pub const MD_ACCESS_EXECUTE = @as(u32, 4);
pub const MD_ACCESS_SOURCE = @as(u32, 16);
pub const MD_ACCESS_SCRIPT = @as(u32, 512);
pub const MD_ACCESS_NO_REMOTE_WRITE = @as(u32, 1024);
pub const MD_ACCESS_NO_REMOTE_READ = @as(u32, 4096);
pub const MD_ACCESS_NO_REMOTE_EXECUTE = @as(u32, 8192);
pub const MD_ACCESS_NO_REMOTE_SCRIPT = @as(u32, 16384);
pub const MD_ACCESS_NO_PHYSICAL_DIR = @as(u32, 32768);
pub const MD_ACCESS_SSL = @as(u32, 8);
pub const MD_ACCESS_NEGO_CERT = @as(u32, 32);
pub const MD_ACCESS_REQUIRE_CERT = @as(u32, 64);
pub const MD_ACCESS_MAP_CERT = @as(u32, 128);
pub const MD_ACCESS_SSL128 = @as(u32, 256);
pub const MD_ACCESS_MASK = @as(u32, 65535);
pub const MD_DIRBROW_SHOW_DATE = @as(u32, 2);
pub const MD_DIRBROW_SHOW_TIME = @as(u32, 4);
pub const MD_DIRBROW_SHOW_SIZE = @as(u32, 8);
pub const MD_DIRBROW_SHOW_EXTENSION = @as(u32, 16);
pub const MD_DIRBROW_LONG_DATE = @as(u32, 32);
pub const MD_DIRBROW_ENABLED = @as(u32, 2147483648);
pub const MD_DIRBROW_LOADDEFAULT = @as(u32, 1073741824);
pub const MD_LOGON_INTERACTIVE = @as(u32, 0);
pub const MD_LOGON_BATCH = @as(u32, 1);
pub const MD_LOGON_NETWORK = @as(u32, 2);
pub const MD_LOGON_NETWORK_CLEARTEXT = @as(u32, 3);
pub const MD_PASSPORT_NO_MAPPING = @as(u32, 0);
pub const MD_PASSPORT_TRY_MAPPING = @as(u32, 1);
pub const MD_PASSPORT_NEED_MAPPING = @as(u32, 2);
pub const MD_NOTIFEXAUTH_NTLMSSL = @as(u32, 1);
pub const MD_FILTER_STATE_LOADED = @as(u32, 1);
pub const MD_FILTER_STATE_UNLOADED = @as(u32, 4);
pub const MD_SERVER_STATE_STARTING = @as(u32, 1);
pub const MD_SERVER_STATE_STARTED = @as(u32, 2);
pub const MD_SERVER_STATE_STOPPING = @as(u32, 3);
pub const MD_SERVER_STATE_STOPPED = @as(u32, 4);
pub const MD_SERVER_STATE_PAUSING = @as(u32, 5);
pub const MD_SERVER_STATE_PAUSED = @as(u32, 6);
pub const MD_SERVER_STATE_CONTINUING = @as(u32, 7);
pub const MD_SERVER_COMMAND_START = @as(u32, 1);
pub const MD_SERVER_COMMAND_STOP = @as(u32, 2);
pub const MD_SERVER_COMMAND_PAUSE = @as(u32, 3);
pub const MD_SERVER_COMMAND_CONTINUE = @as(u32, 4);
pub const MD_SERVER_SIZE_SMALL = @as(u32, 0);
pub const MD_SERVER_SIZE_MEDIUM = @as(u32, 1);
pub const MD_SERVER_SIZE_LARGE = @as(u32, 2);
pub const MD_SERVER_CONFIG_SSL_40 = @as(u32, 1);
pub const MD_SERVER_CONFIG_SSL_128 = @as(u32, 2);
pub const MD_SERVER_CONFIG_ALLOW_ENCRYPT = @as(u32, 4);
pub const MD_SERVER_CONFIG_AUTO_PW_SYNC = @as(u32, 8);
pub const MD_SCRIPTMAPFLAG_SCRIPT = @as(u32, 1);
pub const MD_SCRIPTMAPFLAG_CHECK_PATH_INFO = @as(u32, 4);
pub const MD_SCRIPTMAPFLAG_ALLOWED_ON_READ_DIR = @as(u32, 1);
pub const MD_AUTH_CHANGE_UNSECURE = @as(u32, 1);
pub const MD_AUTH_CHANGE_DISABLE = @as(u32, 2);
pub const MD_AUTH_ADVNOTIFY_DISABLE = @as(u32, 4);
pub const MD_NETLOGON_WKS_NONE = @as(u32, 0);
pub const MD_NETLOGON_WKS_IP = @as(u32, 1);
pub const MD_NETLOGON_WKS_DNS = @as(u32, 2);
pub const MD_ERROR_SUB400_INVALID_DESTINATION = @as(u32, 1);
pub const MD_ERROR_SUB400_INVALID_DEPTH = @as(u32, 2);
pub const MD_ERROR_SUB400_INVALID_IF = @as(u32, 3);
pub const MD_ERROR_SUB400_INVALID_OVERWRITE = @as(u32, 4);
pub const MD_ERROR_SUB400_INVALID_TRANSLATE = @as(u32, 5);
pub const MD_ERROR_SUB400_INVALID_REQUEST_BODY = @as(u32, 6);
pub const MD_ERROR_SUB400_INVALID_CONTENT_LENGTH = @as(u32, 7);
pub const MD_ERROR_SUB400_INVALID_TIMEOUT = @as(u32, 8);
pub const MD_ERROR_SUB400_INVALID_LOCK_TOKEN = @as(u32, 9);
pub const MD_ERROR_SUB400_INVALID_XFF_HEADER = @as(u32, 10);
pub const MD_ERROR_SUB400_INVALID_WEBSOCKET_REQUEST = @as(u32, 11);
pub const MD_ERROR_SUB401_LOGON = @as(u32, 1);
pub const MD_ERROR_SUB401_LOGON_CONFIG = @as(u32, 2);
pub const MD_ERROR_SUB401_LOGON_ACL = @as(u32, 3);
pub const MD_ERROR_SUB401_FILTER = @as(u32, 4);
pub const MD_ERROR_SUB401_APPLICATION = @as(u32, 5);
pub const MD_ERROR_SUB401_URLAUTH_POLICY = @as(u32, 7);
pub const MD_ERROR_SUB403_EXECUTE_ACCESS_DENIED = @as(u32, 1);
pub const MD_ERROR_SUB403_READ_ACCESS_DENIED = @as(u32, 2);
pub const MD_ERROR_SUB403_WRITE_ACCESS_DENIED = @as(u32, 3);
pub const MD_ERROR_SUB403_SSL_REQUIRED = @as(u32, 4);
pub const MD_ERROR_SUB403_SSL128_REQUIRED = @as(u32, 5);
pub const MD_ERROR_SUB403_ADDR_REJECT = @as(u32, 6);
pub const MD_ERROR_SUB403_CERT_REQUIRED = @as(u32, 7);
pub const MD_ERROR_SUB403_SITE_ACCESS_DENIED = @as(u32, 8);
pub const MD_ERROR_SUB403_TOO_MANY_USERS = @as(u32, 9);
pub const MD_ERROR_SUB403_INVALID_CNFG = @as(u32, 10);
pub const MD_ERROR_SUB403_PWD_CHANGE = @as(u32, 11);
pub const MD_ERROR_SUB403_MAPPER_DENY_ACCESS = @as(u32, 12);
pub const MD_ERROR_SUB403_CERT_REVOKED = @as(u32, 13);
pub const MD_ERROR_SUB403_DIR_LIST_DENIED = @as(u32, 14);
pub const MD_ERROR_SUB403_CAL_EXCEEDED = @as(u32, 15);
pub const MD_ERROR_SUB403_CERT_BAD = @as(u32, 16);
pub const MD_ERROR_SUB403_CERT_TIME_INVALID = @as(u32, 17);
pub const MD_ERROR_SUB403_APPPOOL_DENIED = @as(u32, 18);
pub const MD_ERROR_SUB403_INSUFFICIENT_PRIVILEGE_FOR_CGI = @as(u32, 19);
pub const MD_ERROR_SUB403_PASSPORT_LOGIN_FAILURE = @as(u32, 20);
pub const MD_ERROR_SUB403_SOURCE_ACCESS_DENIED = @as(u32, 21);
pub const MD_ERROR_SUB403_INFINITE_DEPTH_DENIED = @as(u32, 22);
pub const MD_ERROR_SUB403_LOCK_TOKEN_REQUIRED = @as(u32, 23);
pub const MD_ERROR_SUB403_VALIDATION_FAILURE = @as(u32, 24);
pub const MD_ERROR_SUB404_SITE_NOT_FOUND = @as(u32, 1);
pub const MD_ERROR_SUB404_DENIED_BY_POLICY = @as(u32, 2);
pub const MD_ERROR_SUB404_DENIED_BY_MIMEMAP = @as(u32, 3);
pub const MD_ERROR_SUB404_NO_HANDLER = @as(u32, 4);
pub const MD_ERROR_SUB404_URL_SEQUENCE_DENIED = @as(u32, 5);
pub const MD_ERROR_SUB404_VERB_DENIED = @as(u32, 6);
pub const MD_ERROR_SUB404_FILE_EXTENSION_DENIED = @as(u32, 7);
pub const MD_ERROR_SUB404_HIDDEN_SEGMENT = @as(u32, 8);
pub const MD_ERROR_SUB404_FILE_ATTRIBUTE_HIDDEN = @as(u32, 9);
pub const MD_ERROR_SUB404_URL_DOUBLE_ESCAPED = @as(u32, 11);
pub const MD_ERROR_SUB404_URL_HAS_HIGH_BIT_CHARS = @as(u32, 12);
pub const MD_ERROR_SUB404_URL_TOO_LONG = @as(u32, 14);
pub const MD_ERROR_SUB404_QUERY_STRING_TOO_LONG = @as(u32, 15);
pub const MD_ERROR_SUB404_STATICFILE_DAV = @as(u32, 16);
pub const MD_ERROR_SUB404_PRECONDITIONED_HANDLER = @as(u32, 17);
pub const MD_ERROR_SUB404_QUERY_STRING_SEQUENCE_DENIED = @as(u32, 18);
pub const MD_ERROR_SUB404_DENIED_BY_FILTERING_RULE = @as(u32, 19);
pub const MD_ERROR_SUB404_TOO_MANY_URL_SEGMENTS = @as(u32, 20);
pub const MD_ERROR_SUB413_CONTENT_LENGTH_TOO_LARGE = @as(u32, 1);
pub const MD_ERROR_SUB423_LOCK_TOKEN_SUBMITTED = @as(u32, 1);
pub const MD_ERROR_SUB423_NO_CONFLICTING_LOCK = @as(u32, 2);
pub const MD_ERROR_SUB500_UNC_ACCESS = @as(u32, 16);
pub const MD_ERROR_SUB500_URLAUTH_NO_STORE = @as(u32, 17);
pub const MD_ERROR_SUB500_URLAUTH_STORE_ERROR = @as(u32, 18);
pub const MD_ERROR_SUB500_BAD_METADATA = @as(u32, 19);
pub const MD_ERROR_SUB500_URLAUTH_NO_SCOPE = @as(u32, 20);
pub const MD_ERROR_SUB500_HANDLERS_MODULE = @as(u32, 21);
pub const MD_ERROR_SUB500_ASPNET_MODULES = @as(u32, 22);
pub const MD_ERROR_SUB500_ASPNET_HANDLERS = @as(u32, 23);
pub const MD_ERROR_SUB500_ASPNET_IMPERSONATION = @as(u32, 24);
pub const MD_ERROR_SUB502_TIMEOUT = @as(u32, 1);
pub const MD_ERROR_SUB502_PREMATURE_EXIT = @as(u32, 2);
pub const MD_ERROR_SUB502_ARR_CONNECTION_ERROR = @as(u32, 3);
pub const MD_ERROR_SUB502_ARR_NO_SERVER = @as(u32, 4);
pub const MD_ERROR_SUB503_CPU_LIMIT = @as(u32, 1);
pub const MD_ERROR_SUB503_APP_CONCURRENT = @as(u32, 2);
pub const MD_ERROR_SUB503_ASPNET_QUEUE_FULL = @as(u32, 3);
pub const MD_ERROR_SUB503_FASTCGI_QUEUE_FULL = @as(u32, 4);
pub const MD_ERROR_SUB503_CONNECTION_LIMIT = @as(u32, 5);
pub const MD_ACR_READ = @as(u32, 1);
pub const MD_ACR_WRITE = @as(u32, 2);
pub const MD_ACR_RESTRICTED_WRITE = @as(u32, 32);
pub const MD_ACR_UNSECURE_PROPS_READ = @as(u32, 128);
pub const MD_ACR_ENUM_KEYS = @as(u32, 8);
pub const MD_ACR_WRITE_DAC = @as(u32, 262144);
pub const MD_USER_ISOLATION_NONE = @as(u32, 0);
pub const MD_USER_ISOLATION_BASIC = @as(u32, 1);
pub const MD_USER_ISOLATION_AD = @as(u32, 2);
pub const MD_USER_ISOLATION_LAST = @as(u32, 2);
pub const CLSID_IisServiceControl = Guid.initString("e8fb8621-588f-11d2-9d61-00c04f79c5fe");
pub const LIBID_IISRSTALib = Guid.initString("e8fb8614-588f-11d2-9d61-00c04f79c5fe");
pub const LIBID_WAMREGLib = Guid.initString("29822aa8-f302-11d0-9953-00c04fd919c1");
pub const CLSID_WamAdmin = Guid.initString("61738644-f196-11d0-9953-00c04fd919c1");
pub const APPSTATUS_STOPPED = @as(u32, 0);
pub const APPSTATUS_RUNNING = @as(u32, 1);
pub const APPSTATUS_NOTDEFINED = @as(u32, 2);
pub const METADATA_MAX_NAME_LEN = @as(u32, 256);
pub const METADATA_PERMISSION_READ = @as(u32, 1);
pub const METADATA_PERMISSION_WRITE = @as(u32, 2);
pub const METADATA_NO_ATTRIBUTES = @as(u32, 0);
pub const METADATA_INHERIT = @as(u32, 1);
pub const METADATA_PARTIAL_PATH = @as(u32, 2);
pub const METADATA_SECURE = @as(u32, 4);
pub const METADATA_REFERENCE = @as(u32, 8);
pub const METADATA_VOLATILE = @as(u32, 16);
pub const METADATA_ISINHERITED = @as(u32, 32);
pub const METADATA_INSERT_PATH = @as(u32, 64);
pub const METADATA_LOCAL_MACHINE_ONLY = @as(u32, 128);
pub const METADATA_NON_SECURE_ONLY = @as(u32, 256);
pub const METADATA_DONT_EXPAND = @as(u32, 512);
pub const MD_BACKUP_OVERWRITE = @as(u32, 1);
pub const MD_BACKUP_SAVE_FIRST = @as(u32, 2);
pub const MD_BACKUP_FORCE_BACKUP = @as(u32, 4);
pub const MD_BACKUP_NEXT_VERSION = @as(u32, 4294967295);
pub const MD_BACKUP_HIGHEST_VERSION = @as(u32, 4294967294);
pub const MD_BACKUP_MAX_VERSION = @as(u32, 9999);
pub const MD_BACKUP_MAX_LEN = @as(u32, 100);
pub const MD_HISTORY_LATEST = @as(u32, 1);
pub const MD_EXPORT_INHERITED = @as(u32, 1);
pub const MD_EXPORT_NODE_ONLY = @as(u32, 2);
pub const MD_IMPORT_INHERITED = @as(u32, 1);
pub const MD_IMPORT_NODE_ONLY = @as(u32, 2);
pub const MD_IMPORT_MERGE = @as(u32, 4);
pub const METADATA_MASTER_ROOT_HANDLE = @as(u32, 0);
pub const MD_CHANGE_TYPE_DELETE_OBJECT = @as(u32, 1);
pub const MD_CHANGE_TYPE_ADD_OBJECT = @as(u32, 2);
pub const MD_CHANGE_TYPE_SET_DATA = @as(u32, 4);
pub const MD_CHANGE_TYPE_DELETE_DATA = @as(u32, 8);
pub const MD_CHANGE_TYPE_RENAME_OBJECT = @as(u32, 16);
pub const MD_CHANGE_TYPE_RESTORE = @as(u32, 32);
pub const MD_MAX_CHANGE_ENTRIES = @as(u32, 100);
pub const MD_ERROR_NOT_INITIALIZED = @as(i32, -2146646016);
pub const MD_ERROR_DATA_NOT_FOUND = @as(i32, -2146646015);
pub const MD_ERROR_INVALID_VERSION = @as(i32, -2146646014);
pub const MD_WARNING_PATH_NOT_FOUND = @as(i32, 837635);
pub const MD_WARNING_DUP_NAME = @as(i32, 837636);
pub const MD_WARNING_INVALID_DATA = @as(i32, 837637);
pub const MD_ERROR_SECURE_CHANNEL_FAILURE = @as(i32, -2146646010);
pub const MD_WARNING_PATH_NOT_INSERTED = @as(i32, 837639);
pub const MD_ERROR_CANNOT_REMOVE_SECURE_ATTRIBUTE = @as(i32, -2146646008);
pub const MD_WARNING_SAVE_FAILED = @as(i32, 837641);
pub const MD_ERROR_IISAO_INVALID_SCHEMA = @as(i32, -2146646000);
pub const MD_ERROR_READ_METABASE_FILE = @as(i32, -2146645991);
pub const MD_ERROR_NO_SESSION_KEY = @as(i32, -2146645987);
pub const LIBID_ASPTypeLibrary = Guid.initString("d97a6da0-a85c-11cf-83ae-00a0c90c2bd8");
pub const CLSID_Request = Guid.initString("920c25d0-25d9-11d0-a55f-00a0c90c2091");
pub const CLSID_Response = Guid.initString("46e19ba0-25dd-11d0-a55f-00a0c90c2091");
pub const CLSID_Session = Guid.initString("509f8f20-25de-11d0-a55f-00a0c90c2091");
pub const CLSID_Server = Guid.initString("a506d160-25e0-11d0-a55f-00a0c90c2091");
pub const CLSID_ScriptingContext = Guid.initString("d97a6da0-a868-11cf-83ae-11b0c90c2bd8");
pub const HSE_VERSION_MAJOR = @as(u32, 8);
pub const HSE_VERSION_MINOR = @as(u32, 0);
pub const HSE_LOG_BUFFER_LEN = @as(u32, 80);
pub const HSE_MAX_EXT_DLL_NAME_LEN = @as(u32, 256);
pub const HSE_STATUS_SUCCESS = @as(u32, 1);
pub const HSE_STATUS_SUCCESS_AND_KEEP_CONN = @as(u32, 2);
pub const HSE_STATUS_PENDING = @as(u32, 3);
pub const HSE_STATUS_ERROR = @as(u32, 4);
pub const HSE_REQ_BASE = @as(u32, 0);
pub const HSE_REQ_SEND_URL_REDIRECT_RESP = @as(u32, 1);
pub const HSE_REQ_SEND_URL = @as(u32, 2);
pub const HSE_REQ_SEND_RESPONSE_HEADER = @as(u32, 3);
pub const HSE_REQ_DONE_WITH_SESSION = @as(u32, 4);
pub const HSE_REQ_END_RESERVED = @as(u32, 1000);
pub const HSE_REQ_MAP_URL_TO_PATH = @as(u32, 1001);
pub const HSE_REQ_GET_SSPI_INFO = @as(u32, 1002);
pub const HSE_APPEND_LOG_PARAMETER = @as(u32, 1003);
pub const HSE_REQ_IO_COMPLETION = @as(u32, 1005);
pub const HSE_REQ_TRANSMIT_FILE = @as(u32, 1006);
pub const HSE_REQ_REFRESH_ISAPI_ACL = @as(u32, 1007);
pub const HSE_REQ_IS_KEEP_CONN = @as(u32, 1008);
pub const HSE_REQ_ASYNC_READ_CLIENT = @as(u32, 1010);
pub const HSE_REQ_GET_IMPERSONATION_TOKEN = @as(u32, 1011);
pub const HSE_REQ_MAP_URL_TO_PATH_EX = @as(u32, 1012);
pub const HSE_REQ_ABORTIVE_CLOSE = @as(u32, 1014);
pub const HSE_REQ_GET_CERT_INFO_EX = @as(u32, 1015);
pub const HSE_REQ_SEND_RESPONSE_HEADER_EX = @as(u32, 1016);
pub const HSE_REQ_CLOSE_CONNECTION = @as(u32, 1017);
pub const HSE_REQ_IS_CONNECTED = @as(u32, 1018);
pub const HSE_REQ_MAP_UNICODE_URL_TO_PATH = @as(u32, 1023);
pub const HSE_REQ_MAP_UNICODE_URL_TO_PATH_EX = @as(u32, 1024);
pub const HSE_REQ_EXEC_UNICODE_URL = @as(u32, 1025);
pub const HSE_REQ_EXEC_URL = @as(u32, 1026);
pub const HSE_REQ_GET_EXEC_URL_STATUS = @as(u32, 1027);
pub const HSE_REQ_SEND_CUSTOM_ERROR = @as(u32, 1028);
pub const HSE_REQ_IS_IN_PROCESS = @as(u32, 1030);
pub const HSE_REQ_REPORT_UNHEALTHY = @as(u32, 1032);
pub const HSE_REQ_NORMALIZE_URL = @as(u32, 1033);
pub const HSE_REQ_VECTOR_SEND = @as(u32, 1037);
pub const HSE_REQ_GET_ANONYMOUS_TOKEN = @as(u32, 1038);
pub const HSE_REQ_GET_CACHE_INVALIDATION_CALLBACK = @as(u32, 1040);
pub const HSE_REQ_GET_UNICODE_ANONYMOUS_TOKEN = @as(u32, 1041);
pub const HSE_REQ_GET_TRACE_INFO = @as(u32, 1042);
pub const HSE_REQ_SET_FLUSH_FLAG = @as(u32, 1043);
pub const HSE_REQ_GET_TRACE_INFO_EX = @as(u32, 1044);
pub const HSE_REQ_RAISE_TRACE_EVENT = @as(u32, 1045);
pub const HSE_REQ_GET_CONFIG_OBJECT = @as(u32, 1046);
pub const HSE_REQ_GET_WORKER_PROCESS_SETTINGS = @as(u32, 1047);
pub const HSE_REQ_GET_PROTOCOL_MANAGER_CUSTOM_INTERFACE_CALLBACK = @as(u32, 1048);
pub const HSE_REQ_CANCEL_IO = @as(u32, 1049);
pub const HSE_REQ_GET_CHANNEL_BINDING_TOKEN = @as(u32, 1050);
pub const HSE_TERM_ADVISORY_UNLOAD = @as(u32, 1);
pub const HSE_TERM_MUST_UNLOAD = @as(u32, 2);
pub const HSE_URL_FLAGS_READ = @as(u32, 1);
pub const HSE_URL_FLAGS_WRITE = @as(u32, 2);
pub const HSE_URL_FLAGS_EXECUTE = @as(u32, 4);
pub const HSE_URL_FLAGS_SSL = @as(u32, 8);
pub const HSE_URL_FLAGS_DONT_CACHE = @as(u32, 16);
pub const HSE_URL_FLAGS_NEGO_CERT = @as(u32, 32);
pub const HSE_URL_FLAGS_REQUIRE_CERT = @as(u32, 64);
pub const HSE_URL_FLAGS_MAP_CERT = @as(u32, 128);
pub const HSE_URL_FLAGS_SSL128 = @as(u32, 256);
pub const HSE_URL_FLAGS_SCRIPT = @as(u32, 512);
pub const HSE_URL_FLAGS_MASK = @as(u32, 1023);
pub const HSE_EXEC_URL_NO_HEADERS = @as(u32, 2);
pub const HSE_EXEC_URL_IGNORE_CURRENT_INTERCEPTOR = @as(u32, 4);
pub const HSE_EXEC_URL_IGNORE_VALIDATION_AND_RANGE = @as(u32, 16);
pub const HSE_EXEC_URL_DISABLE_CUSTOM_ERROR = @as(u32, 32);
pub const HSE_EXEC_URL_SSI_CMD = @as(u32, 64);
pub const HSE_EXEC_URL_HTTP_CACHE_ELIGIBLE = @as(u32, 128);
pub const HSE_VECTOR_ELEMENT_TYPE_MEMORY_BUFFER = @as(u32, 0);
pub const HSE_VECTOR_ELEMENT_TYPE_FILE_HANDLE = @as(u32, 1);
pub const HSE_APP_FLAG_IN_PROCESS = @as(u32, 0);
pub const HSE_APP_FLAG_ISOLATED_OOP = @as(u32, 1);
pub const HSE_APP_FLAG_POOLED_OOP = @as(u32, 2);
pub const SF_MAX_USERNAME = @as(u32, 257);
pub const SF_MAX_PASSWORD = @as(u32, 257);
pub const SF_MAX_AUTH_TYPE = @as(u32, 33);
pub const SF_MAX_FILTER_DESC_LEN = @as(u32, 257);
pub const SF_DENIED_LOGON = @as(u32, 1);
pub const SF_DENIED_RESOURCE = @as(u32, 2);
pub const SF_DENIED_FILTER = @as(u32, 4);
pub const SF_DENIED_APPLICATION = @as(u32, 8);
pub const SF_DENIED_BY_CONFIG = @as(u32, 65536);
pub const SF_NOTIFY_SECURE_PORT = @as(u32, 1);
pub const SF_NOTIFY_NONSECURE_PORT = @as(u32, 2);
pub const SF_NOTIFY_READ_RAW_DATA = @as(u32, 32768);
pub const SF_NOTIFY_PREPROC_HEADERS = @as(u32, 16384);
pub const SF_NOTIFY_AUTHENTICATION = @as(u32, 8192);
pub const SF_NOTIFY_URL_MAP = @as(u32, 4096);
pub const SF_NOTIFY_ACCESS_DENIED = @as(u32, 2048);
pub const SF_NOTIFY_SEND_RESPONSE = @as(u32, 64);
pub const SF_NOTIFY_SEND_RAW_DATA = @as(u32, 1024);
pub const SF_NOTIFY_LOG = @as(u32, 512);
pub const SF_NOTIFY_END_OF_REQUEST = @as(u32, 128);
pub const SF_NOTIFY_END_OF_NET_SESSION = @as(u32, 256);
pub const SF_NOTIFY_AUTH_COMPLETE = @as(u32, 67108864);
pub const SF_NOTIFY_ORDER_HIGH = @as(u32, 524288);
pub const SF_NOTIFY_ORDER_MEDIUM = @as(u32, 262144);
pub const SF_NOTIFY_ORDER_LOW = @as(u32, 131072);
pub const SF_NOTIFY_ORDER_DEFAULT = @as(u32, 131072);
pub const DISPID_HTTPREQUEST_BASE = @as(u32, 1);
pub const DISPID_HTTPREQUEST_OPEN = @as(u32, 1);
pub const DISPID_HTTPREQUEST_SETREQUESTHEADER = @as(u32, 2);
pub const DISPID_HTTPREQUEST_GETRESPONSEHEADER = @as(u32, 3);
pub const DISPID_HTTPREQUEST_GETALLRESPONSEHEADERS = @as(u32, 4);
pub const DISPID_HTTPREQUEST_SEND = @as(u32, 5);
pub const DISPID_HTTPREQUEST_OPTION = @as(u32, 6);
pub const DISPID_HTTPREQUEST_STATUS = @as(u32, 7);
pub const DISPID_HTTPREQUEST_STATUSTEXT = @as(u32, 8);
pub const DISPID_HTTPREQUEST_RESPONSETEXT = @as(u32, 9);
pub const DISPID_HTTPREQUEST_RESPONSEBODY = @as(u32, 10);
pub const DISPID_HTTPREQUEST_RESPONSESTREAM = @as(u32, 11);
pub const DISPID_HTTPREQUEST_ABORT = @as(u32, 12);
pub const DISPID_HTTPREQUEST_SETPROXY = @as(u32, 13);
pub const DISPID_HTTPREQUEST_SETCREDENTIALS = @as(u32, 14);
pub const DISPID_HTTPREQUEST_WAITFORRESPONSE = @as(u32, 15);
pub const DISPID_HTTPREQUEST_SETTIMEOUTS = @as(u32, 16);
pub const DISPID_HTTPREQUEST_SETCLIENTCERTIFICATE = @as(u32, 17);
pub const DISPID_HTTPREQUEST_SETAUTOLOGONPOLICY = @as(u32, 18);
pub const HTTP_TRACE_EVENT_FLAG_STATIC_DESCRIPTIVE_FIELDS = @as(u32, 1);
pub const HTTP_TRACE_LEVEL_START = @as(u32, 6);
pub const HTTP_TRACE_LEVEL_END = @as(u32, 7);
pub const GUID_IIS_ALL_TRACE_PROVIDERS = Guid.initString("00000000-0000-0000-0000-000000000000");
pub const GUID_IIS_WWW_SERVER_TRACE_PROVIDER = Guid.initString("3a2a4e84-4c21-4981-ae10-3fda0d9b0f83");
pub const GUID_IIS_WWW_SERVER_V2_TRACE_PROVIDER = Guid.initString("de4649c9-15e8-4fea-9d85-1cdda520c334");
pub const GUID_IIS_ASPNET_TRACE_PROVIDER = Guid.initString("aff081fe-0247-4275-9c4e-021f3dc1da35");
pub const GUID_IIS_ASP_TRACE_TRACE_PROVIDER = Guid.initString("06b94d9a-b15e-456e-a4ef-37c984a2cb4b");
pub const GUID_IIS_WWW_GLOBAL_TRACE_PROVIDER = Guid.initString("d55d3bc9-cba9-44df-827e-132d3a4596c2");
pub const GUID_IIS_ISAPI_TRACE_PROVIDER = Guid.initString("a1c2040e-8840-4c31-ba11-9871031a19ea");
//--------------------------------------------------------------------------------
// Section: Types (79)
//--------------------------------------------------------------------------------
const CLSID_FtpProvider_Value = @import("../zig.zig").Guid.initString("70bdc667-33b2-45f0-ac52-c3ca46f7a656");
pub const CLSID_FtpProvider = &CLSID_FtpProvider_Value;
pub const CONFIGURATION_ENTRY = extern struct {
bstrKey: ?BSTR,
bstrValue: ?BSTR,
};
const IID_IFtpProviderConstruct_Value = @import("../zig.zig").Guid.initString("4d1a3f7b-412d-447c-b199-64f967e9a2da");
pub const IID_IFtpProviderConstruct = &IID_IFtpProviderConstruct_Value;
pub const IFtpProviderConstruct = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Construct: fn(
self: *const IFtpProviderConstruct,
configurationEntries: ?*SAFEARRAY,
) 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 IFtpProviderConstruct_Construct(self: *const T, configurationEntries: ?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IFtpProviderConstruct.VTable, self.vtable).Construct(@ptrCast(*const IFtpProviderConstruct, self), configurationEntries);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IFtpAuthenticationProvider_Value = @import("../zig.zig").Guid.initString("4659f95c-d5a8-4707-b2fc-6fd5794246cf");
pub const IID_IFtpAuthenticationProvider = &IID_IFtpAuthenticationProvider_Value;
pub const IFtpAuthenticationProvider = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
AuthenticateUser: fn(
self: *const IFtpAuthenticationProvider,
pszSessionId: ?[*:0]const u16,
pszSiteName: ?[*:0]const u16,
pszUserName: ?[*:0]const u16,
pszPassword: ?[*:0]const u16,
ppszCanonicalUserName: ?*?PWSTR,
pfAuthenticated: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFtpAuthenticationProvider_AuthenticateUser(self: *const T, pszSessionId: ?[*:0]const u16, pszSiteName: ?[*:0]const u16, pszUserName: ?[*:0]const u16, pszPassword: ?[*:0]const u16, ppszCanonicalUserName: ?*?PWSTR, pfAuthenticated: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IFtpAuthenticationProvider.VTable, self.vtable).AuthenticateUser(@ptrCast(*const IFtpAuthenticationProvider, self), pszSessionId, pszSiteName, pszUserName, pszPassword, ppszCanonicalUserName, pfAuthenticated);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_AsyncIFtpAuthenticationProvider_Value = @import("../zig.zig").Guid.initString("c24efb65-9f3e-4996-8fb1-ce166916bab5");
pub const IID_AsyncIFtpAuthenticationProvider = &IID_AsyncIFtpAuthenticationProvider_Value;
pub const AsyncIFtpAuthenticationProvider = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Begin_AuthenticateUser: fn(
self: *const AsyncIFtpAuthenticationProvider,
pszSessionId: ?[*:0]const u16,
pszSiteName: ?[*:0]const u16,
pszUserName: ?[*:0]const u16,
pszPassword: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Finish_AuthenticateUser: fn(
self: *const AsyncIFtpAuthenticationProvider,
ppszCanonicalUserName: ?*?PWSTR,
pfAuthenticated: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn AsyncIFtpAuthenticationProvider_Begin_AuthenticateUser(self: *const T, pszSessionId: ?[*:0]const u16, pszSiteName: ?[*:0]const u16, pszUserName: ?[*:0]const u16, pszPassword: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const AsyncIFtpAuthenticationProvider.VTable, self.vtable).Begin_AuthenticateUser(@ptrCast(*const AsyncIFtpAuthenticationProvider, self), pszSessionId, pszSiteName, pszUserName, pszPassword);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn AsyncIFtpAuthenticationProvider_Finish_AuthenticateUser(self: *const T, ppszCanonicalUserName: ?*?PWSTR, pfAuthenticated: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const AsyncIFtpAuthenticationProvider.VTable, self.vtable).Finish_AuthenticateUser(@ptrCast(*const AsyncIFtpAuthenticationProvider, self), ppszCanonicalUserName, pfAuthenticated);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IFtpRoleProvider_Value = @import("../zig.zig").Guid.initString("909c850d-8ca0-4674-96b8-cc2941535725");
pub const IID_IFtpRoleProvider = &IID_IFtpRoleProvider_Value;
pub const IFtpRoleProvider = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
IsUserInRole: fn(
self: *const IFtpRoleProvider,
pszSessionId: ?[*:0]const u16,
pszSiteName: ?[*:0]const u16,
pszUserName: ?[*:0]const u16,
pszRole: ?[*:0]const u16,
pfIsInRole: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFtpRoleProvider_IsUserInRole(self: *const T, pszSessionId: ?[*:0]const u16, pszSiteName: ?[*:0]const u16, pszUserName: ?[*:0]const u16, pszRole: ?[*:0]const u16, pfIsInRole: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IFtpRoleProvider.VTable, self.vtable).IsUserInRole(@ptrCast(*const IFtpRoleProvider, self), pszSessionId, pszSiteName, pszUserName, pszRole, pfIsInRole);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_AsyncIFtpRoleProvider_Value = @import("../zig.zig").Guid.initString("3e83bf99-70ec-41ca-84b6-aca7c7a62caf");
pub const IID_AsyncIFtpRoleProvider = &IID_AsyncIFtpRoleProvider_Value;
pub const AsyncIFtpRoleProvider = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Begin_IsUserInRole: fn(
self: *const AsyncIFtpRoleProvider,
pszSessionId: ?[*:0]const u16,
pszSiteName: ?[*:0]const u16,
pszUserName: ?[*:0]const u16,
pszRole: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Finish_IsUserInRole: fn(
self: *const AsyncIFtpRoleProvider,
pfIsInRole: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn AsyncIFtpRoleProvider_Begin_IsUserInRole(self: *const T, pszSessionId: ?[*:0]const u16, pszSiteName: ?[*:0]const u16, pszUserName: ?[*:0]const u16, pszRole: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const AsyncIFtpRoleProvider.VTable, self.vtable).Begin_IsUserInRole(@ptrCast(*const AsyncIFtpRoleProvider, self), pszSessionId, pszSiteName, pszUserName, pszRole);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn AsyncIFtpRoleProvider_Finish_IsUserInRole(self: *const T, pfIsInRole: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const AsyncIFtpRoleProvider.VTable, self.vtable).Finish_IsUserInRole(@ptrCast(*const AsyncIFtpRoleProvider, self), pfIsInRole);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IFtpHomeDirectoryProvider_Value = @import("../zig.zig").Guid.initString("0933b392-18dd-4097-8b9c-83325c35d9a6");
pub const IID_IFtpHomeDirectoryProvider = &IID_IFtpHomeDirectoryProvider_Value;
pub const IFtpHomeDirectoryProvider = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetUserHomeDirectoryData: fn(
self: *const IFtpHomeDirectoryProvider,
pszSessionId: ?[*:0]const u16,
pszSiteName: ?[*:0]const u16,
pszUserName: ?[*:0]const u16,
ppszHomeDirectoryData: ?*?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 IFtpHomeDirectoryProvider_GetUserHomeDirectoryData(self: *const T, pszSessionId: ?[*:0]const u16, pszSiteName: ?[*:0]const u16, pszUserName: ?[*:0]const u16, ppszHomeDirectoryData: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IFtpHomeDirectoryProvider.VTable, self.vtable).GetUserHomeDirectoryData(@ptrCast(*const IFtpHomeDirectoryProvider, self), pszSessionId, pszSiteName, pszUserName, ppszHomeDirectoryData);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_AsyncIFtpHomeDirectoryProvider_Value = @import("../zig.zig").Guid.initString("73f81638-6295-42bd-a2be-4a657f7c479c");
pub const IID_AsyncIFtpHomeDirectoryProvider = &IID_AsyncIFtpHomeDirectoryProvider_Value;
pub const AsyncIFtpHomeDirectoryProvider = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Begin_GetUserHomeDirectoryData: fn(
self: *const AsyncIFtpHomeDirectoryProvider,
pszSessionId: ?[*:0]const u16,
pszSiteName: ?[*:0]const u16,
pszUserName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Finish_GetUserHomeDirectoryData: fn(
self: *const AsyncIFtpHomeDirectoryProvider,
ppszHomeDirectoryData: ?*?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 AsyncIFtpHomeDirectoryProvider_Begin_GetUserHomeDirectoryData(self: *const T, pszSessionId: ?[*:0]const u16, pszSiteName: ?[*:0]const u16, pszUserName: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const AsyncIFtpHomeDirectoryProvider.VTable, self.vtable).Begin_GetUserHomeDirectoryData(@ptrCast(*const AsyncIFtpHomeDirectoryProvider, self), pszSessionId, pszSiteName, pszUserName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn AsyncIFtpHomeDirectoryProvider_Finish_GetUserHomeDirectoryData(self: *const T, ppszHomeDirectoryData: ?*?PWSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const AsyncIFtpHomeDirectoryProvider.VTable, self.vtable).Finish_GetUserHomeDirectoryData(@ptrCast(*const AsyncIFtpHomeDirectoryProvider, self), ppszHomeDirectoryData);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const LOGGING_PARAMETERS = extern struct {
pszSessionId: ?[*:0]const u16,
pszSiteName: ?[*:0]const u16,
pszUserName: ?[*:0]const u16,
pszHostName: ?[*:0]const u16,
pszRemoteIpAddress: ?[*:0]const u16,
dwRemoteIpPort: u32,
pszLocalIpAddress: ?[*:0]const u16,
dwLocalIpPort: u32,
BytesSent: u64,
BytesReceived: u64,
pszCommand: ?[*:0]const u16,
pszCommandParameters: ?[*:0]const u16,
pszFullPath: ?[*:0]const u16,
dwElapsedMilliseconds: u32,
FtpStatus: u32,
FtpSubStatus: u32,
hrStatus: HRESULT,
pszInformation: ?[*:0]const u16,
};
const IID_IFtpLogProvider_Value = @import("../zig.zig").Guid.initString("a18a94cc-8299-4408-816c-7c3baca1a40e");
pub const IID_IFtpLogProvider = &IID_IFtpLogProvider_Value;
pub const IFtpLogProvider = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Log: fn(
self: *const IFtpLogProvider,
pLoggingParameters: ?*const LOGGING_PARAMETERS,
) 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 IFtpLogProvider_Log(self: *const T, pLoggingParameters: ?*const LOGGING_PARAMETERS) callconv(.Inline) HRESULT {
return @ptrCast(*const IFtpLogProvider.VTable, self.vtable).Log(@ptrCast(*const IFtpLogProvider, self), pLoggingParameters);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_AsyncIFtpLogProvider_Value = @import("../zig.zig").Guid.initString("00a0ae46-2498-48b2-95e6-df678ed7d49f");
pub const IID_AsyncIFtpLogProvider = &IID_AsyncIFtpLogProvider_Value;
pub const AsyncIFtpLogProvider = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Begin_Log: fn(
self: *const AsyncIFtpLogProvider,
pLoggingParameters: ?*const LOGGING_PARAMETERS,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Finish_Log: fn(
self: *const AsyncIFtpLogProvider,
) 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 AsyncIFtpLogProvider_Begin_Log(self: *const T, pLoggingParameters: ?*const LOGGING_PARAMETERS) callconv(.Inline) HRESULT {
return @ptrCast(*const AsyncIFtpLogProvider.VTable, self.vtable).Begin_Log(@ptrCast(*const AsyncIFtpLogProvider, self), pLoggingParameters);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn AsyncIFtpLogProvider_Finish_Log(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const AsyncIFtpLogProvider.VTable, self.vtable).Finish_Log(@ptrCast(*const AsyncIFtpLogProvider, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const FTP_ACCESS = enum(i32) {
NONE = 0,
READ = 1,
WRITE = 2,
READ_WRITE = 3,
};
pub const FTP_ACCESS_NONE = FTP_ACCESS.NONE;
pub const FTP_ACCESS_READ = FTP_ACCESS.READ;
pub const FTP_ACCESS_WRITE = FTP_ACCESS.WRITE;
pub const FTP_ACCESS_READ_WRITE = FTP_ACCESS.READ_WRITE;
const IID_IFtpAuthorizationProvider_Value = @import("../zig.zig").Guid.initString("a50ae7a1-a35a-42b4-a4f3-f4f7057a05d1");
pub const IID_IFtpAuthorizationProvider = &IID_IFtpAuthorizationProvider_Value;
pub const IFtpAuthorizationProvider = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetUserAccessPermission: fn(
self: *const IFtpAuthorizationProvider,
pszSessionId: ?[*:0]const u16,
pszSiteName: ?[*:0]const u16,
pszVirtualPath: ?[*:0]const u16,
pszUserName: ?[*:0]const u16,
pFtpAccess: ?*FTP_ACCESS,
) 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 IFtpAuthorizationProvider_GetUserAccessPermission(self: *const T, pszSessionId: ?[*:0]const u16, pszSiteName: ?[*:0]const u16, pszVirtualPath: ?[*:0]const u16, pszUserName: ?[*:0]const u16, pFtpAccess: ?*FTP_ACCESS) callconv(.Inline) HRESULT {
return @ptrCast(*const IFtpAuthorizationProvider.VTable, self.vtable).GetUserAccessPermission(@ptrCast(*const IFtpAuthorizationProvider, self), pszSessionId, pszSiteName, pszVirtualPath, pszUserName, pFtpAccess);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_AsyncIFtpAuthorizationProvider_Value = @import("../zig.zig").Guid.initString("860dc339-07e5-4a5c-9c61-8820cea012bc");
pub const IID_AsyncIFtpAuthorizationProvider = &IID_AsyncIFtpAuthorizationProvider_Value;
pub const AsyncIFtpAuthorizationProvider = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Begin_GetUserAccessPermission: fn(
self: *const AsyncIFtpAuthorizationProvider,
pszSessionId: ?[*:0]const u16,
pszSiteName: ?[*:0]const u16,
pszVirtualPath: ?[*:0]const u16,
pszUserName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Finish_GetUserAccessPermission: fn(
self: *const AsyncIFtpAuthorizationProvider,
pFtpAccess: ?*FTP_ACCESS,
) 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 AsyncIFtpAuthorizationProvider_Begin_GetUserAccessPermission(self: *const T, pszSessionId: ?[*:0]const u16, pszSiteName: ?[*:0]const u16, pszVirtualPath: ?[*:0]const u16, pszUserName: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const AsyncIFtpAuthorizationProvider.VTable, self.vtable).Begin_GetUserAccessPermission(@ptrCast(*const AsyncIFtpAuthorizationProvider, self), pszSessionId, pszSiteName, pszVirtualPath, pszUserName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn AsyncIFtpAuthorizationProvider_Finish_GetUserAccessPermission(self: *const T, pFtpAccess: ?*FTP_ACCESS) callconv(.Inline) HRESULT {
return @ptrCast(*const AsyncIFtpAuthorizationProvider.VTable, self.vtable).Finish_GetUserAccessPermission(@ptrCast(*const AsyncIFtpAuthorizationProvider, self), pFtpAccess);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const FTP_PROCESS_STATUS = enum(i32) {
CONTINUE = 0,
CLOSE_SESSION = 1,
TERMINATE_SESSION = 2,
REJECT_COMMAND = 3,
};
pub const FTP_PROCESS_CONTINUE = FTP_PROCESS_STATUS.CONTINUE;
pub const FTP_PROCESS_CLOSE_SESSION = FTP_PROCESS_STATUS.CLOSE_SESSION;
pub const FTP_PROCESS_TERMINATE_SESSION = FTP_PROCESS_STATUS.TERMINATE_SESSION;
pub const FTP_PROCESS_REJECT_COMMAND = FTP_PROCESS_STATUS.REJECT_COMMAND;
pub const PRE_PROCESS_PARAMETERS = extern struct {
pszSessionId: ?[*:0]const u16,
pszSiteName: ?[*:0]const u16,
pszUserName: ?[*:0]const u16,
pszHostName: ?[*:0]const u16,
pszRemoteIpAddress: ?[*:0]const u16,
dwRemoteIpPort: u32,
pszLocalIpAddress: ?[*:0]const u16,
dwLocalIpPort: u32,
pszCommand: ?[*:0]const u16,
pszCommandParameters: ?[*:0]const u16,
SessionStartTime: FILETIME,
BytesSentPerSession: u64,
BytesReceivedPerSession: u64,
};
const IID_IFtpPreprocessProvider_Value = @import("../zig.zig").Guid.initString("a3c19b60-5a28-471a-8f93-ab30411cee82");
pub const IID_IFtpPreprocessProvider = &IID_IFtpPreprocessProvider_Value;
pub const IFtpPreprocessProvider = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
HandlePreprocess: fn(
self: *const IFtpPreprocessProvider,
pPreProcessParameters: ?*const PRE_PROCESS_PARAMETERS,
pFtpProcessStatus: ?*FTP_PROCESS_STATUS,
) 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 IFtpPreprocessProvider_HandlePreprocess(self: *const T, pPreProcessParameters: ?*const PRE_PROCESS_PARAMETERS, pFtpProcessStatus: ?*FTP_PROCESS_STATUS) callconv(.Inline) HRESULT {
return @ptrCast(*const IFtpPreprocessProvider.VTable, self.vtable).HandlePreprocess(@ptrCast(*const IFtpPreprocessProvider, self), pPreProcessParameters, pFtpProcessStatus);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_AsyncIFtpPreprocessProvider_Value = @import("../zig.zig").Guid.initString("6ff5fd8f-fd8e-48b1-a3e0-bf7073db4db5");
pub const IID_AsyncIFtpPreprocessProvider = &IID_AsyncIFtpPreprocessProvider_Value;
pub const AsyncIFtpPreprocessProvider = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Begin_HandlePreprocess: fn(
self: *const AsyncIFtpPreprocessProvider,
pPreProcessParameters: ?*const PRE_PROCESS_PARAMETERS,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Finish_HandlePreprocess: fn(
self: *const AsyncIFtpPreprocessProvider,
pFtpProcessStatus: ?*FTP_PROCESS_STATUS,
) 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 AsyncIFtpPreprocessProvider_Begin_HandlePreprocess(self: *const T, pPreProcessParameters: ?*const PRE_PROCESS_PARAMETERS) callconv(.Inline) HRESULT {
return @ptrCast(*const AsyncIFtpPreprocessProvider.VTable, self.vtable).Begin_HandlePreprocess(@ptrCast(*const AsyncIFtpPreprocessProvider, self), pPreProcessParameters);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn AsyncIFtpPreprocessProvider_Finish_HandlePreprocess(self: *const T, pFtpProcessStatus: ?*FTP_PROCESS_STATUS) callconv(.Inline) HRESULT {
return @ptrCast(*const AsyncIFtpPreprocessProvider.VTable, self.vtable).Finish_HandlePreprocess(@ptrCast(*const AsyncIFtpPreprocessProvider, self), pFtpProcessStatus);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const POST_PROCESS_PARAMETERS = extern struct {
pszSessionId: ?[*:0]const u16,
pszSiteName: ?[*:0]const u16,
pszUserName: ?[*:0]const u16,
pszHostName: ?[*:0]const u16,
pszRemoteIpAddress: ?[*:0]const u16,
dwRemoteIpPort: u32,
pszLocalIpAddress: ?[*:0]const u16,
dwLocalIpPort: u32,
BytesSent: u64,
BytesReceived: u64,
pszCommand: ?[*:0]const u16,
pszCommandParameters: ?[*:0]const u16,
pszFullPath: ?[*:0]const u16,
pszPhysicalPath: ?[*:0]const u16,
FtpStatus: u32,
FtpSubStatus: u32,
hrStatus: HRESULT,
SessionStartTime: FILETIME,
BytesSentPerSession: u64,
BytesReceivedPerSession: u64,
};
const IID_IFtpPostprocessProvider_Value = @import("../zig.zig").Guid.initString("4522cbc6-16cd-49ad-8653-9a2c579e4280");
pub const IID_IFtpPostprocessProvider = &IID_IFtpPostprocessProvider_Value;
pub const IFtpPostprocessProvider = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
HandlePostprocess: fn(
self: *const IFtpPostprocessProvider,
pPostProcessParameters: ?*const POST_PROCESS_PARAMETERS,
pFtpProcessStatus: ?*FTP_PROCESS_STATUS,
) 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 IFtpPostprocessProvider_HandlePostprocess(self: *const T, pPostProcessParameters: ?*const POST_PROCESS_PARAMETERS, pFtpProcessStatus: ?*FTP_PROCESS_STATUS) callconv(.Inline) HRESULT {
return @ptrCast(*const IFtpPostprocessProvider.VTable, self.vtable).HandlePostprocess(@ptrCast(*const IFtpPostprocessProvider, self), pPostProcessParameters, pFtpProcessStatus);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_AsyncIFtpPostprocessProvider_Value = @import("../zig.zig").Guid.initString("a16b2542-9694-4eb1-a564-6c2e91fdc133");
pub const IID_AsyncIFtpPostprocessProvider = &IID_AsyncIFtpPostprocessProvider_Value;
pub const AsyncIFtpPostprocessProvider = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Begin_HandlePostprocess: fn(
self: *const AsyncIFtpPostprocessProvider,
pPostProcessParameters: ?*const POST_PROCESS_PARAMETERS,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Finish_HandlePostprocess: fn(
self: *const AsyncIFtpPostprocessProvider,
pFtpProcessStatus: ?*FTP_PROCESS_STATUS,
) 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 AsyncIFtpPostprocessProvider_Begin_HandlePostprocess(self: *const T, pPostProcessParameters: ?*const POST_PROCESS_PARAMETERS) callconv(.Inline) HRESULT {
return @ptrCast(*const AsyncIFtpPostprocessProvider.VTable, self.vtable).Begin_HandlePostprocess(@ptrCast(*const AsyncIFtpPostprocessProvider, self), pPostProcessParameters);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn AsyncIFtpPostprocessProvider_Finish_HandlePostprocess(self: *const T, pFtpProcessStatus: ?*FTP_PROCESS_STATUS) callconv(.Inline) HRESULT {
return @ptrCast(*const AsyncIFtpPostprocessProvider.VTable, self.vtable).Finish_HandlePostprocess(@ptrCast(*const AsyncIFtpPostprocessProvider, self), pFtpProcessStatus);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IADMEXT_Value = @import("../zig.zig").Guid.initString("51dfe970-f6f2-11d0-b9bd-00a0c922e750");
pub const IID_IADMEXT = &IID_IADMEXT_Value;
pub const IADMEXT = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Initialize: fn(
self: *const IADMEXT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumDcomCLSIDs: fn(
self: *const IADMEXT,
pclsidDcom: ?*Guid,
dwEnumIndex: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Terminate: fn(
self: *const IADMEXT,
) 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 IADMEXT_Initialize(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IADMEXT.VTable, self.vtable).Initialize(@ptrCast(*const IADMEXT, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IADMEXT_EnumDcomCLSIDs(self: *const T, pclsidDcom: ?*Guid, dwEnumIndex: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IADMEXT.VTable, self.vtable).EnumDcomCLSIDs(@ptrCast(*const IADMEXT, self), pclsidDcom, dwEnumIndex);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IADMEXT_Terminate(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IADMEXT.VTable, self.vtable).Terminate(@ptrCast(*const IADMEXT, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const METADATATYPES = enum(i32) {
ALL_METADATA = 0,
DWORD_METADATA = 1,
STRING_METADATA = 2,
BINARY_METADATA = 3,
EXPANDSZ_METADATA = 4,
MULTISZ_METADATA = 5,
INVALID_END_METADATA = 6,
};
pub const ALL_METADATA = METADATATYPES.ALL_METADATA;
pub const DWORD_METADATA = METADATATYPES.DWORD_METADATA;
pub const STRING_METADATA = METADATATYPES.STRING_METADATA;
pub const BINARY_METADATA = METADATATYPES.BINARY_METADATA;
pub const EXPANDSZ_METADATA = METADATATYPES.EXPANDSZ_METADATA;
pub const MULTISZ_METADATA = METADATATYPES.MULTISZ_METADATA;
pub const INVALID_END_METADATA = METADATATYPES.INVALID_END_METADATA;
pub const METADATA_RECORD = extern struct {
dwMDIdentifier: u32,
dwMDAttributes: u32,
dwMDUserType: u32,
dwMDDataType: u32,
dwMDDataLen: u32,
pbMDData: ?*u8,
dwMDDataTag: u32,
};
pub const METADATA_GETALL_RECORD = extern struct {
dwMDIdentifier: u32,
dwMDAttributes: u32,
dwMDUserType: u32,
dwMDDataType: u32,
dwMDDataLen: u32,
dwMDDataOffset: u32,
dwMDDataTag: u32,
};
pub const METADATA_GETALL_INTERNAL_RECORD = extern struct {
dwMDIdentifier: u32,
dwMDAttributes: u32,
dwMDUserType: u32,
dwMDDataType: u32,
dwMDDataLen: u32,
Anonymous: extern union {
dwMDDataOffset: usize,
pbMDData: ?*u8,
},
dwMDDataTag: u32,
};
pub const METADATA_HANDLE_INFO = extern struct {
dwMDPermissions: u32,
dwMDSystemChangeNumber: u32,
};
pub const MD_CHANGE_OBJECT_W = extern struct {
pszMDPath: ?PWSTR,
dwMDChangeType: u32,
dwMDNumDataIDs: u32,
pdwMDDataIDs: ?*u32,
};
const IID_IMSAdminBaseW_Value = @import("../zig.zig").Guid.initString("70b51430-b6ca-11d0-b9b9-00a0c922e750");
pub const IID_IMSAdminBaseW = &IID_IMSAdminBaseW_Value;
pub const IMSAdminBaseW = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
AddKey: fn(
self: *const IMSAdminBaseW,
hMDHandle: u32,
pszMDPath: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
DeleteKey: fn(
self: *const IMSAdminBaseW,
hMDHandle: u32,
pszMDPath: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
DeleteChildKeys: fn(
self: *const IMSAdminBaseW,
hMDHandle: u32,
pszMDPath: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumKeys: fn(
self: *const IMSAdminBaseW,
hMDHandle: u32,
pszMDPath: ?[*:0]const u16,
pszMDName: *[256]u16,
dwMDEnumObjectIndex: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CopyKey: fn(
self: *const IMSAdminBaseW,
hMDSourceHandle: u32,
pszMDSourcePath: ?[*:0]const u16,
hMDDestHandle: u32,
pszMDDestPath: ?[*:0]const u16,
bMDOverwriteFlag: BOOL,
bMDCopyFlag: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
RenameKey: fn(
self: *const IMSAdminBaseW,
hMDHandle: u32,
pszMDPath: ?[*:0]const u16,
pszMDNewName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetData: fn(
self: *const IMSAdminBaseW,
hMDHandle: u32,
pszMDPath: ?[*:0]const u16,
pmdrMDData: ?*METADATA_RECORD,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetData: fn(
self: *const IMSAdminBaseW,
hMDHandle: u32,
pszMDPath: ?[*:0]const u16,
pmdrMDData: ?*METADATA_RECORD,
pdwMDRequiredDataLen: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
DeleteData: fn(
self: *const IMSAdminBaseW,
hMDHandle: u32,
pszMDPath: ?[*:0]const u16,
dwMDIdentifier: u32,
dwMDDataType: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumData: fn(
self: *const IMSAdminBaseW,
hMDHandle: u32,
pszMDPath: ?[*:0]const u16,
pmdrMDData: ?*METADATA_RECORD,
dwMDEnumDataIndex: u32,
pdwMDRequiredDataLen: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetAllData: fn(
self: *const IMSAdminBaseW,
hMDHandle: u32,
pszMDPath: ?[*:0]const u16,
dwMDAttributes: u32,
dwMDUserType: u32,
dwMDDataType: u32,
pdwMDNumDataEntries: ?*u32,
pdwMDDataSetNumber: ?*u32,
dwMDBufferSize: u32,
pbMDBuffer: ?*u8,
pdwMDRequiredBufferSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
DeleteAllData: fn(
self: *const IMSAdminBaseW,
hMDHandle: u32,
pszMDPath: ?[*:0]const u16,
dwMDUserType: u32,
dwMDDataType: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CopyData: fn(
self: *const IMSAdminBaseW,
hMDSourceHandle: u32,
pszMDSourcePath: ?[*:0]const u16,
hMDDestHandle: u32,
pszMDDestPath: ?[*:0]const u16,
dwMDAttributes: u32,
dwMDUserType: u32,
dwMDDataType: u32,
bMDCopyFlag: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDataPaths: fn(
self: *const IMSAdminBaseW,
hMDHandle: u32,
pszMDPath: ?[*:0]const u16,
dwMDIdentifier: u32,
dwMDDataType: u32,
dwMDBufferSize: u32,
pszBuffer: [*:0]u16,
pdwMDRequiredBufferSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
OpenKey: fn(
self: *const IMSAdminBaseW,
hMDHandle: u32,
pszMDPath: ?[*:0]const u16,
dwMDAccessRequested: u32,
dwMDTimeOut: u32,
phMDNewHandle: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CloseKey: fn(
self: *const IMSAdminBaseW,
hMDHandle: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ChangePermissions: fn(
self: *const IMSAdminBaseW,
hMDHandle: u32,
dwMDTimeOut: u32,
dwMDAccessRequested: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SaveData: fn(
self: *const IMSAdminBaseW,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetHandleInfo: fn(
self: *const IMSAdminBaseW,
hMDHandle: u32,
pmdhiInfo: ?*METADATA_HANDLE_INFO,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetSystemChangeNumber: fn(
self: *const IMSAdminBaseW,
pdwSystemChangeNumber: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDataSetNumber: fn(
self: *const IMSAdminBaseW,
hMDHandle: u32,
pszMDPath: ?[*:0]const u16,
pdwMDDataSetNumber: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetLastChangeTime: fn(
self: *const IMSAdminBaseW,
hMDHandle: u32,
pszMDPath: ?[*:0]const u16,
pftMDLastChangeTime: ?*FILETIME,
bLocalTime: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetLastChangeTime: fn(
self: *const IMSAdminBaseW,
hMDHandle: u32,
pszMDPath: ?[*:0]const u16,
pftMDLastChangeTime: ?*FILETIME,
bLocalTime: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
KeyExchangePhase1: fn(
self: *const IMSAdminBaseW,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
KeyExchangePhase2: fn(
self: *const IMSAdminBaseW,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Backup: fn(
self: *const IMSAdminBaseW,
pszMDBackupLocation: ?[*:0]const u16,
dwMDVersion: u32,
dwMDFlags: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Restore: fn(
self: *const IMSAdminBaseW,
pszMDBackupLocation: ?[*:0]const u16,
dwMDVersion: u32,
dwMDFlags: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumBackups: fn(
self: *const IMSAdminBaseW,
pszMDBackupLocation: *[256]u16,
pdwMDVersion: ?*u32,
pftMDBackupTime: ?*FILETIME,
dwMDEnumIndex: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
DeleteBackup: fn(
self: *const IMSAdminBaseW,
pszMDBackupLocation: ?[*:0]const u16,
dwMDVersion: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
UnmarshalInterface: fn(
self: *const IMSAdminBaseW,
piadmbwInterface: ?*?*IMSAdminBaseW,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetServerGuid: fn(
self: *const IMSAdminBaseW,
) 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 IMSAdminBaseW_AddKey(self: *const T, hMDHandle: u32, pszMDPath: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).AddKey(@ptrCast(*const IMSAdminBaseW, self), hMDHandle, pszMDPath);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_DeleteKey(self: *const T, hMDHandle: u32, pszMDPath: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).DeleteKey(@ptrCast(*const IMSAdminBaseW, self), hMDHandle, pszMDPath);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_DeleteChildKeys(self: *const T, hMDHandle: u32, pszMDPath: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).DeleteChildKeys(@ptrCast(*const IMSAdminBaseW, self), hMDHandle, pszMDPath);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_EnumKeys(self: *const T, hMDHandle: u32, pszMDPath: ?[*:0]const u16, pszMDName: *[256]u16, dwMDEnumObjectIndex: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).EnumKeys(@ptrCast(*const IMSAdminBaseW, self), hMDHandle, pszMDPath, pszMDName, dwMDEnumObjectIndex);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_CopyKey(self: *const T, hMDSourceHandle: u32, pszMDSourcePath: ?[*:0]const u16, hMDDestHandle: u32, pszMDDestPath: ?[*:0]const u16, bMDOverwriteFlag: BOOL, bMDCopyFlag: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).CopyKey(@ptrCast(*const IMSAdminBaseW, self), hMDSourceHandle, pszMDSourcePath, hMDDestHandle, pszMDDestPath, bMDOverwriteFlag, bMDCopyFlag);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_RenameKey(self: *const T, hMDHandle: u32, pszMDPath: ?[*:0]const u16, pszMDNewName: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).RenameKey(@ptrCast(*const IMSAdminBaseW, self), hMDHandle, pszMDPath, pszMDNewName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_SetData(self: *const T, hMDHandle: u32, pszMDPath: ?[*:0]const u16, pmdrMDData: ?*METADATA_RECORD) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).SetData(@ptrCast(*const IMSAdminBaseW, self), hMDHandle, pszMDPath, pmdrMDData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_GetData(self: *const T, hMDHandle: u32, pszMDPath: ?[*:0]const u16, pmdrMDData: ?*METADATA_RECORD, pdwMDRequiredDataLen: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).GetData(@ptrCast(*const IMSAdminBaseW, self), hMDHandle, pszMDPath, pmdrMDData, pdwMDRequiredDataLen);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_DeleteData(self: *const T, hMDHandle: u32, pszMDPath: ?[*:0]const u16, dwMDIdentifier: u32, dwMDDataType: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).DeleteData(@ptrCast(*const IMSAdminBaseW, self), hMDHandle, pszMDPath, dwMDIdentifier, dwMDDataType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_EnumData(self: *const T, hMDHandle: u32, pszMDPath: ?[*:0]const u16, pmdrMDData: ?*METADATA_RECORD, dwMDEnumDataIndex: u32, pdwMDRequiredDataLen: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).EnumData(@ptrCast(*const IMSAdminBaseW, self), hMDHandle, pszMDPath, pmdrMDData, dwMDEnumDataIndex, pdwMDRequiredDataLen);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_GetAllData(self: *const T, hMDHandle: u32, pszMDPath: ?[*:0]const u16, dwMDAttributes: u32, dwMDUserType: u32, dwMDDataType: u32, pdwMDNumDataEntries: ?*u32, pdwMDDataSetNumber: ?*u32, dwMDBufferSize: u32, pbMDBuffer: ?*u8, pdwMDRequiredBufferSize: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).GetAllData(@ptrCast(*const IMSAdminBaseW, self), hMDHandle, pszMDPath, dwMDAttributes, dwMDUserType, dwMDDataType, pdwMDNumDataEntries, pdwMDDataSetNumber, dwMDBufferSize, pbMDBuffer, pdwMDRequiredBufferSize);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_DeleteAllData(self: *const T, hMDHandle: u32, pszMDPath: ?[*:0]const u16, dwMDUserType: u32, dwMDDataType: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).DeleteAllData(@ptrCast(*const IMSAdminBaseW, self), hMDHandle, pszMDPath, dwMDUserType, dwMDDataType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_CopyData(self: *const T, hMDSourceHandle: u32, pszMDSourcePath: ?[*:0]const u16, hMDDestHandle: u32, pszMDDestPath: ?[*:0]const u16, dwMDAttributes: u32, dwMDUserType: u32, dwMDDataType: u32, bMDCopyFlag: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).CopyData(@ptrCast(*const IMSAdminBaseW, self), hMDSourceHandle, pszMDSourcePath, hMDDestHandle, pszMDDestPath, dwMDAttributes, dwMDUserType, dwMDDataType, bMDCopyFlag);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_GetDataPaths(self: *const T, hMDHandle: u32, pszMDPath: ?[*:0]const u16, dwMDIdentifier: u32, dwMDDataType: u32, dwMDBufferSize: u32, pszBuffer: [*:0]u16, pdwMDRequiredBufferSize: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).GetDataPaths(@ptrCast(*const IMSAdminBaseW, self), hMDHandle, pszMDPath, dwMDIdentifier, dwMDDataType, dwMDBufferSize, pszBuffer, pdwMDRequiredBufferSize);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_OpenKey(self: *const T, hMDHandle: u32, pszMDPath: ?[*:0]const u16, dwMDAccessRequested: u32, dwMDTimeOut: u32, phMDNewHandle: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).OpenKey(@ptrCast(*const IMSAdminBaseW, self), hMDHandle, pszMDPath, dwMDAccessRequested, dwMDTimeOut, phMDNewHandle);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_CloseKey(self: *const T, hMDHandle: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).CloseKey(@ptrCast(*const IMSAdminBaseW, self), hMDHandle);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_ChangePermissions(self: *const T, hMDHandle: u32, dwMDTimeOut: u32, dwMDAccessRequested: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).ChangePermissions(@ptrCast(*const IMSAdminBaseW, self), hMDHandle, dwMDTimeOut, dwMDAccessRequested);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_SaveData(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).SaveData(@ptrCast(*const IMSAdminBaseW, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_GetHandleInfo(self: *const T, hMDHandle: u32, pmdhiInfo: ?*METADATA_HANDLE_INFO) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).GetHandleInfo(@ptrCast(*const IMSAdminBaseW, self), hMDHandle, pmdhiInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_GetSystemChangeNumber(self: *const T, pdwSystemChangeNumber: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).GetSystemChangeNumber(@ptrCast(*const IMSAdminBaseW, self), pdwSystemChangeNumber);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_GetDataSetNumber(self: *const T, hMDHandle: u32, pszMDPath: ?[*:0]const u16, pdwMDDataSetNumber: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).GetDataSetNumber(@ptrCast(*const IMSAdminBaseW, self), hMDHandle, pszMDPath, pdwMDDataSetNumber);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_SetLastChangeTime(self: *const T, hMDHandle: u32, pszMDPath: ?[*:0]const u16, pftMDLastChangeTime: ?*FILETIME, bLocalTime: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).SetLastChangeTime(@ptrCast(*const IMSAdminBaseW, self), hMDHandle, pszMDPath, pftMDLastChangeTime, bLocalTime);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_GetLastChangeTime(self: *const T, hMDHandle: u32, pszMDPath: ?[*:0]const u16, pftMDLastChangeTime: ?*FILETIME, bLocalTime: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).GetLastChangeTime(@ptrCast(*const IMSAdminBaseW, self), hMDHandle, pszMDPath, pftMDLastChangeTime, bLocalTime);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_KeyExchangePhase1(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).KeyExchangePhase1(@ptrCast(*const IMSAdminBaseW, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_KeyExchangePhase2(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).KeyExchangePhase2(@ptrCast(*const IMSAdminBaseW, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_Backup(self: *const T, pszMDBackupLocation: ?[*:0]const u16, dwMDVersion: u32, dwMDFlags: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).Backup(@ptrCast(*const IMSAdminBaseW, self), pszMDBackupLocation, dwMDVersion, dwMDFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_Restore(self: *const T, pszMDBackupLocation: ?[*:0]const u16, dwMDVersion: u32, dwMDFlags: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).Restore(@ptrCast(*const IMSAdminBaseW, self), pszMDBackupLocation, dwMDVersion, dwMDFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_EnumBackups(self: *const T, pszMDBackupLocation: *[256]u16, pdwMDVersion: ?*u32, pftMDBackupTime: ?*FILETIME, dwMDEnumIndex: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).EnumBackups(@ptrCast(*const IMSAdminBaseW, self), pszMDBackupLocation, pdwMDVersion, pftMDBackupTime, dwMDEnumIndex);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_DeleteBackup(self: *const T, pszMDBackupLocation: ?[*:0]const u16, dwMDVersion: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).DeleteBackup(@ptrCast(*const IMSAdminBaseW, self), pszMDBackupLocation, dwMDVersion);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_UnmarshalInterface(self: *const T, piadmbwInterface: ?*?*IMSAdminBaseW) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).UnmarshalInterface(@ptrCast(*const IMSAdminBaseW, self), piadmbwInterface);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseW_GetServerGuid(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseW.VTable, self.vtable).GetServerGuid(@ptrCast(*const IMSAdminBaseW, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const _IIS_CRYPTO_BLOB = extern struct {
placeholder: usize, // TODO: why is this type empty?
};
const IID_IMSAdminBase2W_Value = @import("../zig.zig").Guid.initString("8298d101-f992-43b7-8eca-5052d885b995");
pub const IID_IMSAdminBase2W = &IID_IMSAdminBase2W_Value;
pub const IMSAdminBase2W = extern struct {
pub const VTable = extern struct {
base: IMSAdminBaseW.VTable,
BackupWithPasswd: fn(
self: *const IMSAdminBase2W,
pszMDBackupLocation: ?[*:0]const u16,
dwMDVersion: u32,
dwMDFlags: u32,
pszPasswd: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
RestoreWithPasswd: fn(
self: *const IMSAdminBase2W,
pszMDBackupLocation: ?[*:0]const u16,
dwMDVersion: u32,
dwMDFlags: u32,
pszPasswd: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Export: fn(
self: *const IMSAdminBase2W,
pszPasswd: ?[*:0]const u16,
pszFileName: ?[*:0]const u16,
pszSourcePath: ?[*:0]const u16,
dwMDFlags: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Import: fn(
self: *const IMSAdminBase2W,
pszPasswd: ?[*:0]const u16,
pszFileName: ?[*:0]const u16,
pszSourcePath: ?[*:0]const u16,
pszDestPath: ?[*:0]const u16,
dwMDFlags: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
RestoreHistory: fn(
self: *const IMSAdminBase2W,
pszMDHistoryLocation: ?[*:0]const u16,
dwMDMajorVersion: u32,
dwMDMinorVersion: u32,
dwMDFlags: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumHistory: fn(
self: *const IMSAdminBase2W,
pszMDHistoryLocation: *[256]u16,
pdwMDMajorVersion: ?*u32,
pdwMDMinorVersion: ?*u32,
pftMDHistoryTime: ?*FILETIME,
dwMDEnumIndex: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IMSAdminBaseW.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBase2W_BackupWithPasswd(self: *const T, pszMDBackupLocation: ?[*:0]const u16, dwMDVersion: u32, dwMDFlags: u32, pszPasswd: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBase2W.VTable, self.vtable).BackupWithPasswd(@ptrCast(*const IMSAdminBase2W, self), pszMDBackupLocation, dwMDVersion, dwMDFlags, pszPasswd);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBase2W_RestoreWithPasswd(self: *const T, pszMDBackupLocation: ?[*:0]const u16, dwMDVersion: u32, dwMDFlags: u32, pszPasswd: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBase2W.VTable, self.vtable).RestoreWithPasswd(@ptrCast(*const IMSAdminBase2W, self), pszMDBackupLocation, dwMDVersion, dwMDFlags, pszPasswd);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBase2W_Export(self: *const T, pszPasswd: ?[*:0]const u16, pszFileName: ?[*:0]const u16, pszSourcePath: ?[*:0]const u16, dwMDFlags: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBase2W.VTable, self.vtable).Export(@ptrCast(*const IMSAdminBase2W, self), pszPasswd, pszFileName, pszSourcePath, dwMDFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBase2W_Import(self: *const T, pszPasswd: ?[*:0]const u16, pszFileName: ?[*:0]const u16, pszSourcePath: ?[*:0]const u16, pszDestPath: ?[*:0]const u16, dwMDFlags: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBase2W.VTable, self.vtable).Import(@ptrCast(*const IMSAdminBase2W, self), pszPasswd, pszFileName, pszSourcePath, pszDestPath, dwMDFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBase2W_RestoreHistory(self: *const T, pszMDHistoryLocation: ?[*:0]const u16, dwMDMajorVersion: u32, dwMDMinorVersion: u32, dwMDFlags: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBase2W.VTable, self.vtable).RestoreHistory(@ptrCast(*const IMSAdminBase2W, self), pszMDHistoryLocation, dwMDMajorVersion, dwMDMinorVersion, dwMDFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBase2W_EnumHistory(self: *const T, pszMDHistoryLocation: *[256]u16, pdwMDMajorVersion: ?*u32, pdwMDMinorVersion: ?*u32, pftMDHistoryTime: ?*FILETIME, dwMDEnumIndex: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBase2W.VTable, self.vtable).EnumHistory(@ptrCast(*const IMSAdminBase2W, self), pszMDHistoryLocation, pdwMDMajorVersion, pdwMDMinorVersion, pftMDHistoryTime, dwMDEnumIndex);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IMSAdminBase3W_Value = @import("../zig.zig").Guid.initString("f612954d-3b0b-4c56-9563-227b7be624b4");
pub const IID_IMSAdminBase3W = &IID_IMSAdminBase3W_Value;
pub const IMSAdminBase3W = extern struct {
pub const VTable = extern struct {
base: IMSAdminBase2W.VTable,
GetChildPaths: fn(
self: *const IMSAdminBase3W,
hMDHandle: u32,
pszMDPath: ?[*:0]const u16,
cchMDBufferSize: u32,
pszBuffer: ?[*:0]u16,
pcchMDRequiredBufferSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IMSAdminBase2W.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBase3W_GetChildPaths(self: *const T, hMDHandle: u32, pszMDPath: ?[*:0]const u16, cchMDBufferSize: u32, pszBuffer: ?[*:0]u16, pcchMDRequiredBufferSize: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBase3W.VTable, self.vtable).GetChildPaths(@ptrCast(*const IMSAdminBase3W, self), hMDHandle, pszMDPath, cchMDBufferSize, pszBuffer, pcchMDRequiredBufferSize);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IMSImpExpHelpW_Value = @import("../zig.zig").Guid.initString("29ff67ff-8050-480f-9f30-cc41635f2f9d");
pub const IID_IMSImpExpHelpW = &IID_IMSImpExpHelpW_Value;
pub const IMSImpExpHelpW = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
EnumeratePathsInFile: fn(
self: *const IMSImpExpHelpW,
pszFileName: ?[*:0]const u16,
pszKeyType: ?[*:0]const u16,
dwMDBufferSize: u32,
pszBuffer: ?[*:0]u16,
pdwMDRequiredBufferSize: ?*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 IMSImpExpHelpW_EnumeratePathsInFile(self: *const T, pszFileName: ?[*:0]const u16, pszKeyType: ?[*:0]const u16, dwMDBufferSize: u32, pszBuffer: ?[*:0]u16, pdwMDRequiredBufferSize: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSImpExpHelpW.VTable, self.vtable).EnumeratePathsInFile(@ptrCast(*const IMSImpExpHelpW, self), pszFileName, pszKeyType, dwMDBufferSize, pszBuffer, pdwMDRequiredBufferSize);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IMSAdminBaseSinkW_Value = @import("../zig.zig").Guid.initString("a9e69612-b80d-11d0-b9b9-00a0c922e750");
pub const IID_IMSAdminBaseSinkW = &IID_IMSAdminBaseSinkW_Value;
pub const IMSAdminBaseSinkW = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
SinkNotify: fn(
self: *const IMSAdminBaseSinkW,
dwMDNumElements: u32,
pcoChangeList: [*]MD_CHANGE_OBJECT_W,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ShutdownNotify: fn(
self: *const IMSAdminBaseSinkW,
) 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 IMSAdminBaseSinkW_SinkNotify(self: *const T, dwMDNumElements: u32, pcoChangeList: [*]MD_CHANGE_OBJECT_W) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseSinkW.VTable, self.vtable).SinkNotify(@ptrCast(*const IMSAdminBaseSinkW, self), dwMDNumElements, pcoChangeList);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMSAdminBaseSinkW_ShutdownNotify(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IMSAdminBaseSinkW.VTable, self.vtable).ShutdownNotify(@ptrCast(*const IMSAdminBaseSinkW, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_AsyncIMSAdminBaseSinkW_Value = @import("../zig.zig").Guid.initString("a9e69613-b80d-11d0-b9b9-00a0c922e750");
pub const IID_AsyncIMSAdminBaseSinkW = &IID_AsyncIMSAdminBaseSinkW_Value;
pub const AsyncIMSAdminBaseSinkW = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Begin_SinkNotify: fn(
self: *const AsyncIMSAdminBaseSinkW,
dwMDNumElements: u32,
pcoChangeList: [*]MD_CHANGE_OBJECT_W,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Finish_SinkNotify: fn(
self: *const AsyncIMSAdminBaseSinkW,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Begin_ShutdownNotify: fn(
self: *const AsyncIMSAdminBaseSinkW,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Finish_ShutdownNotify: fn(
self: *const AsyncIMSAdminBaseSinkW,
) 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 AsyncIMSAdminBaseSinkW_Begin_SinkNotify(self: *const T, dwMDNumElements: u32, pcoChangeList: [*]MD_CHANGE_OBJECT_W) callconv(.Inline) HRESULT {
return @ptrCast(*const AsyncIMSAdminBaseSinkW.VTable, self.vtable).Begin_SinkNotify(@ptrCast(*const AsyncIMSAdminBaseSinkW, self), dwMDNumElements, pcoChangeList);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn AsyncIMSAdminBaseSinkW_Finish_SinkNotify(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const AsyncIMSAdminBaseSinkW.VTable, self.vtable).Finish_SinkNotify(@ptrCast(*const AsyncIMSAdminBaseSinkW, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn AsyncIMSAdminBaseSinkW_Begin_ShutdownNotify(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const AsyncIMSAdminBaseSinkW.VTable, self.vtable).Begin_ShutdownNotify(@ptrCast(*const AsyncIMSAdminBaseSinkW, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn AsyncIMSAdminBaseSinkW_Finish_ShutdownNotify(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const AsyncIMSAdminBaseSinkW.VTable, self.vtable).Finish_ShutdownNotify(@ptrCast(*const AsyncIMSAdminBaseSinkW, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const HSE_VERSION_INFO = extern struct {
dwExtensionVersion: u32,
lpszExtensionDesc: [256]CHAR,
};
pub const EXTENSION_CONTROL_BLOCK = extern struct {
cbSize: u32,
dwVersion: u32,
ConnID: ?*anyopaque,
dwHttpStatusCode: u32,
lpszLogData: [80]CHAR,
lpszMethod: ?PSTR,
lpszQueryString: ?PSTR,
lpszPathInfo: ?PSTR,
lpszPathTranslated: ?PSTR,
cbTotalBytes: u32,
cbAvailable: u32,
lpbData: ?*u8,
lpszContentType: ?PSTR,
GetServerVariable: isize,
WriteClient: isize,
ReadClient: isize,
ServerSupportFunction: isize,
};
pub const HSE_URL_MAPEX_INFO = extern struct {
lpszPath: [260]CHAR,
dwFlags: u32,
cchMatchingPath: u32,
cchMatchingURL: u32,
dwReserved1: u32,
dwReserved2: u32,
};
pub const HSE_UNICODE_URL_MAPEX_INFO = extern struct {
lpszPath: [260]u16,
dwFlags: u32,
cchMatchingPath: u32,
cchMatchingURL: u32,
};
pub const PFN_HSE_IO_COMPLETION = fn(
pECB: ?*EXTENSION_CONTROL_BLOCK,
pContext: ?*anyopaque,
cbIO: u32,
dwError: u32,
) callconv(@import("std").os.windows.WINAPI) void;
pub const HSE_TF_INFO = extern struct {
pfnHseIO: ?PFN_HSE_IO_COMPLETION,
pContext: ?*anyopaque,
hFile: ?HANDLE,
pszStatusCode: ?[*:0]const u8,
BytesToWrite: u32,
Offset: u32,
pHead: ?*anyopaque,
HeadLength: u32,
pTail: ?*anyopaque,
TailLength: u32,
dwFlags: u32,
};
pub const HSE_SEND_HEADER_EX_INFO = extern struct {
pszStatus: ?[*:0]const u8,
pszHeader: ?[*:0]const u8,
cchStatus: u32,
cchHeader: u32,
fKeepConn: BOOL,
};
pub const HSE_EXEC_URL_USER_INFO = extern struct {
hImpersonationToken: ?HANDLE,
pszCustomUserName: ?PSTR,
pszCustomAuthType: ?PSTR,
};
pub const HSE_EXEC_URL_ENTITY_INFO = extern struct {
cbAvailable: u32,
lpbData: ?*anyopaque,
};
pub const HSE_EXEC_URL_STATUS = extern struct {
uHttpStatusCode: u16,
uHttpSubStatus: u16,
dwWin32Error: u32,
};
pub const HSE_EXEC_URL_INFO = extern struct {
pszUrl: ?PSTR,
pszMethod: ?PSTR,
pszChildHeaders: ?PSTR,
pUserInfo: ?*HSE_EXEC_URL_USER_INFO,
pEntity: ?*HSE_EXEC_URL_ENTITY_INFO,
dwExecUrlFlags: u32,
};
pub const HSE_EXEC_UNICODE_URL_USER_INFO = extern struct {
hImpersonationToken: ?HANDLE,
pszCustomUserName: ?PWSTR,
pszCustomAuthType: ?PSTR,
};
pub const HSE_EXEC_UNICODE_URL_INFO = extern struct {
pszUrl: ?PWSTR,
pszMethod: ?PSTR,
pszChildHeaders: ?PSTR,
pUserInfo: ?*HSE_EXEC_UNICODE_URL_USER_INFO,
pEntity: ?*HSE_EXEC_URL_ENTITY_INFO,
dwExecUrlFlags: u32,
};
pub const HSE_CUSTOM_ERROR_INFO = extern struct {
pszStatus: ?PSTR,
uHttpSubError: u16,
fAsync: BOOL,
};
pub const HSE_VECTOR_ELEMENT = extern struct {
ElementType: u32,
pvContext: ?*anyopaque,
cbOffset: u64,
cbSize: u64,
};
pub const HSE_RESPONSE_VECTOR = extern struct {
dwFlags: u32,
pszStatus: ?PSTR,
pszHeaders: ?PSTR,
nElementCount: u32,
lpElementArray: ?*HSE_VECTOR_ELEMENT,
};
pub const PFN_HSE_CACHE_INVALIDATION_CALLBACK = fn(
pszUrl: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const CERT_CONTEXT_EX = extern struct {
CertContext: CERT_CONTEXT,
cbAllocated: u32,
dwCertificateFlags: u32,
};
pub const HSE_TRACE_INFO = extern struct {
fTraceRequest: BOOL,
TraceContextId: [16]u8,
dwReserved1: u32,
dwReserved2: u32,
};
pub const PFN_HSE_GET_PROTOCOL_MANAGER_CUSTOM_INTERFACE_CALLBACK = fn(
pszProtocolManagerDll: ?[*:0]const u16,
pszProtocolManagerDllInitFunction: ?[*:0]const u16,
dwCustomInterfaceId: u32,
ppCustomInterface: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const PFN_GETEXTENSIONVERSION = fn(
pVer: ?*HSE_VERSION_INFO,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const PFN_HTTPEXTENSIONPROC = fn(
pECB: ?*EXTENSION_CONTROL_BLOCK,
) callconv(@import("std").os.windows.WINAPI) u32;
pub const PFN_TERMINATEEXTENSION = fn(
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const SF_REQ_TYPE = enum(i32) {
SEND_RESPONSE_HEADER = 0,
ADD_HEADERS_ON_DENIAL = 1,
SET_NEXT_READ_SIZE = 2,
SET_PROXY_INFO = 3,
GET_CONNID = 4,
SET_CERTIFICATE_INFO = 5,
GET_PROPERTY = 6,
NORMALIZE_URL = 7,
DISABLE_NOTIFICATIONS = 8,
};
pub const SF_REQ_SEND_RESPONSE_HEADER = SF_REQ_TYPE.SEND_RESPONSE_HEADER;
pub const SF_REQ_ADD_HEADERS_ON_DENIAL = SF_REQ_TYPE.ADD_HEADERS_ON_DENIAL;
pub const SF_REQ_SET_NEXT_READ_SIZE = SF_REQ_TYPE.SET_NEXT_READ_SIZE;
pub const SF_REQ_SET_PROXY_INFO = SF_REQ_TYPE.SET_PROXY_INFO;
pub const SF_REQ_GET_CONNID = SF_REQ_TYPE.GET_CONNID;
pub const SF_REQ_SET_CERTIFICATE_INFO = SF_REQ_TYPE.SET_CERTIFICATE_INFO;
pub const SF_REQ_GET_PROPERTY = SF_REQ_TYPE.GET_PROPERTY;
pub const SF_REQ_NORMALIZE_URL = SF_REQ_TYPE.NORMALIZE_URL;
pub const SF_REQ_DISABLE_NOTIFICATIONS = SF_REQ_TYPE.DISABLE_NOTIFICATIONS;
pub const SF_PROPERTY_IIS = enum(i32) {
SSL_CTXT = 0,
INSTANCE_NUM_ID = 1,
};
pub const SF_PROPERTY_SSL_CTXT = SF_PROPERTY_IIS.SSL_CTXT;
pub const SF_PROPERTY_INSTANCE_NUM_ID = SF_PROPERTY_IIS.INSTANCE_NUM_ID;
pub const SF_STATUS_TYPE = enum(i32) {
FINISHED = 134217728,
FINISHED_KEEP_CONN = 134217729,
NEXT_NOTIFICATION = 134217730,
HANDLED_NOTIFICATION = 134217731,
ERROR = 134217732,
READ_NEXT = 134217733,
};
pub const SF_STATUS_REQ_FINISHED = SF_STATUS_TYPE.FINISHED;
pub const SF_STATUS_REQ_FINISHED_KEEP_CONN = SF_STATUS_TYPE.FINISHED_KEEP_CONN;
pub const SF_STATUS_REQ_NEXT_NOTIFICATION = SF_STATUS_TYPE.NEXT_NOTIFICATION;
pub const SF_STATUS_REQ_HANDLED_NOTIFICATION = SF_STATUS_TYPE.HANDLED_NOTIFICATION;
pub const SF_STATUS_REQ_ERROR = SF_STATUS_TYPE.ERROR;
pub const SF_STATUS_REQ_READ_NEXT = SF_STATUS_TYPE.READ_NEXT;
pub const HTTP_FILTER_CONTEXT = extern struct {
cbSize: u32,
Revision: u32,
ServerContext: ?*anyopaque,
ulReserved: u32,
fIsSecurePort: BOOL,
pFilterContext: ?*anyopaque,
GetServerVariable: isize,
AddResponseHeaders: isize,
WriteClient: isize,
AllocMem: isize,
ServerSupportFunction: isize,
};
pub const HTTP_FILTER_RAW_DATA = extern struct {
pvInData: ?*anyopaque,
cbInData: u32,
cbInBuffer: u32,
dwReserved: u32,
};
pub const HTTP_FILTER_PREPROC_HEADERS = extern struct {
GetHeader: isize,
SetHeader: isize,
AddHeader: isize,
HttpStatus: u32,
dwReserved: u32,
};
pub const HTTP_FILTER_AUTHENT = extern struct {
pszUser: ?PSTR,
cbUserBuff: u32,
pszPassword: ?PSTR,
cbPasswordBuff: u32,
};
pub const HTTP_FILTER_URL_MAP = extern struct {
pszURL: ?[*:0]const u8,
pszPhysicalPath: ?PSTR,
cbPathBuff: u32,
};
pub const HTTP_FILTER_URL_MAP_EX = extern struct {
pszURL: ?[*:0]const u8,
pszPhysicalPath: ?PSTR,
cbPathBuff: u32,
dwFlags: u32,
cchMatchingPath: u32,
cchMatchingURL: u32,
pszScriptMapEntry: ?[*:0]const u8,
};
pub const HTTP_FILTER_ACCESS_DENIED = extern struct {
pszURL: ?[*:0]const u8,
pszPhysicalPath: ?[*:0]const u8,
dwReason: u32,
};
pub const HTTP_FILTER_LOG = extern struct {
pszClientHostName: ?[*:0]const u8,
pszClientUserName: ?[*:0]const u8,
pszServerName: ?[*:0]const u8,
pszOperation: ?[*:0]const u8,
pszTarget: ?[*:0]const u8,
pszParameters: ?[*:0]const u8,
dwHttpStatus: u32,
dwWin32Status: u32,
dwBytesSent: u32,
dwBytesRecvd: u32,
msTimeForProcessing: u32,
};
pub const HTTP_FILTER_AUTH_COMPLETE_INFO = extern struct {
GetHeader: isize,
SetHeader: isize,
AddHeader: isize,
GetUserToken: isize,
HttpStatus: u32,
fResetAuth: BOOL,
dwReserved: u32,
};
pub const HTTP_FILTER_VERSION = extern struct {
dwServerFilterVersion: u32,
dwFilterVersion: u32,
lpszFilterDesc: [257]CHAR,
dwFlags: u32,
};
pub const HTTP_TRACE_TYPE = enum(i32) {
BYTE = 17,
USHORT = 18,
ULONG = 19,
ULONGLONG = 21,
CHAR = 16,
SHORT = 2,
LONG = 3,
LONGLONG = 20,
LPCWSTR = 31,
LPCSTR = 30,
LPCGUID = 72,
BOOL = 11,
};
pub const HTTP_TRACE_TYPE_BYTE = HTTP_TRACE_TYPE.BYTE;
pub const HTTP_TRACE_TYPE_USHORT = HTTP_TRACE_TYPE.USHORT;
pub const HTTP_TRACE_TYPE_ULONG = HTTP_TRACE_TYPE.ULONG;
pub const HTTP_TRACE_TYPE_ULONGLONG = HTTP_TRACE_TYPE.ULONGLONG;
pub const HTTP_TRACE_TYPE_CHAR = HTTP_TRACE_TYPE.CHAR;
pub const HTTP_TRACE_TYPE_SHORT = HTTP_TRACE_TYPE.SHORT;
pub const HTTP_TRACE_TYPE_LONG = HTTP_TRACE_TYPE.LONG;
pub const HTTP_TRACE_TYPE_LONGLONG = HTTP_TRACE_TYPE.LONGLONG;
pub const HTTP_TRACE_TYPE_LPCWSTR = HTTP_TRACE_TYPE.LPCWSTR;
pub const HTTP_TRACE_TYPE_LPCSTR = HTTP_TRACE_TYPE.LPCSTR;
pub const HTTP_TRACE_TYPE_LPCGUID = HTTP_TRACE_TYPE.LPCGUID;
pub const HTTP_TRACE_TYPE_BOOL = HTTP_TRACE_TYPE.BOOL;
pub const HTTP_TRACE_EVENT = extern struct {
pProviderGuid: ?*const Guid,
dwArea: u32,
pAreaGuid: ?*const Guid,
dwEvent: u32,
pszEventName: ?[*:0]const u16,
dwEventVersion: u32,
dwVerbosity: u32,
pActivityGuid: ?*const Guid,
pRelatedActivityGuid: ?*const Guid,
dwTimeStamp: u32,
dwFlags: u32,
cEventItems: u32,
pEventItems: ?*HTTP_TRACE_EVENT_ITEM,
};
pub const HTTP_TRACE_EVENT_ITEM = extern struct {
pszName: ?[*:0]const u16,
dwDataType: HTTP_TRACE_TYPE,
pbData: ?*u8,
cbData: u32,
pszDataDescription: ?[*:0]const u16,
};
pub const HTTP_TRACE_CONFIGURATION = extern struct {
pProviderGuid: ?*const Guid,
dwAreas: u32,
dwVerbosity: u32,
fProviderEnabled: BOOL,
};
pub const PFN_WEB_CORE_SET_METADATA_DLL_ENTRY = fn(
pszMetadataType: ?[*:0]const u16,
pszValue: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const PFN_WEB_CORE_ACTIVATE = fn(
pszAppHostConfigFile: ?[*:0]const u16,
pszRootWebConfigFile: ?[*:0]const u16,
pszInstanceName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub const PFN_WEB_CORE_SHUTDOWN = fn(
fImmediate: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
//--------------------------------------------------------------------------------
// Section: Functions (4)
//--------------------------------------------------------------------------------
pub extern "RpcProxy" fn GetExtensionVersion(
pVer: ?*HSE_VERSION_INFO,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "RpcProxy" fn HttpExtensionProc(
pECB: ?*EXTENSION_CONTROL_BLOCK,
) callconv(@import("std").os.windows.WINAPI) u32;
pub extern "RpcProxy" fn HttpFilterProc(
pfc: ?*HTTP_FILTER_CONTEXT,
NotificationType: u32,
pvNotification: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) u32;
pub extern "RpcProxy" fn GetFilterVersion(
pVer: ?*HTTP_FILTER_VERSION,
) 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 (12)
//--------------------------------------------------------------------------------
const Guid = @import("../zig.zig").Guid;
const BOOL = @import("../foundation.zig").BOOL;
const BSTR = @import("../foundation.zig").BSTR;
const CERT_CONTEXT = @import("../security/cryptography.zig").CERT_CONTEXT;
const CHAR = @import("../foundation.zig").CHAR;
const FILETIME = @import("../foundation.zig").FILETIME;
const HANDLE = @import("../foundation.zig").HANDLE;
const HRESULT = @import("../foundation.zig").HRESULT;
const IUnknown = @import("../system/com.zig").IUnknown;
const PSTR = @import("../foundation.zig").PSTR;
const PWSTR = @import("../foundation.zig").PWSTR;
const SAFEARRAY = @import("../system/com.zig").SAFEARRAY;
test {
// The following '_ = <FuncPtrType>' lines are a workaround for https://github.com/ziglang/zig/issues/4476
if (@hasDecl(@This(), "PFN_HSE_IO_COMPLETION")) { _ = PFN_HSE_IO_COMPLETION; }
if (@hasDecl(@This(), "PFN_HSE_CACHE_INVALIDATION_CALLBACK")) { _ = PFN_HSE_CACHE_INVALIDATION_CALLBACK; }
if (@hasDecl(@This(), "PFN_HSE_GET_PROTOCOL_MANAGER_CUSTOM_INTERFACE_CALLBACK")) { _ = PFN_HSE_GET_PROTOCOL_MANAGER_CUSTOM_INTERFACE_CALLBACK; }
if (@hasDecl(@This(), "PFN_GETEXTENSIONVERSION")) { _ = PFN_GETEXTENSIONVERSION; }
if (@hasDecl(@This(), "PFN_HTTPEXTENSIONPROC")) { _ = PFN_HTTPEXTENSIONPROC; }
if (@hasDecl(@This(), "PFN_TERMINATEEXTENSION")) { _ = PFN_TERMINATEEXTENSION; }
if (@hasDecl(@This(), "PFN_WEB_CORE_SET_METADATA_DLL_ENTRY")) { _ = PFN_WEB_CORE_SET_METADATA_DLL_ENTRY; }
if (@hasDecl(@This(), "PFN_WEB_CORE_ACTIVATE")) { _ = PFN_WEB_CORE_ACTIVATE; }
if (@hasDecl(@This(), "PFN_WEB_CORE_SHUTDOWN")) { _ = PFN_WEB_CORE_SHUTDOWN; }
@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/iis.zig
|
const std = @import("std");
const Allocator = std.mem.Allocator;
const errors = @import("../errors.zig");
const image = @import("../image.zig");
const FormatInterface = @import("../format_interface.zig").FormatInterface;
const color = @import("../color.zig");
const PixelFormat = @import("../pixel_format.zig").PixelFormat;
const ImageReader = image.ImageReader;
const ImageSeekStream = image.ImageSeekStream;
const ImageFormat = image.ImageFormat;
const ImageInfo = image.ImageInfo;
// TODO: Chroma subsampling
// TODO: Progressive scans
// TODO: Non-baseline sequential DCT
// TODO: Precisions other than 8-bit
const JPEG_DEBUG = false;
const JPEG_VERY_DEBUG = false;
// Marker codes
const Markers = enum(u16) {
// Start of Frame markers, non-differential, Huffman coding
SOF0 = 0xFFC0, // Baseline DCT
SOF1 = 0xFFC1, // Extended sequential DCT
SOF2 = 0xFFC2, // Progressive DCT
SOF3 = 0xFFC3, // Lossless sequential
// Start of Frame markers, differential, Huffman coding
SOF5 = 0xFFC5, // Differential sequential DCT
SOF6 = 0xFFC6, // Differential progressive DCT
SOF7 = 0xFFC7, // Differential lossless sequential
// Start of Frame markers, non-differential, arithmetic coding
SOF9 = 0xFFC9, // Extended sequential DCT
SOF10 = 0xFFCA, // Progressive DCT
SOF11 = 0xFFCB, // Lossless sequential
// Start of Frame markers, differential, arithmetic coding
SOF13 = 0xFFCD, // Differential sequential DCT
SOF14 = 0xFFCE, // Differential progressive DCT
SOF15 = 0xFFCF, // Differential lossless sequential
DefineHuffmanTables = 0xFFC4,
DefineArithmeticCoding = 0xFFCC,
StartOfImage = 0xFFD8,
EndOfImage = 0xFFD9,
StartOfScan = 0xFFDA,
DefineQuantizationTables = 0xFFDB,
DefineNumberOfLines = 0xFFDC,
DefineRestartInterval = 0xFFDD,
DefineHierarchicalProgression = 0xFFDE,
ExpandReferenceComponents = 0xFFDF,
// Add 0-15 as needed.
Application0 = 0xFFE0,
// Add 0-13 as needed.
JpegExtension0 = 0xFFF0,
Comment = 0xFFFE,
};
const DensityUnit = enum {
Pixels,
DotsPerInch,
DotsPerCm,
};
const JFIFHeader = struct {
jfif_revision: u16,
density_unit: DensityUnit,
x_density: u16,
y_density: u16,
fn read(reader: ImageReader, seek_stream: ImageSeekStream) !JFIFHeader {
// Read the first APP0 header.
try seek_stream.seekTo(2);
const maybe_app0_marker = try reader.readIntBig(u16);
if (maybe_app0_marker != @enumToInt(Markers.Application0)) {
return error.App0MarkerDoesNotExist;
}
// Header length
_ = try reader.readIntBig(u16);
var identifier_buffer: [4]u8 = undefined;
_ = try reader.read(identifier_buffer[0..]);
if (!std.mem.eql(u8, identifier_buffer[0..], "JFIF")) {
return error.JfifIdentifierNotSet;
}
// NUL byte after JFIF
_ = try reader.readByte();
const jfif_revision = try reader.readIntBig(u16);
const density_unit = @intToEnum(DensityUnit, try reader.readByte());
const x_density = try reader.readIntBig(u16);
const y_density = try reader.readIntBig(u16);
const thumbnailWidth = try reader.readByte();
const thumbnailHeight = try reader.readByte();
if (thumbnailWidth != 0 or thumbnailHeight != 0) {
return error.ThumbnailImagesUnsupported;
}
// Make sure there are no application markers after us.
if (((try reader.readIntBig(u16)) & 0xFFF0) == @enumToInt(Markers.Application0)) {
return error.ExtraneousApplicationMarker;
}
try seek_stream.seekBy(-2);
return JFIFHeader{
.jfif_revision = jfif_revision,
.density_unit = density_unit,
.x_density = x_density,
.y_density = y_density,
};
}
};
const QuantizationTable = union(enum) {
Q8: [64]u8,
Q16: [64]u16,
pub fn read(precision: u8, reader: ImageReader) !QuantizationTable {
// 0 = 8 bits, 1 = 16 bits
switch (precision) {
0 => {
var table = QuantizationTable{ .Q8 = undefined };
var offset: usize = 0;
while (offset < 64) : (offset += 1) {
const value = try reader.readByte();
table.Q8[ZigzagOffsets[offset]] = value;
}
if (JPEG_DEBUG) {
var i: usize = 0;
while (i < 8) : (i += 1) {
var j: usize = 0;
while (j < 8) : (j += 1) {
std.debug.print("{d:4} ", .{table.Q8[i * 8 + j]});
}
std.debug.print("\n", .{});
}
}
return table;
},
1 => {
var table = QuantizationTable{ .Q16 = undefined };
var offset: usize = 0;
while (offset < 64) : (offset += 1) {
const value = try reader.readIntBig(u16);
table.Q16[ZigzagOffsets[offset]] = value;
}
return table;
},
else => return error.UnknownQuantizationTablePrecision,
}
}
};
const HuffmanCode = struct { length_minus_one: u4, code: u16 };
const HuffmanCodeMap = std.AutoArrayHashMap(HuffmanCode, u8);
const HuffmanTable = struct {
allocator: Allocator,
code_counts: [16]u8,
code_map: HuffmanCodeMap,
table_class: u8,
pub fn read(allocator: Allocator, table_class: u8, reader: ImageReader) !HuffmanTable {
if (table_class & 1 != table_class)
return error.InvalidHuffmanTableClass;
var code_counts: [16]u8 = undefined;
if ((try reader.read(code_counts[0..])) < 16) {
return error.IncompleteHuffmanTable;
}
if (JPEG_DEBUG) std.debug.print(" Code counts: {any}\n", .{code_counts});
var total_huffman_codes: usize = 0;
for (code_counts) |count| total_huffman_codes += count;
var huffman_code_map = HuffmanCodeMap.init(allocator);
errdefer huffman_code_map.deinit();
if (JPEG_VERY_DEBUG) std.debug.print(" Decoded huffman codes map:\n", .{});
var code: u16 = 0;
for (code_counts) |count, i| {
if (JPEG_VERY_DEBUG) {
std.debug.print(" Length {}: ", .{i + 1});
if (count == 0) {
std.debug.print("(none)\n", .{});
} else {
std.debug.print("\n", .{});
}
}
var j: usize = 0;
while (j < count) : (j += 1) {
// Check if we hit all 1s, i.e. 111111 for i == 6, which is an invalid value
if (code == (@intCast(u17, 1) << (@intCast(u5, i) + 1)) - 1) {
return error.InvalidHuffmanTable;
}
const byte = try reader.readByte();
try huffman_code_map.put(.{ .length_minus_one = @intCast(u4, i), .code = code }, byte);
code += 1;
if (JPEG_VERY_DEBUG) std.debug.print(" {b} => 0x{X}\n", .{ code, byte });
}
code <<= 1;
}
return HuffmanTable{
.allocator = allocator,
.code_counts = code_counts,
.code_map = huffman_code_map,
.table_class = table_class,
};
}
pub fn deinit(self: *HuffmanTable) void {
self.code_map.deinit();
}
};
const HuffmanReader = struct {
table: ?*const HuffmanTable = null,
reader: ImageReader,
byte_buffer: u8 = 0,
bits_left: u4 = 0,
last_byte_was_ff: bool = false,
pub fn init(reader: ImageReader) HuffmanReader {
return .{
.reader = reader,
};
}
pub fn setHuffmanTable(self: *HuffmanReader, table: *const HuffmanTable) void {
self.table = table;
}
fn readBit(self: *HuffmanReader) !u1 {
if (self.bits_left == 0) {
self.byte_buffer = try self.reader.readByte();
if (self.byte_buffer == 0 and self.last_byte_was_ff) {
// This was a stuffed byte, read one more.
self.byte_buffer = try self.reader.readByte();
}
self.last_byte_was_ff = self.byte_buffer == 0xFF;
self.bits_left = 8;
}
const bit: u1 = @intCast(u1, self.byte_buffer >> 7);
self.byte_buffer <<= 1;
self.bits_left -= 1;
return bit;
}
pub fn readCode(self: *HuffmanReader) !u8 {
var code: u16 = 0;
var i: u5 = 0;
while (i < 16) : (i += 1) {
code = (code << 1) | (try self.readBit());
if (self.table.?.code_map.get(.{ .length_minus_one = @intCast(u4, i), .code = code })) |value| {
return value;
}
}
return error.NoSuchHuffmanCode;
}
pub fn readLiteralBits(self: *HuffmanReader, bitsNeeded: u8) !u32 {
var bits: u32 = 0;
var i: usize = 0;
while (i < bitsNeeded) : (i += 1) {
bits = (bits << 1) | (try self.readBit());
}
return bits;
}
/// This function implements T.81 section F1.2.1, Huffman encoding of DC coefficients.
pub fn readMagnitudeCoded(self: *HuffmanReader, magnitude: u5) !i32 {
if (magnitude == 0)
return 0;
const bits = try self.readLiteralBits(magnitude);
// The sign of the read bits value.
const bits_sign = (bits >> (magnitude - 1)) & 1;
// The mask for clearing the sign bit.
const bits_mask = (@as(u32, 1) << (magnitude - 1)) - 1;
// The bits without the sign bit.
const unsigned_bits = bits & bits_mask;
// The magnitude base value. This is -2^n+1 when bits_sign == 0, and
// 2^(n-1) when bits_sign == 1.
const base = if (bits_sign == 0)
-(@as(i32, 1) << magnitude) + 1
else
(@as(i32, 1) << (magnitude - 1));
return base + @bitCast(i32, unsigned_bits);
}
};
const Component = struct {
id: u8,
horizontal_sampling_factor: u4,
vertical_sampling_factor: u4,
quantization_table_id: u8,
pub fn read(reader: ImageReader) !Component {
const component_id = try reader.readByte();
const sampling_factors = try reader.readByte();
const quantization_table_id = try reader.readByte();
const horizontal_sampling_factor = @intCast(u4, sampling_factors >> 4);
const vertical_sampling_factor = @intCast(u4, sampling_factors & 0xF);
if (horizontal_sampling_factor < 1 or horizontal_sampling_factor > 4) {
return error.InvalidSamplingFactor;
}
if (vertical_sampling_factor < 1 or vertical_sampling_factor > 4) {
return error.InvalidSamplingFactor;
}
return Component{
.id = component_id,
.horizontal_sampling_factor = horizontal_sampling_factor,
.vertical_sampling_factor = vertical_sampling_factor,
.quantization_table_id = quantization_table_id,
};
}
};
const FrameHeader = struct {
allocator: Allocator,
sample_precision: u8,
row_count: u16,
samples_per_row: u16,
components: []Component,
pub fn read(allocator: Allocator, reader: ImageReader) !FrameHeader {
var segment_size = try reader.readIntBig(u16);
if (JPEG_DEBUG) std.debug.print("StartOfFrame: frame size = 0x{X}\n", .{segment_size});
segment_size -= 2;
const sample_precision = try reader.readByte();
const row_count = try reader.readIntBig(u16);
const samples_per_row = try reader.readIntBig(u16);
const component_count = try reader.readByte();
if (component_count != 1 and component_count != 3) {
return error.InvalidComponentCount;
}
if (JPEG_DEBUG) std.debug.print(" {}x{}, precision={}, {} components\n", .{ samples_per_row, row_count, sample_precision, component_count });
segment_size -= 6;
var components = try allocator.alloc(Component, component_count);
errdefer allocator.free(components);
if (JPEG_VERY_DEBUG) std.debug.print(" Components:\n", .{});
var i: usize = 0;
while (i < component_count) : (i += 1) {
components[i] = try Component.read(reader);
segment_size -= 3;
if (JPEG_VERY_DEBUG) {
std.debug.print(" ID={}, Vfactor={}, Hfactor={} QtableID={}\n", .{
components[i].id, components[i].vertical_sampling_factor, components[i].horizontal_sampling_factor, components[i].quantization_table_id,
});
}
}
std.debug.assert(segment_size == 0);
return FrameHeader{
.allocator = allocator,
.sample_precision = sample_precision,
.row_count = row_count,
.samples_per_row = samples_per_row,
.components = components,
};
}
pub fn deinit(self: *FrameHeader) void {
self.allocator.free(self.components);
}
};
const ScanComponentSpec = struct {
component_selector: u8,
dc_table_selector: u4,
ac_table_selector: u4,
pub fn read(reader: ImageReader) !ScanComponentSpec {
const component_selector = try reader.readByte();
const entropy_coding_selectors = try reader.readByte();
const dc_table_selector = @intCast(u4, entropy_coding_selectors >> 4);
const ac_table_selector = @intCast(u4, entropy_coding_selectors & 0b11);
if (JPEG_VERY_DEBUG) {
std.debug.print(" Component spec: selector={}, DC table ID={}, AC table ID={}\n", .{ component_selector, dc_table_selector, ac_table_selector });
}
return ScanComponentSpec{
.component_selector = component_selector,
.dc_table_selector = dc_table_selector,
.ac_table_selector = ac_table_selector,
};
}
};
const ScanHeader = struct {
components: [4]?ScanComponentSpec,
start_of_spectral_selection: u8,
end_of_spectral_selection: u8,
approximation_high: u4,
approximation_low: u4,
pub fn read(reader: ImageReader) !ScanHeader {
var segment_size = try reader.readIntBig(u16);
if (JPEG_DEBUG) std.debug.print("StartOfScan: segment size = 0x{X}\n", .{segment_size});
segment_size -= 2;
const component_count = try reader.readByte();
if (component_count < 1 or component_count > 4) {
return error.InvalidComponentCount;
}
segment_size -= 1;
var components = [_]?ScanComponentSpec{null} ** 4;
if (JPEG_VERY_DEBUG) std.debug.print(" Components:\n", .{});
var i: usize = 0;
while (i < component_count) : (i += 1) {
components[i] = try ScanComponentSpec.read(reader);
segment_size -= 2;
}
const start_of_spectral_selection = try reader.readByte();
const end_of_spectral_selection = try reader.readByte();
if (start_of_spectral_selection > 63) {
return error.InvalidSpectralSelectionValue;
}
if (end_of_spectral_selection < start_of_spectral_selection or end_of_spectral_selection > 63) {
return error.InvalidSpectralSelectionValue;
}
// If Ss = 0, then Se = 63.
if (start_of_spectral_selection == 0 and end_of_spectral_selection != 63) {
return error.InvalidSpectralSelectionValue;
}
segment_size -= 2;
if (JPEG_VERY_DEBUG) std.debug.print(" Spectral selection: {}-{}\n", .{ start_of_spectral_selection, end_of_spectral_selection });
const approximation_bits = try reader.readByte();
const approximation_high = @intCast(u4, approximation_bits >> 4);
const approximation_low = @intCast(u4, approximation_bits & 0b1111);
segment_size -= 1;
if (JPEG_VERY_DEBUG) std.debug.print(" Approximation bit position: high={} low={}\n", .{ approximation_high, approximation_low });
std.debug.assert(segment_size == 0);
return ScanHeader{
.components = components,
.start_of_spectral_selection = start_of_spectral_selection,
.end_of_spectral_selection = end_of_spectral_selection,
.approximation_high = approximation_high,
.approximation_low = approximation_low,
};
}
};
// See figure A.6 in T.81.
const ZigzagOffsets = blk: {
var offsets: [64]usize = undefined;
offsets[0] = 0;
var current_offset: usize = 0;
var direction: enum { NorthEast, SouthWest } = .NorthEast;
var i: usize = 1;
while (i < 64) : (i += 1) {
switch (direction) {
.NorthEast => {
if (current_offset < 8) {
// Hit top edge
current_offset += 1;
direction = .SouthWest;
} else if (current_offset % 8 == 7) {
// Hit right edge
current_offset += 8;
direction = .SouthWest;
} else {
current_offset -= 7;
}
},
.SouthWest => {
if (current_offset >= 56) {
// Hit bottom edge
current_offset += 1;
direction = .NorthEast;
} else if (current_offset % 8 == 0) {
// Hit left edge
current_offset += 8;
direction = .NorthEast;
} else {
current_offset += 7;
}
},
}
if (current_offset >= 64) {
@compileError(std.fmt.comptimePrint("ZigzagOffsets: Hit offset {} (>= 64) at index {}!\n", .{ current_offset, i }));
}
offsets[i] = current_offset;
}
break :blk offsets;
};
// The precalculated IDCT multipliers. This is possible because the only part of
// the IDCT calculation that changes between runs is the coefficients.
const IDCTMultipliers = blk: {
var multipliers: [8][8][8][8]f32 = undefined;
@setEvalBranchQuota(18086);
var y: usize = 0;
while (y < 8) : (y += 1) {
var x: usize = 0;
while (x < 8) : (x += 1) {
var u: usize = 0;
while (u < 8) : (u += 1) {
var v: usize = 0;
while (v < 8) : (v += 1) {
const C_u: f32 = if (u == 0) 1.0 / @sqrt(2.0) else 1.0;
const C_v: f32 = if (v == 0) 1.0 / @sqrt(2.0) else 1.0;
const x_cosine = @cos(((2 * @intToFloat(f32, x) + 1) * @intToFloat(f32, u) * std.math.pi) / 16.0);
const y_cosine = @cos(((2 * @intToFloat(f32, y) + 1) * @intToFloat(f32, v) * std.math.pi) / 16.0);
const uv_value = C_u * C_v * x_cosine * y_cosine;
multipliers[y][x][u][v] = uv_value;
}
}
}
}
break :blk multipliers;
};
const Scan = struct {
pub fn performScan(frame: *Frame, reader: ImageReader) !void {
const scan_header = try ScanHeader.read(reader);
var prediction_values = [3]i12{ 0, 0, 0 };
var huffman_reader = HuffmanReader.init(reader);
var mcu_id: usize = 0;
while (mcu_id < frame.mcu_storage.len) : (mcu_id += 1) {
try Scan.decodeMCU(frame, scan_header, mcu_id, &huffman_reader, &prediction_values);
}
}
fn decodeMCU(frame: *Frame, scan_header: ScanHeader, mcu_id: usize, reader: *HuffmanReader, prediction_values: *[3]i12) !void {
for (scan_header.components) |maybe_component, component_id| {
_ = component_id;
if (maybe_component == null)
break;
try Scan.decodeMCUComponent(frame, maybe_component.?, mcu_id, reader, prediction_values);
}
}
fn decodeMCUComponent(frame: *Frame, component: ScanComponentSpec, mcu_id: usize, reader: *HuffmanReader, prediction_values: *[3]i12) !void {
// The encoder might reorder components or omit one if it decides that the
// file size can be reduced that way. Therefore we need to select the correct
// destination for this component.
const component_destination = blk: {
for (frame.frame_header.components) |frame_component, i| {
if (frame_component.id == component.component_selector) {
break :blk i;
}
}
return error.UnknownComponentInScan;
};
const mcu = &frame.mcu_storage[mcu_id][component_destination];
// Decode the DC coefficient
if (frame.dc_huffman_tables[component.dc_table_selector] == null)
return error.NonexistentDCHuffmanTableReferenced;
reader.setHuffmanTable(&frame.dc_huffman_tables[component.dc_table_selector].?);
const dc_coefficient = try Scan.decodeDCCoefficient(reader, &prediction_values[component_destination]);
mcu[0] = dc_coefficient;
// Decode the AC coefficients
if (frame.ac_huffman_tables[component.ac_table_selector] == null)
return error.NonexistentACHuffmanTableReferenced;
reader.setHuffmanTable(&frame.ac_huffman_tables[component.ac_table_selector].?);
try Scan.decodeACCoefficients(reader, mcu);
}
fn decodeDCCoefficient(reader: *HuffmanReader, prediction: *i12) !i12 {
const maybe_magnitude = try reader.readCode();
if (maybe_magnitude > 11) return error.InvalidDCMagnitude;
const magnitude = @intCast(u4, maybe_magnitude);
const diff = @intCast(i12, try reader.readMagnitudeCoded(magnitude));
const dc_coefficient = diff + prediction.*;
prediction.* = dc_coefficient;
return dc_coefficient;
}
fn decodeACCoefficients(reader: *HuffmanReader, mcu: *Frame.MCU) !void {
var ac: usize = 1;
var did_see_eob = false;
while (ac < 64) : (ac += 1) {
if (did_see_eob) {
mcu[ZigzagOffsets[ac]] = 0;
continue;
}
const zero_run_length_and_magnitude = try reader.readCode();
// 00 == EOB
if (zero_run_length_and_magnitude == 0x00) {
did_see_eob = true;
mcu[ZigzagOffsets[ac]] = 0;
continue;
}
const zero_run_length = zero_run_length_and_magnitude >> 4;
const maybe_magnitude = zero_run_length_and_magnitude & 0xF;
if (maybe_magnitude > 10) return error.InvalidACMagnitude;
const magnitude = @intCast(u4, maybe_magnitude);
const ac_coefficient = @intCast(i11, try reader.readMagnitudeCoded(magnitude));
var i: usize = 0;
while (i < zero_run_length) : (i += 1) {
mcu[ZigzagOffsets[ac]] = 0;
ac += 1;
}
mcu[ZigzagOffsets[ac]] = ac_coefficient;
}
}
};
const Frame = struct {
allocator: Allocator,
frame_header: FrameHeader,
quantization_tables: *[4]?QuantizationTable,
dc_huffman_tables: [2]?HuffmanTable,
ac_huffman_tables: [2]?HuffmanTable,
mcu_storage: [][MAX_COMPONENTS]MCU,
const MCU = [64]i32;
const MAX_COMPONENTS = 3;
pub fn read(allocator: Allocator, quantization_tables: *[4]?QuantizationTable, reader: ImageReader, seek_stream: ImageSeekStream) !Frame {
var frame_header = try FrameHeader.read(allocator, reader);
const mcu_count = Frame.calculateMCUCountInFrame(&frame_header);
const mcu_storage = try allocator.alloc([MAX_COMPONENTS]MCU, mcu_count);
var self = Frame{
.allocator = allocator,
.frame_header = frame_header,
.quantization_tables = quantization_tables,
.dc_huffman_tables = [_]?HuffmanTable{null} ** 2,
.ac_huffman_tables = [_]?HuffmanTable{null} ** 2,
.mcu_storage = mcu_storage,
};
errdefer self.deinit();
var marker = try reader.readIntBig(u16);
while (marker != @enumToInt(Markers.StartOfScan)) : (marker = try reader.readIntBig(u16)) {
if (JPEG_DEBUG) std.debug.print("Frame: Parsing marker value: 0x{X}\n", .{marker});
switch (@intToEnum(Markers, marker)) {
.DefineHuffmanTables => {
try self.parseDefineHuffmanTables(reader);
},
else => {
return error.UnknownMarkerInFrame;
},
}
}
while (marker == @enumToInt(Markers.StartOfScan)) : (marker = try reader.readIntBig(u16)) {
try self.parseScan(reader);
}
// Undo the last marker read
try seek_stream.seekBy(-2);
// Dequantize
try self.dequantize();
return self;
}
pub fn deinit(self: *Frame) void {
for (self.dc_huffman_tables) |*maybe_huffman_table| {
if (maybe_huffman_table.*) |*huffman_table| {
huffman_table.deinit();
}
}
for (self.ac_huffman_tables) |*maybe_huffman_table| {
if (maybe_huffman_table.*) |*huffman_table| {
huffman_table.deinit();
}
}
self.frame_header.deinit();
self.allocator.free(self.mcu_storage);
}
fn parseDefineHuffmanTables(self: *Frame, reader: ImageReader) !void {
var segment_size = try reader.readIntBig(u16);
if (JPEG_DEBUG) std.debug.print("DefineHuffmanTables: segment size = 0x{X}\n", .{segment_size});
segment_size -= 2;
while (segment_size > 0) {
const class_and_destination = try reader.readByte();
const table_class = class_and_destination >> 4;
const table_destination = class_and_destination & 0b1;
const huffman_table = try HuffmanTable.read(self.allocator, table_class, reader);
if (table_class == 0) {
if (self.dc_huffman_tables[table_destination]) |*old_huffman_table| {
old_huffman_table.deinit();
}
self.dc_huffman_tables[table_destination] = huffman_table;
} else {
if (self.ac_huffman_tables[table_destination]) |*old_huffman_table| {
old_huffman_table.deinit();
}
self.ac_huffman_tables[table_destination] = huffman_table;
}
if (JPEG_DEBUG) std.debug.print(" Table with class {} installed at {}\n", .{ table_class, table_destination });
// Class+Destination + code counts + code table
segment_size -= 1 + 16 + @intCast(u16, huffman_table.code_map.count());
}
}
fn calculateMCUCountInFrame(frame_header: *FrameHeader) usize {
// FIXME: This is very naive and probably only works for Baseline DCT.
const sample_count = @as(usize, frame_header.row_count) * @as(usize, frame_header.samples_per_row);
return (sample_count / 64) + (if (sample_count % 64 != 0) @as(u1, 1) else @as(u1, 0));
}
fn parseScan(self: *Frame, reader: ImageReader) !void {
try Scan.performScan(self, reader);
}
fn dequantize(self: *Frame) !void {
var mcu_id: usize = 0;
while (mcu_id < self.mcu_storage.len) : (mcu_id += 1) {
for (self.frame_header.components) |component, component_id| {
const mcu = &self.mcu_storage[mcu_id][component_id];
if (self.quantization_tables[component.quantization_table_id]) |quantization_table| {
var sample_id: usize = 0;
while (sample_id < 64) : (sample_id += 1) {
mcu[sample_id] = mcu[sample_id] * quantization_table.Q8[sample_id];
}
} else return error.UnknownQuantizationTableReferenced;
}
}
}
pub fn renderToPixels(self: *Frame, pixels: *color.ColorStorage) !void {
switch (self.frame_header.components.len) {
1 => try self.renderToPixelsGrayscale(pixels.Grayscale8),
3 => try self.renderToPixelsRgb(pixels.Rgb24),
else => unreachable,
}
}
fn renderToPixelsGrayscale(self: *Frame, pixels: []color.Grayscale8) !void {
_ = self;
_ = pixels;
return error.NotImplemented;
}
fn renderToPixelsRgb(self: *Frame, pixels: []color.Rgb24) !void {
var width = self.frame_header.samples_per_row;
var mcu_id: usize = 0;
while (mcu_id < self.mcu_storage.len) : (mcu_id += 1) {
const mcus_per_row = width / 8;
// The 8x8 block offsets, from left and top.
const block_x = (mcu_id % mcus_per_row);
const block_y = (mcu_id / mcus_per_row);
const mcu_Y = &self.mcu_storage[mcu_id][0];
const mcu_Cb = &self.mcu_storage[mcu_id][1];
const mcu_Cr = &self.mcu_storage[mcu_id][2];
var y: u4 = 0;
while (y < 8) : (y += 1) {
var x: u4 = 0;
while (x < 8) : (x += 1) {
const reconstructed_Y = idct(mcu_Y, @intCast(u3, x), @intCast(u3, y), mcu_id, 0);
const reconstructed_Cb = idct(mcu_Cb, @intCast(u3, x), @intCast(u3, y), mcu_id, 1);
const reconstructed_Cr = idct(mcu_Cr, @intCast(u3, x), @intCast(u3, y), mcu_id, 2);
const Y = @intToFloat(f32, reconstructed_Y);
const Cb = @intToFloat(f32, reconstructed_Cb);
const Cr = @intToFloat(f32, reconstructed_Cr);
const Co_red = 0.299;
const Co_green = 0.587;
const Co_blue = 0.114;
const R = Cr * (2 - 2 * Co_red) + Y;
const B = Cb * (2 - 2 * Co_blue) + Y;
const G = (Y - Co_blue * B - Co_red * R) / Co_green;
pixels[(((block_y * 8) + y) * width) + (block_x * 8) + x] = .{
.R = @floatToInt(u8, std.math.clamp(R + 128.0, 0.0, 255.0)),
.G = @floatToInt(u8, std.math.clamp(G + 128.0, 0.0, 255.0)),
.B = @floatToInt(u8, std.math.clamp(B + 128.0, 0.0, 255.0)),
};
}
}
}
}
fn idct(mcu: *const MCU, x: u3, y: u3, mcu_id: usize, component_id: usize) i8 {
var reconstructed_pixel: f32 = 0.0;
var u: usize = 0;
while (u < 8) : (u += 1) {
var v: usize = 0;
while (v < 8) : (v += 1) {
const mcu_value = mcu[v * 8 + u];
reconstructed_pixel += IDCTMultipliers[y][x][u][v] * @intToFloat(f32, mcu_value);
}
}
const scaled_pixel = @round(reconstructed_pixel / 4.0);
if (JPEG_DEBUG) {
if (scaled_pixel < -128.0 or scaled_pixel > 127.0) {
std.debug.print("Pixel at mcu={} x={} y={} component_id={} is out of bounds with DCT: {d}!\n", .{ mcu_id, x, y, component_id, scaled_pixel });
}
}
return @floatToInt(i8, std.math.clamp(scaled_pixel, -128.0, 127.0));
}
};
pub const JPEG = struct {
frame: ?Frame = null,
allocator: Allocator,
quantization_tables: [4]?QuantizationTable,
pub fn init(allocator: Allocator) JPEG {
return .{
.allocator = allocator,
.quantization_tables = [_]?QuantizationTable{null} ** 4,
};
}
pub fn deinit(self: *JPEG) void {
if (self.frame) |*frame| {
frame.deinit();
}
}
fn parseDefineQuantizationTables(self: *JPEG, reader: ImageReader) !void {
var segment_size = try reader.readIntBig(u16);
if (JPEG_DEBUG) std.debug.print("DefineQuantizationTables: segment size = 0x{X}\n", .{segment_size});
segment_size -= 2;
while (segment_size > 0) {
const precision_and_destination = try reader.readByte();
const table_precision = precision_and_destination >> 4;
const table_destination = precision_and_destination & 0b11;
const quantization_table = try QuantizationTable.read(table_precision, reader);
switch (quantization_table) {
.Q8 => segment_size -= 64 + 1,
.Q16 => segment_size -= 128 + 1,
}
self.quantization_tables[table_destination] = quantization_table;
if (JPEG_DEBUG) std.debug.print(" Table with precision {} installed at {}\n", .{ table_precision, table_destination });
}
}
fn initializePixels(self: *JPEG, pixels_opt: *?color.ColorStorage) !void {
if (self.frame) |frame| {
var pixel_format: PixelFormat = undefined;
switch (frame.frame_header.components.len) {
1 => pixel_format = .Grayscale8,
3 => pixel_format = .Rgb24,
else => unreachable,
}
const pixel_count = @intCast(usize, frame.frame_header.samples_per_row) * @intCast(usize, frame.frame_header.row_count);
pixels_opt.* = try color.ColorStorage.init(self.allocator, pixel_format, pixel_count);
} else return error.FrameDoesNotExist;
}
pub fn read(self: *JPEG, reader: ImageReader, seek_stream: ImageSeekStream, pixels_opt: *?color.ColorStorage) !Frame {
_ = pixels_opt;
const jfif_header = JFIFHeader.read(reader, seek_stream) catch |err| switch (err) {
error.App0MarkerDoesNotExist, error.JfifIdentifierNotSet, error.ThumbnailImagesUnsupported, error.ExtraneousApplicationMarker => return errors.ImageError.InvalidMagicHeader,
else => |e| return e,
};
_ = jfif_header;
errdefer {
if (pixels_opt.*) |pixels| {
pixels.deinit(self.allocator);
pixels_opt.* = null;
}
}
var marker = try reader.readIntBig(u16);
while (marker != @enumToInt(Markers.EndOfImage)) : (marker = try reader.readIntBig(u16)) {
if (JPEG_DEBUG) std.debug.print("Parsing marker value: 0x{X}\n", .{marker});
if (marker >= @enumToInt(Markers.Application0) and marker < @enumToInt(Markers.Application0) + 16) {
if (JPEG_DEBUG) std.debug.print("Skipping application data segment\n", .{});
const application_data_length = try reader.readIntBig(u16);
try seek_stream.seekBy(application_data_length - 2);
continue;
}
switch (@intToEnum(Markers, marker)) {
.SOF0 => {
if (self.frame != null) {
return error.UnsupportedMultiframe;
}
self.frame = try Frame.read(self.allocator, &self.quantization_tables, reader, seek_stream);
try self.initializePixels(pixels_opt);
try self.frame.?.renderToPixels(&pixels_opt.*.?);
},
.SOF1 => return error.UnsupportedFrameFormat,
.SOF2 => return error.UnsupportedFrameFormat,
.SOF3 => return error.UnsupportedFrameFormat,
.SOF5 => return error.UnsupportedFrameFormat,
.SOF6 => return error.UnsupportedFrameFormat,
.SOF7 => return error.UnsupportedFrameFormat,
.SOF9 => return error.UnsupportedFrameFormat,
.SOF10 => return error.UnsupportedFrameFormat,
.SOF11 => return error.UnsupportedFrameFormat,
.SOF13 => return error.UnsupportedFrameFormat,
.SOF14 => return error.UnsupportedFrameFormat,
.SOF15 => return error.UnsupportedFrameFormat,
.DefineQuantizationTables => {
try self.parseDefineQuantizationTables(reader);
},
.Comment => {
if (JPEG_DEBUG) std.debug.print("Skipping comment segment\n", .{});
const comment_length = try reader.readIntBig(u16);
try seek_stream.seekBy(comment_length - 2);
},
else => {
return error.UnknownMarker;
},
}
}
return if (self.frame) |frame| frame else error.FrameHeaderDoesNotExist;
}
// Format interface
pub fn formatInterface() FormatInterface {
return FormatInterface{
.format = @ptrCast(FormatInterface.FormatFn, format),
.formatDetect = @ptrCast(FormatInterface.FormatDetectFn, formatDetect),
.readForImage = @ptrCast(FormatInterface.ReadForImageFn, readForImage),
.writeForImage = @ptrCast(FormatInterface.WriteForImageFn, writeForImage),
};
}
fn format() ImageFormat {
return ImageFormat.Jpeg;
}
fn formatDetect(reader: ImageReader, seek_stream: ImageSeekStream) !bool {
const maybe_start_of_image = try reader.readIntBig(u16);
if (maybe_start_of_image != @enumToInt(Markers.StartOfImage)) {
return false;
}
try seek_stream.seekTo(6);
var identifier_buffer: [4]u8 = undefined;
_ = try reader.read(identifier_buffer[0..]);
return std.mem.eql(u8, identifier_buffer[0..], "JFIF");
}
fn readForImage(allocator: Allocator, reader: ImageReader, seek_stream: ImageSeekStream, pixels_opt: *?color.ColorStorage) !ImageInfo {
var jpeg = JPEG.init(allocator);
defer jpeg.deinit();
const frame = try jpeg.read(reader, seek_stream, pixels_opt);
return ImageInfo{
.width = frame.frame_header.samples_per_row,
.height = frame.frame_header.row_count,
};
}
fn writeForImage(allocator: Allocator, write_stream: image.ImageWriterStream, seek_stream: ImageSeekStream, pixels: color.ColorStorage, save_info: image.ImageSaveInfo) !void {
_ = allocator;
_ = write_stream;
_ = seek_stream;
_ = pixels;
_ = save_info;
@panic("TODO: Implement JPEG writing! (maybe not...)");
}
};
|
src/formats/jpeg.zig
|
const io = @import("std").io;
/// Receiver Holding Register (R)
const register_rhr = 0;
/// Transmitter Holding Register (W)
const register_thr = 0;
/// Interrupt Enable Register (R/W)
const register_ier = 1;
/// Interrupt Status Register (R)
const register_isr = 2;
/// FIFO Control Register (W)
const register_fcr = 2;
/// Line Control Register (R/W)
const register_lcr = 3;
/// Modem Control Register (R/W)
const register_mcr = 4;
/// Line Status Register (R)
const register_lsr = 5;
/// Modem Status Register (R)
const register_msr = 6;
/// Scratch Pad Register (R/W)
const register_spr = 7;
/// Divisor Latch, LSB (R/W)
const register_dll = 0;
/// Divisor Latch, MSB (R/W)
const register_dlm = 1;
/// Prescaler Division (W)
const register_psd = 5;
const fcr_fifo_enable = 0x01;
const fcr_rx_fifo_reset = 0x02;
const fcr_tx_fifo_reset = 0x04;
const fcr_dma_mode = 0x08;
const fcr_enable_dma_end = 0x10;
const lcr_word_size_5bits = 0x00;
const lcr_word_size_6bits = 0x01;
const lcr_word_size_7bits = 0x02;
const lcr_word_size_8bits = 0x03;
const lsr_data_ready = 0x01;
const lsr_overrun_error = 0x02;
const lsr_parity_error = 0x04;
const lsr_framing_error = 0x08;
const lsr_break_interrupt = 0x10;
const lsr_thr_empty = 0x20;
const lsr_transmitter_empty = 0x40;
const lsr_fifo_data_error = 0x80;
const base = 0x10000000;
const ptr = @intToPtr([*]volatile u8, base);
fn set(register: u8, mask: u8) void {
ptr[register] |= mask;
}
fn isSet(register: u8, mask: u8) bool {
return ptr[register] & mask == mask;
}
// Singleton struct to make `std.io.Writer` happy
const Uart = struct {
const Writer = io.Writer(Uart, error{}, write);
pub fn init(self: Uart) void {
// Enable FIFO
set(register_fcr, fcr_fifo_enable);
// Set the word length to 8 bits
set(register_lcr, lcr_word_size_8bits);
// TODO: set the baud rate, and check if other options need to be set
}
fn writeChar(self: Uart, char: u8) void {
while (!isSet(register_lsr, lsr_thr_empty)) {}
set(register_thr, char);
}
pub fn write(self: Uart, string: []const u8) !usize {
for (string) |char| {
self.writeChar(char);
}
return string.len;
}
pub fn writer(self: Uart) Writer {
return .{ .context = self };
}
};
pub const uart = Uart{};
|
src/uart.zig
|
// SPDX-License-Identifier: MIT
// This file is part of the `termcon` project under the MIT license.
const root = @import("../windows.zig");
const std = @import("std");
const windows = std.os.windows;
pub const CONSOLE_TEXTMODE_BUFFER: windows.DWORD = 1;
// when hConsoleHandle param is an input handle:
const ENABLE_ECHO_INPUT: windows.DWORD = 0x0004;
const ENABLE_EXTENDED_FLAGS: windows.DWORD = 0x0080;
const ENABLE_INSERT_MODE: windows.DWORD = 0x0020;
const ENABLE_LINE_MODE: windows.DWORD = 0x0002;
const ENABLE_MOUSE_INPUT: windows.DWORD = 0x0010;
const ENABLE_PROCESSED_INPUT: windows.DWORD = 0x0001;
const ENABLE_QUICK_EDIT_MODE: windows.DWORD = 0x0040;
const ENABLE_WINDOW_INPUT: windows.DWORD = 0x0008;
const ENABLE_VIRTUAL_TERMINAL_INPUT: windows.DWORD = 0x0200;
// when hConsoleHandle param is a screen buffer handle:
const ENABLE_PROCESSED_OUTPUT: windows.DWORD = 0x0001;
const ENABLE_WRAP_AT_EOL_OUTPUT: windows.DWORD = 0x0002;
const ENABLE_VIRTUAL_TERMINAL_PROCESSING: windows.DWORD = 0x0004;
const DISABLE_NEWLINE_AUTO_RETURN: windows.DWORD = 0x0008;
const ENABLE_LVB_GRID_WORLDWIDE: windows.DWORD = 0x0010;
var in_raw_mode = false;
pub fn getRawMode() bool {
return in_raw_mode;
}
pub fn setRawMode(enabled: bool) !void {
std.debug.assert(root.hConsoleOutCurrent != null);
in_raw_mode = enabled;
if (enabled) {
if (root.SetConsoleMode(root.hConsoleIn orelse return error.Handle, ENABLE_EXTENDED_FLAGS | ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT | ENABLE_VIRTUAL_TERMINAL_INPUT) == 0) return error.Failed;
if (root.SetConsoleMode(root.hConsoleOutCurrent orelse return error.Handle, ENABLE_VIRTUAL_TERMINAL_PROCESSING | DISABLE_NEWLINE_AUTO_RETURN) == 0) return error.Failed;
} else {
if (root.SetConsoleMode(root.hConsoleIn orelse return error.Handle, ENABLE_ECHO_INPUT | ENABLE_EXTENDED_FLAGS | ENABLE_INSERT_MODE | ENABLE_LINE_MODE | ENABLE_MOUSE_INPUT |
ENABLE_PROCESSED_INPUT | ENABLE_QUICK_EDIT_MODE | ENABLE_WINDOW_INPUT | ENABLE_VIRTUAL_TERMINAL_INPUT) == 0) return error.Failed;
if (root.SetConsoleMode(root.hConsoleOutCurrent orelse return error.Handle, ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING) == 0) return error.Failed;
}
}
pub fn getAlternateScreen() bool {
if (root.hConsoleOutAlt == null) return false;
return root.hConsoleOutAlt == root.hConsoleOutCurrent;
}
pub fn setAlternateScreen(enabled: bool) !void {
if (enabled) {
if (root.hConsoleOutAlt == null) { // The alternate screen has not yet been created...
root.hConsoleOutAlt = root.CreateConsoleScreenBuffer(windows.GENERIC_READ | windows.GENERIC_WRITE,
windows.FILE_SHARE_READ | windows.FILE_SHARE_WRITE, null, CONSOLE_TEXTMODE_BUFFER, null);
if (root.hConsoleOutAlt == windows.INVALID_HANDLE_VALUE) return error.SetScreenFailed;
}
if (root.SetConsoleActiveScreenBuffer(root.hConsoleOutAlt orelse return error.Handle) == 0) return error.SetScreenFailed;
root.hConsoleOutCurrent = root.hConsoleOutAlt;
} else {
if (root.SetConsoleActiveScreenBuffer(root.hConsoleOutMain orelse return error.Handle) == 0) return error.SetScreenFailed;
root.hConsoleOutCurrent = root.hConsoleOutMain;
}
}
|
src/backend/windows/config.zig
|
pub const names = @import("xkbcommon_names.zig");
pub const Keycode = u32;
pub const Keysym = @import("xkbcommon_keysyms.zig").Keysym;
pub const KeyDirection = extern enum {
up,
down,
};
pub const LayoutIndex = u32;
pub const LayoutMask = u32;
pub const LevelIndex = u32;
pub const ModIndex = u32;
pub const ModMask = u32;
pub const LED_Index = u32;
pub const LED_Mask = u32;
pub const keycode_invalid = 0xffff_ffff;
pub const layout_invalid = 0xffff_ffff;
pub const level_invalid = 0xffff_ffff;
pub const mod_invalid = 0xffff_ffff;
pub const led_invalid = 0xffff_ffff;
pub const keycode_max = 0xffff_ffff - 1;
pub const RuleNames = extern struct {
rules: ?[*:0]const u8,
model: ?[*:0]const u8,
layout: ?[*:0]const u8,
variant: ?[*:0]const u8,
options: ?[*:0]const u8,
};
pub const LogLevel = extern enum {
crit = 10,
err = 20,
warn = 30,
info = 40,
debug = 50,
};
pub const Context = opaque {
pub const Flags = extern enum {
no_flags = 0,
no_default_includes = 1 << 0,
no_environment_names = 1 << 1,
};
extern fn xkb_context_new(flags: Flags) ?*Context;
pub const new = xkb_context_new;
extern fn xkb_context_ref(context: *Context) *Context;
pub const ref = xkb_context_ref;
extern fn xkb_context_unref(context: *Context) void;
pub const unref = xkb_context_unref;
extern fn xkb_context_set_user_data(context: *Context, user_data: ?*c_void) void;
pub const setUserData = xkb_context_set_user_data;
extern fn xkb_context_get_user_data(context: *Context) ?*c_void;
pub const getUserData = xkb_context_get_user_data;
extern fn xkb_context_include_path_append(context: *Context, path: [*:0]const u8) c_int;
pub const includePathAppend = xkb_context_include_path_append;
extern fn xkb_context_include_path_append_default(context: *Context) c_int;
pub const includePathAppendDefault = xkb_context_include_path_append_default;
extern fn xkb_context_include_path_reset_defaults(context: *Context) c_int;
pub const includePathResetDefaults = xkb_context_include_path_reset_defaults;
extern fn xkb_context_include_path_clear(context: *Context) void;
pub const includePathClear = xkb_context_include_path_clear;
extern fn xkb_context_num_include_paths(context: *Context) c_uint;
pub const numIncludePaths = xkb_context_num_include_paths;
extern fn xkb_context_include_path_get(context: *Context, index: c_uint) ?[*:0]const u8;
pub const includePathGet = xkb_context_include_path_get;
extern fn xkb_context_set_log_level(context: *Context, level: LogLevel) void;
pub const setLogLevel = xkb_context_set_log_level;
extern fn xkb_context_get_log_level(context: *Context) LogLevel;
pub const getLogLevel = xkb_context_get_log_level;
extern fn xkb_context_set_log_verbosity(context: *Context, verbosity: c_int) void;
pub const setLogVerbosity = xkb_context_set_log_verbosity;
extern fn xkb_context_get_log_verbosity(context: *Context) c_int;
pub const getLogVerbosity = xkb_context_get_log_verbosity;
// TODO
//extern fn xkb_context_set_log_fn(context: *Context, log_fn: ?fn (?*Context, enum_xkb_log_level, [*c]const u8, [*c]struct___va_list_tag) callconv(.C) void) void;
};
pub const Keymap = opaque {
pub const CompileFlags = extern enum {
no_flags = 0,
};
pub const Format = extern enum {
text_v1 = 1,
};
extern fn xkb_keymap_new_from_names(context: *Context, names: ?*const RuleNames, flags: CompileFlags) ?*Keymap;
pub const newFromNames = xkb_keymap_new_from_names;
// TODO
//extern fn xkb_keymap_new_from_file(context: *Context, file: *FILE, format: Format, flags: CompileFlags) ?*Keymap;
//pub const newFromFile = xkb_keymap_new_from_file;
extern fn xkb_keymap_new_from_string(context: *Context, string: [*:0]const u8, format: Format, flags: CompileFlags) ?*Keymap;
pub const newFromString = xkb_keymap_new_from_string;
extern fn xkb_keymap_new_from_buffer(context: *Context, buffer: [*]const u8, length: usize, format: Format, flags: CompileFlags) ?*Keymap;
pub const newFromBuffer = xkb_keymap_new_from_buffer;
extern fn xkb_keymap_ref(keymap: *Keymap) *Keymap;
pub const ref = xkb_keymap_ref;
extern fn xkb_keymap_unref(keymap: *Keymap) void;
pub const unref = xkb_keymap_unref;
extern fn xkb_keymap_get_as_string(keymap: *Keymap, format: Format) [*c]u8;
pub const getAsString = xkb_keymap_get_as_string;
extern fn xkb_keymap_min_keycode(keymap: *Keymap) Keycode;
pub const minKeycode = xkb_keymap_min_keycode;
extern fn xkb_keymap_max_keycode(keymap: *Keymap) Keycode;
pub const maxKeycode = xkb_keymap_max_keycode;
extern fn xkb_keymap_key_for_each(
keymap: *Keymap,
iter: fn (keymap: *Keymap, key: Keycode, data: ?*c_void) callconv(.C) void,
data: ?*c_void,
) void;
pub inline fn keyForEach(
keymap: *Keymap,
comptime T: type,
iter: fn (keymap: *Keymap, key: Keycode, data: T) callconv(.C) void,
data: T,
) void {
xkb_keymap_key_for_each(keymap, iter, data);
}
extern fn xkb_keymap_key_get_name(keymap: *Keymap, key: Keycode) ?[*:0]const u8;
pub const keyGetName = xkb_keymap_key_get_name;
extern fn xkb_keymap_key_by_name(keymap: *Keymap, name: [*:0]const u8) Keycode;
pub const keyByName = xkb_keymap_key_by_name;
extern fn xkb_keymap_num_mods(keymap: *Keymap) ModIndex;
pub const numMods = xkb_keymap_num_mods;
extern fn xkb_keymap_mod_get_name(keymap: *Keymap, idx: ModIndex) ?[*:0]const u8;
pub const modGetName = xkb_keymap_mod_get_name;
extern fn xkb_keymap_mod_get_index(keymap: *Keymap, name: [*:0]const u8) ModIndex;
pub const modGetIndex = xkb_keymap_mod_get_index;
extern fn xkb_keymap_num_layouts(keymap: *Keymap) LayoutIndex;
pub const numLayouts = xkb_keymap_num_layouts;
extern fn xkb_keymap_layout_get_name(keymap: *Keymap, idx: LayoutIndex) ?[*:0]const u8;
pub const layoutGetName = xkb_keymap_layout_get_name;
extern fn xkb_keymap_layout_get_index(keymap: *Keymap, name: [*:0]const u8) LayoutIndex;
pub const layoutGetIndex = xkb_keymap_layout_get_index;
extern fn xkb_keymap_num_leds(keymap: *Keymap) LED_Index;
pub const numLeds = xkb_keymap_num_leds;
extern fn xkb_keymap_led_get_name(keymap: *Keymap, idx: LED_Index) ?[*:0]const u8;
pub const ledGetName = xkb_keymap_led_get_name;
extern fn xkb_keymap_led_get_index(keymap: *Keymap, name: [*:0]const u8) LED_Index;
pub const ledGetIndex = xkb_keymap_led_get_index;
extern fn xkb_keymap_num_layouts_for_key(keymap: *Keymap, key: Keycode) LayoutIndex;
pub const numLayoutsForKey = xkb_keymap_num_layouts_for_key;
extern fn xkb_keymap_num_levels_for_key(keymap: *Keymap, key: Keycode, layout: LayoutIndex) LevelIndex;
pub const numLevelsForKey = xkb_keymap_num_levels_for_key;
extern fn xkb_keymap_key_get_mods_for_level(keymap: *Keymap, key: Keycode, layout: LayoutIndex, level: LevelIndex, masks_out: [*]ModMask, masks_size: usize) usize;
pub const keyGetModsForLevel = xkb_keymap_key_get_mods_for_level;
extern fn xkb_keymap_key_get_syms_by_level(keymap: *Keymap, key: Keycode, layout: LayoutIndex, level: LevelIndex, syms_out: *?[*]const Keysym) c_int;
pub fn keyGetSymsByLevel(keymap: *Keymap, key: Keycode, layout: LayoutIndex, level: LevelIndex) []const Keysym {
var ptr: ?[*]const Keysym = undefined;
const len = xkb_keymap_key_get_syms_by_level(keymap, key, layout, level, &ptr);
return if (len == 0) &[0]Keysym{} else ptr.?[0..@intCast(usize, len)];
}
extern fn xkb_keymap_key_repeats(keymap: *Keymap, key: Keycode) c_int;
pub const keyRepeats = xkb_keymap_key_repeats;
};
pub const ConsumedMode = extern enum {
xkb,
gtk,
};
pub const State = opaque {
pub const Component = extern enum(c_int) {
_,
pub const mods_depressed = 1 << 0;
pub const mods_latched = 1 << 1;
pub const mods_locked = 1 << 2;
pub const mods_effective = 1 << 3;
pub const layout_depressed = 1 << 4;
pub const layout_latched = 1 << 5;
pub const layout_locked = 1 << 6;
pub const layout_effective = 1 << 7;
pub const leds = 1 << 8;
};
pub const Match = extern enum(c_int) {
_,
pub const any = 1 << 0;
pub const all = 1 << 1;
pub const non_exclusive = 1 << 16;
};
extern fn xkb_state_new(keymap: *Keymap) ?*State;
pub const new = xkb_state_new;
extern fn xkb_state_ref(state: *State) *State;
pub const ref = xkb_state_ref;
extern fn xkb_state_unref(state: *State) void;
pub const unref = xkb_state_unref;
extern fn xkb_state_get_keymap(state: *State) *Keymap;
pub const getKeymap = xkb_state_get_keymap;
extern fn xkb_state_update_key(state: *State, key: Keycode, direction: KeyDirection) Component;
pub const updateKey = xkb_state_update_key;
extern fn xkb_state_update_mask(
state: *State,
depressed_mods: ModMask,
latched_mods: ModMask,
locked_mods: ModMask,
depressed_layout: LayoutIndex,
latched_layout: LayoutIndex,
locked_layout: LayoutIndex,
) Component;
pub const updateMask = xkb_state_update_mask;
extern fn xkb_state_key_get_syms(state: *State, key: Keycode, syms_out: *?[*]const Keysym) c_int;
pub fn keyGetSyms(state: *State, key: Keycode) []const Keysym {
var ptr: ?[*]const Keysym = undefined;
const len = xkb_state_key_get_syms(state, key, &ptr);
return if (len == 0) &[0]Keysym{} else ptr.?[0..@intCast(usize, len)];
}
extern fn xkb_state_key_get_utf8(state: *State, key: Keycode, buffer: [*]u8, size: usize) c_int;
pub const keyGetUtf8 = xkb_state_key_get_utf8;
extern fn xkb_state_key_get_utf32(state: *State, key: Keycode) u32;
pub const keyGetUtf32 = xkb_state_key_get_utf32;
extern fn xkb_state_key_get_one_sym(state: *State, key: Keycode) Keysym;
pub const keyGetOneSym = xkb_state_key_get_one_sym;
extern fn xkb_state_key_get_layout(state: *State, key: Keycode) LayoutIndex;
pub const keyGetLayout = xkb_state_key_get_layout;
extern fn xkb_state_key_get_level(state: *State, key: Keycode, layout: LayoutIndex) LevelIndex;
pub const keyGetLevel = xkb_state_key_get_level;
extern fn xkb_state_serialize_mods(state: *State, components: Component) ModMask;
pub const serializeMods = xkb_state_serialize_mods;
extern fn xkb_state_serialize_layout(state: *State, components: Component) LayoutIndex;
pub const serializeLayout = xkb_state_serialize_layout;
extern fn xkb_state_mod_name_is_active(state: *State, name: [*:0]const u8, kind: Component) c_int;
pub const modNameIsActive = xkb_state_mod_name_is_active;
extern fn xkb_state_mod_names_are_active(state: *State, kind: Component, match: Match, ...) c_int;
pub const modNamesAreActive = xkb_state_mod_names_are_active;
extern fn xkb_state_mod_index_is_active(state: *State, idx: ModIndex, kind: Component) c_int;
pub const modIndexIsActive = xkb_state_mod_index_is_active;
extern fn xkb_state_mod_indices_are_active(state: *State, kind: Component, match: Match, ...) c_int;
pub const modIndicesAreActive = xkb_state_mod_indices_are_active;
extern fn xkb_state_key_get_consumed_mods2(state: *State, key: Keycode, mode: ConsumedMode) ModMask;
pub const keyGetConsumedMods2 = xkb_state_key_get_consumed_mods2;
extern fn xkb_state_key_get_consumed_mods(state: *State, key: Keycode) ModMask;
pub const keyGetConsumedMods = xkb_state_key_get_consumed_mods;
extern fn xkb_state_mod_index_is_consumed2(state: *State, key: Keycode, idx: ModIndex, mode: ConsumedMode) c_int;
pub const modIndexIsConsumed2 = xkb_state_mod_index_is_consumed2;
extern fn xkb_state_mod_index_is_consumed(state: *State, key: Keycode, idx: ModIndex) c_int;
pub const modIndexIsConsumed = xkb_state_mod_index_is_consumed;
extern fn xkb_state_mod_mask_remove_consumed(state: *State, key: Keycode, mask: ModMask) ModMask;
pub const modMaskRemoveConsumed = xkb_state_mod_mask_remove_consumed;
extern fn xkb_state_layout_name_is_active(state: *State, name: [*c]const u8, kind: Component) c_int;
pub const layoutNameIsActive = xkb_state_layout_name_is_active;
extern fn xkb_state_layout_index_is_active(state: *State, idx: LayoutIndex, kind: Component) c_int;
pub const layoutIndexIsActive = xkb_state_layout_index_is_active;
extern fn xkb_state_led_name_is_active(state: *State, name: [*c]const u8) c_int;
pub const ledNameIsActive = xkb_state_led_name_is_active;
extern fn xkb_state_led_index_is_active(state: *State, idx: LED_Index) c_int;
pub const ledIndexIsActive = xkb_state_led_index_is_active;
};
fn refAllDeclsRecursive(comptime T: type) void {
const decls = switch (@typeInfo(T)) {
.Struct => |info| info.decls,
.Union => |info| info.decls,
.Enum => |info| info.decls,
.Opaque => |info| info.decls,
else => return,
};
inline for (decls) |decl| {
switch (decl.data) {
.Type => |T2| refAllDeclsRecursive(T2),
else => _ = decl,
}
}
}
test "" {
refAllDeclsRecursive(@This());
}
|
source/river-0.1.0/deps/zig-xkbcommon/src/xkbcommon.zig
|
const std = @import("std");
const assert = std.debug.assert;
const c = @import("c.zig");
const helpers = @import("helpers.zig");
const enc = @import("encode.zig");
const dec = @import("decode.zig");
const seek_key = @import("seek_key.zig");
const seek_path = @import("seek_path.zig");
var alloc = std.heap.GeneralPurposeAllocator(.{}){};
var allocator = &alloc.allocator;
export fn napi_register_module_v1(env: c.napi_env, exports: c.napi_value) c.napi_value {
helpers.register_function(env, exports, "encodingLength", encodingLength) catch return null;
helpers.register_function(env, exports, "encode", encode) catch return null;
helpers.register_function(env, exports, "decode", decode) catch return null;
helpers.register_function(env, exports, "seekKey", seekKey) catch return null;
helpers.register_function(env, exports, "allocAndEncode", allocAndEncode) catch return null;
helpers.register_function(env, exports, "slice", slice) catch return null;
helpers.register_function(env, exports, "seekPath", seekPath) catch return null;
return exports;
}
fn encodingLength(env: c.napi_env, info: c.napi_callback_info) callconv(.C) c.napi_value {
var argc: usize = 1;
var argv: [1]c.napi_value = undefined;
if (c.napi_get_cb_info(env, info, &argc, &argv, null, null) != .napi_ok) {
helpers.throw(env, "Failed to get args") catch return null;
}
var input = if (argc == 1) argv[0] else helpers.getUndefined(env) catch return null;
const result = enc.encodingLength(env, input) catch return null;
return helpers.u32ToJS(env, result) catch return null;
}
fn encode(env: c.napi_env, info: c.napi_callback_info) callconv(.C) c.napi_value {
var argc: usize = 4;
var argv: [4]c.napi_value = undefined;
if (c.napi_get_cb_info(env, info, &argc, &argv, null, null) != .napi_ok) {
helpers.throw(env, "Failed to get args") catch return null;
}
if (argc < 2) {
helpers.throw(env, "Not enough arguments") catch return null;
}
var inputJS = argv[0];
var buffer = helpers.slice_from_value(env, argv[1], "buffer") catch return null;
var start: u32 = undefined;
if (argc >= 3) {
if (c.napi_get_value_uint32(env, argv[2], &start) != .napi_ok) {
helpers.throw(env, "Failed to get start") catch return null;
}
} else {
start = 0;
}
var total = enc.encode(env, inputJS, buffer, start) catch return null;
var totalJS: c.napi_value = undefined;
if (c.napi_create_uint32(env, @intCast(u32, total), &totalJS) != .napi_ok) {
helpers.throw(env, "Failed to create total") catch return null;
}
return totalJS;
}
fn decode(env: c.napi_env, info: c.napi_callback_info) callconv(.C) c.napi_value {
var argc: usize = 2;
var argv: [2]c.napi_value = undefined;
if (c.napi_get_cb_info(env, info, &argc, &argv, null, null) != .napi_ok) {
helpers.throw(env, "Failed to get args") catch return null;
}
if (argc < 1) {
helpers.throw(env, "Not enough arguments") catch return null;
}
var buffer = helpers.slice_from_value(env, argv[0], "buffer") catch return null;
var start: u32 = undefined;
if (argc >= 2) {
if (c.napi_get_value_uint32(env, argv[1], &start) != .napi_ok) {
helpers.throw(env, "Failed to get start") catch return null;
}
} else {
start = 0;
}
return dec.decode(env, buffer, start) catch return null;
}
fn allocAndEncode(env: c.napi_env, info: c.napi_callback_info) callconv(.C) c.napi_value {
var argc: usize = 1;
var argv: [1]c.napi_value = undefined;
if (c.napi_get_cb_info(env, info, &argc, &argv, null, null) != .napi_ok) {
helpers.throw(env, "Failed to get args") catch return null;
}
if (argc < 1) {
helpers.throw(env, "Not enough arguments") catch return null;
}
var inputJS = argv[0];
const len = enc.encodingLength(env, inputJS) catch 0;
var dest = allocator.alloc(u8, len) catch return null;
defer allocator.free(dest);
var written = enc.encode(env, inputJS, dest, 0) catch 0;
return helpers.create_buffer(env, dest, "could not create buffer") catch return null;
}
fn seekKey(env: c.napi_env, info: c.napi_callback_info) callconv(.C) c.napi_value {
var argc: usize = 3;
var argv: [3]c.napi_value = undefined;
if (c.napi_get_cb_info(env, info, &argc, &argv, null, null) != .napi_ok) {
helpers.throw(env, "Failed to get args") catch return null;
}
if (argc < 3) {
helpers.throw(env, "Not enough arguments") catch return null;
}
var buffer = helpers.slice_from_value(env, argv[0], "1st arg") catch return null;
var start_i: i32 = undefined;
if (c.napi_get_value_int32(env, argv[1], &start_i) != .napi_ok) {
helpers.throw(env, "Failed to get start") catch return null;
}
if (start_i == -1) {
return helpers.i32ToJS(env, -1) catch return null;
}
var key: []u8 = undefined;
if (helpers.isTypeof(env, argv[2], c.napi_valuetype.napi_string)) {
// TODO document / modify bound
var bytes: usize = undefined;
var len: usize = 1024;
key = allocator.alloc(u8, len) catch return null;
if (c.napi_get_value_string_utf8(env, argv[2], @ptrCast([*c]u8, key), len, &bytes) != .napi_ok) {
helpers.throw(env, "3rd arg is not a string") catch return null;
}
key = key[0..bytes];
} else {
key = helpers.slice_from_value(env, argv[2], "3rd arg") catch return null;
}
defer allocator.free(key);
if (seek_key.seekKey(env, buffer, @intCast(u32, start_i), key)) |result| {
return helpers.u32ToJS(env, result) catch return null;
} else |err| switch(err) {
error.NOT_FOUND => return helpers.i32ToJS(env, -1) catch return null
}
}
fn slice(env: c.napi_env, info: c.napi_callback_info) callconv(.C) c.napi_value {
var argc: usize = 2;
var argv: [2]c.napi_value = undefined;
if (c.napi_get_cb_info(env, info, &argc, &argv, null, null) != .napi_ok) {
helpers.throw(env, "Failed to get args") catch return null;
}
if (argc < 2) {
helpers.throw(env, "Not enough arguments") catch return null;
}
var buffer = helpers.slice_from_value(env, argv[0], "1st arg") catch return null;
var start: u32 = undefined;
if (c.napi_get_value_uint32(env, argv[1], &start) != .napi_ok) {
helpers.throw(env, "Failed to get start") catch return null;
}
var res = seek_key.slice(env, buffer, start) catch return null;
return helpers.create_buffer(env, res, "could not create buffer")catch return null;
}
fn seekPath(env: c.napi_env, info: c.napi_callback_info) callconv(.C) c.napi_value {
var argc: usize = 4;
var argv: [4]c.napi_value = undefined;
if (c.napi_get_cb_info(env, info, &argc, &argv, null, null) != .napi_ok) {
helpers.throw(env, "Failed to get args") catch return null;
}
if (argc < 3) {
helpers.throw(env, "Not enough arguments") catch return null;
}
var buffer = helpers.slice_from_value(env, argv[0], "1st arg") catch return null;
var start_i: i32 = undefined;
if (c.napi_get_value_int32(env, argv[1], &start_i) != .napi_ok) {
helpers.throw(env, "Failed to get start") catch return null;
}
if (start_i == -1) {
return helpers.i32ToJS(env, -1) catch return null;
}
var target = helpers.slice_from_value(env, argv[2], "3rd arg") catch return null;
var target_start: u32 = 0;
if (argc >= 4) {
if (c.napi_get_value_uint32(env, argv[3], &target_start) != .napi_ok) {
helpers.throw(env, "Failed to get target_start") catch return null;
}
}
if (seek_path.seekPath(env, buffer, @intCast(u32, start_i), target, target_start)) |res| {
return helpers.u32ToJS(env, res) catch return null;
} else |err| switch(err) {
error.NOT_FOUND => return helpers.i32ToJS(env, -1) catch return null,
error.NOT_AN_ARRAY => return helpers.throw(env, "path must be encoded array") catch return null,
error.NOT_STRING_OR_BUFFER => return helpers.throw(env, "path must be encoded array of strings") catch return null
}
}
|
src/lib.zig
|
const std = @import("std");
usingnamespace (@import("../machine.zig"));
usingnamespace (@import("../util.zig"));
test "extra instructions" {
const m32 = Machine.init(.x86_32);
const m64 = Machine.init(.x64);
const reg = Operand.register;
const regRm = Operand.registerRm;
const imm = Operand.immediate;
const imm16 = Operand.immediate16;
const imm32 = Operand.immediate32;
const memRm = Operand.memoryRmDef;
const reg16 = Operand.register(.AX);
const reg32 = Operand.register(.EAX);
const reg64 = Operand.register(.RAX);
const rm8 = Operand.memoryRm(.DefaultSeg, .BYTE, .EAX, 0);
const rm16 = Operand.memoryRm(.DefaultSeg, .WORD, .EAX, 0);
const rm32 = Operand.memoryRm(.DefaultSeg, .DWORD, .EAX, 0);
const rm64 = Operand.memoryRm(.DefaultSeg, .QWORD, .EAX, 0);
const rm_mem = Operand.memoryRm(.DefaultSeg, .Void, .EAX, 0);
const rm_mem8 = Operand.memoryRm(.DefaultSeg, .BYTE, .EAX, 0);
const rm_mem16 = Operand.memoryRm(.DefaultSeg, .WORD, .EAX, 0);
const rm_mem32 = Operand.memoryRm(.DefaultSeg, .DWORD, .EAX, 0);
const rm_mem64 = Operand.memoryRm(.DefaultSeg, .QWORD, .EAX, 0);
const rm_mem128 = Operand.memoryRm(.DefaultSeg, .OWORD, .EAX, 0);
debugPrint(false);
{
// Pentium MMX
testOp0(m32, .RDPMC, "0F 33");
testOp0(m64, .RDPMC, "0F 33");
// Pentium Pro
testOp0(m64, .UD2, "0F 0B");
// AMD K6
testOp0(m64, .SYSCALL, "0F 05");
testOp0(m64, .SYSRET, "0F 07");
testOp0(m64, .SYSRETQ, "48 0F 07");
// Pentium II
testOp0(m64, .SYSENTER, "0F 34");
testOp0(m64, .SYSEXIT, "0F 35");
testOp0(m64, .SYSEXITQ, "48 0F 35");
// x86-64
testOp0(m32, .RDTSCP, "0F 01 F9");
testOp0(m64, .RDTSCP, "0F 01 F9");
testOp0(m32, .SWAPGS, "0F 01 F8");
testOp0(m64, .SWAPGS, "0F 01 F8");
}
{
const op1 = Operand.register(.AX);
const op2 = Operand.memoryRm(.DefaultSeg, .WORD, .EAX, 0);
testOp2(m64, .UD0, op1, op2, "66 67 0F FF 00");
testOp2(m64, .UD1, op1, op2, "66 67 0F B9 00");
}
// SSE non-vector
{
testOp0(m64, .SFENCE, "0F AE F8");
testOp0(m64, .LFENCE, "0F AE E8");
testOp0(m64, .MFENCE, "0F AE F0");
testOp0(m64, .PAUSE, "F3 90");
testOp0(m64, .MONITOR, "0F 01 C8");
testOp0(m64, .MWAIT, "0F 01 C9");
testOp1(m64, .FXSAVE, rm_mem, "67 0F AE 00");
testOp1(m64, .FXSAVE64, rm_mem, "67 48 0F AE 00");
testOp1(m64, .FXRSTOR, rm_mem, "67 0F AE 08");
testOp1(m64, .FXRSTOR64, rm_mem, "67 48 0F AE 08");
testOp1(m64, .CLFLUSH, rm_mem8, "67 0F AE 38");
testOp1(m64, .PREFETCHNTA, rm_mem8, "67 0F 18 00");
testOp1(m64, .PREFETCHT0, rm_mem8, "67 0F 18 08");
testOp1(m64, .PREFETCHT1, rm_mem8, "67 0F 18 10");
testOp1(m64, .PREFETCHT2, rm_mem8, "67 0F 18 18");
testOp2(m64, .MOVNTI, rm_mem32, reg32, "67 0F C3 00");
testOp2(m64, .MOVNTI, rm_mem64, reg64, "67 48 0F C3 00");
testOp1(m32, .LDMXCSR, rm_mem32, "0F AE 10");
testOp1(m64, .LDMXCSR, rm_mem32, "67 0F AE 10");
testOp1(m32, .STMXCSR, rm_mem32, "0F AE 18");
testOp1(m64, .STMXCSR, rm_mem32, "67 0F AE 18");
}
// CRC32
{
// CRC32
testOp2(m64, .CRC32, reg(.EAX), rm8, "67f20f38f000");
testOp2(m64, .CRC32, reg(.EAX), rm16, "6667f20f38f100");
testOp2(m64, .CRC32, reg(.EAX), rm32, "67f20f38f100");
testOp2(m64, .CRC32, reg(.RAX), rm64, "67f2480f38f100");
}
// ADX
{
// ADCX
testOp2(m64, .ADCX, reg32, rm32, "67 66 0F 38 F6 00");
testOp2(m64, .ADCX, reg64, rm64, "67 66 48 0F 38 F6 00");
// ADOX
testOp2(m64, .ADOX, reg32, rm32, "67 F3 0F 38 F6 00");
testOp2(m64, .ADOX, reg64, rm64, "67 F3 48 0F 38 F6 00");
}
// BOUND
{
testOp2(m32, .BNDCL, reg(.BND0), rm32, "F3 0F 1A 00");
testOp2(m32, .BNDCL, reg(.BND0), rm64, AsmError.InvalidOperand);
testOp2(m64, .BNDCL, reg(.BND0), rm64, "67 F3 0F 1A 00");
testOp2(m64, .BNDCL, reg(.BND0), rm32, AsmError.InvalidOperand);
testOp2(m32, .BNDCL, reg(.BND3), rm32, "F3 0F 1A 18");
testOp2(m32, .BNDCL, reg(.BND3), rm64, AsmError.InvalidOperand);
testOp2(m64, .BNDCL, reg(.BND3), rm64, "67 F3 0F 1A 18");
testOp2(m64, .BNDCL, reg(.BND3), rm32, AsmError.InvalidOperand);
//
testOp2(m32, .BNDCU, reg(.BND0), rm32, "F2 0F 1A 00");
testOp2(m64, .BNDCU, reg(.BND0), rm64, "67 F2 0F 1A 00");
testOp2(m32, .BNDCN, reg(.BND0), rm32, "F2 0F 1B 00");
testOp2(m64, .BNDCN, reg(.BND0), rm64, "67 F2 0F 1B 00");
// reg(. " ");
testOp2(m64, .BNDLDX, reg(.BND0), rm_mem, "67 0F 1A 00");
// reg(. " ");
testOp2(m32, .BNDMK, reg(.BND0), rm_mem32, "F3 0F 1B 00");
testOp2(m64, .BNDMK, reg(.BND0), rm_mem64, "67 F3 0F 1B 00");
// reg(. " ");
testOp2(m32, .BNDMOV, reg(.BND0), regRm(.BND0), "66 0F 1A C0");
testOp2(m64, .BNDMOV, reg(.BND0), regRm(.BND0), "66 0F 1A C0");
testOp2(m32, .BNDMOV, regRm(.BND0), reg(.BND0), "66 0F 1B C0");
testOp2(m64, .BNDMOV, regRm(.BND0), reg(.BND0), "66 0F 1B C0");
//
testOp2(m32, .BNDMOV, reg(.BND0), rm_mem64, "66 0F 1A 00");
testOp2(m64, .BNDMOV, reg(.BND0), rm_mem128, "67 66 0F 1A 00");
testOp2(m32, .BNDMOV, rm_mem64, reg(.BND0), "66 0F 1B 00");
testOp2(m64, .BNDMOV, rm_mem128, reg(.BND0), "67 66 0F 1B 00");
// reg( "
testOp2(m64, .BNDSTX, rm_mem, reg(.BND0), "67 0F 1B 00");
}
// FSGSBASE
{
// RDFSBASE
testOp1(m64, .RDFSBASE, reg32, "F3 0F AE c0");
testOp1(m64, .RDFSBASE, reg64, "F3 48 0F AE c0");
// RDGSBASE
testOp1(m64, .RDGSBASE, reg32, "F3 0F AE c8");
testOp1(m64, .RDGSBASE, reg64, "F3 48 0F AE c8");
// WRFSBASE
testOp1(m64, .WRFSBASE, reg32, "F3 0F AE d0");
testOp1(m64, .WRFSBASE, reg64, "F3 48 0F AE d0");
// WRGSBASE
testOp1(m64, .WRGSBASE, reg32, "F3 0F AE d8");
testOp1(m64, .WRGSBASE, reg64, "F3 48 0F AE d8");
}
// TDX
{
testOp0(m64, .XACQUIRE, "F2");
testOp0(m64, .XRELEASE, "F3");
testOp1(m64, .XABORT, imm(0), "C6 F8 00");
testOp1(m64, .XBEGIN, imm(0), "66 C7 F8 00 00");
testOp1(m64, .XBEGIN, imm16(0), "66 C7 F8 00 00");
testOp1(m64, .XBEGIN, imm32(0), "C7 F8 00 00 00 00");
testOp0(m64, .XEND, "0F 01 D5");
testOp0(m64, .XTEST, "0F 01 D6");
}
// XSAVE
{
testOp0(m64, .XGETBV, "0F 01 D0");
testOp0(m64, .XSETBV, "0F 01 D1");
testOp1(m64, .XSAVE, rm_mem, "67 0F AE 20");
testOp1(m64, .XSAVE64, rm_mem, "67 48 0F AE 20");
testOp1(m64, .XRSTOR, rm_mem, "67 0F AE 28");
testOp1(m64, .XRSTOR64, rm_mem, "67 48 0F AE 28");
testOp1(m64, .XSAVEOPT, rm_mem, "67 0F AE 30");
testOp1(m64, .XSAVEOPT64, rm_mem, "67 48 0F AE 30");
testOp1(m64, .XSAVEC, rm_mem, "67 0F C7 20");
testOp1(m64, .XSAVEC64, rm_mem, "67 48 0F C7 20");
testOp1(m64, .XSAVES, rm_mem, "67 0F C7 28");
testOp1(m64, .XSAVES64, rm_mem, "67 48 0F C7 28");
testOp1(m64, .XRSTORS, rm_mem, "67 0F C7 18");
testOp1(m64, .XRSTORS64, rm_mem, "67 48 0F C7 18");
}
// AES
{
testOp2(m64, .AESDEC, reg(.XMM0), reg(.XMM0), "66 0f 38 de c0");
testOp2(m64, .AESDECLAST, reg(.XMM0), reg(.XMM0), "66 0f 38 df c0");
testOp2(m64, .AESENC, reg(.XMM0), reg(.XMM0), "66 0f 38 dc c0");
testOp2(m64, .AESENCLAST, reg(.XMM0), reg(.XMM0), "66 0f 38 dd c0");
testOp2(m64, .AESIMC, reg(.XMM0), reg(.XMM0), "66 0f 38 db c0");
testOp3(m64, .AESKEYGENASSIST, reg(.XMM0), reg(.XMM0), imm(0), "66 0F 3A DF c0 00");
}
// GFNI
{
testOp3(m64, .GF2P8AFFINEINVQB, reg(.XMM0), reg(.XMM0), imm(0), "66 0F 3A CF c0 00");
testOp3(m64, .GF2P8AFFINEQB, reg(.XMM0), reg(.XMM0), imm(0), "66 0F 3A CE c0 00");
testOp2(m64, .GF2P8MULB, reg(.XMM0), reg(.XMM0), "66 0F 38 CF c0");
}
// CLDEMOTE
{
testOp1(m32, .CLDEMOTE, rm_mem8, "0F 1C 00");
testOp1(m64, .CLDEMOTE, rm_mem8, "67 0F 1C 00");
}
// CET_IBT
{
testOp0(m64, .ENDBR32, "f30f1efb");
testOp0(m64, .ENDBR64, "f30f1efa");
}
// CET_SS
{
// CLRSSBSY
testOp1(m64, .CLRSSBSY, rm_mem64, "67 f3 0f ae 30");
// INCSSPD / INCSSPQ
testOp1(m64, .INCSSPD, reg(.EAX), "f3 0f ae e8");
testOp1(m64, .INCSSPQ, reg(.RAX), "f3 48 0f ae e8");
// RDSSP
testOp1(m64, .RDSSPD, reg(.EAX), "f3 0f 1e c8");
testOp1(m64, .RDSSPQ, reg(.RAX), "f3 48 0f 1e c8");
// RSTORSSP
testOp1(m64, .RSTORSSP, rm_mem64, "67 f3 0f 01 28");
// SAVEPREVSSP
testOp0(m64, .SAVEPREVSSP, "f3 0f 01 ea");
// SETSSBSY
testOp0(m64, .SETSSBSY, "f3 0f 01 e8");
// WRSS
testOp2(m64, .WRSSD, rm32, reg(.EAX), "67 0f 38 f6 00");
testOp2(m64, .WRSSQ, rm64, reg(.RAX), "67 48 0f 38 f6 00");
// WRUSS
testOp2(m64, .WRUSSD, rm32, reg(.EAX), "67 66 0f 38 f5 00");
testOp2(m64, .WRUSSQ, rm64, reg(.RAX), "67 66 48 0f 38 f5 00");
}
// CLWB
{
testOp1(m32, .CLWB, rm_mem8, "66 0F AE 30");
testOp1(m64, .CLWB, rm_mem8, "67 66 0F AE 30");
}
// CLFLUSHOPT
{
testOp1(m32, .CLFLUSHOPT, rm_mem8, "66 0F AE 38");
testOp1(m64, .CLFLUSHOPT, rm_mem8, "67 66 0F AE 38");
}
// INVPCID
{
testOp2(m32, .INVPCID, reg32, rm_mem128, "66 0F 38 82 00");
testOp2(m64, .INVPCID, reg64, rm_mem128, "67 66 0F 38 82 00");
}
// MOVBE
{
testOp2(m64, .MOVBE, reg16, rm_mem16, "66 67 0F 38 F0 00");
testOp2(m64, .MOVBE, reg32, rm_mem32, "67 0F 38 F0 00");
testOp2(m64, .MOVBE, reg64, rm_mem64, "67 48 0F 38 F0 00");
//
testOp2(m64, .MOVBE, rm_mem16, reg16, "66 67 0F 38 F1 00");
testOp2(m64, .MOVBE, rm_mem32, reg32, "67 0F 38 F1 00");
testOp2(m64, .MOVBE, rm_mem64, reg64, "67 48 0F 38 F1 00");
}
// MOVDIRI
{
testOp2(m64, .MOVDIRI, rm_mem32, reg32, "67 0F 38 F9 00");
testOp2(m64, .MOVDIRI, rm_mem64, reg64, "67 48 0F 38 F9 00");
}
// MOVDIR64B
{
// TODO: this should work, but we need to use 16 bit addressing
if (false) {
testOp2(m32, .MOVDIR64B, reg16, TODO, "67 66 0F 38 F8 00");
}
testOp2(m32, .MOVDIR64B, reg32, memRm(.Void, .EAX, 0), "66 0F 38 F8 00");
testOp2(m32, .MOVDIR64B, reg64, memRm(.Void, .EAX, 0), AsmError.InvalidOperand);
testOp2(m64, .MOVDIR64B, reg16, memRm(.Void, .EAX, 0), AsmError.InvalidOperand);
testOp2(m64, .MOVDIR64B, reg16, memRm(.Void, .RAX, 0), AsmError.InvalidOperand);
testOp2(m64, .MOVDIR64B, reg32, memRm(.Void, .EAX, 0), "67 66 0F 38 F8 00");
testOp2(m64, .MOVDIR64B, reg32, memRm(.Void, .RAX, 0), AsmError.InvalidOperand);
testOp2(m64, .MOVDIR64B, reg64, memRm(.Void, .EAX, 0), AsmError.InvalidOperand);
testOp2(m64, .MOVDIR64B, reg64, memRm(.Void, .RAX, 0), "66 0F 38 F8 00");
}
// WAITPKG
{
testOp1(m32, .UMONITOR, reg16, "67 F3 0F AE f0");
testOp1(m32, .UMONITOR, reg32, "F3 0F AE f0");
testOp1(m32, .UMONITOR, reg64, AsmError.InvalidOperand);
testOp1(m64, .UMONITOR, reg16, AsmError.InvalidOperand);
testOp1(m64, .UMONITOR, reg32, "67 F3 0F AE f0");
testOp1(m64, .UMONITOR, reg64, "F3 0F AE f0");
testOp3(m32, .UMWAIT, reg32, reg(.EDX), reg(.EAX), "F2 0F AE f0");
testOp1(m32, .UMWAIT, reg32, "F2 0F AE f0");
testOp3(m32, .TPAUSE, reg32, reg(.EDX), reg(.EAX), "66 0F AE f0");
testOp1(m32, .TPAUSE, reg32, "66 0F AE f0");
}
// SHA
{
testOp3(m64, .SHA1RNDS4, reg(.XMM0), reg(.XMM0), imm(0), "0f 3a cc c0 00");
testOp2(m64, .SHA1NEXTE, reg(.XMM0), reg(.XMM0), "0f 38 c8 c0");
testOp2(m64, .SHA1MSG1, reg(.XMM0), reg(.XMM0), "0f 38 c9 c0");
testOp2(m64, .SHA1MSG2, reg(.XMM0), reg(.XMM0), "0f 38 ca c0");
testOp2(m64, .SHA256RNDS2, reg(.XMM0), reg(.XMM0), "0f 38 cb c0");
testOp3(m64, .SHA256RNDS2, reg(.XMM0), reg(.XMM0), reg(.XMM0), "0f 38 cb c0");
testOp2(m64, .SHA256MSG1, reg(.XMM0), reg(.XMM0), "0f 38 cc c0");
testOp2(m64, .SHA256MSG2, reg(.XMM0), reg(.XMM0), "0f 38 cd c0");
}
// PKRU
{
testOp0(m64, .RDPKRU, "0F 01 EE");
testOp0(m64, .WRPKRU, "0F 01 EF");
}
// PREFETCHW
{
testOp1(m64, .PREFETCHW, rm_mem8, "67 0F 0D 08");
}
// PTWRITE
{
testOp1(m64, .PTWRITE, reg32, "F3 0F AE E0");
testOp1(m64, .PTWRITE, reg64, "F3 48 0F AE E0");
testOp1(m64, .PTWRITE, rm_mem32, "67 F3 0F AE 20");
testOp1(m64, .PTWRITE, rm_mem64, "67 F3 48 0F AE 20");
}
// RDPID
{
testOp1(m32, .RDPID, reg32, "F3 0F C7 f8");
testOp1(m64, .RDPID, reg64, "F3 0F C7 f8");
}
// RDRAND
{
testOp1(m64, .RDRAND, reg16, "66 0F C7 f0");
testOp1(m64, .RDRAND, reg32, "0F C7 f0");
testOp1(m64, .RDRAND, reg64, "48 0F C7 f0");
}
// RDSEED
{
testOp1(m64, .RDSEED, reg16, "66 0F C7 f8");
testOp1(m64, .RDSEED, reg32, "0F C7 f8");
testOp1(m64, .RDSEED, reg64, "48 0F C7 f8");
}
// SMAP
{
testOp0(m64, .CLAC, "0F 01 CA");
testOp0(m64, .STAC, "0F 01 CB");
}
// SGX
{
testOp0(m64, .ENCLS, "0F 01 CF");
testOp0(m64, .ENCLU, "0F 01 D7");
testOp0(m64, .ENCLV, "0F 01 C0");
}
// SMX
{
testOp0(m64, .GETSEC, "0F 37");
}
// CMOVcc Pentium Pro / P6
{
testOp2(m32, .CMOVA, reg16, rm16, "66 0F 47 00");
testOp2(m32, .CMOVA, reg32, rm32, "0F 47 00");
testOp2(m32, .CMOVA, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVAE, reg16, rm16, "66 0F 43 00");
testOp2(m32, .CMOVAE, reg32, rm32, "0F 43 00");
testOp2(m32, .CMOVAE, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVB, reg16, rm16, "66 0F 42 00");
testOp2(m32, .CMOVB, reg32, rm32, "0F 42 00");
testOp2(m32, .CMOVB, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVBE, reg16, rm16, "66 0F 46 00");
testOp2(m32, .CMOVBE, reg32, rm32, "0F 46 00");
testOp2(m32, .CMOVBE, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVC, reg16, rm16, "66 0F 42 00");
testOp2(m32, .CMOVC, reg32, rm32, "0F 42 00");
testOp2(m32, .CMOVC, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVE, reg16, rm16, "66 0F 44 00");
testOp2(m32, .CMOVE, reg32, rm32, "0F 44 00");
testOp2(m32, .CMOVE, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVG, reg16, rm16, "66 0F 4F 00");
testOp2(m32, .CMOVG, reg32, rm32, "0F 4F 00");
testOp2(m32, .CMOVG, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVGE, reg16, rm16, "66 0F 4D 00");
testOp2(m32, .CMOVGE, reg32, rm32, "0F 4D 00");
testOp2(m32, .CMOVGE, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVL, reg16, rm16, "66 0F 4C 00");
testOp2(m32, .CMOVL, reg32, rm32, "0F 4C 00");
testOp2(m32, .CMOVL, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVLE, reg16, rm16, "66 0F 4E 00");
testOp2(m32, .CMOVLE, reg32, rm32, "0F 4E 00");
testOp2(m32, .CMOVLE, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVNA, reg16, rm16, "66 0F 46 00");
testOp2(m32, .CMOVNA, reg32, rm32, "0F 46 00");
testOp2(m32, .CMOVNA, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVNAE, reg16, rm16, "66 0F 42 00");
testOp2(m32, .CMOVNAE, reg32, rm32, "0F 42 00");
testOp2(m32, .CMOVNAE, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVNB, reg16, rm16, "66 0F 43 00");
testOp2(m32, .CMOVNB, reg32, rm32, "0F 43 00");
testOp2(m32, .CMOVNB, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVNBE, reg16, rm16, "66 0F 47 00");
testOp2(m32, .CMOVNBE, reg32, rm32, "0F 47 00");
testOp2(m32, .CMOVNBE, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVNC, reg16, rm16, "66 0F 43 00");
testOp2(m32, .CMOVNC, reg32, rm32, "0F 43 00");
testOp2(m32, .CMOVNC, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVNE, reg16, rm16, "66 0F 45 00");
testOp2(m32, .CMOVNE, reg32, rm32, "0F 45 00");
testOp2(m32, .CMOVNE, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVNG, reg16, rm16, "66 0F 4E 00");
testOp2(m32, .CMOVNG, reg32, rm32, "0F 4E 00");
testOp2(m32, .CMOVNG, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVNGE, reg16, rm16, "66 0F 4C 00");
testOp2(m32, .CMOVNGE, reg32, rm32, "0F 4C 00");
testOp2(m32, .CMOVNGE, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVNL, reg16, rm16, "66 0F 4D 00");
testOp2(m32, .CMOVNL, reg32, rm32, "0F 4D 00");
testOp2(m32, .CMOVNL, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVNLE, reg16, rm16, "66 0F 4F 00");
testOp2(m32, .CMOVNLE, reg32, rm32, "0F 4F 00");
testOp2(m32, .CMOVNLE, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVNO, reg16, rm16, "66 0F 41 00");
testOp2(m32, .CMOVNO, reg32, rm32, "0F 41 00");
testOp2(m32, .CMOVNO, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVNP, reg16, rm16, "66 0F 4B 00");
testOp2(m32, .CMOVNP, reg32, rm32, "0F 4B 00");
testOp2(m32, .CMOVNP, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVNS, reg16, rm16, "66 0F 49 00");
testOp2(m32, .CMOVNS, reg32, rm32, "0F 49 00");
testOp2(m32, .CMOVNS, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVNZ, reg16, rm16, "66 0F 45 00");
testOp2(m32, .CMOVNZ, reg32, rm32, "0F 45 00");
testOp2(m32, .CMOVNZ, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVO, reg16, rm16, "66 0F 40 00");
testOp2(m32, .CMOVO, reg32, rm32, "0F 40 00");
testOp2(m32, .CMOVO, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVP, reg16, rm16, "66 0F 4A 00");
testOp2(m32, .CMOVP, reg32, rm32, "0F 4A 00");
testOp2(m32, .CMOVP, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVPE, reg16, rm16, "66 0F 4A 00");
testOp2(m32, .CMOVPE, reg32, rm32, "0F 4A 00");
testOp2(m32, .CMOVPE, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVPO, reg16, rm16, "66 0F 4B 00");
testOp2(m32, .CMOVPO, reg32, rm32, "0F 4B 00");
testOp2(m32, .CMOVPO, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVS, reg16, rm16, "66 0F 48 00");
testOp2(m32, .CMOVS, reg32, rm32, "0F 48 00");
testOp2(m32, .CMOVS, reg64, rm64, AsmError.InvalidOperand);
testOp2(m32, .CMOVZ, reg16, rm16, "66 0F 44 00");
testOp2(m32, .CMOVZ, reg32, rm32, "0F 44 00");
testOp2(m32, .CMOVZ, reg64, rm64, AsmError.InvalidOperand);
testOp2(m64, .CMOVA, reg16, rm16, "66 67 0F 47 00");
testOp2(m64, .CMOVA, reg32, rm32, "67 0F 47 00");
testOp2(m64, .CMOVA, reg64, rm64, "67 48 0F 47 00");
testOp2(m64, .CMOVAE, reg16, rm16, "66 67 0F 43 00");
testOp2(m64, .CMOVAE, reg32, rm32, "67 0F 43 00");
testOp2(m64, .CMOVAE, reg64, rm64, "67 48 0F 43 00");
testOp2(m64, .CMOVB, reg16, rm16, "66 67 0F 42 00");
testOp2(m64, .CMOVB, reg32, rm32, "67 0F 42 00");
testOp2(m64, .CMOVB, reg64, rm64, "67 48 0F 42 00");
testOp2(m64, .CMOVBE, reg16, rm16, "66 67 0F 46 00");
testOp2(m64, .CMOVBE, reg32, rm32, "67 0F 46 00");
testOp2(m64, .CMOVBE, reg64, rm64, "67 48 0F 46 00");
testOp2(m64, .CMOVC, reg16, rm16, "66 67 0F 42 00");
testOp2(m64, .CMOVC, reg32, rm32, "67 0F 42 00");
testOp2(m64, .CMOVC, reg64, rm64, "67 48 0F 42 00");
testOp2(m64, .CMOVE, reg16, rm16, "66 67 0F 44 00");
testOp2(m64, .CMOVE, reg32, rm32, "67 0F 44 00");
testOp2(m64, .CMOVE, reg64, rm64, "67 48 0F 44 00");
testOp2(m64, .CMOVG, reg16, rm16, "66 67 0F 4F 00");
testOp2(m64, .CMOVG, reg32, rm32, "67 0F 4F 00");
testOp2(m64, .CMOVG, reg64, rm64, "67 48 0F 4F 00");
testOp2(m64, .CMOVGE, reg16, rm16, "66 67 0F 4D 00");
testOp2(m64, .CMOVGE, reg32, rm32, "67 0F 4D 00");
testOp2(m64, .CMOVGE, reg64, rm64, "67 48 0F 4D 00");
testOp2(m64, .CMOVL, reg16, rm16, "66 67 0F 4C 00");
testOp2(m64, .CMOVL, reg32, rm32, "67 0F 4C 00");
testOp2(m64, .CMOVL, reg64, rm64, "67 48 0F 4C 00");
testOp2(m64, .CMOVLE, reg16, rm16, "66 67 0F 4E 00");
testOp2(m64, .CMOVLE, reg32, rm32, "67 0F 4E 00");
testOp2(m64, .CMOVLE, reg64, rm64, "67 48 0F 4E 00");
testOp2(m64, .CMOVNA, reg16, rm16, "66 67 0F 46 00");
testOp2(m64, .CMOVNA, reg32, rm32, "67 0F 46 00");
testOp2(m64, .CMOVNA, reg64, rm64, "67 48 0F 46 00");
testOp2(m64, .CMOVNAE, reg16, rm16, "66 67 0F 42 00");
testOp2(m64, .CMOVNAE, reg32, rm32, "67 0F 42 00");
testOp2(m64, .CMOVNAE, reg64, rm64, "67 48 0F 42 00");
testOp2(m64, .CMOVNB, reg16, rm16, "66 67 0F 43 00");
testOp2(m64, .CMOVNB, reg32, rm32, "67 0F 43 00");
testOp2(m64, .CMOVNB, reg64, rm64, "67 48 0F 43 00");
testOp2(m64, .CMOVNBE, reg16, rm16, "66 67 0F 47 00");
testOp2(m64, .CMOVNBE, reg32, rm32, "67 0F 47 00");
testOp2(m64, .CMOVNBE, reg64, rm64, "67 48 0F 47 00");
testOp2(m64, .CMOVNC, reg16, rm16, "66 67 0F 43 00");
testOp2(m64, .CMOVNC, reg32, rm32, "67 0F 43 00");
testOp2(m64, .CMOVNC, reg64, rm64, "67 48 0F 43 00");
testOp2(m64, .CMOVNE, reg16, rm16, "66 67 0F 45 00");
testOp2(m64, .CMOVNE, reg32, rm32, "67 0F 45 00");
testOp2(m64, .CMOVNE, reg64, rm64, "67 48 0F 45 00");
testOp2(m64, .CMOVNG, reg16, rm16, "66 67 0F 4E 00");
testOp2(m64, .CMOVNG, reg32, rm32, "67 0F 4E 00");
testOp2(m64, .CMOVNG, reg64, rm64, "67 48 0F 4E 00");
testOp2(m64, .CMOVNGE, reg16, rm16, "66 67 0F 4C 00");
testOp2(m64, .CMOVNGE, reg32, rm32, "67 0F 4C 00");
testOp2(m64, .CMOVNGE, reg64, rm64, "67 48 0F 4C 00");
testOp2(m64, .CMOVNL, reg16, rm16, "66 67 0F 4D 00");
testOp2(m64, .CMOVNL, reg32, rm32, "67 0F 4D 00");
testOp2(m64, .CMOVNL, reg64, rm64, "67 48 0F 4D 00");
testOp2(m64, .CMOVNLE, reg16, rm16, "66 67 0F 4F 00");
testOp2(m64, .CMOVNLE, reg32, rm32, "67 0F 4F 00");
testOp2(m64, .CMOVNLE, reg64, rm64, "67 48 0F 4F 00");
testOp2(m64, .CMOVNO, reg16, rm16, "66 67 0F 41 00");
testOp2(m64, .CMOVNO, reg32, rm32, "67 0F 41 00");
testOp2(m64, .CMOVNO, reg64, rm64, "67 48 0F 41 00");
testOp2(m64, .CMOVNP, reg16, rm16, "66 67 0F 4B 00");
testOp2(m64, .CMOVNP, reg32, rm32, "67 0F 4B 00");
testOp2(m64, .CMOVNP, reg64, rm64, "67 48 0F 4B 00");
testOp2(m64, .CMOVNS, reg16, rm16, "66 67 0F 49 00");
testOp2(m64, .CMOVNS, reg32, rm32, "67 0F 49 00");
testOp2(m64, .CMOVNS, reg64, rm64, "67 48 0F 49 00");
testOp2(m64, .CMOVNZ, reg16, rm16, "66 67 0F 45 00");
testOp2(m64, .CMOVNZ, reg32, rm32, "67 0F 45 00");
testOp2(m64, .CMOVNZ, reg64, rm64, "67 48 0F 45 00");
testOp2(m64, .CMOVO, reg16, rm16, "66 67 0F 40 00");
testOp2(m64, .CMOVO, reg32, rm32, "67 0F 40 00");
testOp2(m64, .CMOVO, reg64, rm64, "67 48 0F 40 00");
testOp2(m64, .CMOVP, reg16, rm16, "66 67 0F 4A 00");
testOp2(m64, .CMOVP, reg32, rm32, "67 0F 4A 00");
testOp2(m64, .CMOVP, reg64, rm64, "67 48 0F 4A 00");
testOp2(m64, .CMOVPE, reg16, rm16, "66 67 0F 4A 00");
testOp2(m64, .CMOVPE, reg32, rm32, "67 0F 4A 00");
testOp2(m64, .CMOVPE, reg64, rm64, "67 48 0F 4A 00");
testOp2(m64, .CMOVPO, reg16, rm16, "66 67 0F 4B 00");
testOp2(m64, .CMOVPO, reg32, rm32, "67 0F 4B 00");
testOp2(m64, .CMOVPO, reg64, rm64, "67 48 0F 4B 00");
testOp2(m64, .CMOVS, reg16, rm16, "66 67 0F 48 00");
testOp2(m64, .CMOVS, reg32, rm32, "67 0F 48 00");
testOp2(m64, .CMOVS, reg64, rm64, "67 48 0F 48 00");
testOp2(m64, .CMOVZ, reg16, rm16, "66 67 0F 44 00");
testOp2(m64, .CMOVZ, reg32, rm32, "67 0F 44 00");
testOp2(m64, .CMOVZ, reg64, rm64, "67 48 0F 44 00");
}
}
|
src/x86/tests/extra.zig
|
const std = @import("std");
const known_folders = @import("known-folders");
const api = @import("./api.zig");
const shared = @import("./shared.zig");
const allocator = std.heap.page_allocator;
var log_file: ?std.fs.File = null;
var log_writer: ?std.fs.File.Writer = null;
pub fn log(
comptime message_level: std.log.Level,
comptime scope: @Type(.EnumLiteral),
comptime format: []const u8,
args: anytype,
) void {
const level_txt = switch (message_level) {
.emerg => "emergency",
.alert => "alert",
.crit => "critical",
.err => "error",
.warn => "warning",
.notice => "notice",
.info => "info",
.debug => "debug",
};
const prefix2 = if (scope == .default) ": " else "(" ++ @tagName(scope) ++ "): ";
if (log_writer) |writer| {
writer.print(level_txt ++ prefix2 ++ format ++ "\n", args) catch return;
}
}
pub fn panic(err: []const u8, maybe_trace: ?*std.builtin.StackTrace) noreturn {
if (log_file) |file| {
var writer = file.writer();
writer.writeAll("Panic: ") catch unreachable;
writer.writeAll(err) catch unreachable;
if (maybe_trace) |trace| writer.print("{}\n", .{trace}) catch unreachable;
}
while (true) {
@breakpoint();
}
}
export fn VSTPluginMain(callback: api.HostCallback) ?*api.AEffect {
var effect = allocator.create(api.AEffect) catch unreachable;
effect.* = .{
.dispatcher = onDispatch,
.setParameter = setParameter,
.getParameter = getParameter,
.processReplacing = processReplacing,
.processReplacingF64 = processReplacingF64,
.unique_id = 0x93843,
.initial_delay = 0,
.version = 0,
.num_programs = 0,
.num_params = shared.Parameters.count,
.num_inputs = 2,
.num_outputs = 2,
.flags = api.Plugin.Flag.toBitmask(&[_]api.Plugin.Flag{
.CanReplacing, .HasEditor,
}),
};
const cwd = std.fs.cwd();
const desktop_path = (known_folders.getPath(allocator, .desktop) catch unreachable).?;
const log_path = std.fs.path.join(allocator, &[_][]const u8{
desktop_path,
"zig-analyzer-log.txt",
}) catch unreachable;
log_file = cwd.createFile(log_path, .{}) catch unreachable;
log_writer = log_file.?.writer();
std.log.debug("\n\n===============\nCreated log file", .{});
return effect;
}
fn onDispatch(
effect: *api.AEffect,
opcode: i32,
index: i32,
value: isize,
ptr: ?*c_void,
opt: f32,
) callconv(.C) isize {
const code = api.Codes.HostToPlugin.fromInt(opcode) catch {
std.log.warn("Unknown opcode: {}", .{opcode});
return 0;
};
switch (code) {
.GetProductName => _ = setData(u8, ptr.?, "Zig Analyzer", api.ProductNameMaxLength),
.GetVendorName => _ = setData(u8, ptr.?, "schroffl", api.VendorNameMaxLength),
.GetPresetName => _ = setData(u8, ptr.?, "Default", api.ProductNameMaxLength),
.GetApiVersion => return 2400,
.GetCategory => return api.Plugin.Category.Analysis.toI32(),
.Initialize => {
var plugin_ptr = allocator.create(Plugin) catch {
std.log.crit("Failed to allocate Plugin", .{});
return 0;
};
Plugin.init(plugin_ptr) catch |err| {
std.log.crit("Plugin.init failed: {}", .{err});
return 0;
};
effect.user = plugin_ptr;
},
.SetSampleRate => {
std.log.debug("Sample rate: {}", .{opt});
if (Plugin.fromEffect(effect)) |plugin| plugin.sample_rate = opt;
},
.SetBufferSize => {
if (Plugin.fromEffect(effect)) |plugin| {
plugin.buffer_size = value;
plugin.sample_buffer = allocator.alloc(f32, @intCast(usize, value * 2)) catch {
std.log.crit("Failed to allocate sample buffer", .{});
return 0;
};
}
},
.GetCurrentPresetNum => return 0,
.GetMidiKeyName => _ = setData(u8, ptr.?, "what is this?", api.ProductNameMaxLength),
.GetTailSize => return 1,
.CanDo => {
const can_do = @ptrCast([*:0]u8, ptr.?);
std.log.debug("CanDo: {s}", .{can_do});
return -1;
},
.EditorGetRect => {
var rect = allocator.create(api.Rect) catch |err| {
std.log.err("Failed to allocate editor rect: {}", .{err});
return 0;
};
rect.top = 0;
rect.left = 0;
rect.right = 900;
rect.bottom = 900;
var rect_ptr = @ptrCast(**c_void, @alignCast(@alignOf(**c_void), ptr.?));
rect_ptr.* = rect;
return 1;
},
.EditorOpen => {
std.log.debug("EditorOpen: {}", .{ptr.?});
if (Plugin.fromEffect(effect)) |plugin| {
plugin.renderer.editorOpen(ptr.?) catch unreachable;
}
return 1;
},
.EditorClose => {
std.log.debug("EditorClose", .{});
if (Plugin.fromEffect(effect)) |plugin| {
plugin.renderer.editorClose();
}
return 1;
},
.GetParameterDisplay => {
std.log.debug("GetParameterDisplay for {}", .{index});
if (Plugin.fromEffect(effect)) |plugin| {
var out: [api.ParamMaxLength]u8 = undefined;
const str = plugin.params.displayByIndex(@intCast(usize, index), &out) orelse "Unknown";
_ = setData(u8, ptr.?, str, out.len);
} else {
_ = setData(u8, ptr.?, "Unknown", api.ParamMaxLength);
}
},
.GetParameterName => {
if (shared.Parameters.getDescription(@intCast(usize, index))) |desc| {
_ = setData(u8, ptr.?, desc.name, api.ParamMaxLength);
} else {
_ = setData(u8, ptr.?, "Unknown", api.ParamMaxLength);
}
},
.GetParameterLabel => {
if (shared.Parameters.getDescription(@intCast(usize, index))) |desc| {
_ = setData(u8, ptr.?, desc.label, api.ParamMaxLength);
} else {
_ = setData(u8, ptr.?, "Unknown", api.ParamMaxLength);
}
},
.CanBeAutomated => {
const desc = shared.Parameters.getDescription(@intCast(usize, index)) orelse return 0;
return if (desc.automatable) 1 else 0;
},
.EditorKeyDown, .EditorKeyUp, .EditorIdle => {},
else => {
const t = std.time.milliTimestamp();
std.log.debug("{d:.} Unhandled opcode: {} {} {} {} {}", .{ t, code, index, value, ptr, opt });
},
}
return 0;
}
fn setParameter(effect: *api.AEffect, index: i32, parameter: f32) callconv(.C) void {
const plugin = Plugin.fromEffect(effect) orelse return;
plugin.params.setByIndex(@intCast(usize, index), parameter);
}
fn getParameter(effect: *api.AEffect, index: i32) callconv(.C) f32 {
const plugin = Plugin.fromEffect(effect) orelse return 0;
return plugin.params.getByIndex(@intCast(usize, index)) orelse 0;
}
fn processReplacing(effect: *api.AEffect, inputs: [*][*]f32, outputs: [*][*]f32, num_frames: i32) callconv(.C) void {
const channels = @intCast(usize, std.math.min(effect.num_inputs, effect.num_outputs));
const frames = @intCast(usize, num_frames);
const plugin = Plugin.fromEffect(effect).?;
var sample_buffer = plugin.sample_buffer.?;
var channel_i: usize = 0;
while (channel_i < channels) : (channel_i += 1) {
const in = inputs[channel_i][0..frames];
var out = outputs[channel_i][0..frames];
for (in) |v, i| {
sample_buffer[i * channels + channel_i] = v;
out[i] = v;
}
}
plugin.renderer.update(sample_buffer);
}
fn processReplacingF64(effect: *api.AEffect, inputs: [*][*]f64, outputs: [*][*]f64, frames: i32) callconv(.C) void {
std.log.warn("processReplacingF64 called", .{});
}
fn setData(comptime T: type, ptr: *c_void, data: []const T, max_length: usize) usize {
const buf_ptr = @ptrCast([*]T, ptr);
const copy_len = std.math.min(max_length - 1, data.len);
@memcpy(buf_ptr, data.ptr, copy_len);
std.mem.set(u8, buf_ptr[copy_len..max_length], 0);
return copy_len;
}
const Plugin = struct {
sample_rate: ?f32 = null,
buffer_size: ?isize = null,
params: shared.Parameters,
editor: @import("./editor.zig"),
sample_buffer: ?[]f32 = null,
renderer: switch (std.Target.current.os.tag) {
.macos => @import("./macos/renderer.zig").Renderer,
.windows => @import("./windows/gl_wrapper.zig").Renderer,
else => @compileError("There's no renderer for the target platform"),
},
fn init(plugin: *Plugin) !void {
plugin.params = shared.Parameters{};
plugin.sample_rate = null;
plugin.buffer_size = null;
plugin.editor = .{
.params = &plugin.params,
};
plugin.renderer = switch (std.Target.current.os.tag) {
.macos => try @import("./macos/renderer.zig").Renderer.init(allocator, plugin.editor.params),
.windows => try @import("./windows/gl_wrapper.zig").Renderer.init(allocator, &plugin.editor),
else => unreachable,
};
}
fn fromEffect(effect: *api.AEffect) ?*Plugin {
const aligned = @alignCast(@alignOf(Plugin), effect.user);
const ptr = @ptrCast(?*Plugin, aligned);
return ptr;
}
};
test {
_ = @import("./util/matrix.zig");
std.testing.refAllDecls(@This());
}
|
src/main.zig
|
const std = @import("std");
const real_input = @embedFile("day-13_real-input");
const test_input = @embedFile("day-13_test-input");
pub fn main() !void {
std.debug.print("--- Day 13 ---\n", .{});
const result = try execute(real_input);
std.debug.print("there are {} visible dots\n", .{ result });
}
fn execute(input: []const u8) !u32 {
var buffer: [1024 * 1024]u8 = undefined;
var alloc = std.heap.FixedBufferAllocator.init(buffer[0..]);
var points = std.ArrayList(Point).init(alloc.allocator());
var folds = std.ArrayList(Fold).init(alloc.allocator());
var max_x: u16 = 0;
var max_y: u16 = 0;
var line_it = std.mem.tokenize(u8, input, "\r\n");
while (line_it.next()) |line| {
if (std.mem.startsWith(u8, line, "fold")) {
var fold_it = std.mem.tokenize(u8, line, " =");
_ = fold_it.next() orelse unreachable; // fold
_ = fold_it.next() orelse unreachable; // along
const direction_string = fold_it.next() orelse unreachable;
const value_string = fold_it.next() orelse unreachable;
try folds.append(.{
.direction = if (direction_string[0] == 'x') .Vertical else .Horizontal,
.value = try std.fmt.parseInt(u16, value_string, 10),
});
}
else if (line.len > 0) {
var coords_it = std.mem.tokenize(u8, line, ",");
const x_string = coords_it.next() orelse unreachable;
const y_string = coords_it.next() orelse unreachable;
const x = try std.fmt.parseInt(u16, x_string, 10);
const y = try std.fmt.parseInt(u16, y_string, 10);
try points.append(.{
.x = x,
.y = y,
});
max_x = @maximum(max_x, x);
max_y = @maximum(max_y, y);
}
}
for (folds.items) |fold| {
var removed_points = std.ArrayList(usize).init(alloc.allocator());
var new_points = std.ArrayList(Point).init(alloc.allocator());
switch (fold.direction) {
.Vertical => {
for (points.items) |point, i| {
if (point.x < fold.value) continue;
const distance = point.x - fold.value;
try new_points.append(.{
.x = fold.value - distance,
.y = point.y,
});
try removed_points.append(i);
}
max_x /= 2;
},
.Horizontal => {
for (points.items) |point, i| {
if (point.y < fold.value) continue;
const distance = point.y - fold.value;
try new_points.append(.{
.x = point.x,
.y = fold.value - distance,
});
try removed_points.append(i);
}
max_y /= 2;
},
}
std.mem.reverse(usize, removed_points.items);
for (removed_points.items) |i| {
_ = points.swapRemove(i);
}
for (new_points.items) |point| {
if (!contains(points.items, point)) {
try points.append(point);
}
}
}
{
var y: u16 = 0;
while (y < max_y):(y += 1) {
var x: u16 = 0;
while (x < max_x):(x += 1) {
const point = Point { .x = x, .y = y };
if (contains(points.items, point)) std.debug.print("#", .{})
else std.debug.print(".", .{});
}
std.debug.print("\n", .{});
}
}
return @intCast(u32, points.items.len);
}
fn addUnique(points: *std.ArrayList(Point), point: Point) !void {
if (contains(points.items, point)) return;
try points.append(point);
}
fn contains(haystack: []Point, needle: Point) bool {
return for (haystack) |point| {
if (point.x == needle.x and point.y == needle.y) break true;
} else false;
}
const Point = struct {
x: u16,
y: u16,
};
const Fold = struct {
direction: enum { Horizontal, Vertical },
value: u16,
};
test "test-input" {
std.debug.print("\n", .{});
const expected: u32 = 16;
const result = try execute(test_input);
try std.testing.expectEqual(expected, result);
}
|
day-13.zig
|
const std = @import("../index.zig");
const crypto = std.crypto;
const debug = std.debug;
const mem = std.mem;
pub const HmacMd5 = Hmac(crypto.Md5);
pub const HmacSha1 = Hmac(crypto.Sha1);
pub const HmacSha256 = Hmac(crypto.Sha256);
pub fn Hmac(comptime H: type) type {
return struct {
const digest_size = H.digest_size;
pub fn hash(output: []u8, key: []const u8, message: []const u8) void {
debug.assert(output.len >= H.digest_size);
debug.assert(H.digest_size <= H.block_size); // HMAC makes this assumption
var scratch: [H.block_size]u8 = undefined;
// Normalize key length to block size of hash
if (key.len > H.block_size) {
H.hash(key, scratch[0..H.digest_size]);
mem.set(u8, scratch[H.digest_size..H.block_size], 0);
} else if (key.len < H.block_size) {
mem.copy(u8, scratch[0..key.len], key);
mem.set(u8, scratch[key.len..H.block_size], 0);
} else {
mem.copy(u8, scratch[0..], key);
}
var o_key_pad: [H.block_size]u8 = undefined;
for (o_key_pad) |*b, i| {
b.* = scratch[i] ^ 0x5c;
}
var i_key_pad: [H.block_size]u8 = undefined;
for (i_key_pad) |*b, i| {
b.* = scratch[i] ^ 0x36;
}
// HMAC(k, m) = H(o_key_pad | H(i_key_pad | message)) where | is concatenation
var hmac = H.init();
hmac.update(i_key_pad[0..]);
hmac.update(message);
hmac.final(scratch[0..H.digest_size]);
hmac.reset();
hmac.update(o_key_pad[0..]);
hmac.update(scratch[0..H.digest_size]);
hmac.final(output[0..H.digest_size]);
}
};
}
const htest = @import("test.zig");
test "hmac md5" {
var out: [crypto.Md5.digest_size]u8 = undefined;
HmacMd5.hash(out[0..], "", "");
htest.assertEqual("74e6f7298a9c2d168935f58c001bad88", out[0..]);
HmacMd5.hash(out[0..], "key", "The quick brown fox jumps over the lazy dog");
htest.assertEqual("80070713463e7749b90c2dc24911e275", out[0..]);
}
test "hmac sha1" {
var out: [crypto.Sha1.digest_size]u8 = undefined;
HmacSha1.hash(out[0..], "", "");
htest.assertEqual("fbdb1d1b18aa6c08324b7d64b71fb76370690e1d", out[0..]);
HmacSha1.hash(out[0..], "key", "The quick brown fox jumps over the lazy dog");
htest.assertEqual("de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9", out[0..]);
}
test "hmac sha256" {
var out: [crypto.Sha256.digest_size]u8 = undefined;
HmacSha256.hash(out[0..], "", "");
htest.assertEqual("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad", out[0..]);
HmacSha256.hash(out[0..], "key", "The quick brown fox jumps over the lazy dog");
htest.assertEqual("f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8", out[0..]);
}
|
std/crypto/hmac.zig
|
const std = @import("std");
const testing = std.testing;
const meta = std.meta;
usingnamespace @import("main.zig");
test "serialization" {
const test_cases = .{
.{
.type = struct { compact: bool, schema: u7 },
.value = .{ .compact = true, .schema = 0 },
.expected = "\x82\xa7\x63\x6f\x6d\x70\x61\x63\x74\xc3\xa6\x73\x63\x68\x65\x6d\x61\x00",
},
.{
.type = []const u8,
.value = "Hello world!",
.expected = "\xac\x48\x65\x6c\x6c\x6f\x20\x77\x6f\x72\x6c\x64\x21",
},
.{
.type = []const []const u8,
.value = &[_][]const u8{ "one", "two", "three" },
.expected = "\x93\xa3\x6f\x6e\x65\xa3\x74\x77\x6f\xa5\x74\x68\x72\x65\x65",
},
.{
.type = ?u32,
.value = null,
.expected = "\xc0",
},
.{
.type = ?u32,
.value = 12389567,
.expected = "\xce\x00\xbd\x0c\xbf",
},
.{
.type = i32,
.value = -12389567,
.expected = "\xd2\xff\x42\xf3\x41",
},
.{
.type = f64,
.value = 1.25,
.expected = "\xcb\x3f\xf4\x00\x00\x00\x00\x00\x00",
},
};
inline for (test_cases) |case| {
var buffer: [4096]u8 = undefined;
var stream = std.io.fixedBufferStream(&buffer);
var _serializer = serializer(stream.writer());
try _serializer.serialize(@as(case.type, case.value));
try testing.expectEqualSlices(u8, case.expected, stream.getWritten());
}
}
test "deserialization" {
const test_cases = .{
.{
.type = []const u8,
.value = "Hello world!",
},
.{
.type = u32,
.value = @as(u32, 21049),
},
.{
.type = i64,
.value = @as(i64, 9223372036854775807),
},
.{
.type = struct { compact: bool, schema: u7 },
.value = .{ .compact = true, .schema = 5 },
},
.{
.type = []const []const u8,
.value = &[_][]const u8{ "one", "two", "three" },
},
.{
.type = [5]u32,
.value = .{ 0, 2, 3, 5, 6 },
},
.{
.type = f32,
.value = 1.25,
},
.{
.type = f64,
.value = 1.5,
},
.{
.type = []const f64,
.value = &[_]f64{ -100.455, 2.0, 3.1415 },
},
};
inline for (test_cases) |case| {
var buffer: [4096]u8 = undefined;
var out = std.io.fixedBufferStream(&buffer);
var _serializer = serializer(out.writer());
try _serializer.serialize(@as(case.type, case.value));
var in = std.io.fixedBufferStream(&buffer);
var _deserializer = deserializer(in.reader(), 4096);
const result = try _deserializer.deserialize(case.type);
switch (case.type) {
[]const u8 => try testing.expectEqualStrings(case.value, result),
[]u8 => try testing.expectEqualSlices(u8, case.value, result),
[]const f64 => try testing.expectEqualSlices(f64, case.value, result),
else => switch (@typeInfo(case.type)) {
.Pointer => |info| switch (info.size) {
.Slice => for (case.value) |val, j| {
try testing.expectEqualSlices(meta.Child(info.child), val, result[j]);
},
else => @panic("TODO: Testing for Pointer types"),
},
else => try testing.expectEqual(@as(case.type, case.value), result),
},
}
}
}
test "(de)serialize timestamp" {
var buffer: [4096]u8 = undefined;
var out = std.io.fixedBufferStream(&buffer);
var _serializer = serializer(out.writer());
var in = std.io.fixedBufferStream(&buffer);
var _deserializer = deserializer(in.reader(), 4096);
const timestamp = Timestamp{ .sec = 50, .nsec = 200 };
try _serializer.serializeTimestamp(timestamp);
const result = try _deserializer.deserializeTimestamp();
try testing.expectEqual(timestamp, result);
}
test "(de)serialize ext format" {
var buffer: [4096]u8 = undefined;
var out = std.io.fixedBufferStream(&buffer);
var _serializer = serializer(out.writer());
var in = std.io.fixedBufferStream(&buffer);
var _deserializer = deserializer(in.reader(), 4096);
try _serializer.serializeExt(2, "Hello world!");
var type_result: i8 = undefined;
const result = try _deserializer.deserializeExt(&type_result);
try testing.expectEqual(@as(i8, 2), type_result);
try testing.expectEqualStrings("Hello world!", result);
}
pub const Decl = struct {
x: u32,
y: u32,
pub fn serialize(self: Decl, _serializer: anytype) !void {
var data: [8]u8 = undefined;
std.mem.writeIntBig(u32, data[0..4], self.x);
std.mem.writeIntBig(u32, data[4..8], self.y);
try _serializer.serializeArray([8]u8, data);
}
pub fn deserialize(self: *Decl, _deserializer: anytype) !void {
const data = try _deserializer.deserializeArray([8]u8);
self.* = .{
.x = std.mem.readIntBig(u32, data[0..4]),
.y = std.mem.readIntBig(u32, data[4..8]),
};
}
};
test "(de)serialize with custom declaration" {
var buffer: [4096]u8 = undefined;
var out = std.io.fixedBufferStream(&buffer);
var _serializer = serializer(out.writer());
var in = std.io.fixedBufferStream(&buffer);
var _deserializer = deserializer(in.reader(), 4096);
var decl = Decl{ .x = 10, .y = 50 };
try _serializer.serialize(decl);
const result = try _deserializer.deserialize(Decl);
try testing.expectEqual(decl, result);
}
|
src/tests.zig
|
const std = @import("std");
const warn = std.debug.warn;
const mem = std.mem;
const fmt = std.fmt;
const ascii = std.ascii;
const testing = std.testing;
const print = std.debug.print;
const expect = testing.expect;
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const xml = @import("xml");
const datetime = @import("datetime").datetime;
const Datetime = datetime.Datetime;
const timezones = @import("datetime").timezones;
const l = std.log;
const expectEqualStrings = std.testing.expectEqualStrings;
const max_title_len = 50;
pub const Html = struct {
pub const Page = struct {
title: ?[]const u8 = null,
links: []Link,
};
pub const Link = struct {
href: []const u8,
media_type: MediaType = .unknown,
title: ?[]const u8 = null,
};
const Tag = enum {
none,
title,
link_or_a,
};
pub const MediaType = enum {
atom,
rss,
unknown,
pub fn toString(media_type: MediaType) []const u8 {
return switch (media_type) {
.atom => "Atom",
.rss => "RSS",
.unknown => "Unknown",
};
}
pub fn toMimetype(media_type: MediaType) []const u8 {
return switch (media_type) {
.atom => "application/atom+xml",
.rss => "application/rss+xml",
.unknown => "Unknown",
};
}
};
pub fn mediaTypeToString(mt: MediaType) []const u8 {
var name = @tagName(mt);
return name;
}
pub fn parseLinks(allocator: Allocator, contents_const: []const u8) !Page {
var contents = contents_const;
var links = ArrayList(Link).init(allocator);
defer links.deinit();
var page_title: ?[]const u8 = null;
const title_elem = "<title>";
if (ascii.indexOfIgnoreCase(contents, title_elem)) |index| {
const start = index + title_elem.len;
if (ascii.indexOfIgnoreCase(contents[start..], "</title>")) |end| {
page_title = contents[start .. start + end];
}
}
var link_rel: ?[]const u8 = null;
var link_type: ?[]const u8 = null;
var link_title: ?[]const u8 = null;
var link_href: ?[]const u8 = null;
const link_elem = "<link ";
const a_elem = "<a ";
while (ascii.indexOfIgnoreCase(contents, link_elem) orelse
ascii.indexOfIgnoreCase(contents, a_elem)) |index|
{
var key: []const u8 = "";
var value: []const u8 = "";
contents = contents[index..];
const start = blk: {
if (ascii.startsWithIgnoreCase(contents, a_elem)) {
break :blk a_elem.len;
}
break :blk link_elem.len;
};
contents = contents[start..];
while (true) {
// skip whitespace
contents = mem.trimLeft(u8, contents, &ascii.spaces);
if (contents[0] == '>') {
contents = contents[1..];
break;
} else if (contents[0] == '/') {
contents = mem.trimLeft(u8, contents[1..], &ascii.spaces);
if (contents[0] == '>') {
contents = contents[1..];
break;
}
} else if (contents.len == 0) {
break;
}
const next_eql = mem.indexOfScalar(u8, contents, '=') orelse contents.len;
const next_space = mem.indexOfAny(u8, contents, &ascii.spaces) orelse contents.len;
const next_slash = mem.indexOfScalar(u8, contents, '/') orelse contents.len;
const next_gt = mem.indexOfScalar(u8, contents, '>') orelse contents.len;
const end = blk: {
var smallest = next_space;
if (next_slash < smallest) {
smallest = next_slash;
}
if (next_gt < smallest) {
smallest = next_gt;
}
break :blk smallest;
};
if (next_eql < end) {
key = contents[0..next_eql];
contents = contents[next_eql + 1 ..];
switch (contents[0]) {
'"', '\'' => |char| {
contents = contents[1..];
const value_end = mem.indexOfScalar(u8, contents, char) orelse break;
value = contents[0..value_end];
contents = contents[value_end + 1 ..];
},
else => {
value = contents[0..end];
contents = contents[end + 1 ..];
},
}
} else {
contents = contents[end + 1 ..];
continue;
}
if (mem.eql(u8, "rel", key)) {
link_rel = value;
} else if (mem.eql(u8, "type", key)) {
link_type = value;
} else if (mem.eql(u8, "title", key)) {
link_title = value;
} else if (mem.eql(u8, "href", key)) {
link_href = value;
}
}
// Check for duplicate links
const has_link = blk: {
if (link_href) |href| {
for (links.items) |link| {
if (mem.eql(u8, link.href, href) and
link.media_type != .unknown and
link_type != null and
mem.eql(u8, link.media_type.toMimetype(), link_type.?))
{
break :blk true;
}
}
}
break :blk false;
};
if (!has_link) {
if (makeLink(link_rel, link_type, link_href, link_title)) |link| {
try links.append(link);
}
}
link_rel = null;
link_type = null;
link_title = null;
link_href = null;
}
return Page{
.title = page_title,
.links = links.toOwnedSlice(),
};
}
fn makeLink(
rel: ?[]const u8,
type_: ?[]const u8,
href: ?[]const u8,
title: ?[]const u8,
) ?Link {
const valid_rel = rel != null and mem.eql(u8, "alternate", rel.?);
const valid_type = type_ != null;
if (valid_rel and valid_type) {
if (href) |link_href| {
const media_type = blk: {
if (mem.eql(u8, "application/rss+xml", type_.?)) {
break :blk MediaType.rss;
} else if (mem.eql(u8, "application/atom+xml", type_.?)) {
break :blk MediaType.atom;
}
break :blk MediaType.unknown;
};
return Link{
.href = link_href,
.title = title,
.media_type = media_type,
};
}
}
return null;
}
};
test "Html.parse" {
const expectEqual = std.testing.expectEqual;
var arena = std.heap.ArenaAllocator.init(testing.allocator);
defer arena.deinit();
const allocator = arena.allocator();
{
// Test duplicate link
const html = @embedFile("../test/many-links.html");
const page = try Html.parseLinks(allocator, html);
try expectEqual(@as(usize, 5), page.links.len);
try expectEqual(Html.MediaType.rss, page.links[0].media_type);
try expectEqual(Html.MediaType.unknown, page.links[1].media_type);
try expectEqual(Html.MediaType.atom, page.links[2].media_type);
}
}
// TODO?: add field interval (ttl/)
// <sy:updatePeriod>hourly</sy:updatePeriod>
// <sy:updateFrequency>1</sy:updateFrequency>
// has something to do with attributes in xml element
// xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
pub const Feed = struct {
const Self = @This();
// Atom: title (required)
// Rss: title (required)
title: []const u8,
// Atom: updated (required)
// Rss: pubDate (optional)
updated_raw: ?[]const u8 = null,
updated_timestamp: ?i64 = null,
// Atom: optional
// Rss: required
link: ?[]const u8 = null,
items: []Item = &[_]Item{},
pub const Item = struct {
// Atom: title (required)
// Rss: title or description (requires one of these)
title: []const u8,
// Atom: id (required). Has to be URI.
// Rss: guid (optional) or link (optional)
id: ?[]const u8 = null,
// In atom id (required) can also be link.
// Check if id is link before outputing some data
// Atom: link (optional),
// Rss: link (optional)
link: ?[]const u8 = null,
// Atom: updated (required) or published (optional)
// Rss: pubDate (optional)
updated_raw: ?[]const u8 = null,
updated_timestamp: ?i64 = null,
};
pub fn sortItemsByDate(items: []Item) void {
std.sort.insertionSort(Item, items, {}, compareItemDate);
}
const cmp = std.sort.asc(i64);
fn compareItemDate(context: void, a: Item, b: Item) bool {
const a_timestamp = a.updated_timestamp orelse return true;
const b_timestamp = b.updated_timestamp orelse return false;
return cmp(context, a_timestamp, b_timestamp);
}
pub fn getItemsWithNullDates(feed: *Self) []Item {
for (feed.items) |it, i| {
if (it.updated_timestamp != null) return feed.items[0..i];
}
return feed.items;
}
pub fn getItemsWithDates(feed: *Self, latest_date: i64) []Item {
const start = feed.getItemsWithNullDates().len;
const items = feed.items[start..];
assert(items[0].updated_timestamp != null);
for (items) |it, i| {
if (it.updated_timestamp.? > latest_date) return items[i..];
}
return items[items.len..];
}
};
pub fn printFeedItems(items: []Feed.Item) void {
for (items) |item| {
print(" title: {s}\n", .{item.title});
if (item.id) |val| print(" id: {s}\n", .{val});
if (item.link) |val| print(" link: {s}\n", .{val});
if (item.updated_raw) |val| print(" updated_raw: {s}\n", .{val});
if (item.updated_timestamp) |val| print(" updated_timestamp: {d}\n", .{val});
print("\n", .{});
}
}
pub fn printFeed(feed: Feed) void {
print("title: {s}\n", .{feed.title});
if (feed.id) |id| print("id: {s}\n", .{id});
if (feed.updated_raw) |val| print("updated_raw: {s}\n", .{val});
if (feed.updated_timestamp) |val| print("updated_timestamp: {d}\n", .{val});
if (feed.link) |val| print("link: {s}\n", .{val});
print("items [{d}]:\n", .{feed.items.len});
printFeedItems(feed.items);
print("\n", .{});
}
pub const Atom = struct {
const State = enum {
feed,
entry,
};
const Field = enum {
title,
link,
id,
updated,
published,
ignore,
};
// Atom feed parsing:
// https://tools.ietf.org/html/rfc4287
// https://validator.w3.org/feed/docs/atom.html
pub fn parse(arena: *std.heap.ArenaAllocator, contents: []const u8) !Feed {
var entries = try ArrayList(Feed.Item).initCapacity(arena.allocator(), 10);
defer entries.deinit();
var state: State = .feed;
var field: Field = .ignore;
var feed_title: ?[]const u8 = null;
var feed_date_raw: ?[]const u8 = null;
var feed_link: ?[]const u8 = null;
var feed_link_rel: []const u8 = "alternate";
var feed_link_href: ?[]const u8 = null;
var title: ?[]const u8 = null;
var id: ?[]const u8 = null;
var updated_raw: ?[]const u8 = null;
var published_raw: ?[]const u8 = null;
var link_rel: []const u8 = "alternate";
var link_href: ?[]const u8 = null;
var xml_parser = xml.Parser.init(contents);
while (xml_parser.next()) |event| {
switch (event) {
.open_tag => |tag| {
// warn("open_tag: {s}\n", .{tag});
if (mem.eql(u8, "entry", tag)) {
state = .entry;
link_rel = "alternate";
link_href = null;
title = null;
id = null;
updated_raw = null;
} else if (mem.eql(u8, "link", tag)) {
field = .link;
} else if (mem.eql(u8, "id", tag)) {
field = .id;
} else if (mem.eql(u8, "updated", tag)) {
field = .updated;
} else if (mem.eql(u8, "title", tag)) {
field = .title;
}
},
.close_tag => |tag| {
// warn("close_tag: {s}\n", .{tag});
switch (state) {
.feed => {
if (field == .link and mem.eql(u8, "self", feed_link_rel)) {
feed_link = feed_link_href;
}
},
.entry => {
if (mem.eql(u8, "entry", tag)) {
const published_timestamp = blk: {
if (published_raw) |date| {
const date_utc = try parseDateToUtc(date);
break :blk @floatToInt(i64, date_utc.toSeconds());
}
if (updated_raw) |date| {
const date_utc = try parseDateToUtc(date);
break :blk @floatToInt(i64, date_utc.toSeconds());
}
break :blk null;
};
const entry = Feed.Item{
.title = title orelse return error.InvalidAtomFeed,
.id = id,
.link = link_href,
.updated_raw = published_raw orelse updated_raw,
.updated_timestamp = published_timestamp,
};
try entries.append(entry);
state = .feed;
}
},
}
field = .ignore;
},
.attribute => |attr| {
// warn("attribute\n", .{});
// warn("\tname: {s}\n", .{attr.name});
// warn("\traw_value: {s}\n", .{attr.raw_value});
switch (state) {
.feed => {
if (mem.eql(u8, "rel", attr.name)) {
feed_link_rel = attr.raw_value;
} else if (mem.eql(u8, "href", attr.name)) {
feed_link_href = attr.raw_value;
}
},
.entry => {
if (mem.eql(u8, "rel", attr.name)) {
link_rel = attr.raw_value;
} else if (mem.eql(u8, "href", attr.name)) {
link_href = attr.raw_value;
}
},
}
},
.comment => |_| {
// warn("comment: {s}\n", .{str});
},
.processing_instruction => |_| {
// warn("processing_instruction: {s}\n", .{str});
},
.character_data => |value| {
// warn("character_data: {s}\n", .{value});
switch (state) {
.feed => {
switch (field) {
.title => {
feed_title = xmlCharacterData(&xml_parser, contents, value, "title");
field = .ignore;
},
.updated => {
feed_date_raw = value;
},
.ignore, .link, .published, .id => {},
}
},
.entry => {
switch (field) {
.id => {
id = value;
},
.title => {
title = xmlCharacterData(&xml_parser, contents, value, "title");
field = .ignore;
},
.updated => {
updated_raw = value;
},
.published => {
published_raw = value;
},
.ignore, .link => {},
}
},
}
},
}
}
var updated_timestamp: ?i64 = null;
if (feed_date_raw) |date| {
const date_utc = try parseDateToUtc(date);
updated_timestamp = @floatToInt(i64, date_utc.toSeconds());
} else if (entries.items.len > 0 and entries.items[0].updated_raw != null) {
var tmp_timestamp: i64 = entries.items[0].updated_timestamp.?;
for (entries.items[1..]) |item| {
if (item.updated_timestamp != null and
item.updated_timestamp.? > tmp_timestamp)
{
feed_date_raw = item.updated_raw;
updated_timestamp = item.updated_timestamp;
}
}
}
var result = Feed{
.title = feed_title orelse return error.InvalidAtomFeed,
.link = feed_link,
.updated_raw = feed_date_raw,
.updated_timestamp = updated_timestamp,
.items = entries.toOwnedSlice(),
};
return result;
}
fn xmlCharacterData(
xml_parser: *xml.Parser,
contents: []const u8,
start_value: []const u8,
close_tag: []const u8,
) []const u8 {
var end_value = start_value;
while (xml_parser.next()) |item_event| {
switch (item_event) {
.close_tag => |tag| if (mem.eql(u8, close_tag, tag)) break,
.character_data => |title_value| end_value = title_value,
else => std.debug.panic("Xml(Atom): Failed to parse {s}'s value\n", .{close_tag}),
}
}
if (start_value.ptr == end_value.ptr) return start_value;
const content_ptr = @ptrToInt(contents.ptr);
const start_index = @ptrToInt(start_value.ptr) - content_ptr;
const end_index = @ptrToInt(end_value.ptr) + end_value.len - content_ptr;
return contents[start_index..end_index];
}
// Atom updated_timestamp: http://www.faqs.org/rfcs/rfc3339.html
pub fn parseDateToUtc(raw: []const u8) !Datetime {
const date_raw = "2003-12-13T18:30:02Z";
const year = try fmt.parseUnsigned(u32, raw[0..4], 10);
const month = try fmt.parseUnsigned(u32, raw[5..7], 10);
const day = try fmt.parseUnsigned(u32, raw[8..10], 10);
assert(date_raw[10] == 'T');
const hour = try fmt.parseUnsigned(u32, raw[11..13], 10);
const minute = try fmt.parseUnsigned(u32, raw[14..16], 10);
const second = try fmt.parseUnsigned(u32, raw[17..19], 10);
const zone_start = mem.lastIndexOfAny(u8, raw, "Z+-") orelse return error.InvalidAtomDate;
const nano_sec: u32 = blk: {
if (zone_start == 19) {
break :blk 0;
}
const ms_raw = raw[20..zone_start];
var ms = try fmt.parseUnsigned(u32, ms_raw, 10);
if (ms_raw.len == 1) {
ms *= 100;
} else if (ms_raw.len == 2) {
ms *= 10;
}
break :blk ms * std.time.ns_per_ms;
};
var result = try Datetime.create(year, month, day, hour, minute, second, nano_sec, null);
if (raw[zone_start] != 'Z') {
const tz = raw[zone_start + 1 ..];
const tz_hour = try fmt.parseUnsigned(u16, tz[0..2], 10);
const tz_minute = try fmt.parseUnsigned(u16, tz[3..5], 10);
var total_minutes: i32 = (tz_hour * 60) + tz_minute;
const sym = raw[zone_start];
if (sym == '+') {
total_minutes *= -1;
}
result = result.shiftMinutes(total_minutes);
}
return result;
}
};
test "Atom.parse" {
l.warn("\n", .{});
var arena = std.heap.ArenaAllocator.init(testing.allocator);
defer arena.deinit();
const contents = @embedFile("../test/atom.xml");
const result = try Atom.parse(&arena, contents);
try testing.expectEqualStrings("Example Feed", result.title);
try testing.expectEqualStrings("http://example.org/feed/", result.link.?);
try testing.expectEqualStrings("2012-12-13T18:30:02Z", result.updated_raw.?);
try expect(1355423402 == result.updated_timestamp.?);
try expect(null != result.items[0].updated_raw);
try expect(2 == result.items.len);
{
const item = result.items[0];
try testing.expectEqualStrings("Atom-Powered Robots Run Amok", item.title);
try testing.expectEqualStrings("http://example.org/2003/12/13/atom03", item.link.?);
try testing.expectEqualStrings("2008-11-13T18:30:02Z", item.updated_raw.?);
}
{
const item = result.items[1];
try testing.expectEqualStrings("Entry one's 1", item.title);
try testing.expectEqualStrings("http://example.org/2008/12/13/entry-1", item.link.?);
try testing.expectEqualStrings("2005-12-13T18:30:02Z", item.updated_raw.?);
}
}
test "Atom.parseDateToUtc" {
l.warn("\n", .{});
{
const date_raw = "2003-12-13T18:30:02Z";
const dt = try Atom.parseDateToUtc(date_raw);
try expect(2003 == dt.date.year);
try expect(12 == dt.date.month);
try expect(13 == dt.date.day);
try expect(18 == dt.time.hour);
try expect(30 == dt.time.minute);
try expect(02 == dt.time.second);
try expect(0 == dt.time.nanosecond);
try expect(0 == dt.zone.offset);
}
{
const date_raw = "2003-12-13T18:30:02.25Z";
const dt = try Atom.parseDateToUtc(date_raw);
try expect(2003 == dt.date.year);
try expect(12 == dt.date.month);
try expect(13 == dt.date.day);
try expect(18 == dt.time.hour);
try expect(30 == dt.time.minute);
try expect(02 == dt.time.second);
try expect(250000000 == dt.time.nanosecond);
try expect(0 == dt.zone.offset);
}
{
const date_raw = "2003-12-13T18:30:02+01:00";
const dt = try Atom.parseDateToUtc(date_raw);
try expect(2003 == dt.date.year);
try expect(12 == dt.date.month);
try expect(13 == dt.date.day);
try expect(17 == dt.time.hour);
try expect(30 == dt.time.minute);
try expect(02 == dt.time.second);
try expect(0 == dt.time.nanosecond);
try expect(0 == dt.zone.offset);
}
{
const date_raw = "2003-12-13T18:30:02.25+01:00";
const dt = try Atom.parseDateToUtc(date_raw);
try expect(2003 == dt.date.year);
try expect(12 == dt.date.month);
try expect(13 == dt.date.day);
try expect(17 == dt.time.hour);
try expect(30 == dt.time.minute);
try expect(02 == dt.time.second);
try expect(250000000 == dt.time.nanosecond);
try expect(0 == dt.zone.offset);
}
}
pub const Rss = struct {
const State = enum {
channel,
item,
};
const ChannelField = enum {
title,
link,
pub_date,
last_build_date,
ttl,
_ignore,
};
const ItemField = enum {
title,
description,
link,
pub_date,
guid,
_ignore,
};
pub fn parse(arena: *std.heap.ArenaAllocator, contents: []const u8) !Feed {
var items = try ArrayList(Feed.Item).initCapacity(arena.allocator(), 10);
defer items.deinit();
var state: State = .channel;
var channel_field: ChannelField = ._ignore;
var item_field: ItemField = ._ignore;
var item_title: ?[]const u8 = null;
var item_description: ?[]const u8 = null;
var item_link: ?[]const u8 = null;
var item_guid: ?[]const u8 = null;
var item_pub_date: ?[]const u8 = null;
var feed_title: ?[]const u8 = null;
var feed_link: ?[]const u8 = null;
var feed_pub_date: ?[]const u8 = null;
var feed_build_date: ?[]const u8 = null;
var feed_ttl: ?u32 = null;
var xml_parser = xml.Parser.init(contents);
while (xml_parser.next()) |event| {
switch (event) {
.open_tag => |tag| {
// warn("open_tag: {s}\n", .{tag});
switch (state) {
.channel => {
if (mem.eql(u8, "title", tag)) {
channel_field = .title;
} else if (mem.eql(u8, "link", tag)) {
channel_field = .link;
} else if (mem.eql(u8, "pubDate", tag)) {
channel_field = .pub_date;
} else if (mem.eql(u8, "lastBuildDate", tag)) {
channel_field = .last_build_date;
} else if (mem.eql(u8, "ttl", tag)) {
channel_field = .ttl;
} else if (mem.eql(u8, "item", tag)) {
state = .item;
item_title = null;
item_description = null;
item_guid = null;
item_link = null;
item_pub_date = null;
} else {
channel_field = ._ignore;
}
},
.item => {
if (mem.eql(u8, "title", tag)) {
item_field = .title;
} else if (mem.eql(u8, "link", tag)) {
item_field = .link;
} else if (mem.eql(u8, "pubDate", tag)) {
item_field = .pub_date;
} else if (mem.eql(u8, "description", tag)) {
item_field = .description;
} else if (mem.eql(u8, "guid", tag)) {
item_field = .guid;
} else {
item_field = ._ignore;
}
},
}
},
.close_tag => |tag| {
// warn("close_tag: {s}\n", .{str});
if (mem.eql(u8, "item", tag)) {
const updated_timestamp = blk: {
if (item_pub_date) |date| {
const date_utc = try parseDateToUtc(date);
break :blk @floatToInt(i64, date_utc.toSeconds());
}
break :blk null;
};
const item = Feed.Item{
.title = item_title orelse item_description orelse return error.InvalidRssFeed,
.id = item_guid,
.link = item_link,
.updated_raw = item_pub_date,
.updated_timestamp = updated_timestamp,
};
try items.append(item);
state = .channel;
}
},
.attribute => |_| {
// warn("attribute\n", .{});
// warn("\tname: {s}\n", .{attr.name});
// warn("\traw_value: {s}\n", .{attr.raw_value});
},
.comment => |_| {
// warn("comment: {s}\n", .{str});
},
.processing_instruction => |_| {
// warn("processing_instruction: {s}\n", .{str});
},
.character_data => |value| {
// warn("character_data: {s}\n", .{value});
switch (state) {
.channel => {
switch (channel_field) {
.title => {
feed_title = xmlCharacterData(&xml_parser, contents, value, "title");
channel_field = ._ignore;
},
.link => {
feed_link = value;
},
.pub_date => {
feed_pub_date = value;
},
.last_build_date => {
feed_build_date = value;
},
.ttl => {
feed_ttl = try std.fmt.parseInt(u32, value, 10);
},
._ignore => {},
}
},
.item => {
switch (item_field) {
.title => {
item_title = xmlCharacterData(&xml_parser, contents, value, "title");
item_field = ._ignore;
},
.link => {
item_link = value;
},
.pub_date => {
item_pub_date = value;
},
.guid => {
item_guid = value;
},
.description => {
item_description = xmlCharacterData(&xml_parser, contents, value, "description");
const len = std.math.min(item_description.?.len, max_title_len);
item_description = item_description.?[0..len];
},
._ignore => {},
}
},
}
},
}
}
var date_raw = feed_pub_date orelse feed_build_date;
var updated_timestamp: ?i64 = null;
if (date_raw) |date| {
const date_utc = try parseDateToUtc(date);
updated_timestamp = @floatToInt(i64, date_utc.toSeconds());
} else if (items.items.len > 0 and items.items[0].updated_raw != null) {
var tmp_timestamp: i64 = items.items[0].updated_timestamp.?;
for (items.items[1..]) |item| {
if (item.updated_timestamp != null and
item.updated_timestamp.? > tmp_timestamp)
{
date_raw = item.updated_raw;
updated_timestamp = item.updated_timestamp;
}
}
}
const result = Feed{
.title = feed_title orelse return error.InvalidRssFeed,
.link = feed_link,
.updated_raw = date_raw,
.items = items.toOwnedSlice(),
.updated_timestamp = updated_timestamp,
};
return result;
}
fn xmlCharacterData(
xml_parser: *xml.Parser,
contents: []const u8,
start_value: []const u8,
close_tag: []const u8,
) []const u8 {
var end_value = start_value;
while (xml_parser.next()) |item_event| {
switch (item_event) {
.close_tag => |tag| if (mem.eql(u8, close_tag, tag)) break,
.character_data => |title_value| end_value = title_value,
else => std.debug.panic("Xml(RSS): Failed to parse {s}'s value\n", .{close_tag}),
}
}
if (start_value.ptr == end_value.ptr) return start_value;
const content_ptr = @ptrToInt(contents.ptr);
const start_index = @ptrToInt(start_value.ptr) - content_ptr;
const end_index = @ptrToInt(end_value.ptr) + end_value.len - content_ptr;
return contents[start_index..end_index];
}
pub fn pubDateToTimestamp(str: []const u8) !i64 {
const dt = try Rss.parseDateToUtc(str);
const date_time_gmt = dt.shiftTimezone(&timezones.GMT);
return @intCast(i64, date_time_gmt.toTimestamp());
}
// Isn't the same as Datetime.parseModifiedSince(). In HTTP header timezone is always GMT.
// In Rss spec timezones might not be GMT.
pub fn parseDateToUtc(str: []const u8) !Datetime {
var iter = mem.split(u8, str, " ");
// Skip: don't care about day of week
_ = iter.next();
// Day of month
const day_str = iter.next() orelse return error.InvalidPubDate;
const day = try fmt.parseInt(u8, day_str, 10);
// month
const month_str = iter.next() orelse return error.InvalidPubDate;
const month = @enumToInt(try datetime.Month.parseAbbr(month_str));
// year
// year can also be 2 digits
const year_str = iter.next() orelse return error.InvalidPubDate;
const year = blk: {
const y = try fmt.parseInt(u16, year_str, 10);
if (y < 100) {
// If year is 2 numbers long
const last_two_digits = datetime.Date.now().year - 2000;
if (y <= last_two_digits) {
break :blk 2000 + y;
}
break :blk 1900 + y;
}
break :blk y;
};
// time
const time_str = iter.next() orelse return error.InvalidPubDate;
var time_iter = mem.split(u8, time_str, ":");
// time: hour
const hour_str = time_iter.next() orelse return error.InvalidPubDate;
const hour = try fmt.parseInt(u8, hour_str, 10);
// time: minute
const minute_str = time_iter.next() orelse return error.InvalidPubDate;
const minute = try fmt.parseInt(u8, minute_str, 10);
// time: second
const second_str = time_iter.next() orelse return error.InvalidPubDate;
const second = try fmt.parseInt(u8, second_str, 10);
// Timezone default to UTC
var result = try Datetime.create(year, month, day, hour, minute, second, 0, null);
// timezone
// NOTE: dates with timezone format +/-NNNN will be turned into UTC
const tz_str = iter.next() orelse return error.InvalidPubDate;
if (tz_str[0] == '+' or tz_str[0] == '-') {
const tz_hours = try fmt.parseInt(i16, tz_str[1..3], 10);
const tz_minutes = try fmt.parseInt(i16, tz_str[3..5], 10);
var total_minutes = (tz_hours * 60) + tz_minutes;
if (tz_str[0] == '-') {
total_minutes = -total_minutes;
}
result = result.shiftMinutes(-total_minutes);
} else {
result.zone = stringToTimezone(tz_str);
}
return result;
}
pub fn stringToTimezone(str: []const u8) *const datetime.Timezone {
// This default case covers UT, GMT and Z timezone values.
if (mem.eql(u8, "EST", str)) {
return &timezones.EST;
} else if (mem.eql(u8, "EDT", str)) {
return &timezones.America.Anguilla;
} else if (mem.eql(u8, "CST", str)) {
return &timezones.CST6CDT;
} else if (mem.eql(u8, "CDT", str)) {
return &timezones.US.Eastern;
} else if (mem.eql(u8, "MST", str)) {
return &timezones.MST;
} else if (mem.eql(u8, "MDT", str)) {
return &timezones.US.Central;
} else if (mem.eql(u8, "PST", str)) {
return &timezones.PST8PDT;
} else if (mem.eql(u8, "PDT", str)) {
return &timezones.US.Mountain;
} else if (mem.eql(u8, "A", str)) {
return &timezones.Atlantic.Cape_Verde;
} else if (mem.eql(u8, "M", str)) {
return &timezones.Etc.GMTp12;
} else if (mem.eql(u8, "N", str)) {
return &timezones.CET;
} else if (mem.eql(u8, "Y", str)) {
return &timezones.NZ;
}
return &timezones.UTC;
}
};
test "Rss.parse" {
var arena = std.heap.ArenaAllocator.init(testing.allocator);
defer arena.deinit();
const contents = @embedFile("../test/rss2.xml");
var feed = try Rss.parse(&arena, contents);
try std.testing.expectEqualStrings("Liftoff News", feed.title);
try std.testing.expectEqualStrings("http://liftoff.msfc.nasa.gov/", feed.link.?);
try std.testing.expectEqualStrings("Tue, 10 Jun 2003 04:00:00 +0100", feed.updated_raw.?);
try expect(1055214000 == feed.updated_timestamp.?);
try expect(6 == feed.items.len);
// Description is used as title
try expect(null != feed.items[0].updated_raw);
try std.testing.expectEqualStrings("Sky watchers in Europe, Asia, and parts of Alaska ", feed.items[1].title);
Feed.sortItemsByDate(feed.items);
const items_with_null_dates = feed.getItemsWithNullDates();
// const start = feed.getNonNullFeedItemStart();
try expect(items_with_null_dates.len == 2);
const items_with_dates = feed.items[items_with_null_dates.len..];
try expect(items_with_dates.len == 4);
{
const latest_timestamp = items_with_dates[0].updated_timestamp.? - 1;
const items_new = feed.getItemsWithDates(latest_timestamp);
try expect(items_new.len == 4);
}
{
const latest_timestamp = items_with_dates[2].updated_timestamp.?;
const items_new = feed.getItemsWithDates(latest_timestamp);
try expect(items_new.len == 1);
}
{
const latest_timestamp = items_with_dates[3].updated_timestamp.? + 1;
const items_new = feed.getItemsWithDates(latest_timestamp);
try expect(items_new.len == 0);
}
}
test "Rss.parseDateToUtc" {
{
const date_str = "Tue, 03 Jun 2003 09:39:21 GMT";
const date = try Rss.parseDateToUtc(date_str);
try expect(2003 == date.date.year);
try expect(6 == date.date.month);
try expect(3 == date.date.day);
try expect(9 == date.time.hour);
try expect(39 == date.time.minute);
try expect(21 == date.time.second);
try expect(date.zone.offset == 0);
}
{
// dates with timezone format +/-NNNN will be turned into UTC
const date_str = "Wed, 01 Oct 2002 01:00:00 +0200";
const date = try Rss.parseDateToUtc(date_str);
try expect(2002 == date.date.year);
try expect(9 == date.date.month);
try expect(30 == date.date.day);
try expect(23 == date.time.hour);
try expect(0 == date.time.minute);
try expect(0 == date.time.second);
try expect(date.zone.offset == 0);
}
{
// dates with timezone format +/-NNNN will be turned into UTC
const date_str = "Wed, 01 Oct 2002 01:00:00 -0200";
const date = try Rss.parseDateToUtc(date_str);
try expect(2002 == date.date.year);
try expect(10 == date.date.month);
try expect(1 == date.date.day);
try expect(3 == date.time.hour);
try expect(0 == date.time.minute);
try expect(0 == date.time.second);
try expect(date.zone.offset == 0);
}
}
// Json Feed
// https://www.jsonfeed.org/version/1.1/
pub const Json = struct {
const json = std.json;
const JsonFeed = struct {
version: []const u8, // required
title: []const u8,
home_page_url: ?[]const u8 = null, // optional
items: []Item,
const Item = struct {
id: []const u8, // required, can be url
// If there is no title slice a title from content_text or content_html.
// Item has to have content_text or content_html field
title: ?[]const u8 = null, // optional
content_text: ?[]const u8 = null, // optional
content_html: ?[]const u8 = null, // optional
url: ?[]const u8 = null,
date_published: ?[]const u8 = null,
date_modified: ?[]const u8 = null,
};
};
pub fn parse(arena: *std.heap.ArenaAllocator, contents: []const u8) !Feed {
const options = .{ .ignore_unknown_fields = true, .allocator = arena.allocator() };
var stream = json.TokenStream.init(contents);
const json_feed = json.parse(JsonFeed, &stream, options) catch |err| {
switch (err) {
error.MissingField => l.err("Failed to parse Json. Missing a required field.", .{}),
else => l.err("Failed to parse Json.", .{}),
}
return error.JsonFeedParsingFailed;
};
errdefer json.parseFree(JsonFeed, json_feed, options);
if (!ascii.startsWithIgnoreCase(json_feed.version, "https://jsonfeed.org/version/1")) {
l.err("Json contains invalid version field value: '{s}'", .{json_feed.version});
return error.JsonFeedInvalidVersion;
}
var new_items = try ArrayList(Feed.Item).initCapacity(arena.allocator(), json_feed.items.len);
errdefer new_items.deinit();
for (json_feed.items) |item| {
const date_str = item.date_published orelse item.date_modified;
const date_utc = blk: {
if (date_str) |date| {
const date_utc = try parseDateToUtc(date);
break :blk @floatToInt(i64, date_utc.toSeconds());
}
break :blk null;
};
const title = item.title orelse blk: {
const text = (item.content_text orelse item.content_html).?;
const len = std.math.min(text.len, max_title_len);
break :blk text[0..len];
};
const new_item = Feed.Item{
.title = title,
.id = item.id,
.link = item.url,
.updated_raw = date_str,
.updated_timestamp = date_utc,
};
new_items.appendAssumeCapacity(new_item);
}
return Feed{
.title = json_feed.title,
// There are no top-level date fields in json feed
.link = json_feed.home_page_url,
.items = new_items.toOwnedSlice(),
};
}
pub fn parseDateToUtc(str: []const u8) !Datetime {
return try Atom.parseDateToUtc(str);
}
};
test "Json.parse()" {
var arena = std.heap.ArenaAllocator.init(testing.allocator);
defer arena.deinit();
const contents = @embedFile("../test/json_feed.json");
var feed = try Json.parse(&arena, contents);
try expectEqualStrings("My Example Feed", feed.title);
try expectEqualStrings("https://example.org/", feed.link.?);
{
const item = feed.items[0];
try expectEqualStrings("2", item.id.?);
try expectEqualStrings("This is a second item.", item.title);
try expectEqualStrings("https://example.org/second-item", item.link.?);
try std.testing.expect(null == item.updated_raw);
}
{
const item = feed.items[1];
try expectEqualStrings("1", item.id.?);
try expectEqualStrings("<p>Hello, world!</p>", item.title);
try expectEqualStrings("https://example.org/initial-post", item.link.?);
try std.testing.expect(null == item.updated_raw);
}
}
pub fn parse(arena: *std.heap.ArenaAllocator, contents: []const u8) !Feed {
if (isAtom(contents)) {
return try Atom.parse(arena, contents);
} else if (isRss(contents)) {
return try Rss.parse(arena, contents);
}
return error.InvalidFeedContent;
}
pub fn isRss(body: []const u8) bool {
const rss_str = "<rss";
var start = ascii.indexOfIgnoreCase(body, rss_str) orelse return false;
const end = mem.indexOfScalarPos(u8, body, start, '>') orelse return false;
start += rss_str.len;
if (ascii.indexOfIgnoreCase(body[start..end], "version=") == null) return false;
if (ascii.indexOfIgnoreCase(body[end + 1 ..], "<channel") == null) return false;
return true;
}
pub fn isAtom(body: []const u8) bool {
const start_str = "<feed";
var start = ascii.indexOfIgnoreCase(body, start_str) orelse return false;
const end = mem.indexOfScalarPos(u8, body, start, '>') orelse return false;
start += start_str.len;
return ascii.indexOfIgnoreCase(body[start..end], "xmlns=\"http://www.w3.org/2005/Atom\"") != null;
}
test "isRss(), isAtom()" {
try expect(isRss(@embedFile("../test/rss2.xml")));
try expect(isAtom(@embedFile("../test/atom.xml")));
}
|
src/parse.zig
|
pub const w4 = @import("wasm4.zig");
const g = @import("graphics.zig");
pub const info = @import("simple_info.zig");
const alphabet = @import("alphabet.zig");
const obj = @import("obj.zig");
// Input
const gpad_timer_max = 13;
// Map
const tilespace = 16;
const map_size_x = 15;
const map_size_y = 10;
const screen_tiles_x = 10;
const screen_tiles_y =
if (screen_tiles_x < map_size_y) screen_tiles_x else map_size_y;
// Objs / Things
pub const team_cnt = 2;
pub const unity_cap = 50;
const obj_cnt = unity_cap * team_cnt;
// selection
const selected_range = 19;
// menus
const day_menu = new_menu( .day_menu, &[_][]const u8{
// "CO",
// "Intel",
// "Optns",
// "Save",
"Cancel",
"End Day",
});
pub const ptrs = struct {
gpads: *[4]u8,
gpads_timer: *[4][4]u4,
redraw: *bool,
game_state: *Game_State,
map: *[map_size_y][map_size_x]info.Map_Tile,
cam: *[2]u8,
curr_day: *u8,
curr_team: *Team,
team_cnt: *Team,
cursor_pos: *[2]u8,
cursor_state: *Cursor_State,
cursor_menu: *Loopable,
selec_offset: *[2]u8,
selected: *[selected_range][selected_range]?info.Cost,
selec_obj: *ObjId,
selec_pos: *[2]u8,
moved_contex: *Moved_Contex,
unloaded_menu: *Loopable,
unloaded: *Loopable,
unloaded_buff: *[4][2]u8,
attacked: *Loopable,
attac_buff: *[4]ObjId,
next_obj: *[team_cnt]ObjId,
obj_id: *[obj_cnt]info.Unity_Id,
obj_info: *[obj_cnt]ObjInfo,
obj_pos: *[2][obj_cnt]u8,
obj_map: *[map_size_y][map_size_x]?ObjId,
freed_cnt: *[team_cnt]ObjId,
freed_list: *[team_cnt][unity_cap]ObjId,
const Self = @This();
const std = @import("std");
pub const MAXSIZE = 58975;
const mem_ptr = 0x19a0;
const mem_buf = @intToPtr(*[MAXSIZE]u8, mem_ptr);
pub const alloced_memory = calc_used();
fn init() Self {
comptime var self: Self = undefined;
comptime var alloc = 0;
inline for (@typeInfo(Self).Struct.fields) |field| {
const T = @typeInfo(field.field_type).Pointer.child;
switch (@typeInfo(T)) {
.Int, .Bool, .Array, .Struct, .Enum => {
const size = @sizeOf(T);
if ( alloc + size > MAXSIZE ) {
@compileLog("Type to alloc", T);
@compileLog("Size to alloc", size);
@compileLog("Before alloc", alloc);
@compileLog("After alloc", alloc + size);
@compileError("ptrs.init: Not enough memory!");
}
@field(self, field.name) = @intToPtr(*T, mem_ptr + alloc);
alloc += size;
},
else => {
@compileLog(field.name, T);
@compileError("ptrs: unhandled case.\nIf you got this compileError, consider adding a case for the unhandled type.");
},
}
}
return self;
}
fn calc_used() comptime_int {
comptime var alloc = 0;
inline for (@typeInfo(Self).Struct.fields) |field| {
const T = @typeInfo(field.field_type).Pointer.child;
const size = @sizeOf(T);
alloc += size;
}
return alloc;
}
}.init();
pub const Team = u2;
const Game_State = enum {
game, army0, army1,
};
const Cursor_State = enum(u8) {
initial = 0,
selected,
moved,
unload_menu,
unload,
attack,
day_menu,
};
const Loopable = struct{
i: u4, max: u4,
const Self = @This();
fn inc(self: *Self) void {
self.*.i = (self.*.i + 1) % self.*.max;
}
fn dec(self: *Self) void {
self.*.i = (self.*.i -% 1 +% self.*.max) % self.*.max;
}
};
const Moved_Contex = packed struct {
@"capture": bool = false,
@"no fire": bool = false,
@"fire" : bool = false,
@"unload" : bool = false,
@"supply" : bool = false,
@"join" : bool = false,
@"load" : bool = false,
@"wait" : bool = false,
};
fn MvdCtxEnum() type {
const fields = @typeInfo(Moved_Contex).Struct.fields;
comptime var texts: [fields.len][]const u8 = undefined;
inline for ( fields ) |f, i| {
texts[i] = f.name;
}
return createEnum(&texts);
}
pub const max_health = 100;
const ObjInfo = struct {
acted: bool,
team: Team,
health: u7,
fuel: info.Fuel,
transporting: ?ObjId,
};
pub const ObjId = u7;
fn createEnum(texts: []const[]const u8) type {
const TP = @import("std").builtin.TypeInfo;
const EF = TP.EnumField;
const Decl = TP.Declaration;
const decls = [0]Decl{};
comptime var enum_f: [texts.len]EF = undefined;
inline for ( texts ) |t, i| {
enum_f[i] = .{ .name = t, .value = i, };
}
return @Type(.{ .Enum = .{
.layout = .Auto, .tag_type = u8, .fields = &enum_f,
.decls = &decls, .is_exhaustive = true,
} });
}
fn new_menu(comptime tag: Cursor_State, texts: []const []const u8) type {
comptime var max_len: u8 = 0;
inline for ( texts ) |t| {
if ( t.len > max_len ) max_len = t.len;
}
const block_cnt = max_len / 2 + 1;
return struct {
const Enum: type = createEnum(texts);
const tag: Cursor_State = tag;
const texts: [][]const u8 = texts;
const block_cnt: u8 = block_cnt;
const size: u8 = texts.len;
fn name(i: u8) Enum {
return @intToEnum(Enum, i);
}
fn draw() void {
const x = @as(i32, ptrs.cursor_pos[0]) * tilespace;
const y = @as(i32, ptrs.cursor_pos[1]) * tilespace;
const xa = x + tilespace;
const ya = y + 8 * ptrs.cursor_menu.*.i;
const off = 2;
w4.DRAW_COLORS.* = 0x01;
var j: u8 = 0;
while ( j < size ) : ( j += 1 ) {
var i: u8 = 0;
while ( i < block_cnt ) : ( i += 1 ) {
blit(&g.square, xa + i * 8, y + j * 8, 8, 8, 0);
}
}
w4.DRAW_COLORS.* = 0x02;
inline for ( texts ) |t, i| {
text(t, xa + off, y + off + @intCast(i32, i) * 8);
}
w4.DRAW_COLORS.* = 0x03;
blit(&g.select_thin_q, xa, ya, 8, 8, 0);
blit(&g.select_thin_q, xa + 8 * (block_cnt - 1), ya, 8, 8, 6);
}
};
}
export fn start() void {
const debug = @import("builtin").mode == .Debug;
if ( debug ) {
// Debug allocated memory
w4.tracef("Memory Usage:\n Allocated: %d\n Free for use: %d" ++
"\n Use (%%): %f",
@as(i32, @TypeOf(ptrs).alloced_memory),
@as(i32, @TypeOf(ptrs).MAXSIZE - @TypeOf(ptrs).alloced_memory),
@as(f32, @TypeOf(ptrs).alloced_memory) /
@as(f32, @TypeOf(ptrs).MAXSIZE));
}
// Game
ptrs.game_state.* = .game;
// Draw fst frame
ptrs.redraw.* = true;
ptrs.cursor_pos[0] = 1;
ptrs.cursor_pos[1] = 1;
{ // map initialization
const t = info.Map_Tile;
ptrs.map.* = [map_size_y][map_size_x]t{
[_]t{.woods} ++ [_]t{.plains}**8 ++ [_]t{.mountain}**2 ++ [_]t{.plains}**4,
[_]t{.plains, .woods, .plains, .plains, .city, .city, .plains, .woods, .plains} ++ [_]t{.mountain}**2 ++ [_]t{.plains}**2 ++ [_]t{.road, .hq},
[_]t{.plains} ++ [_]t{.road}**7 ++ [_]t{.woods} ++ [_]t{.mountain}**2 ++ [_]t{.city, .plains, .road, .plains},
[_]t{.plains, .road} ++ [_]t{.plains}**2 ++ [_]t{.mountain}**2 ++ [_]t{.plains, .road, .plains} ++ [_]t{.mountain}**2 ++ [_]t{.plains, .plains, .road, .plains},
[_]t{.plains, .road} ++ [_]t{.plains}**2 ++ [_]t{.mountain}**2 ++ [_]t{.plains, .road, .plains} ++ [_]t{.mountain}**2 ++ [_]t{.plains, .plains, .road, .plains},
[_]t{.river, .bridge} ++ [_]t{.river}**5 ++ [_]t{.bridge} ++ [_]t{.river}**5 ++ [_]t{.bridge, .river},
[_]t{.plains, .road} ++ [_]t{.plains}**2 ++ [_]t{.mountain}**2 ++ [_]t{.plains, .road, .plains} ++ [_]t{.mountain}**2 ++ [_]t{.plains, .plains, .road, .plains},
[_]t{.plains, .road} ++ [_]t{.plains}**2 ++ [_]t{.mountain}**2 ++ [_]t{.plains} ++ [_]t{.road}**7 ++ [_]t{.plains},
[_]t{.hq, .road, .plains, .city} ++ [_]t{.mountain}**2 ++ [_]t{.woods} ++ [_]t{.plains}**6 ++ [_]t{.woods, .plains},
[_]t{.plains, .road, .plains, .plains} ++ [_]t{.mountain}**2 ++ [_]t{.plains, .woods, .plains, .city, .city, .plains, .plains, .plains, .woods},
};
}
{ // Set team count
ptrs.team_cnt.* = 2;
}
{ // obj_map inicialization
ptrs.obj_map.* = .{ .{ null } ** map_size_x } ** map_size_y;
}
{ // Put objs
ptrs.next_obj.* = [_]ObjId{ 0 } ** team_cnt;
ptrs.freed_cnt.* = [_]ObjId{ 0 } ** team_cnt;
const obj_info = ptrs.obj_info;
const units = [3][3]info.Unity_Id{
.{.mech , .infantry, .apc , },
.{.infantry, .mech , .infantry, },
.{.infantry, .infantry, .mech , },
};
const off0 = @intCast(u8, map_size_y - units.len);
const off1x = @intCast(u8, map_size_x - 1 );
const off1y = @intCast(u8, units.len - 1 );
for ( units ) |line, jj| {
const j = @intCast(u8, jj);
for ( line ) |id, ii| {
const i = @intCast(u8, ii);
const n0 = obj.create(id, 0, i, off0 + j);
obj_info[n0].acted = false;
const n1 = obj.create(id, 1, off1x - i, off1y - j);
obj_info[n1].acted = false;
}
}
// const team_cnt = ptrs.team_cnt.*;
// var i: u7 = 0;
// var j: u8 = 0;
// while ( j < 20 ) : ( j += 1 ) {
// const x = (j * 0x5) % (map_size_x - 2) + 1;
// const y = (j * 0x3) % (map_size_y - 2) + 1;
// if ( x == 0 or x == map_size_x-1 or y == 0 or y == map_size_y-1 ) {
// } else {
// const obj_id = @intToEnum(info.Unity_Id, i % info.Unity_Id.cnt);
// const team = @intCast(u2, i % team_cnt);
// const num = obj.create(obj_id, team, x, y);
// ptrs.obj_info[num].acted = false;
// i += 1;
// }
// }
}
w4.SYSTEM_FLAGS.* = w4.SYSTEM_PRESERVE_FRAMEBUFFER;
if ( debug ) {
// w4.tone(10, 60, 100, 0);
w4.tone(262 | (253 << 16), 60, 30, w4.TONE_PULSE1 | w4.TONE_MODE3);
}
}
export fn update() void {
const timer = &ptrs.gpads_timer[0];
const gpads = ptrs.gpads;
const cam = ptrs.cam;
const cursor_pos = ptrs.cursor_pos;
// Input handling
const pad_old = gpads[0];
const pad_new = w4.GAMEPAD1.*;
const pad_diff = pad_old ^ pad_new;
if ( cursor_pos[1] < map_size_y - 1
and (pad_diff & w4.BUTTON_DOWN == w4.BUTTON_DOWN or timer[0] == 0)
and pad_new & w4.BUTTON_DOWN == w4.BUTTON_DOWN ) {
timer[0] = gpad_timer_max;
ptrs.redraw.* = true;
switch ( ptrs.cursor_state.* ) {
.initial, .selected => {
cursor_pos[1] += 1;
},
.moved, .day_menu => ptrs.cursor_menu.inc(),
.unload_menu => ptrs.unloaded_menu.inc(),
.unload => {
ptrs.unloaded.inc();
const i = ptrs.unloaded.*.i;
ptrs.cursor_pos.* = ptrs.unloaded_buff[i];
},
.attack => {
const i = ptrs.attacked.*.i;
const max = ptrs.attacked.*.max;
const atk = ( i + 1 ) % max;
const num = ptrs.attac_buff[atk];
ptrs.cursor_pos[0] = ptrs.obj_pos[0][num];
ptrs.cursor_pos[1] = ptrs.obj_pos[1][num];
ptrs.attacked.*.i = atk;
},
}
} else if ( cursor_pos[1] > 0
and (pad_diff & w4.BUTTON_UP == w4.BUTTON_UP or timer[1] == 0)
and pad_new & w4.BUTTON_UP == w4.BUTTON_UP ) {
timer[1] = gpad_timer_max;
ptrs.redraw.* = true;
switch ( ptrs.cursor_state.* ) {
.initial, .selected => {
cursor_pos[1] -= 1;
},
.moved, .day_menu => ptrs.cursor_menu.dec(),
.unload_menu => ptrs.cursor_menu.dec(),
.unload => {
ptrs.unloaded.dec();
const i = ptrs.unloaded.*.i;
ptrs.cursor_pos.* = ptrs.unloaded_buff[i];
},
.attack => {
const i = ptrs.attacked.*.i;
const max = ptrs.attacked.*.max;
const atk = ( i -% 1 +% max ) % max;
const num = ptrs.attac_buff[atk];
ptrs.cursor_pos[0] = ptrs.obj_pos[0][num];
ptrs.cursor_pos[1] = ptrs.obj_pos[1][num];
ptrs.attacked.*.i = atk;
},
}
}
if ( cursor_pos[0] < map_size_x - 1
and (pad_diff & w4.BUTTON_RIGHT == w4.BUTTON_RIGHT or timer[2] == 0)
and pad_new & w4.BUTTON_RIGHT == w4.BUTTON_RIGHT ) {
timer[2] = gpad_timer_max;
ptrs.redraw.* = true;
switch ( ptrs.cursor_state.* ) {
.initial, .selected => {
cursor_pos[0] += 1;
},
.moved, .unload_menu, .day_menu => {},
.unload => {
ptrs.unloaded.inc();
const i = ptrs.unloaded.*.i;
ptrs.cursor_pos.* = ptrs.unloaded_buff[i];
},
.attack => {
const i = ptrs.attacked.*.i;
const max = ptrs.attacked.*.max;
const atk = ( i + 1 ) % max;
const num = ptrs.attac_buff[atk];
ptrs.cursor_pos[0] = ptrs.obj_pos[0][num];
ptrs.cursor_pos[1] = ptrs.obj_pos[1][num];
ptrs.attacked.*.i = atk;
},
}
} else if ( cursor_pos[0] > 0
and (pad_diff & w4.BUTTON_LEFT == w4.BUTTON_LEFT or timer[3] == 0)
and pad_new & w4.BUTTON_LEFT == w4.BUTTON_LEFT ) {
timer[3] = gpad_timer_max;
ptrs.redraw.* = true;
switch ( ptrs.cursor_state.* ) {
.initial, .selected => {
cursor_pos[0] -= 1;
},
.moved, .unload_menu, .day_menu => {},
.unload => {
ptrs.unloaded.dec();
const i = ptrs.unloaded.*.i;
ptrs.cursor_pos.* = ptrs.unloaded_buff[i];
},
.attack => {
ptrs.attacked.dec();
const atk = ptrs.attacked.*.i;
const num = ptrs.attac_buff[atk];
ptrs.cursor_pos[0] = ptrs.obj_pos[0][num];
ptrs.cursor_pos[1] = ptrs.obj_pos[1][num];
},
}
}
if ( pad_diff & w4.BUTTON_1 == w4.BUTTON_1
and pad_new & w4.BUTTON_1 == w4.BUTTON_1 ) {
ptrs.redraw.* = true;
if ( ptrs.game_state.* != .game) {
start();
} else switch ( ptrs.cursor_state.* ) {
.initial => {
const n: ?ObjId = get_obj_num_on_cursor();
if ( n != null and !ptrs.obj_info[n.?].acted ) {
const num = n.?;
calculate_movable_tiles(num);
ptrs.cursor_state.* = .selected;
} else {
ptrs.cursor_menu.* = .{ .i = 0, .max = day_menu.size };
ptrs.cursor_state.* = .day_menu;
}
},
.selected => {
ptrs.moved_contex.* = .{};
var menu_max: u4 = 0;
const num = ptrs.selec_obj.*;
const this_obj_info = &ptrs.obj_info[num];
const team = this_obj_info.team;
const offset = ptrs.selec_offset;
const old_x = ptrs.obj_pos[0][num];
const old_y = ptrs.obj_pos[1][num];
const new_x = ptrs.cursor_pos[0];
const new_y = ptrs.cursor_pos[1];
const old_selec_x = new_x -% offset[0];
const old_selec_y = new_y -% offset[1];
if ( team == ptrs.curr_team.*
and old_selec_x < selected_range
and old_selec_y < selected_range
and ptrs.selected[old_selec_y][old_selec_x] != null
) {
const id = ptrs.obj_id[num];
const may_unload =
this_obj_info.transporting != null
and ptrs.map[new_y][new_x].move_cost(
ptrs.obj_id[this_obj_info.transporting.?]
.move_cost().typ ) != null;
const is_empty = ptrs.obj_map[new_y][new_x] == null
or ptrs.obj_map[new_y][new_x].? == num;
const should_join =
if ( ptrs.obj_map[new_y][new_x] ) |n2|
if ( num != n2
and id == ptrs.obj_id[n2]
and (this_obj_info.*.health < max_health
or ptrs.obj_info[n2].health < max_health)
) true else false
else false;
const should_load =
if ( ptrs.obj_map[new_y][new_x] ) |n2|
if ( num != n2
and ptrs.obj_id[n2].may_transport(id)
) true else false
else false;
if ( may_unload and is_empty) {
const n2 = this_obj_info.transporting.?;
const move_typ = ptrs.obj_id[n2].move_cost().typ;
const center = (selected_range - 1) / 2;
offset.*[0] = new_x -% center;
offset.*[1] = new_y -% center;
ptrs.selected.* =
.{ .{ null } ** selected_range }
** selected_range;
var i: u4 = 0;
const directions = [4][2]u8{
.{ new_x, new_y-%1 }, .{ new_x-%1, new_y },
.{ new_x+1, new_y }, .{ new_x, new_y+1 }
};
for ( directions ) |d| {
const dx = d[0];
const dy = d[1];
const sx = dx -% offset[0];
const sy = dy -% offset[1];
const tile = ptrs.map[dy][dx];
if ( dx < map_size_x
and dy < map_size_y
and ptrs.obj_map[dy][dx] == null
and tile.move_cost(move_typ)
!= null ) {
ptrs.selected[sy][sx] = 1;
ptrs.unloaded_buff[i] = .{ dx, dy };
i += 1;
}
}
if ( i > 0 ) {
ptrs.unloaded.* = .{ .i = 0, .max = i };
menu_max += 1;
ptrs.moved_contex.*.unload = true;
}
}
if ( id == .apc and is_empty ) {
obj.moveTo(num, new_x, new_y);
const directions = [4][2]u8{
.{ new_x, new_y-%1 }, .{ new_x-%1, new_y },
.{ new_x+1, new_y }, .{ new_x, new_y+1 }
};
for ( directions ) |d| {
const dx = d[0];
const dy = d[1];
if ( dx < map_size_x
and dy < map_size_y
and ptrs.obj_map[dy][dx] != null ) {
const n2 = ptrs.obj_map[dy][dx].?;
if ( team == ptrs.obj_info[n2].team ) {
menu_max += 1;
ptrs.moved_contex.*.supply = true;
}
}
}
menu_max += 1;
ptrs.moved_contex.*.wait = true;
ptrs.cursor_menu.* = .{ .i = 0, .max = menu_max };
ptrs.cursor_state.* = .moved;
} else if ( should_join ) {
ptrs.obj_map[old_y][old_x] = null;
menu_max += 1;
ptrs.moved_contex.*.join = true;
ptrs.cursor_menu.* = .{ .i = 0, .max = menu_max };
ptrs.cursor_state.* = .moved;
} else if ( should_load ) {
ptrs.obj_map[old_y][old_x] = null;
menu_max += 1;
ptrs.moved_contex.*.load = true;
ptrs.cursor_menu.* = .{ .i = 0, .max = menu_max };
ptrs.cursor_state.* = .moved;
} else if ( is_empty ) {
obj.moveTo(num, new_x, new_y);
const center = (selected_range - 1) / 2;
offset.*[0] = new_x -% center;
offset.*[1] = new_y -% center;
ptrs.selected.* =
.{ .{ null } ** selected_range }
** selected_range;
var i: u4 = 0;
const directions = [4][2]u8{
.{ new_x, new_y-%1 }, .{ new_x-%1, new_y },
.{ new_x+1, new_y }, .{ new_x, new_y+1 }
};
for ( directions ) |d| {
const dx = d[0];
const dy = d[1];
const sx = dx -% offset[0];
const sy = dy -% offset[1];
if ( dx < map_size_x
and dy < map_size_y
and ptrs.obj_map[dy][dx] != null ) {
const n2 = ptrs.obj_map[dy][dx].?;
const id2 = ptrs.obj_id[n2];
if ( team != ptrs.obj_info[n2].team
and id.attack(id2) != null ) {
ptrs.selected[sy][sx] = 1;
ptrs.attac_buff[i] = n2;
i += 1;
}
}
}
if ( i > 0 ) {
ptrs.attacked.* = .{ .i = 0, .max = i };
menu_max += 1;
ptrs.moved_contex.*.fire = true;
}
menu_max += 1;
ptrs.moved_contex.*.wait = true;
ptrs.cursor_menu.* = .{ .i = 0, .max = menu_max };
ptrs.cursor_state.* = .moved;
}
}
},
.moved => {
const ctx = ptrs.moved_contex;
var cnt: u4 = ptrs.cursor_menu.*.i;
const fields = @typeInfo(Moved_Contex).Struct.fields;
const chosen = inline for ( fields ) |f, i| {
if ( @field(ctx, f.name) ) {
if ( cnt == 0 )
break @intToEnum(MvdCtxEnum(), i);
cnt -= 1;
}
};
switch ( chosen ) {
.@"capture", => {
w4.trace("capture: not implemented");
unreachable;
},
.@"no fire", => {
w4.trace("no fire: \"not\" implemented");
w4.trace("(Yes, it should actually do nothing!)");
},
.@"fire", => {
const num = ptrs.attac_buff[0];
ptrs.cursor_pos[0] = ptrs.obj_pos[0][num];
ptrs.cursor_pos[1] = ptrs.obj_pos[1][num];
ptrs.cursor_state.* = .attack;
},
.@"unload", => {
ptrs.unloaded_menu.* = .{ .i = 0, .max = 1 };
ptrs.cursor_state.* = .unload_menu;
},
.@"supply", => {
const num = ptrs.selec_obj.*;
const x = ptrs.obj_pos[0][num];
const y = ptrs.obj_pos[1][num];
const team = ptrs.obj_info[num].team;
const directions = [4][2]u8{
.{ x, y-%1 }, .{ x-%1, y },
.{ x+1, y }, .{ x, y+1 }
};
for ( directions ) |d| {
const dx = d[0];
const dy = d[1];
if ( dx < map_size_x
and dy < map_size_y
and ptrs.obj_map[dy][dx] != null ) {
const n2 = ptrs.obj_map[dy][dx].?;
if ( team == ptrs.obj_info[n2].team ) {
obj.supply(n2);
}
}
}
ptrs.obj_info[num].acted = true;
ptrs.cursor_state.* = .initial;
},
.@"join", => {
const num = ptrs.selec_obj.*;
const id = ptrs.obj_id[num];
const x = ptrs.cursor_pos[0];
const y = ptrs.cursor_pos[1];
const n2 = ptrs.obj_map[y][x].?;
obj.join(n2, num, id);
ptrs.cursor_state.* = .initial;
},
.@"load", => {
const num = ptrs.selec_obj.*;
const x = ptrs.cursor_pos[0];
const y = ptrs.cursor_pos[1];
const n2 = ptrs.obj_map[y][x].?;
ptrs.obj_info[n2].transporting = num;
ptrs.obj_info[num].acted = true;
ptrs.cursor_state.* = .initial;
},
.@"wait", => {
const num = ptrs.selec_obj.*;
ptrs.obj_info[num].acted = true;
ptrs.cursor_state.* = .initial;
},
}
},
.unload_menu => {
const i = ptrs.unloaded.*.i;
ptrs.cursor_pos.* = ptrs.unloaded_buff[i];
ptrs.cursor_state.* = .unload;
},
.unload => {
const num = ptrs.selec_obj.*;
const n2 = ptrs.obj_info[num].transporting.?;
const n2_x = ptrs.cursor_pos[0];
const n2_y = ptrs.cursor_pos[1];
obj.moveTo(n2, n2_x, n2_y);
ptrs.obj_info[num].transporting = null;
ptrs.obj_info[num].acted = true;
ptrs.obj_info[n2].acted = true;
ptrs.cursor_state.* = .initial;
},
.attack => {
const atk_num = ptrs.selec_obj.*;
const def_num = ptrs.attac_buff[ptrs.attacked.*.i];
obj.attack(atk_num, def_num);
ptrs.cursor_state.* = .initial;
},
.day_menu => switch ( day_menu.name(ptrs.cursor_menu.*.i) ) {
.@"Cancel" => ptrs.cursor_state.* = .initial,
.@"End Day" => {
const curr_team = ptrs.curr_team.*;
reset_acted(curr_team);
const next_team = (curr_team + 1) % ptrs.team_cnt.*;
ptrs.curr_team.* = next_team;
if ( next_team < curr_team ) {
ptrs.curr_day.* += 1;
}
turn_start(next_team);
ptrs.cursor_state.* = .initial;
},
},
}
} else if ( pad_diff & w4.BUTTON_2 == w4.BUTTON_2
and pad_new & w4.BUTTON_2 == w4.BUTTON_2 ) {
ptrs.redraw.* = true;
switch ( ptrs.cursor_state.* ) {
.initial => {},
.selected => ptrs.cursor_state.* = .initial,
.moved => {
const num = ptrs.selec_obj.*;
const old_x = ptrs.selec_pos[0];
const old_y = ptrs.selec_pos[1];
obj.moveTo(num, old_x, old_y);
ptrs.cursor_pos.* = .{ old_x, old_y };
calculate_movable_tiles(num);
ptrs.cursor_state.* = .selected;
},
.unload_menu => ptrs.cursor_state.* = .moved,
.unload => ptrs.cursor_state.* = .unload_menu,
.attack => ptrs.cursor_state.* = .moved,
.day_menu => ptrs.cursor_state.* = .initial,
}
}
// Camera movement
const cam_max_x = map_size_x - screen_tiles_x;
const xdiff = @intCast(i8, cursor_pos[0]) - @intCast(i8, cam[0]);
if ( 0 <= cam[0] and cam[0] < cam_max_x and xdiff > screen_tiles_x - 2 ) {
cam[0] += 1;
} else if ( 0 < cam[0] and cam[0] <= cam_max_x and xdiff < 2 ) {
cam[0] -= 1;
}
const cam_max_y = map_size_y - screen_tiles_y;
const ydiff = @intCast(i8, cursor_pos[1]) - @intCast(i8, cam[1]);
if ( 0 <= cam[1] and cam[1] < cam_max_y and ydiff > screen_tiles_y - 2 ) {
cam[1] += 1;
} else if ( 0 < cam[1] and cam[1] <= cam_max_y and ydiff < 2 ) {
cam[1] -= 1;
}
gpads[0] = pad_new;
for (timer) |*t| if ( t.* > 0 ) { t.* -= 1; };
if ( ptrs.redraw.* ) {
const state = ptrs.game_state.*;
switch ( state ) {
.game => draw(),
.army0, .army1 => draw_winner(state),
}
ptrs.redraw.* = false;
}
}
fn get_obj_num_on_cursor() ?ObjId {
const c_p = ptrs.cursor_pos;
return ptrs.obj_map[c_p[1]][c_p[0]];
}
fn calculate_movable_tiles(num: ObjId) void {
const obj_info = ptrs.obj_info[num];
const team = obj_info.team;
const id = ptrs.obj_id[num];
const fuel = obj_info.fuel;
const move_cost = id.move_cost();
const mv_typ = move_cost.typ;
const mv_max = move_cost.moves;
const gas = if ( mv_max < fuel )
mv_max else @intCast(u4, fuel);
const center = (selected_range - 1) / 2;
const selec_x = ptrs.cursor_pos[0] -% center;
const selec_y = ptrs.cursor_pos[1] -% center;
ptrs.selec_offset[0] = selec_x;
ptrs.selec_offset[1] = selec_y;
ptrs.selec_obj.* = num;
ptrs.selec_pos.* = ptrs.cursor_pos.*;
// Flood fill (DFS)
var len: u8 = 1;
const q_size = 0x30;
var queue: [q_size][2]u8 = .{ .{ 0, 0 } } ** q_size;
var local_selec: [selected_range][selected_range]?info.Cost =
.{ .{ null } ** selected_range } ** selected_range;
queue[0] = .{ center, center };
local_selec[center][center] = gas;
while ( len > 0 ) {
len -= 1;
const x = queue[len][0];
const y = queue[len][1];
if ( local_selec[y][x] ) |rem_fuel| {
const directions = [4][2]u8{
.{ x, y-%1 }, .{ x-%1, y }, .{ x+1, y }, .{ x, y+1 }
};
for ( directions ) |d| {
const dx = d[0];
const dy = d[1];
if ( dx >= selected_range or dy >= selected_range ) {
w4.trace("Flood fill: unit has too much movement?");
unreachable;
}
const sx = dx +% selec_x;
const sy = dy +% selec_y;
if ( sx >= map_size_x or sy >= map_size_y ) continue;
const movable = ptrs.map[sy][sx].move_cost(mv_typ);
if ( movable ) |cost| {
const maybe_same_team =
if ( ptrs.obj_map[sy][sx] ) |n2|
team == ptrs.obj_info[n2].team
else null;
var new_fuel: info.Cost = undefined;
const overflow = @subWithOverflow(info.Cost,
rem_fuel, cost, &new_fuel);
if ( !overflow
and ( maybe_same_team == null or
maybe_same_team.? )
and ( local_selec[dy][dx] == null
or local_selec[dy][dx].? < new_fuel ) ) {
local_selec[dy][dx] = new_fuel;
if ( len == q_size ) {
w4.trace("Flood fill: queue overflow!");
unreachable;
}
queue[len] = .{ dx, dy };
len = len + 1;
}
}
}
} else {
w4.tracef("Flood Fill: found null value at pos (%d, %d)",
x, y);
w4.tracef("id: %d, move_max: %d", id, mv_max);
w4.tracef("fuel: %d, gas: %d", fuel, gas);
w4.tracef("len: %d", len);
w4.trace("queue:");
for (queue) |q, i| {
w4.tracef(" %d: (%d, %d)", i, q[0], q[1]);
}
unreachable;
}
}
ptrs.selected.* = local_selec;
// note: Useful for ranged attacks
// for ( ptrs.selected ) |*ss, jj| {
// const j = @intCast(u8, jj);
// if ( y +% j >= map_size_y ) continue;
// const dj = if ( j < center )
// center - j else j - center;
// for (ss) |*s, ii| {
// const i = @intCast(u8, ii);
// if ( x +% i >= map_size_x ) continue;
// const di = if ( i < center )
// center - i else i - center;
// const empty_space = ptrs.obj_map[y+%j][x+%i] == null;
// const no_move = di + dj == 0;
// if ( di + dj <= range and (empty_space or no_move) ) {
// s.* = 1;
// } else {
// s.* = 0;
// }
// }
// }
}
fn reset_acted(team: Team) void {
for ( ptrs.obj_info.* ) |*obj_info| {
if ( obj_info.*.team == team ) {
obj_info.*.acted = false;
}
}
}
fn turn_start(team: Team) void {
// Resupply, earn money, repair ...
_ = team;
}
fn draw() void {
draw_map();
draw_objs();
draw_cursor();
}
fn draw_map() void {
const cx: u8 = ptrs.cam[0];
const cy: u8 = ptrs.cam[1];
const ts = tilespace;
const map = ptrs.map;
var i: u8 = 0;
var j: u8 = 0;
while ( j < screen_tiles_y ) : ( j += 1 ) {
const y = cy +% j;
const yts = @as(i32, y) * @as(i32, ts);
if ( y >= map_size_y ) continue;
i = 0;
w4.DRAW_COLORS.* = 0x43;
while ( i < screen_tiles_x ) : ( i += 1 ) {
const x = cx +% i;
const xts = @as(i32, x) * @as(i32, ts);
if ( x >= map_size_x ) continue;
const tile = map[y][x];
switch (tile) {
.plains => {
w4.DRAW_COLORS.* = 0x42;
blit4(&g.square, xts, yts, 8, 8, 0);
},
.woods => {
w4.DRAW_COLORS.* = 0x42;
blit(&g.woods, xts, yts, 16, 16, 0);
},
.mountain => {
w4.DRAW_COLORS.* = 0x42;
blit(&g.mountain, xts, yts, 16, 16, 0);
},
.road, .bridge => {
w4.DRAW_COLORS.* = 0x04;
blit4(&g.square, xts, yts, 8, 8, 0);
w4.DRAW_COLORS.* = 0x42;
blit(&g.road_pc, xts + 4, yts , 4, 8, 0);
blit(&g.road_pc, xts + 8, yts , 4, 8, 2);
blit(&g.road_pc, xts + 4, yts + 8, 4, 8, 0);
blit(&g.road_pc, xts + 8, yts + 8, 4, 8, 2);
// blit(&g.road_pc_rot, xts , yts + 4, 8, 4, 0);
// blit(&g.road_pc_rot, xts + 8, yts + 4, 8, 4, 0);
// blit(&g.road_pc_rot, xts , yts + 8, 8, 4, 4);
// blit(&g.road_pc_rot, xts + 8, yts + 8, 8, 4, 4);
},
.river => {
w4.DRAW_COLORS.* = 0x42;
blit(&g.river, xts, yts, 16, 16, 0);
},
.sea => {
w4.DRAW_COLORS.* = 0x44;
blit4(&g.square, xts, yts, 8, 8, 0);
},
.hq => {
w4.DRAW_COLORS.* = 0x42;
blit(&g.hq, xts, yts, 16, 16, 0);
},
.city => {
w4.DRAW_COLORS.* = 0x42;
blit(&g.city, xts, yts, 16, 16, 0);
},
else => {
w4.DRAW_COLORS.* = 0x21;
blit4(&g.sqr_border_q, xts, yts, 8, 8, 0);
}
}
}
}
switch (ptrs.cursor_state.*) {
.initial, .moved, .unload_menu, .day_menu => {},
.selected, .unload, .attack => {
const sx = ptrs.selec_offset[0];
const sy = ptrs.selec_offset[1];
for ( ptrs.selected ) |line, jj| {
const sj = @intCast(u8, jj);
const y = sy +% sj;
const yts = @as(i32, y) * ts;
if ( y >= map_size_y ) continue;
for ( line ) |p, ii| {
const si = @intCast(u8, ii);
const x = sx +% si;
const xts = @as(i32, x) * ts;
if ( x >= map_size_x ) continue;
if ( p ) |_| {
w4.DRAW_COLORS.* = 0x01;
blit4(&g.sqr_selected_q, xts, yts, 8, 8, 0);
}
}
}
},
}
}
fn draw_cursor() void {
const x = @as(i32, ptrs.cursor_pos[0]) * tilespace;
const y = @as(i32, ptrs.cursor_pos[1]) * tilespace;
w4.DRAW_COLORS.* = 0x03;
const state = ptrs.cursor_state.*;
switch ( state ) {
.initial, .selected, .unload =>
blit4(&g.select_q, x, y, 8, 8, 0),
.moved, .unload_menu => draw_menu(state),
.attack => blit4(&g.select_q, x, y, 8, 8, 4),
.day_menu => day_menu.draw(),
}
}
fn draw_menu(state: Cursor_State) void {
const x = @as(i32, ptrs.cursor_pos[0]) * tilespace;
const y = @as(i32, ptrs.cursor_pos[1]) * tilespace;
const xa = x + tilespace;
const ya = y + 8 * ptrs.cursor_menu.*.i;
const off = 2;
const ctx = ptrs.moved_contex.*;
const block_cnt = switch ( state ) {
.initial, .selected, .unload, .attack, .day_menu, => {
w4.trace("draw_menu: receaved unreachable state");
unreachable;
},
.moved => blk: {
const fields = @typeInfo(Moved_Contex).Struct.fields;
comptime var max_len = 0;
comptime var texts: [fields.len][]const u8 = undefined;
inline for ( fields ) |f, i| {
texts[i] = f.name;
if ( f.name.len > max_len ) max_len = f.name.len;
}
const size = ptrs.cursor_menu.*.max;
const block_cnt = max_len / 2 + 1;
draw_menu_back(xa, y, size, block_cnt);
w4.DRAW_COLORS.* = 0x02;
var i: u8 = 0;
inline for ( texts ) |t| {
if ( @field(ctx, t) ) {
text(t, xa + off, y + off + @intCast(i32, i) * 8);
i += 1;
}
}
break :blk block_cnt;
},
.unload_menu => blk: {
const num = ptrs.selec_obj.*;
const n2 = ptrs.obj_info[num].transporting.?;
const id = ptrs.obj_id[n2];
const size = ptrs.unloaded_menu.*.max;
const name_len = @intCast(u8, id.name_len());
const block_cnt = name_len / 2 + 1;
draw_menu_back(xa, y, size, block_cnt);
w4.DRAW_COLORS.* = 0x02;
switch ( id ) {
.infantry => text("infantry", xa + off, y + off),
.mech => text("mech" , xa + off, y + off),
.apc => text("apc" , xa + off, y + off),
}
break :blk block_cnt;
},
};
w4.DRAW_COLORS.* = 0x03;
blit(&g.select_thin_q, xa, ya, 8, 8, 0);
blit(&g.select_thin_q, xa + 8 * (block_cnt - 1), ya, 8, 8, 6);
}
fn draw_menu_back(xa: i32, y: i32, size: u8, block_cnt: u8) void {
w4.DRAW_COLORS.* = 0x01;
var j: u8 = 0;
while ( j < size ) : ( j += 1 ) {
var i: u8 = 0;
while ( i < block_cnt ) : ( i += 1 ) {
blit(&g.square, xa + i * 8, y + j * 8, 8, 8, 0);
}
}
}
fn draw_objs() void {
const cx = ptrs.cam[0];
const cy = ptrs.cam[1];
var j: u7 = 0;
var i: u7 = 0;
while ( j < screen_tiles_y ) : ( j += 1 ) {
i = 0;
while ( i < screen_tiles_x ) : ( i += 1 ) {
if ( ptrs.obj_map[cy+j][cx+i] ) |num| {
const id = ptrs.obj_id[num];
const x = @as(i32, cx+i) * tilespace + 4;
const y = @as(i32, cy+j) * tilespace + 4;
const obj_info = ptrs.obj_info[num];
// Health Bar
const health = obj_info.health / 10 + 1;
w4.DRAW_COLORS.* = 0x0004;
if ( health <= 10 ) {
rect(x - 1, y - 1, health, 1);
if ( health > 6 ) {
w4.DRAW_COLORS.* = 0x0003;
rect(x - 1 + 4, y - 1, 2, 1);
} else if ( health == 5 ) {
w4.DRAW_COLORS.* = 0x0003;
rect(x - 1 + 4, y - 1, 1, 1);
}
}
const color: u16 = switch (obj_info.team) {
0 => 0x0133,
1 => 0x0144,
2 => 0x0143,
3 => 0x0123,
};
if ( ptrs.obj_info[num].acted ) {
w4.DRAW_COLORS.* = color & 0xF0FF | 0x0200;
} else {
w4.DRAW_COLORS.* = color;
}
switch (id) {
.infantry => blit(&g.infantry, x, y, 8, 8, 1),
.mech => blit(&g.mech , x, y, 8, 8, 1),
.apc => blit(&g.apc , x, y, 8, 8, 1),
}
if ( obj_info.transporting != null ) {
w4.DRAW_COLORS.* = 0x01;
blit(&g.square, x + 4, y + 4, 3, 3, 0);
}
}
}
}
}
fn draw_winner(state: Game_State) void {
const x = (screen_tiles_x / 2 - 2) * tilespace;
const y = screen_tiles_y / 2 * tilespace;
switch ( state ) {
.game => {
w4.trace("draw_menu: receaved unreachable state");
unreachable;
},
.army0 => {
w4.DRAW_COLORS.* = 0x01;
var i: u8 = 0;
while ( i < 7 ) : ( i += 1 ) {
blit(&g.square, x + i * 8, y - 2, 8, 8, 0);
}
w4.DRAW_COLORS.* = 0x03;
text("Green Army Win", x, y);
},
.army1 => {
w4.DRAW_COLORS.* = 0x01;
var i: u8 = 0;
while ( i < 7 ) : ( i += 1 ) {
blit(&g.square, x + i * 8, y - 2, 8, 8, 0);
}
w4.DRAW_COLORS.* = 0x04;
text("Black Army Win", x, y);
},
}
w4.DRAW_COLORS.* = 0x01;
var i: u8 = 0;
while ( i < 9 ) : ( i += 1 ) {
blit(&g.square, x + i * 8 - 8, y + 14, 8, 8, 0);
}
w4.DRAW_COLORS.* = 0x04;
text("Press X to restart", x - 8, y + 16);
}
fn rect(x: i32, y: i32, width: u32, height: u32) void {
w4.rect(x - @as(i32, ptrs.cam[0]) * tilespace,
y - @as(i32, ptrs.cam[1]) * tilespace,
width, height);
}
fn blit(sprite: [*]const u8, x: i32, y: i32,
width: i32, height: i32, flags: u32) void {
w4.blit(sprite,
x - @as(i32, ptrs.cam[0]) * tilespace,
y - @as(i32, ptrs.cam[1]) * tilespace,
width, height, flags);
}
fn blit4(sprite: [*]const u8, x: i32, y: i32,
w: i32, h: i32, flags: u32) void {
blit(sprite, x , y , w, h, flags ^ 0);
blit(sprite, x + w, y , w, h, flags ^ 2);
blit(sprite, x , y + h, w, h, flags ^ 4);
blit(sprite, x + w, y + h, w, h, flags ^ 6);
}
fn text(comptime str: []const u8, x: i32, y: i32) void {
const letters = alphabet.encode(str);
const advance = 4;
for (letters) |l, i| {
if (l) |letter| {
blit(&letter, x + @intCast(i32, i) * advance, y, 8, 4, 0);
}
}
}
const ST = ?*@import("std").builtin.StackTrace;
pub fn panic(msg: []const u8, trace: ST) noreturn {
@setCold(true);
w4.trace(">> ahh, panic!");
w4.trace(msg);
if ( trace ) |t| {
w4.tracef(" index: %d", @intCast(i32, t.index));
} else {
w4.trace(" no trace :(");
}
while ( true ) {
@breakpoint();
}
}
|
src/main.zig
|
const std = @import("std");
const tools = @import("tools");
const with_trace = true;
const assert = std.debug.assert;
fn trace(comptime fmt: []const u8, args: anytype) void {
if (with_trace) std.debug.print(fmt, args);
}
pub fn main() anyerror!void {
const stdout = std.io.getStdOut().writer();
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = arena.allocator();
const limit = 1 * 1024 * 1024 * 1024;
const text = try std.fs.cwd().readFileAlloc(allocator, "day20.txt", limit);
defer allocator.free(text);
const Range = struct {
min: u32,
max: u32,
};
var blacklist: [1000]Range = undefined;
var len: usize = 0;
var it = std.mem.tokenize(u8, text, "\n");
while (it.next()) |line| {
if (tools.match_pattern("{}-{}", line)) |vals| {
trace("new RANGE {}/{}\n", .{ vals[0], vals[1] });
const range0 = Range{ .min = @intCast(u32, vals[0].imm), .max = @intCast(u32, vals[1].imm) };
const oldlist = blacklist;
var depth: u32 = 0;
var cur: ?u32 = null;
var i: usize = 0;
var j: ?usize = null;
while (true) {
const Edge = struct {
v: u32,
up: i3,
};
const nextedge = blk: {
const e = if (cur == null or range0.min > cur.?) Edge{ .v = range0.min, .up = 1 } else if (range0.max > cur.?) Edge{ .v = range0.max, .up = -1 } else null;
if (i < len) {
const r = oldlist[i];
if (cur == null or r.min > cur.?) {
if (e == null or e.?.v > r.min) {
break :blk Edge{ .v = r.min, .up = 1 };
} else if (e != null and e.?.v == r.min) {
break :blk Edge{ .v = r.min, .up = 1 + e.?.up };
} else {
break :blk e;
}
} else if (r.max > cur.?) {
if (e == null or e.?.v > r.max) {
i += 1;
break :blk Edge{ .v = r.max, .up = -1 };
} else if (e != null and e.?.v == r.max) {
i += 1;
break :blk Edge{ .v = r.min, .up = e.?.up - 1 };
} else {
break :blk e;
}
}
}
break :blk e;
};
if (nextedge) |e| {
depth = @intCast(u32, @intCast(i32, depth) + e.up);
if (e.up > 0 and depth == 1) {
if (j == null) {
j = 0;
blacklist[0].min = e.v;
} else if (e.v > blacklist[j.?].max + 1) {
j.? += 1;
blacklist[j.?].min = e.v;
}
} else if (e.up < 0 and depth == 0) {
blacklist[j.?].max = e.v;
}
cur = e.v;
} else {
break;
}
}
len = j.? + 1;
for (blacklist[0..len]) |range| {
//trace("range = {}\n", .{range});
}
var prev: u32 = 0;
for (blacklist[0..len]) |range| {
assert(range.min >= prev);
assert(range.max >= range.min);
prev = range.max;
}
} else {
trace("skipping {}\n", .{line});
}
}
{
try stdout.print("====================================\n", .{});
var allowed: usize = 0;
var prev: u32 = 0;
for (blacklist[0..len]) |range| {
try stdout.print("range = {}\n", .{range});
allowed += (range.min - prev);
prev = if (range.max != 0xFFFFFFFF) range.max + 1 else undefined;
}
try stdout.print("allowed = {}\n", .{allowed});
}
}
|
2016/day20.zig
|
const std = @import("std");
const debug = std.debug;
const mem = std.mem;
const Allocator = mem.Allocator;
const ArrayList = std.ArrayList;
fn Partition(comptime mod: u8) type {
return struct {
const Self = this;
const digit_count = comptime blk: {
var r: i64 = 1;
var i: u8 = 1;
while (i < mod) : (i += 1) {
r *= 10;
}
break :blk r;
};
allocator: &Allocator,
partitions: ArrayList(i64),
n: usize,
pub fn init(allocator: &Allocator) Self {
return Self {
.allocator = allocator,
.partitions = ArrayList(i64).init(allocator),
.n = 0,
};
}
pub fn deinit(p: &Self) void {
p.partitions.deinit();
}
fn sign_m1(x: i64) i64 {
return if (@mod(x, 2) == 0) i64(1) else -1;
}
pub fn next(p: &Self) !i64 {
if (p.partitions.len == 0) {
try p.partitions.appendSlice([]i64 { 1, 1, 2 });
}
const parts = p.partitions.toSliceConst();
if (p.n < 3) {
const result = parts[p.n];
p.n += 1;
return result;
}
var v: i64 = 0;
var k: i64 = 1;
var n = i64(parts.len);
while (n >= @divFloor(k * (3 * k - 1), 2)) {
v += sign_m1(k - 1) * parts[usize(n - @divFloor(k * (3 * k - 1), 2))];
k += 1;
}
k = -1;
while (n >= @divFloor(k * (3 * k - 1), 2)) {
v += sign_m1(k - 1) * parts[usize(n - @divFloor(k * (3 * k - 1), 2))];
k -= 1;
}
const final = @mod(v, digit_count);
try p.partitions.append(final);
return final;
}
};
}
fn run() u64 {
var p = Partition(7).init(std.heap.c_allocator);
defer p.deinit();
var n: u64 = 0;
while (true) : (n += 1) {
if ((p.next() catch unreachable) == 0) {
return n;
}
}
}
pub fn main() !void {
try debug.warn("{}\n", run());
}
test "078" {
debug.assert(run() == 55374);
}
|
zig/src/078.zig
|
const std = @import("std");
const pagez = @import("pagez");
const gui = @import("gui");
const fs = std.fs;
const mem = std.mem;
const max = std.math.max;
const print = std.debug.print;
const Thread = std.Thread;
const Point = pagez.Point;
const Position = pagez.Position;
const Size = pagez.Size;
const expect = std.testing.expect;
const Mouse = pagez.Mouse;
const sleep = std.time.sleep;
//pub const io_mode = .evented;
pub fn main() !void {
try pagez.init();
try draw();
try pagez.flush();
_ = try Thread.spawn(handleInput, 0);
var pos = center();
cursor_color = gui.white();
updateCursor(pos);
var time = std.time.milliTimestamp();
while (!m.rmb) {
if (!isIdle(m)) {
drawCursorBackground(pos, true);
pos = updatePos(pos);
m.dx = 0;
m.dy = 0;
updateCursor(pos);
}
var dt = std.time.milliTimestamp() - time;
if (dt > 850) {
drawCursorBackground(pos, false);
cursor_color = if (cursor_color[0] == 0) gui.white() else gui.black();
updateCursor(pos);
time = std.time.milliTimestamp();
}
std.time.sleep(50000000);
}
pagez.exit();
}
fn updateCursor(pos: Position) void {
drawCursor(pos, true) catch |err| {
print("drawCursor({s}) error: {s}\n", .{ pos, err });
};
}
inline fn isIdle(mouse: Mouse) bool {
return mouse.dx == 0 and mouse.dy == 0;
}
fn center() Position {
return Position{ .x = pagez.display_size.x / 2, .y = pagez.display_size.y / 2 };
}
const cursor_dots = 8;
const cursor_bytes = cursor_dots * 4;
fn cursorBackground() [cursor_bytes]u8 {
return @splat(cursor_bytes, @as(u8, 0));
}
const cursor_radius = 3;
var bg = cursorBackground();
const dots = [_]Point{
Point{ .x = 2, .y = 0 }, Point{ .x = 3, .y = 0 },
Point{ .x = 4, .y = 0 }, Point{ .x = 5, .y = 0 },
Point{ .x = 0, .y = 2 }, Point{ .x = 0, .y = 3 },
Point{ .x = 0, .y = 4 }, Point{ .x = 0, .y = 5 },
};
var cursor_color: [4]u8 = undefined;
fn drawCursor(pos: Position, flush: bool) !void {
for (dots) |dot, index| {
const p = Position{
.x = @intCast(u16, @intCast(i16, pos.x) + dot.x),
.y = @intCast(u16, @intCast(i16, pos.y) + dot.y),
};
saveBgColorAt(p, index * 4);
gui.pixel(cursor_color, p);
if (flush) {
try pagez.flushData(&cursor_color, gui.calcOffset(p));
}
}
}
inline fn saveBgColorAt(pos: Position, offset: usize) void {
const c = gui.colorAt(pos);
var i: u8 = 0;
while (i < pagez.bytes_per_pixel) : (i += 1) bg[offset + i] = c[i];
}
inline fn cursorBackgroundColor(offset: usize) [4]u8 {
var i: u8 = 0;
var c: [4]u8 = undefined;
while (i < pagez.bytes_per_pixel) : (i += 1) c[i] = bg[offset + i];
return c;
}
fn drawCursorBackground(pos: Position, flush: bool) void {
for (dots) |dot, index| {
const p = Position{
.x = @intCast(u16, @intCast(i16, pos.x) + dot.x),
.y = @intCast(u16, @intCast(i16, pos.y) + dot.y),
};
var bgColor: [4]u8 = cursorBackgroundColor(index * pagez.bytes_per_pixel);
gui.pixel(bgColor, p);
if (flush) {
pagez.flushData(bgColor[0..pagez.bytes_per_pixel], gui.calcOffset(p)) catch |err| {
print("drawCursorBackground() error: {s}\n", .{err});
};
}
}
}
var m: Mouse = undefined;
fn handleInput(num: u8) u8 {
while (true) {
m = pagez.readMouse() catch |err| {
print("readMouse() error: {s}\n", .{err});
return 1;
};
}
return num;
}
fn updatePos(pos: Position) Position {
var result = Position{ .x = @intCast(u16, max(0, (@intCast(i16, pos.x) + @intCast(i16, m.dx)))), .y = @intCast(u16, max(0, (@intCast(i16, pos.y) + @intCast(i16, m.dy) * -1))) };
if (result.x < cursor_radius) {
result.x = cursor_radius;
}
if (result.x + cursor_radius >= pagez.display_size.x) {
result.x = pagez.display_size.x - cursor_radius;
}
if (result.y < cursor_radius) {
result.y = cursor_radius;
}
if (result.y + cursor_radius + 1 >= pagez.display_size.y) {
result.x = pagez.display_size.y - cursor_radius - 1;
}
return result;
}
fn draw() !void {
pagez.clear(gui.gray(), pagez.bytes_per_pixel);
gui.box(gui.white(), Position{ .x = pagez.display_size.x / 2 - 50, .y = pagez.display_size.y / 2 - 4 }, Size{ .x = 8, .y = 8 });
gui.box(gui.white(), Position{ .x = pagez.display_size.x / 2 + 50, .y = pagez.display_size.y / 2 - 4 }, Size{ .x = 8, .y = 8 });
gui.box(gui.red(), Position{ .x = pagez.display_size.x / 2 - 25, .y = pagez.display_size.y / 2 - 4 }, Size{ .x = 8, .y = 8 });
gui.box(gui.red(), Position{ .x = pagez.display_size.x / 2 + 25, .y = pagez.display_size.y / 2 - 4 }, Size{ .x = 8, .y = 8 });
}
|
src/main.zig
|
const builtin = @import("builtin");
const clap = @import("clap");
const std = @import("std");
const util = @import("util");
const common = @import("common.zig");
const gen3 = @import("gen3.zig");
const rom = @import("rom.zig");
const debug = std.debug;
const fs = std.fs;
const heap = std.heap;
const io = std.io;
const math = std.math;
const mem = std.mem;
const testing = std.testing;
const gba = rom.gba;
const offsets = gen3.offsets;
const li16 = rom.int.li16;
const lu16 = rom.int.lu16;
const lu32 = rom.int.lu32;
const lu64 = rom.int.lu64;
const Program = @This();
allocator: mem.Allocator,
files: []const []const u8,
pub const main = util.generateMain(Program);
pub const version = "0.0.0";
pub const description =
\\Finds the offsets of specific structures in a gen3 rom and writes those offsets to stdout.
\\
;
pub const params = &[_]clap.Param(clap.Help){
clap.parseParam("-h, --help Display this help text and exit. ") catch unreachable,
clap.parseParam("-v, --version Output version information and exit.") catch unreachable,
clap.parseParam("<ROM>") catch unreachable,
};
pub fn init(allocator: mem.Allocator, args: anytype) !Program {
return Program{ .allocator = allocator, .files = args.positionals() };
}
pub fn run(
program: *Program,
comptime Reader: type,
comptime Writer: type,
stdio: util.CustomStdIoStreams(Reader, Writer),
) anyerror!void {
const allocator = program.allocator;
for (program.files) |file_name, i| {
const data = try fs.cwd().readFileAlloc(allocator, file_name, math.maxInt(usize));
defer allocator.free(data);
if (data.len < @sizeOf(gba.Header))
return error.FileToSmall;
const header = mem.bytesAsSlice(gba.Header, data[0..@sizeOf(gba.Header)])[0];
const v = try getVersion(&header.gamecode);
const info = try getOffsets(
data,
v,
header.gamecode,
header.game_title,
header.software_version,
);
try outputInfo(stdio.out, i, info);
}
}
fn outputInfo(writer: anytype, i: usize, info: offsets.Info) !void {
try writer.print(".game[{}].game_title={}\n", .{ i, info.game_title });
try writer.print(".game[{}].gamecode={s}\n", .{ i, info.gamecode });
try writer.print(".game[{}].version={s}\n", .{ i, @tagName(info.version) });
try writer.print(".game[{}].software_version={}\n", .{ i, info.software_version });
try writer.print(".game[{}].text_delays.start={}\n", .{ i, info.text_delays.start });
try writer.print(".game[{}].text_delays.len={}\n", .{ i, info.text_delays.len });
try writer.print(".game[{}].trainers.start={}\n", .{ i, info.trainers.start });
try writer.print(".game[{}].trainers.len={}\n", .{ i, info.trainers.len });
try writer.print(".game[{}].moves.start={}\n", .{ i, info.moves.start });
try writer.print(".game[{}].moves.len={}\n", .{ i, info.moves.len });
try writer.print(".game[{}].machine_learnsets.start={}\n", .{ i, info.machine_learnsets.start });
try writer.print(".game[{}].machine_learnsets.len={}\n", .{ i, info.machine_learnsets.len });
try writer.print(".game[{}].pokemons.start={}\n", .{ i, info.pokemons.start });
try writer.print(".game[{}].pokemons.len={}\n", .{ i, info.pokemons.len });
try writer.print(".game[{}].evolutions.start={}\n", .{ i, info.evolutions.start });
try writer.print(".game[{}].evolutions.len={}\n", .{ i, info.evolutions.len });
try writer.print(".game[{}].level_up_learnset_pointers.start={}\n", .{ i, info.level_up_learnset_pointers.start });
try writer.print(".game[{}].level_up_learnset_pointers.len={}\n", .{ i, info.level_up_learnset_pointers.len });
try writer.print(".game[{}].hms.start={}\n", .{ i, info.hms.start });
try writer.print(".game[{}].hms.len={}\n", .{ i, info.hms.len });
try writer.print(".game[{}].tms.start={}\n", .{ i, info.tms.start });
try writer.print(".game[{}].tms.len={}\n", .{ i, info.tms.len });
try writer.print(".game[{}].items.start={}\n", .{ i, info.items.start });
try writer.print(".game[{}].items.len={}\n", .{ i, info.items.len });
try writer.print(".game[{}].wild_pokemon_headers.start={}\n", .{ i, info.wild_pokemon_headers.start });
try writer.print(".game[{}].wild_pokemon_headers.len={}\n", .{ i, info.wild_pokemon_headers.len });
try writer.print(".game[{}].map_headers.start={}\n", .{ i, info.map_headers.start });
try writer.print(".game[{}].map_headers.len={}\n", .{ i, info.map_headers.len });
try writer.print(".game[{}].pokemon_names.start={}\n", .{ i, info.pokemon_names.start });
try writer.print(".game[{}].pokemon_names.len={}\n", .{ i, info.pokemon_names.len });
try writer.print(".game[{}].ability_names.start={}\n", .{ i, info.ability_names.start });
try writer.print(".game[{}].ability_names.len={}\n", .{ i, info.ability_names.len });
try writer.print(".game[{}].move_names.start={}\n", .{ i, info.move_names.start });
try writer.print(".game[{}].move_names.len={}\n", .{ i, info.move_names.len });
try writer.print(".game[{}].type_names.start={}\n", .{ i, info.type_names.start });
try writer.print(".game[{}].type_names.len={}\n", .{ i, info.type_names.len });
try writer.print(".game[{}].species_to_national_dex.start={}\n", .{ i, info.species_to_national_dex.start });
try writer.print(".game[{}].species_to_national_dex.len={}\n", .{ i, info.species_to_national_dex.len });
switch (info.version) {
.emerald => {
try writer.print(".game[{}].pokedex.start={}\n", .{ i, info.pokedex.emerald.start });
try writer.print(".game[{}].pokedex.len={}\n", .{ i, info.pokedex.emerald.len });
},
.ruby,
.sapphire,
.fire_red,
.leaf_green,
=> {
try writer.print(".game[{}].pokedex.start={}\n", .{ i, info.pokedex.rsfrlg.start });
try writer.print(".game[{}].pokedex.len={}\n", .{ i, info.pokedex.rsfrlg.len });
},
else => unreachable,
}
}
fn getVersion(gamecode: []const u8) !common.Version {
if (mem.startsWith(u8, gamecode, "BPE"))
return .emerald;
if (mem.startsWith(u8, gamecode, "BPR"))
return .fire_red;
if (mem.startsWith(u8, gamecode, "BPG"))
return .leaf_green;
if (mem.startsWith(u8, gamecode, "AXV"))
return .ruby;
if (mem.startsWith(u8, gamecode, "AXP"))
return .sapphire;
return error.UnknownPokemonVersion;
}
fn getOffsets(
data: []u8,
game_version: common.Version,
gamecode: [4]u8,
game_title: util.TerminatedArray(12, u8, 0),
software_version: u8,
) !gen3.offsets.Info {
// TODO: A way to find starter pokemons
const Trainers = Searcher(gen3.Trainer, &[_][]const []const u8{
&[_][]const u8{"party"},
&[_][]const u8{"name"},
});
const Moves = Searcher(gen3.Move, &[_][]const []const u8{});
const Machines = Searcher(lu64, &[_][]const []const u8{});
const Pokemons = Searcher(gen3.BasePokemon, &[_][]const []const u8{
&[_][]const u8{"padding"},
&[_][]const u8{"egg_group1_pad"},
&[_][]const u8{"egg_group2_pad"},
});
const Evos = Searcher([5]gen3.Evolution, &[_][]const []const u8{&[_][]const u8{"padding"}});
const LvlUpMoves = Searcher(u8, &[_][]const []const u8{});
const HmTms = Searcher(lu16, &[_][]const []const u8{});
const SpeciesToNationalDex = HmTms;
const Items = Searcher(gen3.Item, &[_][]const []const u8{
&[_][]const u8{"name"},
&[_][]const u8{"description"},
&[_][]const u8{"field_use_func"},
&[_][]const u8{"battle_use_func"},
});
const EmeraldPokedex = Searcher(gen3.EmeraldPokedexEntry, &[_][]const []const u8{
&[_][]const u8{"category_name"},
&[_][]const u8{"description"},
&[_][]const u8{"unused"},
&[_][]const u8{"padding"},
});
const RSFrLgPokedex = Searcher(gen3.RSFrLgPokedexEntry, &[_][]const []const u8{
&[_][]const u8{"category_name"},
&[_][]const u8{"description"},
&[_][]const u8{"unused_description"},
&[_][]const u8{"unused"},
&[_][]const u8{"padding"},
});
const WildPokemonHeaders = Searcher(gen3.WildPokemonHeader, &[_][]const []const u8{
&[_][]const u8{"pad"},
&[_][]const u8{"land"},
&[_][]const u8{"surf"},
&[_][]const u8{"rock_smash"},
&[_][]const u8{"fishing"},
});
const MapHeaders = Searcher(gen3.MapHeader, &[_][]const []const u8{
&[_][]const u8{"map_layout"},
&[_][]const u8{"map_events"},
&[_][]const u8{"map_scripts"},
&[_][]const u8{"map_connections"},
&[_][]const u8{"pad"},
});
const LvlUpRef = gen3.Ptr([*]gen3.LevelUpMove);
const LvlUpRefs = Searcher(LvlUpRef, &[_][]const []const u8{});
const PokemonNames = Searcher([11]u8, &[_][]const []const u8{});
const AbilityNames = Searcher([13]u8, &[_][]const []const u8{});
const MoveNames = Searcher([13]u8, &[_][]const []const u8{});
const TypeNames = Searcher([7]u8, &[_][]const []const u8{});
const Strings = Searcher(u8, &[_][]const []const u8{});
const text_delay = switch (game_version) {
.emerald,
.fire_red,
.leaf_green,
=> (try Strings.find2(data, "\x00\x08\x04\x01\x00"))[1..4],
.ruby,
.sapphire,
=> (try Strings.find2(data, "\x00\x06\x03\x01"))[1..4],
else => unreachable,
};
const trainers = switch (game_version) {
.emerald => try Trainers.find4(data, &em_first_trainers, &em_last_trainers),
.ruby,
.sapphire,
=> try Trainers.find4(data, &rs_first_trainers, &rs_last_trainers),
.fire_red,
.leaf_green,
=> try Trainers.find4(data, &frls_first_trainers, &frls_last_trainers),
else => unreachable,
};
const moves = try Moves.find4(data, &first_moves, &last_moves);
const machine_learnset = try Machines.find4(data, &first_machine_learnsets, &last_machine_learnsets);
const pokemons = try Pokemons.find4(data, &first_pokemons, &last_pokemons);
const evolution_table = try Evos.find4(data, &first_evolutions, &last_evolutions);
const level_up_learnset_pointers = blk: {
var first_pointers: [first_levelup_learnsets.len]LvlUpRef = undefined;
for (first_levelup_learnsets) |learnset, i| {
const p = try LvlUpMoves.find2(data, learnset);
first_pointers[i] = try LvlUpRef.init(p.ptr, data);
}
var last_pointers: [last_levelup_learnsets.len]LvlUpRef = undefined;
for (last_levelup_learnsets) |learnset, i| {
const p = try LvlUpMoves.find2(data, learnset);
last_pointers[i] = try LvlUpRef.init(p.ptr, data);
}
break :blk try LvlUpRefs.find4(data, &first_pointers, &last_pointers);
};
const pokemon_names = try PokemonNames.find4(data, &first_pokemon_names, &last_pokemon_names);
const ability_names = try AbilityNames.find4(data, &first_ability_names, &last_ability_names);
const move_names = switch (game_version) {
.emerald => try MoveNames.find4(data, &e_first_move_names, &last_move_names),
.ruby,
.sapphire,
.fire_red,
.leaf_green,
=> try MoveNames.find4(data, &rsfrlg_first_move_names, &last_move_names),
else => unreachable,
};
const type_names_slice = try TypeNames.find2(data, &type_names);
const hms_slice = try HmTms.find2(data, &hms);
// TODO: Pokemon Emerald have 2 tm tables. I'll figure out some hack for that
// if it turns out that both tables are actually used. For now, I'll
// assume that the first table is the only one used.
const tms_slice = try HmTms.find2(data, &tms);
const species_to_national_dex = try SpeciesToNationalDex.find4(
data,
&species_to_national_dex_start,
&species_to_national_dex_end,
);
const pokedex: gen3.Pokedex = switch (game_version) {
.emerald => .{
.emerald = try EmeraldPokedex.find4(data, &emerald_pokedex_start, &emerald_pokedex_end),
},
.ruby,
.sapphire,
=> .{
.rsfrlg = try RSFrLgPokedex.find4(data, &rs_pokedex_start, &rs_pokedex_end),
},
.fire_red,
.leaf_green,
=> .{
.rsfrlg = try RSFrLgPokedex.find4(data, &frlg_pokedex_start, &frlg_pokedex_end),
},
else => unreachable,
};
const items = switch (game_version) {
.emerald => try Items.find4(data, &em_first_items, &em_last_items),
.ruby,
.sapphire,
=> try Items.find4(data, &rs_first_items, &rs_last_items),
.fire_red,
.leaf_green,
=> try Items.find4(data, &frlg_first_items, &frlg_last_items),
else => unreachable,
};
const wild_pokemon_headers = switch (game_version) {
.emerald => try WildPokemonHeaders.find4(data, &em_first_wild_mon_headers, &em_last_wild_mon_headers),
.ruby,
.sapphire,
=> try WildPokemonHeaders.find4(data, &rs_first_wild_mon_headers, &rs_last_wild_mon_headers),
.fire_red,
.leaf_green,
=> try WildPokemonHeaders.find4(data, &frlg_first_wild_mon_headers, &frlg_last_wild_mon_headers),
else => unreachable,
};
const map_headers = switch (game_version) {
.emerald => try MapHeaders.find4(data, &em_first_map_headers, &em_last_map_headers),
.ruby,
.sapphire,
=> try MapHeaders.find4(data, &rs_first_map_headers, &rs_last_map_headers),
.fire_red,
.leaf_green,
=> try MapHeaders.find4(data, &frlg_first_map_headers, &frlg_last_map_headers),
else => unreachable,
};
return offsets.Info{
.game_title = game_title,
.gamecode = gamecode,
.version = game_version,
.software_version = software_version,
.starters = undefined,
.starters_repeat = undefined,
.text_delays = offsets.TextDelaySection.init(data, text_delay),
.trainers = offsets.TrainerSection.init(data, trainers),
.moves = offsets.MoveSection.init(data, moves),
.machine_learnsets = offsets.MachineLearnsetSection.init(data, machine_learnset),
.pokemons = offsets.BaseStatsSection.init(data, pokemons),
.evolutions = offsets.EvolutionSection.init(data, evolution_table),
.level_up_learnset_pointers = offsets.LevelUpLearnsetPointerSection.init(data, level_up_learnset_pointers),
.type_effectiveness = undefined,
.hms = offsets.HmSection.init(data, hms_slice),
.tms = offsets.TmSection.init(data, tms_slice),
.pokedex = switch (game_version) {
.emerald => .{
.emerald = offsets.EmeraldPokedexSection.init(data, pokedex.emerald),
},
.ruby,
.sapphire,
.fire_red,
.leaf_green,
=> .{
.rsfrlg = offsets.RSFrLgPokedexSection.init(data, pokedex.rsfrlg),
},
else => unreachable,
},
.species_to_national_dex = offsets.SpeciesToNationalDexSection.init(data, species_to_national_dex),
.items = offsets.ItemSection.init(data, items),
.wild_pokemon_headers = offsets.WildPokemonHeaderSection.init(data, wild_pokemon_headers),
.map_headers = offsets.MapHeaderSection.init(data, map_headers),
.pokemon_names = offsets.PokemonNameSection.init(data, pokemon_names),
.ability_names = offsets.AbilityNameSection.init(data, ability_names),
.move_names = offsets.MoveNameSection.init(data, move_names),
.type_names = offsets.TypeNameSection.init(data, type_names_slice),
};
}
// A type for searching binary data for instances of ::T. It also allows ignoring of certain
// fields and nested fields.
pub fn Searcher(comptime T: type, comptime ignored_fields: []const []const []const u8) type {
return struct {
pub fn find1(data: []u8, item: T) !*T {
const slice = try find2(data, &[_]T{item});
return &slice[0];
}
pub fn find2(data: []u8, items: []const T) ![]T {
return find4(data, items, &[_]T{});
}
pub fn find3(data: []u8, start: T, end: T) ![]T {
return find4(data, &[_]T{start}, &[_]T{end});
}
pub fn find4(data: []u8, start: []const T, end: []const T) ![]T {
const found_start = try findSliceHelper(data, 0, 1, start);
const start_offset = @ptrToInt(found_start.ptr);
const next_offset = (start_offset - @ptrToInt(data.ptr)) + start.len * @sizeOf(T);
const found_end = try findSliceHelper(data, next_offset, @sizeOf(T), end);
const end_offset = @ptrToInt(found_end.ptr) + found_end.len * @sizeOf(T);
const len = @divExact(end_offset - start_offset, @sizeOf(T));
return found_start.ptr[0..len];
}
fn findSliceHelper(data: []u8, offset: usize, skip: usize, items: []const T) ![]T {
const bytes = items.len * @sizeOf(T);
if (data.len < bytes)
return error.DataNotFound;
var i: usize = offset;
const end = data.len - bytes;
next: while (i <= end) : (i += skip) {
const data_slice = data[i .. i + bytes];
const data_items = mem.bytesAsSlice(T, data_slice);
for (items) |item_a, j| {
const item_b = data_items[j];
if (!matches(T, ignored_fields, item_a, item_b))
continue :next;
}
// HACK: mem.bytesAsSlice does not return a pointer to the original data, if
// the length of the data passed in is 0. I need the pointer to point into
// `data_slice` so I bypass `data_items` here. I feel like this is a design
// mistake by the Zig `std`.
return @ptrCast([*]T, data_slice.ptr)[0..data_items.len];
}
return error.DataNotFound;
}
};
}
fn matches(comptime T: type, comptime ignored_fields: []const []const []const u8, a: T, b: T) bool {
const info = @typeInfo(T);
if (ignored_fields.len == 0)
return mem.eql(u8, &mem.toBytes(a), &mem.toBytes(b));
switch (info) {
.Array => |array| {
if (a.len != b.len)
return false;
for (a) |_, i| {
if (!matches(array.child, ignored_fields, a[i], b[i]))
return false;
}
return true;
},
.Optional => |optional| {
const a_value = a orelse {
return if (b) |_| false else true;
};
const b_value = b orelse return false;
return matches(optional.child, ignored_fields, a_value, b_value);
},
.ErrorUnion => |err_union| {
const a_value = a catch |a_err| {
if (b) |_| {
return false;
} else |b_err| {
return matches(err_union.error_set, ignored_fields, a_err, b_err);
}
};
const b_value = b catch return false;
return matches(err_union.payload, ignored_fields, a_value, b_value);
},
.Struct => |struct_info| {
const next_ignored = comptime blk: {
var res: []const []const []const u8 = &[_][]const []const u8{};
for (ignored_fields) |fields| {
if (fields.len > 1)
res = res ++ fields[1..];
}
break :blk res;
};
ignore: inline for (struct_info.fields) |field| {
inline for (ignored_fields) |fields| {
if (comptime fields.len == 1 and mem.eql(u8, fields[0], field.name))
continue :ignore;
}
if (!matches(field.field_type, next_ignored, @field(a, field.name), @field(b, field.name)))
return false;
}
return true;
},
.Union => |union_info| {
const first_field = union_info.fields[0];
comptime {
// Only allow comparing unions that have all fields of the same
// size.
const size = @sizeOf(first_field.field_type);
for (union_info.fields) |f|
debug.assert(@sizeOf(f.field_type) == size);
}
return matches(first_field.field_type, ignored_fields, @field(a, first_field.name), @field(b, first_field.name));
},
else => return mem.eql(u8, &mem.toBytes(a), &mem.toBytes(b)),
}
}
test "searcher.Searcher.find" {
const S = packed struct {
a: u16,
b: u32,
};
var s_array = [_]S{
S{ .a = 0, .b = 1 },
S{ .a = 2, .b = 3 },
};
const data = mem.sliceAsBytes(s_array[0..]);
const S1 = Searcher(S, &[_][]const []const u8{
&[_][]const u8{"a"},
});
const S2 = Searcher(S, &[_][]const []const u8{
&[_][]const u8{"b"},
});
const search_for = S{ .a = 0, .b = 3 };
try testing.expectEqual(try S1.find1(data, search_for), &s_array[1]);
try testing.expectEqual(try S2.find1(data, search_for), &s_array[0]);
}
test "searcher.Searcher.find2" {
const S = packed struct {
a: u16,
b: u32,
};
var s_array = [_]S{
S{ .a = 4, .b = 1 },
S{ .a = 0, .b = 3 },
S{ .a = 4, .b = 1 },
};
const data = mem.sliceAsBytes(s_array[0..]);
const S1 = Searcher(S, &[_][]const []const u8{
&[_][]const u8{"a"},
});
const S2 = Searcher(S, &[_][]const []const u8{
&[_][]const u8{"b"},
});
const search_for = &[_]S{
S{ .a = 4, .b = 3 },
S{ .a = 0, .b = 1 },
};
try testing.expectEqualSlices(
u8,
mem.sliceAsBytes(s_array[1..3]),
mem.sliceAsBytes(try S1.find2(data, search_for)),
);
try testing.expectEqualSlices(
u8,
mem.sliceAsBytes(s_array[0..2]),
mem.sliceAsBytes(try S2.find2(data, search_for)),
);
}
test "searcher.Searcher.find3" {
const S = packed struct {
a: u16,
b: u32,
};
var s_array = [_]S{
S{ .a = 4, .b = 1 },
S{ .a = 0, .b = 3 },
S{ .a = 4, .b = 1 },
S{ .a = 0, .b = 3 },
};
const data = mem.sliceAsBytes(s_array[0..]);
const S1 = Searcher(S, &[_][]const []const u8{
&[_][]const u8{"a"},
});
const S2 = Searcher(S, &[_][]const []const u8{
&[_][]const u8{"b"},
});
const a = S{ .a = 4, .b = 3 };
const b = S{ .a = 4, .b = 3 };
try testing.expectEqualSlices(
u8,
mem.sliceAsBytes(s_array[1..4]),
mem.sliceAsBytes(try S1.find3(data, a, b)),
);
try testing.expectEqualSlices(
u8,
mem.sliceAsBytes(s_array[0..3]),
mem.sliceAsBytes(try S2.find3(data, a, b)),
);
}
test "searcher.Searcher.find4" {
const S = packed struct {
a: u16,
b: u32,
};
var s_array = [_]S{
S{ .a = 4, .b = 1 },
S{ .a = 0, .b = 3 },
S{ .a = 4, .b = 1 },
S{ .a = 0, .b = 3 },
S{ .a = 4, .b = 1 },
S{ .a = 0, .b = 3 },
};
const data = mem.sliceAsBytes(s_array[0..]);
const S1 = Searcher(S, &[_][]const []const u8{
&[_][]const u8{"a"},
});
const S2 = Searcher(S, &[_][]const []const u8{
&[_][]const u8{"b"},
});
const a = [_]S{
S{ .a = 4, .b = 3 },
S{ .a = 0, .b = 1 },
};
const b = [_]S{
S{ .a = 0, .b = 1 },
S{ .a = 4, .b = 3 },
};
try testing.expectEqualSlices(
u8,
mem.sliceAsBytes(s_array[1..6]),
mem.sliceAsBytes(try S1.find4(data, &a, &b)),
);
try testing.expectEqualSlices(
u8,
mem.sliceAsBytes(s_array[0..5]),
mem.sliceAsBytes(try S2.find4(data, &a, &b)),
);
}
const em_first_trainers = [_]gen3.Trainer{
gen3.Trainer{
.party_type = .none,
.class = 0,
.encounter_music = .{
.gender = .male,
.music = 0,
},
.trainer_picture = 0,
.name = undefined,
.items = [_]lu16{ lu16.init(0), lu16.init(0), lu16.init(0), lu16.init(0) },
.is_double = lu32.init(0),
.ai = lu32.init(0),
.party = undefined,
},
gen3.Trainer{
.party_type = .none,
.class = 0x02,
.encounter_music = .{
.gender = .male,
.music = 0x0b,
},
.trainer_picture = 0,
.name = undefined,
.items = [_]lu16{ lu16.init(0), lu16.init(0), lu16.init(0), lu16.init(0) },
.is_double = lu32.init(0),
.ai = lu32.init(7),
.party = undefined,
},
};
const em_last_trainers = [_]gen3.Trainer{gen3.Trainer{
.party_type = .none,
.class = 0x41,
.encounter_music = .{
.gender = .female,
.music = 0x00,
},
.trainer_picture = 0x5c,
.name = undefined,
.items = [_]lu16{ lu16.init(0), lu16.init(0), lu16.init(0), lu16.init(0) },
.is_double = lu32.init(0),
.ai = lu32.init(0),
.party = undefined,
}};
const rs_first_trainers = [_]gen3.Trainer{
gen3.Trainer{
.party_type = .none,
.class = 0,
.encounter_music = .{
.gender = .male,
.music = 0x00,
},
.trainer_picture = 0,
.name = undefined,
.items = [_]lu16{ lu16.init(0), lu16.init(0), lu16.init(0), lu16.init(0) },
.is_double = lu32.init(0),
.ai = lu32.init(0),
.party = undefined,
},
gen3.Trainer{
.party_type = .none,
.class = 0x02,
.encounter_music = .{
.gender = .male,
.music = 0x06,
},
.trainer_picture = 0x46,
.name = undefined,
.items = [_]lu16{ lu16.init(0x16), lu16.init(0x16), lu16.init(0), lu16.init(0) },
.is_double = lu32.init(0),
.ai = lu32.init(7),
.party = undefined,
},
};
const rs_last_trainers = [_]gen3.Trainer{gen3.Trainer{
.party_type = .none,
.class = 0x21,
.encounter_music = .{
.gender = .male,
.music = 0x0b,
},
.trainer_picture = 0x06,
.name = undefined,
.items = [_]lu16{ lu16.init(0), lu16.init(0), lu16.init(0), lu16.init(0) },
.is_double = lu32.init(0),
.ai = lu32.init(1),
.party = undefined,
}};
const frls_first_trainers = [_]gen3.Trainer{
gen3.Trainer{
.party_type = .none,
.class = 0,
.encounter_music = .{
.gender = .male,
.music = 0x00,
},
.trainer_picture = 0,
.name = undefined,
.items = [_]lu16{
lu16.init(0),
lu16.init(0),
lu16.init(0),
lu16.init(0),
},
.is_double = lu32.init(0),
.ai = lu32.init(0),
.party = undefined,
},
gen3.Trainer{
.party_type = .none,
.class = 2,
.encounter_music = .{
.gender = .male,
.music = 0x06,
},
.trainer_picture = 0,
.name = undefined,
.items = [_]lu16{
lu16.init(0),
lu16.init(0),
lu16.init(0),
lu16.init(0),
},
.is_double = lu32.init(0),
.ai = lu32.init(1),
.party = undefined,
},
};
const frls_last_trainers = [_]gen3.Trainer{
gen3.Trainer{
.party_type = .both,
.class = 90,
.encounter_music = .{
.gender = .male,
.music = 0x00,
},
.trainer_picture = 125,
.name = undefined,
.items = [_]lu16{
lu16.init(19),
lu16.init(19),
lu16.init(19),
lu16.init(19),
},
.is_double = lu32.init(0),
.ai = lu32.init(7),
.party = undefined,
},
gen3.Trainer{
.party_type = .none,
.class = 0x47,
.encounter_music = .{
.gender = .male,
.music = 0x00,
},
.trainer_picture = 0x60,
.name = undefined,
.items = [_]lu16{
lu16.init(0),
lu16.init(0),
lu16.init(0),
lu16.init(0),
},
.is_double = lu32.init(0),
.ai = lu32.init(1),
.party = undefined,
},
};
const first_moves = [_]gen3.Move{
// Dummy
gen3.Move{
.effect = 0,
.power = 0,
.@"type" = 0,
.accuracy = 0,
.pp = 0,
.side_effect_chance = 0,
.target = 0,
.priority = 0,
.flags0 = 0,
.flags1 = 0,
.flags2 = 0,
.category = .physical,
},
// Pound
gen3.Move{
.effect = 0,
.power = 40,
.@"type" = 0,
.accuracy = 100,
.pp = 35,
.side_effect_chance = 0,
.target = 0,
.priority = 0,
.flags0 = 0x33,
.flags1 = 0,
.flags2 = 0,
.category = .physical,
},
};
const last_moves = [_]gen3.Move{
// Psycho Boost
gen3.Move{
.effect = 204,
.power = 140,
.@"type" = 14,
.accuracy = 90,
.pp = 5,
.side_effect_chance = 100,
.target = 0,
.priority = 0,
.flags0 = 0x32,
.flags1 = 0,
.flags2 = 0,
.category = .physical,
}};
const first_machine_learnsets = [_]lu64{
lu64.init(0x0000000000000000), // Dummy Pokemon
lu64.init(0x00e41e0884350720), // Bulbasaur
lu64.init(0x00e41e0884350720), // Ivysaur
lu64.init(0x00e41e0886354730), // Venusaur
};
const last_machine_learnsets = [_]lu64{
lu64.init(0x035c5e93b7bbd63e), // Latios
lu64.init(0x00408e93b59bc62c), // Jirachi
lu64.init(0x00e58fc3f5bbde2d), // Deoxys
lu64.init(0x00419f03b41b8e28), // Chimecho
};
const first_pokemons = [_]gen3.BasePokemon{
// Dummy
gen3.BasePokemon{
.stats = common.Stats{
.hp = 0,
.attack = 0,
.defense = 0,
.speed = 0,
.sp_attack = 0,
.sp_defense = 0,
},
.types = [_]u8{ 0, 0 },
.catch_rate = 0,
.base_exp_yield = 0,
.ev_yield = common.EvYield{
.hp = 0,
.attack = 0,
.defense = 0,
.speed = 0,
.sp_attack = 0,
.sp_defense = 0,
},
.items = [_]lu16{ lu16.init(0), lu16.init(0) },
.gender_ratio = 0,
.egg_cycles = 0,
.base_friendship = 0,
.growth_rate = .medium_fast,
.egg_groups = [_]common.EggGroup{ .invalid, .invalid },
.abilities = [_]u8{ 0, 0 },
.safari_zone_rate = 0,
.color = common.Color{
.color = .red,
.flip = false,
},
.padding = undefined,
},
// Bulbasaur
gen3.BasePokemon{
.stats = common.Stats{
.hp = 45,
.attack = 49,
.defense = 49,
.speed = 45,
.sp_attack = 65,
.sp_defense = 65,
},
.types = [_]u8{ 12, 3 },
.catch_rate = 45,
.base_exp_yield = 64,
.ev_yield = common.EvYield{
.hp = 0,
.attack = 0,
.defense = 0,
.speed = 0,
.sp_attack = 1,
.sp_defense = 0,
},
.items = [_]lu16{ lu16.init(0), lu16.init(0) },
.gender_ratio = percentFemale(12.5),
.egg_cycles = 20,
.base_friendship = 70,
.growth_rate = .medium_slow,
.egg_groups = [_]common.EggGroup{ .monster, .grass },
.abilities = [_]u8{ 65, 0 },
.safari_zone_rate = 0,
.color = common.Color{
.color = .green,
.flip = false,
},
.padding = undefined,
},
};
const last_pokemons = [_]gen3.BasePokemon{
// Chimecho
gen3.BasePokemon{
.stats = common.Stats{
.hp = 65,
.attack = 50,
.defense = 70,
.speed = 65,
.sp_attack = 95,
.sp_defense = 80,
},
.types = [_]u8{ 14, 14 },
.catch_rate = 45,
.base_exp_yield = 147,
.ev_yield = common.EvYield{
.hp = 0,
.attack = 0,
.defense = 0,
.speed = 0,
.sp_attack = 1,
.sp_defense = 1,
},
.items = [_]lu16{ lu16.init(0), lu16.init(0) },
.gender_ratio = percentFemale(50),
.egg_cycles = 25,
.base_friendship = 70,
.growth_rate = .fast,
.egg_groups = [_]common.EggGroup{ .amorphous, .amorphous },
.abilities = [_]u8{ 26, 0 },
.safari_zone_rate = 0,
.color = common.Color{
.color = .blue,
.flip = false,
},
.padding = undefined,
}};
pub const species_to_national_dex_start = [_]lu16{
lu16.init(1),
lu16.init(2),
lu16.init(3),
lu16.init(4),
lu16.init(5),
lu16.init(6),
lu16.init(7),
lu16.init(8),
lu16.init(9),
lu16.init(10),
lu16.init(11),
lu16.init(12),
lu16.init(13),
lu16.init(14),
lu16.init(15),
lu16.init(16),
lu16.init(17),
lu16.init(18),
lu16.init(19),
lu16.init(20),
lu16.init(21),
lu16.init(22),
lu16.init(23),
lu16.init(24),
lu16.init(25),
lu16.init(26),
lu16.init(27),
lu16.init(28),
lu16.init(29),
lu16.init(30),
lu16.init(31),
lu16.init(32),
lu16.init(33),
lu16.init(34),
lu16.init(35),
lu16.init(36),
lu16.init(37),
lu16.init(38),
lu16.init(39),
};
pub const species_to_national_dex_end = [_]lu16{
lu16.init(378),
lu16.init(379),
lu16.init(382),
lu16.init(383),
lu16.init(384),
lu16.init(380),
lu16.init(381),
lu16.init(385),
lu16.init(386),
lu16.init(358),
};
pub const emerald_pokedex_start = [_]gen3.EmeraldPokedexEntry{
gen3.EmeraldPokedexEntry{
.category_name = undefined,
.height = lu16.init(0),
.weight = lu16.init(0),
.description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(256),
.pokemon_offset = li16.init(0),
.trainer_scale = lu16.init(256),
.trainer_offset = li16.init(0),
.padding = undefined,
},
gen3.EmeraldPokedexEntry{
.category_name = undefined,
.height = lu16.init(7),
.weight = lu16.init(69),
.description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(356),
.pokemon_offset = li16.init(17),
.trainer_scale = lu16.init(256),
.trainer_offset = li16.init(0),
.padding = undefined,
},
gen3.EmeraldPokedexEntry{
.category_name = undefined,
.height = lu16.init(10),
.weight = lu16.init(130),
.description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(335),
.pokemon_offset = li16.init(13),
.trainer_scale = lu16.init(256),
.trainer_offset = li16.init(0),
.padding = undefined,
},
gen3.EmeraldPokedexEntry{
.category_name = undefined,
.height = lu16.init(20),
.weight = lu16.init(1000),
.description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(256),
.pokemon_offset = li16.init(0),
.trainer_scale = lu16.init(388),
.trainer_offset = li16.init(6),
.padding = undefined,
},
};
pub const emerald_pokedex_end = [_]gen3.EmeraldPokedexEntry{
gen3.EmeraldPokedexEntry{
.category_name = undefined,
.height = lu16.init(35),
.weight = lu16.init(9500),
.description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(256),
.pokemon_offset = li16.init(0),
.trainer_scale = lu16.init(515),
.trainer_offset = li16.init(14),
.padding = undefined,
},
gen3.EmeraldPokedexEntry{
.category_name = undefined,
.height = lu16.init(70),
.weight = lu16.init(2065),
.description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(256),
.pokemon_offset = li16.init(0),
.trainer_scale = lu16.init(448),
.trainer_offset = li16.init(12),
.padding = undefined,
},
gen3.EmeraldPokedexEntry{
.category_name = undefined,
.height = lu16.init(3),
.weight = lu16.init(11),
.description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(608),
.pokemon_offset = li16.init(-8),
.trainer_scale = lu16.init(256),
.trainer_offset = li16.init(0),
.padding = undefined,
},
gen3.EmeraldPokedexEntry{
.category_name = undefined,
.height = lu16.init(17),
.weight = lu16.init(608),
.description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(256),
.pokemon_offset = li16.init(0),
.trainer_scale = lu16.init(290),
.trainer_offset = li16.init(2),
.padding = undefined,
},
};
pub const frlg_pokedex_start = [_]gen3.RSFrLgPokedexEntry{
gen3.RSFrLgPokedexEntry{
.category_name = undefined,
.height = lu16.init(0),
.weight = lu16.init(0),
.description = undefined,
.unused_description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(256),
.pokemon_offset = li16.init(0),
.trainer_scale = lu16.init(256),
.trainer_offset = li16.init(0),
.padding = undefined,
},
gen3.RSFrLgPokedexEntry{
.category_name = undefined,
.height = lu16.init(7),
.weight = lu16.init(69),
.description = undefined,
.unused_description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(356),
.pokemon_offset = li16.init(16),
.trainer_scale = lu16.init(256),
.trainer_offset = li16.init(-2),
.padding = undefined,
},
gen3.RSFrLgPokedexEntry{
.category_name = undefined,
.height = lu16.init(10),
.weight = lu16.init(130),
.description = undefined,
.unused_description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(332),
.pokemon_offset = li16.init(11),
.trainer_scale = lu16.init(256),
.trainer_offset = li16.init(-2),
.padding = undefined,
},
gen3.RSFrLgPokedexEntry{
.category_name = undefined,
.height = lu16.init(20),
.weight = lu16.init(1000),
.description = undefined,
.unused_description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(256),
.pokemon_offset = li16.init(1),
.trainer_scale = lu16.init(375),
.trainer_offset = li16.init(6),
.padding = undefined,
},
};
pub const frlg_pokedex_end = [_]gen3.RSFrLgPokedexEntry{
gen3.RSFrLgPokedexEntry{
.category_name = undefined,
.height = lu16.init(35),
.weight = lu16.init(9500),
.description = undefined,
.unused_description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(276),
.pokemon_offset = li16.init(0),
.trainer_scale = lu16.init(530),
.trainer_offset = li16.init(12),
.padding = undefined,
},
gen3.RSFrLgPokedexEntry{
.category_name = undefined,
.height = lu16.init(70),
.weight = lu16.init(2065),
.description = undefined,
.unused_description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(286),
.pokemon_offset = li16.init(-1),
.trainer_scale = lu16.init(483),
.trainer_offset = li16.init(9),
.padding = undefined,
},
gen3.RSFrLgPokedexEntry{
.category_name = undefined,
.height = lu16.init(3),
.weight = lu16.init(11),
.description = undefined,
.unused_description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(608),
.pokemon_offset = li16.init(-8),
.trainer_scale = lu16.init(256),
.trainer_offset = li16.init(-2),
.padding = undefined,
},
gen3.RSFrLgPokedexEntry{
.category_name = undefined,
.height = lu16.init(17),
.weight = lu16.init(608),
.description = undefined,
.unused_description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(293),
.pokemon_offset = li16.init(0),
.trainer_scale = lu16.init(337),
.trainer_offset = li16.init(2),
.padding = undefined,
},
};
pub const rs_pokedex_start = [_]gen3.RSFrLgPokedexEntry{
gen3.RSFrLgPokedexEntry{
.category_name = undefined,
.height = lu16.init(0),
.weight = lu16.init(0),
.description = undefined,
.unused_description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(256),
.pokemon_offset = li16.init(0),
.trainer_scale = lu16.init(256),
.trainer_offset = li16.init(0),
.padding = undefined,
},
gen3.RSFrLgPokedexEntry{
.category_name = undefined,
.height = lu16.init(7),
.weight = lu16.init(69),
.description = undefined,
.unused_description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(356),
.pokemon_offset = li16.init(17),
.trainer_scale = lu16.init(256),
.trainer_offset = li16.init(0),
.padding = undefined,
},
gen3.RSFrLgPokedexEntry{
.category_name = undefined,
.height = lu16.init(10),
.weight = lu16.init(130),
.description = undefined,
.unused_description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(335),
.pokemon_offset = li16.init(13),
.trainer_scale = lu16.init(256),
.trainer_offset = li16.init(0),
.padding = undefined,
},
gen3.RSFrLgPokedexEntry{
.category_name = undefined,
.height = lu16.init(20),
.weight = lu16.init(1000),
.description = undefined,
.unused_description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(256),
.pokemon_offset = li16.init(0),
.trainer_scale = lu16.init(388),
.trainer_offset = li16.init(6),
.padding = undefined,
},
};
pub const rs_pokedex_end = [_]gen3.RSFrLgPokedexEntry{
gen3.RSFrLgPokedexEntry{
.category_name = undefined,
.height = lu16.init(35),
.weight = lu16.init(9500),
.description = undefined,
.unused_description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(256),
.pokemon_offset = li16.init(0),
.trainer_scale = lu16.init(515),
.trainer_offset = li16.init(14),
.padding = undefined,
},
gen3.RSFrLgPokedexEntry{
.category_name = undefined,
.height = lu16.init(70),
.weight = lu16.init(2065),
.description = undefined,
.unused_description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(256),
.pokemon_offset = li16.init(0),
.trainer_scale = lu16.init(448),
.trainer_offset = li16.init(12),
.padding = undefined,
},
gen3.RSFrLgPokedexEntry{
.category_name = undefined,
.height = lu16.init(3),
.weight = lu16.init(11),
.description = undefined,
.unused_description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(608),
.pokemon_offset = li16.init(-8),
.trainer_scale = lu16.init(256),
.trainer_offset = li16.init(0),
.padding = undefined,
},
gen3.RSFrLgPokedexEntry{
.category_name = undefined,
.height = lu16.init(17),
.weight = lu16.init(608),
.description = undefined,
.unused_description = undefined,
.unused = lu16.init(0),
.pokemon_scale = lu16.init(256),
.pokemon_offset = li16.init(0),
.trainer_scale = lu16.init(290),
.trainer_offset = li16.init(2),
.padding = undefined,
},
};
fn percentFemale(percent: f64) u8 {
return @floatToInt(u8, math.min(@as(f64, 254), (percent * 255) / 100));
}
const unused_evo = gen3.Evolution{
.method = .unused,
.padding1 = undefined,
.param = lu16.init(0),
.target = lu16.init(0),
.padding2 = undefined,
};
const unused_evo5 = [_]gen3.Evolution{unused_evo} ** 5;
const first_evolutions = [_][5]gen3.Evolution{
// Dummy
unused_evo5,
// Bulbasaur
[_]gen3.Evolution{
gen3.Evolution{
.method = .level_up,
.padding1 = undefined,
.param = lu16.init(16),
.target = lu16.init(2),
.padding2 = undefined,
},
unused_evo,
unused_evo,
unused_evo,
unused_evo,
},
// Ivysaur
[_]gen3.Evolution{
gen3.Evolution{
.method = .level_up,
.padding1 = undefined,
.param = lu16.init(32),
.target = lu16.init(3),
.padding2 = undefined,
},
unused_evo,
unused_evo,
unused_evo,
unused_evo,
},
};
const last_evolutions = [_][5]gen3.Evolution{
// Beldum
[_]gen3.Evolution{
gen3.Evolution{
.padding1 = undefined,
.method = .level_up,
.param = lu16.init(20),
.target = lu16.init(399),
.padding2 = undefined,
},
unused_evo,
unused_evo,
unused_evo,
unused_evo,
},
// Metang
[_]gen3.Evolution{
gen3.Evolution{
.method = .level_up,
.padding1 = undefined,
.param = lu16.init(45),
.target = lu16.init(400),
.padding2 = undefined,
},
unused_evo,
unused_evo,
unused_evo,
unused_evo,
},
// Metagross, Regirock, Regice, Registeel, Kyogre, Groudon, Rayquaza
// Latias, Latios, Jirachi, Deoxys, Chimecho
unused_evo5,
unused_evo5,
unused_evo5,
unused_evo5,
unused_evo5,
unused_evo5,
unused_evo5,
unused_evo5,
unused_evo5,
unused_evo5,
unused_evo5,
unused_evo5,
};
const first_levelup_learnsets = [_][]const u8{
// Dummy mon have same moves as Bulbasaur
&[_]u8{
0x21, 0x02, 0x2D, 0x08, 0x49, 0x0E, 0x16, 0x14, 0x4D, 0x1E, 0x4F, 0x1E,
0x4B, 0x28, 0xE6, 0x32, 0x4A, 0x40, 0xEB, 0x4E, 0x4C, 0x5C, 0xFF, 0xFF,
},
// Bulbasaur
&[_]u8{
0x21, 0x02, 0x2D, 0x08, 0x49, 0x0E, 0x16, 0x14, 0x4D, 0x1E, 0x4F, 0x1E,
0x4B, 0x28, 0xE6, 0x32, 0x4A, 0x40, 0xEB, 0x4E, 0x4C, 0x5C, 0xFF, 0xFF,
},
// Ivysaur
&[_]u8{
0x21, 0x02, 0x2D, 0x02, 0x49, 0x02, 0x2D, 0x08, 0x49, 0x0E, 0x16, 0x14,
0x4D, 0x1E, 0x4F, 0x1E, 0x4B, 0x2C, 0xE6, 0x3A, 0x4A, 0x4C, 0xEB, 0x5E,
0x4C, 0x70, 0xFF, 0xFF,
},
// Venusaur
&[_]u8{
0x21, 0x02, 0x2D, 0x02, 0x49, 0x02, 0x16, 0x02, 0x2D, 0x08, 0x49, 0x0E,
0x16, 0x14, 0x4D, 0x1E, 0x4F, 0x1E, 0x4B, 0x2C, 0xE6, 0x3A, 0x4A, 0x52,
0xEB, 0x6A, 0x4C, 0x82, 0xFF, 0xFF,
},
};
const last_levelup_learnsets = [_][]const u8{
// TODO: Figure out if only having Chimechos level up learnset is enough.
// Chimecho
&[_]u8{
0x23, 0x02, 0x2D, 0x0C, 0x36, 0x13, 0x5D, 0x1C, 0x24, 0x22, 0xFD, 0x2C, 0x19,
0x33, 0x95, 0x3C, 0x26, 0x42, 0xD7, 0x4C, 0xDB, 0x52, 0x5E, 0x5C, 0xFF, 0xFF,
}};
const hms = [_]lu16{
lu16.init(0x000f),
lu16.init(0x0013),
lu16.init(0x0039),
lu16.init(0x0046),
lu16.init(0x0094),
lu16.init(0x00f9),
lu16.init(0x007f),
lu16.init(0x0123),
};
const tms = [_]lu16{
lu16.init(0x0108),
lu16.init(0x0151),
lu16.init(0x0160),
lu16.init(0x015b),
lu16.init(0x002e),
lu16.init(0x005c),
lu16.init(0x0102),
lu16.init(0x0153),
lu16.init(0x014b),
lu16.init(0x00ed),
lu16.init(0x00f1),
lu16.init(0x010d),
lu16.init(0x003a),
lu16.init(0x003b),
lu16.init(0x003f),
lu16.init(0x0071),
lu16.init(0x00b6),
lu16.init(0x00f0),
lu16.init(0x00ca),
lu16.init(0x00db),
lu16.init(0x00da),
lu16.init(0x004c),
lu16.init(0x00e7),
lu16.init(0x0055),
lu16.init(0x0057),
lu16.init(0x0059),
lu16.init(0x00d8),
lu16.init(0x005b),
lu16.init(0x005e),
lu16.init(0x00f7),
lu16.init(0x0118),
lu16.init(0x0068),
lu16.init(0x0073),
lu16.init(0x015f),
lu16.init(0x0035),
lu16.init(0x00bc),
lu16.init(0x00c9),
lu16.init(0x007e),
lu16.init(0x013d),
lu16.init(0x014c),
lu16.init(0x0103),
lu16.init(0x0107),
lu16.init(0x0122),
lu16.init(0x009c),
lu16.init(0x00d5),
lu16.init(0x00a8),
lu16.init(0x00d3),
lu16.init(0x011d),
lu16.init(0x0121),
lu16.init(0x013b),
};
const em_first_items = [_]gen3.Item{
// ????????
gen3.Item{
.name = undefined,
.id = lu16.init(0),
.price = lu16.init(0),
.battle_effect = 0,
.battle_effect_param = 0,
.description = undefined,
.importance = 0,
.unknown = 0,
.pocket = gen3.Pocket{ .rse = .items },
.@"type" = 4,
.field_use_func = undefined,
.battle_usage = lu32.init(0),
.battle_use_func = undefined,
.secondary_id = lu32.init(0),
},
// MASTER BALL
gen3.Item{
.name = undefined,
.id = lu16.init(1),
.price = lu16.init(0),
.battle_effect = 0,
.battle_effect_param = 0,
.description = undefined,
.importance = 0,
.unknown = 0,
.pocket = gen3.Pocket{ .rse = .poke_balls },
.@"type" = 0,
.field_use_func = undefined,
.battle_usage = lu32.init(2),
.battle_use_func = undefined,
.secondary_id = lu32.init(0),
},
};
const em_last_items = [_]gen3.Item{
// MAGMA EMBLEM
gen3.Item{
.name = undefined,
.id = lu16.init(0x177),
.price = lu16.init(0),
.battle_effect = 0,
.battle_effect_param = 0,
.description = undefined,
.importance = 1,
.unknown = 1,
.pocket = gen3.Pocket{ .rse = .key_items },
.@"type" = 4,
.field_use_func = undefined,
.battle_usage = lu32.init(0),
.battle_use_func = undefined,
.secondary_id = lu32.init(0),
},
// OLD SEA MAP
gen3.Item{
.name = undefined,
.id = lu16.init(0x178),
.price = lu16.init(0),
.battle_effect = 0,
.battle_effect_param = 0,
.description = undefined,
.importance = 1,
.unknown = 1,
.pocket = gen3.Pocket{ .rse = .key_items },
.@"type" = 4,
.field_use_func = undefined,
.battle_usage = lu32.init(0),
.battle_use_func = undefined,
.secondary_id = lu32.init(0),
},
};
const rs_first_items = [_]gen3.Item{
// ????????
gen3.Item{
.name = undefined,
.id = lu16.init(0),
.price = lu16.init(0),
.battle_effect = 0,
.battle_effect_param = 0,
.description = undefined,
.importance = 0,
.unknown = 0,
.pocket = gen3.Pocket{ .rse = .items },
.@"type" = 4,
.field_use_func = undefined,
.battle_usage = lu32.init(0),
.battle_use_func = undefined,
.secondary_id = lu32.init(0),
},
// MASTER BALL
gen3.Item{
.name = undefined,
.id = lu16.init(1),
.price = lu16.init(0),
.battle_effect = 0,
.battle_effect_param = 0,
.description = undefined,
.importance = 0,
.unknown = 0,
.pocket = gen3.Pocket{ .rse = .poke_balls },
.@"type" = 0,
.field_use_func = undefined,
.battle_usage = lu32.init(2),
.battle_use_func = undefined,
.secondary_id = lu32.init(0),
},
};
const rs_last_items = [_]gen3.Item{
// HM08
gen3.Item{
.name = undefined,
.id = lu16.init(0x15A),
.price = lu16.init(0),
.battle_effect = 0,
.battle_effect_param = 0,
.description = undefined,
.importance = 1,
.unknown = 0,
.pocket = gen3.Pocket{ .rse = .tms_hms },
.@"type" = 1,
.field_use_func = undefined,
.battle_usage = lu32.init(0),
.battle_use_func = undefined,
.secondary_id = lu32.init(0),
},
// ????????
gen3.Item{
.name = undefined,
.id = lu16.init(0),
.price = lu16.init(0),
.battle_effect = 0,
.battle_effect_param = 0,
.description = undefined,
.importance = 0,
.unknown = 0,
.pocket = gen3.Pocket{ .rse = .items },
.@"type" = 4,
.field_use_func = undefined,
.battle_usage = lu32.init(0),
.battle_use_func = undefined,
.secondary_id = lu32.init(0),
},
// ????????
gen3.Item{
.name = undefined,
.id = lu16.init(0),
.price = lu16.init(0),
.battle_effect = 0,
.battle_effect_param = 0,
.description = undefined,
.importance = 0,
.unknown = 0,
.pocket = gen3.Pocket{ .rse = .items },
.@"type" = 4,
.field_use_func = undefined,
.battle_usage = lu32.init(0),
.battle_use_func = undefined,
.secondary_id = lu32.init(0),
},
};
const frlg_first_items = [_]gen3.Item{
gen3.Item{
.name = undefined,
.id = lu16.init(0),
.price = lu16.init(0),
.battle_effect = 0,
.battle_effect_param = 0,
.description = undefined,
.importance = 0,
.unknown = 0,
.pocket = gen3.Pocket{ .frlg = .items },
.@"type" = 4,
.field_use_func = undefined,
.battle_usage = lu32.init(0),
.battle_use_func = undefined,
.secondary_id = lu32.init(0),
},
gen3.Item{
.name = undefined,
.id = lu16.init(1),
.price = lu16.init(0),
.battle_effect = 0,
.battle_effect_param = 0,
.description = undefined,
.importance = 0,
.unknown = 0,
.pocket = gen3.Pocket{ .frlg = .poke_balls },
.@"type" = 0,
.field_use_func = undefined,
.battle_usage = lu32.init(2),
.battle_use_func = undefined,
.secondary_id = lu32.init(0),
},
};
const frlg_last_items = [_]gen3.Item{
gen3.Item{
.name = undefined,
.id = lu16.init(372),
.price = lu16.init(0),
.battle_effect = 0,
.battle_effect_param = 0,
.description = undefined,
.importance = 1,
.unknown = 1,
.pocket = gen3.Pocket{ .frlg = .key_items },
.@"type" = 4,
.field_use_func = undefined,
.battle_usage = lu32.init(0),
.battle_use_func = undefined,
.secondary_id = lu32.init(0),
},
gen3.Item{
.name = undefined,
.id = lu16.init(373),
.price = lu16.init(0),
.battle_effect = 0,
.battle_effect_param = 0,
.description = undefined,
.importance = 1,
.unknown = 1,
.pocket = gen3.Pocket{ .frlg = .key_items },
.@"type" = 4,
.field_use_func = undefined,
.battle_usage = lu32.init(0),
.battle_use_func = undefined,
.secondary_id = lu32.init(0),
},
};
fn wildHeader(map_group: u8, map_num: u8) gen3.WildPokemonHeader {
return gen3.WildPokemonHeader{
.map_group = map_group,
.map_num = map_num,
.pad = undefined,
.land = undefined,
.surf = undefined,
.rock_smash = undefined,
.fishing = undefined,
};
}
const em_first_wild_mon_headers = [_]gen3.WildPokemonHeader{
wildHeader(0, 16),
wildHeader(0, 17),
wildHeader(0, 18),
};
const em_last_wild_mon_headers = [_]gen3.WildPokemonHeader{
wildHeader(24, 106),
wildHeader(24, 106),
wildHeader(24, 107),
};
const rs_first_wild_mon_headers = [_]gen3.WildPokemonHeader{
wildHeader(0, 0),
wildHeader(0, 1),
wildHeader(0, 5),
wildHeader(0, 6),
};
const rs_last_wild_mon_headers = [_]gen3.WildPokemonHeader{
wildHeader(0, 15),
wildHeader(0, 50),
wildHeader(0, 51),
};
const frlg_first_wild_mon_headers = [_]gen3.WildPokemonHeader{
wildHeader(2, 27),
wildHeader(2, 28),
wildHeader(2, 29),
};
const frlg_last_wild_mon_headers = [_]gen3.WildPokemonHeader{
wildHeader(1, 122),
wildHeader(1, 122),
wildHeader(1, 122),
wildHeader(1, 122),
wildHeader(1, 122),
wildHeader(1, 122),
wildHeader(1, 122),
wildHeader(1, 122),
wildHeader(1, 122),
};
const em_first_map_headers = [_]gen3.MapHeader{
// Petalburg City
gen3.MapHeader{
.map_layout = undefined,
.map_events = undefined,
.map_scripts = undefined,
.map_connections = undefined,
.music = lu16.init(362),
.map_data_id = lu16.init(1),
.map_sec = 0x07,
.cave = 0,
.weather = 2,
.map_type = 2,
.pad = undefined,
.escape_rope = 0,
.flags = gen3.MapHeader.Flags{
.allow_cycling = true,
.allow_escaping = false,
.allow_running = true,
.show_map_name = true,
.unused = 0,
},
.map_battle_scene = 0,
}};
const em_last_map_headers = [_]gen3.MapHeader{
// Route 124 - Diving Treasure Hunters House
gen3.MapHeader{
.map_layout = undefined,
.map_events = undefined,
.map_scripts = undefined,
.map_connections = undefined,
.music = lu16.init(408),
.map_data_id = lu16.init(301),
.map_sec = 0x27,
.cave = 0,
.weather = 0,
.map_type = 8,
.pad = undefined,
.escape_rope = 0,
.flags = gen3.MapHeader.Flags{
.allow_cycling = false,
.allow_escaping = false,
.allow_running = false,
.show_map_name = false,
.unused = 0,
},
.map_battle_scene = 0,
}};
const rs_first_map_headers = [_]gen3.MapHeader{
// Petalburg City
gen3.MapHeader{
.map_layout = undefined,
.map_events = undefined,
.map_scripts = undefined,
.map_connections = undefined,
.music = lu16.init(362),
.map_data_id = lu16.init(1),
.map_sec = 0x07,
.cave = 0,
.weather = 2,
.map_type = 2,
.pad = undefined,
.escape_rope = 0,
.flags = gen3.MapHeader.Flags{
.allow_cycling = true,
.allow_escaping = false,
.allow_running = false,
.show_map_name = false,
.unused = 0,
},
.map_battle_scene = 0,
}};
const rs_last_map_headers = [_]gen3.MapHeader{
// Route 124 - Diving Treasure Hunters House
gen3.MapHeader{
.map_layout = undefined,
.map_events = undefined,
.map_scripts = undefined,
.map_connections = undefined,
.music = lu16.init(408),
.map_data_id = lu16.init(302),
.map_sec = 0x27,
.cave = 0,
.weather = 0,
.map_type = 8,
.pad = undefined,
.escape_rope = 0,
.flags = gen3.MapHeader.Flags{
.allow_cycling = false,
.allow_escaping = false,
.allow_running = false,
.show_map_name = false,
.unused = 0,
},
.map_battle_scene = 0,
}};
const frlg_first_map_headers = [_]gen3.MapHeader{
// ???
gen3.MapHeader{
.map_layout = undefined,
.map_events = undefined,
.map_scripts = undefined,
.map_connections = undefined,
.music = lu16.init(0x12F),
.map_data_id = lu16.init(0x2F),
.map_sec = 0xC4,
.cave = 0x0,
.weather = 0x0,
.map_type = 0x8,
.pad = undefined,
.escape_rope = 0x0,
.flags = gen3.MapHeader.Flags{
.allow_cycling = false,
.allow_escaping = false,
.allow_running = false,
.show_map_name = false,
.unused = 0,
},
.map_battle_scene = 0x8,
}};
const frlg_last_map_headers = [_]gen3.MapHeader{
// ???
gen3.MapHeader{
.map_layout = undefined,
.map_events = undefined,
.map_scripts = undefined,
.map_connections = undefined,
.music = lu16.init(0x151),
.map_data_id = lu16.init(0xB),
.map_sec = 0xA9,
.cave = 0x0,
.weather = 0x0,
.map_type = 0x8,
.pad = undefined,
.escape_rope = 0x0,
.flags = gen3.MapHeader.Flags{
.allow_cycling = false,
.allow_escaping = false,
.allow_running = false,
.show_map_name = false,
.unused = 0,
},
.map_battle_scene = 0x0,
}};
fn __(comptime len: usize, lang: gen3.Language, str: []const u8) [len]u8 {
_ = lang;
@setEvalBranchQuota(100000);
var res = [_]u8{0} ** len;
var fbs = io.fixedBufferStream(str);
gen3.encodings.encode(.en_us, fbs.reader(), &res) catch unreachable;
return res;
}
const first_pokemon_names = [_][11]u8{
__(11, .en_us, "??????????"),
__(11, .en_us, "BULBASAUR"),
__(11, .en_us, "IVYSAUR"),
__(11, .en_us, "VENUSAUR"),
};
const last_pokemon_names = [_][11]u8{
__(11, .en_us, "LATIAS"),
__(11, .en_us, "LATIOS"),
__(11, .en_us, "JIRACHI"),
__(11, .en_us, "DEOXYS"),
__(11, .en_us, "CHIMECHO"),
};
const first_ability_names = [_][13]u8{
__(13, .en_us, "-------"),
__(13, .en_us, "STENCH"),
__(13, .en_us, "DRIZZLE"),
__(13, .en_us, "SPEED BOOST"),
__(13, .en_us, "BATTLE ARMOR"),
};
const last_ability_names = [_][13]u8{
__(13, .en_us, "WHITE SMOKE"),
__(13, .en_us, "PURE POWER"),
__(13, .en_us, "SHELL ARMOR"),
__(13, .en_us, "CACOPHONY"),
__(13, .en_us, "AIR LOCK"),
};
const e_first_move_names = [_][13]u8{
__(13, .en_us, "-"),
__(13, .en_us, "POUND"),
__(13, .en_us, "KARATE CHOP"),
__(13, .en_us, "DOUBLESLAP"),
__(13, .en_us, "COMET PUNCH"),
};
const rsfrlg_first_move_names = [_][13]u8{
__(13, .en_us, "-$$$$$$"),
__(13, .en_us, "POUND"),
__(13, .en_us, "KARATE CHOP"),
__(13, .en_us, "DOUBLESLAP"),
__(13, .en_us, "COMET PUNCH"),
};
const last_move_names = [_][13]u8{
__(13, .en_us, "ROCK BLAST"),
__(13, .en_us, "SHOCK WAVE"),
__(13, .en_us, "WATER PULSE"),
__(13, .en_us, "DOOM DESIRE"),
__(13, .en_us, "PSYCHO BOOST"),
};
const type_names = [_][7]u8{
__(7, .en_us, "NORMAL"),
__(7, .en_us, "FIGHT"),
__(7, .en_us, "FLYING"),
__(7, .en_us, "POISON"),
__(7, .en_us, "GROUND"),
__(7, .en_us, "ROCK"),
__(7, .en_us, "BUG"),
__(7, .en_us, "GHOST"),
__(7, .en_us, "STEEL"),
__(7, .en_us, "???"),
__(7, .en_us, "FIRE"),
__(7, .en_us, "WATER"),
__(7, .en_us, "GRASS"),
__(7, .en_us, "ELECTR"),
__(7, .en_us, "PSYCHC"),
__(7, .en_us, "ICE"),
__(7, .en_us, "DRAGON"),
__(7, .en_us, "DARK"),
};
|
src/core/tm35-gen3-offsets.zig
|
const macro = @import("pspmacros.zig");
comptime {
asm (macro.import_module_start("scePower", "0x40010000", "46"));
asm (macro.import_function("scePower", "0x2B51FE2F", "scePower_2B51FE2F"));
asm (macro.import_function("scePower", "0x442BFBAC", "scePower_442BFBAC"));
asm (macro.import_function("scePower", "0xEFD3C963", "scePowerTick"));
asm (macro.import_function("scePower", "0xEDC13FE5", "scePowerGetIdleTimer"));
asm (macro.import_function("scePower", "0x7F30B3B1", "scePowerIdleTimerEnable"));
asm (macro.import_function("scePower", "0x972CE941", "scePowerIdleTimerDisable"));
asm (macro.import_function("scePower", "0x27F3292C", "scePowerBatteryUpdateInfo"));
asm (macro.import_function("scePower", "0xE8E4E204", "scePower_E8E4E204"));
asm (macro.import_function("scePower", "0xB999184C", "scePowerGetLowBatteryCapacity"));
asm (macro.import_function("scePower", "0x87440F5E", "scePowerIsPowerOnline"));
asm (macro.import_function("scePower", "0x0AFD0D8B", "scePowerIsBatteryExist"));
asm (macro.import_function("scePower", "0x1E490401", "scePowerIsBatteryCharging"));
asm (macro.import_function("scePower", "0xB4432BC8", "scePowerGetBatteryChargingStatus"));
asm (macro.import_function("scePower", "0xD3075926", "scePowerIsLowBattery"));
asm (macro.import_function("scePower", "0x78A1A796", "scePower_78A1A796"));
asm (macro.import_function("scePower", "0x94F5A53F", "scePowerGetBatteryRemainCapacity"));
asm (macro.import_function("scePower", "0xFD18A0FF", "scePower_FD18A0FF"));
asm (macro.import_function("scePower", "0x2085D15D", "scePowerGetBatteryLifePercent"));
asm (macro.import_function("scePower", "0x8EFB3FA2", "scePowerGetBatteryLifeTime"));
asm (macro.import_function("scePower", "0x28E12023", "scePowerGetBatteryTemp"));
asm (macro.import_function("scePower", "0x862AE1A6", "scePowerGetBatteryElec"));
asm (macro.import_function("scePower", "0x483CE86B", "scePowerGetBatteryVolt"));
asm (macro.import_function("scePower", "0x23436A4A", "scePower_23436A4A"));
asm (macro.import_function("scePower", "0x0CD21B1F", "scePower_0CD21B1F"));
asm (macro.import_function("scePower", "0x165CE085", "scePower_165CE085"));
asm (macro.import_function("scePower", "0xD6D016EF", "scePowerLock"));
asm (macro.import_function("scePower", "0xCA3D34C1", "scePowerUnlock"));
asm (macro.import_function("scePower", "0xDB62C9CF", "scePowerCancelRequest"));
asm (macro.import_function("scePower", "0x7FA406DD", "scePowerIsRequest"));
asm (macro.import_function("scePower", "0x2B7C7CF4", "scePowerRequestStandby"));
asm (macro.import_function("scePower", "0xAC32C9CC", "scePowerRequestSuspend"));
asm (macro.import_function("scePower", "0x2875994B", "scePower_2875994B"));
asm (macro.import_function("scePower", "0x3951AF53", "scePowerEncodeUBattery"));
asm (macro.import_function("scePower", "0x0074EF9B", "scePowerGetResumeCount"));
asm (macro.import_function("scePower", "0x04B7766E", "scePowerRegisterCallback"));
asm (macro.import_function("scePower", "0xDFA8BAF8", "scePowerUnregisterCallback"));
asm (macro.import_function("scePower", "0xDB9D28DD", "scePowerUnregitserCallback"));
asm (macro.import_function("scePower", "0x843FBF43", "scePowerSetCpuClockFrequency"));
asm (macro.import_function("scePower", "0xB8D7B3FB", "scePowerSetBusClockFrequency"));
asm (macro.import_function("scePower", "0xFEE03A2F", "scePowerGetCpuClockFrequency"));
asm (macro.import_function("scePower", "0x478FE6F5", "scePowerGetBusClockFrequency"));
asm (macro.import_function("scePower", "0xFDB5BFE9", "scePowerGetCpuClockFrequencyInt"));
asm (macro.import_function("scePower", "0xBD681969", "scePowerGetBusClockFrequencyInt"));
asm (macro.import_function("scePower", "0xB1A52C83", "scePowerGetCpuClockFrequencyFloat"));
asm (macro.import_function("scePower", "0x9BADB3EB", "scePowerGetBusClockFrequencyFloat"));
asm (macro.import_function("scePower", "0x737486F2", "scePowerSetClockFrequency"));
}
|
src/psp/nids/psppower.zig
|
const std = @import("std");
const alka = @import("alka");
const m = alka.math;
usingnamespace alka.log;
pub const mlog = std.log.scoped(.app);
pub const log_level: std.log.Level = .info;
fn draw() !void {
const asset = alka.getAssetManager();
const testpng = try asset.getTexture(1);
const srect = m.Rectangle{ .position = m.Vec2f{ .x = 0.0, .y = 0.0 }, .size = m.Vec2f{ .x = @intToFloat(f32, testpng.width), .y = @intToFloat(f32, testpng.height) } };
const r = m.Rectangle{ .position = m.Vec2f{ .x = 100.0, .y = 200.0 }, .size = m.Vec2f{ .x = 50.0, .y = 50.0 } };
const col = alka.Colour{ .r = 1, .g = 1, .b = 1, .a = 1 };
// id, rect, source rect, origin, angle in radians, colour
try alka.drawTextureAdv(1, r, srect, m.Vec2f{ .x = 25, .y = 25 }, m.deg2radf(45), col);
const r2 = m.Rectangle{ .position = m.Vec2f{ .x = 300.0, .y = 200.0 }, .size = m.Vec2f{ .x = 50.0, .y = 50.0 } };
const col2 = alka.Colour.rgba(30, 80, 200, 255);
// id, rect, source rect, colour
try alka.drawTexture(1, r2, srect, col2);
}
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const callbacks = alka.Callbacks{
.update = null,
.fixed = null,
.draw = draw,
.resize = null,
.close = null,
};
try alka.init(&gpa.allocator, callbacks, 1024, 768, "Texture Drawing", 0, false);
// id, path
try alka.getAssetManager().loadTexture(1, "assets/test.png");
{
const texture = try alka.getAssetManager().getTexture(1);
// min, mag
texture.setFilter(alka.gl.TextureParamater.filter_nearest, alka.gl.TextureParamater.filter_nearest);
}
// or
{
const texture = try alka.renderer.Texture.createFromPNG(&gpa.allocator, "assets/test.png");
try alka.getAssetManager().loadTexturePro(2, texture);
}
// or
{
const mem = @embedFile("../assets/test.png");
const texture = try alka.renderer.Texture.createFromPNGMemory(mem);
try alka.getAssetManager().loadTexturePro(3, texture);
// or
try alka.getAssetManager().loadTextureFromMemory(4, mem);
}
try alka.open();
try alka.update();
try alka.close();
try alka.deinit();
const leaked = gpa.deinit();
if (leaked) return error.Leak;
}
|
examples/texture_drawing.zig
|
const std = @import("std");
const stdx = @import("stdx");
const ds = stdx.ds;
const v8 = @import("v8");
const v8x = @import("v8x.zig");
const runtime = @import("runtime.zig");
const RuntimeContext = runtime.RuntimeContext;
const SizedJsString = runtime.SizedJsString;
const adapter = @import("adapter.zig");
const This = adapter.This;
const ThisResource = adapter.ThisResource;
const FuncData = adapter.FuncData;
const FuncDataUserPtr = adapter.FuncDataUserPtr;
const CsError = runtime.CsError;
const RuntimeValue = runtime.RuntimeValue;
const PromiseId = runtime.PromiseId;
const tasks = @import("tasks.zig");
const work_queue = @import("work_queue.zig");
const TaskOutput = work_queue.TaskOutput;
const log = stdx.log.scoped(.gen);
pub fn genJsFuncSync(comptime native_fn: anytype) v8.FunctionCallback {
return genJsFunc(native_fn, .{
.asyncify = false,
.is_data_rt = true,
});
}
pub fn genJsFuncAsync(comptime native_fn: anytype) v8.FunctionCallback {
return genJsFunc(native_fn, .{
.asyncify = true,
.is_data_rt = true,
});
}
fn setErrorAndReturn(rt: *RuntimeContext, info: v8.FunctionCallbackInfo, err: CsError) void {
rt.last_err = err;
info.getReturnValue().setValueHandle(rt.js_null.handle);
}
/// Calling v8.throwErrorException inside a native callback function will trigger in v8 when the callback returns.
pub fn genJsFunc(comptime native_fn: anytype, comptime opts: GenJsFuncOptions) v8.FunctionCallback {
const NativeFn = @TypeOf(native_fn);
const asyncify = opts.asyncify;
const is_data_rt = opts.is_data_rt;
const gen = struct {
fn cb(raw_info: ?*const v8.C_FunctionCallbackInfo) callconv(.C) void {
const info = v8.FunctionCallbackInfo.initFromV8(raw_info);
// RT handle is either data or the first field of data.
const rt = if (is_data_rt) stdx.mem.ptrCastAlign(*RuntimeContext, info.getExternalValue())
else stdx.mem.ptrCastAlign(*RuntimeContext, info.getData().castTo(v8.Object).getInternalField(0).castTo(v8.External).get());
const iso = rt.isolate;
const ctx = rt.getContext();
var hscope: v8.HandleScope = undefined;
hscope.init(iso);
defer hscope.deinit();
const ArgTypesT = std.meta.ArgsTuple(NativeFn);
const ArgFields = std.meta.fields(ArgTypesT);
const FuncInfo = comptime getJsFuncInfo(ArgFields);
const num_js_args = info.length();
if (num_js_args < FuncInfo.num_req_js_params) {
v8x.throwErrorExceptionFmt(rt.alloc, iso, "Expected {} args.", .{FuncInfo.num_req_js_params});
return;
}
const StringParams = comptime b: {
var count: u32 = 0;
inline for (ArgFields) |field, i| {
if (FuncInfo.param_tags[i] == .Param and field.field_type == []const u8) {
count += 1;
}
}
var i: u32 = 0;
var idxs: [count]u32 = undefined;
inline for (ArgFields) |field, idx| {
if (FuncInfo.param_tags[idx] == .Param and field.field_type == []const u8) {
idxs[i] = idx;
i += 1;
}
}
break :b idxs;
};
const HasStringParams = StringParams.len > 0;
const has_f32_slice_param: bool = b: {
inline for (ArgFields) |field, i| {
if (FuncInfo.param_tags[i] == .Param and field.field_type == []const f32) {
break :b true;
}
}
break :b false;
};
// This stores the JsValue to JsString conversion to be accessed later to go from JsString to []const u8
// It should be optimized out for functions without string params.
var js_strs: [StringParams.len]SizedJsString = undefined;
if (HasStringParams) {
// Since we are converting js strings to native []const u8,
// we need to make sure the buffer capacity is enough before appending the args or a realloc could invalidate the slice.
// This also means we need to do the JsValue to JsString conversion here and store it in memory.
var total_size: u32 = 0;
inline for (StringParams) |ParamIdx, i| {
const js_str = info.getArg(FuncInfo.param_js_idxs[ParamIdx].?).toString(ctx) catch unreachable;
const len = js_str.lenUtf8(iso);
total_size += len;
js_strs[i] = .{
.str = js_str,
.len = len,
};
}
rt.cb_str_buf.clearRetainingCapacity();
rt.cb_str_buf.ensureUnusedCapacity(total_size) catch unreachable;
}
if (has_f32_slice_param) {
if (rt.cb_f32_buf.items.len > 1e6) {
rt.cb_f32_buf.clearRetainingCapacity();
}
}
var native_args: ArgTypesT = undefined;
inline for (ArgFields) |Field, i| {
switch (FuncInfo.param_tags[i]) {
.This => @field(native_args, Field.name) = This{ .obj = info.getThis() },
.ThisValue => {
const Value = stdx.meta.FieldType(Field.field_type, .val);
const this = info.getThis();
const native_val = rt.getNativeValue(Value, this.toValue()) catch {
v8x.throwErrorException(iso, "Can't convert to native value.");
return;
};
@field(native_args, Field.name) = Field.field_type{ .obj = this, .val = native_val };
},
.ThisResource => {
const Ptr = stdx.meta.FieldType(Field.field_type, .res);
const res_id = info.getThis().getInternalField(0).castTo(v8.Integer).getValueU32();
const handle = rt.resources.getNoCheck(res_id);
if (!handle.deinited) {
@field(native_args, Field.name) = Field.field_type{
.res = stdx.mem.ptrCastAlign(Ptr, handle.ptr),
.res_id = res_id,
.obj = info.getThis(),
};
} else {
v8x.throwErrorException(iso, "Resource handle is already deinitialized.");
return;
}
},
.ThisHandle => {
const Ptr = comptime stdx.meta.FieldType(Field.field_type, .ptr);
const this = info.getThis();
const handle_id = @intCast(u32, @ptrToInt(this.getInternalField(0).castTo(v8.External).get()));
const handle = rt.weak_handles.getNoCheck(handle_id);
if (handle.tag != .Null) {
@field(native_args, Field.name) = Field.field_type{
.ptr = stdx.mem.ptrCastAlign(Ptr, handle.ptr),
.id = handle_id,
.obj = this,
};
} else {
v8x.throwErrorException(iso, "Handle is already deinitialized.");
return;
}
},
.FuncData => @field(native_args, Field.name) = .{ .val = info.getData() },
.FuncDataUserPtr => {
const Ptr = comptime stdx.meta.FieldType(Field.field_type, .ptr);
const ptr = info.getData().castTo(v8.Object).getInternalField(1).castTo(v8.External).get();
@field(native_args, Field.name) = Field.field_type{
.ptr = stdx.mem.ptrCastAlign(Ptr, ptr),
};
},
.ThisPtr => {
const Ptr = Field.field_type;
const ptr = @ptrToInt(info.getThis().getInternalField(0).castTo(v8.External).get());
if (ptr > 0) {
@field(native_args, Field.name) = @intToPtr(Ptr, ptr);
} else {
v8x.throwErrorException(iso, "Native handle expired");
return;
}
},
.RuntimePtr => @field(native_args, Field.name) = rt,
else => {},
}
}
var has_args = true;
inline for (ArgFields) |field, i| {
if (FuncInfo.param_tags[i] == .Param) {
if (field.field_type == []const u8) {
const StrBufIdx = comptime std.mem.indexOfScalar(u32, &StringParams, @intCast(u32, i)).?;
if (rt.getNativeValue(field.field_type, js_strs[StrBufIdx])) |native_val| {
if (asyncify) {
// getNativeValue only returns temporary allocations. Dupe so it can be persisted.
if (@TypeOf(native_val) == []const u8) {
@field(native_args, field.name) = rt.alloc.dupe(u8, native_val) catch unreachable;
} else {
@field(native_args, field.name) = native_val;
}
} else {
@field(native_args, field.name) = native_val;
}
} else |err| {
throwConversionError(rt, err, @typeName(field.field_type));
has_args = false;
}
} else {
if (@typeInfo(field.field_type) == .Optional) {
const JsParamIdx = FuncInfo.param_js_idxs[i].?;
if (JsParamIdx >= num_js_args) {
@field(native_args, field.name) = null;
} else {
const FieldType = comptime @typeInfo(field.field_type).Optional.child;
const js_arg = info.getArg(FuncInfo.param_js_idxs[i].?);
@field(native_args, field.name) = (rt.getNativeValue(FieldType, js_arg) catch null);
}
} else {
const js_arg = info.getArg(FuncInfo.param_js_idxs[i].?);
if (rt.getNativeValue2(field.field_type, js_arg)) |native_val| {
@field(native_args, field.name) = native_val;
} else {
throwConversionError(rt, rt.get_native_val_err, @typeName(field.field_type));
// TODO: How to use return here without crashing compiler? Using a boolean var as a workaround.
has_args = false;
}
}
}
}
}
if (!has_args) {
return;
}
if (asyncify) {
const ClosureTask = tasks.ClosureTask(native_fn);
const task = ClosureTask{
.alloc = rt.alloc,
.args = native_args,
};
const resolver = iso.initPersistent(v8.PromiseResolver, v8.PromiseResolver.init(ctx));
const promise = resolver.inner.getPromise();
const promise_id = rt.promises.add(resolver) catch unreachable;
const S = struct {
fn onSuccess(_ctx: RuntimeValue(PromiseId), _res: TaskOutput(ClosureTask)) void {
const _promise_id = _ctx.inner;
runtime.resolvePromise(_ctx.rt, _promise_id, _res);
}
fn onFailure(_ctx: RuntimeValue(PromiseId), _err: anyerror) void {
const _promise_id = _ctx.inner;
runtime.rejectPromise(_ctx.rt, _promise_id, _err);
}
};
const task_ctx = RuntimeValue(PromiseId){
.rt = rt,
.inner = promise_id,
};
_ = rt.work_queue.addTaskWithCb(task, task_ctx, S.onSuccess, S.onFailure);
const return_value = info.getReturnValue();
return_value.setValueHandle(rt.getJsValuePtr(promise));
} else {
const ReturnType = comptime stdx.meta.FnReturn(NativeFn);
if (ReturnType == void) {
@call(.{}, native_fn, native_args);
} else if (@typeInfo(ReturnType) == .ErrorUnion) {
if (@call(.{}, native_fn, native_args)) |native_val| {
const js_val = rt.getJsValuePtr(native_val);
const return_value = info.getReturnValue();
return_value.setValueHandle(js_val);
freeNativeValue(rt.alloc, native_val);
} else |err| {
if (@typeInfo(ReturnType).ErrorUnion.error_set == CsError) {
setErrorAndReturn(rt, info, err);
return;
} else {
v8x.throwErrorExceptionFmt(rt.alloc, iso, "Unexpected error: {s}", .{@errorName(err)});
return;
}
}
} else {
const native_val = @call(.{}, native_fn, native_args);
const js_val = rt.getJsValuePtr(native_val);
const return_value = info.getReturnValue();
return_value.setValueHandle(js_val);
freeNativeValue(rt.alloc, native_val);
}
}
}
};
return gen.cb;
}
fn throwConversionError(rt: *RuntimeContext, err: anyerror, target_type: []const u8) void {
switch (err) {
error.CantConvert => v8x.throwErrorExceptionFmt(rt.alloc, rt.isolate, "Expected {s}", .{target_type}),
error.HandleExpired => v8x.throwErrorExceptionFmt(rt.alloc, rt.isolate, "Handle {s} expired", .{target_type}),
else => unreachable,
}
}
const GenJsFuncOptions = struct {
// Indicates that the native function is synchronous by nature but we want it async by executing it on a worker thread.
// User must make sure the native function is thread-safe.
// Deprecated. Prefer binding to an explicit function and then calling runtime.invokeFuncAsync.
asyncify: bool,
is_data_rt: bool,
};
const ParamFieldTag = enum {
This,
ThisValue,
ThisResource,
ThisHandle,
// Pointer is converted from this->getInternalField(0)
ThisPtr,
FuncData,
FuncDataUserPtr,
RuntimePtr,
Param,
};
/// Info about a native function callback.
fn JsFuncInfo(comptime NumParams: u32) type {
return struct {
// Maps native param idx to it's tag type.
param_tags: [NumParams]ParamFieldTag,
// Maps native param idx to the corresponding js param idx.
// Maps to null if the native param does not map to a js param.
param_js_idxs: [NumParams]?u32,
// Number of required js params.
num_req_js_params: u32,
};
}
pub fn getJsFuncInfo(comptime param_fields: []const std.builtin.TypeInfo.StructField) JsFuncInfo(param_fields.len) {
var param_tags: [param_fields.len]ParamFieldTag = undefined;
var param_js_idxs: [param_fields.len]?u32 = undefined;
var js_param_idx: u32 = 0;
var num_req_js_params: u32 = 0;
inline for (param_fields) |field, i| {
if (field.field_type == This) {
param_tags[i] = .This;
} else if (@typeInfo(field.field_type) == .Struct and @hasDecl(field.field_type, "ThisValue")) {
param_tags[i] = .ThisValue;
} else if (@typeInfo(field.field_type) == .Struct and @hasDecl(field.field_type, "ThisResource")) {
param_tags[i] = .ThisResource;
} else if (@typeInfo(field.field_type) == .Struct and @hasDecl(field.field_type, "ThisHandle")) {
param_tags[i] = .ThisHandle;
} else if (comptime std.meta.trait.isSingleItemPtr(field.field_type) and field.field_type != *RuntimeContext) {
param_tags[i] = .ThisPtr;
} else if (field.field_type == FuncData) {
param_tags[i] = .FuncData;
} else if (@typeInfo(field.field_type) == .Struct and @hasDecl(field.field_type, "FuncDataUserPtr")) {
param_tags[i] = .FuncDataUserPtr;
} else if (field.field_type == *RuntimeContext) {
param_tags[i] = .RuntimePtr;
} else {
param_tags[i] = .Param;
}
if (param_tags[i] == .Param) {
param_js_idxs[i] = js_param_idx;
js_param_idx += 1;
if (@typeInfo(field.field_type) != .Optional) {
num_req_js_params += 1;
}
} else {
param_js_idxs[i] = null;
}
}
return .{
.param_tags = param_tags,
.param_js_idxs = param_js_idxs,
.num_req_js_params = num_req_js_params,
};
}
/// native_cb: fn () Param | fn (Ptr) Param
pub fn genJsGetter(comptime native_cb: anytype) v8.AccessorNameGetterCallback {
const Args = stdx.meta.FnParams(@TypeOf(native_cb));
const HasSelf = Args.len > 0;
const HasSelfPtr = Args.len > 0 and comptime std.meta.trait.isSingleItemPtr(Args[0].arg_type.?);
const gen = struct {
fn get(_: ?*const v8.Name, raw_info: ?*const v8.C_PropertyCallbackInfo) callconv(.C) void {
const info = v8.PropertyCallbackInfo.initFromV8(raw_info);
const rt = stdx.mem.ptrCastAlign(*RuntimeContext, info.getExternalValue());
const iso = rt.isolate;
const ctx = rt.context;
var hscope: v8.HandleScope = undefined;
hscope.init(iso);
defer hscope.deinit();
const return_value = info.getReturnValue();
if (HasSelf) {
const Self = Args[0].arg_type.?;
const ptr = info.getThis().getInternalField(0).bitCastToU64(ctx);
if (ptr > 0) {
if (HasSelfPtr) {
const native_val = native_cb(@intToPtr(Self, ptr));
return_value.setValueHandle(rt.getJsValuePtr(native_val));
freeNativeValue(native_val);
} else {
const native_val = native_cb(@intToPtr(*Self, ptr).*);
return_value.setValueHandle(rt.getJsValuePtr(native_val));
freeNativeValue(rt.alloc, native_val);
}
} else {
v8x.throwErrorException(iso, "Handle has expired.");
return;
}
} else {
const native_val = native_cb();
return_value.setValueHandle(rt.getJsValuePtr(native_val));
freeNativeValue(rt.alloc, native_val);
}
}
};
return gen.get;
}
// native_cb: fn (Param) void | fn (Ptr, Param) void
pub fn genJsSetter(comptime native_cb: anytype) v8.AccessorNameSetterCallback {
const Args = stdx.meta.FnParams(@TypeOf(native_cb));
const HasPtr = Args.len > 0 and comptime std.meta.trait.isSingleItemPtr(Args[0].arg_type.?);
const Param = if (HasPtr) Args[1].arg_type.? else Args[0].arg_type.?;
const gen = struct {
fn set(_: ?*const v8.Name, value: ?*const anyopaque, raw_info: ?*const v8.C_PropertyCallbackInfo) callconv(.C) void {
const info = v8.PropertyCallbackInfo.initFromV8(raw_info);
const rt = stdx.mem.ptrCastAlign(*RuntimeContext, info.getExternalValue());
const iso = rt.isolate;
const ctx = rt.context;
var hscope: v8.HandleScope = undefined;
hscope.init(iso);
defer hscope.deinit();
const val = v8.Value{ .handle = value.? };
if (rt.getNativeValue(Param, val)) |native_val| {
if (HasPtr) {
const Ptr = Args[0].arg_type.?;
const ptr = info.getThis().getInternalField(0).bitCastToU64(ctx);
if (ptr > 0) {
native_cb(@intToPtr(Ptr, ptr), native_val);
} else {
v8x.throwErrorException(iso, "Handle has expired.");
return;
}
} else {
native_cb(native_val);
}
} else {
v8x.throwErrorExceptionFmt(rt.alloc, iso, "Could not convert to {s}", .{@typeName(Param)});
return;
}
}
};
return gen.set;
}
pub fn genJsFuncGetValue(comptime native_val: anytype) v8.FunctionCallback {
const gen = struct {
fn cb(raw_info: ?*const v8.C_FunctionCallbackInfo) callconv(.C) void {
const info = v8.FunctionCallbackInfo.initFromV8(raw_info);
const rt = stdx.mem.ptrCastAlign(*RuntimeContext, info.getExternalValue());
const iso = rt.isolate;
var hscope: v8.HandleScope = undefined;
hscope.init(iso);
defer hscope.deinit();
const return_value = info.getReturnValue();
return_value.setValueHandle(rt.getJsValuePtr(native_val));
}
};
return gen.cb;
}
fn freeNativeValue(alloc: std.mem.Allocator, native_val: anytype) void {
const Type = @TypeOf(native_val);
switch (Type) {
ds.Box([]const u8) => native_val.deinit(),
else => {
if (@typeInfo(Type) == .Optional) {
if (native_val) |child_val| {
freeNativeValue(alloc, child_val);
}
} else if (comptime std.meta.trait.isContainer(Type)) {
if (@hasDecl(Type, "ManagedSlice")) {
native_val.deinit();
} else if (@hasDecl(Type, "ManagedStruct")) {
native_val.deinit();
} else if (@hasDecl(Type, "RtTempStruct")) {
native_val.deinit(alloc);
}
}
}
}
}
|
runtime/gen.zig
|
const builtin = @import("builtin");
pub const struct_ZigClangConditionalOperator = @OpaqueType();
pub const struct_ZigClangBinaryConditionalOperator = @OpaqueType();
pub const struct_ZigClangAbstractConditionalOperator = @OpaqueType();
pub const struct_ZigClangAPInt = @OpaqueType();
pub const struct_ZigClangAPSInt = @OpaqueType();
pub const struct_ZigClangAPFloat = @OpaqueType();
pub const struct_ZigClangASTContext = @OpaqueType();
pub const struct_ZigClangASTUnit = @OpaqueType();
pub const struct_ZigClangArraySubscriptExpr = @OpaqueType();
pub const struct_ZigClangArrayType = @OpaqueType();
pub const struct_ZigClangAttributedType = @OpaqueType();
pub const struct_ZigClangBinaryOperator = @OpaqueType();
pub const struct_ZigClangBreakStmt = @OpaqueType();
pub const struct_ZigClangBuiltinType = @OpaqueType();
pub const struct_ZigClangCStyleCastExpr = @OpaqueType();
pub const struct_ZigClangCallExpr = @OpaqueType();
pub const struct_ZigClangCaseStmt = @OpaqueType();
pub const struct_ZigClangCompoundAssignOperator = @OpaqueType();
pub const struct_ZigClangCompoundStmt = @OpaqueType();
pub const struct_ZigClangConstantArrayType = @OpaqueType();
pub const struct_ZigClangContinueStmt = @OpaqueType();
pub const struct_ZigClangDecayedType = @OpaqueType();
pub const struct_ZigClangDecl = @OpaqueType();
pub const struct_ZigClangDeclRefExpr = @OpaqueType();
pub const struct_ZigClangDeclStmt = @OpaqueType();
pub const struct_ZigClangDefaultStmt = @OpaqueType();
pub const struct_ZigClangDiagnosticOptions = @OpaqueType();
pub const struct_ZigClangDiagnosticsEngine = @OpaqueType();
pub const struct_ZigClangDoStmt = @OpaqueType();
pub const struct_ZigClangElaboratedType = @OpaqueType();
pub const struct_ZigClangEnumConstantDecl = @OpaqueType();
pub const struct_ZigClangEnumDecl = @OpaqueType();
pub const struct_ZigClangEnumType = @OpaqueType();
pub const struct_ZigClangExpr = @OpaqueType();
pub const struct_ZigClangFieldDecl = @OpaqueType();
pub const struct_ZigClangFileID = @OpaqueType();
pub const struct_ZigClangForStmt = @OpaqueType();
pub const struct_ZigClangFullSourceLoc = @OpaqueType();
pub const struct_ZigClangFunctionDecl = @OpaqueType();
pub const struct_ZigClangFunctionProtoType = @OpaqueType();
pub const struct_ZigClangIfStmt = @OpaqueType();
pub const struct_ZigClangImplicitCastExpr = @OpaqueType();
pub const struct_ZigClangIncompleteArrayType = @OpaqueType();
pub const struct_ZigClangIntegerLiteral = @OpaqueType();
pub const struct_ZigClangMacroDefinitionRecord = @OpaqueType();
pub const struct_ZigClangMacroExpansion = @OpaqueType();
pub const struct_ZigClangMacroQualifiedType = @OpaqueType();
pub const struct_ZigClangMemberExpr = @OpaqueType();
pub const struct_ZigClangNamedDecl = @OpaqueType();
pub const struct_ZigClangNone = @OpaqueType();
pub const struct_ZigClangOpaqueValueExpr = @OpaqueType();
pub const struct_ZigClangPCHContainerOperations = @OpaqueType();
pub const struct_ZigClangParenExpr = @OpaqueType();
pub const struct_ZigClangParenType = @OpaqueType();
pub const struct_ZigClangParmVarDecl = @OpaqueType();
pub const struct_ZigClangPointerType = @OpaqueType();
pub const struct_ZigClangPreprocessedEntity = @OpaqueType();
pub const struct_ZigClangRecordDecl = @OpaqueType();
pub const struct_ZigClangRecordType = @OpaqueType();
pub const struct_ZigClangReturnStmt = @OpaqueType();
pub const struct_ZigClangSkipFunctionBodiesScope = @OpaqueType();
pub const struct_ZigClangSourceManager = @OpaqueType();
pub const struct_ZigClangSourceRange = @OpaqueType();
pub const struct_ZigClangStmt = @OpaqueType();
pub const struct_ZigClangStringLiteral = @OpaqueType();
pub const struct_ZigClangStringRef = @OpaqueType();
pub const struct_ZigClangSwitchStmt = @OpaqueType();
pub const struct_ZigClangTagDecl = @OpaqueType();
pub const struct_ZigClangType = @OpaqueType();
pub const struct_ZigClangTypedefNameDecl = @OpaqueType();
pub const struct_ZigClangTypedefType = @OpaqueType();
pub const struct_ZigClangUnaryExprOrTypeTraitExpr = @OpaqueType();
pub const struct_ZigClangUnaryOperator = @OpaqueType();
pub const struct_ZigClangValueDecl = @OpaqueType();
pub const struct_ZigClangVarDecl = @OpaqueType();
pub const struct_ZigClangWhileStmt = @OpaqueType();
pub const struct_ZigClangFunctionType = @OpaqueType();
pub const struct_ZigClangPredefinedExpr = @OpaqueType();
pub const struct_ZigClangInitListExpr = @OpaqueType();
pub const ZigClangPreprocessingRecord = @OpaqueType();
pub const ZigClangFloatingLiteral = @OpaqueType();
pub const ZigClangConstantExpr = @OpaqueType();
pub const ZigClangCharacterLiteral = @OpaqueType();
pub const ZigClangStmtExpr = @OpaqueType();
pub const ZigClangBO = extern enum {
PtrMemD,
PtrMemI,
Mul,
Div,
Rem,
Add,
Sub,
Shl,
Shr,
Cmp,
LT,
GT,
LE,
GE,
EQ,
NE,
And,
Xor,
Or,
LAnd,
LOr,
Assign,
MulAssign,
DivAssign,
RemAssign,
AddAssign,
SubAssign,
ShlAssign,
ShrAssign,
AndAssign,
XorAssign,
OrAssign,
Comma,
};
pub const ZigClangUO = extern enum {
PostInc,
PostDec,
PreInc,
PreDec,
AddrOf,
Deref,
Plus,
Minus,
Not,
LNot,
Real,
Imag,
Extension,
Coawait,
};
pub const ZigClangTypeClass = extern enum {
Builtin,
Complex,
Pointer,
BlockPointer,
LValueReference,
RValueReference,
MemberPointer,
ConstantArray,
IncompleteArray,
VariableArray,
DependentSizedArray,
DependentSizedExtVector,
DependentAddressSpace,
Vector,
DependentVector,
ExtVector,
FunctionProto,
FunctionNoProto,
UnresolvedUsing,
Paren,
Typedef,
MacroQualified,
Adjusted,
Decayed,
TypeOfExpr,
TypeOf,
Decltype,
UnaryTransform,
Record,
Enum,
Elaborated,
Attributed,
TemplateTypeParm,
SubstTemplateTypeParm,
SubstTemplateTypeParmPack,
TemplateSpecialization,
Auto,
DeducedTemplateSpecialization,
InjectedClassName,
DependentName,
DependentTemplateSpecialization,
PackExpansion,
ObjCTypeParam,
ObjCObject,
ObjCInterface,
ObjCObjectPointer,
Pipe,
Atomic,
};
const ZigClangStmtClass = extern enum {
NoStmtClass,
GCCAsmStmtClass,
MSAsmStmtClass,
BreakStmtClass,
CXXCatchStmtClass,
CXXForRangeStmtClass,
CXXTryStmtClass,
CapturedStmtClass,
CompoundStmtClass,
ContinueStmtClass,
CoreturnStmtClass,
CoroutineBodyStmtClass,
DeclStmtClass,
DoStmtClass,
ForStmtClass,
GotoStmtClass,
IfStmtClass,
IndirectGotoStmtClass,
MSDependentExistsStmtClass,
NullStmtClass,
OMPAtomicDirectiveClass,
OMPBarrierDirectiveClass,
OMPCancelDirectiveClass,
OMPCancellationPointDirectiveClass,
OMPCriticalDirectiveClass,
OMPFlushDirectiveClass,
OMPDistributeDirectiveClass,
OMPDistributeParallelForDirectiveClass,
OMPDistributeParallelForSimdDirectiveClass,
OMPDistributeSimdDirectiveClass,
OMPForDirectiveClass,
OMPForSimdDirectiveClass,
OMPParallelForDirectiveClass,
OMPParallelForSimdDirectiveClass,
OMPSimdDirectiveClass,
OMPTargetParallelForSimdDirectiveClass,
OMPTargetSimdDirectiveClass,
OMPTargetTeamsDistributeDirectiveClass,
OMPTargetTeamsDistributeParallelForDirectiveClass,
OMPTargetTeamsDistributeParallelForSimdDirectiveClass,
OMPTargetTeamsDistributeSimdDirectiveClass,
OMPTaskLoopDirectiveClass,
OMPTaskLoopSimdDirectiveClass,
OMPTeamsDistributeDirectiveClass,
OMPTeamsDistributeParallelForDirectiveClass,
OMPTeamsDistributeParallelForSimdDirectiveClass,
OMPTeamsDistributeSimdDirectiveClass,
OMPMasterDirectiveClass,
OMPOrderedDirectiveClass,
OMPParallelDirectiveClass,
OMPParallelSectionsDirectiveClass,
OMPSectionDirectiveClass,
OMPSectionsDirectiveClass,
OMPSingleDirectiveClass,
OMPTargetDataDirectiveClass,
OMPTargetDirectiveClass,
OMPTargetEnterDataDirectiveClass,
OMPTargetExitDataDirectiveClass,
OMPTargetParallelDirectiveClass,
OMPTargetParallelForDirectiveClass,
OMPTargetTeamsDirectiveClass,
OMPTargetUpdateDirectiveClass,
OMPTaskDirectiveClass,
OMPTaskgroupDirectiveClass,
OMPTaskwaitDirectiveClass,
OMPTaskyieldDirectiveClass,
OMPTeamsDirectiveClass,
ObjCAtCatchStmtClass,
ObjCAtFinallyStmtClass,
ObjCAtSynchronizedStmtClass,
ObjCAtThrowStmtClass,
ObjCAtTryStmtClass,
ObjCAutoreleasePoolStmtClass,
ObjCForCollectionStmtClass,
ReturnStmtClass,
SEHExceptStmtClass,
SEHFinallyStmtClass,
SEHLeaveStmtClass,
SEHTryStmtClass,
CaseStmtClass,
DefaultStmtClass,
SwitchStmtClass,
AttributedStmtClass,
BinaryConditionalOperatorClass,
ConditionalOperatorClass,
AddrLabelExprClass,
ArrayInitIndexExprClass,
ArrayInitLoopExprClass,
ArraySubscriptExprClass,
ArrayTypeTraitExprClass,
AsTypeExprClass,
AtomicExprClass,
BinaryOperatorClass,
CompoundAssignOperatorClass,
BlockExprClass,
CXXBindTemporaryExprClass,
CXXBoolLiteralExprClass,
CXXConstructExprClass,
CXXTemporaryObjectExprClass,
CXXDefaultArgExprClass,
CXXDefaultInitExprClass,
CXXDeleteExprClass,
CXXDependentScopeMemberExprClass,
CXXFoldExprClass,
CXXInheritedCtorInitExprClass,
CXXNewExprClass,
CXXNoexceptExprClass,
CXXNullPtrLiteralExprClass,
CXXPseudoDestructorExprClass,
CXXScalarValueInitExprClass,
CXXStdInitializerListExprClass,
CXXThisExprClass,
CXXThrowExprClass,
CXXTypeidExprClass,
CXXUnresolvedConstructExprClass,
CXXUuidofExprClass,
CallExprClass,
CUDAKernelCallExprClass,
CXXMemberCallExprClass,
CXXOperatorCallExprClass,
UserDefinedLiteralClass,
BuiltinBitCastExprClass,
CStyleCastExprClass,
CXXFunctionalCastExprClass,
CXXConstCastExprClass,
CXXDynamicCastExprClass,
CXXReinterpretCastExprClass,
CXXStaticCastExprClass,
ObjCBridgedCastExprClass,
ImplicitCastExprClass,
CharacterLiteralClass,
ChooseExprClass,
CompoundLiteralExprClass,
ConvertVectorExprClass,
CoawaitExprClass,
CoyieldExprClass,
DeclRefExprClass,
DependentCoawaitExprClass,
DependentScopeDeclRefExprClass,
DesignatedInitExprClass,
DesignatedInitUpdateExprClass,
ExpressionTraitExprClass,
ExtVectorElementExprClass,
FixedPointLiteralClass,
FloatingLiteralClass,
ConstantExprClass,
ExprWithCleanupsClass,
FunctionParmPackExprClass,
GNUNullExprClass,
GenericSelectionExprClass,
ImaginaryLiteralClass,
ImplicitValueInitExprClass,
InitListExprClass,
IntegerLiteralClass,
LambdaExprClass,
MSPropertyRefExprClass,
MSPropertySubscriptExprClass,
MaterializeTemporaryExprClass,
MemberExprClass,
NoInitExprClass,
OMPArraySectionExprClass,
ObjCArrayLiteralClass,
ObjCAvailabilityCheckExprClass,
ObjCBoolLiteralExprClass,
ObjCBoxedExprClass,
ObjCDictionaryLiteralClass,
ObjCEncodeExprClass,
ObjCIndirectCopyRestoreExprClass,
ObjCIsaExprClass,
ObjCIvarRefExprClass,
ObjCMessageExprClass,
ObjCPropertyRefExprClass,
ObjCProtocolExprClass,
ObjCSelectorExprClass,
ObjCStringLiteralClass,
ObjCSubscriptRefExprClass,
OffsetOfExprClass,
OpaqueValueExprClass,
UnresolvedLookupExprClass,
UnresolvedMemberExprClass,
PackExpansionExprClass,
ParenExprClass,
ParenListExprClass,
PredefinedExprClass,
PseudoObjectExprClass,
ShuffleVectorExprClass,
SizeOfPackExprClass,
SourceLocExprClass,
StmtExprClass,
StringLiteralClass,
SubstNonTypeTemplateParmExprClass,
SubstNonTypeTemplateParmPackExprClass,
TypeTraitExprClass,
TypoExprClass,
UnaryExprOrTypeTraitExprClass,
UnaryOperatorClass,
VAArgExprClass,
LabelStmtClass,
WhileStmtClass,
};
pub const ZigClangCK = extern enum {
Dependent,
BitCast,
LValueBitCast,
LValueToRValueBitCast,
LValueToRValue,
NoOp,
BaseToDerived,
DerivedToBase,
UncheckedDerivedToBase,
Dynamic,
ToUnion,
ArrayToPointerDecay,
FunctionToPointerDecay,
NullToPointer,
NullToMemberPointer,
BaseToDerivedMemberPointer,
DerivedToBaseMemberPointer,
MemberPointerToBoolean,
ReinterpretMemberPointer,
UserDefinedConversion,
ConstructorConversion,
IntegralToPointer,
PointerToIntegral,
PointerToBoolean,
ToVoid,
VectorSplat,
IntegralCast,
IntegralToBoolean,
IntegralToFloating,
FixedPointCast,
FixedPointToIntegral,
IntegralToFixedPoint,
FixedPointToBoolean,
FloatingToIntegral,
FloatingToBoolean,
BooleanToSignedIntegral,
FloatingCast,
CPointerToObjCPointerCast,
BlockPointerToObjCPointerCast,
AnyPointerToBlockPointerCast,
ObjCObjectLValueCast,
FloatingRealToComplex,
FloatingComplexToReal,
FloatingComplexToBoolean,
FloatingComplexCast,
FloatingComplexToIntegralComplex,
IntegralRealToComplex,
IntegralComplexToReal,
IntegralComplexToBoolean,
IntegralComplexCast,
IntegralComplexToFloatingComplex,
ARCProduceObject,
ARCConsumeObject,
ARCReclaimReturnedObject,
ARCExtendBlockObject,
AtomicToNonAtomic,
NonAtomicToAtomic,
CopyAndAutoreleaseBlockObject,
BuiltinFnToFnPtr,
ZeroToOCLOpaqueType,
AddressSpaceConversion,
IntToOCLSampler,
};
pub const ZigClangAPValueKind = extern enum {
None,
Indeterminate,
Int,
Float,
FixedPoint,
ComplexInt,
ComplexFloat,
LValue,
Vector,
Array,
Struct,
Union,
MemberPointer,
AddrLabelDiff,
};
pub const ZigClangDeclKind = extern enum {
AccessSpec,
Block,
Captured,
ClassScopeFunctionSpecialization,
Empty,
Export,
ExternCContext,
FileScopeAsm,
Friend,
FriendTemplate,
Import,
LinkageSpec,
Label,
Namespace,
NamespaceAlias,
ObjCCompatibleAlias,
ObjCCategory,
ObjCCategoryImpl,
ObjCImplementation,
ObjCInterface,
ObjCProtocol,
ObjCMethod,
ObjCProperty,
BuiltinTemplate,
Concept,
ClassTemplate,
FunctionTemplate,
TypeAliasTemplate,
VarTemplate,
TemplateTemplateParm,
Enum,
Record,
CXXRecord,
ClassTemplateSpecialization,
ClassTemplatePartialSpecialization,
TemplateTypeParm,
ObjCTypeParam,
TypeAlias,
Typedef,
UnresolvedUsingTypename,
Using,
UsingDirective,
UsingPack,
UsingShadow,
ConstructorUsingShadow,
Binding,
Field,
ObjCAtDefsField,
ObjCIvar,
Function,
CXXDeductionGuide,
CXXMethod,
CXXConstructor,
CXXConversion,
CXXDestructor,
MSProperty,
NonTypeTemplateParm,
Var,
Decomposition,
ImplicitParam,
OMPCapturedExpr,
ParmVar,
VarTemplateSpecialization,
VarTemplatePartialSpecialization,
EnumConstant,
IndirectField,
OMPDeclareMapper,
OMPDeclareReduction,
UnresolvedUsingValue,
OMPAllocate,
OMPRequires,
OMPThreadPrivate,
ObjCPropertyImpl,
PragmaComment,
PragmaDetectMismatch,
StaticAssert,
TranslationUnit,
};
pub const ZigClangBuiltinTypeKind = extern enum {
OCLImage1dRO,
OCLImage1dArrayRO,
OCLImage1dBufferRO,
OCLImage2dRO,
OCLImage2dArrayRO,
OCLImage2dDepthRO,
OCLImage2dArrayDepthRO,
OCLImage2dMSAARO,
OCLImage2dArrayMSAARO,
OCLImage2dMSAADepthRO,
OCLImage2dArrayMSAADepthRO,
OCLImage3dRO,
OCLImage1dWO,
OCLImage1dArrayWO,
OCLImage1dBufferWO,
OCLImage2dWO,
OCLImage2dArrayWO,
OCLImage2dDepthWO,
OCLImage2dArrayDepthWO,
OCLImage2dMSAAWO,
OCLImage2dArrayMSAAWO,
OCLImage2dMSAADepthWO,
OCLImage2dArrayMSAADepthWO,
OCLImage3dWO,
OCLImage1dRW,
OCLImage1dArrayRW,
OCLImage1dBufferRW,
OCLImage2dRW,
OCLImage2dArrayRW,
OCLImage2dDepthRW,
OCLImage2dArrayDepthRW,
OCLImage2dMSAARW,
OCLImage2dArrayMSAARW,
OCLImage2dMSAADepthRW,
OCLImage2dArrayMSAADepthRW,
OCLImage3dRW,
OCLIntelSubgroupAVCMcePayload,
OCLIntelSubgroupAVCImePayload,
OCLIntelSubgroupAVCRefPayload,
OCLIntelSubgroupAVCSicPayload,
OCLIntelSubgroupAVCMceResult,
OCLIntelSubgroupAVCImeResult,
OCLIntelSubgroupAVCRefResult,
OCLIntelSubgroupAVCSicResult,
OCLIntelSubgroupAVCImeResultSingleRefStreamout,
OCLIntelSubgroupAVCImeResultDualRefStreamout,
OCLIntelSubgroupAVCImeSingleRefStreamin,
OCLIntelSubgroupAVCImeDualRefStreamin,
Void,
Bool,
Char_U,
UChar,
WChar_U,
Char8,
Char16,
Char32,
UShort,
UInt,
ULong,
ULongLong,
UInt128,
Char_S,
SChar,
WChar_S,
Short,
Int,
Long,
LongLong,
Int128,
ShortAccum,
Accum,
LongAccum,
UShortAccum,
UAccum,
ULongAccum,
ShortFract,
Fract,
LongFract,
UShortFract,
UFract,
ULongFract,
SatShortAccum,
SatAccum,
SatLongAccum,
SatUShortAccum,
SatUAccum,
SatULongAccum,
SatShortFract,
SatFract,
SatLongFract,
SatUShortFract,
SatUFract,
SatULongFract,
Half,
Float,
Double,
LongDouble,
Float16,
Float128,
NullPtr,
ObjCId,
ObjCClass,
ObjCSel,
OCLSampler,
OCLEvent,
OCLClkEvent,
OCLQueue,
OCLReserveID,
Dependent,
Overload,
BoundMember,
PseudoObject,
UnknownAny,
BuiltinFn,
ARCUnbridgedCast,
OMPArraySection,
};
pub const ZigClangCallingConv = extern enum {
C,
X86StdCall,
X86FastCall,
X86ThisCall,
X86VectorCall,
X86Pascal,
Win64,
X86_64SysV,
X86RegCall,
AAPCS,
AAPCS_VFP,
IntelOclBicc,
SpirFunction,
OpenCLKernel,
Swift,
PreserveMost,
PreserveAll,
AArch64VectorCall,
};
pub const ZigClangStorageClass = extern enum {
None,
Extern,
Static,
PrivateExtern,
Auto,
Register,
};
pub const ZigClangAPFloat_roundingMode = extern enum {
NearestTiesToEven,
TowardPositive,
TowardNegative,
TowardZero,
NearestTiesToAway,
};
pub const ZigClangStringLiteral_StringKind = extern enum {
Ascii,
Wide,
UTF8,
UTF16,
UTF32,
};
pub const ZigClangCharacterLiteral_CharacterKind = extern enum {
Ascii,
Wide,
UTF8,
UTF16,
UTF32,
};
pub const ZigClangRecordDecl_field_iterator = extern struct {
opaque: *c_void,
};
pub const ZigClangEnumDecl_enumerator_iterator = extern struct {
opaque: *c_void,
};
pub const ZigClangPreprocessingRecord_iterator = extern struct {
I: c_int,
Self: *ZigClangPreprocessingRecord,
};
pub const ZigClangPreprocessedEntity_EntityKind = extern enum {
InvalidKind,
MacroExpansionKind,
MacroDefinitionKind,
InclusionDirectiveKind,
};
pub const ZigClangExpr_ConstExprUsage = extern enum {
EvaluateForCodeGen,
EvaluateForMangling,
};
pub extern fn ZigClangSourceManager_getSpellingLoc(self: ?*const struct_ZigClangSourceManager, Loc: struct_ZigClangSourceLocation) struct_ZigClangSourceLocation;
pub extern fn ZigClangSourceManager_getFilename(self: *const struct_ZigClangSourceManager, SpellingLoc: struct_ZigClangSourceLocation) ?[*:0]const u8;
pub extern fn ZigClangSourceManager_getSpellingLineNumber(self: ?*const struct_ZigClangSourceManager, Loc: struct_ZigClangSourceLocation) c_uint;
pub extern fn ZigClangSourceManager_getSpellingColumnNumber(self: ?*const struct_ZigClangSourceManager, Loc: struct_ZigClangSourceLocation) c_uint;
pub extern fn ZigClangSourceManager_getCharacterData(self: ?*const struct_ZigClangSourceManager, SL: struct_ZigClangSourceLocation) [*:0]const u8;
pub extern fn ZigClangASTContext_getPointerType(self: ?*const struct_ZigClangASTContext, T: struct_ZigClangQualType) struct_ZigClangQualType;
pub extern fn ZigClangASTUnit_getASTContext(self: ?*struct_ZigClangASTUnit) ?*struct_ZigClangASTContext;
pub extern fn ZigClangASTUnit_getSourceManager(self: *struct_ZigClangASTUnit) *struct_ZigClangSourceManager;
pub extern fn ZigClangASTUnit_visitLocalTopLevelDecls(self: *struct_ZigClangASTUnit, context: ?*c_void, Fn: ?extern fn (?*c_void, *const struct_ZigClangDecl) bool) bool;
pub extern fn ZigClangRecordType_getDecl(record_ty: ?*const struct_ZigClangRecordType) *const struct_ZigClangRecordDecl;
pub extern fn ZigClangTagDecl_isThisDeclarationADefinition(self: *const ZigClangTagDecl) bool;
pub extern fn ZigClangEnumType_getDecl(record_ty: ?*const struct_ZigClangEnumType) *const struct_ZigClangEnumDecl;
pub extern fn ZigClangRecordDecl_getCanonicalDecl(record_decl: ?*const struct_ZigClangRecordDecl) ?*const struct_ZigClangTagDecl;
pub extern fn ZigClangFieldDecl_getCanonicalDecl(field_decl: ?*const struct_ZigClangFieldDecl) ?*const struct_ZigClangFieldDecl;
pub extern fn ZigClangEnumDecl_getCanonicalDecl(self: ?*const struct_ZigClangEnumDecl) ?*const struct_ZigClangTagDecl;
pub extern fn ZigClangTypedefNameDecl_getCanonicalDecl(self: ?*const struct_ZigClangTypedefNameDecl) ?*const struct_ZigClangTypedefNameDecl;
pub extern fn ZigClangFunctionDecl_getCanonicalDecl(self: ?*const struct_ZigClangFunctionDecl) ?*const struct_ZigClangFunctionDecl;
pub extern fn ZigClangVarDecl_getCanonicalDecl(self: ?*const struct_ZigClangVarDecl) ?*const struct_ZigClangVarDecl;
pub extern fn ZigClangVarDecl_getSectionAttribute(self: *const ZigClangVarDecl, len: *usize) ?[*]const u8;
pub extern fn ZigClangFunctionDecl_getAlignedAttribute(self: *const ZigClangFunctionDecl, *const ZigClangASTContext) c_uint;
pub extern fn ZigClangVarDecl_getAlignedAttribute(self: *const ZigClangVarDecl, *const ZigClangASTContext) c_uint;
pub extern fn ZigClangRecordDecl_getPackedAttribute(self: ?*const struct_ZigClangRecordDecl) bool;
pub extern fn ZigClangRecordDecl_getDefinition(self: ?*const struct_ZigClangRecordDecl) ?*const struct_ZigClangRecordDecl;
pub extern fn ZigClangEnumDecl_getDefinition(self: ?*const struct_ZigClangEnumDecl) ?*const struct_ZigClangEnumDecl;
pub extern fn ZigClangRecordDecl_getLocation(self: ?*const struct_ZigClangRecordDecl) struct_ZigClangSourceLocation;
pub extern fn ZigClangEnumDecl_getLocation(self: ?*const struct_ZigClangEnumDecl) struct_ZigClangSourceLocation;
pub extern fn ZigClangTypedefNameDecl_getLocation(self: ?*const struct_ZigClangTypedefNameDecl) struct_ZigClangSourceLocation;
pub extern fn ZigClangDecl_getLocation(self: *const ZigClangDecl) ZigClangSourceLocation;
pub extern fn ZigClangRecordDecl_isUnion(record_decl: ?*const struct_ZigClangRecordDecl) bool;
pub extern fn ZigClangRecordDecl_isStruct(record_decl: ?*const struct_ZigClangRecordDecl) bool;
pub extern fn ZigClangRecordDecl_isAnonymousStructOrUnion(record_decl: ?*const struct_ZigClangRecordDecl) bool;
pub extern fn ZigClangRecordDecl_field_begin(*const struct_ZigClangRecordDecl) ZigClangRecordDecl_field_iterator;
pub extern fn ZigClangRecordDecl_field_end(*const struct_ZigClangRecordDecl) ZigClangRecordDecl_field_iterator;
pub extern fn ZigClangRecordDecl_field_iterator_next(ZigClangRecordDecl_field_iterator) ZigClangRecordDecl_field_iterator;
pub extern fn ZigClangRecordDecl_field_iterator_deref(ZigClangRecordDecl_field_iterator) *const struct_ZigClangFieldDecl;
pub extern fn ZigClangRecordDecl_field_iterator_neq(ZigClangRecordDecl_field_iterator, ZigClangRecordDecl_field_iterator) bool;
pub extern fn ZigClangEnumDecl_getIntegerType(self: ?*const struct_ZigClangEnumDecl) struct_ZigClangQualType;
pub extern fn ZigClangEnumDecl_enumerator_begin(*const ZigClangEnumDecl) ZigClangEnumDecl_enumerator_iterator;
pub extern fn ZigClangEnumDecl_enumerator_end(*const ZigClangEnumDecl) ZigClangEnumDecl_enumerator_iterator;
pub extern fn ZigClangEnumDecl_enumerator_iterator_next(ZigClangEnumDecl_enumerator_iterator) ZigClangEnumDecl_enumerator_iterator;
pub extern fn ZigClangEnumDecl_enumerator_iterator_deref(ZigClangEnumDecl_enumerator_iterator) *const ZigClangEnumConstantDecl;
pub extern fn ZigClangEnumDecl_enumerator_iterator_neq(ZigClangEnumDecl_enumerator_iterator, ZigClangEnumDecl_enumerator_iterator) bool;
pub extern fn ZigClangDecl_castToNamedDecl(decl: *const struct_ZigClangDecl) ?*const ZigClangNamedDecl;
pub extern fn ZigClangNamedDecl_getName_bytes_begin(decl: ?*const struct_ZigClangNamedDecl) [*:0]const u8;
pub extern fn ZigClangSourceLocation_eq(a: struct_ZigClangSourceLocation, b: struct_ZigClangSourceLocation) bool;
pub extern fn ZigClangTypedefType_getDecl(self: ?*const struct_ZigClangTypedefType) *const struct_ZigClangTypedefNameDecl;
pub extern fn ZigClangTypedefNameDecl_getUnderlyingType(self: ?*const struct_ZigClangTypedefNameDecl) struct_ZigClangQualType;
pub extern fn ZigClangQualType_getCanonicalType(self: struct_ZigClangQualType) struct_ZigClangQualType;
pub extern fn ZigClangQualType_getTypeClass(self: struct_ZigClangQualType) ZigClangTypeClass;
pub extern fn ZigClangQualType_getTypePtr(self: struct_ZigClangQualType) *const struct_ZigClangType;
pub extern fn ZigClangQualType_addConst(self: *struct_ZigClangQualType) void;
pub extern fn ZigClangQualType_eq(self: struct_ZigClangQualType, arg1: struct_ZigClangQualType) bool;
pub extern fn ZigClangQualType_isConstQualified(self: struct_ZigClangQualType) bool;
pub extern fn ZigClangQualType_isVolatileQualified(self: struct_ZigClangQualType) bool;
pub extern fn ZigClangQualType_isRestrictQualified(self: struct_ZigClangQualType) bool;
pub extern fn ZigClangType_getTypeClass(self: ?*const struct_ZigClangType) ZigClangTypeClass;
pub extern fn ZigClangType_getPointeeType(self: ?*const struct_ZigClangType) struct_ZigClangQualType;
pub extern fn ZigClangType_isVoidType(self: ?*const struct_ZigClangType) bool;
pub extern fn ZigClangType_isRecordType(self: ?*const struct_ZigClangType) bool;
pub extern fn ZigClangType_isArrayType(self: ?*const struct_ZigClangType) bool;
pub extern fn ZigClangType_isBooleanType(self: ?*const struct_ZigClangType) bool;
pub extern fn ZigClangType_getTypeClassName(self: *const struct_ZigClangType) [*:0]const u8;
pub extern fn ZigClangType_getAsArrayTypeUnsafe(self: *const ZigClangType) *const ZigClangArrayType;
pub extern fn ZigClangType_getAsRecordType(self: *const ZigClangType) ?*const ZigClangRecordType;
pub extern fn ZigClangType_getAsUnionType(self: *const ZigClangType) ?*const ZigClangRecordType;
pub extern fn ZigClangStmt_getBeginLoc(self: *const struct_ZigClangStmt) struct_ZigClangSourceLocation;
pub extern fn ZigClangStmt_getStmtClass(self: ?*const struct_ZigClangStmt) ZigClangStmtClass;
pub extern fn ZigClangStmt_classof_Expr(self: ?*const struct_ZigClangStmt) bool;
pub extern fn ZigClangExpr_getStmtClass(self: *const struct_ZigClangExpr) ZigClangStmtClass;
pub extern fn ZigClangExpr_getType(self: *const struct_ZigClangExpr) struct_ZigClangQualType;
pub extern fn ZigClangExpr_getBeginLoc(self: *const struct_ZigClangExpr) struct_ZigClangSourceLocation;
pub extern fn ZigClangInitListExpr_getInit(self: ?*const struct_ZigClangInitListExpr, i: c_uint) *const ZigClangExpr;
pub extern fn ZigClangInitListExpr_getArrayFiller(self: ?*const struct_ZigClangInitListExpr) *const ZigClangExpr;
pub extern fn ZigClangInitListExpr_getNumInits(self: ?*const struct_ZigClangInitListExpr) c_uint;
pub extern fn ZigClangInitListExpr_getInitializedFieldInUnion(self: ?*const struct_ZigClangInitListExpr) ?*ZigClangFieldDecl;
pub extern fn ZigClangAPValue_getKind(self: ?*const struct_ZigClangAPValue) ZigClangAPValueKind;
pub extern fn ZigClangAPValue_getInt(self: ?*const struct_ZigClangAPValue) *const struct_ZigClangAPSInt;
pub extern fn ZigClangAPValue_getArrayInitializedElts(self: ?*const struct_ZigClangAPValue) c_uint;
pub extern fn ZigClangAPValue_getArraySize(self: ?*const struct_ZigClangAPValue) c_uint;
pub extern fn ZigClangAPValue_getLValueBase(self: ?*const struct_ZigClangAPValue) struct_ZigClangAPValueLValueBase;
pub extern fn ZigClangAPSInt_isSigned(self: *const struct_ZigClangAPSInt) bool;
pub extern fn ZigClangAPSInt_isNegative(self: *const struct_ZigClangAPSInt) bool;
pub extern fn ZigClangAPSInt_negate(self: *const struct_ZigClangAPSInt) *const struct_ZigClangAPSInt;
pub extern fn ZigClangAPSInt_free(self: *const struct_ZigClangAPSInt) void;
pub extern fn ZigClangAPSInt_getRawData(self: *const struct_ZigClangAPSInt) [*:0]const u64;
pub extern fn ZigClangAPSInt_getNumWords(self: *const struct_ZigClangAPSInt) c_uint;
pub extern fn ZigClangAPInt_getLimitedValue(self: *const struct_ZigClangAPInt, limit: u64) u64;
pub extern fn ZigClangAPValueLValueBase_dyn_cast_Expr(self: struct_ZigClangAPValueLValueBase) ?*const struct_ZigClangExpr;
pub extern fn ZigClangASTUnit_delete(self: ?*struct_ZigClangASTUnit) void;
pub extern fn ZigClangFunctionDecl_getType(self: *const ZigClangFunctionDecl) struct_ZigClangQualType;
pub extern fn ZigClangFunctionDecl_getLocation(self: *const ZigClangFunctionDecl) struct_ZigClangSourceLocation;
pub extern fn ZigClangFunctionDecl_hasBody(self: *const ZigClangFunctionDecl) bool;
pub extern fn ZigClangFunctionDecl_getStorageClass(self: *const ZigClangFunctionDecl) ZigClangStorageClass;
pub extern fn ZigClangFunctionDecl_getParamDecl(self: *const ZigClangFunctionDecl, i: c_uint) *const struct_ZigClangParmVarDecl;
pub extern fn ZigClangFunctionDecl_getBody(self: *const ZigClangFunctionDecl) *const struct_ZigClangStmt;
pub extern fn ZigClangFunctionDecl_doesDeclarationForceExternallyVisibleDefinition(self: *const ZigClangFunctionDecl) bool;
pub extern fn ZigClangFunctionDecl_isThisDeclarationADefinition(self: *const ZigClangFunctionDecl) bool;
pub extern fn ZigClangFunctionDecl_doesThisDeclarationHaveABody(self: *const ZigClangFunctionDecl) bool;
pub extern fn ZigClangFunctionDecl_isInlineSpecified(self: *const ZigClangFunctionDecl) bool;
pub extern fn ZigClangFunctionDecl_isDefined(self: *const ZigClangFunctionDecl) bool;
pub extern fn ZigClangFunctionDecl_getDefinition(self: *const ZigClangFunctionDecl) ?*const struct_ZigClangFunctionDecl;
pub extern fn ZigClangFunctionDecl_getSectionAttribute(self: *const ZigClangFunctionDecl, len: *usize) ?[*]const u8;
pub extern fn ZigClangBuiltinType_getKind(self: *const struct_ZigClangBuiltinType) ZigClangBuiltinTypeKind;
pub extern fn ZigClangFunctionType_getNoReturnAttr(self: *const ZigClangFunctionType) bool;
pub extern fn ZigClangFunctionType_getCallConv(self: *const ZigClangFunctionType) ZigClangCallingConv;
pub extern fn ZigClangFunctionType_getReturnType(self: *const ZigClangFunctionType) ZigClangQualType;
pub extern fn ZigClangFunctionProtoType_isVariadic(self: *const struct_ZigClangFunctionProtoType) bool;
pub extern fn ZigClangFunctionProtoType_getNumParams(self: *const struct_ZigClangFunctionProtoType) c_uint;
pub extern fn ZigClangFunctionProtoType_getParamType(self: *const struct_ZigClangFunctionProtoType, i: c_uint) ZigClangQualType;
pub extern fn ZigClangFunctionProtoType_getReturnType(self: *const ZigClangFunctionProtoType) ZigClangQualType;
pub const ZigClangSourceLocation = struct_ZigClangSourceLocation;
pub const ZigClangQualType = struct_ZigClangQualType;
pub const ZigClangConditionalOperator = struct_ZigClangConditionalOperator;
pub const ZigClangBinaryConditionalOperator = struct_ZigClangBinaryConditionalOperator;
pub const ZigClangAbstractConditionalOperator = struct_ZigClangAbstractConditionalOperator;
pub const ZigClangAPValueLValueBase = struct_ZigClangAPValueLValueBase;
pub const ZigClangAPValue = struct_ZigClangAPValue;
pub const ZigClangAPSInt = struct_ZigClangAPSInt;
pub const ZigClangAPFloat = struct_ZigClangAPFloat;
pub const ZigClangASTContext = struct_ZigClangASTContext;
pub const ZigClangASTUnit = struct_ZigClangASTUnit;
pub const ZigClangArraySubscriptExpr = struct_ZigClangArraySubscriptExpr;
pub const ZigClangArrayType = struct_ZigClangArrayType;
pub const ZigClangAttributedType = struct_ZigClangAttributedType;
pub const ZigClangBinaryOperator = struct_ZigClangBinaryOperator;
pub const ZigClangBreakStmt = struct_ZigClangBreakStmt;
pub const ZigClangBuiltinType = struct_ZigClangBuiltinType;
pub const ZigClangCStyleCastExpr = struct_ZigClangCStyleCastExpr;
pub const ZigClangCallExpr = struct_ZigClangCallExpr;
pub const ZigClangCaseStmt = struct_ZigClangCaseStmt;
pub const ZigClangCompoundAssignOperator = struct_ZigClangCompoundAssignOperator;
pub const ZigClangCompoundStmt = struct_ZigClangCompoundStmt;
pub const ZigClangConstantArrayType = struct_ZigClangConstantArrayType;
pub const ZigClangContinueStmt = struct_ZigClangContinueStmt;
pub const ZigClangDecayedType = struct_ZigClangDecayedType;
pub const ZigClangDecl = struct_ZigClangDecl;
pub const ZigClangDeclRefExpr = struct_ZigClangDeclRefExpr;
pub const ZigClangDeclStmt = struct_ZigClangDeclStmt;
pub const ZigClangDefaultStmt = struct_ZigClangDefaultStmt;
pub const ZigClangDiagnosticOptions = struct_ZigClangDiagnosticOptions;
pub const ZigClangDiagnosticsEngine = struct_ZigClangDiagnosticsEngine;
pub const ZigClangDoStmt = struct_ZigClangDoStmt;
pub const ZigClangElaboratedType = struct_ZigClangElaboratedType;
pub const ZigClangEnumConstantDecl = struct_ZigClangEnumConstantDecl;
pub const ZigClangEnumDecl = struct_ZigClangEnumDecl;
pub const ZigClangEnumType = struct_ZigClangEnumType;
pub const ZigClangExpr = struct_ZigClangExpr;
pub const ZigClangFieldDecl = struct_ZigClangFieldDecl;
pub const ZigClangFileID = struct_ZigClangFileID;
pub const ZigClangForStmt = struct_ZigClangForStmt;
pub const ZigClangFullSourceLoc = struct_ZigClangFullSourceLoc;
pub const ZigClangFunctionDecl = struct_ZigClangFunctionDecl;
pub const ZigClangFunctionProtoType = struct_ZigClangFunctionProtoType;
pub const ZigClangIfStmt = struct_ZigClangIfStmt;
pub const ZigClangImplicitCastExpr = struct_ZigClangImplicitCastExpr;
pub const ZigClangIncompleteArrayType = struct_ZigClangIncompleteArrayType;
pub const ZigClangIntegerLiteral = struct_ZigClangIntegerLiteral;
pub const ZigClangMacroDefinitionRecord = struct_ZigClangMacroDefinitionRecord;
pub const ZigClangMacroExpansion = struct_ZigClangMacroExpansion;
pub const ZigClangMacroQualifiedType = struct_ZigClangMacroQualifiedType;
pub const ZigClangMemberExpr = struct_ZigClangMemberExpr;
pub const ZigClangNamedDecl = struct_ZigClangNamedDecl;
pub const ZigClangNone = struct_ZigClangNone;
pub const ZigClangOpaqueValueExpr = struct_ZigClangOpaqueValueExpr;
pub const ZigClangPCHContainerOperations = struct_ZigClangPCHContainerOperations;
pub const ZigClangParenExpr = struct_ZigClangParenExpr;
pub const ZigClangParenType = struct_ZigClangParenType;
pub const ZigClangParmVarDecl = struct_ZigClangParmVarDecl;
pub const ZigClangPointerType = struct_ZigClangPointerType;
pub const ZigClangPreprocessedEntity = struct_ZigClangPreprocessedEntity;
pub const ZigClangRecordDecl = struct_ZigClangRecordDecl;
pub const ZigClangRecordType = struct_ZigClangRecordType;
pub const ZigClangReturnStmt = struct_ZigClangReturnStmt;
pub const ZigClangSkipFunctionBodiesScope = struct_ZigClangSkipFunctionBodiesScope;
pub const ZigClangSourceManager = struct_ZigClangSourceManager;
pub const ZigClangSourceRange = struct_ZigClangSourceRange;
pub const ZigClangStmt = struct_ZigClangStmt;
pub const ZigClangStringLiteral = struct_ZigClangStringLiteral;
pub const ZigClangStringRef = struct_ZigClangStringRef;
pub const ZigClangSwitchStmt = struct_ZigClangSwitchStmt;
pub const ZigClangTagDecl = struct_ZigClangTagDecl;
pub const ZigClangType = struct_ZigClangType;
pub const ZigClangTypedefNameDecl = struct_ZigClangTypedefNameDecl;
pub const ZigClangTypedefType = struct_ZigClangTypedefType;
pub const ZigClangUnaryExprOrTypeTraitExpr = struct_ZigClangUnaryExprOrTypeTraitExpr;
pub const ZigClangUnaryOperator = struct_ZigClangUnaryOperator;
pub const ZigClangValueDecl = struct_ZigClangValueDecl;
pub const ZigClangVarDecl = struct_ZigClangVarDecl;
pub const ZigClangWhileStmt = struct_ZigClangWhileStmt;
pub const ZigClangFunctionType = struct_ZigClangFunctionType;
pub const ZigClangPredefinedExpr = struct_ZigClangPredefinedExpr;
pub const ZigClangInitListExpr = struct_ZigClangInitListExpr;
pub const struct_ZigClangSourceLocation = extern struct {
ID: c_uint,
};
pub const Stage2ErrorMsg = extern struct {
filename_ptr: ?[*]const u8,
filename_len: usize,
msg_ptr: [*]const u8,
msg_len: usize,
// valid until the ASTUnit is freed
source: ?[*]const u8,
// 0 based
line: c_uint,
// 0 based
column: c_uint,
// byte offset into source
offset: c_uint,
};
pub const struct_ZigClangQualType = extern struct {
ptr: ?*c_void,
};
pub const struct_ZigClangAPValueLValueBase = extern struct {
Ptr: ?*c_void,
CallIndex: c_uint,
Version: c_uint,
};
pub extern fn ZigClangErrorMsg_delete(ptr: [*]Stage2ErrorMsg, len: usize) void;
pub extern fn ZigClangLoadFromCommandLine(
args_begin: [*]?[*]const u8,
args_end: [*]?[*]const u8,
errors_ptr: *[*]Stage2ErrorMsg,
errors_len: *usize,
resources_path: [*:0]const u8,
) ?*ZigClangASTUnit;
pub extern fn ZigClangDecl_getKind(decl: *const ZigClangDecl) ZigClangDeclKind;
pub extern fn ZigClangDecl_getDeclKindName(decl: *const struct_ZigClangDecl) [*:0]const u8;
pub const ZigClangCompoundStmt_const_body_iterator = [*]const *struct_ZigClangStmt;
pub extern fn ZigClangCompoundStmt_body_begin(self: *const ZigClangCompoundStmt) ZigClangCompoundStmt_const_body_iterator;
pub extern fn ZigClangCompoundStmt_body_end(self: *const ZigClangCompoundStmt) ZigClangCompoundStmt_const_body_iterator;
pub const ZigClangDeclStmt_const_decl_iterator = [*]const *struct_ZigClangDecl;
pub extern fn ZigClangDeclStmt_decl_begin(self: *const ZigClangDeclStmt) ZigClangDeclStmt_const_decl_iterator;
pub extern fn ZigClangDeclStmt_decl_end(self: *const ZigClangDeclStmt) ZigClangDeclStmt_const_decl_iterator;
pub extern fn ZigClangVarDecl_getLocation(self: *const struct_ZigClangVarDecl) ZigClangSourceLocation;
pub extern fn ZigClangVarDecl_hasInit(self: *const struct_ZigClangVarDecl) bool;
pub extern fn ZigClangVarDecl_getStorageClass(self: *const ZigClangVarDecl) ZigClangStorageClass;
pub extern fn ZigClangVarDecl_getType(self: ?*const struct_ZigClangVarDecl) struct_ZigClangQualType;
pub extern fn ZigClangVarDecl_getInit(*const ZigClangVarDecl) ?*const ZigClangExpr;
pub extern fn ZigClangVarDecl_getTLSKind(self: ?*const struct_ZigClangVarDecl) ZigClangVarDecl_TLSKind;
pub const ZigClangVarDecl_TLSKind = extern enum {
None,
Static,
Dynamic,
};
pub extern fn ZigClangImplicitCastExpr_getBeginLoc(*const ZigClangImplicitCastExpr) ZigClangSourceLocation;
pub extern fn ZigClangImplicitCastExpr_getCastKind(*const ZigClangImplicitCastExpr) ZigClangCK;
pub extern fn ZigClangImplicitCastExpr_getSubExpr(*const ZigClangImplicitCastExpr) *const ZigClangExpr;
pub extern fn ZigClangArrayType_getElementType(*const ZigClangArrayType) ZigClangQualType;
pub extern fn ZigClangIncompleteArrayType_getElementType(*const ZigClangIncompleteArrayType) ZigClangQualType;
pub extern fn ZigClangConstantArrayType_getElementType(self: *const struct_ZigClangConstantArrayType) ZigClangQualType;
pub extern fn ZigClangConstantArrayType_getSize(self: *const struct_ZigClangConstantArrayType) *const struct_ZigClangAPInt;
pub extern fn ZigClangDeclRefExpr_getDecl(*const ZigClangDeclRefExpr) *const ZigClangValueDecl;
pub extern fn ZigClangDeclRefExpr_getFoundDecl(*const ZigClangDeclRefExpr) *const ZigClangNamedDecl;
pub extern fn ZigClangParenType_getInnerType(*const ZigClangParenType) ZigClangQualType;
pub extern fn ZigClangElaboratedType_getNamedType(*const ZigClangElaboratedType) ZigClangQualType;
pub extern fn ZigClangAttributedType_getEquivalentType(*const ZigClangAttributedType) ZigClangQualType;
pub extern fn ZigClangMacroQualifiedType_getModifiedType(*const ZigClangMacroQualifiedType) ZigClangQualType;
pub extern fn ZigClangCStyleCastExpr_getBeginLoc(*const ZigClangCStyleCastExpr) ZigClangSourceLocation;
pub extern fn ZigClangCStyleCastExpr_getSubExpr(*const ZigClangCStyleCastExpr) *const ZigClangExpr;
pub extern fn ZigClangCStyleCastExpr_getType(*const ZigClangCStyleCastExpr) ZigClangQualType;
pub const ZigClangExprEvalResult = struct_ZigClangExprEvalResult;
pub const struct_ZigClangExprEvalResult = extern struct {
HasSideEffects: bool,
HasUndefinedBehavior: bool,
SmallVectorImpl: ?*c_void,
Val: ZigClangAPValue,
};
pub const struct_ZigClangAPValue = extern struct {
Kind: ZigClangAPValueKind,
Data: if (builtin.os == .windows and builtin.abi == .msvc) [52]u8 else [68]u8,
};
pub extern fn ZigClangVarDecl_getTypeSourceInfo_getType(self: *const struct_ZigClangVarDecl) struct_ZigClangQualType;
pub extern fn ZigClangIntegerLiteral_EvaluateAsInt(*const ZigClangIntegerLiteral, *ZigClangExprEvalResult, *const ZigClangASTContext) bool;
pub extern fn ZigClangIntegerLiteral_getBeginLoc(*const ZigClangIntegerLiteral) ZigClangSourceLocation;
pub extern fn ZigClangReturnStmt_getRetValue(*const ZigClangReturnStmt) ?*const ZigClangExpr;
pub extern fn ZigClangBinaryOperator_getOpcode(*const ZigClangBinaryOperator) ZigClangBO;
pub extern fn ZigClangBinaryOperator_getBeginLoc(*const ZigClangBinaryOperator) ZigClangSourceLocation;
pub extern fn ZigClangBinaryOperator_getLHS(*const ZigClangBinaryOperator) *const ZigClangExpr;
pub extern fn ZigClangBinaryOperator_getRHS(*const ZigClangBinaryOperator) *const ZigClangExpr;
pub extern fn ZigClangBinaryOperator_getType(*const ZigClangBinaryOperator) ZigClangQualType;
pub extern fn ZigClangDecayedType_getDecayedType(*const ZigClangDecayedType) ZigClangQualType;
pub extern fn ZigClangStringLiteral_getKind(*const ZigClangStringLiteral) ZigClangStringLiteral_StringKind;
pub extern fn ZigClangStringLiteral_getString_bytes_begin_size(*const ZigClangStringLiteral, *usize) [*]const u8;
pub extern fn ZigClangParenExpr_getSubExpr(*const ZigClangParenExpr) *const ZigClangExpr;
pub extern fn ZigClangFieldDecl_isAnonymousStructOrUnion(*const struct_ZigClangFieldDecl) bool;
pub extern fn ZigClangFieldDecl_isBitField(*const struct_ZigClangFieldDecl) bool;
pub extern fn ZigClangFieldDecl_getType(*const struct_ZigClangFieldDecl) struct_ZigClangQualType;
pub extern fn ZigClangFieldDecl_getLocation(*const struct_ZigClangFieldDecl) struct_ZigClangSourceLocation;
pub extern fn ZigClangEnumConstantDecl_getInitExpr(*const ZigClangEnumConstantDecl) ?*const ZigClangExpr;
pub extern fn ZigClangEnumConstantDecl_getInitVal(*const ZigClangEnumConstantDecl) *const ZigClangAPSInt;
pub extern fn ZigClangASTUnit_getLocalPreprocessingEntities_begin(*ZigClangASTUnit) ZigClangPreprocessingRecord_iterator;
pub extern fn ZigClangASTUnit_getLocalPreprocessingEntities_end(*ZigClangASTUnit) ZigClangPreprocessingRecord_iterator;
pub extern fn ZigClangPreprocessingRecord_iterator_deref(ZigClangPreprocessingRecord_iterator) *ZigClangPreprocessedEntity;
pub extern fn ZigClangPreprocessedEntity_getKind(*const ZigClangPreprocessedEntity) ZigClangPreprocessedEntity_EntityKind;
pub extern fn ZigClangMacroDefinitionRecord_getName_getNameStart(*const ZigClangMacroDefinitionRecord) [*:0]const u8;
pub extern fn ZigClangMacroDefinitionRecord_getSourceRange_getBegin(*const ZigClangMacroDefinitionRecord) ZigClangSourceLocation;
pub extern fn ZigClangMacroDefinitionRecord_getSourceRange_getEnd(*const ZigClangMacroDefinitionRecord) ZigClangSourceLocation;
pub extern fn ZigClangMacroExpansion_getDefinition(*const ZigClangMacroExpansion) *const ZigClangMacroDefinitionRecord;
pub extern fn ZigClangIfStmt_getThen(*const ZigClangIfStmt) *const ZigClangStmt;
pub extern fn ZigClangIfStmt_getElse(*const ZigClangIfStmt) ?*const ZigClangStmt;
pub extern fn ZigClangIfStmt_getCond(*const ZigClangIfStmt) *const ZigClangStmt;
pub extern fn ZigClangWhileStmt_getCond(*const ZigClangWhileStmt) *const ZigClangExpr;
pub extern fn ZigClangWhileStmt_getBody(*const ZigClangWhileStmt) *const ZigClangStmt;
pub extern fn ZigClangDoStmt_getCond(*const ZigClangDoStmt) *const ZigClangExpr;
pub extern fn ZigClangDoStmt_getBody(*const ZigClangDoStmt) *const ZigClangStmt;
pub extern fn ZigClangForStmt_getInit(*const ZigClangForStmt) ?*const ZigClangStmt;
pub extern fn ZigClangForStmt_getCond(*const ZigClangForStmt) ?*const ZigClangExpr;
pub extern fn ZigClangForStmt_getInc(*const ZigClangForStmt) ?*const ZigClangExpr;
pub extern fn ZigClangForStmt_getBody(*const ZigClangForStmt) *const ZigClangStmt;
pub extern fn ZigClangAPFloat_toString(self: *const ZigClangAPFloat, precision: c_uint, maxPadding: c_uint, truncateZero: bool) [*:0]const u8;
pub extern fn ZigClangAPFloat_getValueAsApproximateDouble(*const ZigClangFloatingLiteral) f64;
pub extern fn ZigClangAbstractConditionalOperator_getCond(*const ZigClangAbstractConditionalOperator) *const ZigClangExpr;
pub extern fn ZigClangAbstractConditionalOperator_getTrueExpr(*const ZigClangAbstractConditionalOperator) *const ZigClangExpr;
pub extern fn ZigClangAbstractConditionalOperator_getFalseExpr(*const ZigClangAbstractConditionalOperator) *const ZigClangExpr;
pub extern fn ZigClangSwitchStmt_getConditionVariableDeclStmt(*const ZigClangSwitchStmt) ?*const ZigClangDeclStmt;
pub extern fn ZigClangSwitchStmt_getCond(*const ZigClangSwitchStmt) *const ZigClangExpr;
pub extern fn ZigClangSwitchStmt_getBody(*const ZigClangSwitchStmt) *const ZigClangStmt;
pub extern fn ZigClangSwitchStmt_isAllEnumCasesCovered(*const ZigClangSwitchStmt) bool;
pub extern fn ZigClangCaseStmt_getLHS(*const ZigClangCaseStmt) *const ZigClangExpr;
pub extern fn ZigClangCaseStmt_getRHS(*const ZigClangCaseStmt) ?*const ZigClangExpr;
pub extern fn ZigClangCaseStmt_getBeginLoc(*const ZigClangCaseStmt) ZigClangSourceLocation;
pub extern fn ZigClangCaseStmt_getSubStmt(*const ZigClangCaseStmt) *const ZigClangStmt;
pub extern fn ZigClangDefaultStmt_getSubStmt(*const ZigClangDefaultStmt) *const ZigClangStmt;
pub extern fn ZigClangExpr_EvaluateAsConstantExpr(*const ZigClangExpr, *ZigClangExprEvalResult, ZigClangExpr_ConstExprUsage, *const ZigClangASTContext) bool;
pub extern fn ZigClangPredefinedExpr_getFunctionName(*const ZigClangPredefinedExpr) *const ZigClangStringLiteral;
pub extern fn ZigClangCharacterLiteral_getBeginLoc(*const ZigClangCharacterLiteral) ZigClangSourceLocation;
pub extern fn ZigClangCharacterLiteral_getKind(*const ZigClangCharacterLiteral) ZigClangCharacterLiteral_CharacterKind;
pub extern fn ZigClangCharacterLiteral_getValue(*const ZigClangCharacterLiteral) c_uint;
pub extern fn ZigClangStmtExpr_getSubStmt(*const ZigClangStmtExpr) *const ZigClangCompoundStmt;
pub extern fn ZigClangMemberExpr_getBase(*const ZigClangMemberExpr) *const ZigClangExpr;
pub extern fn ZigClangMemberExpr_isArrow(*const ZigClangMemberExpr) bool;
pub extern fn ZigClangMemberExpr_getMemberDecl(*const ZigClangMemberExpr) *const ZigClangValueDecl;
pub extern fn ZigClangArraySubscriptExpr_getBase(*const ZigClangArraySubscriptExpr) *const ZigClangExpr;
pub extern fn ZigClangArraySubscriptExpr_getIdx(*const ZigClangArraySubscriptExpr) *const ZigClangExpr;
pub extern fn ZigClangCallExpr_getCallee(*const ZigClangCallExpr) *const ZigClangExpr;
pub extern fn ZigClangCallExpr_getNumArgs(*const ZigClangCallExpr) c_uint;
pub extern fn ZigClangCallExpr_getArgs(*const ZigClangCallExpr) [*]const *const ZigClangExpr;
pub extern fn ZigClangUnaryExprOrTypeTraitExpr_getTypeOfArgument(*const ZigClangUnaryExprOrTypeTraitExpr) ZigClangQualType;
pub extern fn ZigClangUnaryExprOrTypeTraitExpr_getBeginLoc(*const ZigClangUnaryExprOrTypeTraitExpr) ZigClangSourceLocation;
pub extern fn ZigClangUnaryOperator_getOpcode(*const ZigClangUnaryOperator) ZigClangUO;
pub extern fn ZigClangUnaryOperator_getType(*const ZigClangUnaryOperator) ZigClangQualType;
pub extern fn ZigClangUnaryOperator_getSubExpr(*const ZigClangUnaryOperator) *const ZigClangExpr;
pub extern fn ZigClangUnaryOperator_getBeginLoc(*const ZigClangUnaryOperator) ZigClangSourceLocation;
pub extern fn ZigClangOpaqueValueExpr_getSourceExpr(*const ZigClangOpaqueValueExpr) ?*const ZigClangExpr;
pub extern fn ZigClangCompoundAssignOperator_getType(*const ZigClangCompoundAssignOperator) ZigClangQualType;
pub extern fn ZigClangCompoundAssignOperator_getComputationLHSType(*const ZigClangCompoundAssignOperator) ZigClangQualType;
pub extern fn ZigClangCompoundAssignOperator_getComputationResultType(*const ZigClangCompoundAssignOperator) ZigClangQualType;
pub extern fn ZigClangCompoundAssignOperator_getBeginLoc(*const ZigClangCompoundAssignOperator) ZigClangSourceLocation;
pub extern fn ZigClangCompoundAssignOperator_getOpcode(*const ZigClangCompoundAssignOperator) ZigClangBO;
pub extern fn ZigClangCompoundAssignOperator_getLHS(*const ZigClangCompoundAssignOperator) *const ZigClangExpr;
pub extern fn ZigClangCompoundAssignOperator_getRHS(*const ZigClangCompoundAssignOperator) *const ZigClangExpr;
|
src-self-hosted/clang.zig
|
pub const parseFloat = @import("parse_float/parse_float.zig").parseFloat;
pub const ParseFloatError = @import("parse_float/parse_float.zig").ParseFloatError;
const std = @import("std");
const math = std.math;
const testing = std.testing;
const expect = testing.expect;
const expectEqual = testing.expectEqual;
const expectError = testing.expectError;
const approxEqAbs = std.math.approxEqAbs;
const epsilon = 1e-7;
// See https://github.com/tiehuis/parse-number-fxx-test-data for a wider-selection of test-data.
test "fmt.parseFloat" {
inline for ([_]type{ f16, f32, f64, f128 }) |T| {
const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
try testing.expectError(error.InvalidCharacter, parseFloat(T, ""));
try testing.expectError(error.InvalidCharacter, parseFloat(T, " 1"));
try testing.expectError(error.InvalidCharacter, parseFloat(T, "1abc"));
try testing.expectError(error.InvalidCharacter, parseFloat(T, "+"));
try testing.expectError(error.InvalidCharacter, parseFloat(T, "-"));
try expectEqual(try parseFloat(T, "0"), 0.0);
try expectEqual(try parseFloat(T, "0"), 0.0);
try expectEqual(try parseFloat(T, "+0"), 0.0);
try expectEqual(try parseFloat(T, "-0"), 0.0);
try expectEqual(try parseFloat(T, "0e0"), 0);
try expectEqual(try parseFloat(T, "2e3"), 2000.0);
try expectEqual(try parseFloat(T, "1e0"), 1.0);
try expectEqual(try parseFloat(T, "-2e3"), -2000.0);
try expectEqual(try parseFloat(T, "-1e0"), -1.0);
try expectEqual(try parseFloat(T, "1.234e3"), 1234);
try expect(approxEqAbs(T, try parseFloat(T, "3.141"), 3.141, epsilon));
try expect(approxEqAbs(T, try parseFloat(T, "-3.141"), -3.141, epsilon));
try expectEqual(try parseFloat(T, "1e-5000"), 0);
try expectEqual(try parseFloat(T, "1e+5000"), std.math.inf(T));
try expectEqual(@bitCast(Z, try parseFloat(T, "nAn")), @bitCast(Z, std.math.nan(T)));
try expectEqual(try parseFloat(T, "inF"), std.math.inf(T));
try expectEqual(try parseFloat(T, "-INF"), -std.math.inf(T));
try expectEqual(try parseFloat(T, "0.4e0066999999999999999999999999999999999999999999999999999"), std.math.inf(T));
try expect(approxEqAbs(T, try parseFloat(T, "0_1_2_3_4_5_6.7_8_9_0_0_0e0_0_1_0"), @as(T, 123456.789000e10), epsilon));
// underscore rule is simple and reduces to "can only occur between two digits" and multiple are not supported.
try expectError(error.InvalidCharacter, parseFloat(T, "0123456.789000e_0010")); // cannot occur immediately after exponent
try expectError(error.InvalidCharacter, parseFloat(T, "_0123456.789000e0010")); // cannot occur before any digits
try expectError(error.InvalidCharacter, parseFloat(T, "0__123456.789000e_0010")); // cannot occur twice in a row
try expectError(error.InvalidCharacter, parseFloat(T, "0123456_.789000e0010")); // cannot occur before decimal point
try expectError(error.InvalidCharacter, parseFloat(T, "0123456.789000e0010_")); // cannot occur at end of number
try expect(approxEqAbs(T, try parseFloat(T, "1e-2"), 0.01, epsilon));
try expect(approxEqAbs(T, try parseFloat(T, "1234e-2"), 12.34, epsilon));
try expect(approxEqAbs(T, try parseFloat(T, "123142.1"), 123142.1, epsilon));
try expect(approxEqAbs(T, try parseFloat(T, "-123142.1124"), @as(T, -123142.1124), epsilon));
try expect(approxEqAbs(T, try parseFloat(T, "0.7062146892655368"), @as(T, 0.7062146892655368), epsilon));
try expect(approxEqAbs(T, try parseFloat(T, "2.71828182845904523536"), @as(T, 2.718281828459045), epsilon));
}
}
test "fmt.parseFloat #11169" {
try expectEqual(try parseFloat(f128, "9007199254740993.0"), 9007199254740993.0);
}
test "fmt.parseFloat hex.special" {
try testing.expect(math.isNan(try parseFloat(f32, "nAn")));
try testing.expect(math.isPositiveInf(try parseFloat(f32, "iNf")));
try testing.expect(math.isPositiveInf(try parseFloat(f32, "+Inf")));
try testing.expect(math.isNegativeInf(try parseFloat(f32, "-iNf")));
}
test "fmt.parseFloat hex.zero" {
try testing.expectEqual(@as(f32, 0.0), try parseFloat(f32, "0x0"));
try testing.expectEqual(@as(f32, 0.0), try parseFloat(f32, "-0x0"));
try testing.expectEqual(@as(f32, 0.0), try parseFloat(f32, "0x0p42"));
try testing.expectEqual(@as(f32, 0.0), try parseFloat(f32, "-0x0.00000p42"));
try testing.expectEqual(@as(f32, 0.0), try parseFloat(f32, "0x0.00000p666"));
}
test "fmt.parseFloat hex.f16" {
try testing.expectEqual(try parseFloat(f16, "0x1p0"), 1.0);
try testing.expectEqual(try parseFloat(f16, "-0x1p-1"), -0.5);
try testing.expectEqual(try parseFloat(f16, "0x10p+10"), 16384.0);
try testing.expectEqual(try parseFloat(f16, "0x10p-10"), 0.015625);
// Max normalized value.
try testing.expectEqual(try parseFloat(f16, "0x1.ffcp+15"), math.floatMax(f16));
try testing.expectEqual(try parseFloat(f16, "-0x1.ffcp+15"), -math.floatMax(f16));
// Min normalized value.
try testing.expectEqual(try parseFloat(f16, "0x1p-14"), math.floatMin(f16));
try testing.expectEqual(try parseFloat(f16, "-0x1p-14"), -math.floatMin(f16));
// Min denormal value.
try testing.expectEqual(try parseFloat(f16, "0x1p-24"), math.floatTrueMin(f16));
try testing.expectEqual(try parseFloat(f16, "-0x1p-24"), -math.floatTrueMin(f16));
}
test "fmt.parseFloat hex.f32" {
try testing.expectEqual(try parseFloat(f32, "0x1p0"), 1.0);
try testing.expectEqual(try parseFloat(f32, "-0x1p-1"), -0.5);
try testing.expectEqual(try parseFloat(f32, "0x10p+10"), 16384.0);
try testing.expectEqual(try parseFloat(f32, "0x10p-10"), 0.015625);
try testing.expectEqual(try parseFloat(f32, "0x0.ffffffp128"), 0x0.ffffffp128);
try testing.expectEqual(try parseFloat(f32, "0x0.1234570p-125"), 0x0.1234570p-125);
// Max normalized value.
try testing.expectEqual(try parseFloat(f32, "0x1.fffffeP+127"), math.floatMax(f32));
try testing.expectEqual(try parseFloat(f32, "-0x1.fffffeP+127"), -math.floatMax(f32));
// Min normalized value.
try testing.expectEqual(try parseFloat(f32, "0x1p-126"), math.floatMin(f32));
try testing.expectEqual(try parseFloat(f32, "-0x1p-126"), -math.floatMin(f32));
// Min denormal value.
try testing.expectEqual(try parseFloat(f32, "0x1P-149"), math.floatTrueMin(f32));
try testing.expectEqual(try parseFloat(f32, "-0x1P-149"), -math.floatTrueMin(f32));
}
test "fmt.parseFloat hex.f64" {
try testing.expectEqual(try parseFloat(f64, "0x1p0"), 1.0);
try testing.expectEqual(try parseFloat(f64, "-0x1p-1"), -0.5);
try testing.expectEqual(try parseFloat(f64, "0x10p+10"), 16384.0);
try testing.expectEqual(try parseFloat(f64, "0x10p-10"), 0.015625);
// Max normalized value.
try testing.expectEqual(try parseFloat(f64, "0x1.fffffffffffffp+1023"), math.floatMax(f64));
try testing.expectEqual(try parseFloat(f64, "-0x1.fffffffffffffp1023"), -math.floatMax(f64));
// Min normalized value.
try testing.expectEqual(try parseFloat(f64, "0x1p-1022"), math.floatMin(f64));
try testing.expectEqual(try parseFloat(f64, "-0x1p-1022"), -math.floatMin(f64));
// Min denormalized value.
//try testing.expectEqual(try parseFloat(f64, "0x1p-1074"), math.floatTrueMin(f64));
try testing.expectEqual(try parseFloat(f64, "-0x1p-1074"), -math.floatTrueMin(f64));
}
test "fmt.parseFloat hex.f128" {
try testing.expectEqual(try parseFloat(f128, "0x1p0"), 1.0);
try testing.expectEqual(try parseFloat(f128, "-0x1p-1"), -0.5);
try testing.expectEqual(try parseFloat(f128, "0x10p+10"), 16384.0);
try testing.expectEqual(try parseFloat(f128, "0x10p-10"), 0.015625);
// Max normalized value.
try testing.expectEqual(try parseFloat(f128, "0xf.fffffffffffffffffffffffffff8p+16380"), math.floatMax(f128));
try testing.expectEqual(try parseFloat(f128, "-0xf.fffffffffffffffffffffffffff8p+16380"), -math.floatMax(f128));
// Min normalized value.
try testing.expectEqual(try parseFloat(f128, "0x1p-16382"), math.floatMin(f128));
try testing.expectEqual(try parseFloat(f128, "-0x1p-16382"), -math.floatMin(f128));
// // Min denormalized value.
try testing.expectEqual(try parseFloat(f128, "0x1p-16494"), math.floatTrueMin(f128));
try testing.expectEqual(try parseFloat(f128, "-0x1p-16494"), -math.floatTrueMin(f128));
// NOTE: We are performing round-to-even. Previous behavior was round-up.
// try testing.expectEqual(try parseFloat(f128, "0x1.edcb34a235253948765432134674fp-1"), 0x1.edcb34a235253948765432134674fp-1);
}
|
lib/std/fmt/parse_float.zig
|
const std = @import("std");
const AnalysisContext = @import("document_store.zig").AnalysisContext;
const ast = std.zig.ast;
/// REALLY BAD CODE, PLEASE DON'T USE THIS!!!!!!! (only for testing)
pub fn getFunctionByName(tree: *ast.Tree, name: []const u8) ?*ast.Node.FnProto {
var decls = tree.root_node.decls.iterator(0);
while (decls.next()) |decl_ptr| {
var decl = decl_ptr.*;
switch (decl.id) {
.FnProto => {
const func = decl.cast(ast.Node.FnProto).?;
if (std.mem.eql(u8, tree.tokenSlice(func.name_token.?), name)) return func;
},
else => {}
}
}
return null;
}
/// Gets a function's doc comments, caller must free memory when a value is returned
/// Like:
///```zig
///var comments = getFunctionDocComments(allocator, tree, func);
///defer if (comments) |comments_pointer| allocator.free(comments_pointer);
///```
pub fn getDocComments(allocator: *std.mem.Allocator, tree: *ast.Tree, node: *ast.Node) !?[]const u8 {
switch (node.id) {
.FnProto => {
const func = node.cast(ast.Node.FnProto).?;
if (func.doc_comments) |doc_comments| {
return try collectDocComments(allocator, tree, doc_comments);
}
},
.VarDecl => {
const var_decl = node.cast(ast.Node.VarDecl).?;
if (var_decl.doc_comments) |doc_comments| {
return try collectDocComments(allocator, tree, doc_comments);
}
},
.ContainerField => {
const field = node.cast(ast.Node.ContainerField).?;
if (field.doc_comments) |doc_comments| {
return try collectDocComments(allocator, tree, doc_comments);
}
},
.ErrorTag => {
const tag = node.cast(ast.Node.ErrorTag).?;
if (tag.doc_comments) |doc_comments| {
return try collectDocComments(allocator, tree, doc_comments);
}
},
.ParamDecl => {
const param = node.cast(ast.Node.ParamDecl).?;
if (param.doc_comments) |doc_comments| {
return try collectDocComments(allocator, tree, doc_comments);
}
},
else => {}
}
return null;
}
fn collectDocComments(allocator: *std.mem.Allocator, tree: *ast.Tree, doc_comments: *ast.Node.DocComment) ![]const u8 {
var doc_it = doc_comments.lines.iterator(0);
var lines = std.ArrayList([]const u8).init(allocator);
defer lines.deinit();
while (doc_it.next()) |doc_comment| {
_ = try lines.append(std.fmt.trim(tree.tokenSlice(doc_comment.*)[3..]));
}
return try std.mem.join(allocator, "\n", lines.items);
}
/// Gets a function signature (keywords, name, return value)
pub fn getFunctionSignature(tree: *ast.Tree, func: *ast.Node.FnProto) []const u8 {
const start = tree.tokens.at(func.firstToken()).start;
const end = tree.tokens.at(switch (func.return_type) {
.Explicit, .InferErrorSet => |node| node.lastToken()
}).end;
return tree.source[start..end];
}
/// Gets a function snippet insert text
pub fn getFunctionSnippet(allocator: *std.mem.Allocator, tree: *ast.Tree, func: *ast.Node.FnProto) ![]const u8 {
const name_tok = func.name_token orelse unreachable;
var buffer = std.ArrayList(u8).init(allocator);
try buffer.ensureCapacity(128);
try buffer.appendSlice(tree.tokenSlice(name_tok));
try buffer.append('(');
var buf_stream = buffer.outStream();
var param_num = @as(usize, 1);
var param_it = func.params.iterator(0);
while (param_it.next()) |param_ptr| : (param_num += 1) {
const param = param_ptr.*;
const param_decl = param.cast(ast.Node.ParamDecl).?;
if (param_num != 1) try buffer.appendSlice(", ${")
else try buffer.appendSlice("${");
try buf_stream.print("{}:", .{param_num});
if (param_decl.comptime_token) |_| {
try buffer.appendSlice("comptime ");
}
if (param_decl.noalias_token) |_| {
try buffer.appendSlice("noalias ");
}
if (param_decl.name_token) |name_token| {
try buffer.appendSlice(tree.tokenSlice(name_token));
try buffer.appendSlice(": ");
}
if (param_decl.var_args_token) |_| {
try buffer.appendSlice("...");
continue;
}
var curr_tok = param_decl.type_node.firstToken();
var end_tok = param_decl.type_node.lastToken();
while (curr_tok <= end_tok) : (curr_tok += 1) {
const id = tree.tokens.at(curr_tok).id;
const is_comma = tree.tokens.at(curr_tok).id == .Comma;
if (curr_tok == end_tok and is_comma) continue;
try buffer.appendSlice(tree.tokenSlice(curr_tok));
if (is_comma or id == .Keyword_const) try buffer.append(' ');
}
try buffer.append('}');
}
try buffer.append(')');
return buffer.toOwnedSlice();
}
/// Gets a function signature (keywords, name, return value)
pub fn getVariableSignature(tree: *ast.Tree, var_decl: *ast.Node.VarDecl) []const u8 {
const start = tree.tokens.at(var_decl.firstToken()).start;
const end = tree.tokens.at(var_decl.semicolon_token).start;
// var end =
// if (var_decl.init_n) |body| tree.tokens.at(body.firstToken()).start
// else tree.tokens.at(var_decl.name_token).end;
return tree.source[start..end];
}
// STYLE
pub fn isCamelCase(name: []const u8) bool {
return !std.ascii.isUpper(name[0]) and std.mem.indexOf(u8, name, "_") == null;
}
pub fn isPascalCase(name: []const u8) bool {
return std.ascii.isUpper(name[0]) and std.mem.indexOf(u8, name, "_") == null;
}
// ANALYSIS ENGINE
/// Gets the child of node
pub fn getChild(tree: *ast.Tree, node: *ast.Node, name: []const u8) ?*ast.Node {
var index: usize = 0;
while (node.iterate(index)) |child| {
switch (child.id) {
.VarDecl => {
const vari = child.cast(ast.Node.VarDecl).?;
if (std.mem.eql(u8, tree.tokenSlice(vari.name_token), name)) return child;
},
.FnProto => {
const func = child.cast(ast.Node.FnProto).?;
if (func.name_token != null and std.mem.eql(u8, tree.tokenSlice(func.name_token.?), name)) return child;
},
.ContainerField => {
const field = child.cast(ast.Node.ContainerField).?;
if (std.mem.eql(u8, tree.tokenSlice(field.name_token), name)) return child;
},
else => {}
}
index += 1;
}
return null;
}
/// Resolves the type of a node
pub fn resolveTypeOfNode(analysis_ctx: *AnalysisContext, node: *ast.Node) ?*ast.Node {
switch (node.id) {
.VarDecl => {
const vari = node.cast(ast.Node.VarDecl).?;
return resolveTypeOfNode(analysis_ctx, vari.type_node orelse vari.init_node.?) orelse null;
},
.FnProto => {
const func = node.cast(ast.Node.FnProto).?;
switch (func.return_type) {
.Explicit, .InferErrorSet => |return_type| return resolveTypeOfNode(analysis_ctx, return_type),
}
},
.Identifier => {
if (getChild(analysis_ctx.tree, &analysis_ctx.tree.root_node.base, analysis_ctx.tree.getNodeSource(node))) |child| {
return resolveTypeOfNode(analysis_ctx, child);
} else return null;
},
.ContainerDecl => {
return node;
},
.ContainerField => {
const field = node.cast(ast.Node.ContainerField).?;
return resolveTypeOfNode(analysis_ctx, field.type_expr orelse return null);
},
.ErrorSetDecl => {
return node;
},
.SuffixOp => {
const suffix_op = node.cast(ast.Node.SuffixOp).?;
switch (suffix_op.op) {
.Call => {
return resolveTypeOfNode(analysis_ctx, suffix_op.lhs.node);
},
else => {}
}
},
.InfixOp => {
const infix_op = node.cast(ast.Node.InfixOp).?;
switch (infix_op.op) {
.Period => {
// Save the child string from this tree since the tree may switch when processing
// an import lhs.
var rhs_str = nodeToString(analysis_ctx.tree, infix_op.rhs) orelse return null;
// Use the analysis context temporary arena to store the rhs string.
rhs_str = std.mem.dupe(&analysis_ctx.arena.allocator, u8, rhs_str) catch return null;
const left = resolveTypeOfNode(analysis_ctx, infix_op.lhs) orelse return null;
return getChild(analysis_ctx.tree, left, rhs_str);
},
else => {}
}
},
.PrefixOp => {
const prefix_op = node.cast(ast.Node.PrefixOp).?;
switch (prefix_op.op) {
.PtrType => {
return resolveTypeOfNode(analysis_ctx, prefix_op.rhs);
},
else => {}
}
},
.BuiltinCall => {
const builtin_call = node.cast(ast.Node.BuiltinCall).?;
if (!std.mem.eql(u8, analysis_ctx.tree.tokenSlice(builtin_call.builtin_token), "@import")) return null;
if (builtin_call.params.len > 1) return null;
const import_param = builtin_call.params.at(0).*;
if (import_param.id != .StringLiteral) return null;
const import_str = analysis_ctx.tree.tokenSlice(import_param.cast(ast.Node.StringLiteral).?.token);
return analysis_ctx.onImport(import_str[1 .. import_str.len - 1]) catch |err| block: {
std.debug.warn("Error {} while proessing import {}\n", .{err, import_str});
break :block null;
};
},
else => {
std.debug.warn("Type resolution case not implemented; {}\n", .{node.id});
}
}
return null;
}
fn maybeCollectImport(tree: *ast.Tree, builtin_call: *ast.Node.BuiltinCall, arr: *std.ArrayList([]const u8)) !void {
if (!std.mem.eql(u8, tree.tokenSlice(builtin_call.builtin_token), "@import")) return;
if (builtin_call.params.len > 1) return;
const import_param = builtin_call.params.at(0).*;
if (import_param.id != .StringLiteral) return;
const import_str = tree.tokenSlice(import_param.cast(ast.Node.StringLiteral).?.token);
try arr.append(import_str[1 .. import_str.len - 1]);
}
/// Collects all imports we can find into a slice of import paths (without quotes).
/// The import paths are valid as long as the tree is.
pub fn collectImports(allocator: *std.mem.Allocator, tree: *ast.Tree) ![][]const u8 {
// TODO: Currently only detects `const smth = @import("string literal")<.SometThing>;`
var arr = std.ArrayList([]const u8).init(allocator);
var idx: usize = 0;
while (tree.root_node.iterate(idx)) |decl| : (idx += 1) {
if (decl.id != .VarDecl) continue;
const var_decl = decl.cast(ast.Node.VarDecl).?;
if (var_decl.init_node == null) continue;
switch(var_decl.init_node.?.id) {
.BuiltinCall => {
const builtin_call = var_decl.init_node.?.cast(ast.Node.BuiltinCall).?;
try maybeCollectImport(tree, builtin_call, &arr);
},
.InfixOp => {
const infix_op = var_decl.init_node.?.cast(ast.Node.InfixOp).?;
switch(infix_op.op) {
.Period => {},
else => continue,
}
if (infix_op.lhs.id != .BuiltinCall) continue;
try maybeCollectImport(tree, infix_op.lhs.cast(ast.Node.BuiltinCall).?, &arr);
},
else => {},
}
}
return arr.toOwnedSlice();
}
pub fn getFieldAccessTypeNode(analysis_ctx: *AnalysisContext, tokenizer: *std.zig.Tokenizer) ?*ast.Node {
var current_node = &analysis_ctx.tree.root_node.base;
while (true) {
var next = tokenizer.next();
switch (next.id) {
.Eof => {
return current_node;
},
.Identifier => {
// var root = current_node.cast(ast.Node.Root).?;
// current_node.
if (getChild(analysis_ctx.tree, current_node, tokenizer.buffer[next.start..next.end])) |child| {
if (resolveTypeOfNode(analysis_ctx, child)) |node_type| {
current_node = node_type;
} else return null;
} else return null;
},
.Period => {
var after_period = tokenizer.next();
if (after_period.id == .Eof) {
return current_node;
} else if (after_period.id == .Identifier) {
if (getChild(analysis_ctx.tree, current_node, tokenizer.buffer[after_period.start..after_period.end])) |child| {
if (resolveTypeOfNode(analysis_ctx, child)) |child_type| {
current_node = child_type;
} else return null;
} else return null;
}
},
else => {
std.debug.warn("Not implemented; {}\n", .{next.id});
}
}
}
return current_node;
}
pub fn isNodePublic(tree: *ast.Tree, node: *ast.Node) bool {
switch (node.id) {
.VarDecl => {
const var_decl = node.cast(ast.Node.VarDecl).?;
if (var_decl.visib_token) |visib_token| {
return std.mem.eql(u8, tree.tokenSlice(visib_token), "pub");
} else return false;
},
.FnProto => {
const func = node.cast(ast.Node.FnProto).?;
if (func.visib_token) |visib_token| {
return std.mem.eql(u8, tree.tokenSlice(visib_token), "pub");
} else return false;
},
.ContainerField => {
return true;
},
else => {
return false;
}
}
return false;
}
pub fn nodeToString(tree: *ast.Tree, node: *ast.Node) ?[]const u8 {
switch (node.id) {
.ContainerField => {
const field = node.cast(ast.Node.ContainerField).?;
return tree.tokenSlice(field.name_token);
},
.ErrorTag => {
const tag = node.cast(ast.Node.ErrorTag).?;
return tree.tokenSlice(tag.name_token);
},
.Identifier => {
const field = node.cast(ast.Node.Identifier).?;
return tree.tokenSlice(field.token);
},
.FnProto => {
const func = node.cast(ast.Node.FnProto).?;
if (func.name_token) |name_token| {
return tree.tokenSlice(name_token);
}
},
else => {
std.debug.warn("INVALID: {}\n", .{node.id});
}
}
return null;
}
|
src/analysis.zig
|
const std = @import("std");
const mem = std.mem;
const expect = std.testing.expect;
const builtin = @import("builtin");
extern fn random() u8;
extern fn consoleLog(message_ptr: [*]const u8, message_len: usize) void;
extern fn logRam(ram: [*]u8, ram_len: usize) void;
extern fn readBytes(key_ptr: [*]const u8, key_len: usize, buf_ptr: [*]u8, buf_maxlen: usize) usize;
extern fn writeBytes(key_ptr: [*]const u8, key_len: usize, buf_ptr: [*]u8, buf_maxlen: usize) void;
extern fn logInt(int: u8) void;
fn randomByte() u8 {
if (builtin.is_test) {
var buffer = [1]u8{0};
std.os.getrandom(&buffer) catch return 0;
return buffer[0];
} else {
return random();
}
}
const RAM_SIZE = 4096;
const Chip8 = struct {
pc: u16,
i: u16,
delay_timer: u8,
sound_timer: u8,
sp: u4,
stack: [16]u16,
registers: [16]u8,
ram: [RAM_SIZE]u8,
display: [32]u64, // 64 x 32
keys: u16,
pub fn init() Chip8 {
return Chip8{
.pc = 0x200,
.i = 0,
.delay_timer = 0,
.sound_timer = 0,
.sp = 0,
.stack = [1]u16{0} ** 16,
.registers = [1]u8{0} ** 16,
.ram = [_]u8{
// Font sprites
0xF0, 0x90, 0x90, 0x90, 0xF0, // 0
0x20, 0x60, 0x20, 0x20, 0x70, // 1
0xF0, 0x10, 0xF0, 0x80, 0xF0, // 2
0xF0, 0x10, 0xF0, 0x10, 0xF0, // 3
0x90, 0x90, 0xF0, 0x10, 0x10, // 4
0xF0, 0x80, 0xF0, 0x10, 0xF0, // 5
0xF0, 0x80, 0xF0, 0x90, 0xF0, // 6
0xF0, 0x10, 0x20, 0x40, 0x40, // 7
0xF0, 0x90, 0xF0, 0x90, 0xF0, // 8
0xF0, 0x90, 0xF0, 0x10, 0xF0, // 9
0xF0, 0x90, 0xF0, 0x90, 0x90, // A
0xE0, 0x90, 0xE0, 0x90, 0xE0, // B
0xF0, 0x80, 0x80, 0x80, 0xF0, // C
0xE0, 0x90, 0x90, 0x90, 0xE0, // D
0xF0, 0x80, 0xF0, 0x80, 0xF0, // E
0xF0, 0x80, 0xF0, 0x80, 0x80, // F
} ++ [1]u8{0} ** (4096 - 16 * 5),
.display = [1]u64{0} ** 32,
.keys = 0,
};
}
pub fn clearRam(self: *Chip8) void {
mem.set(u8, &self.ram, 0);
}
pub fn runInstruction(self: *Chip8, instruction: u16) void {
self.pc += 2;
var vx = &self.registers[(instruction & 0xF00) >> 8];
var vy = &self.registers[(instruction & 0xF0) >> 4];
switch (instruction & 0xF000) {
0x0000 => switch (instruction) {
0x00E0 => mem.set(u64, self.display[0..self.display.len], 0),
0x00EE => if (self.sp > 0) {
self.sp -= 1;
self.pc = self.stack[self.sp];
},
else => {},
},
0x1000 => self.pc = instruction & 0xFFF,
0x2000 => {
self.stack[self.sp] = self.pc;
self.sp += 1;
self.pc = instruction & 0xFFF;
},
0x3000 => if (vx.* == (instruction & 0xFF)) {
self.pc += 2;
},
0x4000 => if (vx.* != (instruction & 0xFF)) {
self.pc += 2;
},
0x5000 => if (vx.* == vy.*) {
self.pc += 2;
},
0x6000 => vx.* = @intCast(u8, instruction & 0xFF),
0x7000 => _ = @addWithOverflow(u8, vx.*, @intCast(u8, instruction & 0xFF), vx),
0x8000 => switch (instruction & 0xF) {
0x0 => vx.* = vy.*,
0x1 => vx.* |= vy.*,
0x2 => vx.* &= vy.*,
0x3 => vx.* ^= vy.*,
0x4 => {
const carry = @addWithOverflow(u8, vx.*, vy.*, vx);
self.registers[0xF] = @boolToInt(carry);
},
0x5 => {
const borrow = @subWithOverflow(u8, vx.*, vy.*, vx);
self.registers[0xF] = if (borrow) 0 else 1;
},
0x6 => {
self.registers[0xF] = vy.* & 0b1;
vx.* = vy.* >> 1;
},
0x7 => {
const borrow = @subWithOverflow(u8, vy.*, vx.*, vx);
self.registers[0xF] = if (borrow) 0 else 1;
},
0xE => {
self.registers[0xF] = (vy.* & 0b1000_0000) >> 7;
vx.* = vy.* << 1;
},
else => {},
},
0x9000 => if (vx.* != vy.*) {
self.pc += 2;
},
0xA000 => self.i = instruction & 0xFFF,
0xB000 => self.pc = (instruction & 0xFFF) + self.registers[0],
0xC000 => vx.* = randomByte() & @intCast(u8, instruction & 0xFF),
0xD000 => {
const x = vx.* % 64;
const y = vy.* % 32;
const rows = @intCast(u4, instruction & 0xF);
const offset: i32 = 64 - @as(i32, x) - 8;
var i: u4 = 0;
var start_addr = self.i;
var vf = &self.registers[0xF];
vf.* = 0;
while (i <= rows) : (i += 1) {
var row = &self.display[y + i];
const val = if (offset < 0)
@intCast(u64, self.ram[start_addr + i]) >> @intCast(u6, -offset)
else
@intCast(u64, self.ram[start_addr + i]) << @intCast(u6, offset);
if (vf.* == 0) {
vf.* = @boolToInt((row.* ^ val) & val != val);
}
row.* ^= val;
if (y + i == 31 or i == 15) break;
}
},
0xE000 => switch (instruction & 0xFF) {
0x9E => if (self.keys & (@as(u16, 1) << @intCast(u4, instruction & 0xF00)) > 0) {
self.pc += 2;
},
0xA1 => if (self.keys & (@as(u16, 1) << @intCast(u4, instruction & 0xF00)) == 0) {
self.pc += 2;
},
else => {},
},
0xF000 => switch (instruction & 0xFF) {
0x07 => vx.* = self.delay_timer,
0x0A => {
self.pc -= 2;
var i: u4 = 0;
while (i < 16) : (i += 1) {
if (self.keys & (@as(u16, 1) << i) > 0) {
vx.* = i;
self.pc += 2;
break;
}
if (i == 15) break;
}
},
0x15 => self.delay_timer = vx.*,
0x18 => self.sound_timer = vx.*,
0x1E => _ = @addWithOverflow(u16, self.i, vx.*, &self.i),
0x29 => self.i = 5 * vx.*,
0x33 => {
self.ram[self.i] = vx.* / 100;
self.ram[self.i + 1] = (vx.* / 10) % 10;
self.ram[self.i + 2] = (vx.* % 100) % 10;
},
0x55 => {
const n = ((instruction & 0xF00) >> 8) + 1;
mem.copy(u8, self.ram[self.i .. self.i + n], self.registers[0..n]);
self.i += n;
},
0x65 => {
const n = ((instruction & 0xF00) >> 8) + 1;
mem.copy(u8, self.registers[0..n], self.ram[self.i .. self.i + n]);
self.i += n;
},
else => {},
},
else => {},
}
}
pub fn setKey(self: *Chip8, key: u4) void {
self.keys |= @as(u16, 1) << key;
}
};
const State = struct { chip8: Chip8 };
var state: State = undefined;
export fn init() void {
state = State{ .chip8 = Chip8.init() };
}
export fn getPc() c_uint {
return state.chip8.pc;
}
const LoadProgramStatus = enum {
success,
alloc_error,
overread,
access_error,
parse_error,
};
fn keyCodeToKey(keyCode: c_uint) ?u16 {
var key: u4 = undefined;
switch (keyCode) {
88 => key = 0x0, // x
49 => key = 0x1, // 1
50 => key = 0x2, // 2
51 => key = 0x3, // 3
81 => key = 0x4, // q
87 => key = 0x5, // w
69 => key = 0x6, // e
65 => key = 0x7, // a
83 => key = 0x8, // s
68 => key = 0x9, // d
90 => key = 0xA, // z
67 => key = 0xB, // c
52 => key = 0xC, // 4
82 => key = 0xD, // r
70 => key = 0xE, // f
86 => key = 0xF, // v
else => return null,
}
return @as(u16, 1) << key;
}
export fn loadProgram() c_uint {
var buffer = std.heap.page_allocator.alloc(u8, 4096 * 2) catch {
return @enumToInt(LoadProgramStatus.alloc_error);
};
defer std.heap.page_allocator.free(buffer);
const key = "program";
const bytes_read = readBytes(key, key.len, buffer.ptr, buffer.len);
if (bytes_read > buffer.len) {
return @enumToInt(LoadProgramStatus.overread);
}
var iter = mem.split(buffer[0..bytes_read], "\n");
var i = state.chip8.pc;
while (iter.next()) |line| {
if (line.len == 0) continue;
if (i + 2 > state.chip8.ram.len) {
return @enumToInt(LoadProgramStatus.access_error);
}
const instruction = std.fmt.parseUnsigned(u16, line, 16) catch {
return @enumToInt(LoadProgramStatus.parse_error);
};
const msb = @intCast(u8, instruction >> 8);
const lsb = @intCast(u8, instruction & 0xFF);
state.chip8.ram[i] = msb;
state.chip8.ram[i + 1] = lsb;
i += 2;
}
return @enumToInt(LoadProgramStatus.success);
}
export fn getRam() void {
logRam(&state.chip8.ram, state.chip8.ram.len);
}
export fn getFrame() void {
var frame = [1]u8{0} ** (64 * 32 * 4);
frame[0] = 0xFF;
const key = "frame";
writeBytes(key, key.len, &frame, frame.len);
}
export fn getKeys() c_uint {
return state.chip8.keys;
}
export fn onKeyDown(key_code: c_uint) void {
if (keyCodeToKey(key_code)) |key| {
state.chip8.keys |= key;
}
}
export fn onKeyUp(key_code: c_uint) void {
if (keyCodeToKey(key_code)) |key| {
state.chip8.keys &= ~key;
}
}
test "0x00E0 - Clear Display" {
var chip8 = Chip8.init();
chip8.display[0] = std.math.maxInt(u64);
try expect(chip8.display[0] == std.math.maxInt(u64));
chip8.runInstruction(0x00E0);
try expect(chip8.display[0] == 0);
}
test "0x00EE - Return from subroutine" {
var chip8 = Chip8.init();
chip8.runInstruction(0x00EE);
try expect(chip8.pc == 0x202);
try expect(chip8.sp == 0);
chip8.sp = 1;
chip8.stack[0] = 0x300;
chip8.runInstruction(0x00EE);
try expect(chip8.pc == 0x300);
try expect(chip8.sp == 0);
}
test "0x1NNN - Jump to NNN" {
var chip8 = Chip8.init();
chip8.runInstruction(0x1500);
try expect(chip8.pc == 0x500);
}
test "0x2NNN - Call subroutine at NNN" {
var chip8 = Chip8.init();
chip8.runInstruction(0x2500);
try expect(chip8.pc == 0x500);
try expect(chip8.stack[0] == 0x202);
try expect(chip8.sp == 1);
}
test "0x3XNN - Skip next instruction if VX == NN" {
var chip8 = Chip8.init();
chip8.runInstruction(0x3105);
try expect(chip8.pc == 0x202);
chip8.registers[1] = 5;
chip8.runInstruction(0x3105);
try expect(chip8.pc == 0x206);
}
test "0x4XNN - Skip next instruction if VX != NN" {
var chip8 = Chip8.init();
chip8.runInstruction(0x4200);
try expect(chip8.pc == 0x202);
chip8.registers[2] = 5;
chip8.runInstruction(0x4200);
try expect(chip8.pc == 0x206);
}
test "0x5XY0 - Skip next instruction if VX == VY" {
var chip8 = Chip8.init();
chip8.runInstruction(0x5010);
try expect(chip8.pc == 0x204);
chip8.registers[2] = 1;
chip8.runInstruction(0x5020);
try expect(chip8.pc == 0x206);
}
test "0x6XNN - Store NN in VX" {
var chip8 = Chip8.init();
var pc_start = chip8.pc;
var val: u8 = 0xAB;
for (chip8.registers) |_, i| {
try expect(chip8.registers[i] == 0);
chip8.runInstruction(0x6000 + @intCast(u16, i * 0x100) + val);
try expect(chip8.registers[i] == val);
try expect(chip8.pc == pc_start + (i + 1) * 2);
val += 1;
}
}
test "0x7XVV - Add NN to VX (w/o carry)" {
var chip8 = Chip8.init();
chip8.runInstruction(0x70FF);
try expect(chip8.registers[0] == 0xFF);
try expect(chip8.pc == 0x202);
chip8.runInstruction(0x7001);
try expect(chip8.registers[0] == 0);
try expect(chip8.pc == 0x204);
chip8.registers[1] = 0x10;
chip8.runInstruction(0x7110);
try expect(chip8.registers[1] == 0x20);
try expect(chip8.pc == 0x206);
chip8.runInstruction(0x7200);
try expect(chip8.registers[2] == 0);
try expect(chip8.pc == 0x208);
}
test "0x8XY0 - Store the value of VY in VX" {
var chip8 = Chip8.init();
chip8.registers[1] = 0xFF;
chip8.runInstruction(0x8010);
try expect(chip8.registers[0] == 0xFF);
try expect(chip8.registers[1] == 0xFF);
try expect(chip8.pc == 0x202);
chip8.runInstruction(0x8120);
try expect(chip8.registers[1] == 0);
try expect(chip8.registers[2] == 0);
try expect(chip8.pc == 0x204);
}
test "0x8XY1 - Set VX to VX | VY" {
var chip8 = Chip8.init();
chip8.runInstruction(0x8011);
try expect(chip8.registers[0] == 0);
try expect(chip8.registers[1] == 0);
try expect(chip8.pc == 0x202);
chip8.registers[2] = 0xF0;
chip8.registers[3] = 0x0F;
chip8.runInstruction(0x8231);
try expect(chip8.registers[2] == 0xFF);
try expect(chip8.registers[3] == 0x0F);
try expect(chip8.pc == 0x204);
}
test "0x8XY2 - Set VX to VX & VY" {
var chip8 = Chip8.init();
chip8.runInstruction(0x8012);
try expect(chip8.registers[0] == 0);
try expect(chip8.registers[1] == 0);
try expect(chip8.pc == 0x202);
chip8.registers[2] = 0b1111_1100;
chip8.registers[3] = 0b0011_1111;
chip8.runInstruction(0x8232);
try expect(chip8.registers[2] == 0b0011_1100);
try expect(chip8.registers[3] == 0b0011_1111);
try expect(chip8.pc == 0x204);
}
test "0x8XY3 - Set VX to VX ^ VY" {
var chip8 = Chip8.init();
chip8.runInstruction(0x8013);
try expect(chip8.registers[0] == 0);
try expect(chip8.registers[1] == 0);
try expect(chip8.pc == 0x202);
chip8.registers[2] = 0b1100;
chip8.registers[3] = 0b0110;
chip8.runInstruction(0x8233);
try expect(chip8.registers[2] == 0b1010);
try expect(chip8.registers[3] == 0b0110);
try expect(chip8.pc == 0x204);
}
test "0x8XY4 - Add VY to VX (w/ carry in VF)" {
var chip8 = Chip8.init();
chip8.registers[0] = 2;
chip8.registers[1] = 3;
chip8.runInstruction(0x8014);
try expect(chip8.registers[0] == 5);
try expect(chip8.registers[1] == 3);
try expect(chip8.registers[0xF] == 0);
try expect(chip8.pc == 0x202);
chip8.registers[2] = 0xFF;
chip8.registers[3] = 2;
chip8.runInstruction(0x8234);
try expect(chip8.registers[2] == 1);
try expect(chip8.registers[3] == 2);
try expect(chip8.registers[0xF] == 1);
try expect(chip8.pc == 0x204);
}
test "0x8XY5 - Subtract VY from VX (w/ borrow in VF)" {
var chip8 = Chip8.init();
chip8.registers[0] = 5;
chip8.registers[1] = 3;
chip8.runInstruction(0x8015);
try expect(chip8.registers[0] == 2);
try expect(chip8.registers[1] == 3);
try expect(chip8.registers[0xF] == 1);
try expect(chip8.pc == 0x202);
chip8.registers[2] = 0;
chip8.registers[3] = 1;
chip8.runInstruction(0x8235);
try expect(chip8.registers[2] == 0xFF);
try expect(chip8.registers[3] == 1);
try expect(chip8.registers[0xF] == 0);
try expect(chip8.pc == 0x204);
}
test "0x8XY6 - VX = VY >> 1; VF = LSB prior to shift" {
var chip8 = Chip8.init();
chip8.runInstruction(0x8016);
try expect(chip8.registers[0] == 0);
try expect(chip8.registers[1] == 0);
try expect(chip8.registers[0xF] == 0);
try expect(chip8.pc == 0x202);
chip8.registers[3] = 0xF;
chip8.runInstruction(0x8236);
try expect(chip8.registers[2] == 0b111);
try expect(chip8.registers[3] == 0xF);
try expect(chip8.registers[0xF] == 1);
try expect(chip8.pc == 0x204);
}
test "0x8XY7 - VX = VY - VX (w/ borrow in VF)" {
var chip8 = Chip8.init();
chip8.registers[0] = 3;
chip8.registers[1] = 5;
chip8.runInstruction(0x8017);
try expect(chip8.registers[0] == 2);
try expect(chip8.registers[1] == 5);
try expect(chip8.registers[0xF] == 1);
try expect(chip8.pc == 0x202);
chip8.registers[2] = 1;
chip8.registers[3] = 0;
chip8.runInstruction(0x8237);
try expect(chip8.registers[2] == 0xFF);
try expect(chip8.registers[3] == 0);
try expect(chip8.registers[0xF] == 0);
try expect(chip8.pc == 0x204);
}
test "0x8XYE - VX = VY << 1; VF = MSB prior to shift" {
var chip8 = Chip8.init();
chip8.runInstruction(0x801E);
try expect(chip8.registers[0] == 0);
try expect(chip8.registers[1] == 0);
try expect(chip8.registers[0xF] == 0);
try expect(chip8.pc == 0x202);
chip8.registers[3] = 0xF0;
chip8.runInstruction(0x823E);
try expect(chip8.registers[2] == 0b1110_0000);
try expect(chip8.registers[3] == 0xF0);
try expect(chip8.registers[0xF] == 1);
try expect(chip8.pc == 0x204);
}
test "0x9XY0 - Skip next instruction if VX != VY" {
var chip8 = Chip8.init();
chip8.runInstruction(0x9010);
try expect(chip8.pc == 0x202);
chip8.registers[2] = 1;
chip8.runInstruction(0x9020);
try expect(chip8.pc == 0x206);
}
test "0xANNN - Store NNN in I" {
var chip8 = Chip8.init();
chip8.runInstruction(0xA000);
try expect(chip8.i == 0);
try expect(chip8.pc == 0x202);
chip8.runInstruction(0xAFFF);
try expect(chip8.i == 0xFFF);
try expect(chip8.pc == 0x204);
}
test "0xBNNN - Jump to NNN + V0" {
var chip8 = Chip8.init();
chip8.runInstruction(0xB500);
try expect(chip8.pc == 0x500);
chip8.registers[0] = 0x23;
chip8.runInstruction(0xB100);
try expect(chip8.pc == 0x123);
}
test "0xCXNN - VX = randomByte() & NN" {
var chip8 = Chip8.init();
chip8.runInstruction(0xC003);
var val = chip8.registers[0];
try expect(val >= 0 and val <= 3);
try expect(chip8.pc == 0x202);
chip8.runInstruction(0xC1FF);
val = chip8.registers[1];
try expect(val >= 0 and val <= 0xFF);
try expect(chip8.pc == 0x204);
}
test "0xDXYN - Draw N+1 bytes of sprite data starting at I to (VX,VY)" {
var chip8 = Chip8.init();
var i: u16 = 0;
while (i < 16) : (i += 1) {
chip8.ram[0x300 + i] = 0xFF;
}
chip8.i = 0x300;
chip8.runInstruction(0xD010);
try expect(chip8.display[0] == 0xFF00_0000_0000_0000);
try expect(chip8.registers[0xF] == 0);
try expect(chip8.pc == 0x202);
chip8.registers[0] = 4;
chip8.runInstruction(0xD010);
try expect(chip8.display[0] == 0xF0F0_0000_0000_0000);
try expect(chip8.registers[0xF] == 1);
try expect(chip8.pc == 0x204);
chip8.registers[0] = 63;
chip8.registers[1] = 31;
chip8.runInstruction(0xD01F);
try expect(chip8.display[0] == 0xF0F0_0000_0000_0000);
try expect(chip8.display[31] == 0x0000_0000_0000_0001);
try expect(chip8.registers[0xF] == 0);
try expect(chip8.pc == 0x206);
chip8.registers[0] = 56;
chip8.registers[1] = 1;
chip8.runInstruction(0xD01F);
var row: u5 = 1;
while (row <= 16) : (row += 1) {
try expect(chip8.display[row] == 0xFF);
}
try expect(chip8.registers[0xF] == 0);
try expect(chip8.pc == 0x208);
chip8.registers[0] = 60;
chip8.registers[1] = 1;
chip8.runInstruction(0xD010);
try expect(chip8.display[1] == 0xF0);
try expect(chip8.registers[0xF] == 1);
try expect(chip8.pc == 0x20A);
}
test "0xEX9E - Skip next instruction if key X is pressed" {
var chip8 = Chip8.init();
chip8.runInstruction(0xE09E);
try expect(chip8.pc == 0x202);
chip8.keys |= 1;
chip8.runInstruction(0xE09E);
try expect(chip8.pc == 0x206);
}
test "0xEXA1 - Skip next instruction if key X is not pressed" {
var chip8 = Chip8.init();
chip8.runInstruction(0xE0A1);
try expect(chip8.pc == 0x204);
chip8.keys |= 1;
chip8.runInstruction(0xE0A1);
try expect(chip8.pc == 0x206);
}
test "0xFX07 - Store current value of delay timer in VX" {
var chip8 = Chip8.init();
const start_addr = chip8.pc;
for (chip8.registers) |*reg, i| {
chip8.delay_timer = randomByte();
chip8.runInstruction(0xF007 + @intCast(u16, 0x100 * i));
try expect(reg.* == chip8.delay_timer);
try expect(chip8.pc == start_addr + ((i + 1) * 2));
}
}
test "0xFX0A - Await a keypress and store the value in VX" {
var chip8 = Chip8.init();
chip8.runInstruction(0xF00A);
try expect(chip8.pc == 0x200);
chip8.keys |= 0b1100;
chip8.runInstruction(0xF00A);
try expect(chip8.registers[0] == 2);
try expect(chip8.pc == 0x202);
}
test "0xFX15 - Set the delay timer to the value of VX" {
var chip8 = Chip8.init();
chip8.runInstruction(0xF015);
try expect(chip8.delay_timer == 0);
try expect(chip8.pc == 0x202);
chip8.registers[1] = 0xFF;
chip8.runInstruction(0xF115);
try expect(chip8.delay_timer == 0xFF);
try expect(chip8.pc == 0x204);
}
test "0xFX18 - Set the sound timer to the value of VX" {
var chip8 = Chip8.init();
chip8.runInstruction(0xF018);
try expect(chip8.sound_timer == 0);
try expect(chip8.pc == 0x202);
chip8.registers[1] = 0xFF;
chip8.runInstruction(0xF118);
try expect(chip8.sound_timer == 0xFF);
try expect(chip8.pc == 0x204);
}
test "0xFX1E - I += VX (w/o carry)" {
var chip8 = Chip8.init();
chip8.runInstruction(0xF01E);
try expect(chip8.i == 0);
try expect(chip8.pc == 0x202);
chip8.i = 0xF0;
chip8.registers[1] = 0xF;
chip8.runInstruction(0xF11E);
try expect(chip8.i == 0xFF);
try expect(chip8.pc == 0x204);
chip8.i = 0xFFFF;
chip8.registers[1] = 1;
chip8.runInstruction(0xF11E);
try expect(chip8.i == 0);
try expect(chip8.pc == 0x206);
}
test "0xFX29 - Set I to the address of the sprite for char X" {
var chip8 = Chip8.init();
var char: u8 = 0;
const start_addr = chip8.pc;
while (char < 16) : (char += 1) {
chip8.registers[char] = char;
chip8.runInstruction(0xF029 + 0x100 * @as(u16, char));
try expect(chip8.i == 5 * char);
try expect(chip8.pc == start_addr + ((char + 1) * 2));
if (char == 15) break;
}
}
test "0xFX33 - Store the BCD representation of VX at I, I+1, and I+2" {
var chip8 = Chip8.init();
chip8.registers[0] = 123;
chip8.i = 0x300;
chip8.runInstruction(0xF033);
try expect(chip8.ram[0x300] == 1);
try expect(chip8.ram[0x301] == 2);
try expect(chip8.ram[0x302] == 3);
try expect(chip8.pc == 0x202);
}
test "0xFX55 - Store [V0, VX] in memory starting at I (incrementing I)" {
var chip8 = Chip8.init();
const data = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
for (data) |val, i| {
chip8.registers[i] = val;
}
const start_addr = 0x300;
chip8.i = start_addr;
chip8.runInstruction(0xF455);
const mem_range = chip8.ram[start_addr .. start_addr + 5];
try expect(mem.eql(u8, mem_range, data[0..5]));
try expect(mem.eql(u8, mem_range, chip8.registers[0..5]));
try expect(chip8.i == start_addr + 5);
try expect(chip8.pc == 0x202);
}
test "0xFX65 - Fill [V0, VX] from memory starting at I (incrementing I)" {
var chip8 = Chip8.init();
const data = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
const start_addr = 0x300;
for (data) |val, i| {
chip8.ram[start_addr + i] = val;
}
chip8.i = start_addr;
chip8.runInstruction(0xF465);
const reg_range = chip8.registers[0..5];
const mem_range = chip8.ram[start_addr .. start_addr + 5];
try expect(mem.eql(u8, reg_range, data[0..5]));
try expect(mem.eql(u8, reg_range, mem_range));
try expect(chip8.i == start_addr + 5);
try expect(chip8.pc == 0x202);
}
|
src/chip8/main.zig
|
const std = @import("std");
// Boilerplate reducing object construction / deconstruction interface via dynamic function creation
/// Create function that will allocate given T type with given allocator and call 'init' over it with arbitrary argument parameter
pub fn autoAlloc(comptime T: type) fn (std.mem.Allocator, anytype) anyerror!*T {
return struct {
fn alloc(allocator: std.mem.Allocator, args: anytype) anyerror!*T {
var self = try allocator.create(T);
errdefer allocator.destroy(self);
try self.init(args);
return self;
}
}.alloc;
}
/// Create function that will allocate given T type on stack and call 'init' over it with arbitrary argument parameter
pub fn autoCreate(comptime T: type) fn (anytype) callconv(.Inline) anyerror!T {
return struct {
inline fn create(args: anytype) anyerror!T {
var self = std.mem.zeroes(T);
try (&self).init(args);
return self;
}
}.create;
}
/// Create function that will call 'deinit' and then deallocate object with given allocator
pub fn autoDestroy(comptime T: type) fn (*T, std.mem.Allocator) void {
return struct {
fn destroy(self: *T, allocator: std.mem.Allocator) void {
self.deinit();
allocator.destroy(self);
}
}.destroy;
}
test "stack" {
const expect = std.testing.expect;
const MyObj = struct {
value: u32,
const Self = @This();
pub const create = autoCreate(Self);
pub const destroy = autoDestroy(Self);
fn init(self: *Self, args: anytype) !void {
self.value = args.@"0";
}
fn deinit(self: *Self) void {
_ = self;
}
};
var obj = try MyObj.create(.{123});
try expect(obj.value == 123);
}
test "heap" {
const expect = std.testing.expect;
const MyObj = struct {
value: u32,
const Self = @This();
pub const alloc = autoAlloc(Self);
pub const destroy = autoDestroy(Self);
fn init(self: *Self, args: anytype) !void {
self.value = args.@"0";
}
fn deinit(self: *Self) void {
_ = self;
}
};
var buffer: [100]u8 = undefined;
const allocator = std.heap.FixedBufferAllocator.init(&buffer).allocator();
var obj = try MyObj.alloc(allocator, .{123});
try expect(obj.value == 123);
obj.destroy(allocator);
}
|
zvt-object.zig
|
pub const QCC_TRUE = @as(u32, 1);
pub const QCC_FALSE = @as(u32, 0);
pub const ALLJOYN_MESSAGE_FLAG_NO_REPLY_EXPECTED = @as(u32, 1);
pub const ALLJOYN_MESSAGE_FLAG_AUTO_START = @as(u32, 2);
pub const ALLJOYN_MESSAGE_FLAG_ALLOW_REMOTE_MSG = @as(u32, 4);
pub const ALLJOYN_MESSAGE_FLAG_SESSIONLESS = @as(u32, 16);
pub const ALLJOYN_MESSAGE_FLAG_GLOBAL_BROADCAST = @as(u32, 32);
pub const ALLJOYN_MESSAGE_FLAG_ENCRYPTED = @as(u32, 128);
pub const ALLJOYN_TRAFFIC_TYPE_MESSAGES = @as(u32, 1);
pub const ALLJOYN_TRAFFIC_TYPE_RAW_UNRELIABLE = @as(u32, 2);
pub const ALLJOYN_TRAFFIC_TYPE_RAW_RELIABLE = @as(u32, 4);
pub const ALLJOYN_PROXIMITY_ANY = @as(u32, 255);
pub const ALLJOYN_PROXIMITY_PHYSICAL = @as(u32, 1);
pub const ALLJOYN_PROXIMITY_NETWORK = @as(u32, 2);
pub const ALLJOYN_READ_READY = @as(u32, 1);
pub const ALLJOYN_WRITE_READY = @as(u32, 2);
pub const ALLJOYN_DISCONNECTED = @as(u32, 4);
pub const ALLJOYN_LITTLE_ENDIAN = @as(u8, 108);
pub const ALLJOYN_BIG_ENDIAN = @as(u8, 66);
pub const ALLJOYN_MESSAGE_DEFAULT_TIMEOUT = @as(u32, 25000);
pub const ALLJOYN_CRED_PASSWORD = @as(u16, 1);
pub const ALLJOYN_CRED_USER_NAME = @as(u16, 2);
pub const ALLJOYN_CRED_CERT_CHAIN = @as(u16, 4);
pub const ALLJOYN_CRED_PRIVATE_KEY = @as(u16, 8);
pub const ALLJOYN_CRED_LOGON_ENTRY = @as(u16, 16);
pub const ALLJOYN_CRED_EXPIRATION = @as(u16, 32);
pub const ALLJOYN_CRED_NEW_PASSWORD = @as(u16, 4097);
pub const ALLJOYN_CRED_ONE_TIME_PWD = @as(u16, 8193);
pub const ALLJOYN_PROP_ACCESS_READ = @as(u8, 1);
pub const ALLJOYN_PROP_ACCESS_WRITE = @as(u8, 2);
pub const ALLJOYN_PROP_ACCESS_RW = @as(u8, 3);
pub const ALLJOYN_MEMBER_ANNOTATE_NO_REPLY = @as(u8, 1);
pub const ALLJOYN_MEMBER_ANNOTATE_DEPRECATED = @as(u8, 2);
pub const ALLJOYN_MEMBER_ANNOTATE_SESSIONCAST = @as(u8, 4);
pub const ALLJOYN_MEMBER_ANNOTATE_SESSIONLESS = @as(u8, 8);
pub const ALLJOYN_MEMBER_ANNOTATE_UNICAST = @as(u8, 16);
pub const ALLJOYN_MEMBER_ANNOTATE_GLOBAL_BROADCAST = @as(u8, 32);
//--------------------------------------------------------------------------------
// Section: Types (110)
//--------------------------------------------------------------------------------
pub const alljoyn_about_announceflag = enum(i32) {
UNANNOUNCED = 0,
ANNOUNCED = 1,
};
pub const UNANNOUNCED = alljoyn_about_announceflag.UNANNOUNCED;
pub const ANNOUNCED = alljoyn_about_announceflag.ANNOUNCED;
pub const QStatus = enum(i32) {
OK = 0,
FAIL = 1,
UTF_CONVERSION_FAILED = 2,
BUFFER_TOO_SMALL = 3,
OS_ERROR = 4,
OUT_OF_MEMORY = 5,
SOCKET_BIND_ERROR = 6,
INIT_FAILED = 7,
WOULDBLOCK = 8,
NOT_IMPLEMENTED = 9,
TIMEOUT = 10,
SOCK_OTHER_END_CLOSED = 11,
BAD_ARG_1 = 12,
BAD_ARG_2 = 13,
BAD_ARG_3 = 14,
BAD_ARG_4 = 15,
BAD_ARG_5 = 16,
BAD_ARG_6 = 17,
BAD_ARG_7 = 18,
BAD_ARG_8 = 19,
INVALID_ADDRESS = 20,
INVALID_DATA = 21,
READ_ERROR = 22,
WRITE_ERROR = 23,
OPEN_FAILED = 24,
PARSE_ERROR = 25,
END_OF_DATA = 26,
CONN_REFUSED = 27,
BAD_ARG_COUNT = 28,
WARNING = 29,
EOF = 30,
DEADLOCK = 31,
COMMON_ERRORS = 4096,
STOPPING_THREAD = 4097,
ALERTED_THREAD = 4098,
XML_MALFORMED = 4099,
AUTH_FAIL = 4100,
AUTH_USER_REJECT = 4101,
NO_SUCH_ALARM = 4102,
TIMER_FALLBEHIND = 4103,
SSL_ERRORS = 4104,
SSL_INIT = 4105,
SSL_CONNECT = 4106,
SSL_VERIFY = 4107,
EXTERNAL_THREAD = 4108,
CRYPTO_ERROR = 4109,
CRYPTO_TRUNCATED = 4110,
CRYPTO_KEY_UNAVAILABLE = 4111,
BAD_HOSTNAME = 4112,
CRYPTO_KEY_UNUSABLE = 4113,
EMPTY_KEY_BLOB = 4114,
CORRUPT_KEYBLOB = 4115,
INVALID_KEY_ENCODING = 4116,
DEAD_THREAD = 4117,
THREAD_RUNNING = 4118,
THREAD_STOPPING = 4119,
BAD_STRING_ENCODING = 4120,
CRYPTO_INSUFFICIENT_SECURITY = 4121,
CRYPTO_ILLEGAL_PARAMETERS = 4122,
CRYPTO_HASH_UNINITIALIZED = 4123,
THREAD_NO_WAIT = 4124,
TIMER_EXITING = 4125,
INVALID_GUID = 4126,
THREADPOOL_EXHAUSTED = 4127,
THREADPOOL_STOPPING = 4128,
INVALID_STREAM = 4129,
TIMER_FULL = 4130,
IODISPATCH_STOPPING = 4131,
SLAP_INVALID_PACKET_LEN = 4132,
SLAP_HDR_CHECKSUM_ERROR = 4133,
SLAP_INVALID_PACKET_TYPE = 4134,
SLAP_LEN_MISMATCH = 4135,
SLAP_PACKET_TYPE_MISMATCH = 4136,
SLAP_CRC_ERROR = 4137,
SLAP_ERROR = 4138,
SLAP_OTHER_END_CLOSED = 4139,
TIMER_NOT_ALLOWED = 4140,
NOT_CONN = 4141,
XML_CONVERTER_ERROR = 8192,
XML_INVALID_RULES_COUNT = 8193,
XML_INTERFACE_MEMBERS_MISSING = 8194,
XML_INVALID_MEMBER_TYPE = 8195,
XML_INVALID_MEMBER_ACTION = 8196,
XML_MEMBER_DENY_ACTION_WITH_OTHER = 8197,
XML_INVALID_ANNOTATIONS_COUNT = 8198,
XML_INVALID_ELEMENT_NAME = 8199,
XML_INVALID_ATTRIBUTE_VALUE = 8200,
XML_INVALID_SECURITY_LEVEL_ANNOTATION_VALUE = 8201,
XML_INVALID_ELEMENT_CHILDREN_COUNT = 8202,
XML_INVALID_POLICY_VERSION = 8203,
XML_INVALID_POLICY_SERIAL_NUMBER = 8204,
XML_INVALID_ACL_PEER_TYPE = 8205,
XML_INVALID_ACL_PEER_CHILDREN_COUNT = 8206,
XML_ACL_ALL_TYPE_PEER_WITH_OTHERS = 8207,
XML_INVALID_ACL_PEER_PUBLIC_KEY = 8208,
XML_ACL_PEER_NOT_UNIQUE = 8209,
XML_ACL_PEER_PUBLIC_KEY_SET = 8210,
XML_ACLS_MISSING = 8211,
XML_ACL_PEERS_MISSING = 8212,
XML_INVALID_OBJECT_PATH = 8213,
XML_INVALID_INTERFACE_NAME = 8214,
XML_INVALID_MEMBER_NAME = 8215,
XML_INVALID_MANIFEST_VERSION = 8216,
XML_INVALID_OID = 8217,
XML_INVALID_BASE64 = 8218,
XML_INTERFACE_NAME_NOT_UNIQUE = 8219,
XML_MEMBER_NAME_NOT_UNIQUE = 8220,
XML_OBJECT_PATH_NOT_UNIQUE = 8221,
XML_ANNOTATION_NOT_UNIQUE = 8222,
NONE = 65535,
BUS_ERRORS = 36864,
BUS_READ_ERROR = 36865,
BUS_WRITE_ERROR = 36866,
BUS_BAD_VALUE_TYPE = 36867,
BUS_BAD_HEADER_FIELD = 36868,
BUS_BAD_SIGNATURE = 36869,
BUS_BAD_OBJ_PATH = 36870,
BUS_BAD_MEMBER_NAME = 36871,
BUS_BAD_INTERFACE_NAME = 36872,
BUS_BAD_ERROR_NAME = 36873,
BUS_BAD_BUS_NAME = 36874,
BUS_NAME_TOO_LONG = 36875,
BUS_BAD_LENGTH = 36876,
BUS_BAD_VALUE = 36877,
BUS_BAD_HDR_FLAGS = 36878,
BUS_BAD_BODY_LEN = 36879,
BUS_BAD_HEADER_LEN = 36880,
BUS_UNKNOWN_SERIAL = 36881,
BUS_UNKNOWN_PATH = 36882,
BUS_UNKNOWN_INTERFACE = 36883,
BUS_ESTABLISH_FAILED = 36884,
BUS_UNEXPECTED_SIGNATURE = 36885,
BUS_INTERFACE_MISSING = 36886,
BUS_PATH_MISSING = 36887,
BUS_MEMBER_MISSING = 36888,
BUS_REPLY_SERIAL_MISSING = 36889,
BUS_ERROR_NAME_MISSING = 36890,
BUS_INTERFACE_NO_SUCH_MEMBER = 36891,
BUS_NO_SUCH_OBJECT = 36892,
BUS_OBJECT_NO_SUCH_MEMBER = 36893,
BUS_OBJECT_NO_SUCH_INTERFACE = 36894,
BUS_NO_SUCH_INTERFACE = 36895,
BUS_MEMBER_NO_SUCH_SIGNATURE = 36896,
BUS_NOT_NUL_TERMINATED = 36897,
BUS_NO_SUCH_PROPERTY = 36898,
BUS_SET_WRONG_SIGNATURE = 36899,
BUS_PROPERTY_VALUE_NOT_SET = 36900,
BUS_PROPERTY_ACCESS_DENIED = 36901,
BUS_NO_TRANSPORTS = 36902,
BUS_BAD_TRANSPORT_ARGS = 36903,
BUS_NO_ROUTE = 36904,
BUS_NO_ENDPOINT = 36905,
BUS_BAD_SEND_PARAMETER = 36906,
BUS_UNMATCHED_REPLY_SERIAL = 36907,
BUS_BAD_SENDER_ID = 36908,
BUS_TRANSPORT_NOT_STARTED = 36909,
BUS_EMPTY_MESSAGE = 36910,
BUS_NOT_OWNER = 36911,
BUS_SET_PROPERTY_REJECTED = 36912,
BUS_CONNECT_FAILED = 36913,
BUS_REPLY_IS_ERROR_MESSAGE = 36914,
BUS_NOT_AUTHENTICATING = 36915,
BUS_NO_LISTENER = 36916,
BUS_NOT_ALLOWED = 36918,
BUS_WRITE_QUEUE_FULL = 36919,
BUS_ENDPOINT_CLOSING = 36920,
BUS_INTERFACE_MISMATCH = 36921,
BUS_MEMBER_ALREADY_EXISTS = 36922,
BUS_PROPERTY_ALREADY_EXISTS = 36923,
BUS_IFACE_ALREADY_EXISTS = 36924,
BUS_ERROR_RESPONSE = 36925,
BUS_BAD_XML = 36926,
BUS_BAD_CHILD_PATH = 36927,
BUS_OBJ_ALREADY_EXISTS = 36928,
BUS_OBJ_NOT_FOUND = 36929,
BUS_CANNOT_EXPAND_MESSAGE = 36930,
BUS_NOT_COMPRESSED = 36931,
BUS_ALREADY_CONNECTED = 36932,
BUS_NOT_CONNECTED = 36933,
BUS_ALREADY_LISTENING = 36934,
BUS_KEY_UNAVAILABLE = 36935,
BUS_TRUNCATED = 36936,
BUS_KEY_STORE_NOT_LOADED = 36937,
BUS_NO_AUTHENTICATION_MECHANISM = 36938,
BUS_BUS_ALREADY_STARTED = 36939,
BUS_BUS_NOT_STARTED = 36940,
BUS_KEYBLOB_OP_INVALID = 36941,
BUS_INVALID_HEADER_CHECKSUM = 36942,
BUS_MESSAGE_NOT_ENCRYPTED = 36943,
BUS_INVALID_HEADER_SERIAL = 36944,
BUS_TIME_TO_LIVE_EXPIRED = 36945,
BUS_HDR_EXPANSION_INVALID = 36946,
BUS_MISSING_COMPRESSION_TOKEN = 36947,
BUS_NO_PEER_GUID = 36948,
BUS_MESSAGE_DECRYPTION_FAILED = 36949,
BUS_SECURITY_FATAL = 36950,
BUS_KEY_EXPIRED = 36951,
BUS_CORRUPT_KEYSTORE = 36952,
BUS_NO_CALL_FOR_REPLY = 36953,
BUS_NOT_A_COMPLETE_TYPE = 36954,
BUS_POLICY_VIOLATION = 36955,
BUS_NO_SUCH_SERVICE = 36956,
BUS_TRANSPORT_NOT_AVAILABLE = 36957,
BUS_INVALID_AUTH_MECHANISM = 36958,
BUS_KEYSTORE_VERSION_MISMATCH = 36959,
BUS_BLOCKING_CALL_NOT_ALLOWED = 36960,
BUS_SIGNATURE_MISMATCH = 36961,
BUS_STOPPING = 36962,
BUS_METHOD_CALL_ABORTED = 36963,
BUS_CANNOT_ADD_INTERFACE = 36964,
BUS_CANNOT_ADD_HANDLER = 36965,
BUS_KEYSTORE_NOT_LOADED = 36966,
BUS_NO_SUCH_HANDLE = 36971,
BUS_HANDLES_NOT_ENABLED = 36972,
BUS_HANDLES_MISMATCH = 36973,
BUS_NO_SESSION = 36975,
BUS_ELEMENT_NOT_FOUND = 36976,
BUS_NOT_A_DICTIONARY = 36977,
BUS_WAIT_FAILED = 36978,
BUS_BAD_SESSION_OPTS = 36980,
BUS_CONNECTION_REJECTED = 36981,
DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER = 36982,
DBUS_REQUEST_NAME_REPLY_IN_QUEUE = 36983,
DBUS_REQUEST_NAME_REPLY_EXISTS = 36984,
DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER = 36985,
DBUS_RELEASE_NAME_REPLY_RELEASED = 36986,
DBUS_RELEASE_NAME_REPLY_NON_EXISTENT = 36987,
DBUS_RELEASE_NAME_REPLY_NOT_OWNER = 36988,
DBUS_START_REPLY_ALREADY_RUNNING = 36990,
ALLJOYN_BINDSESSIONPORT_REPLY_ALREADY_EXISTS = 36992,
ALLJOYN_BINDSESSIONPORT_REPLY_FAILED = 36993,
ALLJOYN_JOINSESSION_REPLY_NO_SESSION = 36995,
ALLJOYN_JOINSESSION_REPLY_UNREACHABLE = 36996,
ALLJOYN_JOINSESSION_REPLY_CONNECT_FAILED = 36997,
ALLJOYN_JOINSESSION_REPLY_REJECTED = 36998,
ALLJOYN_JOINSESSION_REPLY_BAD_SESSION_OPTS = 36999,
ALLJOYN_JOINSESSION_REPLY_FAILED = 37000,
ALLJOYN_LEAVESESSION_REPLY_NO_SESSION = 37002,
ALLJOYN_LEAVESESSION_REPLY_FAILED = 37003,
ALLJOYN_ADVERTISENAME_REPLY_TRANSPORT_NOT_AVAILABLE = 37004,
ALLJOYN_ADVERTISENAME_REPLY_ALREADY_ADVERTISING = 37005,
ALLJOYN_ADVERTISENAME_REPLY_FAILED = 37006,
ALLJOYN_CANCELADVERTISENAME_REPLY_FAILED = 37008,
ALLJOYN_FINDADVERTISEDNAME_REPLY_TRANSPORT_NOT_AVAILABLE = 37009,
ALLJOYN_FINDADVERTISEDNAME_REPLY_ALREADY_DISCOVERING = 37010,
ALLJOYN_FINDADVERTISEDNAME_REPLY_FAILED = 37011,
ALLJOYN_CANCELFINDADVERTISEDNAME_REPLY_FAILED = 37013,
BUS_UNEXPECTED_DISPOSITION = 37014,
BUS_INTERFACE_ACTIVATED = 37015,
ALLJOYN_UNBINDSESSIONPORT_REPLY_BAD_PORT = 37016,
ALLJOYN_UNBINDSESSIONPORT_REPLY_FAILED = 37017,
ALLJOYN_BINDSESSIONPORT_REPLY_INVALID_OPTS = 37018,
ALLJOYN_JOINSESSION_REPLY_ALREADY_JOINED = 37019,
BUS_SELF_CONNECT = 37020,
BUS_SECURITY_NOT_ENABLED = 37021,
BUS_LISTENER_ALREADY_SET = 37022,
BUS_PEER_AUTH_VERSION_MISMATCH = 37023,
ALLJOYN_SETLINKTIMEOUT_REPLY_NOT_SUPPORTED = 37024,
ALLJOYN_SETLINKTIMEOUT_REPLY_NO_DEST_SUPPORT = 37025,
ALLJOYN_SETLINKTIMEOUT_REPLY_FAILED = 37026,
ALLJOYN_ACCESS_PERMISSION_WARNING = 37027,
ALLJOYN_ACCESS_PERMISSION_ERROR = 37028,
BUS_DESTINATION_NOT_AUTHENTICATED = 37029,
BUS_ENDPOINT_REDIRECTED = 37030,
BUS_AUTHENTICATION_PENDING = 37031,
BUS_NOT_AUTHORIZED = 37032,
PACKET_BUS_NO_SUCH_CHANNEL = 37033,
PACKET_BAD_FORMAT = 37034,
PACKET_CONNECT_TIMEOUT = 37035,
PACKET_CHANNEL_FAIL = 37036,
PACKET_TOO_LARGE = 37037,
PACKET_BAD_PARAMETER = 37038,
PACKET_BAD_CRC = 37039,
RENDEZVOUS_SERVER_DEACTIVATED_USER = 37067,
RENDEZVOUS_SERVER_UNKNOWN_USER = 37068,
UNABLE_TO_CONNECT_TO_RENDEZVOUS_SERVER = 37069,
NOT_CONNECTED_TO_RENDEZVOUS_SERVER = 37070,
UNABLE_TO_SEND_MESSAGE_TO_RENDEZVOUS_SERVER = 37071,
INVALID_RENDEZVOUS_SERVER_INTERFACE_MESSAGE = 37072,
INVALID_PERSISTENT_CONNECTION_MESSAGE_RESPONSE = 37073,
INVALID_ON_DEMAND_CONNECTION_MESSAGE_RESPONSE = 37074,
INVALID_HTTP_METHOD_USED_FOR_RENDEZVOUS_SERVER_INTERFACE_MESSAGE = 37075,
RENDEZVOUS_SERVER_ERR500_INTERNAL_ERROR = 37076,
RENDEZVOUS_SERVER_ERR503_STATUS_UNAVAILABLE = 37077,
RENDEZVOUS_SERVER_ERR401_UNAUTHORIZED_REQUEST = 37078,
RENDEZVOUS_SERVER_UNRECOVERABLE_ERROR = 37079,
RENDEZVOUS_SERVER_ROOT_CERTIFICATE_UNINITIALIZED = 37080,
BUS_NO_SUCH_ANNOTATION = 37081,
BUS_ANNOTATION_ALREADY_EXISTS = 37082,
SOCK_CLOSING = 37083,
NO_SUCH_DEVICE = 37084,
P2P = 37085,
P2P_TIMEOUT = 37086,
P2P_NOT_CONNECTED = 37087,
BAD_TRANSPORT_MASK = 37088,
PROXIMITY_CONNECTION_ESTABLISH_FAIL = 37089,
PROXIMITY_NO_PEERS_FOUND = 37090,
BUS_OBJECT_NOT_REGISTERED = 37091,
P2P_DISABLED = 37092,
P2P_BUSY = 37093,
BUS_INCOMPATIBLE_DAEMON = 37094,
P2P_NO_GO = 37095,
P2P_NO_STA = 37096,
P2P_FORBIDDEN = 37097,
ALLJOYN_ONAPPSUSPEND_REPLY_FAILED = 37098,
ALLJOYN_ONAPPSUSPEND_REPLY_UNSUPPORTED = 37099,
ALLJOYN_ONAPPRESUME_REPLY_FAILED = 37100,
ALLJOYN_ONAPPRESUME_REPLY_UNSUPPORTED = 37101,
BUS_NO_SUCH_MESSAGE = 37102,
ALLJOYN_REMOVESESSIONMEMBER_REPLY_NO_SESSION = 37103,
ALLJOYN_REMOVESESSIONMEMBER_NOT_BINDER = 37104,
ALLJOYN_REMOVESESSIONMEMBER_NOT_MULTIPOINT = 37105,
ALLJOYN_REMOVESESSIONMEMBER_NOT_FOUND = 37106,
ALLJOYN_REMOVESESSIONMEMBER_INCOMPATIBLE_REMOTE_DAEMON = 37107,
ALLJOYN_REMOVESESSIONMEMBER_REPLY_FAILED = 37108,
BUS_REMOVED_BY_BINDER = 37109,
BUS_MATCH_RULE_NOT_FOUND = 37110,
ALLJOYN_PING_FAILED = 37111,
ALLJOYN_PING_REPLY_UNREACHABLE = 37112,
UDP_MSG_TOO_LONG = 37113,
UDP_DEMUX_NO_ENDPOINT = 37114,
UDP_NO_NETWORK = 37115,
UDP_UNEXPECTED_LENGTH = 37116,
UDP_UNEXPECTED_FLOW = 37117,
UDP_DISCONNECT = 37118,
UDP_NOT_IMPLEMENTED = 37119,
UDP_NO_LISTENER = 37120,
UDP_STOPPING = 37121,
ARDP_BACKPRESSURE = 37122,
UDP_BACKPRESSURE = 37123,
ARDP_INVALID_STATE = 37124,
ARDP_TTL_EXPIRED = 37125,
ARDP_PERSIST_TIMEOUT = 37126,
ARDP_PROBE_TIMEOUT = 37127,
ARDP_REMOTE_CONNECTION_RESET = 37128,
UDP_BUSHELLO = 37129,
UDP_MESSAGE = 37130,
UDP_INVALID = 37131,
UDP_UNSUPPORTED = 37132,
UDP_ENDPOINT_STALLED = 37133,
ARDP_INVALID_RESPONSE = 37134,
ARDP_INVALID_CONNECTION = 37135,
UDP_LOCAL_DISCONNECT = 37136,
UDP_EARLY_EXIT = 37137,
UDP_LOCAL_DISCONNECT_FAIL = 37138,
ARDP_DISCONNECTING = 37139,
ALLJOYN_PING_REPLY_INCOMPATIBLE_REMOTE_ROUTING_NODE = 37140,
ALLJOYN_PING_REPLY_TIMEOUT = 37141,
ALLJOYN_PING_REPLY_UNKNOWN_NAME = 37142,
ALLJOYN_PING_REPLY_FAILED = 37143,
TCP_MAX_UNTRUSTED = 37144,
ALLJOYN_PING_REPLY_IN_PROGRESS = 37145,
LANGUAGE_NOT_SUPPORTED = 37146,
ABOUT_FIELD_ALREADY_SPECIFIED = 37147,
UDP_NOT_DISCONNECTED = 37148,
UDP_ENDPOINT_NOT_STARTED = 37149,
UDP_ENDPOINT_REMOVED = 37150,
ARDP_VERSION_NOT_SUPPORTED = 37151,
CONNECTION_LIMIT_EXCEEDED = 37152,
ARDP_WRITE_BLOCKED = 37153,
PERMISSION_DENIED = 37154,
ABOUT_DEFAULT_LANGUAGE_NOT_SPECIFIED = 37155,
ABOUT_SESSIONPORT_NOT_BOUND = 37156,
ABOUT_ABOUTDATA_MISSING_REQUIRED_FIELD = 37157,
ABOUT_INVALID_ABOUTDATA_LISTENER = 37158,
BUS_PING_GROUP_NOT_FOUND = 37159,
BUS_REMOVED_BY_BINDER_SELF = 37160,
INVALID_CONFIG = 37161,
ABOUT_INVALID_ABOUTDATA_FIELD_VALUE = 37162,
ABOUT_INVALID_ABOUTDATA_FIELD_APPID_SIZE = 37163,
BUS_TRANSPORT_ACCESS_DENIED = 37164,
INVALID_CERTIFICATE = 37165,
CERTIFICATE_NOT_FOUND = 37166,
DUPLICATE_CERTIFICATE = 37167,
UNKNOWN_CERTIFICATE = 37168,
MISSING_DIGEST_IN_CERTIFICATE = 37169,
DIGEST_MISMATCH = 37170,
DUPLICATE_KEY = 37171,
NO_COMMON_TRUST = 37172,
MANIFEST_NOT_FOUND = 37173,
INVALID_CERT_CHAIN = 37174,
NO_TRUST_ANCHOR = 37175,
INVALID_APPLICATION_STATE = 37176,
FEATURE_NOT_AVAILABLE = 37177,
KEY_STORE_ALREADY_INITIALIZED = 37178,
KEY_STORE_ID_NOT_YET_SET = 37179,
POLICY_NOT_NEWER = 37180,
MANIFEST_REJECTED = 37181,
INVALID_CERTIFICATE_USAGE = 37182,
INVALID_SIGNAL_EMISSION_TYPE = 37183,
APPLICATION_STATE_LISTENER_ALREADY_EXISTS = 37184,
APPLICATION_STATE_LISTENER_NO_SUCH_LISTENER = 37185,
MANAGEMENT_ALREADY_STARTED = 37186,
MANAGEMENT_NOT_STARTED = 37187,
BUS_DESCRIPTION_ALREADY_EXISTS = 37188,
};
pub const ER_OK = QStatus.OK;
pub const ER_FAIL = QStatus.FAIL;
pub const ER_UTF_CONVERSION_FAILED = QStatus.UTF_CONVERSION_FAILED;
pub const ER_BUFFER_TOO_SMALL = QStatus.BUFFER_TOO_SMALL;
pub const ER_OS_ERROR = QStatus.OS_ERROR;
pub const ER_OUT_OF_MEMORY = QStatus.OUT_OF_MEMORY;
pub const ER_SOCKET_BIND_ERROR = QStatus.SOCKET_BIND_ERROR;
pub const ER_INIT_FAILED = QStatus.INIT_FAILED;
pub const ER_WOULDBLOCK = QStatus.WOULDBLOCK;
pub const ER_NOT_IMPLEMENTED = QStatus.NOT_IMPLEMENTED;
pub const ER_TIMEOUT = QStatus.TIMEOUT;
pub const ER_SOCK_OTHER_END_CLOSED = QStatus.SOCK_OTHER_END_CLOSED;
pub const ER_BAD_ARG_1 = QStatus.BAD_ARG_1;
pub const ER_BAD_ARG_2 = QStatus.BAD_ARG_2;
pub const ER_BAD_ARG_3 = QStatus.BAD_ARG_3;
pub const ER_BAD_ARG_4 = QStatus.BAD_ARG_4;
pub const ER_BAD_ARG_5 = QStatus.BAD_ARG_5;
pub const ER_BAD_ARG_6 = QStatus.BAD_ARG_6;
pub const ER_BAD_ARG_7 = QStatus.BAD_ARG_7;
pub const ER_BAD_ARG_8 = QStatus.BAD_ARG_8;
pub const ER_INVALID_ADDRESS = QStatus.INVALID_ADDRESS;
pub const ER_INVALID_DATA = QStatus.INVALID_DATA;
pub const ER_READ_ERROR = QStatus.READ_ERROR;
pub const ER_WRITE_ERROR = QStatus.WRITE_ERROR;
pub const ER_OPEN_FAILED = QStatus.OPEN_FAILED;
pub const ER_PARSE_ERROR = QStatus.PARSE_ERROR;
pub const ER_END_OF_DATA = QStatus.END_OF_DATA;
pub const ER_CONN_REFUSED = QStatus.CONN_REFUSED;
pub const ER_BAD_ARG_COUNT = QStatus.BAD_ARG_COUNT;
pub const ER_WARNING = QStatus.WARNING;
pub const ER_EOF = QStatus.EOF;
pub const ER_DEADLOCK = QStatus.DEADLOCK;
pub const ER_COMMON_ERRORS = QStatus.COMMON_ERRORS;
pub const ER_STOPPING_THREAD = QStatus.STOPPING_THREAD;
pub const ER_ALERTED_THREAD = QStatus.ALERTED_THREAD;
pub const ER_XML_MALFORMED = QStatus.XML_MALFORMED;
pub const ER_AUTH_FAIL = QStatus.AUTH_FAIL;
pub const ER_AUTH_USER_REJECT = QStatus.AUTH_USER_REJECT;
pub const ER_NO_SUCH_ALARM = QStatus.NO_SUCH_ALARM;
pub const ER_TIMER_FALLBEHIND = QStatus.TIMER_FALLBEHIND;
pub const ER_SSL_ERRORS = QStatus.SSL_ERRORS;
pub const ER_SSL_INIT = QStatus.SSL_INIT;
pub const ER_SSL_CONNECT = QStatus.SSL_CONNECT;
pub const ER_SSL_VERIFY = QStatus.SSL_VERIFY;
pub const ER_EXTERNAL_THREAD = QStatus.EXTERNAL_THREAD;
pub const ER_CRYPTO_ERROR = QStatus.CRYPTO_ERROR;
pub const ER_CRYPTO_TRUNCATED = QStatus.CRYPTO_TRUNCATED;
pub const ER_CRYPTO_KEY_UNAVAILABLE = QStatus.CRYPTO_KEY_UNAVAILABLE;
pub const ER_BAD_HOSTNAME = QStatus.BAD_HOSTNAME;
pub const ER_CRYPTO_KEY_UNUSABLE = QStatus.CRYPTO_KEY_UNUSABLE;
pub const ER_EMPTY_KEY_BLOB = QStatus.EMPTY_KEY_BLOB;
pub const ER_CORRUPT_KEYBLOB = QStatus.CORRUPT_KEYBLOB;
pub const ER_INVALID_KEY_ENCODING = QStatus.INVALID_KEY_ENCODING;
pub const ER_DEAD_THREAD = QStatus.DEAD_THREAD;
pub const ER_THREAD_RUNNING = QStatus.THREAD_RUNNING;
pub const ER_THREAD_STOPPING = QStatus.THREAD_STOPPING;
pub const ER_BAD_STRING_ENCODING = QStatus.BAD_STRING_ENCODING;
pub const ER_CRYPTO_INSUFFICIENT_SECURITY = QStatus.CRYPTO_INSUFFICIENT_SECURITY;
pub const ER_CRYPTO_ILLEGAL_PARAMETERS = QStatus.CRYPTO_ILLEGAL_PARAMETERS;
pub const ER_CRYPTO_HASH_UNINITIALIZED = QStatus.CRYPTO_HASH_UNINITIALIZED;
pub const ER_THREAD_NO_WAIT = QStatus.THREAD_NO_WAIT;
pub const ER_TIMER_EXITING = QStatus.TIMER_EXITING;
pub const ER_INVALID_GUID = QStatus.INVALID_GUID;
pub const ER_THREADPOOL_EXHAUSTED = QStatus.THREADPOOL_EXHAUSTED;
pub const ER_THREADPOOL_STOPPING = QStatus.THREADPOOL_STOPPING;
pub const ER_INVALID_STREAM = QStatus.INVALID_STREAM;
pub const ER_TIMER_FULL = QStatus.TIMER_FULL;
pub const ER_IODISPATCH_STOPPING = QStatus.IODISPATCH_STOPPING;
pub const ER_SLAP_INVALID_PACKET_LEN = QStatus.SLAP_INVALID_PACKET_LEN;
pub const ER_SLAP_HDR_CHECKSUM_ERROR = QStatus.SLAP_HDR_CHECKSUM_ERROR;
pub const ER_SLAP_INVALID_PACKET_TYPE = QStatus.SLAP_INVALID_PACKET_TYPE;
pub const ER_SLAP_LEN_MISMATCH = QStatus.SLAP_LEN_MISMATCH;
pub const ER_SLAP_PACKET_TYPE_MISMATCH = QStatus.SLAP_PACKET_TYPE_MISMATCH;
pub const ER_SLAP_CRC_ERROR = QStatus.SLAP_CRC_ERROR;
pub const ER_SLAP_ERROR = QStatus.SLAP_ERROR;
pub const ER_SLAP_OTHER_END_CLOSED = QStatus.SLAP_OTHER_END_CLOSED;
pub const ER_TIMER_NOT_ALLOWED = QStatus.TIMER_NOT_ALLOWED;
pub const ER_NOT_CONN = QStatus.NOT_CONN;
pub const ER_XML_CONVERTER_ERROR = QStatus.XML_CONVERTER_ERROR;
pub const ER_XML_INVALID_RULES_COUNT = QStatus.XML_INVALID_RULES_COUNT;
pub const ER_XML_INTERFACE_MEMBERS_MISSING = QStatus.XML_INTERFACE_MEMBERS_MISSING;
pub const ER_XML_INVALID_MEMBER_TYPE = QStatus.XML_INVALID_MEMBER_TYPE;
pub const ER_XML_INVALID_MEMBER_ACTION = QStatus.XML_INVALID_MEMBER_ACTION;
pub const ER_XML_MEMBER_DENY_ACTION_WITH_OTHER = QStatus.XML_MEMBER_DENY_ACTION_WITH_OTHER;
pub const ER_XML_INVALID_ANNOTATIONS_COUNT = QStatus.XML_INVALID_ANNOTATIONS_COUNT;
pub const ER_XML_INVALID_ELEMENT_NAME = QStatus.XML_INVALID_ELEMENT_NAME;
pub const ER_XML_INVALID_ATTRIBUTE_VALUE = QStatus.XML_INVALID_ATTRIBUTE_VALUE;
pub const ER_XML_INVALID_SECURITY_LEVEL_ANNOTATION_VALUE = QStatus.XML_INVALID_SECURITY_LEVEL_ANNOTATION_VALUE;
pub const ER_XML_INVALID_ELEMENT_CHILDREN_COUNT = QStatus.XML_INVALID_ELEMENT_CHILDREN_COUNT;
pub const ER_XML_INVALID_POLICY_VERSION = QStatus.XML_INVALID_POLICY_VERSION;
pub const ER_XML_INVALID_POLICY_SERIAL_NUMBER = QStatus.XML_INVALID_POLICY_SERIAL_NUMBER;
pub const ER_XML_INVALID_ACL_PEER_TYPE = QStatus.XML_INVALID_ACL_PEER_TYPE;
pub const ER_XML_INVALID_ACL_PEER_CHILDREN_COUNT = QStatus.XML_INVALID_ACL_PEER_CHILDREN_COUNT;
pub const ER_XML_ACL_ALL_TYPE_PEER_WITH_OTHERS = QStatus.XML_ACL_ALL_TYPE_PEER_WITH_OTHERS;
pub const ER_XML_INVALID_ACL_PEER_PUBLIC_KEY = QStatus.XML_INVALID_ACL_PEER_PUBLIC_KEY;
pub const ER_XML_ACL_PEER_NOT_UNIQUE = QStatus.XML_ACL_PEER_NOT_UNIQUE;
pub const ER_XML_ACL_PEER_PUBLIC_KEY_SET = QStatus.XML_ACL_PEER_PUBLIC_KEY_SET;
pub const ER_XML_ACLS_MISSING = QStatus.XML_ACLS_MISSING;
pub const ER_XML_ACL_PEERS_MISSING = QStatus.XML_ACL_PEERS_MISSING;
pub const ER_XML_INVALID_OBJECT_PATH = QStatus.XML_INVALID_OBJECT_PATH;
pub const ER_XML_INVALID_INTERFACE_NAME = QStatus.XML_INVALID_INTERFACE_NAME;
pub const ER_XML_INVALID_MEMBER_NAME = QStatus.XML_INVALID_MEMBER_NAME;
pub const ER_XML_INVALID_MANIFEST_VERSION = QStatus.XML_INVALID_MANIFEST_VERSION;
pub const ER_XML_INVALID_OID = QStatus.XML_INVALID_OID;
pub const ER_XML_INVALID_BASE64 = QStatus.XML_INVALID_BASE64;
pub const ER_XML_INTERFACE_NAME_NOT_UNIQUE = QStatus.XML_INTERFACE_NAME_NOT_UNIQUE;
pub const ER_XML_MEMBER_NAME_NOT_UNIQUE = QStatus.XML_MEMBER_NAME_NOT_UNIQUE;
pub const ER_XML_OBJECT_PATH_NOT_UNIQUE = QStatus.XML_OBJECT_PATH_NOT_UNIQUE;
pub const ER_XML_ANNOTATION_NOT_UNIQUE = QStatus.XML_ANNOTATION_NOT_UNIQUE;
pub const ER_NONE = QStatus.NONE;
pub const ER_BUS_ERRORS = QStatus.BUS_ERRORS;
pub const ER_BUS_READ_ERROR = QStatus.BUS_READ_ERROR;
pub const ER_BUS_WRITE_ERROR = QStatus.BUS_WRITE_ERROR;
pub const ER_BUS_BAD_VALUE_TYPE = QStatus.BUS_BAD_VALUE_TYPE;
pub const ER_BUS_BAD_HEADER_FIELD = QStatus.BUS_BAD_HEADER_FIELD;
pub const ER_BUS_BAD_SIGNATURE = QStatus.BUS_BAD_SIGNATURE;
pub const ER_BUS_BAD_OBJ_PATH = QStatus.BUS_BAD_OBJ_PATH;
pub const ER_BUS_BAD_MEMBER_NAME = QStatus.BUS_BAD_MEMBER_NAME;
pub const ER_BUS_BAD_INTERFACE_NAME = QStatus.BUS_BAD_INTERFACE_NAME;
pub const ER_BUS_BAD_ERROR_NAME = QStatus.BUS_BAD_ERROR_NAME;
pub const ER_BUS_BAD_BUS_NAME = QStatus.BUS_BAD_BUS_NAME;
pub const ER_BUS_NAME_TOO_LONG = QStatus.BUS_NAME_TOO_LONG;
pub const ER_BUS_BAD_LENGTH = QStatus.BUS_BAD_LENGTH;
pub const ER_BUS_BAD_VALUE = QStatus.BUS_BAD_VALUE;
pub const ER_BUS_BAD_HDR_FLAGS = QStatus.BUS_BAD_HDR_FLAGS;
pub const ER_BUS_BAD_BODY_LEN = QStatus.BUS_BAD_BODY_LEN;
pub const ER_BUS_BAD_HEADER_LEN = QStatus.BUS_BAD_HEADER_LEN;
pub const ER_BUS_UNKNOWN_SERIAL = QStatus.BUS_UNKNOWN_SERIAL;
pub const ER_BUS_UNKNOWN_PATH = QStatus.BUS_UNKNOWN_PATH;
pub const ER_BUS_UNKNOWN_INTERFACE = QStatus.BUS_UNKNOWN_INTERFACE;
pub const ER_BUS_ESTABLISH_FAILED = QStatus.BUS_ESTABLISH_FAILED;
pub const ER_BUS_UNEXPECTED_SIGNATURE = QStatus.BUS_UNEXPECTED_SIGNATURE;
pub const ER_BUS_INTERFACE_MISSING = QStatus.BUS_INTERFACE_MISSING;
pub const ER_BUS_PATH_MISSING = QStatus.BUS_PATH_MISSING;
pub const ER_BUS_MEMBER_MISSING = QStatus.BUS_MEMBER_MISSING;
pub const ER_BUS_REPLY_SERIAL_MISSING = QStatus.BUS_REPLY_SERIAL_MISSING;
pub const ER_BUS_ERROR_NAME_MISSING = QStatus.BUS_ERROR_NAME_MISSING;
pub const ER_BUS_INTERFACE_NO_SUCH_MEMBER = QStatus.BUS_INTERFACE_NO_SUCH_MEMBER;
pub const ER_BUS_NO_SUCH_OBJECT = QStatus.BUS_NO_SUCH_OBJECT;
pub const ER_BUS_OBJECT_NO_SUCH_MEMBER = QStatus.BUS_OBJECT_NO_SUCH_MEMBER;
pub const ER_BUS_OBJECT_NO_SUCH_INTERFACE = QStatus.BUS_OBJECT_NO_SUCH_INTERFACE;
pub const ER_BUS_NO_SUCH_INTERFACE = QStatus.BUS_NO_SUCH_INTERFACE;
pub const ER_BUS_MEMBER_NO_SUCH_SIGNATURE = QStatus.BUS_MEMBER_NO_SUCH_SIGNATURE;
pub const ER_BUS_NOT_NUL_TERMINATED = QStatus.BUS_NOT_NUL_TERMINATED;
pub const ER_BUS_NO_SUCH_PROPERTY = QStatus.BUS_NO_SUCH_PROPERTY;
pub const ER_BUS_SET_WRONG_SIGNATURE = QStatus.BUS_SET_WRONG_SIGNATURE;
pub const ER_BUS_PROPERTY_VALUE_NOT_SET = QStatus.BUS_PROPERTY_VALUE_NOT_SET;
pub const ER_BUS_PROPERTY_ACCESS_DENIED = QStatus.BUS_PROPERTY_ACCESS_DENIED;
pub const ER_BUS_NO_TRANSPORTS = QStatus.BUS_NO_TRANSPORTS;
pub const ER_BUS_BAD_TRANSPORT_ARGS = QStatus.BUS_BAD_TRANSPORT_ARGS;
pub const ER_BUS_NO_ROUTE = QStatus.BUS_NO_ROUTE;
pub const ER_BUS_NO_ENDPOINT = QStatus.BUS_NO_ENDPOINT;
pub const ER_BUS_BAD_SEND_PARAMETER = QStatus.BUS_BAD_SEND_PARAMETER;
pub const ER_BUS_UNMATCHED_REPLY_SERIAL = QStatus.BUS_UNMATCHED_REPLY_SERIAL;
pub const ER_BUS_BAD_SENDER_ID = QStatus.BUS_BAD_SENDER_ID;
pub const ER_BUS_TRANSPORT_NOT_STARTED = QStatus.BUS_TRANSPORT_NOT_STARTED;
pub const ER_BUS_EMPTY_MESSAGE = QStatus.BUS_EMPTY_MESSAGE;
pub const ER_BUS_NOT_OWNER = QStatus.BUS_NOT_OWNER;
pub const ER_BUS_SET_PROPERTY_REJECTED = QStatus.BUS_SET_PROPERTY_REJECTED;
pub const ER_BUS_CONNECT_FAILED = QStatus.BUS_CONNECT_FAILED;
pub const ER_BUS_REPLY_IS_ERROR_MESSAGE = QStatus.BUS_REPLY_IS_ERROR_MESSAGE;
pub const ER_BUS_NOT_AUTHENTICATING = QStatus.BUS_NOT_AUTHENTICATING;
pub const ER_BUS_NO_LISTENER = QStatus.BUS_NO_LISTENER;
pub const ER_BUS_NOT_ALLOWED = QStatus.BUS_NOT_ALLOWED;
pub const ER_BUS_WRITE_QUEUE_FULL = QStatus.BUS_WRITE_QUEUE_FULL;
pub const ER_BUS_ENDPOINT_CLOSING = QStatus.BUS_ENDPOINT_CLOSING;
pub const ER_BUS_INTERFACE_MISMATCH = QStatus.BUS_INTERFACE_MISMATCH;
pub const ER_BUS_MEMBER_ALREADY_EXISTS = QStatus.BUS_MEMBER_ALREADY_EXISTS;
pub const ER_BUS_PROPERTY_ALREADY_EXISTS = QStatus.BUS_PROPERTY_ALREADY_EXISTS;
pub const ER_BUS_IFACE_ALREADY_EXISTS = QStatus.BUS_IFACE_ALREADY_EXISTS;
pub const ER_BUS_ERROR_RESPONSE = QStatus.BUS_ERROR_RESPONSE;
pub const ER_BUS_BAD_XML = QStatus.BUS_BAD_XML;
pub const ER_BUS_BAD_CHILD_PATH = QStatus.BUS_BAD_CHILD_PATH;
pub const ER_BUS_OBJ_ALREADY_EXISTS = QStatus.BUS_OBJ_ALREADY_EXISTS;
pub const ER_BUS_OBJ_NOT_FOUND = QStatus.BUS_OBJ_NOT_FOUND;
pub const ER_BUS_CANNOT_EXPAND_MESSAGE = QStatus.BUS_CANNOT_EXPAND_MESSAGE;
pub const ER_BUS_NOT_COMPRESSED = QStatus.BUS_NOT_COMPRESSED;
pub const ER_BUS_ALREADY_CONNECTED = QStatus.BUS_ALREADY_CONNECTED;
pub const ER_BUS_NOT_CONNECTED = QStatus.BUS_NOT_CONNECTED;
pub const ER_BUS_ALREADY_LISTENING = QStatus.BUS_ALREADY_LISTENING;
pub const ER_BUS_KEY_UNAVAILABLE = QStatus.BUS_KEY_UNAVAILABLE;
pub const ER_BUS_TRUNCATED = QStatus.BUS_TRUNCATED;
pub const ER_BUS_KEY_STORE_NOT_LOADED = QStatus.BUS_KEY_STORE_NOT_LOADED;
pub const ER_BUS_NO_AUTHENTICATION_MECHANISM = QStatus.BUS_NO_AUTHENTICATION_MECHANISM;
pub const ER_BUS_BUS_ALREADY_STARTED = QStatus.BUS_BUS_ALREADY_STARTED;
pub const ER_BUS_BUS_NOT_STARTED = QStatus.BUS_BUS_NOT_STARTED;
pub const ER_BUS_KEYBLOB_OP_INVALID = QStatus.BUS_KEYBLOB_OP_INVALID;
pub const ER_BUS_INVALID_HEADER_CHECKSUM = QStatus.BUS_INVALID_HEADER_CHECKSUM;
pub const ER_BUS_MESSAGE_NOT_ENCRYPTED = QStatus.BUS_MESSAGE_NOT_ENCRYPTED;
pub const ER_BUS_INVALID_HEADER_SERIAL = QStatus.BUS_INVALID_HEADER_SERIAL;
pub const ER_BUS_TIME_TO_LIVE_EXPIRED = QStatus.BUS_TIME_TO_LIVE_EXPIRED;
pub const ER_BUS_HDR_EXPANSION_INVALID = QStatus.BUS_HDR_EXPANSION_INVALID;
pub const ER_BUS_MISSING_COMPRESSION_TOKEN = QStatus.BUS_MISSING_COMPRESSION_TOKEN;
pub const ER_BUS_NO_PEER_GUID = QStatus.BUS_NO_PEER_GUID;
pub const ER_BUS_MESSAGE_DECRYPTION_FAILED = QStatus.BUS_MESSAGE_DECRYPTION_FAILED;
pub const ER_BUS_SECURITY_FATAL = QStatus.BUS_SECURITY_FATAL;
pub const ER_BUS_KEY_EXPIRED = QStatus.BUS_KEY_EXPIRED;
pub const ER_BUS_CORRUPT_KEYSTORE = QStatus.BUS_CORRUPT_KEYSTORE;
pub const ER_BUS_NO_CALL_FOR_REPLY = QStatus.BUS_NO_CALL_FOR_REPLY;
pub const ER_BUS_NOT_A_COMPLETE_TYPE = QStatus.BUS_NOT_A_COMPLETE_TYPE;
pub const ER_BUS_POLICY_VIOLATION = QStatus.BUS_POLICY_VIOLATION;
pub const ER_BUS_NO_SUCH_SERVICE = QStatus.BUS_NO_SUCH_SERVICE;
pub const ER_BUS_TRANSPORT_NOT_AVAILABLE = QStatus.BUS_TRANSPORT_NOT_AVAILABLE;
pub const ER_BUS_INVALID_AUTH_MECHANISM = QStatus.BUS_INVALID_AUTH_MECHANISM;
pub const ER_BUS_KEYSTORE_VERSION_MISMATCH = QStatus.BUS_KEYSTORE_VERSION_MISMATCH;
pub const ER_BUS_BLOCKING_CALL_NOT_ALLOWED = QStatus.BUS_BLOCKING_CALL_NOT_ALLOWED;
pub const ER_BUS_SIGNATURE_MISMATCH = QStatus.BUS_SIGNATURE_MISMATCH;
pub const ER_BUS_STOPPING = QStatus.BUS_STOPPING;
pub const ER_BUS_METHOD_CALL_ABORTED = QStatus.BUS_METHOD_CALL_ABORTED;
pub const ER_BUS_CANNOT_ADD_INTERFACE = QStatus.BUS_CANNOT_ADD_INTERFACE;
pub const ER_BUS_CANNOT_ADD_HANDLER = QStatus.BUS_CANNOT_ADD_HANDLER;
pub const ER_BUS_KEYSTORE_NOT_LOADED = QStatus.BUS_KEYSTORE_NOT_LOADED;
pub const ER_BUS_NO_SUCH_HANDLE = QStatus.BUS_NO_SUCH_HANDLE;
pub const ER_BUS_HANDLES_NOT_ENABLED = QStatus.BUS_HANDLES_NOT_ENABLED;
pub const ER_BUS_HANDLES_MISMATCH = QStatus.BUS_HANDLES_MISMATCH;
pub const ER_BUS_NO_SESSION = QStatus.BUS_NO_SESSION;
pub const ER_BUS_ELEMENT_NOT_FOUND = QStatus.BUS_ELEMENT_NOT_FOUND;
pub const ER_BUS_NOT_A_DICTIONARY = QStatus.BUS_NOT_A_DICTIONARY;
pub const ER_BUS_WAIT_FAILED = QStatus.BUS_WAIT_FAILED;
pub const ER_BUS_BAD_SESSION_OPTS = QStatus.BUS_BAD_SESSION_OPTS;
pub const ER_BUS_CONNECTION_REJECTED = QStatus.BUS_CONNECTION_REJECTED;
pub const ER_DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER = QStatus.DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER;
pub const ER_DBUS_REQUEST_NAME_REPLY_IN_QUEUE = QStatus.DBUS_REQUEST_NAME_REPLY_IN_QUEUE;
pub const ER_DBUS_REQUEST_NAME_REPLY_EXISTS = QStatus.DBUS_REQUEST_NAME_REPLY_EXISTS;
pub const ER_DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER = QStatus.DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER;
pub const ER_DBUS_RELEASE_NAME_REPLY_RELEASED = QStatus.DBUS_RELEASE_NAME_REPLY_RELEASED;
pub const ER_DBUS_RELEASE_NAME_REPLY_NON_EXISTENT = QStatus.DBUS_RELEASE_NAME_REPLY_NON_EXISTENT;
pub const ER_DBUS_RELEASE_NAME_REPLY_NOT_OWNER = QStatus.DBUS_RELEASE_NAME_REPLY_NOT_OWNER;
pub const ER_DBUS_START_REPLY_ALREADY_RUNNING = QStatus.DBUS_START_REPLY_ALREADY_RUNNING;
pub const ER_ALLJOYN_BINDSESSIONPORT_REPLY_ALREADY_EXISTS = QStatus.ALLJOYN_BINDSESSIONPORT_REPLY_ALREADY_EXISTS;
pub const ER_ALLJOYN_BINDSESSIONPORT_REPLY_FAILED = QStatus.ALLJOYN_BINDSESSIONPORT_REPLY_FAILED;
pub const ER_ALLJOYN_JOINSESSION_REPLY_NO_SESSION = QStatus.ALLJOYN_JOINSESSION_REPLY_NO_SESSION;
pub const ER_ALLJOYN_JOINSESSION_REPLY_UNREACHABLE = QStatus.ALLJOYN_JOINSESSION_REPLY_UNREACHABLE;
pub const ER_ALLJOYN_JOINSESSION_REPLY_CONNECT_FAILED = QStatus.ALLJOYN_JOINSESSION_REPLY_CONNECT_FAILED;
pub const ER_ALLJOYN_JOINSESSION_REPLY_REJECTED = QStatus.ALLJOYN_JOINSESSION_REPLY_REJECTED;
pub const ER_ALLJOYN_JOINSESSION_REPLY_BAD_SESSION_OPTS = QStatus.ALLJOYN_JOINSESSION_REPLY_BAD_SESSION_OPTS;
pub const ER_ALLJOYN_JOINSESSION_REPLY_FAILED = QStatus.ALLJOYN_JOINSESSION_REPLY_FAILED;
pub const ER_ALLJOYN_LEAVESESSION_REPLY_NO_SESSION = QStatus.ALLJOYN_LEAVESESSION_REPLY_NO_SESSION;
pub const ER_ALLJOYN_LEAVESESSION_REPLY_FAILED = QStatus.ALLJOYN_LEAVESESSION_REPLY_FAILED;
pub const ER_ALLJOYN_ADVERTISENAME_REPLY_TRANSPORT_NOT_AVAILABLE = QStatus.ALLJOYN_ADVERTISENAME_REPLY_TRANSPORT_NOT_AVAILABLE;
pub const ER_ALLJOYN_ADVERTISENAME_REPLY_ALREADY_ADVERTISING = QStatus.ALLJOYN_ADVERTISENAME_REPLY_ALREADY_ADVERTISING;
pub const ER_ALLJOYN_ADVERTISENAME_REPLY_FAILED = QStatus.ALLJOYN_ADVERTISENAME_REPLY_FAILED;
pub const ER_ALLJOYN_CANCELADVERTISENAME_REPLY_FAILED = QStatus.ALLJOYN_CANCELADVERTISENAME_REPLY_FAILED;
pub const ER_ALLJOYN_FINDADVERTISEDNAME_REPLY_TRANSPORT_NOT_AVAILABLE = QStatus.ALLJOYN_FINDADVERTISEDNAME_REPLY_TRANSPORT_NOT_AVAILABLE;
pub const ER_ALLJOYN_FINDADVERTISEDNAME_REPLY_ALREADY_DISCOVERING = QStatus.ALLJOYN_FINDADVERTISEDNAME_REPLY_ALREADY_DISCOVERING;
pub const ER_ALLJOYN_FINDADVERTISEDNAME_REPLY_FAILED = QStatus.ALLJOYN_FINDADVERTISEDNAME_REPLY_FAILED;
pub const ER_ALLJOYN_CANCELFINDADVERTISEDNAME_REPLY_FAILED = QStatus.ALLJOYN_CANCELFINDADVERTISEDNAME_REPLY_FAILED;
pub const ER_BUS_UNEXPECTED_DISPOSITION = QStatus.BUS_UNEXPECTED_DISPOSITION;
pub const ER_BUS_INTERFACE_ACTIVATED = QStatus.BUS_INTERFACE_ACTIVATED;
pub const ER_ALLJOYN_UNBINDSESSIONPORT_REPLY_BAD_PORT = QStatus.ALLJOYN_UNBINDSESSIONPORT_REPLY_BAD_PORT;
pub const ER_ALLJOYN_UNBINDSESSIONPORT_REPLY_FAILED = QStatus.ALLJOYN_UNBINDSESSIONPORT_REPLY_FAILED;
pub const ER_ALLJOYN_BINDSESSIONPORT_REPLY_INVALID_OPTS = QStatus.ALLJOYN_BINDSESSIONPORT_REPLY_INVALID_OPTS;
pub const ER_ALLJOYN_JOINSESSION_REPLY_ALREADY_JOINED = QStatus.ALLJOYN_JOINSESSION_REPLY_ALREADY_JOINED;
pub const ER_BUS_SELF_CONNECT = QStatus.BUS_SELF_CONNECT;
pub const ER_BUS_SECURITY_NOT_ENABLED = QStatus.BUS_SECURITY_NOT_ENABLED;
pub const ER_BUS_LISTENER_ALREADY_SET = QStatus.BUS_LISTENER_ALREADY_SET;
pub const ER_BUS_PEER_AUTH_VERSION_MISMATCH = QStatus.BUS_PEER_AUTH_VERSION_MISMATCH;
pub const ER_ALLJOYN_SETLINKTIMEOUT_REPLY_NOT_SUPPORTED = QStatus.ALLJOYN_SETLINKTIMEOUT_REPLY_NOT_SUPPORTED;
pub const ER_ALLJOYN_SETLINKTIMEOUT_REPLY_NO_DEST_SUPPORT = QStatus.ALLJOYN_SETLINKTIMEOUT_REPLY_NO_DEST_SUPPORT;
pub const ER_ALLJOYN_SETLINKTIMEOUT_REPLY_FAILED = QStatus.ALLJOYN_SETLINKTIMEOUT_REPLY_FAILED;
pub const ER_ALLJOYN_ACCESS_PERMISSION_WARNING = QStatus.ALLJOYN_ACCESS_PERMISSION_WARNING;
pub const ER_ALLJOYN_ACCESS_PERMISSION_ERROR = QStatus.ALLJOYN_ACCESS_PERMISSION_ERROR;
pub const ER_BUS_DESTINATION_NOT_AUTHENTICATED = QStatus.BUS_DESTINATION_NOT_AUTHENTICATED;
pub const ER_BUS_ENDPOINT_REDIRECTED = QStatus.BUS_ENDPOINT_REDIRECTED;
pub const ER_BUS_AUTHENTICATION_PENDING = QStatus.BUS_AUTHENTICATION_PENDING;
pub const ER_BUS_NOT_AUTHORIZED = QStatus.BUS_NOT_AUTHORIZED;
pub const ER_PACKET_BUS_NO_SUCH_CHANNEL = QStatus.PACKET_BUS_NO_SUCH_CHANNEL;
pub const ER_PACKET_BAD_FORMAT = QStatus.PACKET_BAD_FORMAT;
pub const ER_PACKET_CONNECT_TIMEOUT = QStatus.PACKET_CONNECT_TIMEOUT;
pub const ER_PACKET_CHANNEL_FAIL = QStatus.PACKET_CHANNEL_FAIL;
pub const ER_PACKET_TOO_LARGE = QStatus.PACKET_TOO_LARGE;
pub const ER_PACKET_BAD_PARAMETER = QStatus.PACKET_BAD_PARAMETER;
pub const ER_PACKET_BAD_CRC = QStatus.PACKET_BAD_CRC;
pub const ER_RENDEZVOUS_SERVER_DEACTIVATED_USER = QStatus.RENDEZVOUS_SERVER_DEACTIVATED_USER;
pub const ER_RENDEZVOUS_SERVER_UNKNOWN_USER = QStatus.RENDEZVOUS_SERVER_UNKNOWN_USER;
pub const ER_UNABLE_TO_CONNECT_TO_RENDEZVOUS_SERVER = QStatus.UNABLE_TO_CONNECT_TO_RENDEZVOUS_SERVER;
pub const ER_NOT_CONNECTED_TO_RENDEZVOUS_SERVER = QStatus.NOT_CONNECTED_TO_RENDEZVOUS_SERVER;
pub const ER_UNABLE_TO_SEND_MESSAGE_TO_RENDEZVOUS_SERVER = QStatus.UNABLE_TO_SEND_MESSAGE_TO_RENDEZVOUS_SERVER;
pub const ER_INVALID_RENDEZVOUS_SERVER_INTERFACE_MESSAGE = QStatus.INVALID_RENDEZVOUS_SERVER_INTERFACE_MESSAGE;
pub const ER_INVALID_PERSISTENT_CONNECTION_MESSAGE_RESPONSE = QStatus.INVALID_PERSISTENT_CONNECTION_MESSAGE_RESPONSE;
pub const ER_INVALID_ON_DEMAND_CONNECTION_MESSAGE_RESPONSE = QStatus.INVALID_ON_DEMAND_CONNECTION_MESSAGE_RESPONSE;
pub const ER_INVALID_HTTP_METHOD_USED_FOR_RENDEZVOUS_SERVER_INTERFACE_MESSAGE = QStatus.INVALID_HTTP_METHOD_USED_FOR_RENDEZVOUS_SERVER_INTERFACE_MESSAGE;
pub const ER_RENDEZVOUS_SERVER_ERR500_INTERNAL_ERROR = QStatus.RENDEZVOUS_SERVER_ERR500_INTERNAL_ERROR;
pub const ER_RENDEZVOUS_SERVER_ERR503_STATUS_UNAVAILABLE = QStatus.RENDEZVOUS_SERVER_ERR503_STATUS_UNAVAILABLE;
pub const ER_RENDEZVOUS_SERVER_ERR401_UNAUTHORIZED_REQUEST = QStatus.RENDEZVOUS_SERVER_ERR401_UNAUTHORIZED_REQUEST;
pub const ER_RENDEZVOUS_SERVER_UNRECOVERABLE_ERROR = QStatus.RENDEZVOUS_SERVER_UNRECOVERABLE_ERROR;
pub const ER_RENDEZVOUS_SERVER_ROOT_CERTIFICATE_UNINITIALIZED = QStatus.RENDEZVOUS_SERVER_ROOT_CERTIFICATE_UNINITIALIZED;
pub const ER_BUS_NO_SUCH_ANNOTATION = QStatus.BUS_NO_SUCH_ANNOTATION;
pub const ER_BUS_ANNOTATION_ALREADY_EXISTS = QStatus.BUS_ANNOTATION_ALREADY_EXISTS;
pub const ER_SOCK_CLOSING = QStatus.SOCK_CLOSING;
pub const ER_NO_SUCH_DEVICE = QStatus.NO_SUCH_DEVICE;
pub const ER_P2P = QStatus.P2P;
pub const ER_P2P_TIMEOUT = QStatus.P2P_TIMEOUT;
pub const ER_P2P_NOT_CONNECTED = QStatus.P2P_NOT_CONNECTED;
pub const ER_BAD_TRANSPORT_MASK = QStatus.BAD_TRANSPORT_MASK;
pub const ER_PROXIMITY_CONNECTION_ESTABLISH_FAIL = QStatus.PROXIMITY_CONNECTION_ESTABLISH_FAIL;
pub const ER_PROXIMITY_NO_PEERS_FOUND = QStatus.PROXIMITY_NO_PEERS_FOUND;
pub const ER_BUS_OBJECT_NOT_REGISTERED = QStatus.BUS_OBJECT_NOT_REGISTERED;
pub const ER_P2P_DISABLED = QStatus.P2P_DISABLED;
pub const ER_P2P_BUSY = QStatus.P2P_BUSY;
pub const ER_BUS_INCOMPATIBLE_DAEMON = QStatus.BUS_INCOMPATIBLE_DAEMON;
pub const ER_P2P_NO_GO = QStatus.P2P_NO_GO;
pub const ER_P2P_NO_STA = QStatus.P2P_NO_STA;
pub const ER_P2P_FORBIDDEN = QStatus.P2P_FORBIDDEN;
pub const ER_ALLJOYN_ONAPPSUSPEND_REPLY_FAILED = QStatus.ALLJOYN_ONAPPSUSPEND_REPLY_FAILED;
pub const ER_ALLJOYN_ONAPPSUSPEND_REPLY_UNSUPPORTED = QStatus.ALLJOYN_ONAPPSUSPEND_REPLY_UNSUPPORTED;
pub const ER_ALLJOYN_ONAPPRESUME_REPLY_FAILED = QStatus.ALLJOYN_ONAPPRESUME_REPLY_FAILED;
pub const ER_ALLJOYN_ONAPPRESUME_REPLY_UNSUPPORTED = QStatus.ALLJOYN_ONAPPRESUME_REPLY_UNSUPPORTED;
pub const ER_BUS_NO_SUCH_MESSAGE = QStatus.BUS_NO_SUCH_MESSAGE;
pub const ER_ALLJOYN_REMOVESESSIONMEMBER_REPLY_NO_SESSION = QStatus.ALLJOYN_REMOVESESSIONMEMBER_REPLY_NO_SESSION;
pub const ER_ALLJOYN_REMOVESESSIONMEMBER_NOT_BINDER = QStatus.ALLJOYN_REMOVESESSIONMEMBER_NOT_BINDER;
pub const ER_ALLJOYN_REMOVESESSIONMEMBER_NOT_MULTIPOINT = QStatus.ALLJOYN_REMOVESESSIONMEMBER_NOT_MULTIPOINT;
pub const ER_ALLJOYN_REMOVESESSIONMEMBER_NOT_FOUND = QStatus.ALLJOYN_REMOVESESSIONMEMBER_NOT_FOUND;
pub const ER_ALLJOYN_REMOVESESSIONMEMBER_INCOMPATIBLE_REMOTE_DAEMON = QStatus.ALLJOYN_REMOVESESSIONMEMBER_INCOMPATIBLE_REMOTE_DAEMON;
pub const ER_ALLJOYN_REMOVESESSIONMEMBER_REPLY_FAILED = QStatus.ALLJOYN_REMOVESESSIONMEMBER_REPLY_FAILED;
pub const ER_BUS_REMOVED_BY_BINDER = QStatus.BUS_REMOVED_BY_BINDER;
pub const ER_BUS_MATCH_RULE_NOT_FOUND = QStatus.BUS_MATCH_RULE_NOT_FOUND;
pub const ER_ALLJOYN_PING_FAILED = QStatus.ALLJOYN_PING_FAILED;
pub const ER_ALLJOYN_PING_REPLY_UNREACHABLE = QStatus.ALLJOYN_PING_REPLY_UNREACHABLE;
pub const ER_UDP_MSG_TOO_LONG = QStatus.UDP_MSG_TOO_LONG;
pub const ER_UDP_DEMUX_NO_ENDPOINT = QStatus.UDP_DEMUX_NO_ENDPOINT;
pub const ER_UDP_NO_NETWORK = QStatus.UDP_NO_NETWORK;
pub const ER_UDP_UNEXPECTED_LENGTH = QStatus.UDP_UNEXPECTED_LENGTH;
pub const ER_UDP_UNEXPECTED_FLOW = QStatus.UDP_UNEXPECTED_FLOW;
pub const ER_UDP_DISCONNECT = QStatus.UDP_DISCONNECT;
pub const ER_UDP_NOT_IMPLEMENTED = QStatus.UDP_NOT_IMPLEMENTED;
pub const ER_UDP_NO_LISTENER = QStatus.UDP_NO_LISTENER;
pub const ER_UDP_STOPPING = QStatus.UDP_STOPPING;
pub const ER_ARDP_BACKPRESSURE = QStatus.ARDP_BACKPRESSURE;
pub const ER_UDP_BACKPRESSURE = QStatus.UDP_BACKPRESSURE;
pub const ER_ARDP_INVALID_STATE = QStatus.ARDP_INVALID_STATE;
pub const ER_ARDP_TTL_EXPIRED = QStatus.ARDP_TTL_EXPIRED;
pub const ER_ARDP_PERSIST_TIMEOUT = QStatus.ARDP_PERSIST_TIMEOUT;
pub const ER_ARDP_PROBE_TIMEOUT = QStatus.ARDP_PROBE_TIMEOUT;
pub const ER_ARDP_REMOTE_CONNECTION_RESET = QStatus.ARDP_REMOTE_CONNECTION_RESET;
pub const ER_UDP_BUSHELLO = QStatus.UDP_BUSHELLO;
pub const ER_UDP_MESSAGE = QStatus.UDP_MESSAGE;
pub const ER_UDP_INVALID = QStatus.UDP_INVALID;
pub const ER_UDP_UNSUPPORTED = QStatus.UDP_UNSUPPORTED;
pub const ER_UDP_ENDPOINT_STALLED = QStatus.UDP_ENDPOINT_STALLED;
pub const ER_ARDP_INVALID_RESPONSE = QStatus.ARDP_INVALID_RESPONSE;
pub const ER_ARDP_INVALID_CONNECTION = QStatus.ARDP_INVALID_CONNECTION;
pub const ER_UDP_LOCAL_DISCONNECT = QStatus.UDP_LOCAL_DISCONNECT;
pub const ER_UDP_EARLY_EXIT = QStatus.UDP_EARLY_EXIT;
pub const ER_UDP_LOCAL_DISCONNECT_FAIL = QStatus.UDP_LOCAL_DISCONNECT_FAIL;
pub const ER_ARDP_DISCONNECTING = QStatus.ARDP_DISCONNECTING;
pub const ER_ALLJOYN_PING_REPLY_INCOMPATIBLE_REMOTE_ROUTING_NODE = QStatus.ALLJOYN_PING_REPLY_INCOMPATIBLE_REMOTE_ROUTING_NODE;
pub const ER_ALLJOYN_PING_REPLY_TIMEOUT = QStatus.ALLJOYN_PING_REPLY_TIMEOUT;
pub const ER_ALLJOYN_PING_REPLY_UNKNOWN_NAME = QStatus.ALLJOYN_PING_REPLY_UNKNOWN_NAME;
pub const ER_ALLJOYN_PING_REPLY_FAILED = QStatus.ALLJOYN_PING_REPLY_FAILED;
pub const ER_TCP_MAX_UNTRUSTED = QStatus.TCP_MAX_UNTRUSTED;
pub const ER_ALLJOYN_PING_REPLY_IN_PROGRESS = QStatus.ALLJOYN_PING_REPLY_IN_PROGRESS;
pub const ER_LANGUAGE_NOT_SUPPORTED = QStatus.LANGUAGE_NOT_SUPPORTED;
pub const ER_ABOUT_FIELD_ALREADY_SPECIFIED = QStatus.ABOUT_FIELD_ALREADY_SPECIFIED;
pub const ER_UDP_NOT_DISCONNECTED = QStatus.UDP_NOT_DISCONNECTED;
pub const ER_UDP_ENDPOINT_NOT_STARTED = QStatus.UDP_ENDPOINT_NOT_STARTED;
pub const ER_UDP_ENDPOINT_REMOVED = QStatus.UDP_ENDPOINT_REMOVED;
pub const ER_ARDP_VERSION_NOT_SUPPORTED = QStatus.ARDP_VERSION_NOT_SUPPORTED;
pub const ER_CONNECTION_LIMIT_EXCEEDED = QStatus.CONNECTION_LIMIT_EXCEEDED;
pub const ER_ARDP_WRITE_BLOCKED = QStatus.ARDP_WRITE_BLOCKED;
pub const ER_PERMISSION_DENIED = QStatus.PERMISSION_DENIED;
pub const ER_ABOUT_DEFAULT_LANGUAGE_NOT_SPECIFIED = QStatus.ABOUT_DEFAULT_LANGUAGE_NOT_SPECIFIED;
pub const ER_ABOUT_SESSIONPORT_NOT_BOUND = QStatus.ABOUT_SESSIONPORT_NOT_BOUND;
pub const ER_ABOUT_ABOUTDATA_MISSING_REQUIRED_FIELD = QStatus.ABOUT_ABOUTDATA_MISSING_REQUIRED_FIELD;
pub const ER_ABOUT_INVALID_ABOUTDATA_LISTENER = QStatus.ABOUT_INVALID_ABOUTDATA_LISTENER;
pub const ER_BUS_PING_GROUP_NOT_FOUND = QStatus.BUS_PING_GROUP_NOT_FOUND;
pub const ER_BUS_REMOVED_BY_BINDER_SELF = QStatus.BUS_REMOVED_BY_BINDER_SELF;
pub const ER_INVALID_CONFIG = QStatus.INVALID_CONFIG;
pub const ER_ABOUT_INVALID_ABOUTDATA_FIELD_VALUE = QStatus.ABOUT_INVALID_ABOUTDATA_FIELD_VALUE;
pub const ER_ABOUT_INVALID_ABOUTDATA_FIELD_APPID_SIZE = QStatus.ABOUT_INVALID_ABOUTDATA_FIELD_APPID_SIZE;
pub const ER_BUS_TRANSPORT_ACCESS_DENIED = QStatus.BUS_TRANSPORT_ACCESS_DENIED;
pub const ER_INVALID_CERTIFICATE = QStatus.INVALID_CERTIFICATE;
pub const ER_CERTIFICATE_NOT_FOUND = QStatus.CERTIFICATE_NOT_FOUND;
pub const ER_DUPLICATE_CERTIFICATE = QStatus.DUPLICATE_CERTIFICATE;
pub const ER_UNKNOWN_CERTIFICATE = QStatus.UNKNOWN_CERTIFICATE;
pub const ER_MISSING_DIGEST_IN_CERTIFICATE = QStatus.MISSING_DIGEST_IN_CERTIFICATE;
pub const ER_DIGEST_MISMATCH = QStatus.DIGEST_MISMATCH;
pub const ER_DUPLICATE_KEY = QStatus.DUPLICATE_KEY;
pub const ER_NO_COMMON_TRUST = QStatus.NO_COMMON_TRUST;
pub const ER_MANIFEST_NOT_FOUND = QStatus.MANIFEST_NOT_FOUND;
pub const ER_INVALID_CERT_CHAIN = QStatus.INVALID_CERT_CHAIN;
pub const ER_NO_TRUST_ANCHOR = QStatus.NO_TRUST_ANCHOR;
pub const ER_INVALID_APPLICATION_STATE = QStatus.INVALID_APPLICATION_STATE;
pub const ER_FEATURE_NOT_AVAILABLE = QStatus.FEATURE_NOT_AVAILABLE;
pub const ER_KEY_STORE_ALREADY_INITIALIZED = QStatus.KEY_STORE_ALREADY_INITIALIZED;
pub const ER_KEY_STORE_ID_NOT_YET_SET = QStatus.KEY_STORE_ID_NOT_YET_SET;
pub const ER_POLICY_NOT_NEWER = QStatus.POLICY_NOT_NEWER;
pub const ER_MANIFEST_REJECTED = QStatus.MANIFEST_REJECTED;
pub const ER_INVALID_CERTIFICATE_USAGE = QStatus.INVALID_CERTIFICATE_USAGE;
pub const ER_INVALID_SIGNAL_EMISSION_TYPE = QStatus.INVALID_SIGNAL_EMISSION_TYPE;
pub const ER_APPLICATION_STATE_LISTENER_ALREADY_EXISTS = QStatus.APPLICATION_STATE_LISTENER_ALREADY_EXISTS;
pub const ER_APPLICATION_STATE_LISTENER_NO_SUCH_LISTENER = QStatus.APPLICATION_STATE_LISTENER_NO_SUCH_LISTENER;
pub const ER_MANAGEMENT_ALREADY_STARTED = QStatus.MANAGEMENT_ALREADY_STARTED;
pub const ER_MANAGEMENT_NOT_STARTED = QStatus.MANAGEMENT_NOT_STARTED;
pub const ER_BUS_DESCRIPTION_ALREADY_EXISTS = QStatus.BUS_DESCRIPTION_ALREADY_EXISTS;
pub const alljoyn_typeid = enum(i32) {
INVALID = 0,
ARRAY = 97,
BOOLEAN = 98,
DOUBLE = 100,
DICT_ENTRY = 101,
SIGNATURE = 103,
HANDLE = 104,
INT32 = 105,
INT16 = 110,
OBJECT_PATH = 111,
UINT16 = 113,
STRUCT = 114,
STRING = 115,
UINT64 = 116,
UINT32 = 117,
VARIANT = 118,
INT64 = 120,
BYTE = 121,
STRUCT_OPEN = 40,
STRUCT_CLOSE = 41,
DICT_ENTRY_OPEN = 123,
DICT_ENTRY_CLOSE = 125,
BOOLEAN_ARRAY = 25185,
DOUBLE_ARRAY = 25697,
INT32_ARRAY = 26977,
INT16_ARRAY = 28257,
UINT16_ARRAY = 29025,
UINT64_ARRAY = 29793,
UINT32_ARRAY = 30049,
INT64_ARRAY = 30817,
BYTE_ARRAY = 31073,
WILDCARD = 42,
};
pub const ALLJOYN_INVALID = alljoyn_typeid.INVALID;
pub const ALLJOYN_ARRAY = alljoyn_typeid.ARRAY;
pub const ALLJOYN_BOOLEAN = alljoyn_typeid.BOOLEAN;
pub const ALLJOYN_DOUBLE = alljoyn_typeid.DOUBLE;
pub const ALLJOYN_DICT_ENTRY = alljoyn_typeid.DICT_ENTRY;
pub const ALLJOYN_SIGNATURE = alljoyn_typeid.SIGNATURE;
pub const ALLJOYN_HANDLE = alljoyn_typeid.HANDLE;
pub const ALLJOYN_INT32 = alljoyn_typeid.INT32;
pub const ALLJOYN_INT16 = alljoyn_typeid.INT16;
pub const ALLJOYN_OBJECT_PATH = alljoyn_typeid.OBJECT_PATH;
pub const ALLJOYN_UINT16 = alljoyn_typeid.UINT16;
pub const ALLJOYN_STRUCT = alljoyn_typeid.STRUCT;
pub const ALLJOYN_STRING = alljoyn_typeid.STRING;
pub const ALLJOYN_UINT64 = alljoyn_typeid.UINT64;
pub const ALLJOYN_UINT32 = alljoyn_typeid.UINT32;
pub const ALLJOYN_VARIANT = alljoyn_typeid.VARIANT;
pub const ALLJOYN_INT64 = alljoyn_typeid.INT64;
pub const ALLJOYN_BYTE = alljoyn_typeid.BYTE;
pub const ALLJOYN_STRUCT_OPEN = alljoyn_typeid.STRUCT_OPEN;
pub const ALLJOYN_STRUCT_CLOSE = alljoyn_typeid.STRUCT_CLOSE;
pub const ALLJOYN_DICT_ENTRY_OPEN = alljoyn_typeid.DICT_ENTRY_OPEN;
pub const ALLJOYN_DICT_ENTRY_CLOSE = alljoyn_typeid.DICT_ENTRY_CLOSE;
pub const ALLJOYN_BOOLEAN_ARRAY = alljoyn_typeid.BOOLEAN_ARRAY;
pub const ALLJOYN_DOUBLE_ARRAY = alljoyn_typeid.DOUBLE_ARRAY;
pub const ALLJOYN_INT32_ARRAY = alljoyn_typeid.INT32_ARRAY;
pub const ALLJOYN_INT16_ARRAY = alljoyn_typeid.INT16_ARRAY;
pub const ALLJOYN_UINT16_ARRAY = alljoyn_typeid.UINT16_ARRAY;
pub const ALLJOYN_UINT64_ARRAY = alljoyn_typeid.UINT64_ARRAY;
pub const ALLJOYN_UINT32_ARRAY = alljoyn_typeid.UINT32_ARRAY;
pub const ALLJOYN_INT64_ARRAY = alljoyn_typeid.INT64_ARRAY;
pub const ALLJOYN_BYTE_ARRAY = alljoyn_typeid.BYTE_ARRAY;
pub const ALLJOYN_WILDCARD = alljoyn_typeid.WILDCARD;
pub const _alljoyn_abouticon_handle = extern struct {
placeholder: usize, // TODO: why is this type empty?
};
pub const alljoyn_applicationstate = enum(i32) {
NOT_CLAIMABLE = 0,
CLAIMABLE = 1,
CLAIMED = 2,
NEED_UPDATE = 3,
};
pub const NOT_CLAIMABLE = alljoyn_applicationstate.NOT_CLAIMABLE;
pub const CLAIMABLE = alljoyn_applicationstate.CLAIMABLE;
pub const CLAIMED = alljoyn_applicationstate.CLAIMED;
pub const NEED_UPDATE = alljoyn_applicationstate.NEED_UPDATE;
pub const alljoyn_claimcapability_masks = enum(i32) {
NULL = 1,
ECDSA = 4,
SPEKE = 8,
};
pub const CAPABLE_ECDHE_NULL = alljoyn_claimcapability_masks.NULL;
pub const CAPABLE_ECDHE_ECDSA = alljoyn_claimcapability_masks.ECDSA;
pub const CAPABLE_ECDHE_SPEKE = alljoyn_claimcapability_masks.SPEKE;
pub const alljoyn_claimcapabilityadditionalinfo_masks = enum(i32) {
SECURITY_MANAGER = 1,
APPLICATION = 2,
};
pub const PASSWORD_GENERATED_BY_SECURITY_MANAGER = alljoyn_claimcapabilityadditionalinfo_masks.SECURITY_MANAGER;
pub const PASSWORD_GENERATED_BY_APPLICATION = alljoyn_claimcapabilityadditionalinfo_masks.APPLICATION;
pub const alljoyn_certificateid = extern struct {
serial: ?*u8,
serialLen: usize,
issuerPublicKey: ?*i8,
issuerAki: ?*u8,
issuerAkiLen: usize,
};
pub const alljoyn_certificateidarray = extern struct {
count: usize,
ids: ?*alljoyn_certificateid,
};
pub const alljoyn_manifestarray = extern struct {
count: usize,
xmls: ?*?*i8,
};
pub const alljoyn_applicationstatelistener_state_ptr = fn(
busName: ?*i8,
publicKey: ?*i8,
applicationState: alljoyn_applicationstate,
context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_applicationstatelistener_callbacks = extern struct {
state: ?alljoyn_applicationstatelistener_state_ptr,
};
pub const alljoyn_keystorelistener_loadrequest_ptr = fn(
context: ?*const anyopaque,
listener: alljoyn_keystorelistener,
keyStore: alljoyn_keystore,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub const alljoyn_keystorelistener_storerequest_ptr = fn(
context: ?*const anyopaque,
listener: alljoyn_keystorelistener,
keyStore: alljoyn_keystore,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub const alljoyn_keystorelistener_acquireexclusivelock_ptr = fn(
context: ?*const anyopaque,
listener: alljoyn_keystorelistener,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub const alljoyn_keystorelistener_releaseexclusivelock_ptr = fn(
context: ?*const anyopaque,
listener: alljoyn_keystorelistener,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_keystorelistener_callbacks = extern struct {
load_request: ?alljoyn_keystorelistener_loadrequest_ptr,
store_request: ?alljoyn_keystorelistener_storerequest_ptr,
};
pub const alljoyn_keystorelistener_with_synchronization_callbacks = extern struct {
load_request: ?alljoyn_keystorelistener_loadrequest_ptr,
store_request: ?alljoyn_keystorelistener_storerequest_ptr,
acquire_exclusive_lock: ?alljoyn_keystorelistener_acquireexclusivelock_ptr,
release_exclusive_lock: ?alljoyn_keystorelistener_releaseexclusivelock_ptr,
};
pub const alljoyn_messagetype = enum(i32) {
INVALID = 0,
METHOD_CALL = 1,
METHOD_RET = 2,
ERROR = 3,
SIGNAL = 4,
};
pub const ALLJOYN_MESSAGE_INVALID = alljoyn_messagetype.INVALID;
pub const ALLJOYN_MESSAGE_METHOD_CALL = alljoyn_messagetype.METHOD_CALL;
pub const ALLJOYN_MESSAGE_METHOD_RET = alljoyn_messagetype.METHOD_RET;
pub const ALLJOYN_MESSAGE_ERROR = alljoyn_messagetype.ERROR;
pub const ALLJOYN_MESSAGE_SIGNAL = alljoyn_messagetype.SIGNAL;
pub const alljoyn_authlistener_requestcredentials_ptr = fn(
context: ?*const anyopaque,
authMechanism: ?[*:0]const u8,
peerName: ?[*:0]const u8,
authCount: u16,
userName: ?[*:0]const u8,
credMask: u16,
credentials: alljoyn_credentials,
) callconv(@import("std").os.windows.WINAPI) i32;
pub const alljoyn_authlistener_requestcredentialsasync_ptr = fn(
context: ?*const anyopaque,
listener: alljoyn_authlistener,
authMechanism: ?[*:0]const u8,
peerName: ?[*:0]const u8,
authCount: u16,
userName: ?[*:0]const u8,
credMask: u16,
authContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub const alljoyn_authlistener_verifycredentials_ptr = fn(
context: ?*const anyopaque,
authMechanism: ?[*:0]const u8,
peerName: ?[*:0]const u8,
credentials: alljoyn_credentials,
) callconv(@import("std").os.windows.WINAPI) i32;
pub const alljoyn_authlistener_verifycredentialsasync_ptr = fn(
context: ?*const anyopaque,
listener: alljoyn_authlistener,
authMechanism: ?[*:0]const u8,
peerName: ?[*:0]const u8,
credentials: <PASSWORD>_credentials,
authContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub const alljoyn_authlistener_securityviolation_ptr = fn(
context: ?*const anyopaque,
status: QStatus,
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_authlistener_authenticationcomplete_ptr = fn(
context: ?*const anyopaque,
authMechanism: ?[*:0]const u8,
peerName: ?[*:0]const u8,
success: i32,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_authlistener_callbacks = extern struct {
request_credentials: ?alljoyn_authlistener_requestcredentials_ptr,
verify_credentials: ?alljoyn_authlistener_verifycredentials_ptr,
security_violation: ?alljoyn_authlistener_securityviolation_ptr,
authentication_complete: ?alljoyn_authlistener_authenticationcomplete_ptr,
};
pub const alljoyn_authlistenerasync_callbacks = extern struct {
request_credentials: ?alljoyn_authlistener_requestcredentialsasync_ptr,
verify_credentials: ?alljoyn_authlistener_verifycredentialsasync_ptr,
security_violation: ?alljoyn_authlistener_securityviolation_ptr,
authentication_complete: ?alljoyn_authlistener_authenticationcomplete_ptr,
};
pub const alljoyn_buslistener_listener_registered_ptr = fn(
context: ?*const anyopaque,
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_buslistener_listener_unregistered_ptr = fn(
context: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_buslistener_found_advertised_name_ptr = fn(
context: ?*const anyopaque,
name: ?[*:0]const u8,
transport: u16,
namePrefix: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_buslistener_lost_advertised_name_ptr = fn(
context: ?*const anyopaque,
name: ?[*:0]const u8,
transport: u16,
namePrefix: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_buslistener_name_owner_changed_ptr = fn(
context: ?*const anyopaque,
busName: ?[*:0]const u8,
previousOwner: ?[*:0]const u8,
newOwner: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_buslistener_bus_stopping_ptr = fn(
context: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_buslistener_bus_disconnected_ptr = fn(
context: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_buslistener_bus_prop_changed_ptr = fn(
context: ?*const anyopaque,
prop_name: ?[*:0]const u8,
prop_value: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_buslistener_callbacks = extern struct {
listener_registered: ?alljoyn_buslistener_listener_registered_ptr,
listener_unregistered: ?alljoyn_buslistener_listener_unregistered_ptr,
found_advertised_name: ?alljoyn_buslistener_found_advertised_name_ptr,
lost_advertised_name: ?alljoyn_buslistener_lost_advertised_name_ptr,
name_owner_changed: ?alljoyn_buslistener_name_owner_changed_ptr,
bus_stopping: ?alljoyn_buslistener_bus_stopping_ptr,
bus_disconnected: ?alljoyn_buslistener_bus_disconnected_ptr,
property_changed: ?alljoyn_buslistener_bus_prop_changed_ptr,
};
pub const alljoyn_interfacedescription_securitypolicy = enum(i32) {
INHERIT = 0,
REQUIRED = 1,
OFF = 2,
};
pub const AJ_IFC_SECURITY_INHERIT = alljoyn_interfacedescription_securitypolicy.INHERIT;
pub const AJ_IFC_SECURITY_REQUIRED = alljoyn_interfacedescription_securitypolicy.REQUIRED;
pub const AJ_IFC_SECURITY_OFF = alljoyn_interfacedescription_securitypolicy.OFF;
pub const alljoyn_interfacedescription_member = extern struct {
iface: alljoyn_interfacedescription,
memberType: alljoyn_messagetype,
name: ?[*:0]const u8,
signature: ?[*:0]const u8,
returnSignature: ?[*:0]const u8,
argNames: ?[*:0]const u8,
internal_member: ?*const anyopaque,
};
pub const alljoyn_interfacedescription_translation_callback_ptr = fn(
sourceLanguage: ?[*:0]const u8,
targetLanguage: ?[*:0]const u8,
sourceText: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub const alljoyn_interfacedescription_property = extern struct {
name: ?[*:0]const u8,
signature: ?[*:0]const u8,
access: u8,
internal_property: ?*const anyopaque,
};
pub const alljoyn_messagereceiver_methodhandler_ptr = fn(
bus: alljoyn_busobject,
member: ?*const alljoyn_interfacedescription_member,
message: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_messagereceiver_replyhandler_ptr = fn(
message: alljoyn_message,
context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_messagereceiver_signalhandler_ptr = fn(
member: ?*const alljoyn_interfacedescription_member,
srcPath: ?[*:0]const u8,
message: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_busobject_prop_get_ptr = fn(
context: ?*const anyopaque,
ifcName: ?[*:0]const u8,
propName: ?[*:0]const u8,
val: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub const alljoyn_busobject_prop_set_ptr = fn(
context: ?*const anyopaque,
ifcName: ?[*:0]const u8,
propName: ?[*:0]const u8,
val: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub const alljoyn_busobject_object_registration_ptr = fn(
context: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_busobject_callbacks = extern struct {
property_get: ?alljoyn_busobject_prop_get_ptr,
property_set: ?alljoyn_busobject_prop_set_ptr,
object_registered: ?alljoyn_busobject_object_registration_ptr,
object_unregistered: ?alljoyn_busobject_object_registration_ptr,
};
pub const alljoyn_busobject_methodentry = extern struct {
member: ?*const alljoyn_interfacedescription_member,
method_handler: ?alljoyn_messagereceiver_methodhandler_ptr,
};
pub const alljoyn_proxybusobject_listener_introspectcb_ptr = fn(
status: QStatus,
obj: alljoyn_proxybusobject,
context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_proxybusobject_listener_getpropertycb_ptr = fn(
status: QStatus,
obj: alljoyn_proxybusobject,
value: alljoyn_msgarg,
context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_proxybusobject_listener_getallpropertiescb_ptr = fn(
status: QStatus,
obj: alljoyn_proxybusobject,
values: alljoyn_msgarg,
context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_proxybusobject_listener_setpropertycb_ptr = fn(
status: QStatus,
obj: alljoyn_proxybusobject,
context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_proxybusobject_listener_propertieschanged_ptr = fn(
obj: alljoyn_proxybusobject,
ifaceName: ?[*:0]const u8,
changed: alljoyn_msgarg,
invalidated: alljoyn_msgarg,
context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_permissionconfigurationlistener_factoryreset_ptr = fn(
context: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub const alljoyn_permissionconfigurationlistener_policychanged_ptr = fn(
context: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_permissionconfigurationlistener_startmanagement_ptr = fn(
context: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_permissionconfigurationlistener_endmanagement_ptr = fn(
context: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_permissionconfigurationlistener_callbacks = extern struct {
factory_reset: ?alljoyn_permissionconfigurationlistener_factoryreset_ptr,
policy_changed: ?alljoyn_permissionconfigurationlistener_policychanged_ptr,
start_management: ?alljoyn_permissionconfigurationlistener_startmanagement_ptr,
end_management: ?alljoyn_permissionconfigurationlistener_endmanagement_ptr,
};
pub const alljoyn_sessionlostreason = enum(i32) {
INVALID = 0,
REMOTE_END_LEFT_SESSION = 1,
REMOTE_END_CLOSED_ABRUPTLY = 2,
REMOVED_BY_BINDER = 3,
LINK_TIMEOUT = 4,
REASON_OTHER = 5,
};
pub const ALLJOYN_SESSIONLOST_INVALID = alljoyn_sessionlostreason.INVALID;
pub const ALLJOYN_SESSIONLOST_REMOTE_END_LEFT_SESSION = alljoyn_sessionlostreason.REMOTE_END_LEFT_SESSION;
pub const ALLJOYN_SESSIONLOST_REMOTE_END_CLOSED_ABRUPTLY = alljoyn_sessionlostreason.REMOTE_END_CLOSED_ABRUPTLY;
pub const ALLJOYN_SESSIONLOST_REMOVED_BY_BINDER = alljoyn_sessionlostreason.REMOVED_BY_BINDER;
pub const ALLJOYN_SESSIONLOST_LINK_TIMEOUT = alljoyn_sessionlostreason.LINK_TIMEOUT;
pub const ALLJOYN_SESSIONLOST_REASON_OTHER = alljoyn_sessionlostreason.REASON_OTHER;
pub const alljoyn_sessionlistener_sessionlost_ptr = fn(
context: ?*const anyopaque,
sessionId: u32,
reason: alljoyn_sessionlostreason,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_sessionlistener_sessionmemberadded_ptr = fn(
context: ?*const anyopaque,
sessionId: u32,
uniqueName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_sessionlistener_sessionmemberremoved_ptr = fn(
context: ?*const anyopaque,
sessionId: u32,
uniqueName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_sessionlistener_callbacks = extern struct {
session_lost: ?alljoyn_sessionlistener_sessionlost_ptr,
session_member_added: ?alljoyn_sessionlistener_sessionmemberadded_ptr,
session_member_removed: ?alljoyn_sessionlistener_sessionmemberremoved_ptr,
};
pub const alljoyn_sessionportlistener_acceptsessionjoiner_ptr = fn(
context: ?*const anyopaque,
sessionPort: u16,
joiner: ?[*:0]const u8,
opts: alljoyn_sessionopts,
) callconv(@import("std").os.windows.WINAPI) i32;
pub const alljoyn_sessionportlistener_sessionjoined_ptr = fn(
context: ?*const anyopaque,
sessionPort: u16,
id: u32,
joiner: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_sessionportlistener_callbacks = extern struct {
accept_session_joiner: ?alljoyn_sessionportlistener_acceptsessionjoiner_ptr,
session_joined: ?alljoyn_sessionportlistener_sessionjoined_ptr,
};
pub const alljoyn_about_announced_ptr = fn(
context: ?*const anyopaque,
busName: ?[*:0]const u8,
version: u16,
port: u16,
objectDescriptionArg: alljoyn_msgarg,
aboutDataArg: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_aboutlistener_callback = extern struct {
about_listener_announced: ?alljoyn_about_announced_ptr,
};
pub const alljoyn_busattachment_joinsessioncb_ptr = fn(
status: QStatus,
sessionId: u32,
opts: alljoyn_sessionopts,
context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_busattachment_setlinktimeoutcb_ptr = fn(
status: QStatus,
timeout: u32,
context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) void;
pub const _alljoyn_abouticonobj_handle = extern struct {
placeholder: usize, // TODO: why is this type empty?
};
pub const _alljoyn_abouticonproxy_handle = extern struct {
placeholder: usize, // TODO: why is this type empty?
};
pub const alljoyn_aboutdatalistener_getaboutdata_ptr = fn(
context: ?*const anyopaque,
msgArg: alljoyn_msgarg,
language: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub const alljoyn_aboutdatalistener_getannouncedaboutdata_ptr = fn(
context: ?*const anyopaque,
msgArg: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub const alljoyn_aboutdatalistener_callbacks = extern struct {
about_datalistener_getaboutdata: ?alljoyn_aboutdatalistener_getaboutdata_ptr,
about_datalistener_getannouncedaboutdata: ?alljoyn_aboutdatalistener_getannouncedaboutdata_ptr,
};
pub const alljoyn_autopinger_destination_lost_ptr = fn(
context: ?*const anyopaque,
group: ?[*:0]const u8,
destination: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_autopinger_destination_found_ptr = fn(
context: ?*const anyopaque,
group: ?[*:0]const u8,
destination: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_pinglistener_callback = extern struct {
destination_found: ?alljoyn_autopinger_destination_found_ptr,
destination_lost: ?alljoyn_autopinger_destination_lost_ptr,
};
pub const alljoyn_observer_object_discovered_ptr = fn(
context: ?*const anyopaque,
proxyref: alljoyn_proxybusobject_ref,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_observer_object_lost_ptr = fn(
context: ?*const anyopaque,
proxyref: alljoyn_proxybusobject_ref,
) callconv(@import("std").os.windows.WINAPI) void;
pub const alljoyn_observerlistener_callback = extern struct {
object_discovered: ?alljoyn_observer_object_discovered_ptr,
object_lost: ?alljoyn_observer_object_lost_ptr,
};
pub const alljoyn_aboutdata = isize;
pub const alljoyn_aboutdatalistener = isize;
pub const alljoyn_aboutlistener = isize;
pub const alljoyn_aboutobj = isize;
pub const alljoyn_aboutobjectdescription = isize;
pub const alljoyn_aboutproxy = isize;
pub const alljoyn_applicationstatelistener = isize;
pub const alljoyn_authlistener = isize;
pub const alljoyn_autopinger = isize;
pub const alljoyn_busattachment = isize;
pub const alljoyn_buslistener = isize;
pub const alljoyn_busobject = isize;
pub const alljoyn_credentials = isize;
pub const alljoyn_interfacedescription = isize;
pub const alljoyn_keystore = isize;
pub const alljoyn_keystorelistener = isize;
pub const alljoyn_message = isize;
pub const alljoyn_msgarg = isize;
pub const alljoyn_observer = isize;
pub const alljoyn_observerlistener = isize;
pub const alljoyn_permissionconfigurationlistener = isize;
pub const alljoyn_permissionconfigurator = isize;
pub const alljoyn_pinglistener = isize;
pub const alljoyn_proxybusobject = isize;
pub const alljoyn_proxybusobject_ref = isize;
pub const alljoyn_securityapplicationproxy = isize;
pub const alljoyn_sessionlistener = isize;
pub const alljoyn_sessionopts = isize;
pub const alljoyn_sessionportlistener = isize;
//--------------------------------------------------------------------------------
// Section: Functions (547)
//--------------------------------------------------------------------------------
// TODO: this type is limited to platform 'windows10.0.10240'
pub extern "MSAJApi" fn AllJoynConnectToBus(
connectionSpec: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) ?HANDLE;
// TODO: this type is limited to platform 'windows10.0.10240'
pub extern "MSAJApi" fn AllJoynCloseBusHandle(
busHandle: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows10.0.10240'
pub extern "MSAJApi" fn AllJoynSendToBus(
connectedBusHandle: ?HANDLE,
// TODO: what to do with BytesParamIndex 2?
buffer: ?*const anyopaque,
bytesToWrite: u32,
bytesTransferred: ?*u32,
reserved: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows10.0.10240'
pub extern "MSAJApi" fn AllJoynReceiveFromBus(
connectedBusHandle: ?HANDLE,
// TODO: what to do with BytesParamIndex 2?
buffer: ?*anyopaque,
bytesToRead: u32,
bytesTransferred: ?*u32,
reserved: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows10.0.10240'
pub extern "MSAJApi" fn AllJoynEventSelect(
connectedBusHandle: ?HANDLE,
eventHandle: ?HANDLE,
eventTypes: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows10.0.10240'
pub extern "MSAJApi" fn AllJoynEnumEvents(
connectedBusHandle: ?HANDLE,
eventToReset: ?HANDLE,
eventTypes: ?*u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "MSAJApi" fn AllJoynCreateBus(
outBufferSize: u32,
inBufferSize: u32,
lpSecurityAttributes: ?*SECURITY_ATTRIBUTES,
) callconv(@import("std").os.windows.WINAPI) ?HANDLE;
pub extern "MSAJApi" fn AllJoynAcceptBusConnection(
serverBusHandle: ?HANDLE,
abortEvent: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
pub extern "MSAJApi" fn alljoyn_unity_deferred_callbacks_process(
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_unity_set_deferred_callback_mainthread_only(
mainthread_only: i32,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn QCC_StatusText(
status: QStatus,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_msgarg_create(
) callconv(@import("std").os.windows.WINAPI) alljoyn_msgarg;
pub extern "MSAJApi" fn alljoyn_msgarg_create_and_set(
signature: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) alljoyn_msgarg;
pub extern "MSAJApi" fn alljoyn_msgarg_destroy(
arg: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_msgarg_array_create(
size: usize,
) callconv(@import("std").os.windows.WINAPI) alljoyn_msgarg;
pub extern "MSAJApi" fn alljoyn_msgarg_array_element(
arg: alljoyn_msgarg,
index: usize,
) callconv(@import("std").os.windows.WINAPI) alljoyn_msgarg;
pub extern "MSAJApi" fn alljoyn_msgarg_set(
arg: alljoyn_msgarg,
signature: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get(
arg: alljoyn_msgarg,
signature: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_copy(
source: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) alljoyn_msgarg;
pub extern "MSAJApi" fn alljoyn_msgarg_clone(
destination: alljoyn_msgarg,
source: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_msgarg_equal(
lhv: alljoyn_msgarg,
rhv: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_msgarg_array_set(
args: alljoyn_msgarg,
numArgs: ?*usize,
signature: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_array_get(
args: alljoyn_msgarg,
numArgs: usize,
signature: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_tostring(
arg: alljoyn_msgarg,
str: ?PSTR,
buf: usize,
indent: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_msgarg_array_tostring(
args: alljoyn_msgarg,
numArgs: usize,
str: ?PSTR,
buf: usize,
indent: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_msgarg_signature(
arg: alljoyn_msgarg,
str: ?PSTR,
buf: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_msgarg_array_signature(
values: alljoyn_msgarg,
numValues: usize,
str: ?PSTR,
buf: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_msgarg_hassignature(
arg: alljoyn_msgarg,
signature: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_msgarg_getdictelement(
arg: alljoyn_msgarg,
elemSig: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_gettype(
arg: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) alljoyn_typeid;
pub extern "MSAJApi" fn alljoyn_msgarg_clear(
arg: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_msgarg_stabilize(
arg: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_msgarg_array_set_offset(
args: alljoyn_msgarg,
argOffset: usize,
numArgs: ?*usize,
signature: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_and_stabilize(
arg: alljoyn_msgarg,
signature: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_uint8(
arg: alljoyn_msgarg,
y: u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_bool(
arg: alljoyn_msgarg,
b: i32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_int16(
arg: alljoyn_msgarg,
n: i16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_uint16(
arg: alljoyn_msgarg,
q: u16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_int32(
arg: alljoyn_msgarg,
i: i32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_uint32(
arg: alljoyn_msgarg,
u: u32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_int64(
arg: alljoyn_msgarg,
x: i64,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_uint64(
arg: alljoyn_msgarg,
t: u64,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_double(
arg: alljoyn_msgarg,
d: f64,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_string(
arg: alljoyn_msgarg,
s: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_objectpath(
arg: alljoyn_msgarg,
o: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_signature(
arg: alljoyn_msgarg,
g: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_uint8(
arg: alljoyn_msgarg,
y: ?*u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_bool(
arg: alljoyn_msgarg,
b: ?*i32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_int16(
arg: alljoyn_msgarg,
n: ?*i16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_uint16(
arg: alljoyn_msgarg,
q: ?*u16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_int32(
arg: alljoyn_msgarg,
i: ?*i32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_uint32(
arg: alljoyn_msgarg,
u: ?*u32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_int64(
arg: alljoyn_msgarg,
x: ?*i64,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_uint64(
arg: alljoyn_msgarg,
t: ?*u64,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_double(
arg: alljoyn_msgarg,
d: ?*f64,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_string(
arg: alljoyn_msgarg,
s: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_objectpath(
arg: alljoyn_msgarg,
o: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_signature(
arg: alljoyn_msgarg,
g: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_variant(
arg: alljoyn_msgarg,
v: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_uint8_array(
arg: alljoyn_msgarg,
length: usize,
ay: ?*u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_bool_array(
arg: alljoyn_msgarg,
length: usize,
ab: ?*i32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_int16_array(
arg: alljoyn_msgarg,
length: usize,
an: ?*i16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_uint16_array(
arg: alljoyn_msgarg,
length: usize,
aq: ?*u16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_int32_array(
arg: alljoyn_msgarg,
length: usize,
ai: ?*i32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_uint32_array(
arg: alljoyn_msgarg,
length: usize,
au: ?*u32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_int64_array(
arg: alljoyn_msgarg,
length: usize,
ax: ?*i64,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_uint64_array(
arg: alljoyn_msgarg,
length: usize,
at: ?*u64,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_double_array(
arg: alljoyn_msgarg,
length: usize,
ad: ?*f64,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_string_array(
arg: alljoyn_msgarg,
length: usize,
as: ?*const ?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_objectpath_array(
arg: alljoyn_msgarg,
length: usize,
ao: ?*const ?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_set_signature_array(
arg: alljoyn_msgarg,
length: usize,
ag: ?*const ?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_uint8_array(
arg: alljoyn_msgarg,
length: ?*usize,
ay: ?*u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_bool_array(
arg: alljoyn_msgarg,
length: ?*usize,
ab: ?*i32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_int16_array(
arg: alljoyn_msgarg,
length: ?*usize,
an: ?*i16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_uint16_array(
arg: alljoyn_msgarg,
length: ?*usize,
aq: ?*u16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_int32_array(
arg: alljoyn_msgarg,
length: ?*usize,
ai: ?*i32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_uint32_array(
arg: alljoyn_msgarg,
length: ?*usize,
au: ?*u32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_int64_array(
arg: alljoyn_msgarg,
length: ?*usize,
ax: ?*i64,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_uint64_array(
arg: alljoyn_msgarg,
length: ?*usize,
at: ?*u64,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_double_array(
arg: alljoyn_msgarg,
length: ?*usize,
ad: ?*f64,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_variant_array(
arg: alljoyn_msgarg,
signature: ?[*:0]const u8,
length: ?*usize,
av: ?*alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_get_array_numberofelements(
arg: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_msgarg_get_array_element(
arg: alljoyn_msgarg,
index: usize,
element: ?*alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_msgarg_get_array_elementsignature(
arg: alljoyn_msgarg,
index: usize,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_msgarg_getkey(
arg: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) alljoyn_msgarg;
pub extern "MSAJApi" fn alljoyn_msgarg_getvalue(
arg: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) alljoyn_msgarg;
pub extern "MSAJApi" fn alljoyn_msgarg_setdictentry(
arg: alljoyn_msgarg,
key: alljoyn_msgarg,
value: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_setstruct(
arg: alljoyn_msgarg,
struct_members: alljoyn_msgarg,
num_members: usize,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_msgarg_getnummembers(
arg: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_msgarg_getmember(
arg: alljoyn_msgarg,
index: usize,
) callconv(@import("std").os.windows.WINAPI) alljoyn_msgarg;
pub extern "MSAJApi" fn alljoyn_aboutdata_create_empty(
) callconv(@import("std").os.windows.WINAPI) alljoyn_aboutdata;
pub extern "MSAJApi" fn alljoyn_aboutdata_create(
defaultLanguage: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) alljoyn_aboutdata;
pub extern "MSAJApi" fn alljoyn_aboutdata_create_full(
arg: alljoyn_msgarg,
language: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) alljoyn_aboutdata;
pub extern "MSAJApi" fn alljoyn_aboutdata_destroy(
data: alljoyn_aboutdata,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_aboutdata_createfromxml(
data: alljoyn_aboutdata,
aboutDataXml: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_isvalid(
data: alljoyn_aboutdata,
language: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u8;
pub extern "MSAJApi" fn alljoyn_aboutdata_createfrommsgarg(
data: alljoyn_aboutdata,
arg: alljoyn_msgarg,
language: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_setappid(
data: alljoyn_aboutdata,
appId: ?*const u8,
num: usize,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_setappid_fromstring(
data: alljoyn_aboutdata,
appId: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_getappid(
data: alljoyn_aboutdata,
appId: ?*?*u8,
num: ?*usize,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_setdefaultlanguage(
data: alljoyn_aboutdata,
defaultLanguage: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_getdefaultlanguage(
data: alljoyn_aboutdata,
defaultLanguage: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_setdevicename(
data: alljoyn_aboutdata,
deviceName: ?[*:0]const u8,
language: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_getdevicename(
data: alljoyn_aboutdata,
deviceName: ?*?*i8,
language: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_setdeviceid(
data: alljoyn_aboutdata,
deviceId: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_getdeviceid(
data: alljoyn_aboutdata,
deviceId: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_setappname(
data: alljoyn_aboutdata,
appName: ?[*:0]const u8,
language: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_getappname(
data: alljoyn_aboutdata,
appName: ?*?*i8,
language: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_setmanufacturer(
data: alljoyn_aboutdata,
manufacturer: ?[*:0]const u8,
language: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_getmanufacturer(
data: alljoyn_aboutdata,
manufacturer: ?*?*i8,
language: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_setmodelnumber(
data: alljoyn_aboutdata,
modelNumber: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_getmodelnumber(
data: alljoyn_aboutdata,
modelNumber: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_setsupportedlanguage(
data: alljoyn_aboutdata,
language: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_getsupportedlanguages(
data: alljoyn_aboutdata,
languageTags: ?*const ?*i8,
num: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_aboutdata_setdescription(
data: alljoyn_aboutdata,
description: ?[*:0]const u8,
language: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_getdescription(
data: alljoyn_aboutdata,
description: ?*?*i8,
language: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_setdateofmanufacture(
data: alljoyn_aboutdata,
dateOfManufacture: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_getdateofmanufacture(
data: alljoyn_aboutdata,
dateOfManufacture: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_setsoftwareversion(
data: alljoyn_aboutdata,
softwareVersion: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_getsoftwareversion(
data: alljoyn_aboutdata,
softwareVersion: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_getajsoftwareversion(
data: alljoyn_aboutdata,
ajSoftwareVersion: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_sethardwareversion(
data: alljoyn_aboutdata,
hardwareVersion: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_gethardwareversion(
data: alljoyn_aboutdata,
hardwareVersion: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_setsupporturl(
data: alljoyn_aboutdata,
supportUrl: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_getsupporturl(
data: alljoyn_aboutdata,
supportUrl: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_setfield(
data: alljoyn_aboutdata,
name: ?[*:0]const u8,
value: alljoyn_msgarg,
language: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_getfield(
data: alljoyn_aboutdata,
name: ?[*:0]const u8,
value: ?*alljoyn_msgarg,
language: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_getfields(
data: alljoyn_aboutdata,
fields: ?*const ?*i8,
num_fields: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_aboutdata_getaboutdata(
data: alljoyn_aboutdata,
msgArg: alljoyn_msgarg,
language: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_getannouncedaboutdata(
data: alljoyn_aboutdata,
msgArg: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdata_isfieldrequired(
data: alljoyn_aboutdata,
fieldName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u8;
pub extern "MSAJApi" fn alljoyn_aboutdata_isfieldannounced(
data: alljoyn_aboutdata,
fieldName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u8;
pub extern "MSAJApi" fn alljoyn_aboutdata_isfieldlocalized(
data: alljoyn_aboutdata,
fieldName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u8;
pub extern "MSAJApi" fn alljoyn_aboutdata_getfieldsignature(
data: alljoyn_aboutdata,
fieldName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_abouticon_create(
) callconv(@import("std").os.windows.WINAPI) ?*_alljoyn_abouticon_handle;
pub extern "MSAJApi" fn alljoyn_abouticon_destroy(
icon: ?*_alljoyn_abouticon_handle,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_abouticon_getcontent(
icon: ?*_alljoyn_abouticon_handle,
data: ?*const ?*u8,
size: ?*usize,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_abouticon_setcontent(
icon: ?*_alljoyn_abouticon_handle,
type: ?[*:0]const u8,
data: ?*u8,
csize: usize,
ownsData: u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_abouticon_geturl(
icon: ?*_alljoyn_abouticon_handle,
type: ?*const ?*i8,
url: ?*const ?*i8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_abouticon_seturl(
icon: ?*_alljoyn_abouticon_handle,
type: ?[*:0]const u8,
url: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_abouticon_clear(
icon: ?*_alljoyn_abouticon_handle,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_abouticon_setcontent_frommsgarg(
icon: ?*_alljoyn_abouticon_handle,
arg: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_getdefaultclaimcapabilities(
) callconv(@import("std").os.windows.WINAPI) u16;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_getapplicationstate(
configurator: alljoyn_permissionconfigurator,
state: ?*alljoyn_applicationstate,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_setapplicationstate(
configurator: alljoyn_permissionconfigurator,
state: alljoyn_applicationstate,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_getpublickey(
configurator: alljoyn_permissionconfigurator,
publicKey: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_publickey_destroy(
publicKey: ?*i8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_getmanifesttemplate(
configurator: alljoyn_permissionconfigurator,
manifestTemplateXml: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_manifesttemplate_destroy(
manifestTemplateXml: ?*i8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_setmanifesttemplatefromxml(
configurator: alljoyn_permissionconfigurator,
manifestTemplateXml: ?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_getclaimcapabilities(
configurator: alljoyn_permissionconfigurator,
claimCapabilities: ?*u16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_setclaimcapabilities(
configurator: alljoyn_permissionconfigurator,
claimCapabilities: u16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_getclaimcapabilitiesadditionalinfo(
configurator: alljoyn_permissionconfigurator,
additionalInfo: ?*u16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_setclaimcapabilitiesadditionalinfo(
configurator: alljoyn_permissionconfigurator,
additionalInfo: u16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_reset(
configurator: alljoyn_permissionconfigurator,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_claim(
configurator: alljoyn_permissionconfigurator,
caKey: ?*i8,
identityCertificateChain: ?*i8,
groupId: ?*const u8,
groupSize: usize,
groupAuthority: ?*i8,
manifestsXmls: ?*?*i8,
manifestsCount: usize,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_updateidentity(
configurator: alljoyn_permissionconfigurator,
identityCertificateChain: ?*i8,
manifestsXmls: ?*?*i8,
manifestsCount: usize,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_getidentity(
configurator: alljoyn_permissionconfigurator,
identityCertificateChain: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_certificatechain_destroy(
certificateChain: ?*i8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_getmanifests(
configurator: alljoyn_permissionconfigurator,
manifestArray: ?*alljoyn_manifestarray,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_manifestarray_cleanup(
manifestArray: ?*alljoyn_manifestarray,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_installmanifests(
configurator: alljoyn_permissionconfigurator,
manifestsXmls: ?*?*i8,
manifestsCount: usize,
append: i32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_getidentitycertificateid(
configurator: alljoyn_permissionconfigurator,
certificateId: ?*alljoyn_certificateid,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_certificateid_cleanup(
certificateId: ?*alljoyn_certificateid,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_updatepolicy(
configurator: alljoyn_permissionconfigurator,
policyXml: ?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_getpolicy(
configurator: alljoyn_permissionconfigurator,
policyXml: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_getdefaultpolicy(
configurator: alljoyn_permissionconfigurator,
policyXml: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_policy_destroy(
policyXml: ?*i8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_resetpolicy(
configurator: alljoyn_permissionconfigurator,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_getmembershipsummaries(
configurator: alljoyn_permissionconfigurator,
certificateIds: ?*alljoyn_certificateidarray,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_certificateidarray_cleanup(
certificateIdArray: ?*alljoyn_certificateidarray,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_installmembership(
configurator: alljoyn_permissionconfigurator,
membershipCertificateChain: ?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_removemembership(
configurator: alljoyn_permissionconfigurator,
serial: ?*const u8,
serialLen: usize,
issuerPublicKey: ?*i8,
issuerAki: ?*const u8,
issuerAkiLen: usize,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_startmanagement(
configurator: alljoyn_permissionconfigurator,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_permissionconfigurator_endmanagement(
configurator: alljoyn_permissionconfigurator,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_applicationstatelistener_create(
callbacks: ?*const alljoyn_applicationstatelistener_callbacks,
context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) alljoyn_applicationstatelistener;
pub extern "MSAJApi" fn alljoyn_applicationstatelistener_destroy(
listener: alljoyn_applicationstatelistener,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_keystorelistener_create(
callbacks: ?*const alljoyn_keystorelistener_callbacks,
context: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) alljoyn_keystorelistener;
pub extern "MSAJApi" fn alljoyn_keystorelistener_with_synchronization_create(
callbacks: ?*const alljoyn_keystorelistener_with_synchronization_callbacks,
context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) alljoyn_keystorelistener;
pub extern "MSAJApi" fn alljoyn_keystorelistener_destroy(
listener: alljoyn_keystorelistener,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_keystorelistener_putkeys(
listener: alljoyn_keystorelistener,
keyStore: alljoyn_keystore,
source: ?[*:0]const u8,
password: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_keystorelistener_getkeys(
listener: alljoyn_keystorelistener,
keyStore: alljoyn_keystore,
sink: ?PSTR,
sink_sz: ?*usize,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_sessionopts_create(
traffic: u8,
isMultipoint: i32,
proximity: u8,
transports: u16,
) callconv(@import("std").os.windows.WINAPI) alljoyn_sessionopts;
pub extern "MSAJApi" fn alljoyn_sessionopts_destroy(
opts: alljoyn_sessionopts,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_sessionopts_get_traffic(
opts: alljoyn_sessionopts,
) callconv(@import("std").os.windows.WINAPI) u8;
pub extern "MSAJApi" fn alljoyn_sessionopts_set_traffic(
opts: alljoyn_sessionopts,
traffic: u8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_sessionopts_get_multipoint(
opts: alljoyn_sessionopts,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_sessionopts_set_multipoint(
opts: alljoyn_sessionopts,
isMultipoint: i32,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_sessionopts_get_proximity(
opts: alljoyn_sessionopts,
) callconv(@import("std").os.windows.WINAPI) u8;
pub extern "MSAJApi" fn alljoyn_sessionopts_set_proximity(
opts: alljoyn_sessionopts,
proximity: u8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_sessionopts_get_transports(
opts: alljoyn_sessionopts,
) callconv(@import("std").os.windows.WINAPI) u16;
pub extern "MSAJApi" fn alljoyn_sessionopts_set_transports(
opts: alljoyn_sessionopts,
transports: u16,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_sessionopts_iscompatible(
one: alljoyn_sessionopts,
other: alljoyn_sessionopts,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_sessionopts_cmp(
one: alljoyn_sessionopts,
other: alljoyn_sessionopts,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_message_create(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) alljoyn_message;
pub extern "MSAJApi" fn alljoyn_message_destroy(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_message_isbroadcastsignal(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_message_isglobalbroadcast(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_message_issessionless(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_message_getflags(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) u8;
pub extern "MSAJApi" fn alljoyn_message_isexpired(
msg: alljoyn_message,
tillExpireMS: ?*u32,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_message_isunreliable(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_message_isencrypted(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_message_getauthmechanism(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_message_gettype(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) alljoyn_messagetype;
pub extern "MSAJApi" fn alljoyn_message_getargs(
msg: alljoyn_message,
numArgs: ?*usize,
args: ?*alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_message_getarg(
msg: alljoyn_message,
argN: usize,
) callconv(@import("std").os.windows.WINAPI) alljoyn_msgarg;
pub extern "MSAJApi" fn alljoyn_message_parseargs(
msg: alljoyn_message,
signature: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_message_getcallserial(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) u32;
pub extern "MSAJApi" fn alljoyn_message_getsignature(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_message_getobjectpath(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_message_getinterface(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_message_getmembername(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_message_getreplyserial(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) u32;
pub extern "MSAJApi" fn alljoyn_message_getsender(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_message_getreceiveendpointname(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_message_getdestination(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_message_getcompressiontoken(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) u32;
pub extern "MSAJApi" fn alljoyn_message_getsessionid(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) u32;
pub extern "MSAJApi" fn alljoyn_message_geterrorname(
msg: alljoyn_message,
errorMessage: ?PSTR,
errorMessage_size: ?*usize,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_message_tostring(
msg: alljoyn_message,
str: ?PSTR,
buf: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_message_description(
msg: alljoyn_message,
str: ?PSTR,
buf: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_message_gettimestamp(
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) u32;
pub extern "MSAJApi" fn alljoyn_message_eql(
one: alljoyn_message,
other: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_message_setendianess(
endian: i8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_authlistener_requestcredentialsresponse(
listener: alljoyn_authlistener,
authContext: ?*anyopaque,
accept: i32,
credentials: alljoyn_credentials,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_authlistener_verifycredentialsresponse(
listener: alljoyn_authlistener,
authContext: ?*anyopaque,
accept: i32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_authlistener_create(
callbacks: ?*const alljoyn_authlistener_callbacks,
context: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) alljoyn_authlistener;
pub extern "MSAJApi" fn alljoyn_authlistenerasync_create(
callbacks: ?*const alljoyn_authlistenerasync_callbacks,
context: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) alljoyn_authlistener;
pub extern "MSAJApi" fn alljoyn_authlistener_destroy(
listener: alljoyn_authlistener,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_authlistenerasync_destroy(
listener: alljoyn_authlistener,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_authlistener_setsharedsecret(
listener: alljoyn_authlistener,
sharedSecret: ?*const u8,
sharedSecretSize: usize,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_credentials_create(
) callconv(@import("std").os.windows.WINAPI) alljoyn_credentials;
pub extern "MSAJApi" fn alljoyn_credentials_destroy(
cred: alljoyn_credentials,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_credentials_isset(
cred: alljoyn_credentials,
creds: u16,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_credentials_setpassword(
cred: alljoyn_credentials,
pwd: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_credentials_setusername(
cred: alljoyn_credentials,
userName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_credentials_setcertchain(
cred: alljoyn_credentials,
certChain: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_credentials_setprivatekey(
cred: alljoyn_credentials,
pk: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_credentials_setlogonentry(
cred: alljoyn_credentials,
logonEntry: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_credentials_setexpiration(
cred: alljoyn_credentials,
expiration: u32,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_credentials_getpassword(
cred: alljoyn_credentials,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_credentials_getusername(
cred: alljoyn_credentials,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_credentials_getcertchain(
cred: alljoyn_credentials,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_credentials_getprivateKey(
cred: alljoyn_credentials,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_credentials_getlogonentry(
cred: alljoyn_credentials,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_credentials_getexpiration(
cred: alljoyn_credentials,
) callconv(@import("std").os.windows.WINAPI) u32;
pub extern "MSAJApi" fn alljoyn_credentials_clear(
cred: alljoyn_credentials,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_buslistener_create(
callbacks: ?*const alljoyn_buslistener_callbacks,
context: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) alljoyn_buslistener;
pub extern "MSAJApi" fn alljoyn_buslistener_destroy(
listener: alljoyn_buslistener,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_interfacedescription_member_getannotationscount(
member: alljoyn_interfacedescription_member,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_interfacedescription_member_getannotationatindex(
member: alljoyn_interfacedescription_member,
index: usize,
name: ?PSTR,
name_size: ?*usize,
value: ?PSTR,
value_size: ?*usize,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_interfacedescription_member_getannotation(
member: alljoyn_interfacedescription_member,
name: ?[*:0]const u8,
value: ?PSTR,
value_size: ?*usize,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_interfacedescription_member_getargannotationscount(
member: alljoyn_interfacedescription_member,
argName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_interfacedescription_member_getargannotationatindex(
member: alljoyn_interfacedescription_member,
argName: ?[*:0]const u8,
index: usize,
name: ?PSTR,
name_size: ?*usize,
value: ?PSTR,
value_size: ?*usize,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_interfacedescription_member_getargannotation(
member: alljoyn_interfacedescription_member,
argName: ?[*:0]const u8,
name: ?[*:0]const u8,
value: ?PSTR,
value_size: ?*usize,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_interfacedescription_property_getannotationscount(
property: alljoyn_interfacedescription_property,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_interfacedescription_property_getannotationatindex(
property: alljoyn_interfacedescription_property,
index: usize,
name: ?PSTR,
name_size: ?*usize,
value: ?PSTR,
value_size: ?*usize,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_interfacedescription_property_getannotation(
property: alljoyn_interfacedescription_property,
name: ?[*:0]const u8,
value: ?PSTR,
value_size: ?*usize,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_interfacedescription_activate(
iface: alljoyn_interfacedescription,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_interfacedescription_addannotation(
iface: alljoyn_interfacedescription,
name: ?[*:0]const u8,
value: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getannotation(
iface: alljoyn_interfacedescription,
name: ?[*:0]const u8,
value: ?PSTR,
value_size: ?*usize,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getannotationscount(
iface: alljoyn_interfacedescription,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getannotationatindex(
iface: alljoyn_interfacedescription,
index: usize,
name: ?PSTR,
name_size: ?*usize,
value: ?PSTR,
value_size: ?*usize,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getmember(
iface: alljoyn_interfacedescription,
name: ?[*:0]const u8,
member: ?*alljoyn_interfacedescription_member,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_interfacedescription_addmember(
iface: alljoyn_interfacedescription,
type: alljoyn_messagetype,
name: ?[*:0]const u8,
inputSig: ?[*:0]const u8,
outSig: ?[*:0]const u8,
argNames: ?[*:0]const u8,
annotation: u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_interfacedescription_addmemberannotation(
iface: alljoyn_interfacedescription,
member: ?[*:0]const u8,
name: ?[*:0]const u8,
value: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getmemberannotation(
iface: alljoyn_interfacedescription,
member: ?[*:0]const u8,
name: ?[*:0]const u8,
value: ?PSTR,
value_size: ?*usize,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getmembers(
iface: alljoyn_interfacedescription,
members: ?*alljoyn_interfacedescription_member,
numMembers: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_interfacedescription_hasmember(
iface: alljoyn_interfacedescription,
name: ?[*:0]const u8,
inSig: ?[*:0]const u8,
outSig: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_interfacedescription_addmethod(
iface: alljoyn_interfacedescription,
name: ?[*:0]const u8,
inputSig: ?[*:0]const u8,
outSig: ?[*:0]const u8,
argNames: ?[*:0]const u8,
annotation: u8,
accessPerms: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getmethod(
iface: alljoyn_interfacedescription,
name: ?[*:0]const u8,
member: ?*alljoyn_interfacedescription_member,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_interfacedescription_addsignal(
iface: alljoyn_interfacedescription,
name: ?[*:0]const u8,
sig: ?[*:0]const u8,
argNames: ?[*:0]const u8,
annotation: u8,
accessPerms: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getsignal(
iface: alljoyn_interfacedescription,
name: ?[*:0]const u8,
member: ?*alljoyn_interfacedescription_member,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getproperty(
iface: alljoyn_interfacedescription,
name: ?[*:0]const u8,
property: ?*alljoyn_interfacedescription_property,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getproperties(
iface: alljoyn_interfacedescription,
props: ?*alljoyn_interfacedescription_property,
numProps: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_interfacedescription_addproperty(
iface: alljoyn_interfacedescription,
name: ?[*:0]const u8,
signature: ?[*:0]const u8,
access: u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_interfacedescription_addpropertyannotation(
iface: alljoyn_interfacedescription,
property: ?[*:0]const u8,
name: ?[*:0]const u8,
value: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getpropertyannotation(
iface: alljoyn_interfacedescription,
property: ?[*:0]const u8,
name: ?[*:0]const u8,
value: ?PSTR,
str_size: ?*usize,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_interfacedescription_hasproperty(
iface: alljoyn_interfacedescription,
name: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_interfacedescription_hasproperties(
iface: alljoyn_interfacedescription,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getname(
iface: alljoyn_interfacedescription,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_interfacedescription_introspect(
iface: alljoyn_interfacedescription,
str: ?PSTR,
buf: usize,
indent: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_interfacedescription_issecure(
iface: alljoyn_interfacedescription,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getsecuritypolicy(
iface: alljoyn_interfacedescription,
) callconv(@import("std").os.windows.WINAPI) alljoyn_interfacedescription_securitypolicy;
pub extern "MSAJApi" fn alljoyn_interfacedescription_setdescriptionlanguage(
iface: alljoyn_interfacedescription,
language: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getdescriptionlanguages(
iface: alljoyn_interfacedescription,
languages: ?*const ?*i8,
size: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getdescriptionlanguages2(
iface: alljoyn_interfacedescription,
languages: ?PSTR,
languagesSize: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_interfacedescription_setdescription(
iface: alljoyn_interfacedescription,
description: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_interfacedescription_setdescriptionforlanguage(
iface: alljoyn_interfacedescription,
description: ?[*:0]const u8,
languageTag: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getdescriptionforlanguage(
iface: alljoyn_interfacedescription,
description: ?PSTR,
maxLanguageLength: usize,
languageTag: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_interfacedescription_setmemberdescription(
iface: alljoyn_interfacedescription,
member: ?[*:0]const u8,
description: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_interfacedescription_setmemberdescriptionforlanguage(
iface: alljoyn_interfacedescription,
member: ?[*:0]const u8,
description: ?[*:0]const u8,
languageTag: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getmemberdescriptionforlanguage(
iface: alljoyn_interfacedescription,
member: ?[*:0]const u8,
description: ?PSTR,
maxLanguageLength: usize,
languageTag: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_interfacedescription_setargdescription(
iface: alljoyn_interfacedescription,
member: ?[*:0]const u8,
argName: ?[*:0]const u8,
description: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_interfacedescription_setargdescriptionforlanguage(
iface: alljoyn_interfacedescription,
member: ?[*:0]const u8,
arg: ?[*:0]const u8,
description: ?[*:0]const u8,
languageTag: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getargdescriptionforlanguage(
iface: alljoyn_interfacedescription,
member: ?[*:0]const u8,
arg: ?[*:0]const u8,
description: ?PSTR,
maxLanguageLength: usize,
languageTag: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_interfacedescription_setpropertydescription(
iface: alljoyn_interfacedescription,
name: ?[*:0]const u8,
description: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_interfacedescription_setpropertydescriptionforlanguage(
iface: alljoyn_interfacedescription,
name: ?[*:0]const u8,
description: ?[*:0]const u8,
languageTag: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getpropertydescriptionforlanguage(
iface: alljoyn_interfacedescription,
property: ?[*:0]const u8,
description: ?PSTR,
maxLanguageLength: usize,
languageTag: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_interfacedescription_setdescriptiontranslationcallback(
iface: alljoyn_interfacedescription,
translationCallback: ?alljoyn_interfacedescription_translation_callback_ptr,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getdescriptiontranslationcallback(
iface: alljoyn_interfacedescription,
) callconv(@import("std").os.windows.WINAPI) ?alljoyn_interfacedescription_translation_callback_ptr;
pub extern "MSAJApi" fn alljoyn_interfacedescription_hasdescription(
iface: alljoyn_interfacedescription,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_interfacedescription_addargannotation(
iface: alljoyn_interfacedescription,
member: ?[*:0]const u8,
argName: ?[*:0]const u8,
name: ?[*:0]const u8,
value: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_interfacedescription_getmemberargannotation(
iface: alljoyn_interfacedescription,
member: ?[*:0]const u8,
argName: ?[*:0]const u8,
name: ?[*:0]const u8,
value: ?PSTR,
value_size: ?*usize,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_interfacedescription_eql(
one: alljoyn_interfacedescription,
other: alljoyn_interfacedescription,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_interfacedescription_member_eql(
one: alljoyn_interfacedescription_member,
other: alljoyn_interfacedescription_member,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_interfacedescription_property_eql(
one: alljoyn_interfacedescription_property,
other: alljoyn_interfacedescription_property,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_busobject_create(
path: ?[*:0]const u8,
isPlaceholder: i32,
callbacks_in: ?*const alljoyn_busobject_callbacks,
context_in: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) alljoyn_busobject;
pub extern "MSAJApi" fn alljoyn_busobject_destroy(
bus: alljoyn_busobject,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_busobject_getpath(
bus: alljoyn_busobject,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_busobject_emitpropertychanged(
bus: alljoyn_busobject,
ifcName: ?[*:0]const u8,
propName: ?[*:0]const u8,
val: alljoyn_msgarg,
id: u32,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_busobject_emitpropertieschanged(
bus: alljoyn_busobject,
ifcName: ?[*:0]const u8,
propNames: ?*const ?*i8,
numProps: usize,
id: u32,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_busobject_getname(
bus: alljoyn_busobject,
buffer: ?PSTR,
bufferSz: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_busobject_addinterface(
bus: alljoyn_busobject,
iface: alljoyn_interfacedescription,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busobject_addmethodhandler(
bus: alljoyn_busobject,
member: alljoyn_interfacedescription_member,
handler: ?alljoyn_messagereceiver_methodhandler_ptr,
context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busobject_addmethodhandlers(
bus: alljoyn_busobject,
entries: ?*const alljoyn_busobject_methodentry,
numEntries: usize,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busobject_methodreply_args(
bus: alljoyn_busobject,
msg: alljoyn_message,
args: alljoyn_msgarg,
numArgs: usize,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busobject_methodreply_err(
bus: alljoyn_busobject,
msg: alljoyn_message,
@"error": ?[*:0]const u8,
errorMessage: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busobject_methodreply_status(
bus: alljoyn_busobject,
msg: alljoyn_message,
status: QStatus,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busobject_getbusattachment(
bus: alljoyn_busobject,
) callconv(@import("std").os.windows.WINAPI) alljoyn_busattachment;
pub extern "MSAJApi" fn alljoyn_busobject_signal(
bus: alljoyn_busobject,
destination: ?[*:0]const u8,
sessionId: u32,
signal: alljoyn_interfacedescription_member,
args: alljoyn_msgarg,
numArgs: usize,
timeToLive: u16,
flags: u8,
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busobject_cancelsessionlessmessage_serial(
bus: alljoyn_busobject,
serialNumber: u32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busobject_cancelsessionlessmessage(
bus: alljoyn_busobject,
msg: alljoyn_message,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busobject_issecure(
bus: alljoyn_busobject,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_busobject_getannouncedinterfacenames(
bus: alljoyn_busobject,
interfaces: ?*const ?*i8,
numInterfaces: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_busobject_setannounceflag(
bus: alljoyn_busobject,
iface: alljoyn_interfacedescription,
isAnnounced: alljoyn_about_announceflag,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busobject_addinterface_announced(
bus: alljoyn_busobject,
iface: alljoyn_interfacedescription,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_create(
bus: alljoyn_busattachment,
service: ?[*:0]const u8,
path: ?[*:0]const u8,
sessionId: u32,
) callconv(@import("std").os.windows.WINAPI) alljoyn_proxybusobject;
pub extern "MSAJApi" fn alljoyn_proxybusobject_create_secure(
bus: alljoyn_busattachment,
service: ?[*:0]const u8,
path: ?[*:0]const u8,
sessionId: u32,
) callconv(@import("std").os.windows.WINAPI) alljoyn_proxybusobject;
pub extern "MSAJApi" fn alljoyn_proxybusobject_destroy(
proxyObj: alljoyn_proxybusobject,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_proxybusobject_addinterface(
proxyObj: alljoyn_proxybusobject,
iface: alljoyn_interfacedescription,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_addinterface_by_name(
proxyObj: alljoyn_proxybusobject,
name: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_getchildren(
proxyObj: alljoyn_proxybusobject,
children: ?*alljoyn_proxybusobject,
numChildren: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_proxybusobject_getchild(
proxyObj: alljoyn_proxybusobject,
path: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) alljoyn_proxybusobject;
pub extern "MSAJApi" fn alljoyn_proxybusobject_addchild(
proxyObj: alljoyn_proxybusobject,
child: alljoyn_proxybusobject,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_removechild(
proxyObj: alljoyn_proxybusobject,
path: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_introspectremoteobject(
proxyObj: alljoyn_proxybusobject,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_introspectremoteobjectasync(
proxyObj: alljoyn_proxybusobject,
callback: ?alljoyn_proxybusobject_listener_introspectcb_ptr,
context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_getproperty(
proxyObj: alljoyn_proxybusobject,
iface: ?[*:0]const u8,
property: ?[*:0]const u8,
value: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_getpropertyasync(
proxyObj: alljoyn_proxybusobject,
iface: ?[*:0]const u8,
property: ?[*:0]const u8,
callback: ?alljoyn_proxybusobject_listener_getpropertycb_ptr,
timeout: u32,
context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_getallproperties(
proxyObj: alljoyn_proxybusobject,
iface: ?[*:0]const u8,
values: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_getallpropertiesasync(
proxyObj: alljoyn_proxybusobject,
iface: ?[*:0]const u8,
callback: ?alljoyn_proxybusobject_listener_getallpropertiescb_ptr,
timeout: u32,
context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_setproperty(
proxyObj: alljoyn_proxybusobject,
iface: ?[*:0]const u8,
property: ?[*:0]const u8,
value: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_registerpropertieschangedlistener(
proxyObj: alljoyn_proxybusobject,
iface: ?[*:0]const u8,
properties: ?*const ?*i8,
numProperties: usize,
callback: ?alljoyn_proxybusobject_listener_propertieschanged_ptr,
context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_unregisterpropertieschangedlistener(
proxyObj: alljoyn_proxybusobject,
iface: ?[*:0]const u8,
callback: ?alljoyn_proxybusobject_listener_propertieschanged_ptr,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_setpropertyasync(
proxyObj: alljoyn_proxybusobject,
iface: ?[*:0]const u8,
property: ?[*:0]const u8,
value: alljoyn_msgarg,
callback: ?alljoyn_proxybusobject_listener_setpropertycb_ptr,
timeout: u32,
context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_methodcall(
proxyObj: alljoyn_proxybusobject,
ifaceName: ?[*:0]const u8,
methodName: ?[*:0]const u8,
args: alljoyn_msgarg,
numArgs: usize,
replyMsg: alljoyn_message,
timeout: u32,
flags: u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_methodcall_member(
proxyObj: alljoyn_proxybusobject,
method: alljoyn_interfacedescription_member,
args: alljoyn_msgarg,
numArgs: usize,
replyMsg: alljoyn_message,
timeout: u32,
flags: u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_methodcall_noreply(
proxyObj: alljoyn_proxybusobject,
ifaceName: ?[*:0]const u8,
methodName: ?[*:0]const u8,
args: alljoyn_msgarg,
numArgs: usize,
flags: u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_methodcall_member_noreply(
proxyObj: alljoyn_proxybusobject,
method: alljoyn_interfacedescription_member,
args: alljoyn_msgarg,
numArgs: usize,
flags: u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_methodcallasync(
proxyObj: alljoyn_proxybusobject,
ifaceName: ?[*:0]const u8,
methodName: ?[*:0]const u8,
replyFunc: ?alljoyn_messagereceiver_replyhandler_ptr,
args: alljoyn_msgarg,
numArgs: usize,
context: ?*anyopaque,
timeout: u32,
flags: u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_methodcallasync_member(
proxyObj: alljoyn_proxybusobject,
method: alljoyn_interfacedescription_member,
replyFunc: ?alljoyn_messagereceiver_replyhandler_ptr,
args: alljoyn_msgarg,
numArgs: usize,
context: ?*anyopaque,
timeout: u32,
flags: u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_parsexml(
proxyObj: alljoyn_proxybusobject,
xml: ?[*:0]const u8,
identifier: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_secureconnection(
proxyObj: alljoyn_proxybusobject,
forceAuth: i32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_secureconnectionasync(
proxyObj: alljoyn_proxybusobject,
forceAuth: i32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_getinterface(
proxyObj: alljoyn_proxybusobject,
iface: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) alljoyn_interfacedescription;
pub extern "MSAJApi" fn alljoyn_proxybusobject_getinterfaces(
proxyObj: alljoyn_proxybusobject,
ifaces: ?*const alljoyn_interfacedescription,
numIfaces: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_proxybusobject_getpath(
proxyObj: alljoyn_proxybusobject,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_proxybusobject_getservicename(
proxyObj: alljoyn_proxybusobject,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_proxybusobject_getuniquename(
proxyObj: alljoyn_proxybusobject,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_proxybusobject_getsessionid(
proxyObj: alljoyn_proxybusobject,
) callconv(@import("std").os.windows.WINAPI) u32;
pub extern "MSAJApi" fn alljoyn_proxybusobject_implementsinterface(
proxyObj: alljoyn_proxybusobject,
iface: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_proxybusobject_copy(
source: alljoyn_proxybusobject,
) callconv(@import("std").os.windows.WINAPI) alljoyn_proxybusobject;
pub extern "MSAJApi" fn alljoyn_proxybusobject_isvalid(
proxyObj: alljoyn_proxybusobject,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_proxybusobject_issecure(
proxyObj: alljoyn_proxybusobject,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_proxybusobject_enablepropertycaching(
proxyObj: alljoyn_proxybusobject,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_permissionconfigurationlistener_create(
callbacks: ?*const alljoyn_permissionconfigurationlistener_callbacks,
context: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) alljoyn_permissionconfigurationlistener;
pub extern "MSAJApi" fn alljoyn_permissionconfigurationlistener_destroy(
listener: alljoyn_permissionconfigurationlistener,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_sessionlistener_create(
callbacks: ?*const alljoyn_sessionlistener_callbacks,
context: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) alljoyn_sessionlistener;
pub extern "MSAJApi" fn alljoyn_sessionlistener_destroy(
listener: alljoyn_sessionlistener,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_sessionportlistener_create(
callbacks: ?*const alljoyn_sessionportlistener_callbacks,
context: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) alljoyn_sessionportlistener;
pub extern "MSAJApi" fn alljoyn_sessionportlistener_destroy(
listener: alljoyn_sessionportlistener,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_aboutlistener_create(
callback: ?*const alljoyn_aboutlistener_callback,
context: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) alljoyn_aboutlistener;
pub extern "MSAJApi" fn alljoyn_aboutlistener_destroy(
listener: alljoyn_aboutlistener,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_busattachment_create(
applicationName: ?[*:0]const u8,
allowRemoteMessages: i32,
) callconv(@import("std").os.windows.WINAPI) alljoyn_busattachment;
pub extern "MSAJApi" fn alljoyn_busattachment_create_concurrency(
applicationName: ?[*:0]const u8,
allowRemoteMessages: i32,
concurrency: u32,
) callconv(@import("std").os.windows.WINAPI) alljoyn_busattachment;
pub extern "MSAJApi" fn alljoyn_busattachment_destroy(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_busattachment_start(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_stop(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_join(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_getconcurrency(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) u32;
pub extern "MSAJApi" fn alljoyn_busattachment_getconnectspec(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_busattachment_enableconcurrentcallbacks(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_busattachment_createinterface(
bus: alljoyn_busattachment,
name: ?[*:0]const u8,
iface: ?*alljoyn_interfacedescription,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_createinterface_secure(
bus: alljoyn_busattachment,
name: ?[*:0]const u8,
iface: ?*alljoyn_interfacedescription,
secPolicy: alljoyn_interfacedescription_securitypolicy,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_connect(
bus: alljoyn_busattachment,
connectSpec: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_registerbuslistener(
bus: alljoyn_busattachment,
listener: alljoyn_buslistener,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_busattachment_unregisterbuslistener(
bus: alljoyn_busattachment,
listener: alljoyn_buslistener,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_busattachment_findadvertisedname(
bus: alljoyn_busattachment,
namePrefix: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_findadvertisednamebytransport(
bus: alljoyn_busattachment,
namePrefix: ?[*:0]const u8,
transports: u16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_cancelfindadvertisedname(
bus: alljoyn_busattachment,
namePrefix: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_cancelfindadvertisednamebytransport(
bus: alljoyn_busattachment,
namePrefix: ?[*:0]const u8,
transports: u16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_advertisename(
bus: alljoyn_busattachment,
name: ?[*:0]const u8,
transports: u16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_canceladvertisename(
bus: alljoyn_busattachment,
name: ?[*:0]const u8,
transports: u16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_getinterface(
bus: alljoyn_busattachment,
name: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) alljoyn_interfacedescription;
pub extern "MSAJApi" fn alljoyn_busattachment_joinsession(
bus: alljoyn_busattachment,
sessionHost: ?[*:0]const u8,
sessionPort: u16,
listener: alljoyn_sessionlistener,
sessionId: ?*u32,
opts: alljoyn_sessionopts,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_joinsessionasync(
bus: alljoyn_busattachment,
sessionHost: ?[*:0]const u8,
sessionPort: u16,
listener: alljoyn_sessionlistener,
opts: alljoyn_sessionopts,
callback: ?alljoyn_busattachment_joinsessioncb_ptr,
context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_registerbusobject(
bus: alljoyn_busattachment,
obj: alljoyn_busobject,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_registerbusobject_secure(
bus: alljoyn_busattachment,
obj: alljoyn_busobject,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_unregisterbusobject(
bus: alljoyn_busattachment,
object: alljoyn_busobject,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_busattachment_requestname(
bus: alljoyn_busattachment,
requestedName: ?[*:0]const u8,
flags: u32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_releasename(
bus: alljoyn_busattachment,
name: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_bindsessionport(
bus: alljoyn_busattachment,
sessionPort: ?*u16,
opts: alljoyn_sessionopts,
listener: alljoyn_sessionportlistener,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_unbindsessionport(
bus: alljoyn_busattachment,
sessionPort: u16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_enablepeersecurity(
bus: alljoyn_busattachment,
authMechanisms: ?[*:0]const u8,
listener: alljoyn_authlistener,
keyStoreFileName: ?[*:0]const u8,
isShared: i32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_enablepeersecuritywithpermissionconfigurationlistener(
bus: alljoyn_busattachment,
authMechanisms: ?[*:0]const u8,
authListener: alljoyn_authlistener,
keyStoreFileName: ?[*:0]const u8,
isShared: i32,
permissionConfigurationListener: alljoyn_permissionconfigurationlistener,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_ispeersecurityenabled(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_busattachment_createinterfacesfromxml(
bus: alljoyn_busattachment,
xml: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_getinterfaces(
bus: alljoyn_busattachment,
ifaces: ?*const alljoyn_interfacedescription,
numIfaces: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_busattachment_deleteinterface(
bus: alljoyn_busattachment,
iface: alljoyn_interfacedescription,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_isstarted(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_busattachment_isstopping(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_busattachment_isconnected(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "MSAJApi" fn alljoyn_busattachment_disconnect(
bus: alljoyn_busattachment,
unused: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_getdbusproxyobj(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) alljoyn_proxybusobject;
pub extern "MSAJApi" fn alljoyn_busattachment_getalljoynproxyobj(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) alljoyn_proxybusobject;
pub extern "MSAJApi" fn alljoyn_busattachment_getalljoyndebugobj(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) alljoyn_proxybusobject;
pub extern "MSAJApi" fn alljoyn_busattachment_getuniquename(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_busattachment_getglobalguidstring(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_busattachment_registersignalhandler(
bus: alljoyn_busattachment,
signal_handler: ?alljoyn_messagereceiver_signalhandler_ptr,
member: alljoyn_interfacedescription_member,
srcPath: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_registersignalhandlerwithrule(
bus: alljoyn_busattachment,
signal_handler: ?alljoyn_messagereceiver_signalhandler_ptr,
member: alljoyn_interfacedescription_member,
matchRule: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_unregistersignalhandler(
bus: alljoyn_busattachment,
signal_handler: ?alljoyn_messagereceiver_signalhandler_ptr,
member: alljoyn_interfacedescription_member,
srcPath: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_unregistersignalhandlerwithrule(
bus: alljoyn_busattachment,
signal_handler: ?alljoyn_messagereceiver_signalhandler_ptr,
member: alljoyn_interfacedescription_member,
matchRule: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_unregisterallhandlers(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_registerkeystorelistener(
bus: alljoyn_busattachment,
listener: alljoyn_keystorelistener,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_reloadkeystore(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_clearkeystore(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_busattachment_clearkeys(
bus: alljoyn_busattachment,
guid: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_setkeyexpiration(
bus: alljoyn_busattachment,
guid: ?[*:0]const u8,
timeout: u32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_getkeyexpiration(
bus: alljoyn_busattachment,
guid: ?[*:0]const u8,
timeout: ?*u32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_addlogonentry(
bus: alljoyn_busattachment,
authMechanism: ?[*:0]const u8,
userName: ?[*:0]const u8,
password: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_addmatch(
bus: alljoyn_busattachment,
rule: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_removematch(
bus: alljoyn_busattachment,
rule: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_setsessionlistener(
bus: alljoyn_busattachment,
sessionId: u32,
listener: alljoyn_sessionlistener,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_leavesession(
bus: alljoyn_busattachment,
sessionId: u32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_secureconnection(
bus: alljoyn_busattachment,
name: ?[*:0]const u8,
forceAuth: i32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_secureconnectionasync(
bus: alljoyn_busattachment,
name: ?[*:0]const u8,
forceAuth: i32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_removesessionmember(
bus: alljoyn_busattachment,
sessionId: u32,
memberName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_setlinktimeout(
bus: alljoyn_busattachment,
sessionid: u32,
linkTimeout: ?*u32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_setlinktimeoutasync(
bus: alljoyn_busattachment,
sessionid: u32,
linkTimeout: u32,
callback: ?alljoyn_busattachment_setlinktimeoutcb_ptr,
context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_namehasowner(
bus: alljoyn_busattachment,
name: ?[*:0]const u8,
hasOwner: ?*i32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_getpeerguid(
bus: alljoyn_busattachment,
name: ?[*:0]const u8,
guid: ?PSTR,
guidSz: ?*usize,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_setdaemondebug(
bus: alljoyn_busattachment,
module: ?[*:0]const u8,
level: u32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_gettimestamp(
) callconv(@import("std").os.windows.WINAPI) u32;
pub extern "MSAJApi" fn alljoyn_busattachment_ping(
bus: alljoyn_busattachment,
name: ?[*:0]const u8,
timeout: u32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_registeraboutlistener(
bus: alljoyn_busattachment,
aboutListener: alljoyn_aboutlistener,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_busattachment_unregisteraboutlistener(
bus: alljoyn_busattachment,
aboutListener: alljoyn_aboutlistener,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_busattachment_unregisterallaboutlisteners(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_busattachment_whoimplements_interfaces(
bus: alljoyn_busattachment,
implementsInterfaces: ?*const ?*i8,
numberInterfaces: usize,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_whoimplements_interface(
bus: alljoyn_busattachment,
implementsInterface: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_cancelwhoimplements_interfaces(
bus: alljoyn_busattachment,
implementsInterfaces: ?*const ?*i8,
numberInterfaces: usize,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_cancelwhoimplements_interface(
bus: alljoyn_busattachment,
implementsInterface: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_getpermissionconfigurator(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) alljoyn_permissionconfigurator;
pub extern "MSAJApi" fn alljoyn_busattachment_registerapplicationstatelistener(
bus: alljoyn_busattachment,
listener: alljoyn_applicationstatelistener,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_unregisterapplicationstatelistener(
bus: alljoyn_busattachment,
listener: alljoyn_applicationstatelistener,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_busattachment_deletedefaultkeystore(
applicationName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_abouticonobj_create(
bus: alljoyn_busattachment,
icon: ?*_alljoyn_abouticon_handle,
) callconv(@import("std").os.windows.WINAPI) ?*_alljoyn_abouticonobj_handle;
pub extern "MSAJApi" fn alljoyn_abouticonobj_destroy(
icon: ?*_alljoyn_abouticonobj_handle,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_abouticonproxy_create(
bus: alljoyn_busattachment,
busName: ?[*:0]const u8,
sessionId: u32,
) callconv(@import("std").os.windows.WINAPI) ?*_alljoyn_abouticonproxy_handle;
pub extern "MSAJApi" fn alljoyn_abouticonproxy_destroy(
proxy: ?*_alljoyn_abouticonproxy_handle,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_abouticonproxy_geticon(
proxy: ?*_alljoyn_abouticonproxy_handle,
icon: ?*_alljoyn_abouticon_handle,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_abouticonproxy_getversion(
proxy: ?*_alljoyn_abouticonproxy_handle,
version: ?*u16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutdatalistener_create(
callbacks: ?*const alljoyn_aboutdatalistener_callbacks,
context: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) alljoyn_aboutdatalistener;
pub extern "MSAJApi" fn alljoyn_aboutdatalistener_destroy(
listener: alljoyn_aboutdatalistener,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_aboutobj_create(
bus: alljoyn_busattachment,
isAnnounced: alljoyn_about_announceflag,
) callconv(@import("std").os.windows.WINAPI) alljoyn_aboutobj;
pub extern "MSAJApi" fn alljoyn_aboutobj_destroy(
obj: alljoyn_aboutobj,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_aboutobj_announce(
obj: alljoyn_aboutobj,
sessionPort: u16,
aboutData: alljoyn_aboutdata,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutobj_announce_using_datalistener(
obj: alljoyn_aboutobj,
sessionPort: u16,
aboutListener: alljoyn_aboutdatalistener,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutobj_unannounce(
obj: alljoyn_aboutobj,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutobjectdescription_create(
) callconv(@import("std").os.windows.WINAPI) alljoyn_aboutobjectdescription;
pub extern "MSAJApi" fn alljoyn_aboutobjectdescription_create_full(
arg: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) alljoyn_aboutobjectdescription;
pub extern "MSAJApi" fn alljoyn_aboutobjectdescription_createfrommsgarg(
description: alljoyn_aboutobjectdescription,
arg: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutobjectdescription_destroy(
description: alljoyn_aboutobjectdescription,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_aboutobjectdescription_getpaths(
description: alljoyn_aboutobjectdescription,
paths: ?*const ?*i8,
numPaths: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_aboutobjectdescription_getinterfaces(
description: alljoyn_aboutobjectdescription,
path: ?[*:0]const u8,
interfaces: ?*const ?*i8,
numInterfaces: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_aboutobjectdescription_getinterfacepaths(
description: alljoyn_aboutobjectdescription,
interfaceName: ?[*:0]const u8,
paths: ?*const ?*i8,
numPaths: usize,
) callconv(@import("std").os.windows.WINAPI) usize;
pub extern "MSAJApi" fn alljoyn_aboutobjectdescription_clear(
description: alljoyn_aboutobjectdescription,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_aboutobjectdescription_haspath(
description: alljoyn_aboutobjectdescription,
path: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u8;
pub extern "MSAJApi" fn alljoyn_aboutobjectdescription_hasinterface(
description: alljoyn_aboutobjectdescription,
interfaceName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u8;
pub extern "MSAJApi" fn alljoyn_aboutobjectdescription_hasinterfaceatpath(
description: alljoyn_aboutobjectdescription,
path: ?[*:0]const u8,
interfaceName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u8;
pub extern "MSAJApi" fn alljoyn_aboutobjectdescription_getmsgarg(
description: alljoyn_aboutobjectdescription,
msgArg: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutproxy_create(
bus: alljoyn_busattachment,
busName: ?[*:0]const u8,
sessionId: u32,
) callconv(@import("std").os.windows.WINAPI) alljoyn_aboutproxy;
pub extern "MSAJApi" fn alljoyn_aboutproxy_destroy(
proxy: alljoyn_aboutproxy,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_aboutproxy_getobjectdescription(
proxy: alljoyn_aboutproxy,
objectDesc: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutproxy_getaboutdata(
proxy: alljoyn_aboutproxy,
language: ?[*:0]const u8,
data: alljoyn_msgarg,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_aboutproxy_getversion(
proxy: alljoyn_aboutproxy,
version: ?*u16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_pinglistener_create(
callback: ?*const alljoyn_pinglistener_callback,
context: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) alljoyn_pinglistener;
pub extern "MSAJApi" fn alljoyn_pinglistener_destroy(
listener: alljoyn_pinglistener,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_autopinger_create(
bus: alljoyn_busattachment,
) callconv(@import("std").os.windows.WINAPI) alljoyn_autopinger;
pub extern "MSAJApi" fn alljoyn_autopinger_destroy(
autopinger: alljoyn_autopinger,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_autopinger_pause(
autopinger: alljoyn_autopinger,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_autopinger_resume(
autopinger: alljoyn_autopinger,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_autopinger_addpinggroup(
autopinger: alljoyn_autopinger,
group: ?[*:0]const u8,
listener: alljoyn_pinglistener,
pinginterval: u32,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_autopinger_removepinggroup(
autopinger: alljoyn_autopinger,
group: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_autopinger_setpinginterval(
autopinger: alljoyn_autopinger,
group: ?[*:0]const u8,
pinginterval: u32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_autopinger_adddestination(
autopinger: alljoyn_autopinger,
group: ?[*:0]const u8,
destination: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_autopinger_removedestination(
autopinger: alljoyn_autopinger,
group: ?[*:0]const u8,
destination: ?[*:0]const u8,
removeall: i32,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_getversion(
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_getbuildinfo(
) callconv(@import("std").os.windows.WINAPI) ?PSTR;
pub extern "MSAJApi" fn alljoyn_getnumericversion(
) callconv(@import("std").os.windows.WINAPI) u32;
pub extern "MSAJApi" fn alljoyn_init(
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_shutdown(
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_routerinit(
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_routerinitwithconfig(
configXml: ?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_routershutdown(
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_proxybusobject_ref_create(
proxy: alljoyn_proxybusobject,
) callconv(@import("std").os.windows.WINAPI) alljoyn_proxybusobject_ref;
pub extern "MSAJApi" fn alljoyn_proxybusobject_ref_get(
ref: alljoyn_proxybusobject_ref,
) callconv(@import("std").os.windows.WINAPI) alljoyn_proxybusobject;
pub extern "MSAJApi" fn alljoyn_proxybusobject_ref_incref(
ref: alljoyn_proxybusobject_ref,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_proxybusobject_ref_decref(
ref: alljoyn_proxybusobject_ref,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_observerlistener_create(
callback: ?*const alljoyn_observerlistener_callback,
context: ?*const anyopaque,
) callconv(@import("std").os.windows.WINAPI) alljoyn_observerlistener;
pub extern "MSAJApi" fn alljoyn_observerlistener_destroy(
listener: alljoyn_observerlistener,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_observer_create(
bus: alljoyn_busattachment,
mandatoryInterfaces: ?*const ?*i8,
numMandatoryInterfaces: usize,
) callconv(@import("std").os.windows.WINAPI) alljoyn_observer;
pub extern "MSAJApi" fn alljoyn_observer_destroy(
observer: alljoyn_observer,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_observer_registerlistener(
observer: alljoyn_observer,
listener: alljoyn_observerlistener,
triggerOnExisting: i32,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_observer_unregisterlistener(
observer: alljoyn_observer,
listener: alljoyn_observerlistener,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_observer_unregisteralllisteners(
observer: alljoyn_observer,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_observer_get(
observer: alljoyn_observer,
uniqueBusName: ?[*:0]const u8,
objectPath: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) alljoyn_proxybusobject_ref;
pub extern "MSAJApi" fn alljoyn_observer_getfirst(
observer: alljoyn_observer,
) callconv(@import("std").os.windows.WINAPI) alljoyn_proxybusobject_ref;
pub extern "MSAJApi" fn alljoyn_observer_getnext(
observer: alljoyn_observer,
proxyref: alljoyn_proxybusobject_ref,
) callconv(@import("std").os.windows.WINAPI) alljoyn_proxybusobject_ref;
pub extern "MSAJApi" fn alljoyn_passwordmanager_setcredentials(
authMechanism: ?[*:0]const u8,
password: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_getpermissionmanagementsessionport(
) callconv(@import("std").os.windows.WINAPI) u16;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_create(
bus: alljoyn_busattachment,
appBusName: ?*i8,
sessionId: u32,
) callconv(@import("std").os.windows.WINAPI) alljoyn_securityapplicationproxy;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_destroy(
proxy: alljoyn_securityapplicationproxy,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_claim(
proxy: alljoyn_securityapplicationproxy,
caKey: ?*i8,
identityCertificateChain: ?*i8,
groupId: ?*const u8,
groupSize: usize,
groupAuthority: ?*i8,
manifestsXmls: ?*?*i8,
manifestsCount: usize,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_getmanifesttemplate(
proxy: alljoyn_securityapplicationproxy,
manifestTemplateXml: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_manifesttemplate_destroy(
manifestTemplateXml: ?*i8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_getapplicationstate(
proxy: alljoyn_securityapplicationproxy,
applicationState: ?*alljoyn_applicationstate,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_getclaimcapabilities(
proxy: alljoyn_securityapplicationproxy,
capabilities: ?*u16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_getclaimcapabilitiesadditionalinfo(
proxy: alljoyn_securityapplicationproxy,
additionalInfo: ?*u16,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_getpolicy(
proxy: alljoyn_securityapplicationproxy,
policyXml: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_getdefaultpolicy(
proxy: alljoyn_securityapplicationproxy,
policyXml: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_policy_destroy(
policyXml: ?*i8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_updatepolicy(
proxy: alljoyn_securityapplicationproxy,
policyXml: ?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_updateidentity(
proxy: alljoyn_securityapplicationproxy,
identityCertificateChain: ?*i8,
manifestsXmls: ?*?*i8,
manifestsCount: usize,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_installmembership(
proxy: alljoyn_securityapplicationproxy,
membershipCertificateChain: ?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_reset(
proxy: alljoyn_securityapplicationproxy,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_resetpolicy(
proxy: alljoyn_securityapplicationproxy,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_startmanagement(
proxy: alljoyn_securityapplicationproxy,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_endmanagement(
proxy: alljoyn_securityapplicationproxy,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_geteccpublickey(
proxy: alljoyn_securityapplicationproxy,
eccPublicKey: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_eccpublickey_destroy(
eccPublicKey: ?*i8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_signmanifest(
unsignedManifestXml: ?*i8,
identityCertificatePem: ?*i8,
signingPrivateKeyPem: ?*i8,
signedManifestXml: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_manifest_destroy(
signedManifestXml: ?*i8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_computemanifestdigest(
unsignedManifestXml: ?*i8,
identityCertificatePem: ?*i8,
digest: ?*?*u8,
digestSize: ?*usize,
) callconv(@import("std").os.windows.WINAPI) QStatus;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_digest_destroy(
digest: ?*u8,
) callconv(@import("std").os.windows.WINAPI) void;
pub extern "MSAJApi" fn alljoyn_securityapplicationproxy_setmanifestsignature(
unsignedManifestXml: ?*i8,
identityCertificatePem: ?*i8,
signature: ?*const u8,
signatureSize: usize,
signedManifestXml: ?*?*i8,
) callconv(@import("std").os.windows.WINAPI) QStatus;
//--------------------------------------------------------------------------------
// Section: Unicode Aliases (0)
//--------------------------------------------------------------------------------
const thismodule = @This();
pub usingnamespace switch (@import("../zig.zig").unicode_mode) {
.ansi => struct {
},
.wide => struct {
},
.unspecified => if (@import("builtin").is_test) struct {
} else struct {
},
};
//--------------------------------------------------------------------------------
// Section: Imports (5)
//--------------------------------------------------------------------------------
const BOOL = @import("../foundation.zig").BOOL;
const HANDLE = @import("../foundation.zig").HANDLE;
const PSTR = @import("../foundation.zig").PSTR;
const PWSTR = @import("../foundation.zig").PWSTR;
const SECURITY_ATTRIBUTES = @import("../security.zig").SECURITY_ATTRIBUTES;
test {
// The following '_ = <FuncPtrType>' lines are a workaround for https://github.com/ziglang/zig/issues/4476
if (@hasDecl(@This(), "alljoyn_applicationstatelistener_state_ptr")) { _ = alljoyn_applicationstatelistener_state_ptr; }
if (@hasDecl(@This(), "alljoyn_keystorelistener_loadrequest_ptr")) { _ = alljoyn_keystorelistener_loadrequest_ptr; }
if (@hasDecl(@This(), "alljoyn_keystorelistener_storerequest_ptr")) { _ = alljoyn_keystorelistener_storerequest_ptr; }
if (@hasDecl(@This(), "alljoyn_keystorelistener_acquireexclusivelock_ptr")) { _ = alljoyn_keystorelistener_acquireexclusivelock_ptr; }
if (@hasDecl(@This(), "alljoyn_keystorelistener_releaseexclusivelock_ptr")) { _ = alljoyn_keystorelistener_releaseexclusivelock_ptr; }
if (@hasDecl(@This(), "alljoyn_authlistener_requestcredentials_ptr")) { _ = alljoyn_authlistener_requestcredentials_ptr; }
if (@hasDecl(@This(), "alljoyn_authlistener_requestcredentialsasync_ptr")) { _ = alljoyn_authlistener_requestcredentialsasync_ptr; }
if (@hasDecl(@This(), "alljoyn_authlistener_verifycredentials_ptr")) { _ = alljoyn_authlistener_verifycredentials_ptr; }
if (@hasDecl(@This(), "alljoyn_authlistener_verifycredentialsasync_ptr")) { _ = alljoyn_authlistener_verifycredentialsasync_ptr; }
if (@hasDecl(@This(), "alljoyn_authlistener_securityviolation_ptr")) { _ = alljoyn_authlistener_securityviolation_ptr; }
if (@hasDecl(@This(), "alljoyn_authlistener_authenticationcomplete_ptr")) { _ = alljoyn_authlistener_authenticationcomplete_ptr; }
if (@hasDecl(@This(), "alljoyn_buslistener_listener_registered_ptr")) { _ = alljoyn_buslistener_listener_registered_ptr; }
if (@hasDecl(@This(), "alljoyn_buslistener_listener_unregistered_ptr")) { _ = alljoyn_buslistener_listener_unregistered_ptr; }
if (@hasDecl(@This(), "alljoyn_buslistener_found_advertised_name_ptr")) { _ = alljoyn_buslistener_found_advertised_name_ptr; }
if (@hasDecl(@This(), "alljoyn_buslistener_lost_advertised_name_ptr")) { _ = alljoyn_buslistener_lost_advertised_name_ptr; }
if (@hasDecl(@This(), "alljoyn_buslistener_name_owner_changed_ptr")) { _ = alljoyn_buslistener_name_owner_changed_ptr; }
if (@hasDecl(@This(), "alljoyn_buslistener_bus_stopping_ptr")) { _ = alljoyn_buslistener_bus_stopping_ptr; }
if (@hasDecl(@This(), "alljoyn_buslistener_bus_disconnected_ptr")) { _ = alljoyn_buslistener_bus_disconnected_ptr; }
if (@hasDecl(@This(), "alljoyn_buslistener_bus_prop_changed_ptr")) { _ = alljoyn_buslistener_bus_prop_changed_ptr; }
if (@hasDecl(@This(), "alljoyn_interfacedescription_translation_callback_ptr")) { _ = alljoyn_interfacedescription_translation_callback_ptr; }
if (@hasDecl(@This(), "alljoyn_messagereceiver_methodhandler_ptr")) { _ = alljoyn_messagereceiver_methodhandler_ptr; }
if (@hasDecl(@This(), "alljoyn_messagereceiver_replyhandler_ptr")) { _ = alljoyn_messagereceiver_replyhandler_ptr; }
if (@hasDecl(@This(), "alljoyn_messagereceiver_signalhandler_ptr")) { _ = alljoyn_messagereceiver_signalhandler_ptr; }
if (@hasDecl(@This(), "alljoyn_busobject_prop_get_ptr")) { _ = alljoyn_busobject_prop_get_ptr; }
if (@hasDecl(@This(), "alljoyn_busobject_prop_set_ptr")) { _ = alljoyn_busobject_prop_set_ptr; }
if (@hasDecl(@This(), "alljoyn_busobject_object_registration_ptr")) { _ = alljoyn_busobject_object_registration_ptr; }
if (@hasDecl(@This(), "alljoyn_proxybusobject_listener_introspectcb_ptr")) { _ = alljoyn_proxybusobject_listener_introspectcb_ptr; }
if (@hasDecl(@This(), "alljoyn_proxybusobject_listener_getpropertycb_ptr")) { _ = alljoyn_proxybusobject_listener_getpropertycb_ptr; }
if (@hasDecl(@This(), "alljoyn_proxybusobject_listener_getallpropertiescb_ptr")) { _ = alljoyn_proxybusobject_listener_getallpropertiescb_ptr; }
if (@hasDecl(@This(), "alljoyn_proxybusobject_listener_setpropertycb_ptr")) { _ = alljoyn_proxybusobject_listener_setpropertycb_ptr; }
if (@hasDecl(@This(), "alljoyn_proxybusobject_listener_propertieschanged_ptr")) { _ = alljoyn_proxybusobject_listener_propertieschanged_ptr; }
if (@hasDecl(@This(), "alljoyn_permissionconfigurationlistener_factoryreset_ptr")) { _ = alljoyn_permissionconfigurationlistener_factoryreset_ptr; }
if (@hasDecl(@This(), "alljoyn_permissionconfigurationlistener_policychanged_ptr")) { _ = alljoyn_permissionconfigurationlistener_policychanged_ptr; }
if (@hasDecl(@This(), "alljoyn_permissionconfigurationlistener_startmanagement_ptr")) { _ = alljoyn_permissionconfigurationlistener_startmanagement_ptr; }
if (@hasDecl(@This(), "alljoyn_permissionconfigurationlistener_endmanagement_ptr")) { _ = alljoyn_permissionconfigurationlistener_endmanagement_ptr; }
if (@hasDecl(@This(), "alljoyn_sessionlistener_sessionlost_ptr")) { _ = alljoyn_sessionlistener_sessionlost_ptr; }
if (@hasDecl(@This(), "alljoyn_sessionlistener_sessionmemberadded_ptr")) { _ = alljoyn_sessionlistener_sessionmemberadded_ptr; }
if (@hasDecl(@This(), "alljoyn_sessionlistener_sessionmemberremoved_ptr")) { _ = alljoyn_sessionlistener_sessionmemberremoved_ptr; }
if (@hasDecl(@This(), "alljoyn_sessionportlistener_acceptsessionjoiner_ptr")) { _ = alljoyn_sessionportlistener_acceptsessionjoiner_ptr; }
if (@hasDecl(@This(), "alljoyn_sessionportlistener_sessionjoined_ptr")) { _ = alljoyn_sessionportlistener_sessionjoined_ptr; }
if (@hasDecl(@This(), "alljoyn_about_announced_ptr")) { _ = alljoyn_about_announced_ptr; }
if (@hasDecl(@This(), "alljoyn_busattachment_joinsessioncb_ptr")) { _ = alljoyn_busattachment_joinsessioncb_ptr; }
if (@hasDecl(@This(), "alljoyn_busattachment_setlinktimeoutcb_ptr")) { _ = alljoyn_busattachment_setlinktimeoutcb_ptr; }
if (@hasDecl(@This(), "alljoyn_aboutdatalistener_getaboutdata_ptr")) { _ = alljoyn_aboutdatalistener_getaboutdata_ptr; }
if (@hasDecl(@This(), "alljoyn_aboutdatalistener_getannouncedaboutdata_ptr")) { _ = alljoyn_aboutdatalistener_getannouncedaboutdata_ptr; }
if (@hasDecl(@This(), "alljoyn_autopinger_destination_lost_ptr")) { _ = alljoyn_autopinger_destination_lost_ptr; }
if (@hasDecl(@This(), "alljoyn_autopinger_destination_found_ptr")) { _ = alljoyn_autopinger_destination_found_ptr; }
if (@hasDecl(@This(), "alljoyn_observer_object_discovered_ptr")) { _ = alljoyn_observer_object_discovered_ptr; }
if (@hasDecl(@This(), "alljoyn_observer_object_lost_ptr")) { _ = alljoyn_observer_object_lost_ptr; }
@setEvalBranchQuota(
@import("std").meta.declarations(@This()).len * 3
);
// reference all the pub declarations
if (!@import("builtin").is_test) return;
inline for (@import("std").meta.declarations(@This())) |decl| {
if (decl.is_pub) {
_ = decl;
}
}
}
|
win32/devices/all_joyn.zig
|
pub const UIALL = @as(u32, 32768);
pub const LOGTOKEN_TYPE_MASK = @as(u32, 3);
pub const LOGTOKEN_UNSPECIFIED = @as(u32, 0);
pub const LOGTOKEN_NO_LOG = @as(u32, 1);
pub const LOGTOKEN_SETUPAPI_APPLOG = @as(u32, 2);
pub const LOGTOKEN_SETUPAPI_DEVLOG = @as(u32, 3);
pub const TXTLOG_SETUPAPI_DEVLOG = @as(u32, 1);
pub const TXTLOG_SETUPAPI_CMDLINE = @as(u32, 2);
pub const TXTLOG_SETUPAPI_BITS = @as(u32, 3);
pub const TXTLOG_ERROR = @as(u32, 1);
pub const TXTLOG_WARNING = @as(u32, 2);
pub const TXTLOG_SYSTEM_STATE_CHANGE = @as(u32, 3);
pub const TXTLOG_SUMMARY = @as(u32, 4);
pub const TXTLOG_DETAILS = @as(u32, 5);
pub const TXTLOG_VERBOSE = @as(u32, 6);
pub const TXTLOG_VERY_VERBOSE = @as(u32, 7);
pub const TXTLOG_RESERVED_FLAGS = @as(u32, 65520);
pub const TXTLOG_TIMESTAMP = @as(u32, 65536);
pub const TXTLOG_DEPTH_INCR = @as(u32, 131072);
pub const TXTLOG_DEPTH_DECR = @as(u32, 262144);
pub const TXTLOG_TAB_1 = @as(u32, 524288);
pub const TXTLOG_FLUSH_FILE = @as(u32, 1048576);
pub const TXTLOG_DEVINST = @as(u32, 1);
pub const TXTLOG_INF = @as(u32, 2);
pub const TXTLOG_FILEQ = @as(u32, 4);
pub const TXTLOG_COPYFILES = @as(u32, 8);
pub const TXTLOG_SIGVERIF = @as(u32, 32);
pub const TXTLOG_BACKUP = @as(u32, 128);
pub const TXTLOG_UI = @as(u32, 256);
pub const TXTLOG_UTIL = @as(u32, 512);
pub const TXTLOG_INFDB = @as(u32, 1024);
pub const TXTLOG_DRVSETUP = @as(u32, 4194304);
pub const TXTLOG_POLICY = @as(u32, 8388608);
pub const TXTLOG_NEWDEV = @as(u32, 16777216);
pub const TXTLOG_UMPNPMGR = @as(u32, 33554432);
pub const TXTLOG_DRIVER_STORE = @as(u32, 67108864);
pub const TXTLOG_SETUP = @as(u32, 134217728);
pub const TXTLOG_CMI = @as(u32, 268435456);
pub const TXTLOG_DEVMGR = @as(u32, 536870912);
pub const TXTLOG_INSTALLER = @as(u32, 1073741824);
pub const TXTLOG_VENDOR = @as(u32, 2147483648);
pub const CLSID_EvalCom2 = Guid.initString("6e5e1910-8053-4660-b795-6b612e29bc58");
pub const _WIN32_MSM = @as(u32, 100);
pub const LIBID_MsmMergeTypeLib = Guid.initString("0adda82f-2c26-11d2-ad65-00a0c9af11a6");
pub const CLSID_MsmMerge2 = Guid.initString("f94985d5-29f9-4743-9805-99bc3f35b678");
pub const _WIN32_MSI = @as(u32, 500);
pub const MAX_GUID_CHARS = @as(u32, 38);
pub const MAX_FEATURE_CHARS = @as(u32, 38);
pub const MSI_INVALID_HASH_IS_FATAL = @as(u32, 1);
pub const ERROR_ROLLBACK_DISABLED = @as(u32, 1653);
pub const MSI_NULL_INTEGER = @as(u32, 2147483648);
pub const INSTALLMESSAGE_TYPEMASK = @as(i32, -16777216);
pub const STREAM_FORMAT_COMPLIB_MODULE = @as(u32, 0);
pub const STREAM_FORMAT_COMPLIB_MANIFEST = @as(u32, 1);
pub const STREAM_FORMAT_WIN32_MODULE = @as(u32, 2);
pub const STREAM_FORMAT_WIN32_MANIFEST = @as(u32, 4);
pub const IASSEMBLYCACHEITEM_COMMIT_FLAG_REFRESH = @as(u32, 1);
pub const ASSEMBLYINFO_FLAG_INSTALLED = @as(u32, 1);
pub const ASSEMBLYINFO_FLAG_PAYLOADRESIDENT = @as(u32, 2);
pub const IASSEMBLYCACHEITEM_COMMIT_DISPOSITION_INSTALLED = @as(u32, 1);
pub const IASSEMBLYCACHEITEM_COMMIT_DISPOSITION_REFRESHED = @as(u32, 2);
pub const IASSEMBLYCACHEITEM_COMMIT_DISPOSITION_ALREADY_INSTALLED = @as(u32, 3);
pub const FUSION_REFCOUNT_UNINSTALL_SUBKEY_GUID = Guid.initString("<KEY>");
pub const FUSION_REFCOUNT_FILEPATH_GUID = Guid.initString("b02f9d65-fb77-4f7a-afa5-b391309f11c9");
pub const FUSION_REFCOUNT_OPAQUE_STRING_GUID = Guid.initString("2ec93463-b0c3-45e1-8364-327e96aea856");
pub const SFC_DISABLE_NORMAL = @as(u32, 0);
pub const SFC_DISABLE_ASK = @as(u32, 1);
pub const SFC_DISABLE_ONCE = @as(u32, 2);
pub const SFC_DISABLE_SETUP = @as(u32, 3);
pub const SFC_DISABLE_NOPOPUPS = @as(u32, 4);
pub const SFC_SCAN_NORMAL = @as(u32, 0);
pub const SFC_SCAN_ALWAYS = @as(u32, 1);
pub const SFC_SCAN_ONCE = @as(u32, 2);
pub const SFC_SCAN_IMMEDIATE = @as(u32, 3);
pub const SFC_QUOTA_DEFAULT = @as(u32, 50);
pub const PID_TITLE = @as(u32, 2);
pub const PID_SUBJECT = @as(u32, 3);
pub const PID_AUTHOR = @as(u32, 4);
pub const PID_KEYWORDS = @as(u32, 5);
pub const PID_COMMENTS = @as(u32, 6);
pub const PID_TEMPLATE = @as(u32, 7);
pub const PID_LASTAUTHOR = @as(u32, 8);
pub const PID_REVNUMBER = @as(u32, 9);
pub const PID_EDITTIME = @as(u32, 10);
pub const PID_LASTPRINTED = @as(u32, 11);
pub const PID_CREATE_DTM = @as(u32, 12);
pub const PID_LASTSAVE_DTM = @as(u32, 13);
pub const PID_PAGECOUNT = @as(u32, 14);
pub const PID_WORDCOUNT = @as(u32, 15);
pub const PID_CHARCOUNT = @as(u32, 16);
pub const PID_THUMBNAIL = @as(u32, 17);
pub const PID_APPNAME = @as(u32, 18);
pub const PID_MSIVERSION = @as(u32, 14);
pub const PID_MSISOURCE = @as(u32, 15);
pub const PID_MSIRESTRICT = @as(u32, 16);
pub const PATCH_OPTION_USE_BEST = @as(u32, 0);
pub const PATCH_OPTION_USE_LZX_BEST = @as(u32, 3);
pub const PATCH_OPTION_USE_LZX_A = @as(u32, 1);
pub const PATCH_OPTION_USE_LZX_B = @as(u32, 2);
pub const PATCH_OPTION_USE_LZX_LARGE = @as(u32, 4);
pub const PATCH_OPTION_NO_BINDFIX = @as(u32, 65536);
pub const PATCH_OPTION_NO_LOCKFIX = @as(u32, 131072);
pub const PATCH_OPTION_NO_REBASE = @as(u32, 262144);
pub const PATCH_OPTION_FAIL_IF_SAME_FILE = @as(u32, 524288);
pub const PATCH_OPTION_FAIL_IF_BIGGER = @as(u32, 1048576);
pub const PATCH_OPTION_NO_CHECKSUM = @as(u32, 2097152);
pub const PATCH_OPTION_NO_RESTIMEFIX = @as(u32, 4194304);
pub const PATCH_OPTION_NO_TIMESTAMP = @as(u32, 8388608);
pub const PATCH_OPTION_SIGNATURE_MD5 = @as(u32, 16777216);
pub const PATCH_OPTION_INTERLEAVE_FILES = @as(u32, 1073741824);
pub const PATCH_OPTION_RESERVED1 = @as(u32, 2147483648);
pub const PATCH_OPTION_VALID_FLAGS = @as(u32, 3237937159);
pub const PATCH_SYMBOL_NO_IMAGEHLP = @as(u32, 1);
pub const PATCH_SYMBOL_NO_FAILURES = @as(u32, 2);
pub const PATCH_SYMBOL_UNDECORATED_TOO = @as(u32, 4);
pub const PATCH_SYMBOL_RESERVED1 = @as(u32, 2147483648);
pub const PATCH_TRANSFORM_PE_RESOURCE_2 = @as(u32, 256);
pub const PATCH_TRANSFORM_PE_IRELOC_2 = @as(u32, 512);
pub const APPLY_OPTION_FAIL_IF_EXACT = @as(u32, 1);
pub const APPLY_OPTION_FAIL_IF_CLOSE = @as(u32, 2);
pub const APPLY_OPTION_TEST_ONLY = @as(u32, 4);
pub const APPLY_OPTION_VALID_FLAGS = @as(u32, 7);
pub const ERROR_PATCH_ENCODE_FAILURE = @as(u32, 3222155521);
pub const ERROR_PATCH_INVALID_OPTIONS = @as(u32, 3222155522);
pub const ERROR_PATCH_SAME_FILE = @as(u32, 3222155523);
pub const ERROR_PATCH_RETAIN_RANGES_DIFFER = @as(u32, 3222155524);
pub const ERROR_PATCH_BIGGER_THAN_COMPRESSED = @as(u32, 3222155525);
pub const ERROR_PATCH_IMAGEHLP_FAILURE = @as(u32, 3222155526);
pub const ERROR_PATCH_DECODE_FAILURE = @as(u32, 3222159617);
pub const ERROR_PATCH_CORRUPT = @as(u32, 3222159618);
pub const ERROR_PATCH_NEWER_FORMAT = @as(u32, 3222159619);
pub const ERROR_PATCH_WRONG_FILE = @as(u32, 3222159620);
pub const ERROR_PATCH_NOT_NECESSARY = @as(u32, 3222159621);
pub const ERROR_PATCH_NOT_AVAILABLE = @as(u32, 3222159622);
pub const ERROR_PCW_BASE = @as(u32, 3222163713);
pub const ERROR_PCW_PCP_DOESNT_EXIST = @as(u32, 3222163713);
pub const ERROR_PCW_PCP_BAD_FORMAT = @as(u32, 3222163714);
pub const ERROR_PCW_CANT_CREATE_TEMP_FOLDER = @as(u32, 3222163715);
pub const ERROR_PCW_MISSING_PATCH_PATH = @as(u32, 3222163716);
pub const ERROR_PCW_CANT_OVERWRITE_PATCH = @as(u32, 3222163717);
pub const ERROR_PCW_CANT_CREATE_PATCH_FILE = @as(u32, 3222163718);
pub const ERROR_PCW_MISSING_PATCH_GUID = @as(u32, 3222163719);
pub const ERROR_PCW_BAD_PATCH_GUID = @as(u32, 3222163720);
pub const ERROR_PCW_BAD_GUIDS_TO_REPLACE = @as(u32, 3222163721);
pub const ERROR_PCW_BAD_TARGET_PRODUCT_CODE_LIST = @as(u32, 3222163722);
pub const ERROR_PCW_NO_UPGRADED_IMAGES_TO_PATCH = @as(u32, 3222163723);
pub const ERROR_PCW_BAD_API_PATCHING_SYMBOL_FLAGS = @as(u32, 3222163725);
pub const ERROR_PCW_OODS_COPYING_MSI = @as(u32, 3222163726);
pub const ERROR_PCW_UPGRADED_IMAGE_NAME_TOO_LONG = @as(u32, 3222163727);
pub const ERROR_PCW_BAD_UPGRADED_IMAGE_NAME = @as(u32, 3222163728);
pub const ERROR_PCW_DUP_UPGRADED_IMAGE_NAME = @as(u32, 3222163729);
pub const ERROR_PCW_UPGRADED_IMAGE_PATH_TOO_LONG = @as(u32, 3222163730);
pub const ERROR_PCW_UPGRADED_IMAGE_PATH_EMPTY = @as(u32, 3222163731);
pub const ERROR_PCW_UPGRADED_IMAGE_PATH_NOT_EXIST = @as(u32, 3222163732);
pub const ERROR_PCW_UPGRADED_IMAGE_PATH_NOT_MSI = @as(u32, 3222163733);
pub const ERROR_PCW_UPGRADED_IMAGE_COMPRESSED = @as(u32, 3222163734);
pub const ERROR_PCW_TARGET_IMAGE_NAME_TOO_LONG = @as(u32, 3222163735);
pub const ERROR_PCW_BAD_TARGET_IMAGE_NAME = @as(u32, 3222163736);
pub const ERROR_PCW_DUP_TARGET_IMAGE_NAME = @as(u32, 3222163737);
pub const ERROR_PCW_TARGET_IMAGE_PATH_TOO_LONG = @as(u32, 3222163738);
pub const ERROR_PCW_TARGET_IMAGE_PATH_EMPTY = @as(u32, 3222163739);
pub const ERROR_PCW_TARGET_IMAGE_PATH_NOT_EXIST = @as(u32, 3222163740);
pub const ERROR_PCW_TARGET_IMAGE_PATH_NOT_MSI = @as(u32, 3222163741);
pub const ERROR_PCW_TARGET_IMAGE_COMPRESSED = @as(u32, 3222163742);
pub const ERROR_PCW_TARGET_BAD_PROD_VALIDATE = @as(u32, 3222163743);
pub const ERROR_PCW_TARGET_BAD_PROD_CODE_VAL = @as(u32, 3222163744);
pub const ERROR_PCW_UPGRADED_MISSING_SRC_FILES = @as(u32, 3222163745);
pub const ERROR_PCW_TARGET_MISSING_SRC_FILES = @as(u32, 3222163746);
pub const ERROR_PCW_IMAGE_FAMILY_NAME_TOO_LONG = @as(u32, 3222163747);
pub const ERROR_PCW_BAD_IMAGE_FAMILY_NAME = @as(u32, 3222163748);
pub const ERROR_PCW_DUP_IMAGE_FAMILY_NAME = @as(u32, 3222163749);
pub const ERROR_PCW_BAD_IMAGE_FAMILY_SRC_PROP = @as(u32, 3222163750);
pub const ERROR_PCW_UFILEDATA_LONG_FILE_TABLE_KEY = @as(u32, 3222163751);
pub const ERROR_PCW_UFILEDATA_BLANK_FILE_TABLE_KEY = @as(u32, 3222163752);
pub const ERROR_PCW_UFILEDATA_MISSING_FILE_TABLE_KEY = @as(u32, 3222163753);
pub const ERROR_PCW_EXTFILE_LONG_FILE_TABLE_KEY = @as(u32, 3222163754);
pub const ERROR_PCW_EXTFILE_BLANK_FILE_TABLE_KEY = @as(u32, 3222163755);
pub const ERROR_PCW_EXTFILE_BAD_FAMILY_FIELD = @as(u32, 3222163756);
pub const ERROR_PCW_EXTFILE_LONG_PATH_TO_FILE = @as(u32, 3222163757);
pub const ERROR_PCW_EXTFILE_BLANK_PATH_TO_FILE = @as(u32, 3222163758);
pub const ERROR_PCW_EXTFILE_MISSING_FILE = @as(u32, 3222163759);
pub const ERROR_PCW_BAD_FILE_SEQUENCE_START = @as(u32, 3222163770);
pub const ERROR_PCW_CANT_COPY_FILE_TO_TEMP_FOLDER = @as(u32, 3222163771);
pub const ERROR_PCW_CANT_CREATE_ONE_PATCH_FILE = @as(u32, 3222163772);
pub const ERROR_PCW_BAD_IMAGE_FAMILY_DISKID = @as(u32, 3222163773);
pub const ERROR_PCW_BAD_IMAGE_FAMILY_FILESEQSTART = @as(u32, 3222163774);
pub const ERROR_PCW_BAD_UPGRADED_IMAGE_FAMILY = @as(u32, 3222163775);
pub const ERROR_PCW_BAD_TARGET_IMAGE_UPGRADED = @as(u32, 3222163776);
pub const ERROR_PCW_DUP_TARGET_IMAGE_PACKCODE = @as(u32, 3222163777);
pub const ERROR_PCW_UFILEDATA_BAD_UPGRADED_FIELD = @as(u32, 3222163778);
pub const ERROR_PCW_MISMATCHED_PRODUCT_CODES = @as(u32, 3222163779);
pub const ERROR_PCW_MISMATCHED_PRODUCT_VERSIONS = @as(u32, 3222163780);
pub const ERROR_PCW_CANNOT_WRITE_DDF = @as(u32, 3222163781);
pub const ERROR_PCW_CANNOT_RUN_MAKECAB = @as(u32, 3222163782);
pub const ERROR_PCW_WRITE_SUMMARY_PROPERTIES = @as(u32, 3222163787);
pub const ERROR_PCW_TFILEDATA_LONG_FILE_TABLE_KEY = @as(u32, 3222163788);
pub const ERROR_PCW_TFILEDATA_BLANK_FILE_TABLE_KEY = @as(u32, 3222163789);
pub const ERROR_PCW_TFILEDATA_MISSING_FILE_TABLE_KEY = @as(u32, 3222163790);
pub const ERROR_PCW_TFILEDATA_BAD_TARGET_FIELD = @as(u32, 3222163791);
pub const ERROR_PCW_UPGRADED_IMAGE_PATCH_PATH_TOO_LONG = @as(u32, 3222163792);
pub const ERROR_PCW_UPGRADED_IMAGE_PATCH_PATH_NOT_EXIST = @as(u32, 3222163793);
pub const ERROR_PCW_UPGRADED_IMAGE_PATCH_PATH_NOT_MSI = @as(u32, 3222163794);
pub const ERROR_PCW_DUP_UPGRADED_IMAGE_PACKCODE = @as(u32, 3222163795);
pub const ERROR_PCW_UFILEIGNORE_BAD_UPGRADED_FIELD = @as(u32, 3222163796);
pub const ERROR_PCW_UFILEIGNORE_LONG_FILE_TABLE_KEY = @as(u32, 3222163797);
pub const ERROR_PCW_UFILEIGNORE_BLANK_FILE_TABLE_KEY = @as(u32, 3222163798);
pub const ERROR_PCW_UFILEIGNORE_BAD_FILE_TABLE_KEY = @as(u32, 3222163799);
pub const ERROR_PCW_FAMILY_RANGE_NAME_TOO_LONG = @as(u32, 3222163800);
pub const ERROR_PCW_BAD_FAMILY_RANGE_NAME = @as(u32, 3222163801);
pub const ERROR_PCW_FAMILY_RANGE_LONG_FILE_TABLE_KEY = @as(u32, 3222163802);
pub const ERROR_PCW_FAMILY_RANGE_BLANK_FILE_TABLE_KEY = @as(u32, 3222163803);
pub const ERROR_PCW_FAMILY_RANGE_LONG_RETAIN_OFFSETS = @as(u32, 3222163804);
pub const ERROR_PCW_FAMILY_RANGE_BLANK_RETAIN_OFFSETS = @as(u32, 3222163805);
pub const ERROR_PCW_FAMILY_RANGE_BAD_RETAIN_OFFSETS = @as(u32, 3222163806);
pub const ERROR_PCW_FAMILY_RANGE_LONG_RETAIN_LENGTHS = @as(u32, 3222163807);
pub const ERROR_PCW_FAMILY_RANGE_BLANK_RETAIN_LENGTHS = @as(u32, 3222163808);
pub const ERROR_PCW_FAMILY_RANGE_BAD_RETAIN_LENGTHS = @as(u32, 3222163809);
pub const ERROR_PCW_FAMILY_RANGE_COUNT_MISMATCH = @as(u32, 3222163810);
pub const ERROR_PCW_EXTFILE_LONG_IGNORE_OFFSETS = @as(u32, 3222163811);
pub const ERROR_PCW_EXTFILE_BAD_IGNORE_OFFSETS = @as(u32, 3222163812);
pub const ERROR_PCW_EXTFILE_LONG_IGNORE_LENGTHS = @as(u32, 3222163813);
pub const ERROR_PCW_EXTFILE_BAD_IGNORE_LENGTHS = @as(u32, 3222163814);
pub const ERROR_PCW_EXTFILE_IGNORE_COUNT_MISMATCH = @as(u32, 3222163815);
pub const ERROR_PCW_EXTFILE_LONG_RETAIN_OFFSETS = @as(u32, 3222163816);
pub const ERROR_PCW_EXTFILE_BAD_RETAIN_OFFSETS = @as(u32, 3222163817);
pub const ERROR_PCW_TFILEDATA_LONG_IGNORE_OFFSETS = @as(u32, 3222163819);
pub const ERROR_PCW_TFILEDATA_BAD_IGNORE_OFFSETS = @as(u32, 3222163820);
pub const ERROR_PCW_TFILEDATA_LONG_IGNORE_LENGTHS = @as(u32, 3222163821);
pub const ERROR_PCW_TFILEDATA_BAD_IGNORE_LENGTHS = @as(u32, 3222163822);
pub const ERROR_PCW_TFILEDATA_IGNORE_COUNT_MISMATCH = @as(u32, 3222163823);
pub const ERROR_PCW_TFILEDATA_LONG_RETAIN_OFFSETS = @as(u32, 3222163824);
pub const ERROR_PCW_TFILEDATA_BAD_RETAIN_OFFSETS = @as(u32, 3222163825);
pub const ERROR_PCW_CANT_GENERATE_TRANSFORM = @as(u32, 3222163827);
pub const ERROR_PCW_CANT_CREATE_SUMMARY_INFO = @as(u32, 3222163828);
pub const ERROR_PCW_CANT_GENERATE_TRANSFORM_POUND = @as(u32, 3222163829);
pub const ERROR_PCW_CANT_CREATE_SUMMARY_INFO_POUND = @as(u32, 3222163830);
pub const ERROR_PCW_BAD_UPGRADED_IMAGE_PRODUCT_CODE = @as(u32, 3222163831);
pub const ERROR_PCW_BAD_UPGRADED_IMAGE_PRODUCT_VERSION = @as(u32, 3222163832);
pub const ERROR_PCW_BAD_UPGRADED_IMAGE_UPGRADE_CODE = @as(u32, 3222163833);
pub const ERROR_PCW_BAD_TARGET_IMAGE_PRODUCT_CODE = @as(u32, 3222163834);
pub const ERROR_PCW_BAD_TARGET_IMAGE_PRODUCT_VERSION = @as(u32, 3222163835);
pub const ERROR_PCW_BAD_TARGET_IMAGE_UPGRADE_CODE = @as(u32, 3222163836);
pub const ERROR_PCW_MATCHED_PRODUCT_VERSIONS = @as(u32, 3222163837);
pub const ERROR_PCW_OBSOLETION_WITH_SEQUENCE_DATA = @as(u32, 3222163838);
pub const ERROR_PCW_OBSOLETION_WITH_MSI30 = @as(u32, 3222163839);
pub const ERROR_PCW_OBSOLETION_WITH_PATCHSEQUENCE = @as(u32, 3222163840);
pub const ERROR_PCW_CANNOT_CREATE_TABLE = @as(u32, 3222163841);
pub const ERROR_PCW_CANT_GENERATE_SEQUENCEINFO_MAJORUPGD = @as(u32, 3222163842);
pub const ERROR_PCW_MAJOR_UPGD_WITHOUT_SEQUENCING = @as(u32, 3222163843);
pub const ERROR_PCW_BAD_PRODUCTVERSION_VALIDATION = @as(u32, 3222163844);
pub const ERROR_PCW_BAD_TRANSFORMSET = @as(u32, 3222163845);
pub const ERROR_PCW_BAD_TGT_UPD_IMAGES = @as(u32, 3222163846);
pub const ERROR_PCW_BAD_SUPERCEDENCE = @as(u32, 3222163847);
pub const ERROR_PCW_BAD_SEQUENCE = @as(u32, 3222163848);
pub const ERROR_PCW_BAD_TARGET = @as(u32, 3222163849);
pub const ERROR_PCW_NULL_PATCHFAMILY = @as(u32, 3222163850);
pub const ERROR_PCW_NULL_SEQUENCE_NUMBER = @as(u32, 3222163851);
pub const ERROR_PCW_BAD_VERSION_STRING = @as(u32, 3222163852);
pub const ERROR_PCW_BAD_MAJOR_VERSION = @as(u32, 3222163853);
pub const ERROR_PCW_SEQUENCING_BAD_TARGET = @as(u32, 3222163854);
pub const ERROR_PCW_PATCHMETADATA_PROP_NOT_SET = @as(u32, 3222163855);
pub const ERROR_PCW_INVALID_PATCHMETADATA_PROP = @as(u32, 3222163856);
pub const ERROR_PCW_INVALID_SUPERCEDENCE = @as(u32, 3222163857);
pub const ERROR_PCW_DUPLICATE_SEQUENCE_RECORD = @as(u32, 3222163858);
pub const ERROR_PCW_WRONG_PATCHMETADATA_STRD_PROP = @as(u32, 3222163859);
pub const ERROR_PCW_INVALID_PARAMETER = @as(u32, 3222163860);
pub const ERROR_PCW_CREATEFILE_LOG_FAILED = @as(u32, 3222163861);
pub const ERROR_PCW_INVALID_LOG_LEVEL = @as(u32, 3222163862);
pub const ERROR_PCW_INVALID_UI_LEVEL = @as(u32, 3222163863);
pub const ERROR_PCW_ERROR_WRITING_TO_LOG = @as(u32, 3222163864);
pub const ERROR_PCW_OUT_OF_MEMORY = @as(u32, 3222163865);
pub const ERROR_PCW_UNKNOWN_ERROR = @as(u32, 3222163866);
pub const ERROR_PCW_UNKNOWN_INFO = @as(u32, 3222163867);
pub const ERROR_PCW_UNKNOWN_WARN = @as(u32, 3222163868);
pub const ERROR_PCW_OPEN_VIEW = @as(u32, 3222163869);
pub const ERROR_PCW_EXECUTE_VIEW = @as(u32, 3222163870);
pub const ERROR_PCW_VIEW_FETCH = @as(u32, 3222163871);
pub const ERROR_PCW_FAILED_EXPAND_PATH = @as(u32, 3222163872);
pub const ERROR_PCW_INTERNAL_ERROR = @as(u32, 3222163969);
pub const ERROR_PCW_INVALID_PCP_PROPERTY = @as(u32, 3222163970);
pub const ERROR_PCW_INVALID_PCP_TARGETIMAGES = @as(u32, 3222163971);
pub const ERROR_PCW_LAX_VALIDATION_FLAGS = @as(u32, 3222163972);
pub const ERROR_PCW_FAILED_CREATE_TRANSFORM = @as(u32, 3222163973);
pub const ERROR_PCW_CANT_DELETE_TEMP_FOLDER = @as(u32, 3222163974);
pub const ERROR_PCW_MISSING_DIRECTORY_TABLE = @as(u32, 3222163975);
pub const ERROR_PCW_INVALID_SUPERSEDENCE_VALUE = @as(u32, 3222163976);
pub const ERROR_PCW_INVALID_PATCH_TYPE_SEQUENCING = @as(u32, 3222163977);
pub const ERROR_PCW_CANT_READ_FILE = @as(u32, 3222163978);
pub const ERROR_PCW_TARGET_WRONG_PRODUCT_VERSION_COMP = @as(u32, 3222163979);
pub const ERROR_PCW_INVALID_PCP_UPGRADEDFILESTOIGNORE = @as(u32, 3222163980);
pub const ERROR_PCW_INVALID_PCP_UPGRADEDIMAGES = @as(u32, 3222163981);
pub const ERROR_PCW_INVALID_PCP_EXTERNALFILES = @as(u32, 3222163982);
pub const ERROR_PCW_INVALID_PCP_IMAGEFAMILIES = @as(u32, 3222163983);
pub const ERROR_PCW_INVALID_PCP_PATCHSEQUENCE = @as(u32, 3222163984);
pub const ERROR_PCW_INVALID_PCP_TARGETFILES_OPTIONALDATA = @as(u32, 3222163985);
pub const ERROR_PCW_INVALID_PCP_UPGRADEDFILES_OPTIONALDATA = @as(u32, 3222163986);
pub const ERROR_PCW_MISSING_PATCHMETADATA = @as(u32, 3222163987);
pub const ERROR_PCW_IMAGE_PATH_NOT_EXIST = @as(u32, 3222163988);
pub const ERROR_PCW_INVALID_RANGE_ELEMENT = @as(u32, 3222163989);
pub const ERROR_PCW_INVALID_MAJOR_VERSION = @as(u32, 3222163990);
pub const ERROR_PCW_INVALID_PCP_PROPERTIES = @as(u32, 3222163991);
pub const ERROR_PCW_INVALID_PCP_FAMILYFILERANGES = @as(u32, 3222163992);
pub const INFO_BASE = @as(u32, 3222229249);
pub const INFO_PASSED_MAIN_CONTROL = @as(u32, 3222229249);
pub const INFO_ENTERING_PHASE_I_VALIDATION = @as(u32, 3222229250);
pub const INFO_ENTERING_PHASE_I = @as(u32, 3222229251);
pub const INFO_PCP_PATH = @as(u32, 3222229252);
pub const INFO_TEMP_DIR = @as(u32, 3222229253);
pub const INFO_SET_OPTIONS = @as(u32, 3222229254);
pub const INFO_PROPERTY = @as(u32, 3222229255);
pub const INFO_ENTERING_PHASE_II = @as(u32, 3222229256);
pub const INFO_ENTERING_PHASE_III = @as(u32, 3222229257);
pub const INFO_ENTERING_PHASE_IV = @as(u32, 3222229258);
pub const INFO_ENTERING_PHASE_V = @as(u32, 3222229259);
pub const INFO_GENERATING_METADATA = @as(u32, 3222229265);
pub const INFO_TEMP_DIR_CLEANUP = @as(u32, 3222229266);
pub const INFO_PATCHCACHE_FILEINFO_FAILURE = @as(u32, 3222229267);
pub const INFO_PATCHCACHE_PCI_READFAILURE = @as(u32, 3222229268);
pub const INFO_PATCHCACHE_PCI_WRITEFAILURE = @as(u32, 3222229269);
pub const INFO_USING_USER_MSI_FOR_PATCH_TABLES = @as(u32, 3222229270);
pub const INFO_SUCCESSFUL_PATCH_CREATION = @as(u32, 3222229271);
pub const WARN_BASE = @as(u32, 3222294785);
pub const WARN_MAJOR_UPGRADE_PATCH = @as(u32, 3222294785);
pub const WARN_SEQUENCE_DATA_GENERATION_DISABLED = @as(u32, 3222294786);
pub const WARN_SEQUENCE_DATA_SUPERSEDENCE_IGNORED = @as(u32, 3222294787);
pub const WARN_IMPROPER_TRANSFORM_VALIDATION = @as(u32, 3222294788);
pub const WARN_PCW_MISMATCHED_PRODUCT_CODES = @as(u32, 3222294789);
pub const WARN_PCW_MISMATCHED_PRODUCT_VERSIONS = @as(u32, 3222294790);
pub const WARN_INVALID_TRANSFORM_VALIDATION = @as(u32, 3222294791);
pub const WARN_BAD_MAJOR_VERSION = @as(u32, 3222294792);
pub const WARN_FILE_VERSION_DOWNREV = @as(u32, 3222294793);
pub const WARN_EQUAL_FILE_VERSION = @as(u32, 3222294794);
pub const WARN_PATCHPROPERTYNOTSET = @as(u32, 3222294795);
pub const WARN_OBSOLETION_WITH_SEQUENCE_DATA = @as(u32, 3222294802);
pub const WARN_OBSOLETION_WITH_MSI30 = @as(u32, 3222294801);
pub const WARN_OBSOLETION_WITH_PATCHSEQUENCE = @as(u32, 3222294803);
pub const DELTA_MAX_HASH_SIZE = @as(u32, 32);
pub const cchMaxInteger = @as(i32, 12);
pub const LOGNONE = @as(u32, 0);
pub const LOGINFO = @as(u32, 1);
pub const LOGWARN = @as(u32, 2);
pub const LOGERR = @as(u32, 4);
pub const LOGPERFMESSAGES = @as(u32, 8);
pub const LOGALL = @as(u32, 15);
pub const UINONE = @as(u32, 0);
pub const UILOGBITS = @as(u32, 15);
pub const DEFAULT_MINIMUM_REQUIRED_MSI_VERSION = @as(u32, 100);
pub const DEFAULT_FILE_SEQUENCE_START = @as(u32, 2);
pub const DEFAULT_DISK_ID = @as(u32, 2);
//--------------------------------------------------------------------------------
// Section: Types (179)
//--------------------------------------------------------------------------------
pub const MSIASSEMBLYINFO = enum(u32) {
NETASSEMBLY = 0,
WIN32ASSEMBLY = 1,
};
pub const MSIASSEMBLYINFO_NETASSEMBLY = MSIASSEMBLYINFO.NETASSEMBLY;
pub const MSIASSEMBLYINFO_WIN32ASSEMBLY = MSIASSEMBLYINFO.WIN32ASSEMBLY;
pub const IASSEMBLYCACHE_UNINSTALL_DISPOSITION = enum(u32) {
UNINSTALLED = 1,
STILL_IN_USE = 2,
ALREADY_UNINSTALLED = 3,
DELETE_PENDING = 4,
};
pub const IASSEMBLYCACHE_UNINSTALL_DISPOSITION_UNINSTALLED = IASSEMBLYCACHE_UNINSTALL_DISPOSITION.UNINSTALLED;
pub const IASSEMBLYCACHE_UNINSTALL_DISPOSITION_STILL_IN_USE = IASSEMBLYCACHE_UNINSTALL_DISPOSITION.STILL_IN_USE;
pub const IASSEMBLYCACHE_UNINSTALL_DISPOSITION_ALREADY_UNINSTALLED = IASSEMBLYCACHE_UNINSTALL_DISPOSITION.ALREADY_UNINSTALLED;
pub const IASSEMBLYCACHE_UNINSTALL_DISPOSITION_DELETE_PENDING = IASSEMBLYCACHE_UNINSTALL_DISPOSITION.DELETE_PENDING;
pub const QUERYASMINFO_FLAGS = enum(u32) {
E = 1,
_,
pub fn initFlags(o: struct {
E: u1 = 0,
}) QUERYASMINFO_FLAGS {
return @intToEnum(QUERYASMINFO_FLAGS,
(if (o.E == 1) @enumToInt(QUERYASMINFO_FLAGS.E) else 0)
);
}
};
pub const QUERYASMINFO_FLAG_VALIDATE = QUERYASMINFO_FLAGS.E;
// TODO: this type has a FreeFunc 'MsiCloseHandle', what can Zig do with this information?
pub const MSIHANDLE = u32;
pub const RESULTTYPES = enum(i32) {
Unknown = 0,
Error = 1,
Warning = 2,
Info = 3,
};
pub const ieUnknown = RESULTTYPES.Unknown;
pub const ieError = RESULTTYPES.Error;
pub const ieWarning = RESULTTYPES.Warning;
pub const ieInfo = RESULTTYPES.Info;
pub const STATUSTYPES = enum(i32) {
GetCUB = 0,
ICECount = 1,
Merge = 2,
SummaryInfo = 3,
CreateEngine = 4,
Starting = 5,
RunICE = 6,
Shutdown = 7,
Success = 8,
Fail = 9,
Cancel = 10,
};
pub const ieStatusGetCUB = STATUSTYPES.GetCUB;
pub const ieStatusICECount = STATUSTYPES.ICECount;
pub const ieStatusMerge = STATUSTYPES.Merge;
pub const ieStatusSummaryInfo = STATUSTYPES.SummaryInfo;
pub const ieStatusCreateEngine = STATUSTYPES.CreateEngine;
pub const ieStatusStarting = STATUSTYPES.Starting;
pub const ieStatusRunICE = STATUSTYPES.RunICE;
pub const ieStatusShutdown = STATUSTYPES.Shutdown;
pub const ieStatusSuccess = STATUSTYPES.Success;
pub const ieStatusFail = STATUSTYPES.Fail;
pub const ieStatusCancel = STATUSTYPES.Cancel;
pub const LPDISPLAYVAL = fn(
pContext: ?*anyopaque,
uiType: RESULTTYPES,
szwVal: ?[*:0]const u16,
szwDescription: ?[*:0]const u16,
szwLocation: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const LPEVALCOMCALLBACK = fn(
iStatus: STATUSTYPES,
szData: ?[*:0]const u16,
pContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) BOOL;
const IID_IValidate_Value = Guid.initString("e482e5c6-e31e-4143-a2e6-dbc3d8e4b8d3");
pub const IID_IValidate = &IID_IValidate_Value;
pub const IValidate = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
OpenDatabase: fn(
self: *const IValidate,
szDatabase: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
OpenCUB: fn(
self: *const IValidate,
szCUBFile: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CloseDatabase: fn(
self: *const IValidate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CloseCUB: fn(
self: *const IValidate,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetDisplay: fn(
self: *const IValidate,
pDisplayFunction: ?LPDISPLAYVAL,
pContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetStatus: fn(
self: *const IValidate,
pStatusFunction: ?LPEVALCOMCALLBACK,
pContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Validate: fn(
self: *const IValidate,
wzICEs: ?[*: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 IValidate_OpenDatabase(self: *const T, szDatabase: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IValidate.VTable, self.vtable).OpenDatabase(@ptrCast(*const IValidate, self), szDatabase);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IValidate_OpenCUB(self: *const T, szCUBFile: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IValidate.VTable, self.vtable).OpenCUB(@ptrCast(*const IValidate, self), szCUBFile);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IValidate_CloseDatabase(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IValidate.VTable, self.vtable).CloseDatabase(@ptrCast(*const IValidate, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IValidate_CloseCUB(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IValidate.VTable, self.vtable).CloseCUB(@ptrCast(*const IValidate, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IValidate_SetDisplay(self: *const T, pDisplayFunction: ?LPDISPLAYVAL, pContext: ?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IValidate.VTable, self.vtable).SetDisplay(@ptrCast(*const IValidate, self), pDisplayFunction, pContext);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IValidate_SetStatus(self: *const T, pStatusFunction: ?LPEVALCOMCALLBACK, pContext: ?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IValidate.VTable, self.vtable).SetStatus(@ptrCast(*const IValidate, self), pStatusFunction, pContext);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IValidate_Validate(self: *const T, wzICEs: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IValidate.VTable, self.vtable).Validate(@ptrCast(*const IValidate, self), wzICEs);
}
};}
pub usingnamespace MethodMixin(@This());
};
const CLSID_MsmMerge_Value = Guid.initString("0adda830-2c26-11d2-ad65-00a0c9af11a6");
pub const CLSID_MsmMerge = &CLSID_MsmMerge_Value;
pub const msmErrorType = enum(i32) {
LanguageUnsupported = 1,
LanguageFailed = 2,
Exclusion = 3,
TableMerge = 4,
ResequenceMerge = 5,
FileCreate = 6,
DirCreate = 7,
FeatureRequired = 8,
};
pub const msmErrorLanguageUnsupported = msmErrorType.LanguageUnsupported;
pub const msmErrorLanguageFailed = msmErrorType.LanguageFailed;
pub const msmErrorExclusion = msmErrorType.Exclusion;
pub const msmErrorTableMerge = msmErrorType.TableMerge;
pub const msmErrorResequenceMerge = msmErrorType.ResequenceMerge;
pub const msmErrorFileCreate = msmErrorType.FileCreate;
pub const msmErrorDirCreate = msmErrorType.DirCreate;
pub const msmErrorFeatureRequired = msmErrorType.FeatureRequired;
const IID_IEnumMsmString_Value = Guid.initString("0adda826-2c26-11d2-ad65-00a0c9af11a6");
pub const IID_IEnumMsmString = &IID_IEnumMsmString_Value;
pub const IEnumMsmString = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Next: fn(
self: *const IEnumMsmString,
cFetch: u32,
rgbstrStrings: ?*?BSTR,
pcFetched: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Skip: fn(
self: *const IEnumMsmString,
cSkip: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reset: fn(
self: *const IEnumMsmString,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clone: fn(
self: *const IEnumMsmString,
pemsmStrings: ?*?*IEnumMsmString,
) 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 IEnumMsmString_Next(self: *const T, cFetch: u32, rgbstrStrings: ?*?BSTR, pcFetched: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumMsmString.VTable, self.vtable).Next(@ptrCast(*const IEnumMsmString, self), cFetch, rgbstrStrings, pcFetched);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumMsmString_Skip(self: *const T, cSkip: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumMsmString.VTable, self.vtable).Skip(@ptrCast(*const IEnumMsmString, self), cSkip);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumMsmString_Reset(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumMsmString.VTable, self.vtable).Reset(@ptrCast(*const IEnumMsmString, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumMsmString_Clone(self: *const T, pemsmStrings: ?*?*IEnumMsmString) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumMsmString.VTable, self.vtable).Clone(@ptrCast(*const IEnumMsmString, self), pemsmStrings);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IMsmStrings_Value = Guid.initString("0adda827-2c26-11d2-ad65-00a0c9af11a6");
pub const IID_IMsmStrings = &IID_IMsmStrings_Value;
pub const IMsmStrings = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Item: fn(
self: *const IMsmStrings,
Item: i32,
Return: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const IMsmStrings,
Count: ?*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 IMsmStrings,
NewEnum: ?*?*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 IMsmStrings_get_Item(self: *const T, Item: i32, Return: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmStrings.VTable, self.vtable).get_Item(@ptrCast(*const IMsmStrings, self), Item, Return);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmStrings_get_Count(self: *const T, Count: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmStrings.VTable, self.vtable).get_Count(@ptrCast(*const IMsmStrings, self), Count);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmStrings_get__NewEnum(self: *const T, NewEnum: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmStrings.VTable, self.vtable).get__NewEnum(@ptrCast(*const IMsmStrings, self), NewEnum);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IMsmError_Value = Guid.initString("0adda828-2c26-11d2-ad65-00a0c9af11a6");
pub const IID_IMsmError = &IID_IMsmError_Value;
pub const IMsmError = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Type: fn(
self: *const IMsmError,
ErrorType: ?*msmErrorType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Path: fn(
self: *const IMsmError,
ErrorPath: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Language: fn(
self: *const IMsmError,
ErrorLanguage: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DatabaseTable: fn(
self: *const IMsmError,
ErrorTable: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DatabaseKeys: fn(
self: *const IMsmError,
ErrorKeys: ?*?*IMsmStrings,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ModuleTable: fn(
self: *const IMsmError,
ErrorTable: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ModuleKeys: fn(
self: *const IMsmError,
ErrorKeys: ?*?*IMsmStrings,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmError_get_Type(self: *const T, ErrorType: ?*msmErrorType) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmError.VTable, self.vtable).get_Type(@ptrCast(*const IMsmError, self), ErrorType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmError_get_Path(self: *const T, ErrorPath: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmError.VTable, self.vtable).get_Path(@ptrCast(*const IMsmError, self), ErrorPath);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmError_get_Language(self: *const T, ErrorLanguage: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmError.VTable, self.vtable).get_Language(@ptrCast(*const IMsmError, self), ErrorLanguage);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmError_get_DatabaseTable(self: *const T, ErrorTable: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmError.VTable, self.vtable).get_DatabaseTable(@ptrCast(*const IMsmError, self), ErrorTable);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmError_get_DatabaseKeys(self: *const T, ErrorKeys: ?*?*IMsmStrings) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmError.VTable, self.vtable).get_DatabaseKeys(@ptrCast(*const IMsmError, self), ErrorKeys);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmError_get_ModuleTable(self: *const T, ErrorTable: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmError.VTable, self.vtable).get_ModuleTable(@ptrCast(*const IMsmError, self), ErrorTable);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmError_get_ModuleKeys(self: *const T, ErrorKeys: ?*?*IMsmStrings) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmError.VTable, self.vtable).get_ModuleKeys(@ptrCast(*const IMsmError, self), ErrorKeys);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IEnumMsmError_Value = Guid.initString("0adda829-2c26-11d2-ad65-00a0c9af11a6");
pub const IID_IEnumMsmError = &IID_IEnumMsmError_Value;
pub const IEnumMsmError = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Next: fn(
self: *const IEnumMsmError,
cFetch: u32,
rgmsmErrors: ?*?*IMsmError,
pcFetched: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Skip: fn(
self: *const IEnumMsmError,
cSkip: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reset: fn(
self: *const IEnumMsmError,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clone: fn(
self: *const IEnumMsmError,
pemsmErrors: ?*?*IEnumMsmError,
) 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 IEnumMsmError_Next(self: *const T, cFetch: u32, rgmsmErrors: ?*?*IMsmError, pcFetched: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumMsmError.VTable, self.vtable).Next(@ptrCast(*const IEnumMsmError, self), cFetch, rgmsmErrors, pcFetched);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumMsmError_Skip(self: *const T, cSkip: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumMsmError.VTable, self.vtable).Skip(@ptrCast(*const IEnumMsmError, self), cSkip);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumMsmError_Reset(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumMsmError.VTable, self.vtable).Reset(@ptrCast(*const IEnumMsmError, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumMsmError_Clone(self: *const T, pemsmErrors: ?*?*IEnumMsmError) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumMsmError.VTable, self.vtable).Clone(@ptrCast(*const IEnumMsmError, self), pemsmErrors);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IMsmErrors_Value = Guid.initString("0adda82a-2c26-11d2-ad65-00a0c9af11a6");
pub const IID_IMsmErrors = &IID_IMsmErrors_Value;
pub const IMsmErrors = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Item: fn(
self: *const IMsmErrors,
Item: i32,
Return: ?*?*IMsmError,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const IMsmErrors,
Count: ?*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 IMsmErrors,
NewEnum: ?*?*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 IMsmErrors_get_Item(self: *const T, Item: i32, Return: ?*?*IMsmError) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmErrors.VTable, self.vtable).get_Item(@ptrCast(*const IMsmErrors, self), Item, Return);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmErrors_get_Count(self: *const T, Count: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmErrors.VTable, self.vtable).get_Count(@ptrCast(*const IMsmErrors, self), Count);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmErrors_get__NewEnum(self: *const T, NewEnum: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmErrors.VTable, self.vtable).get__NewEnum(@ptrCast(*const IMsmErrors, self), NewEnum);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IMsmDependency_Value = Guid.initString("0adda82b-2c26-11d2-ad65-00a0c9af11a6");
pub const IID_IMsmDependency = &IID_IMsmDependency_Value;
pub const IMsmDependency = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Module: fn(
self: *const IMsmDependency,
Module: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Language: fn(
self: *const IMsmDependency,
Language: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Version: fn(
self: *const IMsmDependency,
Version: ?*?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 IMsmDependency_get_Module(self: *const T, Module: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmDependency.VTable, self.vtable).get_Module(@ptrCast(*const IMsmDependency, self), Module);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmDependency_get_Language(self: *const T, Language: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmDependency.VTable, self.vtable).get_Language(@ptrCast(*const IMsmDependency, self), Language);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmDependency_get_Version(self: *const T, Version: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmDependency.VTable, self.vtable).get_Version(@ptrCast(*const IMsmDependency, self), Version);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IEnumMsmDependency_Value = Guid.initString("0adda82c-2c26-11d2-ad65-00a0c9af11a6");
pub const IID_IEnumMsmDependency = &IID_IEnumMsmDependency_Value;
pub const IEnumMsmDependency = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Next: fn(
self: *const IEnumMsmDependency,
cFetch: u32,
rgmsmDependencies: ?*?*IMsmDependency,
pcFetched: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Skip: fn(
self: *const IEnumMsmDependency,
cSkip: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reset: fn(
self: *const IEnumMsmDependency,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clone: fn(
self: *const IEnumMsmDependency,
pemsmDependencies: ?*?*IEnumMsmDependency,
) 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 IEnumMsmDependency_Next(self: *const T, cFetch: u32, rgmsmDependencies: ?*?*IMsmDependency, pcFetched: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumMsmDependency.VTable, self.vtable).Next(@ptrCast(*const IEnumMsmDependency, self), cFetch, rgmsmDependencies, pcFetched);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumMsmDependency_Skip(self: *const T, cSkip: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumMsmDependency.VTable, self.vtable).Skip(@ptrCast(*const IEnumMsmDependency, self), cSkip);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumMsmDependency_Reset(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumMsmDependency.VTable, self.vtable).Reset(@ptrCast(*const IEnumMsmDependency, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumMsmDependency_Clone(self: *const T, pemsmDependencies: ?*?*IEnumMsmDependency) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumMsmDependency.VTable, self.vtable).Clone(@ptrCast(*const IEnumMsmDependency, self), pemsmDependencies);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IMsmDependencies_Value = Guid.initString("0adda82d-2c26-11d2-ad65-00a0c9af11a6");
pub const IID_IMsmDependencies = &IID_IMsmDependencies_Value;
pub const IMsmDependencies = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Item: fn(
self: *const IMsmDependencies,
Item: i32,
Return: ?*?*IMsmDependency,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const IMsmDependencies,
Count: ?*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 IMsmDependencies,
NewEnum: ?*?*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 IMsmDependencies_get_Item(self: *const T, Item: i32, Return: ?*?*IMsmDependency) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmDependencies.VTable, self.vtable).get_Item(@ptrCast(*const IMsmDependencies, self), Item, Return);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmDependencies_get_Count(self: *const T, Count: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmDependencies.VTable, self.vtable).get_Count(@ptrCast(*const IMsmDependencies, self), Count);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmDependencies_get__NewEnum(self: *const T, NewEnum: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmDependencies.VTable, self.vtable).get__NewEnum(@ptrCast(*const IMsmDependencies, self), NewEnum);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IMsmMerge_Value = Guid.initString("0adda82e-2c26-11d2-ad65-00a0c9af11a6");
pub const IID_IMsmMerge = &IID_IMsmMerge_Value;
pub const IMsmMerge = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
OpenDatabase: fn(
self: *const IMsmMerge,
Path: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
OpenModule: fn(
self: *const IMsmMerge,
Path: ?BSTR,
Language: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CloseDatabase: fn(
self: *const IMsmMerge,
Commit: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CloseModule: fn(
self: *const IMsmMerge,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
OpenLog: fn(
self: *const IMsmMerge,
Path: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CloseLog: fn(
self: *const IMsmMerge,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Log: fn(
self: *const IMsmMerge,
Message: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Errors: fn(
self: *const IMsmMerge,
Errors: ?*?*IMsmErrors,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Dependencies: fn(
self: *const IMsmMerge,
Dependencies: ?*?*IMsmDependencies,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Merge: fn(
self: *const IMsmMerge,
Feature: ?BSTR,
RedirectDir: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Connect: fn(
self: *const IMsmMerge,
Feature: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ExtractCAB: fn(
self: *const IMsmMerge,
FileName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ExtractFiles: fn(
self: *const IMsmMerge,
Path: ?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 IMsmMerge_OpenDatabase(self: *const T, Path: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmMerge.VTable, self.vtable).OpenDatabase(@ptrCast(*const IMsmMerge, self), Path);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmMerge_OpenModule(self: *const T, Path: ?BSTR, Language: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmMerge.VTable, self.vtable).OpenModule(@ptrCast(*const IMsmMerge, self), Path, Language);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmMerge_CloseDatabase(self: *const T, Commit: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmMerge.VTable, self.vtable).CloseDatabase(@ptrCast(*const IMsmMerge, self), Commit);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmMerge_CloseModule(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmMerge.VTable, self.vtable).CloseModule(@ptrCast(*const IMsmMerge, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmMerge_OpenLog(self: *const T, Path: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmMerge.VTable, self.vtable).OpenLog(@ptrCast(*const IMsmMerge, self), Path);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmMerge_CloseLog(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmMerge.VTable, self.vtable).CloseLog(@ptrCast(*const IMsmMerge, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmMerge_Log(self: *const T, Message: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmMerge.VTable, self.vtable).Log(@ptrCast(*const IMsmMerge, self), Message);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmMerge_get_Errors(self: *const T, Errors: ?*?*IMsmErrors) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmMerge.VTable, self.vtable).get_Errors(@ptrCast(*const IMsmMerge, self), Errors);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmMerge_get_Dependencies(self: *const T, Dependencies: ?*?*IMsmDependencies) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmMerge.VTable, self.vtable).get_Dependencies(@ptrCast(*const IMsmMerge, self), Dependencies);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmMerge_Merge(self: *const T, Feature: ?BSTR, RedirectDir: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmMerge.VTable, self.vtable).Merge(@ptrCast(*const IMsmMerge, self), Feature, RedirectDir);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmMerge_Connect(self: *const T, Feature: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmMerge.VTable, self.vtable).Connect(@ptrCast(*const IMsmMerge, self), Feature);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmMerge_ExtractCAB(self: *const T, FileName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmMerge.VTable, self.vtable).ExtractCAB(@ptrCast(*const IMsmMerge, self), FileName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmMerge_ExtractFiles(self: *const T, Path: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmMerge.VTable, self.vtable).ExtractFiles(@ptrCast(*const IMsmMerge, self), Path);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IMsmGetFiles_Value = Guid.initString("7041ae26-2d78-11d2-888a-00a0c981b015");
pub const IID_IMsmGetFiles = &IID_IMsmGetFiles_Value;
pub const IMsmGetFiles = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ModuleFiles: fn(
self: *const IMsmGetFiles,
Files: ?*?*IMsmStrings,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMsmGetFiles_get_ModuleFiles(self: *const T, Files: ?*?*IMsmStrings) callconv(.Inline) HRESULT {
return @ptrCast(*const IMsmGetFiles.VTable, self.vtable).get_ModuleFiles(@ptrCast(*const IMsmGetFiles, self), Files);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const PMSIHANDLE = extern struct {
m_h: MSIHANDLE,
};
pub const INSTALLMESSAGE = enum(i32) {
FATALEXIT = 0,
ERROR = 16777216,
WARNING = 33554432,
USER = 50331648,
INFO = 67108864,
FILESINUSE = 83886080,
RESOLVESOURCE = 100663296,
OUTOFDISKSPACE = 117440512,
ACTIONSTART = 134217728,
ACTIONDATA = 150994944,
PROGRESS = 167772160,
COMMONDATA = 184549376,
INITIALIZE = 201326592,
TERMINATE = 218103808,
SHOWDIALOG = 234881024,
PERFORMANCE = 251658240,
RMFILESINUSE = 419430400,
INSTALLSTART = 436207616,
INSTALLEND = 452984832,
};
pub const INSTALLMESSAGE_FATALEXIT = INSTALLMESSAGE.FATALEXIT;
pub const INSTALLMESSAGE_ERROR = INSTALLMESSAGE.ERROR;
pub const INSTALLMESSAGE_WARNING = INSTALLMESSAGE.WARNING;
pub const INSTALLMESSAGE_USER = INSTALLMESSAGE.USER;
pub const INSTALLMESSAGE_INFO = INSTALLMESSAGE.INFO;
pub const INSTALLMESSAGE_FILESINUSE = INSTALLMESSAGE.FILESINUSE;
pub const INSTALLMESSAGE_RESOLVESOURCE = INSTALLMESSAGE.RESOLVESOURCE;
pub const INSTALLMESSAGE_OUTOFDISKSPACE = INSTALLMESSAGE.OUTOFDISKSPACE;
pub const INSTALLMESSAGE_ACTIONSTART = INSTALLMESSAGE.ACTIONSTART;
pub const INSTALLMESSAGE_ACTIONDATA = INSTALLMESSAGE.ACTIONDATA;
pub const INSTALLMESSAGE_PROGRESS = INSTALLMESSAGE.PROGRESS;
pub const INSTALLMESSAGE_COMMONDATA = INSTALLMESSAGE.COMMONDATA;
pub const INSTALLMESSAGE_INITIALIZE = INSTALLMESSAGE.INITIALIZE;
pub const INSTALLMESSAGE_TERMINATE = INSTALLMESSAGE.TERMINATE;
pub const INSTALLMESSAGE_SHOWDIALOG = INSTALLMESSAGE.SHOWDIALOG;
pub const INSTALLMESSAGE_PERFORMANCE = INSTALLMESSAGE.PERFORMANCE;
pub const INSTALLMESSAGE_RMFILESINUSE = INSTALLMESSAGE.RMFILESINUSE;
pub const INSTALLMESSAGE_INSTALLSTART = INSTALLMESSAGE.INSTALLSTART;
pub const INSTALLMESSAGE_INSTALLEND = INSTALLMESSAGE.INSTALLEND;
pub const INSTALLUI_HANDLERA = fn(
pvContext: ?*anyopaque,
iMessageType: u32,
szMessage: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) i32;
pub const INSTALLUI_HANDLERW = fn(
pvContext: ?*anyopaque,
iMessageType: u32,
szMessage: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) i32;
pub const PINSTALLUI_HANDLER_RECORD = fn(
pvContext: ?*anyopaque,
iMessageType: u32,
hRecord: MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) i32;
pub const INSTALLUILEVEL = enum(i32) {
NOCHANGE = 0,
DEFAULT = 1,
NONE = 2,
BASIC = 3,
REDUCED = 4,
FULL = 5,
ENDDIALOG = 128,
PROGRESSONLY = 64,
HIDECANCEL = 32,
SOURCERESONLY = 256,
UACONLY = 512,
};
pub const INSTALLUILEVEL_NOCHANGE = INSTALLUILEVEL.NOCHANGE;
pub const INSTALLUILEVEL_DEFAULT = INSTALLUILEVEL.DEFAULT;
pub const INSTALLUILEVEL_NONE = INSTALLUILEVEL.NONE;
pub const INSTALLUILEVEL_BASIC = INSTALLUILEVEL.BASIC;
pub const INSTALLUILEVEL_REDUCED = INSTALLUILEVEL.REDUCED;
pub const INSTALLUILEVEL_FULL = INSTALLUILEVEL.FULL;
pub const INSTALLUILEVEL_ENDDIALOG = INSTALLUILEVEL.ENDDIALOG;
pub const INSTALLUILEVEL_PROGRESSONLY = INSTALLUILEVEL.PROGRESSONLY;
pub const INSTALLUILEVEL_HIDECANCEL = INSTALLUILEVEL.HIDECANCEL;
pub const INSTALLUILEVEL_SOURCERESONLY = INSTALLUILEVEL.SOURCERESONLY;
pub const INSTALLUILEVEL_UACONLY = INSTALLUILEVEL.UACONLY;
pub const INSTALLSTATE = enum(i32) {
NOTUSED = -7,
BADCONFIG = -6,
INCOMPLETE = -5,
SOURCEABSENT = -4,
MOREDATA = -3,
INVALIDARG = -2,
UNKNOWN = -1,
BROKEN = 0,
ADVERTISED = 1,
// REMOVED = 1, this enum value conflicts with ADVERTISED
ABSENT = 2,
LOCAL = 3,
SOURCE = 4,
DEFAULT = 5,
};
pub const INSTALLSTATE_NOTUSED = INSTALLSTATE.NOTUSED;
pub const INSTALLSTATE_BADCONFIG = INSTALLSTATE.BADCONFIG;
pub const INSTALLSTATE_INCOMPLETE = INSTALLSTATE.INCOMPLETE;
pub const INSTALLSTATE_SOURCEABSENT = INSTALLSTATE.SOURCEABSENT;
pub const INSTALLSTATE_MOREDATA = INSTALLSTATE.MOREDATA;
pub const INSTALLSTATE_INVALIDARG = INSTALLSTATE.INVALIDARG;
pub const INSTALLSTATE_UNKNOWN = INSTALLSTATE.UNKNOWN;
pub const INSTALLSTATE_BROKEN = INSTALLSTATE.BROKEN;
pub const INSTALLSTATE_ADVERTISED = INSTALLSTATE.ADVERTISED;
pub const INSTALLSTATE_REMOVED = INSTALLSTATE.ADVERTISED;
pub const INSTALLSTATE_ABSENT = INSTALLSTATE.ABSENT;
pub const INSTALLSTATE_LOCAL = INSTALLSTATE.LOCAL;
pub const INSTALLSTATE_SOURCE = INSTALLSTATE.SOURCE;
pub const INSTALLSTATE_DEFAULT = INSTALLSTATE.DEFAULT;
pub const USERINFOSTATE = enum(i32) {
MOREDATA = -3,
INVALIDARG = -2,
UNKNOWN = -1,
ABSENT = 0,
PRESENT = 1,
};
pub const USERINFOSTATE_MOREDATA = USERINFOSTATE.MOREDATA;
pub const USERINFOSTATE_INVALIDARG = USERINFOSTATE.INVALIDARG;
pub const USERINFOSTATE_UNKNOWN = USERINFOSTATE.UNKNOWN;
pub const USERINFOSTATE_ABSENT = USERINFOSTATE.ABSENT;
pub const USERINFOSTATE_PRESENT = USERINFOSTATE.PRESENT;
pub const INSTALLLEVEL = enum(i32) {
DEFAULT = 0,
MINIMUM = 1,
MAXIMUM = 65535,
};
pub const INSTALLLEVEL_DEFAULT = INSTALLLEVEL.DEFAULT;
pub const INSTALLLEVEL_MINIMUM = INSTALLLEVEL.MINIMUM;
pub const INSTALLLEVEL_MAXIMUM = INSTALLLEVEL.MAXIMUM;
pub const REINSTALLMODE = enum(i32) {
REPAIR = 1,
FILEMISSING = 2,
FILEOLDERVERSION = 4,
FILEEQUALVERSION = 8,
FILEEXACT = 16,
FILEVERIFY = 32,
FILEREPLACE = 64,
MACHINEDATA = 128,
USERDATA = 256,
SHORTCUT = 512,
PACKAGE = 1024,
};
pub const REINSTALLMODE_REPAIR = REINSTALLMODE.REPAIR;
pub const REINSTALLMODE_FILEMISSING = REINSTALLMODE.FILEMISSING;
pub const REINSTALLMODE_FILEOLDERVERSION = REINSTALLMODE.FILEOLDERVERSION;
pub const REINSTALLMODE_FILEEQUALVERSION = REINSTALLMODE.FILEEQUALVERSION;
pub const REINSTALLMODE_FILEEXACT = REINSTALLMODE.FILEEXACT;
pub const REINSTALLMODE_FILEVERIFY = REINSTALLMODE.FILEVERIFY;
pub const REINSTALLMODE_FILEREPLACE = REINSTALLMODE.FILEREPLACE;
pub const REINSTALLMODE_MACHINEDATA = REINSTALLMODE.MACHINEDATA;
pub const REINSTALLMODE_USERDATA = REINSTALLMODE.USERDATA;
pub const REINSTALLMODE_SHORTCUT = REINSTALLMODE.SHORTCUT;
pub const REINSTALLMODE_PACKAGE = REINSTALLMODE.PACKAGE;
pub const INSTALLOGMODE = enum(i32) {
FATALEXIT = 1,
ERROR = 2,
WARNING = 4,
USER = 8,
INFO = 16,
RESOLVESOURCE = 64,
OUTOFDISKSPACE = 128,
ACTIONSTART = 256,
ACTIONDATA = 512,
COMMONDATA = 2048,
PROPERTYDUMP = 1024,
VERBOSE = 4096,
EXTRADEBUG = 8192,
LOGONLYONERROR = 16384,
LOGPERFORMANCE = 32768,
// PROGRESS = 1024, this enum value conflicts with PROPERTYDUMP
// INITIALIZE = 4096, this enum value conflicts with VERBOSE
// TERMINATE = 8192, this enum value conflicts with EXTRADEBUG
// SHOWDIALOG = 16384, this enum value conflicts with LOGONLYONERROR
FILESINUSE = 32,
RMFILESINUSE = 33554432,
INSTALLSTART = 67108864,
INSTALLEND = 134217728,
};
pub const INSTALLLOGMODE_FATALEXIT = INSTALLOGMODE.FATALEXIT;
pub const INSTALLLOGMODE_ERROR = INSTALLOGMODE.ERROR;
pub const INSTALLLOGMODE_WARNING = INSTALLOGMODE.WARNING;
pub const INSTALLLOGMODE_USER = INSTALLOGMODE.USER;
pub const INSTALLLOGMODE_INFO = INSTALLOGMODE.INFO;
pub const INSTALLLOGMODE_RESOLVESOURCE = INSTALLOGMODE.RESOLVESOURCE;
pub const INSTALLLOGMODE_OUTOFDISKSPACE = INSTALLOGMODE.OUTOFDISKSPACE;
pub const INSTALLLOGMODE_ACTIONSTART = INSTALLOGMODE.ACTIONSTART;
pub const INSTALLLOGMODE_ACTIONDATA = INSTALLOGMODE.ACTIONDATA;
pub const INSTALLLOGMODE_COMMONDATA = INSTALLOGMODE.COMMONDATA;
pub const INSTALLLOGMODE_PROPERTYDUMP = INSTALLOGMODE.PROPERTYDUMP;
pub const INSTALLLOGMODE_VERBOSE = INSTALLOGMODE.VERBOSE;
pub const INSTALLLOGMODE_EXTRADEBUG = INSTALLOGMODE.EXTRADEBUG;
pub const INSTALLLOGMODE_LOGONLYONERROR = INSTALLOGMODE.LOGONLYONERROR;
pub const INSTALLLOGMODE_LOGPERFORMANCE = INSTALLOGMODE.LOGPERFORMANCE;
pub const INSTALLLOGMODE_PROGRESS = INSTALLOGMODE.PROPERTYDUMP;
pub const INSTALLLOGMODE_INITIALIZE = INSTALLOGMODE.VERBOSE;
pub const INSTALLLOGMODE_TERMINATE = INSTALLOGMODE.EXTRADEBUG;
pub const INSTALLLOGMODE_SHOWDIALOG = INSTALLOGMODE.LOGONLYONERROR;
pub const INSTALLLOGMODE_FILESINUSE = INSTALLOGMODE.FILESINUSE;
pub const INSTALLLOGMODE_RMFILESINUSE = INSTALLOGMODE.RMFILESINUSE;
pub const INSTALLLOGMODE_INSTALLSTART = INSTALLOGMODE.INSTALLSTART;
pub const INSTALLLOGMODE_INSTALLEND = INSTALLOGMODE.INSTALLEND;
pub const INSTALLLOGATTRIBUTES = enum(i32) {
APPEND = 1,
FLUSHEACHLINE = 2,
};
pub const INSTALLLOGATTRIBUTES_APPEND = INSTALLLOGATTRIBUTES.APPEND;
pub const INSTALLLOGATTRIBUTES_FLUSHEACHLINE = INSTALLLOGATTRIBUTES.FLUSHEACHLINE;
pub const INSTALLFEATUREATTRIBUTE = enum(i32) {
FAVORLOCAL = 1,
FAVORSOURCE = 2,
FOLLOWPARENT = 4,
FAVORADVERTISE = 8,
DISALLOWADVERTISE = 16,
NOUNSUPPORTEDADVERTISE = 32,
};
pub const INSTALLFEATUREATTRIBUTE_FAVORLOCAL = INSTALLFEATUREATTRIBUTE.FAVORLOCAL;
pub const INSTALLFEATUREATTRIBUTE_FAVORSOURCE = INSTALLFEATUREATTRIBUTE.FAVORSOURCE;
pub const INSTALLFEATUREATTRIBUTE_FOLLOWPARENT = INSTALLFEATUREATTRIBUTE.FOLLOWPARENT;
pub const INSTALLFEATUREATTRIBUTE_FAVORADVERTISE = INSTALLFEATUREATTRIBUTE.FAVORADVERTISE;
pub const INSTALLFEATUREATTRIBUTE_DISALLOWADVERTISE = INSTALLFEATUREATTRIBUTE.DISALLOWADVERTISE;
pub const INSTALLFEATUREATTRIBUTE_NOUNSUPPORTEDADVERTISE = INSTALLFEATUREATTRIBUTE.NOUNSUPPORTEDADVERTISE;
pub const INSTALLMODE = enum(i32) {
NODETECTION_ANY = -4,
NOSOURCERESOLUTION = -3,
NODETECTION = -2,
EXISTING = -1,
DEFAULT = 0,
};
pub const INSTALLMODE_NODETECTION_ANY = INSTALLMODE.NODETECTION_ANY;
pub const INSTALLMODE_NOSOURCERESOLUTION = INSTALLMODE.NOSOURCERESOLUTION;
pub const INSTALLMODE_NODETECTION = INSTALLMODE.NODETECTION;
pub const INSTALLMODE_EXISTING = INSTALLMODE.EXISTING;
pub const INSTALLMODE_DEFAULT = INSTALLMODE.DEFAULT;
pub const MSIPATCHSTATE = enum(i32) {
INVALID = 0,
APPLIED = 1,
SUPERSEDED = 2,
OBSOLETED = 4,
REGISTERED = 8,
ALL = 15,
};
pub const MSIPATCHSTATE_INVALID = MSIPATCHSTATE.INVALID;
pub const MSIPATCHSTATE_APPLIED = MSIPATCHSTATE.APPLIED;
pub const MSIPATCHSTATE_SUPERSEDED = MSIPATCHSTATE.SUPERSEDED;
pub const MSIPATCHSTATE_OBSOLETED = MSIPATCHSTATE.OBSOLETED;
pub const MSIPATCHSTATE_REGISTERED = MSIPATCHSTATE.REGISTERED;
pub const MSIPATCHSTATE_ALL = MSIPATCHSTATE.ALL;
pub const MSIINSTALLCONTEXT = enum(i32) {
FIRSTVISIBLE = 0,
// NONE = 0, this enum value conflicts with FIRSTVISIBLE
USERMANAGED = 1,
USERUNMANAGED = 2,
MACHINE = 4,
ALL = 7,
ALLUSERMANAGED = 8,
};
pub const MSIINSTALLCONTEXT_FIRSTVISIBLE = MSIINSTALLCONTEXT.FIRSTVISIBLE;
pub const MSIINSTALLCONTEXT_NONE = MSIINSTALLCONTEXT.FIRSTVISIBLE;
pub const MSIINSTALLCONTEXT_USERMANAGED = MSIINSTALLCONTEXT.USERMANAGED;
pub const MSIINSTALLCONTEXT_USERUNMANAGED = MSIINSTALLCONTEXT.USERUNMANAGED;
pub const MSIINSTALLCONTEXT_MACHINE = MSIINSTALLCONTEXT.MACHINE;
pub const MSIINSTALLCONTEXT_ALL = MSIINSTALLCONTEXT.ALL;
pub const MSIINSTALLCONTEXT_ALLUSERMANAGED = MSIINSTALLCONTEXT.ALLUSERMANAGED;
pub const MSIPATCHDATATYPE = enum(i32) {
PATCHFILE = 0,
XMLPATH = 1,
XMLBLOB = 2,
};
pub const MSIPATCH_DATATYPE_PATCHFILE = MSIPATCHDATATYPE.PATCHFILE;
pub const MSIPATCH_DATATYPE_XMLPATH = MSIPATCHDATATYPE.XMLPATH;
pub const MSIPATCH_DATATYPE_XMLBLOB = MSIPATCHDATATYPE.XMLBLOB;
pub const MSIPATCHSEQUENCEINFOA = extern struct {
szPatchData: ?[*:0]const u8,
ePatchDataType: MSIPATCHDATATYPE,
dwOrder: u32,
uStatus: u32,
};
pub const MSIPATCHSEQUENCEINFOW = extern struct {
szPatchData: ?[*:0]const u16,
ePatchDataType: MSIPATCHDATATYPE,
dwOrder: u32,
uStatus: u32,
};
pub const SCRIPTFLAGS = enum(i32) {
CACHEINFO = 1,
SHORTCUTS = 4,
MACHINEASSIGN = 8,
REGDATA_CNFGINFO = 32,
VALIDATE_TRANSFORMS_LIST = 64,
REGDATA_CLASSINFO = 128,
REGDATA_EXTENSIONINFO = 256,
REGDATA_APPINFO = 384,
REGDATA = 416,
};
pub const SCRIPTFLAGS_CACHEINFO = SCRIPTFLAGS.CACHEINFO;
pub const SCRIPTFLAGS_SHORTCUTS = SCRIPTFLAGS.SHORTCUTS;
pub const SCRIPTFLAGS_MACHINEASSIGN = SCRIPTFLAGS.MACHINEASSIGN;
pub const SCRIPTFLAGS_REGDATA_CNFGINFO = SCRIPTFLAGS.REGDATA_CNFGINFO;
pub const SCRIPTFLAGS_VALIDATE_TRANSFORMS_LIST = SCRIPTFLAGS.VALIDATE_TRANSFORMS_LIST;
pub const SCRIPTFLAGS_REGDATA_CLASSINFO = SCRIPTFLAGS.REGDATA_CLASSINFO;
pub const SCRIPTFLAGS_REGDATA_EXTENSIONINFO = SCRIPTFLAGS.REGDATA_EXTENSIONINFO;
pub const SCRIPTFLAGS_REGDATA_APPINFO = SCRIPTFLAGS.REGDATA_APPINFO;
pub const SCRIPTFLAGS_REGDATA = SCRIPTFLAGS.REGDATA;
pub const ADVERTISEFLAGS = enum(i32) {
MACHINEASSIGN = 0,
USERASSIGN = 1,
};
pub const ADVERTISEFLAGS_MACHINEASSIGN = ADVERTISEFLAGS.MACHINEASSIGN;
pub const ADVERTISEFLAGS_USERASSIGN = ADVERTISEFLAGS.USERASSIGN;
pub const INSTALLTYPE = enum(i32) {
DEFAULT = 0,
NETWORK_IMAGE = 1,
SINGLE_INSTANCE = 2,
};
pub const INSTALLTYPE_DEFAULT = INSTALLTYPE.DEFAULT;
pub const INSTALLTYPE_NETWORK_IMAGE = INSTALLTYPE.NETWORK_IMAGE;
pub const INSTALLTYPE_SINGLE_INSTANCE = INSTALLTYPE.SINGLE_INSTANCE;
pub const MSIFILEHASHINFO = extern struct {
dwFileHashInfoSize: u32,
dwData: [4]u32,
};
pub const MSIARCHITECTUREFLAGS = enum(i32) {
X86 = 1,
IA64 = 2,
AMD64 = 4,
ARM = 8,
};
pub const MSIARCHITECTUREFLAGS_X86 = MSIARCHITECTUREFLAGS.X86;
pub const MSIARCHITECTUREFLAGS_IA64 = MSIARCHITECTUREFLAGS.IA64;
pub const MSIARCHITECTUREFLAGS_AMD64 = MSIARCHITECTUREFLAGS.AMD64;
pub const MSIARCHITECTUREFLAGS_ARM = MSIARCHITECTUREFLAGS.ARM;
pub const MSIOPENPACKAGEFLAGS = enum(i32) {
E = 1,
};
pub const MSIOPENPACKAGEFLAGS_IGNOREMACHINESTATE = MSIOPENPACKAGEFLAGS.E;
pub const MSIADVERTISEOPTIONFLAGS = enum(i32) {
E = 1,
};
pub const MSIADVERTISEOPTIONFLAGS_INSTANCE = MSIADVERTISEOPTIONFLAGS.E;
pub const MSISOURCETYPE = enum(i32) {
UNKNOWN = 0,
NETWORK = 1,
URL = 2,
MEDIA = 4,
};
pub const MSISOURCETYPE_UNKNOWN = MSISOURCETYPE.UNKNOWN;
pub const MSISOURCETYPE_NETWORK = MSISOURCETYPE.NETWORK;
pub const MSISOURCETYPE_URL = MSISOURCETYPE.URL;
pub const MSISOURCETYPE_MEDIA = MSISOURCETYPE.MEDIA;
pub const MSICODE = enum(i32) {
RODUCT = 0,
ATCH = 1073741824,
};
pub const MSICODE_PRODUCT = MSICODE.RODUCT;
pub const MSICODE_PATCH = MSICODE.ATCH;
pub const MSITRANSACTION = enum(i32) {
CHAIN_EMBEDDEDUI = 1,
JOIN_EXISTING_EMBEDDEDUI = 2,
};
pub const MSITRANSACTION_CHAIN_EMBEDDEDUI = MSITRANSACTION.CHAIN_EMBEDDEDUI;
pub const MSITRANSACTION_JOIN_EXISTING_EMBEDDEDUI = MSITRANSACTION.JOIN_EXISTING_EMBEDDEDUI;
pub const MSITRANSACTIONSTATE = enum(u32) {
ROLLBACK = 0,
COMMIT = 1,
};
pub const MSITRANSACTIONSTATE_ROLLBACK = MSITRANSACTIONSTATE.ROLLBACK;
pub const MSITRANSACTIONSTATE_COMMIT = MSITRANSACTIONSTATE.COMMIT;
pub const MSIDBSTATE = enum(i32) {
ERROR = -1,
READ = 0,
WRITE = 1,
};
pub const MSIDBSTATE_ERROR = MSIDBSTATE.ERROR;
pub const MSIDBSTATE_READ = MSIDBSTATE.READ;
pub const MSIDBSTATE_WRITE = MSIDBSTATE.WRITE;
pub const MSIMODIFY = enum(i32) {
SEEK = -1,
REFRESH = 0,
INSERT = 1,
UPDATE = 2,
ASSIGN = 3,
REPLACE = 4,
MERGE = 5,
DELETE = 6,
INSERT_TEMPORARY = 7,
VALIDATE = 8,
VALIDATE_NEW = 9,
VALIDATE_FIELD = 10,
VALIDATE_DELETE = 11,
};
pub const MSIMODIFY_SEEK = MSIMODIFY.SEEK;
pub const MSIMODIFY_REFRESH = MSIMODIFY.REFRESH;
pub const MSIMODIFY_INSERT = MSIMODIFY.INSERT;
pub const MSIMODIFY_UPDATE = MSIMODIFY.UPDATE;
pub const MSIMODIFY_ASSIGN = MSIMODIFY.ASSIGN;
pub const MSIMODIFY_REPLACE = MSIMODIFY.REPLACE;
pub const MSIMODIFY_MERGE = MSIMODIFY.MERGE;
pub const MSIMODIFY_DELETE = MSIMODIFY.DELETE;
pub const MSIMODIFY_INSERT_TEMPORARY = MSIMODIFY.INSERT_TEMPORARY;
pub const MSIMODIFY_VALIDATE = MSIMODIFY.VALIDATE;
pub const MSIMODIFY_VALIDATE_NEW = MSIMODIFY.VALIDATE_NEW;
pub const MSIMODIFY_VALIDATE_FIELD = MSIMODIFY.VALIDATE_FIELD;
pub const MSIMODIFY_VALIDATE_DELETE = MSIMODIFY.VALIDATE_DELETE;
pub const MSICOLINFO = enum(i32) {
NAMES = 0,
TYPES = 1,
};
pub const MSICOLINFO_NAMES = MSICOLINFO.NAMES;
pub const MSICOLINFO_TYPES = MSICOLINFO.TYPES;
pub const MSICONDITION = enum(i32) {
FALSE = 0,
TRUE = 1,
NONE = 2,
ERROR = 3,
};
pub const MSICONDITION_FALSE = MSICONDITION.FALSE;
pub const MSICONDITION_TRUE = MSICONDITION.TRUE;
pub const MSICONDITION_NONE = MSICONDITION.NONE;
pub const MSICONDITION_ERROR = MSICONDITION.ERROR;
pub const MSICOSTTREE = enum(i32) {
SELFONLY = 0,
CHILDREN = 1,
PARENTS = 2,
RESERVED = 3,
};
pub const MSICOSTTREE_SELFONLY = MSICOSTTREE.SELFONLY;
pub const MSICOSTTREE_CHILDREN = MSICOSTTREE.CHILDREN;
pub const MSICOSTTREE_PARENTS = MSICOSTTREE.PARENTS;
pub const MSICOSTTREE_RESERVED = MSICOSTTREE.RESERVED;
pub const MSIDBERROR = enum(i32) {
INVALIDARG = -3,
MOREDATA = -2,
FUNCTIONERROR = -1,
NOERROR = 0,
DUPLICATEKEY = 1,
REQUIRED = 2,
BADLINK = 3,
OVERFLOW = 4,
UNDERFLOW = 5,
NOTINSET = 6,
BADVERSION = 7,
BADCASE = 8,
BADGUID = 9,
BADWILDCARD = 10,
BADIDENTIFIER = 11,
BADLANGUAGE = 12,
BADFILENAME = 13,
BADPATH = 14,
BADCONDITION = 15,
BADFORMATTED = 16,
BADTEMPLATE = 17,
BADDEFAULTDIR = 18,
BADREGPATH = 19,
BADCUSTOMSOURCE = 20,
BADPROPERTY = 21,
MISSINGDATA = 22,
BADCATEGORY = 23,
BADKEYTABLE = 24,
BADMAXMINVALUES = 25,
BADCABINET = 26,
BADSHORTCUT = 27,
STRINGOVERFLOW = 28,
BADLOCALIZEATTRIB = 29,
};
pub const MSIDBERROR_INVALIDARG = MSIDBERROR.INVALIDARG;
pub const MSIDBERROR_MOREDATA = MSIDBERROR.MOREDATA;
pub const MSIDBERROR_FUNCTIONERROR = MSIDBERROR.FUNCTIONERROR;
pub const MSIDBERROR_NOERROR = MSIDBERROR.NOERROR;
pub const MSIDBERROR_DUPLICATEKEY = MSIDBERROR.DUPLICATEKEY;
pub const MSIDBERROR_REQUIRED = MSIDBERROR.REQUIRED;
pub const MSIDBERROR_BADLINK = MSIDBERROR.BADLINK;
pub const MSIDBERROR_OVERFLOW = MSIDBERROR.OVERFLOW;
pub const MSIDBERROR_UNDERFLOW = MSIDBERROR.UNDERFLOW;
pub const MSIDBERROR_NOTINSET = MSIDBERROR.NOTINSET;
pub const MSIDBERROR_BADVERSION = MSIDBERROR.BADVERSION;
pub const MSIDBERROR_BADCASE = MSIDBERROR.BADCASE;
pub const MSIDBERROR_BADGUID = MSIDBERROR.BADGUID;
pub const MSIDBERROR_BADWILDCARD = MSIDBERROR.BADWILDCARD;
pub const MSIDBERROR_BADIDENTIFIER = MSIDBERROR.BADIDENTIFIER;
pub const MSIDBERROR_BADLANGUAGE = MSIDBERROR.BADLANGUAGE;
pub const MSIDBERROR_BADFILENAME = MSIDBERROR.BADFILENAME;
pub const MSIDBERROR_BADPATH = MSIDBERROR.BADPATH;
pub const MSIDBERROR_BADCONDITION = MSIDBERROR.BADCONDITION;
pub const MSIDBERROR_BADFORMATTED = MSIDBERROR.BADFORMATTED;
pub const MSIDBERROR_BADTEMPLATE = MSIDBERROR.BADTEMPLATE;
pub const MSIDBERROR_BADDEFAULTDIR = MSIDBERROR.BADDEFAULTDIR;
pub const MSIDBERROR_BADREGPATH = MSIDBERROR.BADREGPATH;
pub const MSIDBERROR_BADCUSTOMSOURCE = MSIDBERROR.BADCUSTOMSOURCE;
pub const MSIDBERROR_BADPROPERTY = MSIDBERROR.BADPROPERTY;
pub const MSIDBERROR_MISSINGDATA = MSIDBERROR.MISSINGDATA;
pub const MSIDBERROR_BADCATEGORY = MSIDBERROR.BADCATEGORY;
pub const MSIDBERROR_BADKEYTABLE = MSIDBERROR.BADKEYTABLE;
pub const MSIDBERROR_BADMAXMINVALUES = MSIDBERROR.BADMAXMINVALUES;
pub const MSIDBERROR_BADCABINET = MSIDBERROR.BADCABINET;
pub const MSIDBERROR_BADSHORTCUT = MSIDBERROR.BADSHORTCUT;
pub const MSIDBERROR_STRINGOVERFLOW = MSIDBERROR.STRINGOVERFLOW;
pub const MSIDBERROR_BADLOCALIZEATTRIB = MSIDBERROR.BADLOCALIZEATTRIB;
pub const MSIRUNMODE = enum(i32) {
ADMIN = 0,
ADVERTISE = 1,
MAINTENANCE = 2,
ROLLBACKENABLED = 3,
LOGENABLED = 4,
OPERATIONS = 5,
REBOOTATEND = 6,
REBOOTNOW = 7,
CABINET = 8,
SOURCESHORTNAMES = 9,
TARGETSHORTNAMES = 10,
RESERVED11 = 11,
WINDOWS9X = 12,
ZAWENABLED = 13,
RESERVED14 = 14,
RESERVED15 = 15,
SCHEDULED = 16,
ROLLBACK = 17,
COMMIT = 18,
};
pub const MSIRUNMODE_ADMIN = MSIRUNMODE.ADMIN;
pub const MSIRUNMODE_ADVERTISE = MSIRUNMODE.ADVERTISE;
pub const MSIRUNMODE_MAINTENANCE = MSIRUNMODE.MAINTENANCE;
pub const MSIRUNMODE_ROLLBACKENABLED = MSIRUNMODE.ROLLBACKENABLED;
pub const MSIRUNMODE_LOGENABLED = MSIRUNMODE.LOGENABLED;
pub const MSIRUNMODE_OPERATIONS = MSIRUNMODE.OPERATIONS;
pub const MSIRUNMODE_REBOOTATEND = MSIRUNMODE.REBOOTATEND;
pub const MSIRUNMODE_REBOOTNOW = MSIRUNMODE.REBOOTNOW;
pub const MSIRUNMODE_CABINET = MSIRUNMODE.CABINET;
pub const MSIRUNMODE_SOURCESHORTNAMES = MSIRUNMODE.SOURCESHORTNAMES;
pub const MSIRUNMODE_TARGETSHORTNAMES = MSIRUNMODE.TARGETSHORTNAMES;
pub const MSIRUNMODE_RESERVED11 = MSIRUNMODE.RESERVED11;
pub const MSIRUNMODE_WINDOWS9X = MSIRUNMODE.WINDOWS9X;
pub const MSIRUNMODE_ZAWENABLED = MSIRUNMODE.ZAWENABLED;
pub const MSIRUNMODE_RESERVED14 = MSIRUNMODE.RESERVED14;
pub const MSIRUNMODE_RESERVED15 = MSIRUNMODE.RESERVED15;
pub const MSIRUNMODE_SCHEDULED = MSIRUNMODE.SCHEDULED;
pub const MSIRUNMODE_ROLLBACK = MSIRUNMODE.ROLLBACK;
pub const MSIRUNMODE_COMMIT = MSIRUNMODE.COMMIT;
pub const MSITRANSFORM_ERROR = enum(i32) {
ADDEXISTINGROW = 1,
DELMISSINGROW = 2,
ADDEXISTINGTABLE = 4,
DELMISSINGTABLE = 8,
UPDATEMISSINGROW = 16,
CHANGECODEPAGE = 32,
VIEWTRANSFORM = 256,
NONE = 0,
};
pub const MSITRANSFORM_ERROR_ADDEXISTINGROW = MSITRANSFORM_ERROR.ADDEXISTINGROW;
pub const MSITRANSFORM_ERROR_DELMISSINGROW = MSITRANSFORM_ERROR.DELMISSINGROW;
pub const MSITRANSFORM_ERROR_ADDEXISTINGTABLE = MSITRANSFORM_ERROR.ADDEXISTINGTABLE;
pub const MSITRANSFORM_ERROR_DELMISSINGTABLE = MSITRANSFORM_ERROR.DELMISSINGTABLE;
pub const MSITRANSFORM_ERROR_UPDATEMISSINGROW = MSITRANSFORM_ERROR.UPDATEMISSINGROW;
pub const MSITRANSFORM_ERROR_CHANGECODEPAGE = MSITRANSFORM_ERROR.CHANGECODEPAGE;
pub const MSITRANSFORM_ERROR_VIEWTRANSFORM = MSITRANSFORM_ERROR.VIEWTRANSFORM;
pub const MSITRANSFORM_ERROR_NONE = MSITRANSFORM_ERROR.NONE;
pub const MSITRANSFORM_VALIDATE = enum(i32) {
LANGUAGE = 1,
PRODUCT = 2,
PLATFORM = 4,
MAJORVERSION = 8,
MINORVERSION = 16,
UPDATEVERSION = 32,
NEWLESSBASEVERSION = 64,
NEWLESSEQUALBASEVERSION = 128,
NEWEQUALBASEVERSION = 256,
NEWGREATEREQUALBASEVERSION = 512,
NEWGREATERBASEVERSION = 1024,
UPGRADECODE = 2048,
};
pub const MSITRANSFORM_VALIDATE_LANGUAGE = MSITRANSFORM_VALIDATE.LANGUAGE;
pub const MSITRANSFORM_VALIDATE_PRODUCT = MSITRANSFORM_VALIDATE.PRODUCT;
pub const MSITRANSFORM_VALIDATE_PLATFORM = MSITRANSFORM_VALIDATE.PLATFORM;
pub const MSITRANSFORM_VALIDATE_MAJORVERSION = MSITRANSFORM_VALIDATE.MAJORVERSION;
pub const MSITRANSFORM_VALIDATE_MINORVERSION = MSITRANSFORM_VALIDATE.MINORVERSION;
pub const MSITRANSFORM_VALIDATE_UPDATEVERSION = MSITRANSFORM_VALIDATE.UPDATEVERSION;
pub const MSITRANSFORM_VALIDATE_NEWLESSBASEVERSION = MSITRANSFORM_VALIDATE.NEWLESSBASEVERSION;
pub const MSITRANSFORM_VALIDATE_NEWLESSEQUALBASEVERSION = MSITRANSFORM_VALIDATE.NEWLESSEQUALBASEVERSION;
pub const MSITRANSFORM_VALIDATE_NEWEQUALBASEVERSION = MSITRANSFORM_VALIDATE.NEWEQUALBASEVERSION;
pub const MSITRANSFORM_VALIDATE_NEWGREATEREQUALBASEVERSION = MSITRANSFORM_VALIDATE.NEWGREATEREQUALBASEVERSION;
pub const MSITRANSFORM_VALIDATE_NEWGREATERBASEVERSION = MSITRANSFORM_VALIDATE.NEWGREATERBASEVERSION;
pub const MSITRANSFORM_VALIDATE_UPGRADECODE = MSITRANSFORM_VALIDATE.UPGRADECODE;
pub const ASSEMBLY_INFO = extern struct {
cbAssemblyInfo: u32,
dwAssemblyFlags: u32,
uliAssemblySizeInKB: ULARGE_INTEGER,
pszCurrentAssemblyPathBuf: ?PWSTR,
cchBuf: u32,
};
pub const FUSION_INSTALL_REFERENCE = extern struct {
cbSize: u32,
dwFlags: u32,
guidScheme: Guid,
szIdentifier: ?[*:0]const u16,
szNonCannonicalData: ?[*:0]const u16,
};
pub const ASM_NAME = enum(i32) {
PUBLIC_KEY = 0,
PUBLIC_KEY_TOKEN = 1,
HASH_VALUE = 2,
NAME = 3,
MAJOR_VERSION = 4,
MINOR_VERSION = 5,
BUILD_NUMBER = 6,
REVISION_NUMBER = 7,
CULTURE = 8,
PROCESSOR_ID_ARRAY = 9,
OSINFO_ARRAY = 10,
HASH_ALGID = 11,
ALIAS = 12,
CODEBASE_URL = 13,
CODEBASE_LASTMOD = 14,
NULL_PUBLIC_KEY = 15,
NULL_PUBLIC_KEY_TOKEN = 16,
CUSTOM = 17,
NULL_CUSTOM = 18,
MVID = 19,
MAX_PARAMS = 20,
};
pub const ASM_NAME_PUBLIC_KEY = ASM_NAME.PUBLIC_KEY;
pub const ASM_NAME_PUBLIC_KEY_TOKEN = ASM_NAME.PUBLIC_KEY_TOKEN;
pub const ASM_NAME_HASH_VALUE = ASM_NAME.HASH_VALUE;
pub const ASM_NAME_NAME = ASM_NAME.NAME;
pub const ASM_NAME_MAJOR_VERSION = ASM_NAME.MAJOR_VERSION;
pub const ASM_NAME_MINOR_VERSION = ASM_NAME.MINOR_VERSION;
pub const ASM_NAME_BUILD_NUMBER = ASM_NAME.BUILD_NUMBER;
pub const ASM_NAME_REVISION_NUMBER = ASM_NAME.REVISION_NUMBER;
pub const ASM_NAME_CULTURE = ASM_NAME.CULTURE;
pub const ASM_NAME_PROCESSOR_ID_ARRAY = ASM_NAME.PROCESSOR_ID_ARRAY;
pub const ASM_NAME_OSINFO_ARRAY = ASM_NAME.OSINFO_ARRAY;
pub const ASM_NAME_HASH_ALGID = ASM_NAME.HASH_ALGID;
pub const ASM_NAME_ALIAS = ASM_NAME.ALIAS;
pub const ASM_NAME_CODEBASE_URL = ASM_NAME.CODEBASE_URL;
pub const ASM_NAME_CODEBASE_LASTMOD = ASM_NAME.CODEBASE_LASTMOD;
pub const ASM_NAME_NULL_PUBLIC_KEY = ASM_NAME.NULL_PUBLIC_KEY;
pub const ASM_NAME_NULL_PUBLIC_KEY_TOKEN = ASM_NAME.NULL_PUBLIC_KEY_TOKEN;
pub const ASM_NAME_CUSTOM = ASM_NAME.CUSTOM;
pub const ASM_NAME_NULL_CUSTOM = ASM_NAME.NULL_CUSTOM;
pub const ASM_NAME_MVID = ASM_NAME.MVID;
pub const ASM_NAME_MAX_PARAMS = ASM_NAME.MAX_PARAMS;
pub const ASM_BIND_FLAGS = enum(u32) {
FORCE_CACHE_INSTALL = 1,
RFS_INTEGRITY_CHECK = 2,
RFS_MODULE_CHECK = 4,
BINPATH_PROBE_ONLY = 8,
SHARED_BINPATH_HINT = 16,
PARENT_ASM_HINT = 32,
_,
pub fn initFlags(o: struct {
FORCE_CACHE_INSTALL: u1 = 0,
RFS_INTEGRITY_CHECK: u1 = 0,
RFS_MODULE_CHECK: u1 = 0,
BINPATH_PROBE_ONLY: u1 = 0,
SHARED_BINPATH_HINT: u1 = 0,
PARENT_ASM_HINT: u1 = 0,
}) ASM_BIND_FLAGS {
return @intToEnum(ASM_BIND_FLAGS,
(if (o.FORCE_CACHE_INSTALL == 1) @enumToInt(ASM_BIND_FLAGS.FORCE_CACHE_INSTALL) else 0)
| (if (o.RFS_INTEGRITY_CHECK == 1) @enumToInt(ASM_BIND_FLAGS.RFS_INTEGRITY_CHECK) else 0)
| (if (o.RFS_MODULE_CHECK == 1) @enumToInt(ASM_BIND_FLAGS.RFS_MODULE_CHECK) else 0)
| (if (o.BINPATH_PROBE_ONLY == 1) @enumToInt(ASM_BIND_FLAGS.BINPATH_PROBE_ONLY) else 0)
| (if (o.SHARED_BINPATH_HINT == 1) @enumToInt(ASM_BIND_FLAGS.SHARED_BINPATH_HINT) else 0)
| (if (o.PARENT_ASM_HINT == 1) @enumToInt(ASM_BIND_FLAGS.PARENT_ASM_HINT) else 0)
);
}
};
pub const ASM_BINDF_FORCE_CACHE_INSTALL = ASM_BIND_FLAGS.FORCE_CACHE_INSTALL;
pub const ASM_BINDF_RFS_INTEGRITY_CHECK = ASM_BIND_FLAGS.RFS_INTEGRITY_CHECK;
pub const ASM_BINDF_RFS_MODULE_CHECK = ASM_BIND_FLAGS.RFS_MODULE_CHECK;
pub const ASM_BINDF_BINPATH_PROBE_ONLY = ASM_BIND_FLAGS.BINPATH_PROBE_ONLY;
pub const ASM_BINDF_SHARED_BINPATH_HINT = ASM_BIND_FLAGS.SHARED_BINPATH_HINT;
pub const ASM_BINDF_PARENT_ASM_HINT = ASM_BIND_FLAGS.PARENT_ASM_HINT;
pub const ASM_DISPLAY_FLAGS = enum(i32) {
VERSION = 1,
CULTURE = 2,
PUBLIC_KEY_TOKEN = 4,
PUBLIC_KEY = 8,
CUSTOM = 16,
PROCESSORARCHITECTURE = 32,
LANGUAGEID = 64,
};
pub const ASM_DISPLAYF_VERSION = ASM_DISPLAY_FLAGS.VERSION;
pub const ASM_DISPLAYF_CULTURE = ASM_DISPLAY_FLAGS.CULTURE;
pub const ASM_DISPLAYF_PUBLIC_KEY_TOKEN = ASM_DISPLAY_FLAGS.PUBLIC_KEY_TOKEN;
pub const ASM_DISPLAYF_PUBLIC_KEY = ASM_DISPLAY_FLAGS.PUBLIC_KEY;
pub const ASM_DISPLAYF_CUSTOM = ASM_DISPLAY_FLAGS.CUSTOM;
pub const ASM_DISPLAYF_PROCESSORARCHITECTURE = ASM_DISPLAY_FLAGS.PROCESSORARCHITECTURE;
pub const ASM_DISPLAYF_LANGUAGEID = ASM_DISPLAY_FLAGS.LANGUAGEID;
pub const ASM_CMP_FLAGS = enum(i32) {
NAME = 1,
MAJOR_VERSION = 2,
MINOR_VERSION = 4,
BUILD_NUMBER = 8,
REVISION_NUMBER = 16,
PUBLIC_KEY_TOKEN = 32,
CULTURE = 64,
CUSTOM = 128,
ALL = 255,
DEFAULT = 256,
};
pub const ASM_CMPF_NAME = ASM_CMP_FLAGS.NAME;
pub const ASM_CMPF_MAJOR_VERSION = ASM_CMP_FLAGS.MAJOR_VERSION;
pub const ASM_CMPF_MINOR_VERSION = ASM_CMP_FLAGS.MINOR_VERSION;
pub const ASM_CMPF_BUILD_NUMBER = ASM_CMP_FLAGS.BUILD_NUMBER;
pub const ASM_CMPF_REVISION_NUMBER = ASM_CMP_FLAGS.REVISION_NUMBER;
pub const ASM_CMPF_PUBLIC_KEY_TOKEN = ASM_CMP_FLAGS.PUBLIC_KEY_TOKEN;
pub const ASM_CMPF_CULTURE = ASM_CMP_FLAGS.CULTURE;
pub const ASM_CMPF_CUSTOM = ASM_CMP_FLAGS.CUSTOM;
pub const ASM_CMPF_ALL = ASM_CMP_FLAGS.ALL;
pub const ASM_CMPF_DEFAULT = ASM_CMP_FLAGS.DEFAULT;
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IAssemblyName_Value = Guid.initString("cd193bc0-b4bc-11d2-9833-00c04fc31d2e");
pub const IID_IAssemblyName = &IID_IAssemblyName_Value;
pub const IAssemblyName = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
SetProperty: fn(
self: *const IAssemblyName,
PropertyId: u32,
pvProperty: ?*anyopaque,
cbProperty: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetProperty: fn(
self: *const IAssemblyName,
PropertyId: u32,
pvProperty: ?*anyopaque,
pcbProperty: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Finalize: fn(
self: *const IAssemblyName,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDisplayName: fn(
self: *const IAssemblyName,
szDisplayName: ?[*:0]u16,
pccDisplayName: ?*u32,
dwDisplayFlags: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reserved: fn(
self: *const IAssemblyName,
refIID: ?*const Guid,
pUnkReserved1: ?*IUnknown,
pUnkReserved2: ?*IUnknown,
szReserved: ?[*:0]const u16,
llReserved: i64,
pvReserved: ?*anyopaque,
cbReserved: u32,
ppReserved: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetName: fn(
self: *const IAssemblyName,
lpcwBuffer: ?*u32,
pwzName: ?[*:0]u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetVersion: fn(
self: *const IAssemblyName,
pdwVersionHi: ?*u32,
pdwVersionLow: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
IsEqual: fn(
self: *const IAssemblyName,
pName: ?*IAssemblyName,
dwCmpFlags: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clone: fn(
self: *const IAssemblyName,
pName: ?*?*IAssemblyName,
) 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 IAssemblyName_SetProperty(self: *const T, PropertyId: u32, pvProperty: ?*anyopaque, cbProperty: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IAssemblyName.VTable, self.vtable).SetProperty(@ptrCast(*const IAssemblyName, self), PropertyId, pvProperty, cbProperty);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAssemblyName_GetProperty(self: *const T, PropertyId: u32, pvProperty: ?*anyopaque, pcbProperty: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IAssemblyName.VTable, self.vtable).GetProperty(@ptrCast(*const IAssemblyName, self), PropertyId, pvProperty, pcbProperty);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAssemblyName_Finalize(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IAssemblyName.VTable, self.vtable).Finalize(@ptrCast(*const IAssemblyName, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAssemblyName_GetDisplayName(self: *const T, szDisplayName: ?[*:0]u16, pccDisplayName: ?*u32, dwDisplayFlags: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IAssemblyName.VTable, self.vtable).GetDisplayName(@ptrCast(*const IAssemblyName, self), szDisplayName, pccDisplayName, dwDisplayFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAssemblyName_Reserved(self: *const T, refIID: ?*const Guid, pUnkReserved1: ?*IUnknown, pUnkReserved2: ?*IUnknown, szReserved: ?[*:0]const u16, llReserved: i64, pvReserved: ?*anyopaque, cbReserved: u32, ppReserved: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IAssemblyName.VTable, self.vtable).Reserved(@ptrCast(*const IAssemblyName, self), refIID, pUnkReserved1, pUnkReserved2, szReserved, llReserved, pvReserved, cbReserved, ppReserved);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAssemblyName_GetName(self: *const T, lpcwBuffer: ?*u32, pwzName: ?[*:0]u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IAssemblyName.VTable, self.vtable).GetName(@ptrCast(*const IAssemblyName, self), lpcwBuffer, pwzName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAssemblyName_GetVersion(self: *const T, pdwVersionHi: ?*u32, pdwVersionLow: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IAssemblyName.VTable, self.vtable).GetVersion(@ptrCast(*const IAssemblyName, self), pdwVersionHi, pdwVersionLow);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAssemblyName_IsEqual(self: *const T, pName: ?*IAssemblyName, dwCmpFlags: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IAssemblyName.VTable, self.vtable).IsEqual(@ptrCast(*const IAssemblyName, self), pName, dwCmpFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAssemblyName_Clone(self: *const T, pName: ?*?*IAssemblyName) callconv(.Inline) HRESULT {
return @ptrCast(*const IAssemblyName.VTable, self.vtable).Clone(@ptrCast(*const IAssemblyName, self), pName);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IAssemblyCacheItem_Value = Guid.initString("9e3aaeb4-d1cd-11d2-bab9-00c04f8eceae");
pub const IID_IAssemblyCacheItem = &IID_IAssemblyCacheItem_Value;
pub const IAssemblyCacheItem = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
CreateStream: fn(
self: *const IAssemblyCacheItem,
dwFlags: u32,
pszStreamName: ?[*:0]const u16,
dwFormat: u32,
dwFormatFlags: u32,
ppIStream: ?*?*IStream,
puliMaxSize: ?*ULARGE_INTEGER,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Commit: fn(
self: *const IAssemblyCacheItem,
dwFlags: u32,
pulDisposition: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AbortItem: fn(
self: *const IAssemblyCacheItem,
) 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 IAssemblyCacheItem_CreateStream(self: *const T, dwFlags: u32, pszStreamName: ?[*:0]const u16, dwFormat: u32, dwFormatFlags: u32, ppIStream: ?*?*IStream, puliMaxSize: ?*ULARGE_INTEGER) callconv(.Inline) HRESULT {
return @ptrCast(*const IAssemblyCacheItem.VTable, self.vtable).CreateStream(@ptrCast(*const IAssemblyCacheItem, self), dwFlags, pszStreamName, dwFormat, dwFormatFlags, ppIStream, puliMaxSize);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAssemblyCacheItem_Commit(self: *const T, dwFlags: u32, pulDisposition: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IAssemblyCacheItem.VTable, self.vtable).Commit(@ptrCast(*const IAssemblyCacheItem, self), dwFlags, pulDisposition);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAssemblyCacheItem_AbortItem(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IAssemblyCacheItem.VTable, self.vtable).AbortItem(@ptrCast(*const IAssemblyCacheItem, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IAssemblyCache_Value = Guid.initString("e707dcde-d1cd-11d2-bab9-00c04f8eceae");
pub const IID_IAssemblyCache = &IID_IAssemblyCache_Value;
pub const IAssemblyCache = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
UninstallAssembly: fn(
self: *const IAssemblyCache,
dwFlags: u32,
pszAssemblyName: ?[*:0]const u16,
pRefData: ?*FUSION_INSTALL_REFERENCE,
pulDisposition: ?*IASSEMBLYCACHE_UNINSTALL_DISPOSITION,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
QueryAssemblyInfo: fn(
self: *const IAssemblyCache,
dwFlags: QUERYASMINFO_FLAGS,
pszAssemblyName: ?[*:0]const u16,
pAsmInfo: ?*ASSEMBLY_INFO,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CreateAssemblyCacheItem: fn(
self: *const IAssemblyCache,
dwFlags: u32,
pvReserved: ?*anyopaque,
ppAsmItem: ?*?*IAssemblyCacheItem,
pszAssemblyName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reserved: fn(
self: *const IAssemblyCache,
ppUnk: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InstallAssembly: fn(
self: *const IAssemblyCache,
dwFlags: u32,
pszManifestFilePath: ?[*:0]const u16,
pRefData: ?*FUSION_INSTALL_REFERENCE,
) 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 IAssemblyCache_UninstallAssembly(self: *const T, dwFlags: u32, pszAssemblyName: ?[*:0]const u16, pRefData: ?*FUSION_INSTALL_REFERENCE, pulDisposition: ?*IASSEMBLYCACHE_UNINSTALL_DISPOSITION) callconv(.Inline) HRESULT {
return @ptrCast(*const IAssemblyCache.VTable, self.vtable).UninstallAssembly(@ptrCast(*const IAssemblyCache, self), dwFlags, pszAssemblyName, pRefData, pulDisposition);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAssemblyCache_QueryAssemblyInfo(self: *const T, dwFlags: QUERYASMINFO_FLAGS, pszAssemblyName: ?[*:0]const u16, pAsmInfo: ?*ASSEMBLY_INFO) callconv(.Inline) HRESULT {
return @ptrCast(*const IAssemblyCache.VTable, self.vtable).QueryAssemblyInfo(@ptrCast(*const IAssemblyCache, self), dwFlags, pszAssemblyName, pAsmInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAssemblyCache_CreateAssemblyCacheItem(self: *const T, dwFlags: u32, pvReserved: ?*anyopaque, ppAsmItem: ?*?*IAssemblyCacheItem, pszAssemblyName: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IAssemblyCache.VTable, self.vtable).CreateAssemblyCacheItem(@ptrCast(*const IAssemblyCache, self), dwFlags, pvReserved, ppAsmItem, pszAssemblyName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAssemblyCache_Reserved(self: *const T, ppUnk: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const IAssemblyCache.VTable, self.vtable).Reserved(@ptrCast(*const IAssemblyCache, self), ppUnk);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IAssemblyCache_InstallAssembly(self: *const T, dwFlags: u32, pszManifestFilePath: ?[*:0]const u16, pRefData: ?*FUSION_INSTALL_REFERENCE) callconv(.Inline) HRESULT {
return @ptrCast(*const IAssemblyCache.VTable, self.vtable).InstallAssembly(@ptrCast(*const IAssemblyCache, self), dwFlags, pszManifestFilePath, pRefData);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const CREATE_ASM_NAME_OBJ_FLAGS = enum(i32) {
PARSE_DISPLAY_NAME = 1,
SET_DEFAULT_VALUES = 2,
};
pub const CANOF_PARSE_DISPLAY_NAME = CREATE_ASM_NAME_OBJ_FLAGS.PARSE_DISPLAY_NAME;
pub const CANOF_SET_DEFAULT_VALUES = CREATE_ASM_NAME_OBJ_FLAGS.SET_DEFAULT_VALUES;
pub const PROTECTED_FILE_DATA = extern struct {
FileName: [260]u16,
FileNumber: u32,
};
pub const msidbControlAttributes = enum(i32) {
AttributesVisible = 1,
AttributesEnabled = 2,
AttributesSunken = 4,
AttributesIndirect = 8,
AttributesInteger = 16,
AttributesRTLRO = 32,
AttributesRightAligned = 64,
AttributesLeftScroll = 128,
AttributesBiDi = 224,
AttributesTransparent = 65536,
AttributesNoPrefix = 131072,
AttributesNoWrap = 262144,
AttributesFormatSize = 524288,
AttributesUsersLanguage = 1048576,
// AttributesMultiline = 65536, this enum value conflicts with AttributesTransparent
AttributesPasswordInput = 2097152,
// AttributesProgress95 = 65536, this enum value conflicts with AttributesTransparent
// AttributesRemovableVolume = 65536, this enum value conflicts with AttributesTransparent
// AttributesFixedVolume = 131072, this enum value conflicts with AttributesNoPrefix
// AttributesRemoteVolume = 262144, this enum value conflicts with AttributesNoWrap
// AttributesCDROMVolume = 524288, this enum value conflicts with AttributesFormatSize
// AttributesRAMDiskVolume = 1048576, this enum value conflicts with AttributesUsersLanguage
// AttributesFloppyVolume = 2097152, this enum value conflicts with AttributesPasswordInput
ShowRollbackCost = 4194304,
// AttributesSorted = 65536, this enum value conflicts with AttributesTransparent
// AttributesComboList = 131072, this enum value conflicts with AttributesNoPrefix
// AttributesImageHandle = 65536, this enum value conflicts with AttributesTransparent
// AttributesPushLike = 131072, this enum value conflicts with AttributesNoPrefix
// AttributesBitmap = 262144, this enum value conflicts with AttributesNoWrap
// AttributesIcon = 524288, this enum value conflicts with AttributesFormatSize
// AttributesFixedSize = 1048576, this enum value conflicts with AttributesUsersLanguage
// AttributesIconSize16 = 2097152, this enum value conflicts with AttributesPasswordInput
// AttributesIconSize32 = 4194304, this enum value conflicts with ShowRollbackCost
AttributesIconSize48 = 6291456,
AttributesElevationShield = 8388608,
AttributesHasBorder = 16777216,
};
pub const msidbControlAttributesVisible = msidbControlAttributes.AttributesVisible;
pub const msidbControlAttributesEnabled = msidbControlAttributes.AttributesEnabled;
pub const msidbControlAttributesSunken = msidbControlAttributes.AttributesSunken;
pub const msidbControlAttributesIndirect = msidbControlAttributes.AttributesIndirect;
pub const msidbControlAttributesInteger = msidbControlAttributes.AttributesInteger;
pub const msidbControlAttributesRTLRO = msidbControlAttributes.AttributesRTLRO;
pub const msidbControlAttributesRightAligned = msidbControlAttributes.AttributesRightAligned;
pub const msidbControlAttributesLeftScroll = msidbControlAttributes.AttributesLeftScroll;
pub const msidbControlAttributesBiDi = msidbControlAttributes.AttributesBiDi;
pub const msidbControlAttributesTransparent = msidbControlAttributes.AttributesTransparent;
pub const msidbControlAttributesNoPrefix = msidbControlAttributes.AttributesNoPrefix;
pub const msidbControlAttributesNoWrap = msidbControlAttributes.AttributesNoWrap;
pub const msidbControlAttributesFormatSize = msidbControlAttributes.AttributesFormatSize;
pub const msidbControlAttributesUsersLanguage = msidbControlAttributes.AttributesUsersLanguage;
pub const msidbControlAttributesMultiline = msidbControlAttributes.AttributesTransparent;
pub const msidbControlAttributesPasswordInput = msidbControlAttributes.AttributesPasswordInput;
pub const msidbControlAttributesProgress95 = msidbControlAttributes.AttributesTransparent;
pub const msidbControlAttributesRemovableVolume = msidbControlAttributes.AttributesTransparent;
pub const msidbControlAttributesFixedVolume = msidbControlAttributes.AttributesNoPrefix;
pub const msidbControlAttributesRemoteVolume = msidbControlAttributes.AttributesNoWrap;
pub const msidbControlAttributesCDROMVolume = msidbControlAttributes.AttributesFormatSize;
pub const msidbControlAttributesRAMDiskVolume = msidbControlAttributes.AttributesUsersLanguage;
pub const msidbControlAttributesFloppyVolume = msidbControlAttributes.AttributesPasswordInput;
pub const msidbControlShowRollbackCost = msidbControlAttributes.ShowRollbackCost;
pub const msidbControlAttributesSorted = msidbControlAttributes.AttributesTransparent;
pub const msidbControlAttributesComboList = msidbControlAttributes.AttributesNoPrefix;
pub const msidbControlAttributesImageHandle = msidbControlAttributes.AttributesTransparent;
pub const msidbControlAttributesPushLike = msidbControlAttributes.AttributesNoPrefix;
pub const msidbControlAttributesBitmap = msidbControlAttributes.AttributesNoWrap;
pub const msidbControlAttributesIcon = msidbControlAttributes.AttributesFormatSize;
pub const msidbControlAttributesFixedSize = msidbControlAttributes.AttributesUsersLanguage;
pub const msidbControlAttributesIconSize16 = msidbControlAttributes.AttributesPasswordInput;
pub const msidbControlAttributesIconSize32 = msidbControlAttributes.ShowRollbackCost;
pub const msidbControlAttributesIconSize48 = msidbControlAttributes.AttributesIconSize48;
pub const msidbControlAttributesElevationShield = msidbControlAttributes.AttributesElevationShield;
pub const msidbControlAttributesHasBorder = msidbControlAttributes.AttributesHasBorder;
pub const msidbLocatorType = enum(i32) {
Directory = 0,
FileName = 1,
RawValue = 2,
@"64bit" = 16,
};
pub const msidbLocatorTypeDirectory = msidbLocatorType.Directory;
pub const msidbLocatorTypeFileName = msidbLocatorType.FileName;
pub const msidbLocatorTypeRawValue = msidbLocatorType.RawValue;
pub const msidbLocatorType64bit = msidbLocatorType.@"64bit";
pub const msidbComponentAttributes = enum(i32) {
LocalOnly = 0,
SourceOnly = 1,
Optional = 2,
RegistryKeyPath = 4,
SharedDllRefCount = 8,
Permanent = 16,
ODBCDataSource = 32,
Transitive = 64,
NeverOverwrite = 128,
@"64bit" = 256,
DisableRegistryReflection = 512,
UninstallOnSupersedence = 1024,
Shared = 2048,
};
pub const msidbComponentAttributesLocalOnly = msidbComponentAttributes.LocalOnly;
pub const msidbComponentAttributesSourceOnly = msidbComponentAttributes.SourceOnly;
pub const msidbComponentAttributesOptional = msidbComponentAttributes.Optional;
pub const msidbComponentAttributesRegistryKeyPath = msidbComponentAttributes.RegistryKeyPath;
pub const msidbComponentAttributesSharedDllRefCount = msidbComponentAttributes.SharedDllRefCount;
pub const msidbComponentAttributesPermanent = msidbComponentAttributes.Permanent;
pub const msidbComponentAttributesODBCDataSource = msidbComponentAttributes.ODBCDataSource;
pub const msidbComponentAttributesTransitive = msidbComponentAttributes.Transitive;
pub const msidbComponentAttributesNeverOverwrite = msidbComponentAttributes.NeverOverwrite;
pub const msidbComponentAttributes64bit = msidbComponentAttributes.@"64bit";
pub const msidbComponentAttributesDisableRegistryReflection = msidbComponentAttributes.DisableRegistryReflection;
pub const msidbComponentAttributesUninstallOnSupersedence = msidbComponentAttributes.UninstallOnSupersedence;
pub const msidbComponentAttributesShared = msidbComponentAttributes.Shared;
pub const msidbAssemblyAttributes = enum(i32) {
URT = 0,
Win32 = 1,
};
pub const msidbAssemblyAttributesURT = msidbAssemblyAttributes.URT;
pub const msidbAssemblyAttributesWin32 = msidbAssemblyAttributes.Win32;
pub const msidbCustomActionType = enum(i32) {
Dll = 1,
Exe = 2,
TextData = 3,
JScript = 5,
VBScript = 6,
Install = 7,
BinaryData = 0,
SourceFile = 16,
Directory = 32,
Property = 48,
Continue = 64,
Async = 128,
FirstSequence = 256,
OncePerProcess = 512,
ClientRepeat = 768,
InScript = 1024,
// Rollback = 256, this enum value conflicts with FirstSequence
// Commit = 512, this enum value conflicts with OncePerProcess
NoImpersonate = 2048,
TSAware = 16384,
@"64BitScript" = 4096,
HideTarget = 8192,
PatchUninstall = 32768,
};
pub const msidbCustomActionTypeDll = msidbCustomActionType.Dll;
pub const msidbCustomActionTypeExe = msidbCustomActionType.Exe;
pub const msidbCustomActionTypeTextData = msidbCustomActionType.TextData;
pub const msidbCustomActionTypeJScript = msidbCustomActionType.JScript;
pub const msidbCustomActionTypeVBScript = msidbCustomActionType.VBScript;
pub const msidbCustomActionTypeInstall = msidbCustomActionType.Install;
pub const msidbCustomActionTypeBinaryData = msidbCustomActionType.BinaryData;
pub const msidbCustomActionTypeSourceFile = msidbCustomActionType.SourceFile;
pub const msidbCustomActionTypeDirectory = msidbCustomActionType.Directory;
pub const msidbCustomActionTypeProperty = msidbCustomActionType.Property;
pub const msidbCustomActionTypeContinue = msidbCustomActionType.Continue;
pub const msidbCustomActionTypeAsync = msidbCustomActionType.Async;
pub const msidbCustomActionTypeFirstSequence = msidbCustomActionType.FirstSequence;
pub const msidbCustomActionTypeOncePerProcess = msidbCustomActionType.OncePerProcess;
pub const msidbCustomActionTypeClientRepeat = msidbCustomActionType.ClientRepeat;
pub const msidbCustomActionTypeInScript = msidbCustomActionType.InScript;
pub const msidbCustomActionTypeRollback = msidbCustomActionType.FirstSequence;
pub const msidbCustomActionTypeCommit = msidbCustomActionType.OncePerProcess;
pub const msidbCustomActionTypeNoImpersonate = msidbCustomActionType.NoImpersonate;
pub const msidbCustomActionTypeTSAware = msidbCustomActionType.TSAware;
pub const msidbCustomActionType64BitScript = msidbCustomActionType.@"64BitScript";
pub const msidbCustomActionTypeHideTarget = msidbCustomActionType.HideTarget;
pub const msidbCustomActionTypePatchUninstall = msidbCustomActionType.PatchUninstall;
pub const msidbDialogAttributes = enum(i32) {
Visible = 1,
Modal = 2,
Minimize = 4,
SysModal = 8,
KeepModeless = 16,
TrackDiskSpace = 32,
UseCustomPalette = 64,
RTLRO = 128,
RightAligned = 256,
LeftScroll = 512,
BiDi = 896,
Error = 65536,
};
pub const msidbDialogAttributesVisible = msidbDialogAttributes.Visible;
pub const msidbDialogAttributesModal = msidbDialogAttributes.Modal;
pub const msidbDialogAttributesMinimize = msidbDialogAttributes.Minimize;
pub const msidbDialogAttributesSysModal = msidbDialogAttributes.SysModal;
pub const msidbDialogAttributesKeepModeless = msidbDialogAttributes.KeepModeless;
pub const msidbDialogAttributesTrackDiskSpace = msidbDialogAttributes.TrackDiskSpace;
pub const msidbDialogAttributesUseCustomPalette = msidbDialogAttributes.UseCustomPalette;
pub const msidbDialogAttributesRTLRO = msidbDialogAttributes.RTLRO;
pub const msidbDialogAttributesRightAligned = msidbDialogAttributes.RightAligned;
pub const msidbDialogAttributesLeftScroll = msidbDialogAttributes.LeftScroll;
pub const msidbDialogAttributesBiDi = msidbDialogAttributes.BiDi;
pub const msidbDialogAttributesError = msidbDialogAttributes.Error;
pub const msidbFeatureAttributes = enum(i32) {
FavorLocal = 0,
FavorSource = 1,
FollowParent = 2,
FavorAdvertise = 4,
DisallowAdvertise = 8,
UIDisallowAbsent = 16,
NoUnsupportedAdvertise = 32,
};
pub const msidbFeatureAttributesFavorLocal = msidbFeatureAttributes.FavorLocal;
pub const msidbFeatureAttributesFavorSource = msidbFeatureAttributes.FavorSource;
pub const msidbFeatureAttributesFollowParent = msidbFeatureAttributes.FollowParent;
pub const msidbFeatureAttributesFavorAdvertise = msidbFeatureAttributes.FavorAdvertise;
pub const msidbFeatureAttributesDisallowAdvertise = msidbFeatureAttributes.DisallowAdvertise;
pub const msidbFeatureAttributesUIDisallowAbsent = msidbFeatureAttributes.UIDisallowAbsent;
pub const msidbFeatureAttributesNoUnsupportedAdvertise = msidbFeatureAttributes.NoUnsupportedAdvertise;
pub const msidbFileAttributes = enum(i32) {
ReadOnly = 1,
Hidden = 2,
System = 4,
Reserved0 = 8,
IsolatedComp = 16,
Reserved1 = 64,
Reserved2 = 128,
Reserved3 = 256,
Vital = 512,
Checksum = 1024,
PatchAdded = 4096,
Noncompressed = 8192,
Compressed = 16384,
Reserved4 = 32768,
};
pub const msidbFileAttributesReadOnly = msidbFileAttributes.ReadOnly;
pub const msidbFileAttributesHidden = msidbFileAttributes.Hidden;
pub const msidbFileAttributesSystem = msidbFileAttributes.System;
pub const msidbFileAttributesReserved0 = msidbFileAttributes.Reserved0;
pub const msidbFileAttributesIsolatedComp = msidbFileAttributes.IsolatedComp;
pub const msidbFileAttributesReserved1 = msidbFileAttributes.Reserved1;
pub const msidbFileAttributesReserved2 = msidbFileAttributes.Reserved2;
pub const msidbFileAttributesReserved3 = msidbFileAttributes.Reserved3;
pub const msidbFileAttributesVital = msidbFileAttributes.Vital;
pub const msidbFileAttributesChecksum = msidbFileAttributes.Checksum;
pub const msidbFileAttributesPatchAdded = msidbFileAttributes.PatchAdded;
pub const msidbFileAttributesNoncompressed = msidbFileAttributes.Noncompressed;
pub const msidbFileAttributesCompressed = msidbFileAttributes.Compressed;
pub const msidbFileAttributesReserved4 = msidbFileAttributes.Reserved4;
pub const msidbIniFileAction = enum(i32) {
AddLine = 0,
CreateLine = 1,
RemoveLine = 2,
AddTag = 3,
RemoveTag = 4,
};
pub const msidbIniFileActionAddLine = msidbIniFileAction.AddLine;
pub const msidbIniFileActionCreateLine = msidbIniFileAction.CreateLine;
pub const msidbIniFileActionRemoveLine = msidbIniFileAction.RemoveLine;
pub const msidbIniFileActionAddTag = msidbIniFileAction.AddTag;
pub const msidbIniFileActionRemoveTag = msidbIniFileAction.RemoveTag;
pub const msidbMoveFileOptions = enum(i32) {
e = 1,
};
pub const msidbMoveFileOptionsMove = msidbMoveFileOptions.e;
pub const msidbODBCDataSourceRegistration = enum(i32) {
Machine = 0,
User = 1,
};
pub const msidbODBCDataSourceRegistrationPerMachine = msidbODBCDataSourceRegistration.Machine;
pub const msidbODBCDataSourceRegistrationPerUser = msidbODBCDataSourceRegistration.User;
pub const msidbClassAttributes = enum(i32) {
h = 1,
};
pub const msidbClassAttributesRelativePath = msidbClassAttributes.h;
pub const msidbPatchAttributes = enum(i32) {
l = 1,
};
pub const msidbPatchAttributesNonVital = msidbPatchAttributes.l;
pub const msidbRegistryRoot = enum(i32) {
ClassesRoot = 0,
CurrentUser = 1,
LocalMachine = 2,
Users = 3,
};
pub const msidbRegistryRootClassesRoot = msidbRegistryRoot.ClassesRoot;
pub const msidbRegistryRootCurrentUser = msidbRegistryRoot.CurrentUser;
pub const msidbRegistryRootLocalMachine = msidbRegistryRoot.LocalMachine;
pub const msidbRegistryRootUsers = msidbRegistryRoot.Users;
pub const msidbRemoveFileInstallMode = enum(i32) {
Install = 1,
Remove = 2,
Both = 3,
};
pub const msidbRemoveFileInstallModeOnInstall = msidbRemoveFileInstallMode.Install;
pub const msidbRemoveFileInstallModeOnRemove = msidbRemoveFileInstallMode.Remove;
pub const msidbRemoveFileInstallModeOnBoth = msidbRemoveFileInstallMode.Both;
pub const msidbServiceControlEvent = enum(i32) {
Start = 1,
Stop = 2,
Delete = 8,
UninstallStart = 16,
UninstallStop = 32,
UninstallDelete = 128,
};
pub const msidbServiceControlEventStart = msidbServiceControlEvent.Start;
pub const msidbServiceControlEventStop = msidbServiceControlEvent.Stop;
pub const msidbServiceControlEventDelete = msidbServiceControlEvent.Delete;
pub const msidbServiceControlEventUninstallStart = msidbServiceControlEvent.UninstallStart;
pub const msidbServiceControlEventUninstallStop = msidbServiceControlEvent.UninstallStop;
pub const msidbServiceControlEventUninstallDelete = msidbServiceControlEvent.UninstallDelete;
pub const msidbServiceConfigEvent = enum(i32) {
Install = 1,
Uninstall = 2,
Reinstall = 4,
};
pub const msidbServiceConfigEventInstall = msidbServiceConfigEvent.Install;
pub const msidbServiceConfigEventUninstall = msidbServiceConfigEvent.Uninstall;
pub const msidbServiceConfigEventReinstall = msidbServiceConfigEvent.Reinstall;
pub const msidbServiceInstallErrorControl = enum(i32) {
l = 32768,
};
pub const msidbServiceInstallErrorControlVital = msidbServiceInstallErrorControl.l;
pub const msidbTextStyleStyleBits = enum(i32) {
Bold = 1,
Italic = 2,
Underline = 4,
Strike = 8,
};
pub const msidbTextStyleStyleBitsBold = msidbTextStyleStyleBits.Bold;
pub const msidbTextStyleStyleBitsItalic = msidbTextStyleStyleBits.Italic;
pub const msidbTextStyleStyleBitsUnderline = msidbTextStyleStyleBits.Underline;
pub const msidbTextStyleStyleBitsStrike = msidbTextStyleStyleBits.Strike;
pub const msidbUpgradeAttributes = enum(i32) {
MigrateFeatures = 1,
OnlyDetect = 2,
IgnoreRemoveFailure = 4,
VersionMinInclusive = 256,
VersionMaxInclusive = 512,
LanguagesExclusive = 1024,
};
pub const msidbUpgradeAttributesMigrateFeatures = msidbUpgradeAttributes.MigrateFeatures;
pub const msidbUpgradeAttributesOnlyDetect = msidbUpgradeAttributes.OnlyDetect;
pub const msidbUpgradeAttributesIgnoreRemoveFailure = msidbUpgradeAttributes.IgnoreRemoveFailure;
pub const msidbUpgradeAttributesVersionMinInclusive = msidbUpgradeAttributes.VersionMinInclusive;
pub const msidbUpgradeAttributesVersionMaxInclusive = msidbUpgradeAttributes.VersionMaxInclusive;
pub const msidbUpgradeAttributesLanguagesExclusive = msidbUpgradeAttributes.LanguagesExclusive;
pub const msidbEmbeddedUIAttributes = enum(i32) {
UI = 1,
HandlesBasic = 2,
};
pub const msidbEmbeddedUI = msidbEmbeddedUIAttributes.UI;
pub const msidbEmbeddedHandlesBasic = msidbEmbeddedUIAttributes.HandlesBasic;
pub const msidbSumInfoSourceType = enum(i32) {
SFN = 1,
Compressed = 2,
AdminImage = 4,
LUAPackage = 8,
};
pub const msidbSumInfoSourceTypeSFN = msidbSumInfoSourceType.SFN;
pub const msidbSumInfoSourceTypeCompressed = msidbSumInfoSourceType.Compressed;
pub const msidbSumInfoSourceTypeAdminImage = msidbSumInfoSourceType.AdminImage;
pub const msidbSumInfoSourceTypeLUAPackage = msidbSumInfoSourceType.LUAPackage;
pub const msirbRebootType = enum(i32) {
Immediate = 1,
Deferred = 2,
};
pub const msirbRebootImmediate = msirbRebootType.Immediate;
pub const msirbRebootDeferred = msirbRebootType.Deferred;
pub const msirbRebootReason = enum(i32) {
UndeterminedReason = 0,
InUseFilesReason = 1,
ScheduleRebootReason = 2,
ForceRebootReason = 3,
CustomActionReason = 4,
};
pub const msirbRebootUndeterminedReason = msirbRebootReason.UndeterminedReason;
pub const msirbRebootInUseFilesReason = msirbRebootReason.InUseFilesReason;
pub const msirbRebootScheduleRebootReason = msirbRebootReason.ScheduleRebootReason;
pub const msirbRebootForceRebootReason = msirbRebootReason.ForceRebootReason;
pub const msirbRebootCustomActionReason = msirbRebootReason.CustomActionReason;
pub const msifiFastInstallBits = enum(i32) {
NoSR = 1,
QuickCosting = 2,
LessPrgMsg = 4,
};
pub const msifiFastInstallNoSR = msifiFastInstallBits.NoSR;
pub const msifiFastInstallQuickCosting = msifiFastInstallBits.QuickCosting;
pub const msifiFastInstallLessPrgMsg = msifiFastInstallBits.LessPrgMsg;
const CLSID_PMSvc_Value = Guid.initString("b9e511fc-e364-497a-a121-b7b3612cedce");
pub const CLSID_PMSvc = &CLSID_PMSvc_Value;
pub const TILE_TEMPLATE_TYPE = enum(i32) {
INVALID = 0,
FLIP = 5,
DEEPLINK = 13,
CYCLE = 14,
METROCOUNT = 1,
AGILESTORE = 2,
GAMES = 3,
CALENDAR = 4,
MUSICVIDEO = 7,
PEOPLE = 10,
CONTACT = 11,
GROUP = 12,
DEFAULT = 15,
BADGE = 16,
BLOCK = 17,
TEXT01 = 18,
TEXT02 = 19,
TEXT03 = 20,
TEXT04 = 21,
TEXT05 = 22,
TEXT06 = 23,
TEXT07 = 24,
TEXT08 = 25,
TEXT09 = 26,
TEXT10 = 27,
TEXT11 = 28,
IMAGE = 29,
IMAGECOLLECTION = 30,
IMAGEANDTEXT01 = 31,
IMAGEANDTEXT02 = 32,
BLOCKANDTEXT01 = 33,
BLOCKANDTEXT02 = 34,
PEEKIMAGEANDTEXT01 = 35,
PEEKIMAGEANDTEXT02 = 36,
PEEKIMAGEANDTEXT03 = 37,
PEEKIMAGEANDTEXT04 = 38,
PEEKIMAGE01 = 39,
PEEKIMAGE02 = 40,
PEEKIMAGE03 = 41,
PEEKIMAGE04 = 42,
PEEKIMAGE05 = 43,
PEEKIMAGE06 = 44,
PEEKIMAGECOLLECTION01 = 45,
PEEKIMAGECOLLECTION02 = 46,
PEEKIMAGECOLLECTION03 = 47,
PEEKIMAGECOLLECTION04 = 48,
PEEKIMAGECOLLECTION05 = 49,
PEEKIMAGECOLLECTION06 = 50,
SMALLIMAGEANDTEXT01 = 51,
SMALLIMAGEANDTEXT02 = 52,
SMALLIMAGEANDTEXT03 = 53,
SMALLIMAGEANDTEXT04 = 54,
SMALLIMAGEANDTEXT05 = 55,
METROCOUNTQUEUE = 56,
SEARCH = 57,
TILEFLYOUT01 = 58,
FOLDER = 59,
ALL = 100,
};
pub const TILE_TEMPLATE_INVALID = TILE_TEMPLATE_TYPE.INVALID;
pub const TILE_TEMPLATE_FLIP = TILE_TEMPLATE_TYPE.FLIP;
pub const TILE_TEMPLATE_DEEPLINK = TILE_TEMPLATE_TYPE.DEEPLINK;
pub const TILE_TEMPLATE_CYCLE = TILE_TEMPLATE_TYPE.CYCLE;
pub const TILE_TEMPLATE_METROCOUNT = TILE_TEMPLATE_TYPE.METROCOUNT;
pub const TILE_TEMPLATE_AGILESTORE = TILE_TEMPLATE_TYPE.AGILESTORE;
pub const TILE_TEMPLATE_GAMES = TILE_TEMPLATE_TYPE.GAMES;
pub const TILE_TEMPLATE_CALENDAR = TILE_TEMPLATE_TYPE.CALENDAR;
pub const TILE_TEMPLATE_MUSICVIDEO = TILE_TEMPLATE_TYPE.MUSICVIDEO;
pub const TILE_TEMPLATE_PEOPLE = TILE_TEMPLATE_TYPE.PEOPLE;
pub const TILE_TEMPLATE_CONTACT = TILE_TEMPLATE_TYPE.CONTACT;
pub const TILE_TEMPLATE_GROUP = TILE_TEMPLATE_TYPE.GROUP;
pub const TILE_TEMPLATE_DEFAULT = TILE_TEMPLATE_TYPE.DEFAULT;
pub const TILE_TEMPLATE_BADGE = TILE_TEMPLATE_TYPE.BADGE;
pub const TILE_TEMPLATE_BLOCK = TILE_TEMPLATE_TYPE.BLOCK;
pub const TILE_TEMPLATE_TEXT01 = TILE_TEMPLATE_TYPE.TEXT01;
pub const TILE_TEMPLATE_TEXT02 = TILE_TEMPLATE_TYPE.TEXT02;
pub const TILE_TEMPLATE_TEXT03 = TILE_TEMPLATE_TYPE.TEXT03;
pub const TILE_TEMPLATE_TEXT04 = TILE_TEMPLATE_TYPE.TEXT04;
pub const TILE_TEMPLATE_TEXT05 = TILE_TEMPLATE_TYPE.TEXT05;
pub const TILE_TEMPLATE_TEXT06 = TILE_TEMPLATE_TYPE.TEXT06;
pub const TILE_TEMPLATE_TEXT07 = TILE_TEMPLATE_TYPE.TEXT07;
pub const TILE_TEMPLATE_TEXT08 = TILE_TEMPLATE_TYPE.TEXT08;
pub const TILE_TEMPLATE_TEXT09 = TILE_TEMPLATE_TYPE.TEXT09;
pub const TILE_TEMPLATE_TEXT10 = TILE_TEMPLATE_TYPE.TEXT10;
pub const TILE_TEMPLATE_TEXT11 = TILE_TEMPLATE_TYPE.TEXT11;
pub const TILE_TEMPLATE_IMAGE = TILE_TEMPLATE_TYPE.IMAGE;
pub const TILE_TEMPLATE_IMAGECOLLECTION = TILE_TEMPLATE_TYPE.IMAGECOLLECTION;
pub const TILE_TEMPLATE_IMAGEANDTEXT01 = TILE_TEMPLATE_TYPE.IMAGEANDTEXT01;
pub const TILE_TEMPLATE_IMAGEANDTEXT02 = TILE_TEMPLATE_TYPE.IMAGEANDTEXT02;
pub const TILE_TEMPLATE_BLOCKANDTEXT01 = TILE_TEMPLATE_TYPE.BLOCKANDTEXT01;
pub const TILE_TEMPLATE_BLOCKANDTEXT02 = TILE_TEMPLATE_TYPE.BLOCKANDTEXT02;
pub const TILE_TEMPLATE_PEEKIMAGEANDTEXT01 = TILE_TEMPLATE_TYPE.PEEKIMAGEANDTEXT01;
pub const TILE_TEMPLATE_PEEKIMAGEANDTEXT02 = TILE_TEMPLATE_TYPE.PEEKIMAGEANDTEXT02;
pub const TILE_TEMPLATE_PEEKIMAGEANDTEXT03 = TILE_TEMPLATE_TYPE.PEEKIMAGEANDTEXT03;
pub const TILE_TEMPLATE_PEEKIMAGEANDTEXT04 = TILE_TEMPLATE_TYPE.PEEKIMAGEANDTEXT04;
pub const TILE_TEMPLATE_PEEKIMAGE01 = TILE_TEMPLATE_TYPE.PEEKIMAGE01;
pub const TILE_TEMPLATE_PEEKIMAGE02 = TILE_TEMPLATE_TYPE.PEEKIMAGE02;
pub const TILE_TEMPLATE_PEEKIMAGE03 = TILE_TEMPLATE_TYPE.PEEKIMAGE03;
pub const TILE_TEMPLATE_PEEKIMAGE04 = TILE_TEMPLATE_TYPE.PEEKIMAGE04;
pub const TILE_TEMPLATE_PEEKIMAGE05 = TILE_TEMPLATE_TYPE.PEEKIMAGE05;
pub const TILE_TEMPLATE_PEEKIMAGE06 = TILE_TEMPLATE_TYPE.PEEKIMAGE06;
pub const TILE_TEMPLATE_PEEKIMAGECOLLECTION01 = TILE_TEMPLATE_TYPE.PEEKIMAGECOLLECTION01;
pub const TILE_TEMPLATE_PEEKIMAGECOLLECTION02 = TILE_TEMPLATE_TYPE.PEEKIMAGECOLLECTION02;
pub const TILE_TEMPLATE_PEEKIMAGECOLLECTION03 = TILE_TEMPLATE_TYPE.PEEKIMAGECOLLECTION03;
pub const TILE_TEMPLATE_PEEKIMAGECOLLECTION04 = TILE_TEMPLATE_TYPE.PEEKIMAGECOLLECTION04;
pub const TILE_TEMPLATE_PEEKIMAGECOLLECTION05 = TILE_TEMPLATE_TYPE.PEEKIMAGECOLLECTION05;
pub const TILE_TEMPLATE_PEEKIMAGECOLLECTION06 = TILE_TEMPLATE_TYPE.PEEKIMAGECOLLECTION06;
pub const TILE_TEMPLATE_SMALLIMAGEANDTEXT01 = TILE_TEMPLATE_TYPE.SMALLIMAGEANDTEXT01;
pub const TILE_TEMPLATE_SMALLIMAGEANDTEXT02 = TILE_TEMPLATE_TYPE.SMALLIMAGEANDTEXT02;
pub const TILE_TEMPLATE_SMALLIMAGEANDTEXT03 = TILE_TEMPLATE_TYPE.SMALLIMAGEANDTEXT03;
pub const TILE_TEMPLATE_SMALLIMAGEANDTEXT04 = TILE_TEMPLATE_TYPE.SMALLIMAGEANDTEXT04;
pub const TILE_TEMPLATE_SMALLIMAGEANDTEXT05 = TILE_TEMPLATE_TYPE.SMALLIMAGEANDTEXT05;
pub const TILE_TEMPLATE_METROCOUNTQUEUE = TILE_TEMPLATE_TYPE.METROCOUNTQUEUE;
pub const TILE_TEMPLATE_SEARCH = TILE_TEMPLATE_TYPE.SEARCH;
pub const TILE_TEMPLATE_TILEFLYOUT01 = TILE_TEMPLATE_TYPE.TILEFLYOUT01;
pub const TILE_TEMPLATE_FOLDER = TILE_TEMPLATE_TYPE.FOLDER;
pub const TILE_TEMPLATE_ALL = TILE_TEMPLATE_TYPE.ALL;
pub const PM_APP_GENRE = enum(i32) {
GAMES = 0,
OTHER = 1,
INVALID = 2,
};
pub const PM_APP_GENRE_GAMES = PM_APP_GENRE.GAMES;
pub const PM_APP_GENRE_OTHER = PM_APP_GENRE.OTHER;
pub const PM_APP_GENRE_INVALID = PM_APP_GENRE.INVALID;
pub const PM_APPLICATION_INSTALL_TYPE = enum(i32) {
NORMAL = 0,
IN_ROM = 1,
PA = 2,
DEBUG = 3,
ENTERPRISE = 4,
INVALID = 5,
};
pub const PM_APPLICATION_INSTALL_NORMAL = PM_APPLICATION_INSTALL_TYPE.NORMAL;
pub const PM_APPLICATION_INSTALL_IN_ROM = PM_APPLICATION_INSTALL_TYPE.IN_ROM;
pub const PM_APPLICATION_INSTALL_PA = PM_APPLICATION_INSTALL_TYPE.PA;
pub const PM_APPLICATION_INSTALL_DEBUG = PM_APPLICATION_INSTALL_TYPE.DEBUG;
pub const PM_APPLICATION_INSTALL_ENTERPRISE = PM_APPLICATION_INSTALL_TYPE.ENTERPRISE;
pub const PM_APPLICATION_INSTALL_INVALID = PM_APPLICATION_INSTALL_TYPE.INVALID;
pub const PM_APPLICATION_STATE = enum(i32) {
MIN = 0,
INSTALLED = 1,
INSTALLING = 2,
UPDATING = 3,
UNINSTALLING = 4,
LICENSE_UPDATING = 5,
MOVING = 6,
DISABLED_SD_CARD = 7,
DISABLED_ENTERPRISE = 8,
DISABLED_BACKING_UP = 9,
DISABLED_MDIL_BINDING = 10,
// MAX = 10, this enum value conflicts with DISABLED_MDIL_BINDING
INVALID = 11,
};
pub const PM_APPLICATION_STATE_MIN = PM_APPLICATION_STATE.MIN;
pub const PM_APPLICATION_STATE_INSTALLED = PM_APPLICATION_STATE.INSTALLED;
pub const PM_APPLICATION_STATE_INSTALLING = PM_APPLICATION_STATE.INSTALLING;
pub const PM_APPLICATION_STATE_UPDATING = PM_APPLICATION_STATE.UPDATING;
pub const PM_APPLICATION_STATE_UNINSTALLING = PM_APPLICATION_STATE.UNINSTALLING;
pub const PM_APPLICATION_STATE_LICENSE_UPDATING = PM_APPLICATION_STATE.LICENSE_UPDATING;
pub const PM_APPLICATION_STATE_MOVING = PM_APPLICATION_STATE.MOVING;
pub const PM_APPLICATION_STATE_DISABLED_SD_CARD = PM_APPLICATION_STATE.DISABLED_SD_CARD;
pub const PM_APPLICATION_STATE_DISABLED_ENTERPRISE = PM_APPLICATION_STATE.DISABLED_ENTERPRISE;
pub const PM_APPLICATION_STATE_DISABLED_BACKING_UP = PM_APPLICATION_STATE.DISABLED_BACKING_UP;
pub const PM_APPLICATION_STATE_DISABLED_MDIL_BINDING = PM_APPLICATION_STATE.DISABLED_MDIL_BINDING;
pub const PM_APPLICATION_STATE_MAX = PM_APPLICATION_STATE.DISABLED_MDIL_BINDING;
pub const PM_APPLICATION_STATE_INVALID = PM_APPLICATION_STATE.INVALID;
pub const PM_APPLICATION_HUBTYPE = enum(i32) {
NONMUSIC = 0,
MUSIC = 1,
INVALID = 2,
};
pub const PM_APPLICATION_HUBTYPE_NONMUSIC = PM_APPLICATION_HUBTYPE.NONMUSIC;
pub const PM_APPLICATION_HUBTYPE_MUSIC = PM_APPLICATION_HUBTYPE.MUSIC;
pub const PM_APPLICATION_HUBTYPE_INVALID = PM_APPLICATION_HUBTYPE.INVALID;
pub const PM_TILE_HUBTYPE = enum(i32) {
MUSIC = 1,
MOSETTINGS = 268435456,
GAMES = 536870912,
APPLIST = 1073741824,
STARTMENU = -2147483648,
LOCKSCREEN = 16777216,
KIDZONE = 33554432,
CACHED = 67108864,
INVALID = 67108865,
};
pub const PM_TILE_HUBTYPE_MUSIC = PM_TILE_HUBTYPE.MUSIC;
pub const PM_TILE_HUBTYPE_MOSETTINGS = PM_TILE_HUBTYPE.MOSETTINGS;
pub const PM_TILE_HUBTYPE_GAMES = PM_TILE_HUBTYPE.GAMES;
pub const PM_TILE_HUBTYPE_APPLIST = PM_TILE_HUBTYPE.APPLIST;
pub const PM_TILE_HUBTYPE_STARTMENU = PM_TILE_HUBTYPE.STARTMENU;
pub const PM_TILE_HUBTYPE_LOCKSCREEN = PM_TILE_HUBTYPE.LOCKSCREEN;
pub const PM_TILE_HUBTYPE_KIDZONE = PM_TILE_HUBTYPE.KIDZONE;
pub const PM_TILE_HUBTYPE_CACHED = PM_TILE_HUBTYPE.CACHED;
pub const PM_TILE_HUBTYPE_INVALID = PM_TILE_HUBTYPE.INVALID;
pub const PM_STARTTILE_TYPE = enum(i32) {
PRIMARY = 1,
SECONDARY = 2,
APPLIST = 3,
APPLISTPRIMARY = 4,
INVALID = 5,
};
pub const PM_STARTTILE_TYPE_PRIMARY = PM_STARTTILE_TYPE.PRIMARY;
pub const PM_STARTTILE_TYPE_SECONDARY = PM_STARTTILE_TYPE.SECONDARY;
pub const PM_STARTTILE_TYPE_APPLIST = PM_STARTTILE_TYPE.APPLIST;
pub const PM_STARTTILE_TYPE_APPLISTPRIMARY = PM_STARTTILE_TYPE.APPLISTPRIMARY;
pub const PM_STARTTILE_TYPE_INVALID = PM_STARTTILE_TYPE.INVALID;
pub const PM_TASK_TYPE = enum(i32) {
NORMAL = 0,
DEFAULT = 1,
SETTINGS = 2,
BACKGROUNDSERVICEAGENT = 3,
BACKGROUNDWORKER = 4,
INVALID = 5,
};
pub const PM_TASK_TYPE_NORMAL = PM_TASK_TYPE.NORMAL;
pub const PM_TASK_TYPE_DEFAULT = PM_TASK_TYPE.DEFAULT;
pub const PM_TASK_TYPE_SETTINGS = PM_TASK_TYPE.SETTINGS;
pub const PM_TASK_TYPE_BACKGROUNDSERVICEAGENT = PM_TASK_TYPE.BACKGROUNDSERVICEAGENT;
pub const PM_TASK_TYPE_BACKGROUNDWORKER = PM_TASK_TYPE.BACKGROUNDWORKER;
pub const PM_TASK_TYPE_INVALID = PM_TASK_TYPE.INVALID;
pub const PACKMAN_RUNTIME = enum(i32) {
NATIVE = 1,
SILVERLIGHTMOBILE = 2,
XNA = 3,
MODERN_NATIVE = 4,
JUPITER = 5,
INVALID = 6,
};
pub const PACKMAN_RUNTIME_NATIVE = PACKMAN_RUNTIME.NATIVE;
pub const PACKMAN_RUNTIME_SILVERLIGHTMOBILE = PACKMAN_RUNTIME.SILVERLIGHTMOBILE;
pub const PACKMAN_RUNTIME_XNA = PACKMAN_RUNTIME.XNA;
pub const PACKMAN_RUNTIME_MODERN_NATIVE = PACKMAN_RUNTIME.MODERN_NATIVE;
pub const PACKMAN_RUNTIME_JUPITER = PACKMAN_RUNTIME.JUPITER;
pub const PACKMAN_RUNTIME_INVALID = PACKMAN_RUNTIME.INVALID;
pub const PM_ACTIVATION_POLICY = enum(i32) {
RESUME = 0,
RESUMESAMEPARAMS = 1,
REPLACE = 2,
REPLACESAMEPARAMS = 3,
MULTISESSION = 4,
REPLACE_IGNOREFOREGROUND = 5,
UNKNOWN = 6,
INVALID = 7,
};
pub const PM_ACTIVATION_POLICY_RESUME = PM_ACTIVATION_POLICY.RESUME;
pub const PM_ACTIVATION_POLICY_RESUMESAMEPARAMS = PM_ACTIVATION_POLICY.RESUMESAMEPARAMS;
pub const PM_ACTIVATION_POLICY_REPLACE = PM_ACTIVATION_POLICY.REPLACE;
pub const PM_ACTIVATION_POLICY_REPLACESAMEPARAMS = PM_ACTIVATION_POLICY.REPLACESAMEPARAMS;
pub const PM_ACTIVATION_POLICY_MULTISESSION = PM_ACTIVATION_POLICY.MULTISESSION;
pub const PM_ACTIVATION_POLICY_REPLACE_IGNOREFOREGROUND = PM_ACTIVATION_POLICY.REPLACE_IGNOREFOREGROUND;
pub const PM_ACTIVATION_POLICY_UNKNOWN = PM_ACTIVATION_POLICY.UNKNOWN;
pub const PM_ACTIVATION_POLICY_INVALID = PM_ACTIVATION_POLICY.INVALID;
pub const PM_TASK_TRANSITION = enum(i32) {
DEFAULT = 0,
NONE = 1,
TURNSTILE = 2,
SLIDE = 3,
SWIVEL = 4,
READERBOARD = 5,
CUSTOM = 6,
INVALID = 7,
};
pub const PM_TASK_TRANSITION_DEFAULT = PM_TASK_TRANSITION.DEFAULT;
pub const PM_TASK_TRANSITION_NONE = PM_TASK_TRANSITION.NONE;
pub const PM_TASK_TRANSITION_TURNSTILE = PM_TASK_TRANSITION.TURNSTILE;
pub const PM_TASK_TRANSITION_SLIDE = PM_TASK_TRANSITION.SLIDE;
pub const PM_TASK_TRANSITION_SWIVEL = PM_TASK_TRANSITION.SWIVEL;
pub const PM_TASK_TRANSITION_READERBOARD = PM_TASK_TRANSITION.READERBOARD;
pub const PM_TASK_TRANSITION_CUSTOM = PM_TASK_TRANSITION.CUSTOM;
pub const PM_TASK_TRANSITION_INVALID = PM_TASK_TRANSITION.INVALID;
pub const PM_ENUM_APP_FILTER = enum(i32) {
ALL = 0,
VISIBLE = 1,
GENRE = 2,
NONGAMES = 3,
HUBTYPE = 4,
PINABLEONKIDZONE = 5,
ALL_INCLUDE_MODERN = 6,
FRAMEWORK = 7,
MAX = 8,
};
pub const PM_APP_FILTER_ALL = PM_ENUM_APP_FILTER.ALL;
pub const PM_APP_FILTER_VISIBLE = PM_ENUM_APP_FILTER.VISIBLE;
pub const PM_APP_FILTER_GENRE = PM_ENUM_APP_FILTER.GENRE;
pub const PM_APP_FILTER_NONGAMES = PM_ENUM_APP_FILTER.NONGAMES;
pub const PM_APP_FILTER_HUBTYPE = PM_ENUM_APP_FILTER.HUBTYPE;
pub const PM_APP_FILTER_PINABLEONKIDZONE = PM_ENUM_APP_FILTER.PINABLEONKIDZONE;
pub const PM_APP_FILTER_ALL_INCLUDE_MODERN = PM_ENUM_APP_FILTER.ALL_INCLUDE_MODERN;
pub const PM_APP_FILTER_FRAMEWORK = PM_ENUM_APP_FILTER.FRAMEWORK;
pub const PM_APP_FILTER_MAX = PM_ENUM_APP_FILTER.MAX;
pub const PM_ENUM_TILE_FILTER = enum(i32) {
APPLIST = 8,
PINNED = 9,
HUBTYPE = 10,
APP_ALL = 11,
MAX = 12,
};
pub const PM_TILE_FILTER_APPLIST = PM_ENUM_TILE_FILTER.APPLIST;
pub const PM_TILE_FILTER_PINNED = PM_ENUM_TILE_FILTER.PINNED;
pub const PM_TILE_FILTER_HUBTYPE = PM_ENUM_TILE_FILTER.HUBTYPE;
pub const PM_TILE_FILTER_APP_ALL = PM_ENUM_TILE_FILTER.APP_ALL;
pub const PM_TILE_FILTER_MAX = PM_ENUM_TILE_FILTER.MAX;
pub const PM_ENUM_TASK_FILTER = enum(i32) {
APP_ALL = 12,
TASK_TYPE = 13,
DEHYD_SUPRESSING = 14,
APP_TASK_TYPE = 15,
BGEXECUTION = 16,
MAX = 17,
};
pub const PM_TASK_FILTER_APP_ALL = PM_ENUM_TASK_FILTER.APP_ALL;
pub const PM_TASK_FILTER_TASK_TYPE = PM_ENUM_TASK_FILTER.TASK_TYPE;
pub const PM_TASK_FILTER_DEHYD_SUPRESSING = PM_ENUM_TASK_FILTER.DEHYD_SUPRESSING;
pub const PM_TASK_FILTER_APP_TASK_TYPE = PM_ENUM_TASK_FILTER.APP_TASK_TYPE;
pub const PM_TASK_FILTER_BGEXECUTION = PM_ENUM_TASK_FILTER.BGEXECUTION;
pub const PM_TASK_FILTER_MAX = PM_ENUM_TASK_FILTER.MAX;
pub const PM_ENUM_EXTENSION_FILTER = enum(i32) {
BY_CONSUMER = 17,
// APPCONNECT = 17, this enum value conflicts with BY_CONSUMER
PROTOCOL_ALL = 18,
FTASSOC_FILETYPE_ALL = 19,
FTASSOC_CONTENTTYPE_ALL = 20,
FTASSOC_APPLICATION_ALL = 21,
SHARETARGET_ALL = 22,
FILEOPENPICKER_ALL = 23,
FILESAVEPICKER_ALL = 24,
CACHEDFILEUPDATER_ALL = 25,
MAX = 26,
};
pub const PM_ENUM_EXTENSION_FILTER_BY_CONSUMER = PM_ENUM_EXTENSION_FILTER.BY_CONSUMER;
pub const PM_ENUM_EXTENSION_FILTER_APPCONNECT = PM_ENUM_EXTENSION_FILTER.BY_CONSUMER;
pub const PM_ENUM_EXTENSION_FILTER_PROTOCOL_ALL = PM_ENUM_EXTENSION_FILTER.PROTOCOL_ALL;
pub const PM_ENUM_EXTENSION_FILTER_FTASSOC_FILETYPE_ALL = PM_ENUM_EXTENSION_FILTER.FTASSOC_FILETYPE_ALL;
pub const PM_ENUM_EXTENSION_FILTER_FTASSOC_CONTENTTYPE_ALL = PM_ENUM_EXTENSION_FILTER.FTASSOC_CONTENTTYPE_ALL;
pub const PM_ENUM_EXTENSION_FILTER_FTASSOC_APPLICATION_ALL = PM_ENUM_EXTENSION_FILTER.FTASSOC_APPLICATION_ALL;
pub const PM_ENUM_EXTENSION_FILTER_SHARETARGET_ALL = PM_ENUM_EXTENSION_FILTER.SHARETARGET_ALL;
pub const PM_ENUM_EXTENSION_FILTER_FILEOPENPICKER_ALL = PM_ENUM_EXTENSION_FILTER.FILEOPENPICKER_ALL;
pub const PM_ENUM_EXTENSION_FILTER_FILESAVEPICKER_ALL = PM_ENUM_EXTENSION_FILTER.FILESAVEPICKER_ALL;
pub const PM_ENUM_EXTENSION_FILTER_CACHEDFILEUPDATER_ALL = PM_ENUM_EXTENSION_FILTER.CACHEDFILEUPDATER_ALL;
pub const PM_ENUM_EXTENSION_FILTER_MAX = PM_ENUM_EXTENSION_FILTER.MAX;
pub const PM_ENUM_BSA_FILTER = enum(i32) {
ALL = 26,
BY_TASKID = 27,
BY_PRODUCTID = 28,
BY_PERIODIC = 29,
BY_ALL_LAUNCHONBOOT = 30,
MAX = 31,
};
pub const PM_ENUM_BSA_FILTER_ALL = PM_ENUM_BSA_FILTER.ALL;
pub const PM_ENUM_BSA_FILTER_BY_TASKID = PM_ENUM_BSA_FILTER.BY_TASKID;
pub const PM_ENUM_BSA_FILTER_BY_PRODUCTID = PM_ENUM_BSA_FILTER.BY_PRODUCTID;
pub const PM_ENUM_BSA_FILTER_BY_PERIODIC = PM_ENUM_BSA_FILTER.BY_PERIODIC;
pub const PM_ENUM_BSA_FILTER_BY_ALL_LAUNCHONBOOT = PM_ENUM_BSA_FILTER.BY_ALL_LAUNCHONBOOT;
pub const PM_ENUM_BSA_FILTER_MAX = PM_ENUM_BSA_FILTER.MAX;
pub const PM_ENUM_BW_FILTER = enum(i32) {
BOOTWORKER_ALL = 31,
BY_TASKID = 32,
MAX = 33,
};
pub const PM_ENUM_BW_FILTER_BOOTWORKER_ALL = PM_ENUM_BW_FILTER.BOOTWORKER_ALL;
pub const PM_ENUM_BW_FILTER_BY_TASKID = PM_ENUM_BW_FILTER.BY_TASKID;
pub const PM_ENUM_BW_FILTER_MAX = PM_ENUM_BW_FILTER.MAX;
pub const _tagAPPTASKTYPE = extern struct {
ProductID: Guid,
TaskType: PM_TASK_TYPE,
};
pub const PM_EXTENSIONCONSUMER = extern struct {
ConsumerPID: Guid,
ExtensionID: ?BSTR,
};
pub const PM_BSATASKID = extern struct {
ProductID: Guid,
TaskID: ?BSTR,
};
pub const PM_BWTASKID = extern struct {
ProductID: Guid,
TaskID: ?BSTR,
};
pub const PM_ENUM_FILTER = extern struct {
FilterType: i32,
FilterParameter: extern union {
Dummy: i32,
Genre: PM_APP_GENRE,
AppHubType: PM_APPLICATION_HUBTYPE,
HubType: PM_TILE_HUBTYPE,
Tasktype: PM_TASK_TYPE,
TaskProductID: Guid,
TileProductID: Guid,
AppTaskType: _tagAPPTASKTYPE,
Consumer: PM_EXTENSIONCONSUMER,
BSATask: PM_BSATASKID,
BSAProductID: Guid,
BWTask: PM_BWTASKID,
ProtocolName: ?BSTR,
FileType: ?BSTR,
ContentType: ?BSTR,
AppSupportedFileExtPID: Guid,
ShareTargetFileType: ?BSTR,
},
};
pub const PM_LIVETILE_RECURRENCE_TYPE = enum(i32) {
INSTANT = 0,
ONETIME = 1,
INTERVAL = 2,
// MAX = 2, this enum value conflicts with INTERVAL
};
pub const PM_LIVETILE_RECURRENCE_TYPE_INSTANT = PM_LIVETILE_RECURRENCE_TYPE.INSTANT;
pub const PM_LIVETILE_RECURRENCE_TYPE_ONETIME = PM_LIVETILE_RECURRENCE_TYPE.ONETIME;
pub const PM_LIVETILE_RECURRENCE_TYPE_INTERVAL = PM_LIVETILE_RECURRENCE_TYPE.INTERVAL;
pub const PM_LIVETILE_RECURRENCE_TYPE_MAX = PM_LIVETILE_RECURRENCE_TYPE.INTERVAL;
pub const PM_TILE_SIZE = enum(i32) {
SMALL = 0,
MEDIUM = 1,
LARGE = 2,
SQUARE310X310 = 3,
TALL150X310 = 4,
INVALID = 5,
};
pub const PM_TILE_SIZE_SMALL = PM_TILE_SIZE.SMALL;
pub const PM_TILE_SIZE_MEDIUM = PM_TILE_SIZE.MEDIUM;
pub const PM_TILE_SIZE_LARGE = PM_TILE_SIZE.LARGE;
pub const PM_TILE_SIZE_SQUARE310X310 = PM_TILE_SIZE.SQUARE310X310;
pub const PM_TILE_SIZE_TALL150X310 = PM_TILE_SIZE.TALL150X310;
pub const PM_TILE_SIZE_INVALID = PM_TILE_SIZE.INVALID;
pub const PM_LOGO_SIZE = enum(i32) {
SMALL = 0,
MEDIUM = 1,
LARGE = 2,
INVALID = 3,
};
pub const PM_LOGO_SIZE_SMALL = PM_LOGO_SIZE.SMALL;
pub const PM_LOGO_SIZE_MEDIUM = PM_LOGO_SIZE.MEDIUM;
pub const PM_LOGO_SIZE_LARGE = PM_LOGO_SIZE.LARGE;
pub const PM_LOGO_SIZE_INVALID = PM_LOGO_SIZE.INVALID;
pub const PM_STARTAPPBLOB = extern struct {
cbSize: u32,
ProductID: Guid,
AppTitle: ?BSTR,
IconPath: ?BSTR,
IsUninstallable: BOOL,
AppInstallType: PM_APPLICATION_INSTALL_TYPE,
InstanceID: Guid,
State: PM_APPLICATION_STATE,
IsModern: BOOL,
IsModernLightUp: BOOL,
LightUpSupportMask: u16,
};
pub const PM_INVOCATIONINFO = extern struct {
URIBaseOrAUMID: ?BSTR,
URIFragmentOrArgs: ?BSTR,
};
pub const PM_STARTTILEBLOB = extern struct {
cbSize: u32,
ProductID: Guid,
TileID: ?BSTR,
TemplateType: TILE_TEMPLATE_TYPE,
HubPosition: [32]u32,
HubVisibilityBitmask: u32,
IsDefault: BOOL,
TileType: PM_STARTTILE_TYPE,
pbPropBlob: ?*u8,
cbPropBlob: u32,
IsRestoring: BOOL,
IsModern: BOOL,
InvocationInfo: PM_INVOCATIONINFO,
};
pub const PM_INSTALLINFO = extern struct {
ProductID: Guid,
PackagePath: ?BSTR,
InstanceID: Guid,
pbLicense: ?*u8,
cbLicense: u32,
IsUninstallDisabled: BOOL,
DeploymentOptions: u32,
OfferID: Guid,
MarketplaceAppVersion: ?BSTR,
};
pub const PM_UPDATEINFO_LEGACY = extern struct {
ProductID: Guid,
PackagePath: ?BSTR,
InstanceID: Guid,
pbLicense: ?*u8,
cbLicense: u32,
MarketplaceAppVersion: ?BSTR,
};
pub const PM_UPDATEINFO = extern struct {
ProductID: Guid,
PackagePath: ?BSTR,
InstanceID: Guid,
pbLicense: ?*u8,
cbLicense: u32,
MarketplaceAppVersion: ?BSTR,
DeploymentOptions: u32,
};
const IID_IPMApplicationInfo_Value = Guid.initString("50afb58a-438c-4088-9789-f8c4899829c7");
pub const IID_IPMApplicationInfo = &IID_IPMApplicationInfo_Value;
pub const IPMApplicationInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProductID: fn(
self: *const IPMApplicationInfo,
pProductID: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_InstanceID: fn(
self: *const IPMApplicationInfo,
pInstanceID: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_OfferID: fn(
self: *const IPMApplicationInfo,
pOfferID: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DefaultTask: fn(
self: *const IPMApplicationInfo,
pDefaultTask: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AppTitle: fn(
self: *const IPMApplicationInfo,
pAppTitle: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IconPath: fn(
self: *const IPMApplicationInfo,
pAppIconPath: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_NotificationState: fn(
self: *const IPMApplicationInfo,
pIsNotified: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AppInstallType: fn(
self: *const IPMApplicationInfo,
pAppInstallType: ?*PM_APPLICATION_INSTALL_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_State: fn(
self: *const IPMApplicationInfo,
pState: ?*PM_APPLICATION_STATE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsRevoked: fn(
self: *const IPMApplicationInfo,
pIsRevoked: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_UpdateAvailable: fn(
self: *const IPMApplicationInfo,
pIsUpdateAvailable: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_InstallDate: fn(
self: *const IPMApplicationInfo,
pInstallDate: ?*FILETIME,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsUninstallable: fn(
self: *const IPMApplicationInfo,
pIsUninstallable: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsThemable: fn(
self: *const IPMApplicationInfo,
pIsThemable: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsTrial: fn(
self: *const IPMApplicationInfo,
pIsTrial: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_InstallPath: fn(
self: *const IPMApplicationInfo,
pInstallPath: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DataRoot: fn(
self: *const IPMApplicationInfo,
pDataRoot: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Genre: fn(
self: *const IPMApplicationInfo,
pGenre: ?*PM_APP_GENRE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Publisher: fn(
self: *const IPMApplicationInfo,
pPublisher: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Author: fn(
self: *const IPMApplicationInfo,
pAuthor: ?*?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 IPMApplicationInfo,
pDescription: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Version: fn(
self: *const IPMApplicationInfo,
pVersion: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_InvocationInfo: fn(
self: *const IPMApplicationInfo,
pImageUrn: ?*?BSTR,
pParameters: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AppPlatMajorVersion: fn(
self: *const IPMApplicationInfo,
pMajorVer: ?*u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AppPlatMinorVersion: fn(
self: *const IPMApplicationInfo,
pMinorVer: ?*u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PublisherID: fn(
self: *const IPMApplicationInfo,
pPublisherID: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsMultiCore: fn(
self: *const IPMApplicationInfo,
pIsMultiCore: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SID: fn(
self: *const IPMApplicationInfo,
pSID: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AppPlatMajorVersionLightUp: fn(
self: *const IPMApplicationInfo,
pMajorVer: ?*u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AppPlatMinorVersionLightUp: fn(
self: *const IPMApplicationInfo,
pMinorVer: ?*u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_UpdateAvailable: fn(
self: *const IPMApplicationInfo,
IsUpdateAvailable: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_NotificationState: fn(
self: *const IPMApplicationInfo,
IsNotified: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_IconPath: fn(
self: *const IPMApplicationInfo,
AppIconPath: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_UninstallableState: fn(
self: *const IPMApplicationInfo,
IsUninstallable: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsPinableOnKidZone: fn(
self: *const IPMApplicationInfo,
pIsPinable: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsOriginallyPreInstalled: fn(
self: *const IPMApplicationInfo,
pIsPreinstalled: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsInstallOnSD: fn(
self: *const IPMApplicationInfo,
pIsInstallOnSD: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsOptoutOnSD: fn(
self: *const IPMApplicationInfo,
pIsOptoutOnSD: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsOptoutBackupRestore: fn(
self: *const IPMApplicationInfo,
pIsOptoutBackupRestore: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_EnterpriseDisabled: fn(
self: *const IPMApplicationInfo,
IsDisabled: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_EnterpriseUninstallable: fn(
self: *const IPMApplicationInfo,
IsUninstallable: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EnterpriseDisabled: fn(
self: *const IPMApplicationInfo,
IsDisabled: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EnterpriseUninstallable: fn(
self: *const IPMApplicationInfo,
IsUninstallable: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsVisibleOnAppList: fn(
self: *const IPMApplicationInfo,
pIsVisible: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsInboxApp: fn(
self: *const IPMApplicationInfo,
pIsInboxApp: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_StorageID: fn(
self: *const IPMApplicationInfo,
pStorageID: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_StartAppBlob: fn(
self: *const IPMApplicationInfo,
pBlob: ?*PM_STARTAPPBLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsMovable: fn(
self: *const IPMApplicationInfo,
pIsMovable: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DeploymentAppEnumerationHubFilter: fn(
self: *const IPMApplicationInfo,
HubType: ?*PM_TILE_HUBTYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ModifiedDate: fn(
self: *const IPMApplicationInfo,
pModifiedDate: ?*FILETIME,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsOriginallyRestored: fn(
self: *const IPMApplicationInfo,
pIsRestored: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ShouldDeferMdilBind: fn(
self: *const IPMApplicationInfo,
pfDeferMdilBind: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsFullyPreInstall: fn(
self: *const IPMApplicationInfo,
pfIsFullyPreInstall: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_IsMdilMaintenanceNeeded: fn(
self: *const IPMApplicationInfo,
fIsMdilMaintenanceNeeded: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_Title: fn(
self: *const IPMApplicationInfo,
AppTitle: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_ProductID(self: *const T, pProductID: ?*Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_ProductID(@ptrCast(*const IPMApplicationInfo, self), pProductID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_InstanceID(self: *const T, pInstanceID: ?*Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_InstanceID(@ptrCast(*const IPMApplicationInfo, self), pInstanceID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_OfferID(self: *const T, pOfferID: ?*Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_OfferID(@ptrCast(*const IPMApplicationInfo, self), pOfferID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_DefaultTask(self: *const T, pDefaultTask: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_DefaultTask(@ptrCast(*const IPMApplicationInfo, self), pDefaultTask);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_AppTitle(self: *const T, pAppTitle: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_AppTitle(@ptrCast(*const IPMApplicationInfo, self), pAppTitle);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_IconPath(self: *const T, pAppIconPath: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_IconPath(@ptrCast(*const IPMApplicationInfo, self), pAppIconPath);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_NotificationState(self: *const T, pIsNotified: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_NotificationState(@ptrCast(*const IPMApplicationInfo, self), pIsNotified);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_AppInstallType(self: *const T, pAppInstallType: ?*PM_APPLICATION_INSTALL_TYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_AppInstallType(@ptrCast(*const IPMApplicationInfo, self), pAppInstallType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_State(self: *const T, pState: ?*PM_APPLICATION_STATE) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_State(@ptrCast(*const IPMApplicationInfo, self), pState);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_IsRevoked(self: *const T, pIsRevoked: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_IsRevoked(@ptrCast(*const IPMApplicationInfo, self), pIsRevoked);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_UpdateAvailable(self: *const T, pIsUpdateAvailable: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_UpdateAvailable(@ptrCast(*const IPMApplicationInfo, self), pIsUpdateAvailable);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_InstallDate(self: *const T, pInstallDate: ?*FILETIME) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_InstallDate(@ptrCast(*const IPMApplicationInfo, self), pInstallDate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_IsUninstallable(self: *const T, pIsUninstallable: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_IsUninstallable(@ptrCast(*const IPMApplicationInfo, self), pIsUninstallable);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_IsThemable(self: *const T, pIsThemable: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_IsThemable(@ptrCast(*const IPMApplicationInfo, self), pIsThemable);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_IsTrial(self: *const T, pIsTrial: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_IsTrial(@ptrCast(*const IPMApplicationInfo, self), pIsTrial);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_InstallPath(self: *const T, pInstallPath: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_InstallPath(@ptrCast(*const IPMApplicationInfo, self), pInstallPath);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_DataRoot(self: *const T, pDataRoot: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_DataRoot(@ptrCast(*const IPMApplicationInfo, self), pDataRoot);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_Genre(self: *const T, pGenre: ?*PM_APP_GENRE) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_Genre(@ptrCast(*const IPMApplicationInfo, self), pGenre);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_Publisher(self: *const T, pPublisher: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_Publisher(@ptrCast(*const IPMApplicationInfo, self), pPublisher);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_Author(self: *const T, pAuthor: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_Author(@ptrCast(*const IPMApplicationInfo, self), pAuthor);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_Description(self: *const T, pDescription: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_Description(@ptrCast(*const IPMApplicationInfo, self), pDescription);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_Version(self: *const T, pVersion: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_Version(@ptrCast(*const IPMApplicationInfo, self), pVersion);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_InvocationInfo(self: *const T, pImageUrn: ?*?BSTR, pParameters: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_InvocationInfo(@ptrCast(*const IPMApplicationInfo, self), pImageUrn, pParameters);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_AppPlatMajorVersion(self: *const T, pMajorVer: ?*u8) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_AppPlatMajorVersion(@ptrCast(*const IPMApplicationInfo, self), pMajorVer);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_AppPlatMinorVersion(self: *const T, pMinorVer: ?*u8) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_AppPlatMinorVersion(@ptrCast(*const IPMApplicationInfo, self), pMinorVer);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_PublisherID(self: *const T, pPublisherID: ?*Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_PublisherID(@ptrCast(*const IPMApplicationInfo, self), pPublisherID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_IsMultiCore(self: *const T, pIsMultiCore: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_IsMultiCore(@ptrCast(*const IPMApplicationInfo, self), pIsMultiCore);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_SID(self: *const T, pSID: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_SID(@ptrCast(*const IPMApplicationInfo, self), pSID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_AppPlatMajorVersionLightUp(self: *const T, pMajorVer: ?*u8) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_AppPlatMajorVersionLightUp(@ptrCast(*const IPMApplicationInfo, self), pMajorVer);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_AppPlatMinorVersionLightUp(self: *const T, pMinorVer: ?*u8) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_AppPlatMinorVersionLightUp(@ptrCast(*const IPMApplicationInfo, self), pMinorVer);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_set_UpdateAvailable(self: *const T, IsUpdateAvailable: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).set_UpdateAvailable(@ptrCast(*const IPMApplicationInfo, self), IsUpdateAvailable);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_set_NotificationState(self: *const T, IsNotified: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).set_NotificationState(@ptrCast(*const IPMApplicationInfo, self), IsNotified);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_set_IconPath(self: *const T, AppIconPath: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).set_IconPath(@ptrCast(*const IPMApplicationInfo, self), AppIconPath);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_set_UninstallableState(self: *const T, IsUninstallable: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).set_UninstallableState(@ptrCast(*const IPMApplicationInfo, self), IsUninstallable);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_IsPinableOnKidZone(self: *const T, pIsPinable: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_IsPinableOnKidZone(@ptrCast(*const IPMApplicationInfo, self), pIsPinable);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_IsOriginallyPreInstalled(self: *const T, pIsPreinstalled: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_IsOriginallyPreInstalled(@ptrCast(*const IPMApplicationInfo, self), pIsPreinstalled);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_IsInstallOnSD(self: *const T, pIsInstallOnSD: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_IsInstallOnSD(@ptrCast(*const IPMApplicationInfo, self), pIsInstallOnSD);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_IsOptoutOnSD(self: *const T, pIsOptoutOnSD: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_IsOptoutOnSD(@ptrCast(*const IPMApplicationInfo, self), pIsOptoutOnSD);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_IsOptoutBackupRestore(self: *const T, pIsOptoutBackupRestore: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_IsOptoutBackupRestore(@ptrCast(*const IPMApplicationInfo, self), pIsOptoutBackupRestore);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_set_EnterpriseDisabled(self: *const T, IsDisabled: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).set_EnterpriseDisabled(@ptrCast(*const IPMApplicationInfo, self), IsDisabled);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_set_EnterpriseUninstallable(self: *const T, IsUninstallable: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).set_EnterpriseUninstallable(@ptrCast(*const IPMApplicationInfo, self), IsUninstallable);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_EnterpriseDisabled(self: *const T, IsDisabled: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_EnterpriseDisabled(@ptrCast(*const IPMApplicationInfo, self), IsDisabled);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_EnterpriseUninstallable(self: *const T, IsUninstallable: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_EnterpriseUninstallable(@ptrCast(*const IPMApplicationInfo, self), IsUninstallable);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_IsVisibleOnAppList(self: *const T, pIsVisible: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_IsVisibleOnAppList(@ptrCast(*const IPMApplicationInfo, self), pIsVisible);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_IsInboxApp(self: *const T, pIsInboxApp: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_IsInboxApp(@ptrCast(*const IPMApplicationInfo, self), pIsInboxApp);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_StorageID(self: *const T, pStorageID: ?*Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_StorageID(@ptrCast(*const IPMApplicationInfo, self), pStorageID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_StartAppBlob(self: *const T, pBlob: ?*PM_STARTAPPBLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_StartAppBlob(@ptrCast(*const IPMApplicationInfo, self), pBlob);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_IsMovable(self: *const T, pIsMovable: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_IsMovable(@ptrCast(*const IPMApplicationInfo, self), pIsMovable);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_DeploymentAppEnumerationHubFilter(self: *const T, HubType: ?*PM_TILE_HUBTYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_DeploymentAppEnumerationHubFilter(@ptrCast(*const IPMApplicationInfo, self), HubType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_ModifiedDate(self: *const T, pModifiedDate: ?*FILETIME) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_ModifiedDate(@ptrCast(*const IPMApplicationInfo, self), pModifiedDate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_IsOriginallyRestored(self: *const T, pIsRestored: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_IsOriginallyRestored(@ptrCast(*const IPMApplicationInfo, self), pIsRestored);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_ShouldDeferMdilBind(self: *const T, pfDeferMdilBind: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_ShouldDeferMdilBind(@ptrCast(*const IPMApplicationInfo, self), pfDeferMdilBind);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_get_IsFullyPreInstall(self: *const T, pfIsFullyPreInstall: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).get_IsFullyPreInstall(@ptrCast(*const IPMApplicationInfo, self), pfIsFullyPreInstall);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_set_IsMdilMaintenanceNeeded(self: *const T, fIsMdilMaintenanceNeeded: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).set_IsMdilMaintenanceNeeded(@ptrCast(*const IPMApplicationInfo, self), fIsMdilMaintenanceNeeded);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMApplicationInfo_set_Title(self: *const T, AppTitle: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfo.VTable, self.vtable).set_Title(@ptrCast(*const IPMApplicationInfo, self), AppTitle);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMTilePropertyInfo_Value = Guid.initString("6c2b8017-1efa-42a7-86c0-6d4b640bf528");
pub const IID_IPMTilePropertyInfo = &IID_IPMTilePropertyInfo_Value;
pub const IPMTilePropertyInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PropertyID: fn(
self: *const IPMTilePropertyInfo,
pPropID: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PropertyValue: fn(
self: *const IPMTilePropertyInfo,
pPropValue: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_Property: fn(
self: *const IPMTilePropertyInfo,
PropValue: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTilePropertyInfo_get_PropertyID(self: *const T, pPropID: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTilePropertyInfo.VTable, self.vtable).get_PropertyID(@ptrCast(*const IPMTilePropertyInfo, self), pPropID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTilePropertyInfo_get_PropertyValue(self: *const T, pPropValue: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTilePropertyInfo.VTable, self.vtable).get_PropertyValue(@ptrCast(*const IPMTilePropertyInfo, self), pPropValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTilePropertyInfo_set_Property(self: *const T, PropValue: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTilePropertyInfo.VTable, self.vtable).set_Property(@ptrCast(*const IPMTilePropertyInfo, self), PropValue);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMTilePropertyEnumerator_Value = Guid.initString("cc4cd629-9047-4250-aac8-930e47812421");
pub const IID_IPMTilePropertyEnumerator = &IID_IPMTilePropertyEnumerator_Value;
pub const IPMTilePropertyEnumerator = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Next: fn(
self: *const IPMTilePropertyEnumerator,
ppPropInfo: ?*?*IPMTilePropertyInfo,
) 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 IPMTilePropertyEnumerator_get_Next(self: *const T, ppPropInfo: ?*?*IPMTilePropertyInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTilePropertyEnumerator.VTable, self.vtable).get_Next(@ptrCast(*const IPMTilePropertyEnumerator, self), ppPropInfo);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMTileInfo_Value = Guid.initString("d1604833-2b08-4001-82cd-183ad734f752");
pub const IID_IPMTileInfo = &IID_IPMTileInfo_Value;
pub const IPMTileInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProductID: fn(
self: *const IPMTileInfo,
pProductID: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TileID: fn(
self: *const IPMTileInfo,
pTileID: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TemplateType: fn(
self: *const IPMTileInfo,
pTemplateType: ?*TILE_TEMPLATE_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_HubPinnedState: fn(
self: *const IPMTileInfo,
HubType: PM_TILE_HUBTYPE,
pPinned: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_HubPosition: fn(
self: *const IPMTileInfo,
HubType: PM_TILE_HUBTYPE,
pPosition: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsNotified: fn(
self: *const IPMTileInfo,
pIsNotified: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsDefault: fn(
self: *const IPMTileInfo,
pIsDefault: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TaskID: fn(
self: *const IPMTileInfo,
pTaskID: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TileType: fn(
self: *const IPMTileInfo,
pStartTileType: ?*PM_STARTTILE_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsThemable: fn(
self: *const IPMTileInfo,
pIsThemable: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PropertyById: fn(
self: *const IPMTileInfo,
PropID: u32,
ppPropInfo: ?*?*IPMTilePropertyInfo,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_InvocationInfo: fn(
self: *const IPMTileInfo,
pImageUrn: ?*?BSTR,
pParameters: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PropertyEnum: fn(
self: *const IPMTileInfo,
ppTilePropEnum: ?*?*IPMTilePropertyEnumerator,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_HubTileSize: fn(
self: *const IPMTileInfo,
HubType: PM_TILE_HUBTYPE,
pSize: ?*PM_TILE_SIZE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_HubPosition: fn(
self: *const IPMTileInfo,
HubType: PM_TILE_HUBTYPE,
Position: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_NotifiedState: fn(
self: *const IPMTileInfo,
Notified: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_HubPinnedState: fn(
self: *const IPMTileInfo,
HubType: PM_TILE_HUBTYPE,
Pinned: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_HubTileSize: fn(
self: *const IPMTileInfo,
HubType: PM_TILE_HUBTYPE,
Size: PM_TILE_SIZE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_InvocationInfo: fn(
self: *const IPMTileInfo,
TaskName: ?BSTR,
TaskParameters: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_StartTileBlob: fn(
self: *const IPMTileInfo,
pBlob: ?*PM_STARTTILEBLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsRestoring: fn(
self: *const IPMTileInfo,
pIsRestoring: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsAutoRestoreDisabled: fn(
self: *const IPMTileInfo,
pIsAutoRestoreDisabled: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_IsRestoring: fn(
self: *const IPMTileInfo,
Restoring: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_IsAutoRestoreDisabled: fn(
self: *const IPMTileInfo,
AutoRestoreDisabled: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_get_ProductID(self: *const T, pProductID: ?*Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).get_ProductID(@ptrCast(*const IPMTileInfo, self), pProductID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_get_TileID(self: *const T, pTileID: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).get_TileID(@ptrCast(*const IPMTileInfo, self), pTileID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_get_TemplateType(self: *const T, pTemplateType: ?*TILE_TEMPLATE_TYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).get_TemplateType(@ptrCast(*const IPMTileInfo, self), pTemplateType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_get_HubPinnedState(self: *const T, HubType: PM_TILE_HUBTYPE, pPinned: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).get_HubPinnedState(@ptrCast(*const IPMTileInfo, self), HubType, pPinned);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_get_HubPosition(self: *const T, HubType: PM_TILE_HUBTYPE, pPosition: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).get_HubPosition(@ptrCast(*const IPMTileInfo, self), HubType, pPosition);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_get_IsNotified(self: *const T, pIsNotified: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).get_IsNotified(@ptrCast(*const IPMTileInfo, self), pIsNotified);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_get_IsDefault(self: *const T, pIsDefault: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).get_IsDefault(@ptrCast(*const IPMTileInfo, self), pIsDefault);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_get_TaskID(self: *const T, pTaskID: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).get_TaskID(@ptrCast(*const IPMTileInfo, self), pTaskID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_get_TileType(self: *const T, pStartTileType: ?*PM_STARTTILE_TYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).get_TileType(@ptrCast(*const IPMTileInfo, self), pStartTileType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_get_IsThemable(self: *const T, pIsThemable: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).get_IsThemable(@ptrCast(*const IPMTileInfo, self), pIsThemable);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_get_PropertyById(self: *const T, PropID: u32, ppPropInfo: ?*?*IPMTilePropertyInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).get_PropertyById(@ptrCast(*const IPMTileInfo, self), PropID, ppPropInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_get_InvocationInfo(self: *const T, pImageUrn: ?*?BSTR, pParameters: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).get_InvocationInfo(@ptrCast(*const IPMTileInfo, self), pImageUrn, pParameters);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_get_PropertyEnum(self: *const T, ppTilePropEnum: ?*?*IPMTilePropertyEnumerator) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).get_PropertyEnum(@ptrCast(*const IPMTileInfo, self), ppTilePropEnum);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_get_HubTileSize(self: *const T, HubType: PM_TILE_HUBTYPE, pSize: ?*PM_TILE_SIZE) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).get_HubTileSize(@ptrCast(*const IPMTileInfo, self), HubType, pSize);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_set_HubPosition(self: *const T, HubType: PM_TILE_HUBTYPE, Position: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).set_HubPosition(@ptrCast(*const IPMTileInfo, self), HubType, Position);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_set_NotifiedState(self: *const T, Notified: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).set_NotifiedState(@ptrCast(*const IPMTileInfo, self), Notified);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_set_HubPinnedState(self: *const T, HubType: PM_TILE_HUBTYPE, Pinned: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).set_HubPinnedState(@ptrCast(*const IPMTileInfo, self), HubType, Pinned);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_set_HubTileSize(self: *const T, HubType: PM_TILE_HUBTYPE, Size: PM_TILE_SIZE) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).set_HubTileSize(@ptrCast(*const IPMTileInfo, self), HubType, Size);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_set_InvocationInfo(self: *const T, TaskName: ?BSTR, TaskParameters: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).set_InvocationInfo(@ptrCast(*const IPMTileInfo, self), TaskName, TaskParameters);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_get_StartTileBlob(self: *const T, pBlob: ?*PM_STARTTILEBLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).get_StartTileBlob(@ptrCast(*const IPMTileInfo, self), pBlob);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_get_IsRestoring(self: *const T, pIsRestoring: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).get_IsRestoring(@ptrCast(*const IPMTileInfo, self), pIsRestoring);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_get_IsAutoRestoreDisabled(self: *const T, pIsAutoRestoreDisabled: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).get_IsAutoRestoreDisabled(@ptrCast(*const IPMTileInfo, self), pIsAutoRestoreDisabled);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_set_IsRestoring(self: *const T, Restoring: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).set_IsRestoring(@ptrCast(*const IPMTileInfo, self), Restoring);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTileInfo_set_IsAutoRestoreDisabled(self: *const T, AutoRestoreDisabled: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfo.VTable, self.vtable).set_IsAutoRestoreDisabled(@ptrCast(*const IPMTileInfo, self), AutoRestoreDisabled);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMTileInfoEnumerator_Value = Guid.initString("ded83065-e462-4b2c-acb5-e39cea61c874");
pub const IID_IPMTileInfoEnumerator = &IID_IPMTileInfoEnumerator_Value;
pub const IPMTileInfoEnumerator = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Next: fn(
self: *const IPMTileInfoEnumerator,
ppTileInfo: ?*?*IPMTileInfo,
) 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 IPMTileInfoEnumerator_get_Next(self: *const T, ppTileInfo: ?*?*IPMTileInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTileInfoEnumerator.VTable, self.vtable).get_Next(@ptrCast(*const IPMTileInfoEnumerator, self), ppTileInfo);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMApplicationInfoEnumerator_Value = Guid.initString("0ec42a96-4d46-4dc6-a3d9-a7acaac0f5fa");
pub const IID_IPMApplicationInfoEnumerator = &IID_IPMApplicationInfoEnumerator_Value;
pub const IPMApplicationInfoEnumerator = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Next: fn(
self: *const IPMApplicationInfoEnumerator,
ppAppInfo: ?*?*IPMApplicationInfo,
) 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 IPMApplicationInfoEnumerator_get_Next(self: *const T, ppAppInfo: ?*?*IPMApplicationInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMApplicationInfoEnumerator.VTable, self.vtable).get_Next(@ptrCast(*const IPMApplicationInfoEnumerator, self), ppAppInfo);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMLiveTileJobInfo_Value = Guid.initString("6009a81f-4710-4697-b5f6-2208f6057b8e");
pub const IID_IPMLiveTileJobInfo = &IID_IPMLiveTileJobInfo_Value;
pub const IPMLiveTileJobInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProductID: fn(
self: *const IPMLiveTileJobInfo,
pProductID: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TileID: fn(
self: *const IPMLiveTileJobInfo,
pTileID: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_NextSchedule: fn(
self: *const IPMLiveTileJobInfo,
pNextSchedule: ?*FILETIME,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_NextSchedule: fn(
self: *const IPMLiveTileJobInfo,
ftNextSchedule: FILETIME,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_StartSchedule: fn(
self: *const IPMLiveTileJobInfo,
pStartSchedule: ?*FILETIME,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_StartSchedule: fn(
self: *const IPMLiveTileJobInfo,
ftStartSchedule: FILETIME,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IntervalDuration: fn(
self: *const IPMLiveTileJobInfo,
pIntervalDuration: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_IntervalDuration: fn(
self: *const IPMLiveTileJobInfo,
ulIntervalDuration: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RunForever: fn(
self: *const IPMLiveTileJobInfo,
IsRunForever: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_RunForever: fn(
self: *const IPMLiveTileJobInfo,
fRunForever: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MaxRunCount: fn(
self: *const IPMLiveTileJobInfo,
pMaxRunCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_MaxRunCount: fn(
self: *const IPMLiveTileJobInfo,
ulMaxRunCount: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RunCount: fn(
self: *const IPMLiveTileJobInfo,
pRunCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_RunCount: fn(
self: *const IPMLiveTileJobInfo,
ulRunCount: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RecurrenceType: fn(
self: *const IPMLiveTileJobInfo,
pRecurrenceType: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_RecurrenceType: fn(
self: *const IPMLiveTileJobInfo,
ulRecurrenceType: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TileXML: fn(
self: *const IPMLiveTileJobInfo,
pTileXml: ?[*]?*u8,
pcbTileXml: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_TileXML: fn(
self: *const IPMLiveTileJobInfo,
pTileXml: [*:0]u8,
cbTileXml: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_UrlXML: fn(
self: *const IPMLiveTileJobInfo,
pUrlXML: ?[*]?*u8,
pcbUrlXML: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_UrlXML: fn(
self: *const IPMLiveTileJobInfo,
pUrlXML: [*:0]u8,
cbUrlXML: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AttemptCount: fn(
self: *const IPMLiveTileJobInfo,
pAttemptCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_AttemptCount: fn(
self: *const IPMLiveTileJobInfo,
ulAttemptCount: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DownloadState: fn(
self: *const IPMLiveTileJobInfo,
pDownloadState: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_DownloadState: fn(
self: *const IPMLiveTileJobInfo,
ulDownloadState: 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 IPMLiveTileJobInfo_get_ProductID(self: *const T, pProductID: ?*Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).get_ProductID(@ptrCast(*const IPMLiveTileJobInfo, self), pProductID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_get_TileID(self: *const T, pTileID: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).get_TileID(@ptrCast(*const IPMLiveTileJobInfo, self), pTileID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_get_NextSchedule(self: *const T, pNextSchedule: ?*FILETIME) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).get_NextSchedule(@ptrCast(*const IPMLiveTileJobInfo, self), pNextSchedule);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_set_NextSchedule(self: *const T, ftNextSchedule: FILETIME) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).set_NextSchedule(@ptrCast(*const IPMLiveTileJobInfo, self), ftNextSchedule);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_get_StartSchedule(self: *const T, pStartSchedule: ?*FILETIME) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).get_StartSchedule(@ptrCast(*const IPMLiveTileJobInfo, self), pStartSchedule);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_set_StartSchedule(self: *const T, ftStartSchedule: FILETIME) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).set_StartSchedule(@ptrCast(*const IPMLiveTileJobInfo, self), ftStartSchedule);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_get_IntervalDuration(self: *const T, pIntervalDuration: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).get_IntervalDuration(@ptrCast(*const IPMLiveTileJobInfo, self), pIntervalDuration);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_set_IntervalDuration(self: *const T, ulIntervalDuration: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).set_IntervalDuration(@ptrCast(*const IPMLiveTileJobInfo, self), ulIntervalDuration);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_get_RunForever(self: *const T, IsRunForever: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).get_RunForever(@ptrCast(*const IPMLiveTileJobInfo, self), IsRunForever);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_set_RunForever(self: *const T, fRunForever: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).set_RunForever(@ptrCast(*const IPMLiveTileJobInfo, self), fRunForever);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_get_MaxRunCount(self: *const T, pMaxRunCount: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).get_MaxRunCount(@ptrCast(*const IPMLiveTileJobInfo, self), pMaxRunCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_set_MaxRunCount(self: *const T, ulMaxRunCount: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).set_MaxRunCount(@ptrCast(*const IPMLiveTileJobInfo, self), ulMaxRunCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_get_RunCount(self: *const T, pRunCount: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).get_RunCount(@ptrCast(*const IPMLiveTileJobInfo, self), pRunCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_set_RunCount(self: *const T, ulRunCount: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).set_RunCount(@ptrCast(*const IPMLiveTileJobInfo, self), ulRunCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_get_RecurrenceType(self: *const T, pRecurrenceType: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).get_RecurrenceType(@ptrCast(*const IPMLiveTileJobInfo, self), pRecurrenceType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_set_RecurrenceType(self: *const T, ulRecurrenceType: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).set_RecurrenceType(@ptrCast(*const IPMLiveTileJobInfo, self), ulRecurrenceType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_get_TileXML(self: *const T, pTileXml: ?[*]?*u8, pcbTileXml: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).get_TileXML(@ptrCast(*const IPMLiveTileJobInfo, self), pTileXml, pcbTileXml);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_set_TileXML(self: *const T, pTileXml: [*:0]u8, cbTileXml: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).set_TileXML(@ptrCast(*const IPMLiveTileJobInfo, self), pTileXml, cbTileXml);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_get_UrlXML(self: *const T, pUrlXML: ?[*]?*u8, pcbUrlXML: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).get_UrlXML(@ptrCast(*const IPMLiveTileJobInfo, self), pUrlXML, pcbUrlXML);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_set_UrlXML(self: *const T, pUrlXML: [*:0]u8, cbUrlXML: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).set_UrlXML(@ptrCast(*const IPMLiveTileJobInfo, self), pUrlXML, cbUrlXML);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_get_AttemptCount(self: *const T, pAttemptCount: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).get_AttemptCount(@ptrCast(*const IPMLiveTileJobInfo, self), pAttemptCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_set_AttemptCount(self: *const T, ulAttemptCount: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).set_AttemptCount(@ptrCast(*const IPMLiveTileJobInfo, self), ulAttemptCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_get_DownloadState(self: *const T, pDownloadState: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).get_DownloadState(@ptrCast(*const IPMLiveTileJobInfo, self), pDownloadState);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMLiveTileJobInfo_set_DownloadState(self: *const T, ulDownloadState: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfo.VTable, self.vtable).set_DownloadState(@ptrCast(*const IPMLiveTileJobInfo, self), ulDownloadState);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMLiveTileJobInfoEnumerator_Value = Guid.initString("bc042582-9415-4f36-9f99-06f104c07c03");
pub const IID_IPMLiveTileJobInfoEnumerator = &IID_IPMLiveTileJobInfoEnumerator_Value;
pub const IPMLiveTileJobInfoEnumerator = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Next: fn(
self: *const IPMLiveTileJobInfoEnumerator,
ppLiveTileJobInfo: ?*?*IPMLiveTileJobInfo,
) 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 IPMLiveTileJobInfoEnumerator_get_Next(self: *const T, ppLiveTileJobInfo: ?*?*IPMLiveTileJobInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMLiveTileJobInfoEnumerator.VTable, self.vtable).get_Next(@ptrCast(*const IPMLiveTileJobInfoEnumerator, self), ppLiveTileJobInfo);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMDeploymentManager_Value = Guid.initString("35f785fa-1979-4a8b-bc8f-fd70eb0d1544");
pub const IID_IPMDeploymentManager = &IID_IPMDeploymentManager_Value;
pub const IPMDeploymentManager = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
ReportDownloadBegin: fn(
self: *const IPMDeploymentManager,
productID: Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ReportDownloadProgress: fn(
self: *const IPMDeploymentManager,
productID: Guid,
usProgress: u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ReportDownloadComplete: fn(
self: *const IPMDeploymentManager,
productID: Guid,
hrResult: HRESULT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
BeginInstall: fn(
self: *const IPMDeploymentManager,
pInstallInfo: ?*PM_INSTALLINFO,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
BeginUpdate: fn(
self: *const IPMDeploymentManager,
pUpdateInfo: ?*PM_UPDATEINFO,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
BeginDeployPackage: fn(
self: *const IPMDeploymentManager,
pInstallInfo: ?*PM_INSTALLINFO,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
BeginUpdateDeployedPackageLegacy: fn(
self: *const IPMDeploymentManager,
pUpdateInfo: ?*PM_UPDATEINFO_LEGACY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
BeginUninstall: fn(
self: *const IPMDeploymentManager,
productID: Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
BeginEnterpriseAppInstall: fn(
self: *const IPMDeploymentManager,
pInstallInfo: ?*PM_INSTALLINFO,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
BeginEnterpriseAppUpdate: fn(
self: *const IPMDeploymentManager,
pUpdateInfo: ?*PM_UPDATEINFO,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
BeginUpdateLicense: fn(
self: *const IPMDeploymentManager,
productID: Guid,
offerID: Guid,
pbLicense: [*:0]u8,
cbLicense: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetLicenseChallenge: fn(
self: *const IPMDeploymentManager,
PackagePath: ?BSTR,
ppbChallenge: ?[*]?*u8,
pcbChallenge: ?*u32,
ppbKID: ?[*]?*u8,
pcbKID: ?*u32,
ppbDeviceID: ?[*]?*u8,
pcbDeviceID: ?*u32,
ppbSaltValue: ?[*]?*u8,
pcbSaltValue: ?*u32,
ppbKGVValue: ?[*]?*u8,
pcbKGVValue: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetLicenseChallengeByProductID: fn(
self: *const IPMDeploymentManager,
ProductID: Guid,
ppbChallenge: ?[*]?*u8,
pcbLicense: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetLicenseChallengeByProductID2: fn(
self: *const IPMDeploymentManager,
ProductID: Guid,
ppbChallenge: ?[*]?*u8,
pcbLicense: ?*u32,
ppbKID: ?[*]?*u8,
pcbKID: ?*u32,
ppbDeviceID: ?[*]?*u8,
pcbDeviceID: ?*u32,
ppbSaltValue: ?[*]?*u8,
pcbSaltValue: ?*u32,
ppbKGVValue: ?[*]?*u8,
pcbKGVValue: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
RevokeLicense: fn(
self: *const IPMDeploymentManager,
productID: Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
RebindMdilBinaries: fn(
self: *const IPMDeploymentManager,
ProductID: Guid,
FileNames: ?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
RebindAllMdilBinaries: fn(
self: *const IPMDeploymentManager,
ProductID: Guid,
InstanceID: Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
RegenerateXbf: fn(
self: *const IPMDeploymentManager,
ProductID: Guid,
AssemblyPaths: ?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GenerateXbfForCurrentLocale: fn(
self: *const IPMDeploymentManager,
ProductID: Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
BeginProvision: fn(
self: *const IPMDeploymentManager,
ProductID: Guid,
XMLpath: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
BeginDeprovision: fn(
self: *const IPMDeploymentManager,
ProductID: Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ReindexSQLCEDatabases: fn(
self: *const IPMDeploymentManager,
ProductID: Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetApplicationsNeedMaintenance: fn(
self: *const IPMDeploymentManager,
RequiredMaintenanceOperations: u32,
pcApplications: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
UpdateChamberProfile: fn(
self: *const IPMDeploymentManager,
ProductID: Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnterprisePolicyIsApplicationAllowed: fn(
self: *const IPMDeploymentManager,
productId: Guid,
publisherName: ?[*:0]const u16,
pIsAllowed: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
BeginUpdateDeployedPackage: fn(
self: *const IPMDeploymentManager,
pUpdateInfo: ?*PM_UPDATEINFO,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ReportRestoreCancelled: fn(
self: *const IPMDeploymentManager,
productID: Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ResolveResourceString: fn(
self: *const IPMDeploymentManager,
resourceString: ?[*:0]const u16,
pResolvedResourceString: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
UpdateCapabilitiesForModernApps: fn(
self: *const IPMDeploymentManager,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ReportDownloadStatusUpdate: fn(
self: *const IPMDeploymentManager,
productId: Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
BeginUninstallWithOptions: fn(
self: *const IPMDeploymentManager,
productID: Guid,
removalOptions: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
BindDeferredMdilBinaries: fn(
self: *const IPMDeploymentManager,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GenerateXamlLightupXbfForCurrentLocale: fn(
self: *const IPMDeploymentManager,
PackageFamilyName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddLicenseForAppx: fn(
self: *const IPMDeploymentManager,
productID: Guid,
pbLicense: [*:0]u8,
cbLicense: u32,
pbPlayReadyHeader: ?[*:0]u8,
cbPlayReadyHeader: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
FixJunctionsForAppsOnSDCard: fn(
self: *const IPMDeploymentManager,
) 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 IPMDeploymentManager_ReportDownloadBegin(self: *const T, productID: Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).ReportDownloadBegin(@ptrCast(*const IPMDeploymentManager, self), productID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_ReportDownloadProgress(self: *const T, productID: Guid, usProgress: u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).ReportDownloadProgress(@ptrCast(*const IPMDeploymentManager, self), productID, usProgress);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_ReportDownloadComplete(self: *const T, productID: Guid, hrResult: HRESULT) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).ReportDownloadComplete(@ptrCast(*const IPMDeploymentManager, self), productID, hrResult);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_BeginInstall(self: *const T, pInstallInfo: ?*PM_INSTALLINFO) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).BeginInstall(@ptrCast(*const IPMDeploymentManager, self), pInstallInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_BeginUpdate(self: *const T, pUpdateInfo: ?*PM_UPDATEINFO) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).BeginUpdate(@ptrCast(*const IPMDeploymentManager, self), pUpdateInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_BeginDeployPackage(self: *const T, pInstallInfo: ?*PM_INSTALLINFO) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).BeginDeployPackage(@ptrCast(*const IPMDeploymentManager, self), pInstallInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_BeginUpdateDeployedPackageLegacy(self: *const T, pUpdateInfo: ?*PM_UPDATEINFO_LEGACY) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).BeginUpdateDeployedPackageLegacy(@ptrCast(*const IPMDeploymentManager, self), pUpdateInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_BeginUninstall(self: *const T, productID: Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).BeginUninstall(@ptrCast(*const IPMDeploymentManager, self), productID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_BeginEnterpriseAppInstall(self: *const T, pInstallInfo: ?*PM_INSTALLINFO) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).BeginEnterpriseAppInstall(@ptrCast(*const IPMDeploymentManager, self), pInstallInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_BeginEnterpriseAppUpdate(self: *const T, pUpdateInfo: ?*PM_UPDATEINFO) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).BeginEnterpriseAppUpdate(@ptrCast(*const IPMDeploymentManager, self), pUpdateInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_BeginUpdateLicense(self: *const T, productID: Guid, offerID: Guid, pbLicense: [*:0]u8, cbLicense: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).BeginUpdateLicense(@ptrCast(*const IPMDeploymentManager, self), productID, offerID, pbLicense, cbLicense);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_GetLicenseChallenge(self: *const T, PackagePath: ?BSTR, ppbChallenge: ?[*]?*u8, pcbChallenge: ?*u32, ppbKID: ?[*]?*u8, pcbKID: ?*u32, ppbDeviceID: ?[*]?*u8, pcbDeviceID: ?*u32, ppbSaltValue: ?[*]?*u8, pcbSaltValue: ?*u32, ppbKGVValue: ?[*]?*u8, pcbKGVValue: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).GetLicenseChallenge(@ptrCast(*const IPMDeploymentManager, self), PackagePath, ppbChallenge, pcbChallenge, ppbKID, pcbKID, ppbDeviceID, pcbDeviceID, ppbSaltValue, pcbSaltValue, ppbKGVValue, pcbKGVValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_GetLicenseChallengeByProductID(self: *const T, ProductID: Guid, ppbChallenge: ?[*]?*u8, pcbLicense: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).GetLicenseChallengeByProductID(@ptrCast(*const IPMDeploymentManager, self), ProductID, ppbChallenge, pcbLicense);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_GetLicenseChallengeByProductID2(self: *const T, ProductID: Guid, ppbChallenge: ?[*]?*u8, pcbLicense: ?*u32, ppbKID: ?[*]?*u8, pcbKID: ?*u32, ppbDeviceID: ?[*]?*u8, pcbDeviceID: ?*u32, ppbSaltValue: ?[*]?*u8, pcbSaltValue: ?*u32, ppbKGVValue: ?[*]?*u8, pcbKGVValue: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).GetLicenseChallengeByProductID2(@ptrCast(*const IPMDeploymentManager, self), ProductID, ppbChallenge, pcbLicense, ppbKID, pcbKID, ppbDeviceID, pcbDeviceID, ppbSaltValue, pcbSaltValue, ppbKGVValue, pcbKGVValue);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_RevokeLicense(self: *const T, productID: Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).RevokeLicense(@ptrCast(*const IPMDeploymentManager, self), productID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_RebindMdilBinaries(self: *const T, ProductID: Guid, FileNames: ?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).RebindMdilBinaries(@ptrCast(*const IPMDeploymentManager, self), ProductID, FileNames);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_RebindAllMdilBinaries(self: *const T, ProductID: Guid, InstanceID: Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).RebindAllMdilBinaries(@ptrCast(*const IPMDeploymentManager, self), ProductID, InstanceID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_RegenerateXbf(self: *const T, ProductID: Guid, AssemblyPaths: ?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).RegenerateXbf(@ptrCast(*const IPMDeploymentManager, self), ProductID, AssemblyPaths);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_GenerateXbfForCurrentLocale(self: *const T, ProductID: Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).GenerateXbfForCurrentLocale(@ptrCast(*const IPMDeploymentManager, self), ProductID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_BeginProvision(self: *const T, ProductID: Guid, XMLpath: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).BeginProvision(@ptrCast(*const IPMDeploymentManager, self), ProductID, XMLpath);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_BeginDeprovision(self: *const T, ProductID: Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).BeginDeprovision(@ptrCast(*const IPMDeploymentManager, self), ProductID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_ReindexSQLCEDatabases(self: *const T, ProductID: Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).ReindexSQLCEDatabases(@ptrCast(*const IPMDeploymentManager, self), ProductID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_SetApplicationsNeedMaintenance(self: *const T, RequiredMaintenanceOperations: u32, pcApplications: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).SetApplicationsNeedMaintenance(@ptrCast(*const IPMDeploymentManager, self), RequiredMaintenanceOperations, pcApplications);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_UpdateChamberProfile(self: *const T, ProductID: Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).UpdateChamberProfile(@ptrCast(*const IPMDeploymentManager, self), ProductID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_EnterprisePolicyIsApplicationAllowed(self: *const T, productId: Guid, publisherName: ?[*:0]const u16, pIsAllowed: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).EnterprisePolicyIsApplicationAllowed(@ptrCast(*const IPMDeploymentManager, self), productId, publisherName, pIsAllowed);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_BeginUpdateDeployedPackage(self: *const T, pUpdateInfo: ?*PM_UPDATEINFO) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).BeginUpdateDeployedPackage(@ptrCast(*const IPMDeploymentManager, self), pUpdateInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_ReportRestoreCancelled(self: *const T, productID: Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).ReportRestoreCancelled(@ptrCast(*const IPMDeploymentManager, self), productID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_ResolveResourceString(self: *const T, resourceString: ?[*:0]const u16, pResolvedResourceString: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).ResolveResourceString(@ptrCast(*const IPMDeploymentManager, self), resourceString, pResolvedResourceString);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_UpdateCapabilitiesForModernApps(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).UpdateCapabilitiesForModernApps(@ptrCast(*const IPMDeploymentManager, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_ReportDownloadStatusUpdate(self: *const T, productId: Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).ReportDownloadStatusUpdate(@ptrCast(*const IPMDeploymentManager, self), productId);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_BeginUninstallWithOptions(self: *const T, productID: Guid, removalOptions: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).BeginUninstallWithOptions(@ptrCast(*const IPMDeploymentManager, self), productID, removalOptions);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_BindDeferredMdilBinaries(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).BindDeferredMdilBinaries(@ptrCast(*const IPMDeploymentManager, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_GenerateXamlLightupXbfForCurrentLocale(self: *const T, PackageFamilyName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).GenerateXamlLightupXbfForCurrentLocale(@ptrCast(*const IPMDeploymentManager, self), PackageFamilyName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_AddLicenseForAppx(self: *const T, productID: Guid, pbLicense: [*:0]u8, cbLicense: u32, pbPlayReadyHeader: ?[*:0]u8, cbPlayReadyHeader: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).AddLicenseForAppx(@ptrCast(*const IPMDeploymentManager, self), productID, pbLicense, cbLicense, pbPlayReadyHeader, cbPlayReadyHeader);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMDeploymentManager_FixJunctionsForAppsOnSDCard(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMDeploymentManager.VTable, self.vtable).FixJunctionsForAppsOnSDCard(@ptrCast(*const IPMDeploymentManager, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMEnumerationManager_Value = Guid.initString("698d57c2-292d-4cf3-b73c-d95a6922ed9a");
pub const IID_IPMEnumerationManager = &IID_IPMEnumerationManager_Value;
pub const IPMEnumerationManager = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AllApplications: fn(
self: *const IPMEnumerationManager,
ppAppEnum: ?*?*IPMApplicationInfoEnumerator,
Filter: PM_ENUM_FILTER,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AllTiles: fn(
self: *const IPMEnumerationManager,
ppTileEnum: ?*?*IPMTileInfoEnumerator,
Filter: PM_ENUM_FILTER,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AllTasks: fn(
self: *const IPMEnumerationManager,
ppTaskEnum: ?*?*IPMTaskInfoEnumerator,
Filter: PM_ENUM_FILTER,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AllExtensions: fn(
self: *const IPMEnumerationManager,
ppExtensionEnum: ?*?*IPMExtensionInfoEnumerator,
Filter: PM_ENUM_FILTER,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AllBackgroundServiceAgents: fn(
self: *const IPMEnumerationManager,
ppBSAEnum: ?*?*IPMBackgroundServiceAgentInfoEnumerator,
Filter: PM_ENUM_FILTER,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AllBackgroundWorkers: fn(
self: *const IPMEnumerationManager,
ppBSWEnum: ?*?*IPMBackgroundWorkerInfoEnumerator,
Filter: PM_ENUM_FILTER,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ApplicationInfo: fn(
self: *const IPMEnumerationManager,
ProductID: Guid,
ppAppInfo: ?*?*IPMApplicationInfo,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TileInfo: fn(
self: *const IPMEnumerationManager,
ProductID: Guid,
TileID: ?BSTR,
ppTileInfo: ?*?*IPMTileInfo,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TaskInfo: fn(
self: *const IPMEnumerationManager,
ProductID: Guid,
TaskID: ?BSTR,
ppTaskInfo: ?*?*IPMTaskInfo,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TaskInfoEx: fn(
self: *const IPMEnumerationManager,
ProductID: Guid,
TaskID: ?[*:0]const u16,
ppTaskInfo: ?*?*IPMTaskInfo,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BackgroundServiceAgentInfo: fn(
self: *const IPMEnumerationManager,
BSAID: u32,
ppTaskInfo: ?*?*IPMBackgroundServiceAgentInfo,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AllLiveTileJobs: fn(
self: *const IPMEnumerationManager,
ppLiveTileJobEnum: ?*?*IPMLiveTileJobInfoEnumerator,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_LiveTileJob: fn(
self: *const IPMEnumerationManager,
ProductID: Guid,
TileID: ?BSTR,
RecurrenceType: PM_LIVETILE_RECURRENCE_TYPE,
ppLiveTileJobInfo: ?*?*IPMLiveTileJobInfo,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ApplicationInfoExternal: fn(
self: *const IPMEnumerationManager,
ProductID: Guid,
ppAppInfo: ?*?*IPMApplicationInfo,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_FileHandlerGenericLogo: fn(
self: *const IPMEnumerationManager,
FileType: ?BSTR,
LogoSize: PM_LOGO_SIZE,
pLogo: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ApplicationInfoFromAccessClaims: fn(
self: *const IPMEnumerationManager,
SysAppID0: ?BSTR,
SysAppID1: ?BSTR,
ppAppInfo: ?*?*IPMApplicationInfo,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_StartTileEnumeratorBlob: fn(
self: *const IPMEnumerationManager,
Filter: PM_ENUM_FILTER,
pcTiles: ?*u32,
ppTileBlobs: ?[*]?*PM_STARTTILEBLOB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_StartAppEnumeratorBlob: fn(
self: *const IPMEnumerationManager,
Filter: PM_ENUM_FILTER,
pcApps: ?*u32,
ppAppBlobs: ?[*]?*PM_STARTAPPBLOB,
) 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 IPMEnumerationManager_get_AllApplications(self: *const T, ppAppEnum: ?*?*IPMApplicationInfoEnumerator, Filter: PM_ENUM_FILTER) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMEnumerationManager.VTable, self.vtable).get_AllApplications(@ptrCast(*const IPMEnumerationManager, self), ppAppEnum, Filter);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMEnumerationManager_get_AllTiles(self: *const T, ppTileEnum: ?*?*IPMTileInfoEnumerator, Filter: PM_ENUM_FILTER) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMEnumerationManager.VTable, self.vtable).get_AllTiles(@ptrCast(*const IPMEnumerationManager, self), ppTileEnum, Filter);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMEnumerationManager_get_AllTasks(self: *const T, ppTaskEnum: ?*?*IPMTaskInfoEnumerator, Filter: PM_ENUM_FILTER) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMEnumerationManager.VTable, self.vtable).get_AllTasks(@ptrCast(*const IPMEnumerationManager, self), ppTaskEnum, Filter);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMEnumerationManager_get_AllExtensions(self: *const T, ppExtensionEnum: ?*?*IPMExtensionInfoEnumerator, Filter: PM_ENUM_FILTER) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMEnumerationManager.VTable, self.vtable).get_AllExtensions(@ptrCast(*const IPMEnumerationManager, self), ppExtensionEnum, Filter);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMEnumerationManager_get_AllBackgroundServiceAgents(self: *const T, ppBSAEnum: ?*?*IPMBackgroundServiceAgentInfoEnumerator, Filter: PM_ENUM_FILTER) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMEnumerationManager.VTable, self.vtable).get_AllBackgroundServiceAgents(@ptrCast(*const IPMEnumerationManager, self), ppBSAEnum, Filter);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMEnumerationManager_get_AllBackgroundWorkers(self: *const T, ppBSWEnum: ?*?*IPMBackgroundWorkerInfoEnumerator, Filter: PM_ENUM_FILTER) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMEnumerationManager.VTable, self.vtable).get_AllBackgroundWorkers(@ptrCast(*const IPMEnumerationManager, self), ppBSWEnum, Filter);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMEnumerationManager_get_ApplicationInfo(self: *const T, ProductID: Guid, ppAppInfo: ?*?*IPMApplicationInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMEnumerationManager.VTable, self.vtable).get_ApplicationInfo(@ptrCast(*const IPMEnumerationManager, self), ProductID, ppAppInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMEnumerationManager_get_TileInfo(self: *const T, ProductID: Guid, TileID: ?BSTR, ppTileInfo: ?*?*IPMTileInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMEnumerationManager.VTable, self.vtable).get_TileInfo(@ptrCast(*const IPMEnumerationManager, self), ProductID, TileID, ppTileInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMEnumerationManager_get_TaskInfo(self: *const T, ProductID: Guid, TaskID: ?BSTR, ppTaskInfo: ?*?*IPMTaskInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMEnumerationManager.VTable, self.vtable).get_TaskInfo(@ptrCast(*const IPMEnumerationManager, self), ProductID, TaskID, ppTaskInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMEnumerationManager_get_TaskInfoEx(self: *const T, ProductID: Guid, TaskID: ?[*:0]const u16, ppTaskInfo: ?*?*IPMTaskInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMEnumerationManager.VTable, self.vtable).get_TaskInfoEx(@ptrCast(*const IPMEnumerationManager, self), ProductID, TaskID, ppTaskInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMEnumerationManager_get_BackgroundServiceAgentInfo(self: *const T, BSAID: u32, ppTaskInfo: ?*?*IPMBackgroundServiceAgentInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMEnumerationManager.VTable, self.vtable).get_BackgroundServiceAgentInfo(@ptrCast(*const IPMEnumerationManager, self), BSAID, ppTaskInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMEnumerationManager_get_AllLiveTileJobs(self: *const T, ppLiveTileJobEnum: ?*?*IPMLiveTileJobInfoEnumerator) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMEnumerationManager.VTable, self.vtable).get_AllLiveTileJobs(@ptrCast(*const IPMEnumerationManager, self), ppLiveTileJobEnum);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMEnumerationManager_get_LiveTileJob(self: *const T, ProductID: Guid, TileID: ?BSTR, RecurrenceType: PM_LIVETILE_RECURRENCE_TYPE, ppLiveTileJobInfo: ?*?*IPMLiveTileJobInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMEnumerationManager.VTable, self.vtable).get_LiveTileJob(@ptrCast(*const IPMEnumerationManager, self), ProductID, TileID, RecurrenceType, ppLiveTileJobInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMEnumerationManager_get_ApplicationInfoExternal(self: *const T, ProductID: Guid, ppAppInfo: ?*?*IPMApplicationInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMEnumerationManager.VTable, self.vtable).get_ApplicationInfoExternal(@ptrCast(*const IPMEnumerationManager, self), ProductID, ppAppInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMEnumerationManager_get_FileHandlerGenericLogo(self: *const T, FileType: ?BSTR, LogoSize: PM_LOGO_SIZE, pLogo: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMEnumerationManager.VTable, self.vtable).get_FileHandlerGenericLogo(@ptrCast(*const IPMEnumerationManager, self), FileType, LogoSize, pLogo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMEnumerationManager_get_ApplicationInfoFromAccessClaims(self: *const T, SysAppID0: ?BSTR, SysAppID1: ?BSTR, ppAppInfo: ?*?*IPMApplicationInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMEnumerationManager.VTable, self.vtable).get_ApplicationInfoFromAccessClaims(@ptrCast(*const IPMEnumerationManager, self), SysAppID0, SysAppID1, ppAppInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMEnumerationManager_get_StartTileEnumeratorBlob(self: *const T, Filter: PM_ENUM_FILTER, pcTiles: ?*u32, ppTileBlobs: ?[*]?*PM_STARTTILEBLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMEnumerationManager.VTable, self.vtable).get_StartTileEnumeratorBlob(@ptrCast(*const IPMEnumerationManager, self), Filter, pcTiles, ppTileBlobs);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMEnumerationManager_get_StartAppEnumeratorBlob(self: *const T, Filter: PM_ENUM_FILTER, pcApps: ?*u32, ppAppBlobs: ?[*]?*PM_STARTAPPBLOB) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMEnumerationManager.VTable, self.vtable).get_StartAppEnumeratorBlob(@ptrCast(*const IPMEnumerationManager, self), Filter, pcApps, ppAppBlobs);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMTaskInfo_Value = Guid.initString("bf1d8c33-1bf5-4ee0-b549-6b9dd3834942");
pub const IID_IPMTaskInfo = &IID_IPMTaskInfo_Value;
pub const IPMTaskInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProductID: fn(
self: *const IPMTaskInfo,
pProductID: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TaskID: fn(
self: *const IPMTaskInfo,
pTaskID: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_NavigationPage: fn(
self: *const IPMTaskInfo,
pNavigationPage: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TaskTransition: fn(
self: *const IPMTaskInfo,
pTaskTransition: ?*PM_TASK_TRANSITION,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RuntimeType: fn(
self: *const IPMTaskInfo,
pRuntimetype: ?*PACKMAN_RUNTIME,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ActivationPolicy: fn(
self: *const IPMTaskInfo,
pActivationPolicy: ?*PM_ACTIVATION_POLICY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TaskType: fn(
self: *const IPMTaskInfo,
pTaskType: ?*PM_TASK_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_InvocationInfo: fn(
self: *const IPMTaskInfo,
pImageUrn: ?*?BSTR,
pParameters: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ImagePath: fn(
self: *const IPMTaskInfo,
pImagePath: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ImageParams: fn(
self: *const IPMTaskInfo,
pImageParams: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_InstallRootFolder: fn(
self: *const IPMTaskInfo,
pInstallRootFolder: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DataRootFolder: fn(
self: *const IPMTaskInfo,
pDataRootFolder: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsSingleInstanceHost: fn(
self: *const IPMTaskInfo,
pIsSingleInstanceHost: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsInteropEnabled: fn(
self: *const IPMTaskInfo,
pIsInteropEnabled: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ApplicationState: fn(
self: *const IPMTaskInfo,
pApplicationState: ?*PM_APPLICATION_STATE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_InstallType: fn(
self: *const IPMTaskInfo,
pInstallType: ?*PM_APPLICATION_INSTALL_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Version: fn(
self: *const IPMTaskInfo,
pTargetMajorVersion: ?*u8,
pTargetMinorVersion: ?*u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BitsPerPixel: fn(
self: *const IPMTaskInfo,
pBitsPerPixel: ?*u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SuppressesDehydration: fn(
self: *const IPMTaskInfo,
pSuppressesDehydration: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BackgroundExecutionAbilities: fn(
self: *const IPMTaskInfo,
pBackgroundExecutionAbilities: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsOptedForExtendedMem: fn(
self: *const IPMTaskInfo,
pIsOptedIn: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_ProductID(self: *const T, pProductID: ?*Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_ProductID(@ptrCast(*const IPMTaskInfo, self), pProductID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_TaskID(self: *const T, pTaskID: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_TaskID(@ptrCast(*const IPMTaskInfo, self), pTaskID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_NavigationPage(self: *const T, pNavigationPage: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_NavigationPage(@ptrCast(*const IPMTaskInfo, self), pNavigationPage);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_TaskTransition(self: *const T, pTaskTransition: ?*PM_TASK_TRANSITION) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_TaskTransition(@ptrCast(*const IPMTaskInfo, self), pTaskTransition);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_RuntimeType(self: *const T, pRuntimetype: ?*PACKMAN_RUNTIME) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_RuntimeType(@ptrCast(*const IPMTaskInfo, self), pRuntimetype);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_ActivationPolicy(self: *const T, pActivationPolicy: ?*PM_ACTIVATION_POLICY) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_ActivationPolicy(@ptrCast(*const IPMTaskInfo, self), pActivationPolicy);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_TaskType(self: *const T, pTaskType: ?*PM_TASK_TYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_TaskType(@ptrCast(*const IPMTaskInfo, self), pTaskType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_InvocationInfo(self: *const T, pImageUrn: ?*?BSTR, pParameters: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_InvocationInfo(@ptrCast(*const IPMTaskInfo, self), pImageUrn, pParameters);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_ImagePath(self: *const T, pImagePath: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_ImagePath(@ptrCast(*const IPMTaskInfo, self), pImagePath);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_ImageParams(self: *const T, pImageParams: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_ImageParams(@ptrCast(*const IPMTaskInfo, self), pImageParams);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_InstallRootFolder(self: *const T, pInstallRootFolder: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_InstallRootFolder(@ptrCast(*const IPMTaskInfo, self), pInstallRootFolder);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_DataRootFolder(self: *const T, pDataRootFolder: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_DataRootFolder(@ptrCast(*const IPMTaskInfo, self), pDataRootFolder);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_IsSingleInstanceHost(self: *const T, pIsSingleInstanceHost: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_IsSingleInstanceHost(@ptrCast(*const IPMTaskInfo, self), pIsSingleInstanceHost);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_IsInteropEnabled(self: *const T, pIsInteropEnabled: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_IsInteropEnabled(@ptrCast(*const IPMTaskInfo, self), pIsInteropEnabled);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_ApplicationState(self: *const T, pApplicationState: ?*PM_APPLICATION_STATE) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_ApplicationState(@ptrCast(*const IPMTaskInfo, self), pApplicationState);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_InstallType(self: *const T, pInstallType: ?*PM_APPLICATION_INSTALL_TYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_InstallType(@ptrCast(*const IPMTaskInfo, self), pInstallType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_Version(self: *const T, pTargetMajorVersion: ?*u8, pTargetMinorVersion: ?*u8) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_Version(@ptrCast(*const IPMTaskInfo, self), pTargetMajorVersion, pTargetMinorVersion);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_BitsPerPixel(self: *const T, pBitsPerPixel: ?*u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_BitsPerPixel(@ptrCast(*const IPMTaskInfo, self), pBitsPerPixel);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_SuppressesDehydration(self: *const T, pSuppressesDehydration: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_SuppressesDehydration(@ptrCast(*const IPMTaskInfo, self), pSuppressesDehydration);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_BackgroundExecutionAbilities(self: *const T, pBackgroundExecutionAbilities: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_BackgroundExecutionAbilities(@ptrCast(*const IPMTaskInfo, self), pBackgroundExecutionAbilities);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMTaskInfo_get_IsOptedForExtendedMem(self: *const T, pIsOptedIn: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfo.VTable, self.vtable).get_IsOptedForExtendedMem(@ptrCast(*const IPMTaskInfo, self), pIsOptedIn);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMTaskInfoEnumerator_Value = Guid.initString("0630b0f8-0bbc-4821-be74-c7995166ed2a");
pub const IID_IPMTaskInfoEnumerator = &IID_IPMTaskInfoEnumerator_Value;
pub const IPMTaskInfoEnumerator = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Next: fn(
self: *const IPMTaskInfoEnumerator,
ppTaskInfo: ?*?*IPMTaskInfo,
) 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 IPMTaskInfoEnumerator_get_Next(self: *const T, ppTaskInfo: ?*?*IPMTaskInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMTaskInfoEnumerator.VTable, self.vtable).get_Next(@ptrCast(*const IPMTaskInfoEnumerator, self), ppTaskInfo);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMExtensionInfo_Value = Guid.initString("49acde79-9788-4d0a-8aa0-1746afdb9e9d");
pub const IID_IPMExtensionInfo = &IID_IPMExtensionInfo_Value;
pub const IPMExtensionInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SupplierPID: fn(
self: *const IPMExtensionInfo,
pSupplierPID: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SupplierTaskID: fn(
self: *const IPMExtensionInfo,
pSupplierTID: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Title: fn(
self: *const IPMExtensionInfo,
pTitle: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IconPath: fn(
self: *const IPMExtensionInfo,
pIconPath: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ExtraFile: fn(
self: *const IPMExtensionInfo,
pFilePath: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_InvocationInfo: fn(
self: *const IPMExtensionInfo,
pImageUrn: ?*?BSTR,
pParameters: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionInfo_get_SupplierPID(self: *const T, pSupplierPID: ?*Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionInfo.VTable, self.vtable).get_SupplierPID(@ptrCast(*const IPMExtensionInfo, self), pSupplierPID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionInfo_get_SupplierTaskID(self: *const T, pSupplierTID: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionInfo.VTable, self.vtable).get_SupplierTaskID(@ptrCast(*const IPMExtensionInfo, self), pSupplierTID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionInfo_get_Title(self: *const T, pTitle: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionInfo.VTable, self.vtable).get_Title(@ptrCast(*const IPMExtensionInfo, self), pTitle);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionInfo_get_IconPath(self: *const T, pIconPath: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionInfo.VTable, self.vtable).get_IconPath(@ptrCast(*const IPMExtensionInfo, self), pIconPath);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionInfo_get_ExtraFile(self: *const T, pFilePath: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionInfo.VTable, self.vtable).get_ExtraFile(@ptrCast(*const IPMExtensionInfo, self), pFilePath);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionInfo_get_InvocationInfo(self: *const T, pImageUrn: ?*?BSTR, pParameters: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionInfo.VTable, self.vtable).get_InvocationInfo(@ptrCast(*const IPMExtensionInfo, self), pImageUrn, pParameters);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMExtensionFileExtensionInfo_Value = Guid.initString("6b87cb6c-0b88-4989-a4ec-033714f710d4");
pub const IID_IPMExtensionFileExtensionInfo = &IID_IPMExtensionFileExtensionInfo_Value;
pub const IPMExtensionFileExtensionInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Name: fn(
self: *const IPMExtensionFileExtensionInfo,
pName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DisplayName: fn(
self: *const IPMExtensionFileExtensionInfo,
pDisplayName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Logo: fn(
self: *const IPMExtensionFileExtensionInfo,
LogoSize: PM_LOGO_SIZE,
pLogo: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ContentType: fn(
self: *const IPMExtensionFileExtensionInfo,
FileType: ?BSTR,
pContentType: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_FileType: fn(
self: *const IPMExtensionFileExtensionInfo,
ContentType: ?BSTR,
pFileType: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_InvocationInfo: fn(
self: *const IPMExtensionFileExtensionInfo,
pImageUrn: ?*?BSTR,
pParameters: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AllFileTypes: fn(
self: *const IPMExtensionFileExtensionInfo,
pcbTypes: ?*u32,
ppTypes: ?[*]?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionFileExtensionInfo_get_Name(self: *const T, pName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionFileExtensionInfo.VTable, self.vtable).get_Name(@ptrCast(*const IPMExtensionFileExtensionInfo, self), pName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionFileExtensionInfo_get_DisplayName(self: *const T, pDisplayName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionFileExtensionInfo.VTable, self.vtable).get_DisplayName(@ptrCast(*const IPMExtensionFileExtensionInfo, self), pDisplayName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionFileExtensionInfo_get_Logo(self: *const T, LogoSize: PM_LOGO_SIZE, pLogo: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionFileExtensionInfo.VTable, self.vtable).get_Logo(@ptrCast(*const IPMExtensionFileExtensionInfo, self), LogoSize, pLogo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionFileExtensionInfo_get_ContentType(self: *const T, FileType: ?BSTR, pContentType: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionFileExtensionInfo.VTable, self.vtable).get_ContentType(@ptrCast(*const IPMExtensionFileExtensionInfo, self), FileType, pContentType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionFileExtensionInfo_get_FileType(self: *const T, ContentType: ?BSTR, pFileType: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionFileExtensionInfo.VTable, self.vtable).get_FileType(@ptrCast(*const IPMExtensionFileExtensionInfo, self), ContentType, pFileType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionFileExtensionInfo_get_InvocationInfo(self: *const T, pImageUrn: ?*?BSTR, pParameters: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionFileExtensionInfo.VTable, self.vtable).get_InvocationInfo(@ptrCast(*const IPMExtensionFileExtensionInfo, self), pImageUrn, pParameters);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionFileExtensionInfo_get_AllFileTypes(self: *const T, pcbTypes: ?*u32, ppTypes: ?[*]?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionFileExtensionInfo.VTable, self.vtable).get_AllFileTypes(@ptrCast(*const IPMExtensionFileExtensionInfo, self), pcbTypes, ppTypes);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMExtensionProtocolInfo_Value = Guid.initString("1e3fa036-51eb-4453-baff-b8d8e4b46c8e");
pub const IID_IPMExtensionProtocolInfo = &IID_IPMExtensionProtocolInfo_Value;
pub const IPMExtensionProtocolInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Protocol: fn(
self: *const IPMExtensionProtocolInfo,
pProtocol: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_InvocationInfo: fn(
self: *const IPMExtensionProtocolInfo,
pImageUrn: ?*?BSTR,
pParameters: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionProtocolInfo_get_Protocol(self: *const T, pProtocol: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionProtocolInfo.VTable, self.vtable).get_Protocol(@ptrCast(*const IPMExtensionProtocolInfo, self), pProtocol);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionProtocolInfo_get_InvocationInfo(self: *const T, pImageUrn: ?*?BSTR, pParameters: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionProtocolInfo.VTable, self.vtable).get_InvocationInfo(@ptrCast(*const IPMExtensionProtocolInfo, self), pImageUrn, pParameters);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMExtensionShareTargetInfo_Value = Guid.initString("5471f48b-c65c-4656-8c70-242e31195fea");
pub const IID_IPMExtensionShareTargetInfo = &IID_IPMExtensionShareTargetInfo_Value;
pub const IPMExtensionShareTargetInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AllFileTypes: fn(
self: *const IPMExtensionShareTargetInfo,
pcTypes: ?*u32,
ppTypes: ?[*]?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AllDataFormats: fn(
self: *const IPMExtensionShareTargetInfo,
pcDataFormats: ?*u32,
ppDataFormats: ?[*]?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SupportsAllFileTypes: fn(
self: *const IPMExtensionShareTargetInfo,
pSupportsAllTypes: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionShareTargetInfo_get_AllFileTypes(self: *const T, pcTypes: ?*u32, ppTypes: ?[*]?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionShareTargetInfo.VTable, self.vtable).get_AllFileTypes(@ptrCast(*const IPMExtensionShareTargetInfo, self), pcTypes, ppTypes);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionShareTargetInfo_get_AllDataFormats(self: *const T, pcDataFormats: ?*u32, ppDataFormats: ?[*]?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionShareTargetInfo.VTable, self.vtable).get_AllDataFormats(@ptrCast(*const IPMExtensionShareTargetInfo, self), pcDataFormats, ppDataFormats);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionShareTargetInfo_get_SupportsAllFileTypes(self: *const T, pSupportsAllTypes: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionShareTargetInfo.VTable, self.vtable).get_SupportsAllFileTypes(@ptrCast(*const IPMExtensionShareTargetInfo, self), pSupportsAllTypes);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMExtensionContractInfo_Value = Guid.initString("e5666373-7ba1-467c-b819-b175db1c295b");
pub const IID_IPMExtensionContractInfo = &IID_IPMExtensionContractInfo_Value;
pub const IPMExtensionContractInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_InvocationInfo: fn(
self: *const IPMExtensionContractInfo,
pAUMID: ?*?BSTR,
pArgs: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionContractInfo_get_InvocationInfo(self: *const T, pAUMID: ?*?BSTR, pArgs: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionContractInfo.VTable, self.vtable).get_InvocationInfo(@ptrCast(*const IPMExtensionContractInfo, self), pAUMID, pArgs);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMExtensionFileOpenPickerInfo_Value = Guid.initString("6dc91d25-9606-420c-9a78-e034a3418345");
pub const IID_IPMExtensionFileOpenPickerInfo = &IID_IPMExtensionFileOpenPickerInfo_Value;
pub const IPMExtensionFileOpenPickerInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AllFileTypes: fn(
self: *const IPMExtensionFileOpenPickerInfo,
pcTypes: ?*u32,
ppTypes: ?[*]?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SupportsAllFileTypes: fn(
self: *const IPMExtensionFileOpenPickerInfo,
pSupportsAllTypes: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionFileOpenPickerInfo_get_AllFileTypes(self: *const T, pcTypes: ?*u32, ppTypes: ?[*]?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionFileOpenPickerInfo.VTable, self.vtable).get_AllFileTypes(@ptrCast(*const IPMExtensionFileOpenPickerInfo, self), pcTypes, ppTypes);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionFileOpenPickerInfo_get_SupportsAllFileTypes(self: *const T, pSupportsAllTypes: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionFileOpenPickerInfo.VTable, self.vtable).get_SupportsAllFileTypes(@ptrCast(*const IPMExtensionFileOpenPickerInfo, self), pSupportsAllTypes);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMExtensionFileSavePickerInfo_Value = Guid.initString("38005cba-f81a-493e-a0f8-922c8680da43");
pub const IID_IPMExtensionFileSavePickerInfo = &IID_IPMExtensionFileSavePickerInfo_Value;
pub const IPMExtensionFileSavePickerInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AllFileTypes: fn(
self: *const IPMExtensionFileSavePickerInfo,
pcTypes: ?*u32,
ppTypes: ?[*]?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SupportsAllFileTypes: fn(
self: *const IPMExtensionFileSavePickerInfo,
pSupportsAllTypes: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionFileSavePickerInfo_get_AllFileTypes(self: *const T, pcTypes: ?*u32, ppTypes: ?[*]?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionFileSavePickerInfo.VTable, self.vtable).get_AllFileTypes(@ptrCast(*const IPMExtensionFileSavePickerInfo, self), pcTypes, ppTypes);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionFileSavePickerInfo_get_SupportsAllFileTypes(self: *const T, pSupportsAllTypes: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionFileSavePickerInfo.VTable, self.vtable).get_SupportsAllFileTypes(@ptrCast(*const IPMExtensionFileSavePickerInfo, self), pSupportsAllTypes);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMExtensionCachedFileUpdaterInfo_Value = Guid.initString("e2d77509-4e58-4ba9-af7e-b642e370e1b0");
pub const IID_IPMExtensionCachedFileUpdaterInfo = &IID_IPMExtensionCachedFileUpdaterInfo_Value;
pub const IPMExtensionCachedFileUpdaterInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SupportsUpdates: fn(
self: *const IPMExtensionCachedFileUpdaterInfo,
pSupportsUpdates: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMExtensionCachedFileUpdaterInfo_get_SupportsUpdates(self: *const T, pSupportsUpdates: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionCachedFileUpdaterInfo.VTable, self.vtable).get_SupportsUpdates(@ptrCast(*const IPMExtensionCachedFileUpdaterInfo, self), pSupportsUpdates);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMExtensionInfoEnumerator_Value = Guid.initString("403b9e82-1171-4573-8e6f-6f33f39b83dd");
pub const IID_IPMExtensionInfoEnumerator = &IID_IPMExtensionInfoEnumerator_Value;
pub const IPMExtensionInfoEnumerator = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Next: fn(
self: *const IPMExtensionInfoEnumerator,
ppExtensionInfo: ?*?*IPMExtensionInfo,
) 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 IPMExtensionInfoEnumerator_get_Next(self: *const T, ppExtensionInfo: ?*?*IPMExtensionInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMExtensionInfoEnumerator.VTable, self.vtable).get_Next(@ptrCast(*const IPMExtensionInfoEnumerator, self), ppExtensionInfo);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMBackgroundServiceAgentInfo_Value = Guid.initString("3a8b46da-928c-4879-998c-09dc96f3d490");
pub const IID_IPMBackgroundServiceAgentInfo = &IID_IPMBackgroundServiceAgentInfo_Value;
pub const IPMBackgroundServiceAgentInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProductID: fn(
self: *const IPMBackgroundServiceAgentInfo,
pProductID: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TaskID: fn(
self: *const IPMBackgroundServiceAgentInfo,
pTaskID: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BSAID: fn(
self: *const IPMBackgroundServiceAgentInfo,
pBSAID: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BGSpecifier: fn(
self: *const IPMBackgroundServiceAgentInfo,
pBGSpecifier: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BGName: fn(
self: *const IPMBackgroundServiceAgentInfo,
pBGName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BGSource: fn(
self: *const IPMBackgroundServiceAgentInfo,
pBGSource: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BGType: fn(
self: *const IPMBackgroundServiceAgentInfo,
pBGType: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsPeriodic: fn(
self: *const IPMBackgroundServiceAgentInfo,
pIsPeriodic: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsScheduled: fn(
self: *const IPMBackgroundServiceAgentInfo,
pIsScheduled: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsScheduleAllowed: fn(
self: *const IPMBackgroundServiceAgentInfo,
pIsScheduleAllowed: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Description: fn(
self: *const IPMBackgroundServiceAgentInfo,
pDescription: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsLaunchOnBoot: fn(
self: *const IPMBackgroundServiceAgentInfo,
pLaunchOnBoot: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_IsScheduled: fn(
self: *const IPMBackgroundServiceAgentInfo,
IsScheduled: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
set_IsScheduleAllowed: fn(
self: *const IPMBackgroundServiceAgentInfo,
IsScheduleAllowed: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundServiceAgentInfo_get_ProductID(self: *const T, pProductID: ?*Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundServiceAgentInfo.VTable, self.vtable).get_ProductID(@ptrCast(*const IPMBackgroundServiceAgentInfo, self), pProductID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundServiceAgentInfo_get_TaskID(self: *const T, pTaskID: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundServiceAgentInfo.VTable, self.vtable).get_TaskID(@ptrCast(*const IPMBackgroundServiceAgentInfo, self), pTaskID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundServiceAgentInfo_get_BSAID(self: *const T, pBSAID: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundServiceAgentInfo.VTable, self.vtable).get_BSAID(@ptrCast(*const IPMBackgroundServiceAgentInfo, self), pBSAID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundServiceAgentInfo_get_BGSpecifier(self: *const T, pBGSpecifier: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundServiceAgentInfo.VTable, self.vtable).get_BGSpecifier(@ptrCast(*const IPMBackgroundServiceAgentInfo, self), pBGSpecifier);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundServiceAgentInfo_get_BGName(self: *const T, pBGName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundServiceAgentInfo.VTable, self.vtable).get_BGName(@ptrCast(*const IPMBackgroundServiceAgentInfo, self), pBGName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundServiceAgentInfo_get_BGSource(self: *const T, pBGSource: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundServiceAgentInfo.VTable, self.vtable).get_BGSource(@ptrCast(*const IPMBackgroundServiceAgentInfo, self), pBGSource);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundServiceAgentInfo_get_BGType(self: *const T, pBGType: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundServiceAgentInfo.VTable, self.vtable).get_BGType(@ptrCast(*const IPMBackgroundServiceAgentInfo, self), pBGType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundServiceAgentInfo_get_IsPeriodic(self: *const T, pIsPeriodic: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundServiceAgentInfo.VTable, self.vtable).get_IsPeriodic(@ptrCast(*const IPMBackgroundServiceAgentInfo, self), pIsPeriodic);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundServiceAgentInfo_get_IsScheduled(self: *const T, pIsScheduled: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundServiceAgentInfo.VTable, self.vtable).get_IsScheduled(@ptrCast(*const IPMBackgroundServiceAgentInfo, self), pIsScheduled);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundServiceAgentInfo_get_IsScheduleAllowed(self: *const T, pIsScheduleAllowed: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundServiceAgentInfo.VTable, self.vtable).get_IsScheduleAllowed(@ptrCast(*const IPMBackgroundServiceAgentInfo, self), pIsScheduleAllowed);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundServiceAgentInfo_get_Description(self: *const T, pDescription: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundServiceAgentInfo.VTable, self.vtable).get_Description(@ptrCast(*const IPMBackgroundServiceAgentInfo, self), pDescription);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundServiceAgentInfo_get_IsLaunchOnBoot(self: *const T, pLaunchOnBoot: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundServiceAgentInfo.VTable, self.vtable).get_IsLaunchOnBoot(@ptrCast(*const IPMBackgroundServiceAgentInfo, self), pLaunchOnBoot);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundServiceAgentInfo_set_IsScheduled(self: *const T, IsScheduled: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundServiceAgentInfo.VTable, self.vtable).set_IsScheduled(@ptrCast(*const IPMBackgroundServiceAgentInfo, self), IsScheduled);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundServiceAgentInfo_set_IsScheduleAllowed(self: *const T, IsScheduleAllowed: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundServiceAgentInfo.VTable, self.vtable).set_IsScheduleAllowed(@ptrCast(*const IPMBackgroundServiceAgentInfo, self), IsScheduleAllowed);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMBackgroundWorkerInfo_Value = Guid.initString("7dd4531b-d3bf-4b6b-94f3-69c098b1497d");
pub const IID_IPMBackgroundWorkerInfo = &IID_IPMBackgroundWorkerInfo_Value;
pub const IPMBackgroundWorkerInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProductID: fn(
self: *const IPMBackgroundWorkerInfo,
pProductID: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TaskID: fn(
self: *const IPMBackgroundWorkerInfo,
pTaskID: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BGName: fn(
self: *const IPMBackgroundWorkerInfo,
pBGName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MaxStartupLatency: fn(
self: *const IPMBackgroundWorkerInfo,
pMaxStartupLatency: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ExpectedRuntime: fn(
self: *const IPMBackgroundWorkerInfo,
pExpectedRuntime: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsBootWorker: fn(
self: *const IPMBackgroundWorkerInfo,
pIsBootWorker: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundWorkerInfo_get_ProductID(self: *const T, pProductID: ?*Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundWorkerInfo.VTable, self.vtable).get_ProductID(@ptrCast(*const IPMBackgroundWorkerInfo, self), pProductID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundWorkerInfo_get_TaskID(self: *const T, pTaskID: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundWorkerInfo.VTable, self.vtable).get_TaskID(@ptrCast(*const IPMBackgroundWorkerInfo, self), pTaskID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundWorkerInfo_get_BGName(self: *const T, pBGName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundWorkerInfo.VTable, self.vtable).get_BGName(@ptrCast(*const IPMBackgroundWorkerInfo, self), pBGName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundWorkerInfo_get_MaxStartupLatency(self: *const T, pMaxStartupLatency: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundWorkerInfo.VTable, self.vtable).get_MaxStartupLatency(@ptrCast(*const IPMBackgroundWorkerInfo, self), pMaxStartupLatency);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundWorkerInfo_get_ExpectedRuntime(self: *const T, pExpectedRuntime: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundWorkerInfo.VTable, self.vtable).get_ExpectedRuntime(@ptrCast(*const IPMBackgroundWorkerInfo, self), pExpectedRuntime);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPMBackgroundWorkerInfo_get_IsBootWorker(self: *const T, pIsBootWorker: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundWorkerInfo.VTable, self.vtable).get_IsBootWorker(@ptrCast(*const IPMBackgroundWorkerInfo, self), pIsBootWorker);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMBackgroundServiceAgentInfoEnumerator_Value = Guid.initString("18eb2072-ab56-43b3-872c-beafb7a6b391");
pub const IID_IPMBackgroundServiceAgentInfoEnumerator = &IID_IPMBackgroundServiceAgentInfoEnumerator_Value;
pub const IPMBackgroundServiceAgentInfoEnumerator = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Next: fn(
self: *const IPMBackgroundServiceAgentInfoEnumerator,
ppBSAInfo: ?*?*IPMBackgroundServiceAgentInfo,
) 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 IPMBackgroundServiceAgentInfoEnumerator_get_Next(self: *const T, ppBSAInfo: ?*?*IPMBackgroundServiceAgentInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundServiceAgentInfoEnumerator.VTable, self.vtable).get_Next(@ptrCast(*const IPMBackgroundServiceAgentInfoEnumerator, self), ppBSAInfo);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPMBackgroundWorkerInfoEnumerator_Value = Guid.initString("87f479f8-90d8-4ec7-92b9-72787e2f636b");
pub const IID_IPMBackgroundWorkerInfoEnumerator = &IID_IPMBackgroundWorkerInfoEnumerator_Value;
pub const IPMBackgroundWorkerInfoEnumerator = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Next: fn(
self: *const IPMBackgroundWorkerInfoEnumerator,
ppBWInfo: ?*?*IPMBackgroundWorkerInfo,
) 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 IPMBackgroundWorkerInfoEnumerator_get_Next(self: *const T, ppBWInfo: ?*?*IPMBackgroundWorkerInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IPMBackgroundWorkerInfoEnumerator.VTable, self.vtable).get_Next(@ptrCast(*const IPMBackgroundWorkerInfoEnumerator, self), ppBWInfo);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const PPATCH_PROGRESS_CALLBACK = fn(
CallbackContext: ?*anyopaque,
CurrentPosition: u32,
MaximumPosition: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const PPATCH_SYMLOAD_CALLBACK = fn(
WhichFile: u32,
SymbolFileName: ?[*:0]const u8,
SymType: u32,
SymbolFileCheckSum: u32,
SymbolFileTimeDate: u32,
ImageFileCheckSum: u32,
ImageFileTimeDate: u32,
CallbackContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub const PATCH_IGNORE_RANGE = extern struct {
OffsetInOldFile: u32,
LengthInBytes: u32,
};
pub const PATCH_RETAIN_RANGE = extern struct {
OffsetInOldFile: u32,
LengthInBytes: u32,
OffsetInNewFile: u32,
};
pub const PATCH_OLD_FILE_INFO_A = extern struct {
SizeOfThisStruct: u32,
OldFileName: ?[*:0]const u8,
IgnoreRangeCount: u32,
IgnoreRangeArray: ?*PATCH_IGNORE_RANGE,
RetainRangeCount: u32,
RetainRangeArray: ?*PATCH_RETAIN_RANGE,
};
pub const PATCH_OLD_FILE_INFO_W = extern struct {
SizeOfThisStruct: u32,
OldFileName: ?[*:0]const u16,
IgnoreRangeCount: u32,
IgnoreRangeArray: ?*PATCH_IGNORE_RANGE,
RetainRangeCount: u32,
RetainRangeArray: ?*PATCH_RETAIN_RANGE,
};
pub const PATCH_OLD_FILE_INFO_H = extern struct {
SizeOfThisStruct: u32,
OldFileHandle: ?HANDLE,
IgnoreRangeCount: u32,
IgnoreRangeArray: ?*PATCH_IGNORE_RANGE,
RetainRangeCount: u32,
RetainRangeArray: ?*PATCH_RETAIN_RANGE,
};
pub const PATCH_OLD_FILE_INFO = extern struct {
SizeOfThisStruct: u32,
Anonymous: extern union {
OldFileNameA: ?[*:0]const u8,
OldFileNameW: ?[*:0]const u16,
OldFileHandle: ?HANDLE,
},
IgnoreRangeCount: u32,
IgnoreRangeArray: ?*PATCH_IGNORE_RANGE,
RetainRangeCount: u32,
RetainRangeArray: ?*PATCH_RETAIN_RANGE,
};
pub const PATCH_INTERLEAVE_MAP = extern struct {
CountRanges: u32,
Range: [1]extern struct {
OldOffset: u32,
OldLength: u32,
NewLength: u32,
},
};
pub const PATCH_OPTION_DATA = extern struct {
SizeOfThisStruct: u32,
SymbolOptionFlags: u32,
NewFileSymbolPath: ?[*:0]const u8,
OldFileSymbolPathArray: ?*?PSTR,
ExtendedOptionFlags: u32,
SymLoadCallback: ?PPATCH_SYMLOAD_CALLBACK,
SymLoadContext: ?*anyopaque,
InterleaveMapArray: ?*?*PATCH_INTERLEAVE_MAP,
MaxLzxWindowSize: u32,
};
pub const DELTA_INPUT = extern struct {
Anonymous: extern union {
lpcStart: ?*const anyopaque,
lpStart: ?*anyopaque,
},
uSize: usize,
Editable: BOOL,
};
pub const DELTA_OUTPUT = extern struct {
lpStart: ?*anyopaque,
uSize: usize,
};
pub const DELTA_HASH = extern struct {
HashSize: u32,
HashValue: [32]u8,
};
pub const DELTA_HEADER_INFO = extern struct {
FileTypeSet: i64,
FileType: i64,
Flags: i64,
TargetSize: usize,
TargetFileTime: FILETIME,
TargetHashAlgId: u32,
TargetHash: DELTA_HASH,
};
pub const ACTIVATION_CONTEXT_QUERY_INDEX = extern struct {
ulAssemblyIndex: u32,
ulFileIndexInAssembly: u32,
};
pub const ASSEMBLY_FILE_DETAILED_INFORMATION = extern struct {
ulFlags: u32,
ulFilenameLength: u32,
ulPathLength: u32,
lpFileName: ?[*:0]const u16,
lpFilePath: ?[*:0]const u16,
};
pub const ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION = extern struct {
ulFlags: u32,
ulEncodedAssemblyIdentityLength: u32,
ulManifestPathType: u32,
ulManifestPathLength: u32,
liManifestLastWriteTime: LARGE_INTEGER,
ulPolicyPathType: u32,
ulPolicyPathLength: u32,
liPolicyLastWriteTime: LARGE_INTEGER,
ulMetadataSatelliteRosterIndex: u32,
ulManifestVersionMajor: u32,
ulManifestVersionMinor: u32,
ulPolicyVersionMajor: u32,
ulPolicyVersionMinor: u32,
ulAssemblyDirectoryNameLength: u32,
lpAssemblyEncodedAssemblyIdentity: ?[*:0]const u16,
lpAssemblyManifestPath: ?[*:0]const u16,
lpAssemblyPolicyPath: ?[*:0]const u16,
lpAssemblyDirectoryName: ?[*:0]const u16,
ulFileCount: u32,
};
pub const ACTCTX_REQUESTED_RUN_LEVEL = enum(i32) {
UNSPECIFIED = 0,
AS_INVOKER = 1,
HIGHEST_AVAILABLE = 2,
REQUIRE_ADMIN = 3,
NUMBERS = 4,
};
pub const ACTCTX_RUN_LEVEL_UNSPECIFIED = ACTCTX_REQUESTED_RUN_LEVEL.UNSPECIFIED;
pub const ACTCTX_RUN_LEVEL_AS_INVOKER = ACTCTX_REQUESTED_RUN_LEVEL.AS_INVOKER;
pub const ACTCTX_RUN_LEVEL_HIGHEST_AVAILABLE = ACTCTX_REQUESTED_RUN_LEVEL.HIGHEST_AVAILABLE;
pub const ACTCTX_RUN_LEVEL_REQUIRE_ADMIN = ACTCTX_REQUESTED_RUN_LEVEL.REQUIRE_ADMIN;
pub const ACTCTX_RUN_LEVEL_NUMBERS = ACTCTX_REQUESTED_RUN_LEVEL.NUMBERS;
pub const ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION = extern struct {
ulFlags: u32,
RunLevel: ACTCTX_REQUESTED_RUN_LEVEL,
UiAccess: u32,
};
pub const ACTCTX_COMPATIBILITY_ELEMENT_TYPE = enum(i32) {
UNKNOWN = 0,
OS = 1,
MITIGATION = 2,
MAXVERSIONTESTED = 3,
};
pub const ACTCTX_COMPATIBILITY_ELEMENT_TYPE_UNKNOWN = ACTCTX_COMPATIBILITY_ELEMENT_TYPE.UNKNOWN;
pub const ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS = ACTCTX_COMPATIBILITY_ELEMENT_TYPE.OS;
pub const ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MITIGATION = ACTCTX_COMPATIBILITY_ELEMENT_TYPE.MITIGATION;
pub const ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MAXVERSIONTESTED = ACTCTX_COMPATIBILITY_ELEMENT_TYPE.MAXVERSIONTESTED;
pub const COMPATIBILITY_CONTEXT_ELEMENT = extern struct {
Id: Guid,
Type: ACTCTX_COMPATIBILITY_ELEMENT_TYPE,
MaxVersionTested: u64,
};
pub const ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION = extern struct {
ElementCount: u32,
Elements: [1]COMPATIBILITY_CONTEXT_ELEMENT,
};
pub const ACTIVATION_CONTEXT_DETAILED_INFORMATION = extern struct {
dwFlags: u32,
ulFormatVersion: u32,
ulAssemblyCount: u32,
ulRootManifestPathType: u32,
ulRootManifestPathChars: u32,
ulRootConfigurationPathType: u32,
ulRootConfigurationPathChars: u32,
ulAppDirPathType: u32,
ulAppDirPathChars: u32,
lpRootManifestPath: ?[*:0]const u16,
lpRootConfigurationPath: ?[*:0]const u16,
lpAppDirPath: ?[*:0]const u16,
};
pub const ACTCTXA = extern struct {
cbSize: u32,
dwFlags: u32,
lpSource: ?[*:0]const u8,
wProcessorArchitecture: u16,
wLangId: u16,
lpAssemblyDirectory: ?[*:0]const u8,
lpResourceName: ?[*:0]const u8,
lpApplicationName: ?[*:0]const u8,
hModule: ?HINSTANCE,
};
pub const ACTCTXW = extern struct {
cbSize: u32,
dwFlags: u32,
lpSource: ?[*:0]const u16,
wProcessorArchitecture: u16,
wLangId: u16,
lpAssemblyDirectory: ?[*:0]const u16,
lpResourceName: ?[*:0]const u16,
lpApplicationName: ?[*:0]const u16,
hModule: ?HINSTANCE,
};
pub const ACTCTX_SECTION_KEYED_DATA = extern struct {
cbSize: u32,
ulDataFormatVersion: u32,
lpData: ?*anyopaque,
ulLength: u32,
lpSectionGlobalData: ?*anyopaque,
ulSectionGlobalDataLength: u32,
lpSectionBase: ?*anyopaque,
ulSectionTotalLength: u32,
hActCtx: ?HANDLE,
ulAssemblyRosterIndex: u32,
ulFlags: u32,
AssemblyMetadata: ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA,
};
//--------------------------------------------------------------------------------
// Section: Functions (322)
//--------------------------------------------------------------------------------
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiCloseHandle(
hAny: MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiCloseAllHandles(
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSetInternalUI(
dwUILevel: INSTALLUILEVEL,
phWnd: ?*?HWND,
) callconv(@import("std").os.windows.WINAPI) INSTALLUILEVEL;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSetExternalUIA(
puiHandler: ?INSTALLUI_HANDLERA,
dwMessageFilter: u32,
pvContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) ?INSTALLUI_HANDLERA;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSetExternalUIW(
puiHandler: ?INSTALLUI_HANDLERW,
dwMessageFilter: u32,
pvContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) ?INSTALLUI_HANDLERW;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSetExternalUIRecord(
puiHandler: ?PINSTALLUI_HANDLER_RECORD,
dwMessageFilter: u32,
pvContext: ?*anyopaque,
ppuiPrevHandler: ?PINSTALLUI_HANDLER_RECORD,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnableLogA(
dwLogMode: INSTALLOGMODE,
szLogFile: ?[*:0]const u8,
dwLogAttributes: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnableLogW(
dwLogMode: INSTALLOGMODE,
szLogFile: ?[*:0]const u16,
dwLogAttributes: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiQueryProductStateA(
szProduct: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) INSTALLSTATE;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiQueryProductStateW(
szProduct: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) INSTALLSTATE;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetProductInfoA(
szProduct: ?[*:0]const u8,
szAttribute: ?[*:0]const u8,
lpValueBuf: ?[*:0]u8,
pcchValueBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetProductInfoW(
szProduct: ?[*:0]const u16,
szAttribute: ?[*:0]const u16,
lpValueBuf: ?[*:0]u16,
pcchValueBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetProductInfoExA(
szProductCode: ?[*:0]const u8,
szUserSid: ?[*:0]const u8,
dwContext: MSIINSTALLCONTEXT,
szProperty: ?[*:0]const u8,
szValue: ?[*:0]u8,
pcchValue: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetProductInfoExW(
szProductCode: ?[*:0]const u16,
szUserSid: ?[*:0]const u16,
dwContext: MSIINSTALLCONTEXT,
szProperty: ?[*:0]const u16,
szValue: ?[*:0]u16,
pcchValue: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiInstallProductA(
szPackagePath: ?[*:0]const u8,
szCommandLine: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiInstallProductW(
szPackagePath: ?[*:0]const u16,
szCommandLine: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiConfigureProductA(
szProduct: ?[*:0]const u8,
iInstallLevel: INSTALLLEVEL,
eInstallState: INSTALLSTATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiConfigureProductW(
szProduct: ?[*:0]const u16,
iInstallLevel: INSTALLLEVEL,
eInstallState: INSTALLSTATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiConfigureProductExA(
szProduct: ?[*:0]const u8,
iInstallLevel: INSTALLLEVEL,
eInstallState: INSTALLSTATE,
szCommandLine: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiConfigureProductExW(
szProduct: ?[*:0]const u16,
iInstallLevel: INSTALLLEVEL,
eInstallState: INSTALLSTATE,
szCommandLine: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiReinstallProductA(
szProduct: ?[*:0]const u8,
szReinstallMode: REINSTALLMODE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiReinstallProductW(
szProduct: ?[*:0]const u16,
szReinstallMode: REINSTALLMODE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiAdvertiseProductExA(
szPackagePath: ?[*:0]const u8,
szScriptfilePath: ?[*:0]const u8,
szTransforms: ?[*:0]const u8,
lgidLanguage: u16,
dwPlatform: u32,
dwOptions: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiAdvertiseProductExW(
szPackagePath: ?[*:0]const u16,
szScriptfilePath: ?[*:0]const u16,
szTransforms: ?[*:0]const u16,
lgidLanguage: u16,
dwPlatform: u32,
dwOptions: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiAdvertiseProductA(
szPackagePath: ?[*:0]const u8,
szScriptfilePath: ?[*:0]const u8,
szTransforms: ?[*:0]const u8,
lgidLanguage: u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiAdvertiseProductW(
szPackagePath: ?[*:0]const u16,
szScriptfilePath: ?[*:0]const u16,
szTransforms: ?[*:0]const u16,
lgidLanguage: u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiProcessAdvertiseScriptA(
szScriptFile: ?[*:0]const u8,
szIconFolder: ?[*:0]const u8,
hRegData: ?HKEY,
fShortcuts: BOOL,
fRemoveItems: BOOL,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiProcessAdvertiseScriptW(
szScriptFile: ?[*:0]const u16,
szIconFolder: ?[*:0]const u16,
hRegData: ?HKEY,
fShortcuts: BOOL,
fRemoveItems: BOOL,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiAdvertiseScriptA(
szScriptFile: ?[*:0]const u8,
dwFlags: u32,
phRegData: ?*?HKEY,
fRemoveItems: BOOL,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiAdvertiseScriptW(
szScriptFile: ?[*:0]const u16,
dwFlags: u32,
phRegData: ?*?HKEY,
fRemoveItems: BOOL,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetProductInfoFromScriptA(
szScriptFile: ?[*:0]const u8,
lpProductBuf39: ?PSTR,
plgidLanguage: ?*u16,
pdwVersion: ?*u32,
lpNameBuf: ?[*:0]u8,
pcchNameBuf: ?*u32,
lpPackageBuf: ?[*:0]u8,
pcchPackageBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetProductInfoFromScriptW(
szScriptFile: ?[*:0]const u16,
lpProductBuf39: ?PWSTR,
plgidLanguage: ?*u16,
pdwVersion: ?*u32,
lpNameBuf: ?[*:0]u16,
pcchNameBuf: ?*u32,
lpPackageBuf: ?[*:0]u16,
pcchPackageBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetProductCodeA(
szComponent: ?[*:0]const u8,
lpBuf39: ?PSTR,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetProductCodeW(
szComponent: ?[*:0]const u16,
lpBuf39: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetUserInfoA(
szProduct: ?[*:0]const u8,
lpUserNameBuf: ?[*:0]u8,
pcchUserNameBuf: ?*u32,
lpOrgNameBuf: ?[*:0]u8,
pcchOrgNameBuf: ?*u32,
lpSerialBuf: ?[*:0]u8,
pcchSerialBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) USERINFOSTATE;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetUserInfoW(
szProduct: ?[*:0]const u16,
lpUserNameBuf: ?[*:0]u16,
pcchUserNameBuf: ?*u32,
lpOrgNameBuf: ?[*:0]u16,
pcchOrgNameBuf: ?*u32,
lpSerialBuf: ?[*:0]u16,
pcchSerialBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) USERINFOSTATE;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiCollectUserInfoA(
szProduct: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiCollectUserInfoW(
szProduct: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiApplyPatchA(
szPatchPackage: ?[*:0]const u8,
szInstallPackage: ?[*:0]const u8,
eInstallType: INSTALLTYPE,
szCommandLine: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiApplyPatchW(
szPatchPackage: ?[*:0]const u16,
szInstallPackage: ?[*:0]const u16,
eInstallType: INSTALLTYPE,
szCommandLine: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetPatchInfoA(
szPatch: ?[*:0]const u8,
szAttribute: ?[*:0]const u8,
lpValueBuf: ?[*:0]u8,
pcchValueBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetPatchInfoW(
szPatch: ?[*:0]const u16,
szAttribute: ?[*:0]const u16,
lpValueBuf: ?[*:0]u16,
pcchValueBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumPatchesA(
szProduct: ?[*:0]const u8,
iPatchIndex: u32,
lpPatchBuf: ?PSTR,
lpTransformsBuf: [*:0]u8,
pcchTransformsBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumPatchesW(
szProduct: ?[*:0]const u16,
iPatchIndex: u32,
lpPatchBuf: ?PWSTR,
lpTransformsBuf: [*:0]u16,
pcchTransformsBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiRemovePatchesA(
szPatchList: ?[*:0]const u8,
szProductCode: ?[*:0]const u8,
eUninstallType: INSTALLTYPE,
szPropertyList: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiRemovePatchesW(
szPatchList: ?[*:0]const u16,
szProductCode: ?[*:0]const u16,
eUninstallType: INSTALLTYPE,
szPropertyList: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows Vista'
pub extern "msi" fn MsiExtractPatchXMLDataA(
szPatchPath: ?[*:0]const u8,
dwReserved: u32,
szXMLData: ?[*:0]u8,
pcchXMLData: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows Vista'
pub extern "msi" fn MsiExtractPatchXMLDataW(
szPatchPath: ?[*:0]const u16,
dwReserved: u32,
szXMLData: ?[*:0]u16,
pcchXMLData: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetPatchInfoExA(
szPatchCode: ?[*:0]const u8,
szProductCode: ?[*:0]const u8,
szUserSid: ?[*:0]const u8,
dwContext: MSIINSTALLCONTEXT,
szProperty: ?[*:0]const u8,
lpValue: ?[*:0]u8,
pcchValue: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetPatchInfoExW(
szPatchCode: ?[*:0]const u16,
szProductCode: ?[*:0]const u16,
szUserSid: ?[*:0]const u16,
dwContext: MSIINSTALLCONTEXT,
szProperty: ?[*:0]const u16,
lpValue: ?[*:0]u16,
pcchValue: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiApplyMultiplePatchesA(
szPatchPackages: ?[*:0]const u8,
szProductCode: ?[*:0]const u8,
szPropertiesList: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiApplyMultiplePatchesW(
szPatchPackages: ?[*:0]const u16,
szProductCode: ?[*:0]const u16,
szPropertiesList: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDeterminePatchSequenceA(
szProductCode: ?[*:0]const u8,
szUserSid: ?[*:0]const u8,
dwContext: MSIINSTALLCONTEXT,
cPatchInfo: u32,
pPatchInfo: [*]MSIPATCHSEQUENCEINFOA,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDeterminePatchSequenceW(
szProductCode: ?[*:0]const u16,
szUserSid: ?[*:0]const u16,
dwContext: MSIINSTALLCONTEXT,
cPatchInfo: u32,
pPatchInfo: [*]MSIPATCHSEQUENCEINFOW,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDetermineApplicablePatchesA(
szProductPackagePath: ?[*:0]const u8,
cPatchInfo: u32,
pPatchInfo: [*]MSIPATCHSEQUENCEINFOA,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDetermineApplicablePatchesW(
szProductPackagePath: ?[*:0]const u16,
cPatchInfo: u32,
pPatchInfo: [*]MSIPATCHSEQUENCEINFOW,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumPatchesExA(
szProductCode: ?[*:0]const u8,
szUserSid: ?[*:0]const u8,
dwContext: u32,
dwFilter: u32,
dwIndex: u32,
szPatchCode: ?PSTR,
szTargetProductCode: ?PSTR,
pdwTargetProductContext: ?*MSIINSTALLCONTEXT,
szTargetUserSid: ?[*:0]u8,
pcchTargetUserSid: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumPatchesExW(
szProductCode: ?[*:0]const u16,
szUserSid: ?[*:0]const u16,
dwContext: u32,
dwFilter: u32,
dwIndex: u32,
szPatchCode: ?PWSTR,
szTargetProductCode: ?PWSTR,
pdwTargetProductContext: ?*MSIINSTALLCONTEXT,
szTargetUserSid: ?[*:0]u16,
pcchTargetUserSid: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiQueryFeatureStateA(
szProduct: ?[*:0]const u8,
szFeature: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) INSTALLSTATE;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiQueryFeatureStateW(
szProduct: ?[*:0]const u16,
szFeature: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) INSTALLSTATE;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiQueryFeatureStateExA(
szProductCode: ?[*:0]const u8,
szUserSid: ?[*:0]const u8,
dwContext: MSIINSTALLCONTEXT,
szFeature: ?[*:0]const u8,
pdwState: ?*INSTALLSTATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiQueryFeatureStateExW(
szProductCode: ?[*:0]const u16,
szUserSid: ?[*:0]const u16,
dwContext: MSIINSTALLCONTEXT,
szFeature: ?[*:0]const u16,
pdwState: ?*INSTALLSTATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiUseFeatureA(
szProduct: ?[*:0]const u8,
szFeature: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) INSTALLSTATE;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiUseFeatureW(
szProduct: ?[*:0]const u16,
szFeature: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) INSTALLSTATE;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiUseFeatureExA(
szProduct: ?[*:0]const u8,
szFeature: ?[*:0]const u8,
dwInstallMode: u32,
dwReserved: u32,
) callconv(@import("std").os.windows.WINAPI) INSTALLSTATE;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiUseFeatureExW(
szProduct: ?[*:0]const u16,
szFeature: ?[*:0]const u16,
dwInstallMode: u32,
dwReserved: u32,
) callconv(@import("std").os.windows.WINAPI) INSTALLSTATE;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetFeatureUsageA(
szProduct: ?[*:0]const u8,
szFeature: ?[*:0]const u8,
pdwUseCount: ?*u32,
pwDateUsed: ?*u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetFeatureUsageW(
szProduct: ?[*:0]const u16,
szFeature: ?[*:0]const u16,
pdwUseCount: ?*u32,
pwDateUsed: ?*u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiConfigureFeatureA(
szProduct: ?[*:0]const u8,
szFeature: ?[*:0]const u8,
eInstallState: INSTALLSTATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiConfigureFeatureW(
szProduct: ?[*:0]const u16,
szFeature: ?[*:0]const u16,
eInstallState: INSTALLSTATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiReinstallFeatureA(
szProduct: ?[*:0]const u8,
szFeature: ?[*:0]const u8,
dwReinstallMode: REINSTALLMODE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiReinstallFeatureW(
szProduct: ?[*:0]const u16,
szFeature: ?[*:0]const u16,
dwReinstallMode: REINSTALLMODE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiProvideComponentA(
szProduct: ?[*:0]const u8,
szFeature: ?[*:0]const u8,
szComponent: ?[*:0]const u8,
dwInstallMode: INSTALLMODE,
lpPathBuf: ?[*:0]u8,
pcchPathBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiProvideComponentW(
szProduct: ?[*:0]const u16,
szFeature: ?[*:0]const u16,
szComponent: ?[*:0]const u16,
dwInstallMode: INSTALLMODE,
lpPathBuf: ?[*:0]u16,
pcchPathBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiProvideQualifiedComponentA(
szCategory: ?[*:0]const u8,
szQualifier: ?[*:0]const u8,
dwInstallMode: INSTALLMODE,
lpPathBuf: ?[*:0]u8,
pcchPathBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiProvideQualifiedComponentW(
szCategory: ?[*:0]const u16,
szQualifier: ?[*:0]const u16,
dwInstallMode: INSTALLMODE,
lpPathBuf: ?[*:0]u16,
pcchPathBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiProvideQualifiedComponentExA(
szCategory: ?[*:0]const u8,
szQualifier: ?[*:0]const u8,
dwInstallMode: INSTALLMODE,
szProduct: ?[*:0]const u8,
dwUnused1: u32,
dwUnused2: u32,
lpPathBuf: ?[*:0]u8,
pcchPathBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiProvideQualifiedComponentExW(
szCategory: ?[*:0]const u16,
szQualifier: ?[*:0]const u16,
dwInstallMode: INSTALLMODE,
szProduct: ?[*:0]const u16,
dwUnused1: u32,
dwUnused2: u32,
lpPathBuf: ?[*:0]u16,
pcchPathBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetComponentPathA(
szProduct: ?[*:0]const u8,
szComponent: ?[*:0]const u8,
lpPathBuf: ?[*:0]u8,
pcchBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) INSTALLSTATE;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetComponentPathW(
szProduct: ?[*:0]const u16,
szComponent: ?[*:0]const u16,
lpPathBuf: ?[*:0]u16,
pcchBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) INSTALLSTATE;
// TODO: this type is limited to platform 'Windows 8'
// This function from dll 'msi' is being skipped because it has some sort of issue
pub fn MsiGetComponentPathExA() void { @panic("this function is not working"); }
// TODO: this type is limited to platform 'Windows 8'
// This function from dll 'msi' is being skipped because it has some sort of issue
pub fn MsiGetComponentPathExW() void { @panic("this function is not working"); }
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiProvideAssemblyA(
szAssemblyName: ?[*:0]const u8,
szAppContext: ?[*:0]const u8,
dwInstallMode: INSTALLMODE,
dwAssemblyInfo: MSIASSEMBLYINFO,
lpPathBuf: ?[*:0]u8,
pcchPathBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiProvideAssemblyW(
szAssemblyName: ?[*:0]const u16,
szAppContext: ?[*:0]const u16,
dwInstallMode: INSTALLMODE,
dwAssemblyInfo: MSIASSEMBLYINFO,
lpPathBuf: ?[*:0]u16,
pcchPathBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiQueryComponentStateA(
szProductCode: ?[*:0]const u8,
szUserSid: ?[*:0]const u8,
dwContext: MSIINSTALLCONTEXT,
szComponentCode: ?[*:0]const u8,
pdwState: ?*INSTALLSTATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiQueryComponentStateW(
szProductCode: ?[*:0]const u16,
szUserSid: ?[*:0]const u16,
dwContext: MSIINSTALLCONTEXT,
szComponentCode: ?[*:0]const u16,
pdwState: ?*INSTALLSTATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumProductsA(
iProductIndex: u32,
lpProductBuf: ?PSTR,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumProductsW(
iProductIndex: u32,
lpProductBuf: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumProductsExA(
szProductCode: ?[*:0]const u8,
szUserSid: ?[*:0]const u8,
dwContext: u32,
dwIndex: u32,
szInstalledProductCode: ?PSTR,
pdwInstalledContext: ?*MSIINSTALLCONTEXT,
szSid: ?[*:0]u8,
pcchSid: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumProductsExW(
szProductCode: ?[*:0]const u16,
szUserSid: ?[*:0]const u16,
dwContext: u32,
dwIndex: u32,
szInstalledProductCode: ?PWSTR,
pdwInstalledContext: ?*MSIINSTALLCONTEXT,
szSid: ?[*:0]u16,
pcchSid: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumRelatedProductsA(
lpUpgradeCode: ?[*:0]const u8,
dwReserved: u32,
iProductIndex: u32,
lpProductBuf: ?PSTR,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumRelatedProductsW(
lpUpgradeCode: ?[*:0]const u16,
dwReserved: u32,
iProductIndex: u32,
lpProductBuf: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumFeaturesA(
szProduct: ?[*:0]const u8,
iFeatureIndex: u32,
lpFeatureBuf: ?PSTR,
lpParentBuf: ?PSTR,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumFeaturesW(
szProduct: ?[*:0]const u16,
iFeatureIndex: u32,
lpFeatureBuf: ?PWSTR,
lpParentBuf: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumComponentsA(
iComponentIndex: u32,
lpComponentBuf: ?PSTR,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumComponentsW(
iComponentIndex: u32,
lpComponentBuf: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumComponentsExA(
szUserSid: ?[*:0]const u8,
dwContext: u32,
dwIndex: u32,
szInstalledComponentCode: ?PSTR,
pdwInstalledContext: ?*MSIINSTALLCONTEXT,
szSid: ?[*:0]u8,
pcchSid: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumComponentsExW(
szUserSid: ?[*:0]const u16,
dwContext: u32,
dwIndex: u32,
szInstalledComponentCode: ?PWSTR,
pdwInstalledContext: ?*MSIINSTALLCONTEXT,
szSid: ?[*:0]u16,
pcchSid: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumClientsA(
szComponent: ?[*:0]const u8,
iProductIndex: u32,
lpProductBuf: ?PSTR,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumClientsW(
szComponent: ?[*:0]const u16,
iProductIndex: u32,
lpProductBuf: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumClientsExA(
szComponent: ?[*:0]const u8,
szUserSid: ?[*:0]const u8,
dwContext: MSIINSTALLCONTEXT,
dwProductIndex: u32,
szProductBuf: ?PSTR,
pdwInstalledContext: ?*MSIINSTALLCONTEXT,
szSid: ?[*:0]u8,
pcchSid: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumClientsExW(
szComponent: ?[*:0]const u16,
szUserSid: ?[*:0]const u16,
dwContext: MSIINSTALLCONTEXT,
dwProductIndex: u32,
szProductBuf: ?PWSTR,
pdwInstalledContext: ?*MSIINSTALLCONTEXT,
szSid: ?[*:0]u16,
pcchSid: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumComponentQualifiersA(
szComponent: ?[*:0]const u8,
iIndex: u32,
lpQualifierBuf: [*:0]u8,
pcchQualifierBuf: ?*u32,
lpApplicationDataBuf: ?[*:0]u8,
pcchApplicationDataBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumComponentQualifiersW(
szComponent: ?[*:0]const u16,
iIndex: u32,
lpQualifierBuf: [*:0]u16,
pcchQualifierBuf: ?*u32,
lpApplicationDataBuf: ?[*:0]u16,
pcchApplicationDataBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiOpenProductA(
szProduct: ?[*:0]const u8,
hProduct: ?*MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiOpenProductW(
szProduct: ?[*:0]const u16,
hProduct: ?*MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiOpenPackageA(
szPackagePath: ?[*:0]const u8,
hProduct: ?*MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiOpenPackageW(
szPackagePath: ?[*:0]const u16,
hProduct: ?*MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiOpenPackageExA(
szPackagePath: ?[*:0]const u8,
dwOptions: u32,
hProduct: ?*MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiOpenPackageExW(
szPackagePath: ?[*:0]const u16,
dwOptions: u32,
hProduct: ?*MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetPatchFileListA(
szProductCode: ?[*:0]const u8,
szPatchPackages: ?[*:0]const u8,
pcFiles: ?*u32,
pphFileRecords: ?*?*MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetPatchFileListW(
szProductCode: ?[*:0]const u16,
szPatchPackages: ?[*:0]const u16,
pcFiles: ?*u32,
pphFileRecords: ?*?*MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetProductPropertyA(
hProduct: MSIHANDLE,
szProperty: ?[*:0]const u8,
lpValueBuf: ?[*:0]u8,
pcchValueBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetProductPropertyW(
hProduct: MSIHANDLE,
szProperty: ?[*:0]const u16,
lpValueBuf: ?[*:0]u16,
pcchValueBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiVerifyPackageA(
szPackagePath: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiVerifyPackageW(
szPackagePath: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetFeatureInfoA(
hProduct: MSIHANDLE,
szFeature: ?[*:0]const u8,
lpAttributes: ?*u32,
lpTitleBuf: ?[*:0]u8,
pcchTitleBuf: ?*u32,
lpHelpBuf: ?[*:0]u8,
pcchHelpBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetFeatureInfoW(
hProduct: MSIHANDLE,
szFeature: ?[*:0]const u16,
lpAttributes: ?*u32,
lpTitleBuf: ?[*:0]u16,
pcchTitleBuf: ?*u32,
lpHelpBuf: ?[*:0]u16,
pcchHelpBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiInstallMissingComponentA(
szProduct: ?[*:0]const u8,
szComponent: ?[*:0]const u8,
eInstallState: INSTALLSTATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiInstallMissingComponentW(
szProduct: ?[*:0]const u16,
szComponent: ?[*:0]const u16,
eInstallState: INSTALLSTATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiInstallMissingFileA(
szProduct: ?[*:0]const u8,
szFile: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiInstallMissingFileW(
szProduct: ?[*:0]const u16,
szFile: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiLocateComponentA(
szComponent: ?[*:0]const u8,
lpPathBuf: ?[*:0]u8,
pcchBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) INSTALLSTATE;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiLocateComponentW(
szComponent: ?[*:0]const u16,
lpPathBuf: ?[*:0]u16,
pcchBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) INSTALLSTATE;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListClearAllA(
szProduct: ?[*:0]const u8,
szUserName: ?[*:0]const u8,
dwReserved: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListClearAllW(
szProduct: ?[*:0]const u16,
szUserName: ?[*:0]const u16,
dwReserved: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListAddSourceA(
szProduct: ?[*:0]const u8,
szUserName: ?[*:0]const u8,
dwReserved: u32,
szSource: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListAddSourceW(
szProduct: ?[*:0]const u16,
szUserName: ?[*:0]const u16,
dwReserved: u32,
szSource: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListForceResolutionA(
szProduct: ?[*:0]const u8,
szUserName: ?[*:0]const u8,
dwReserved: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListForceResolutionW(
szProduct: ?[*:0]const u16,
szUserName: ?[*:0]const u16,
dwReserved: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListAddSourceExA(
szProductCodeOrPatchCode: ?[*:0]const u8,
szUserSid: ?[*:0]const u8,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
szSource: ?[*:0]const u8,
dwIndex: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListAddSourceExW(
szProductCodeOrPatchCode: ?[*:0]const u16,
szUserSid: ?[*:0]const u16,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
szSource: ?[*:0]const u16,
dwIndex: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListAddMediaDiskA(
szProductCodeOrPatchCode: ?[*:0]const u8,
szUserSid: ?[*:0]const u8,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
dwDiskId: u32,
szVolumeLabel: ?[*:0]const u8,
szDiskPrompt: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListAddMediaDiskW(
szProductCodeOrPatchCode: ?[*:0]const u16,
szUserSid: ?[*:0]const u16,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
dwDiskId: u32,
szVolumeLabel: ?[*:0]const u16,
szDiskPrompt: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListClearSourceA(
szProductCodeOrPatchCode: ?[*:0]const u8,
szUserSid: ?[*:0]const u8,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
szSource: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListClearSourceW(
szProductCodeOrPatchCode: ?[*:0]const u16,
szUserSid: ?[*:0]const u16,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
szSource: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListClearMediaDiskA(
szProductCodeOrPatchCode: ?[*:0]const u8,
szUserSid: ?[*:0]const u8,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
dwDiskId: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListClearMediaDiskW(
szProductCodeOrPatchCode: ?[*:0]const u16,
szUserSid: ?[*:0]const u16,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
dwDiskId: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListClearAllExA(
szProductCodeOrPatchCode: ?[*:0]const u8,
szUserSid: ?[*:0]const u8,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListClearAllExW(
szProductCodeOrPatchCode: ?[*:0]const u16,
szUserSid: ?[*:0]const u16,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListForceResolutionExA(
szProductCodeOrPatchCode: ?[*:0]const u8,
szUserSid: ?[*:0]const u8,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListForceResolutionExW(
szProductCodeOrPatchCode: ?[*:0]const u16,
szUserSid: ?[*:0]const u16,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListSetInfoA(
szProductCodeOrPatchCode: ?[*:0]const u8,
szUserSid: ?[*:0]const u8,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
szProperty: ?[*:0]const u8,
szValue: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListSetInfoW(
szProductCodeOrPatchCode: ?[*:0]const u16,
szUserSid: ?[*:0]const u16,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
szProperty: ?[*:0]const u16,
szValue: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListGetInfoA(
szProductCodeOrPatchCode: ?[*:0]const u8,
szUserSid: ?[*:0]const u8,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
szProperty: ?[*:0]const u8,
szValue: ?[*:0]u8,
pcchValue: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListGetInfoW(
szProductCodeOrPatchCode: ?[*:0]const u16,
szUserSid: ?[*:0]const u16,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
szProperty: ?[*:0]const u16,
szValue: ?[*:0]u16,
pcchValue: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListEnumSourcesA(
szProductCodeOrPatchCode: ?[*:0]const u8,
szUserSid: ?[*:0]const u8,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
dwIndex: u32,
szSource: ?[*:0]u8,
pcchSource: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListEnumSourcesW(
szProductCodeOrPatchCode: ?[*:0]const u16,
szUserSid: ?[*:0]const u16,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
dwIndex: u32,
szSource: ?[*:0]u16,
pcchSource: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListEnumMediaDisksA(
szProductCodeOrPatchCode: ?[*:0]const u8,
szUserSid: ?[*:0]const u8,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
dwIndex: u32,
pdwDiskId: ?*u32,
szVolumeLabel: ?[*:0]u8,
pcchVolumeLabel: ?*u32,
szDiskPrompt: ?[*:0]u8,
pcchDiskPrompt: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSourceListEnumMediaDisksW(
szProductCodeOrPatchCode: ?[*:0]const u16,
szUserSid: ?[*:0]const u16,
dwContext: MSIINSTALLCONTEXT,
dwOptions: u32,
dwIndex: u32,
pdwDiskId: ?*u32,
szVolumeLabel: ?[*:0]u16,
pcchVolumeLabel: ?*u32,
szDiskPrompt: ?[*:0]u16,
pcchDiskPrompt: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetFileVersionA(
szFilePath: ?[*:0]const u8,
lpVersionBuf: ?[*:0]u8,
pcchVersionBuf: ?*u32,
lpLangBuf: ?[*:0]u8,
pcchLangBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetFileVersionW(
szFilePath: ?[*:0]const u16,
lpVersionBuf: ?[*:0]u16,
pcchVersionBuf: ?*u32,
lpLangBuf: ?[*:0]u16,
pcchLangBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetFileHashA(
szFilePath: ?[*:0]const u8,
dwOptions: u32,
pHash: ?*MSIFILEHASHINFO,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetFileHashW(
szFilePath: ?[*:0]const u16,
dwOptions: u32,
pHash: ?*MSIFILEHASHINFO,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetFileSignatureInformationA(
szSignedObjectPath: ?[*:0]const u8,
dwFlags: u32,
ppcCertContext: ?*?*CERT_CONTEXT,
// TODO: what to do with BytesParamIndex 4?
pbHashData: ?*u8,
pcbHashData: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetFileSignatureInformationW(
szSignedObjectPath: ?[*:0]const u16,
dwFlags: u32,
ppcCertContext: ?*?*CERT_CONTEXT,
// TODO: what to do with BytesParamIndex 4?
pbHashData: ?*u8,
pcbHashData: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetShortcutTargetA(
szShortcutPath: ?[*:0]const u8,
szProductCode: ?PSTR,
szFeatureId: ?PSTR,
szComponentCode: ?PSTR,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetShortcutTargetW(
szShortcutPath: ?[*:0]const u16,
szProductCode: ?PWSTR,
szFeatureId: ?PWSTR,
szComponentCode: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiIsProductElevatedA(
szProduct: ?[*:0]const u8,
pfElevated: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiIsProductElevatedW(
szProduct: ?[*:0]const u16,
pfElevated: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiNotifySidChangeA(
pOldSid: ?[*:0]const u8,
pNewSid: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiNotifySidChangeW(
pOldSid: ?[*:0]const u16,
pNewSid: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiBeginTransactionA(
szName: ?[*:0]const u8,
dwTransactionAttributes: u32,
phTransactionHandle: ?*MSIHANDLE,
phChangeOfOwnerEvent: ?*?HANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiBeginTransactionW(
szName: ?[*:0]const u16,
dwTransactionAttributes: u32,
phTransactionHandle: ?*MSIHANDLE,
phChangeOfOwnerEvent: ?*?HANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEndTransaction(
dwTransactionState: MSITRANSACTIONSTATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiJoinTransaction(
hTransactionHandle: MSIHANDLE,
dwTransactionAttributes: u32,
phChangeOfOwnerEvent: ?*?HANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDatabaseOpenViewA(
hDatabase: MSIHANDLE,
szQuery: ?[*:0]const u8,
phView: ?*MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDatabaseOpenViewW(
hDatabase: MSIHANDLE,
szQuery: ?[*:0]const u16,
phView: ?*MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiViewGetErrorA(
hView: MSIHANDLE,
szColumnNameBuffer: ?[*:0]u8,
pcchBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) MSIDBERROR;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiViewGetErrorW(
hView: MSIHANDLE,
szColumnNameBuffer: ?[*:0]u16,
pcchBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) MSIDBERROR;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiViewExecute(
hView: MSIHANDLE,
hRecord: MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiViewFetch(
hView: MSIHANDLE,
phRecord: ?*MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiViewModify(
hView: MSIHANDLE,
eModifyMode: MSIMODIFY,
hRecord: MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiViewGetColumnInfo(
hView: MSIHANDLE,
eColumnInfo: MSICOLINFO,
phRecord: ?*MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiViewClose(
hView: MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDatabaseGetPrimaryKeysA(
hDatabase: MSIHANDLE,
szTableName: ?[*:0]const u8,
phRecord: ?*MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDatabaseGetPrimaryKeysW(
hDatabase: MSIHANDLE,
szTableName: ?[*:0]const u16,
phRecord: ?*MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDatabaseIsTablePersistentA(
hDatabase: MSIHANDLE,
szTableName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) MSICONDITION;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDatabaseIsTablePersistentW(
hDatabase: MSIHANDLE,
szTableName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) MSICONDITION;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetSummaryInformationA(
hDatabase: MSIHANDLE,
szDatabasePath: ?[*:0]const u8,
uiUpdateCount: u32,
phSummaryInfo: ?*MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetSummaryInformationW(
hDatabase: MSIHANDLE,
szDatabasePath: ?[*:0]const u16,
uiUpdateCount: u32,
phSummaryInfo: ?*MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSummaryInfoGetPropertyCount(
hSummaryInfo: MSIHANDLE,
puiPropertyCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSummaryInfoSetPropertyA(
hSummaryInfo: MSIHANDLE,
uiProperty: u32,
uiDataType: u32,
iValue: i32,
pftValue: ?*FILETIME,
szValue: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSummaryInfoSetPropertyW(
hSummaryInfo: MSIHANDLE,
uiProperty: u32,
uiDataType: u32,
iValue: i32,
pftValue: ?*FILETIME,
szValue: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSummaryInfoGetPropertyA(
hSummaryInfo: MSIHANDLE,
uiProperty: u32,
puiDataType: ?*u32,
piValue: ?*i32,
pftValue: ?*FILETIME,
szValueBuf: ?[*:0]u8,
pcchValueBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSummaryInfoGetPropertyW(
hSummaryInfo: MSIHANDLE,
uiProperty: u32,
puiDataType: ?*u32,
piValue: ?*i32,
pftValue: ?*FILETIME,
szValueBuf: ?[*:0]u16,
pcchValueBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSummaryInfoPersist(
hSummaryInfo: MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiOpenDatabaseA(
szDatabasePath: ?[*:0]const u8,
szPersist: ?[*:0]const u8,
phDatabase: ?*MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiOpenDatabaseW(
szDatabasePath: ?[*:0]const u16,
szPersist: ?[*:0]const u16,
phDatabase: ?*MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDatabaseImportA(
hDatabase: MSIHANDLE,
szFolderPath: ?[*:0]const u8,
szFileName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDatabaseImportW(
hDatabase: MSIHANDLE,
szFolderPath: ?[*:0]const u16,
szFileName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDatabaseExportA(
hDatabase: MSIHANDLE,
szTableName: ?[*:0]const u8,
szFolderPath: ?[*:0]const u8,
szFileName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDatabaseExportW(
hDatabase: MSIHANDLE,
szTableName: ?[*:0]const u16,
szFolderPath: ?[*:0]const u16,
szFileName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDatabaseMergeA(
hDatabase: MSIHANDLE,
hDatabaseMerge: MSIHANDLE,
szTableName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDatabaseMergeW(
hDatabase: MSIHANDLE,
hDatabaseMerge: MSIHANDLE,
szTableName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDatabaseGenerateTransformA(
hDatabase: MSIHANDLE,
hDatabaseReference: MSIHANDLE,
szTransformFile: ?[*:0]const u8,
iReserved1: i32,
iReserved2: i32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDatabaseGenerateTransformW(
hDatabase: MSIHANDLE,
hDatabaseReference: MSIHANDLE,
szTransformFile: ?[*:0]const u16,
iReserved1: i32,
iReserved2: i32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDatabaseApplyTransformA(
hDatabase: MSIHANDLE,
szTransformFile: ?[*:0]const u8,
iErrorConditions: MSITRANSFORM_ERROR,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDatabaseApplyTransformW(
hDatabase: MSIHANDLE,
szTransformFile: ?[*:0]const u16,
iErrorConditions: MSITRANSFORM_ERROR,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiCreateTransformSummaryInfoA(
hDatabase: MSIHANDLE,
hDatabaseReference: MSIHANDLE,
szTransformFile: ?[*:0]const u8,
iErrorConditions: MSITRANSFORM_ERROR,
iValidation: MSITRANSFORM_VALIDATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiCreateTransformSummaryInfoW(
hDatabase: MSIHANDLE,
hDatabaseReference: MSIHANDLE,
szTransformFile: ?[*:0]const u16,
iErrorConditions: MSITRANSFORM_ERROR,
iValidation: MSITRANSFORM_VALIDATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDatabaseCommit(
hDatabase: MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetDatabaseState(
hDatabase: MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) MSIDBSTATE;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiCreateRecord(
cParams: u32,
) callconv(@import("std").os.windows.WINAPI) MSIHANDLE;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiRecordIsNull(
hRecord: MSIHANDLE,
iField: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiRecordDataSize(
hRecord: MSIHANDLE,
iField: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiRecordSetInteger(
hRecord: MSIHANDLE,
iField: u32,
iValue: i32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiRecordSetStringA(
hRecord: MSIHANDLE,
iField: u32,
szValue: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiRecordSetStringW(
hRecord: MSIHANDLE,
iField: u32,
szValue: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiRecordGetInteger(
hRecord: MSIHANDLE,
iField: u32,
) callconv(@import("std").os.windows.WINAPI) i32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiRecordGetStringA(
hRecord: MSIHANDLE,
iField: u32,
szValueBuf: ?[*:0]u8,
pcchValueBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiRecordGetStringW(
hRecord: MSIHANDLE,
iField: u32,
szValueBuf: ?[*:0]u16,
pcchValueBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiRecordGetFieldCount(
hRecord: MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiRecordSetStreamA(
hRecord: MSIHANDLE,
iField: u32,
szFilePath: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiRecordSetStreamW(
hRecord: MSIHANDLE,
iField: u32,
szFilePath: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiRecordReadStream(
hRecord: MSIHANDLE,
iField: u32,
// TODO: what to do with BytesParamIndex 3?
szDataBuf: ?PSTR,
pcbDataBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiRecordClearData(
hRecord: MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetActiveDatabase(
hInstall: MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) MSIHANDLE;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSetPropertyA(
hInstall: MSIHANDLE,
szName: ?[*:0]const u8,
szValue: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSetPropertyW(
hInstall: MSIHANDLE,
szName: ?[*:0]const u16,
szValue: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetPropertyA(
hInstall: MSIHANDLE,
szName: ?[*:0]const u8,
szValueBuf: ?[*:0]u8,
pcchValueBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetPropertyW(
hInstall: MSIHANDLE,
szName: ?[*:0]const u16,
szValueBuf: ?[*:0]u16,
pcchValueBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetLanguage(
hInstall: MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u16;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetMode(
hInstall: MSIHANDLE,
eRunMode: MSIRUNMODE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSetMode(
hInstall: MSIHANDLE,
eRunMode: MSIRUNMODE,
fState: BOOL,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiFormatRecordA(
hInstall: MSIHANDLE,
hRecord: MSIHANDLE,
szResultBuf: ?[*:0]u8,
pcchResultBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiFormatRecordW(
hInstall: MSIHANDLE,
hRecord: MSIHANDLE,
szResultBuf: ?[*:0]u16,
pcchResultBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDoActionA(
hInstall: MSIHANDLE,
szAction: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiDoActionW(
hInstall: MSIHANDLE,
szAction: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSequenceA(
hInstall: MSIHANDLE,
szTable: ?[*:0]const u8,
iSequenceMode: i32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSequenceW(
hInstall: MSIHANDLE,
szTable: ?[*:0]const u16,
iSequenceMode: i32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiProcessMessage(
hInstall: MSIHANDLE,
eMessageType: INSTALLMESSAGE,
hRecord: MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) i32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEvaluateConditionA(
hInstall: MSIHANDLE,
szCondition: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) MSICONDITION;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEvaluateConditionW(
hInstall: MSIHANDLE,
szCondition: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) MSICONDITION;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetFeatureStateA(
hInstall: MSIHANDLE,
szFeature: ?[*:0]const u8,
piInstalled: ?*INSTALLSTATE,
piAction: ?*INSTALLSTATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetFeatureStateW(
hInstall: MSIHANDLE,
szFeature: ?[*:0]const u16,
piInstalled: ?*INSTALLSTATE,
piAction: ?*INSTALLSTATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSetFeatureStateA(
hInstall: MSIHANDLE,
szFeature: ?[*:0]const u8,
iState: INSTALLSTATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSetFeatureStateW(
hInstall: MSIHANDLE,
szFeature: ?[*:0]const u16,
iState: INSTALLSTATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSetFeatureAttributesA(
hInstall: MSIHANDLE,
szFeature: ?[*:0]const u8,
dwAttributes: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSetFeatureAttributesW(
hInstall: MSIHANDLE,
szFeature: ?[*:0]const u16,
dwAttributes: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetComponentStateA(
hInstall: MSIHANDLE,
szComponent: ?[*:0]const u8,
piInstalled: ?*INSTALLSTATE,
piAction: ?*INSTALLSTATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetComponentStateW(
hInstall: MSIHANDLE,
szComponent: ?[*:0]const u16,
piInstalled: ?*INSTALLSTATE,
piAction: ?*INSTALLSTATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSetComponentStateA(
hInstall: MSIHANDLE,
szComponent: ?[*:0]const u8,
iState: INSTALLSTATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSetComponentStateW(
hInstall: MSIHANDLE,
szComponent: ?[*:0]const u16,
iState: INSTALLSTATE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetFeatureCostA(
hInstall: MSIHANDLE,
szFeature: ?[*:0]const u8,
iCostTree: MSICOSTTREE,
iState: INSTALLSTATE,
piCost: ?*i32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetFeatureCostW(
hInstall: MSIHANDLE,
szFeature: ?[*:0]const u16,
iCostTree: MSICOSTTREE,
iState: INSTALLSTATE,
piCost: ?*i32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumComponentCostsA(
hInstall: MSIHANDLE,
szComponent: ?[*:0]const u8,
dwIndex: u32,
iState: INSTALLSTATE,
szDriveBuf: [*:0]u8,
pcchDriveBuf: ?*u32,
piCost: ?*i32,
piTempCost: ?*i32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnumComponentCostsW(
hInstall: MSIHANDLE,
szComponent: ?[*:0]const u16,
dwIndex: u32,
iState: INSTALLSTATE,
szDriveBuf: [*:0]u16,
pcchDriveBuf: ?*u32,
piCost: ?*i32,
piTempCost: ?*i32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSetInstallLevel(
hInstall: MSIHANDLE,
iInstallLevel: i32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetFeatureValidStatesA(
hInstall: MSIHANDLE,
szFeature: ?[*:0]const u8,
lpInstallStates: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetFeatureValidStatesW(
hInstall: MSIHANDLE,
szFeature: ?[*:0]const u16,
lpInstallStates: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetSourcePathA(
hInstall: MSIHANDLE,
szFolder: ?[*:0]const u8,
szPathBuf: ?[*:0]u8,
pcchPathBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetSourcePathW(
hInstall: MSIHANDLE,
szFolder: ?[*:0]const u16,
szPathBuf: ?[*:0]u16,
pcchPathBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetTargetPathA(
hInstall: MSIHANDLE,
szFolder: ?[*:0]const u8,
szPathBuf: ?[*:0]u8,
pcchPathBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetTargetPathW(
hInstall: MSIHANDLE,
szFolder: ?[*:0]const u16,
szPathBuf: ?[*:0]u16,
pcchPathBuf: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSetTargetPathA(
hInstall: MSIHANDLE,
szFolder: ?[*:0]const u8,
szFolderPath: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiSetTargetPathW(
hInstall: MSIHANDLE,
szFolder: ?[*:0]const u16,
szFolderPath: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiVerifyDiskSpace(
hInstall: MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiEnableUIPreview(
hDatabase: MSIHANDLE,
phPreview: ?*MSIHANDLE,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiPreviewDialogA(
hPreview: MSIHANDLE,
szDialogName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiPreviewDialogW(
hPreview: MSIHANDLE,
szDialogName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiPreviewBillboardA(
hPreview: MSIHANDLE,
szControlName: ?[*:0]const u8,
szBillboard: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiPreviewBillboardW(
hPreview: MSIHANDLE,
szControlName: ?[*:0]const u16,
szBillboard: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'Windows 8'
pub extern "msi" fn MsiGetLastErrorRecord(
) callconv(@import("std").os.windows.WINAPI) MSIHANDLE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "sfc" fn SfcGetNextProtectedFile(
RpcHandle: ?HANDLE,
ProtFileData: ?*PROTECTED_FILE_DATA,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "sfc" fn SfcIsFileProtected(
RpcHandle: ?HANDLE,
ProtFileName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "sfc" fn SfcIsKeyProtected(
KeyHandle: ?HKEY,
SubKeyName: ?[*:0]const u16,
KeySam: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "sfc" fn SfpVerifyFile(
pszFileName: ?[*:0]const u8,
pszError: [*:0]u8,
dwErrSize: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatchc" fn CreatePatchFileA(
OldFileName: ?[*:0]const u8,
NewFileName: ?[*:0]const u8,
PatchFileName: ?[*:0]const u8,
OptionFlags: u32,
OptionData: ?*PATCH_OPTION_DATA,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatchc" fn CreatePatchFileW(
OldFileName: ?[*:0]const u16,
NewFileName: ?[*:0]const u16,
PatchFileName: ?[*:0]const u16,
OptionFlags: u32,
OptionData: ?*PATCH_OPTION_DATA,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatchc" fn CreatePatchFileByHandles(
OldFileHandle: ?HANDLE,
NewFileHandle: ?HANDLE,
PatchFileHandle: ?HANDLE,
OptionFlags: u32,
OptionData: ?*PATCH_OPTION_DATA,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatchc" fn CreatePatchFileExA(
OldFileCount: u32,
OldFileInfoArray: [*]PATCH_OLD_FILE_INFO_A,
NewFileName: ?[*:0]const u8,
PatchFileName: ?[*:0]const u8,
OptionFlags: u32,
OptionData: ?*PATCH_OPTION_DATA,
ProgressCallback: ?PPATCH_PROGRESS_CALLBACK,
CallbackContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatchc" fn CreatePatchFileExW(
OldFileCount: u32,
OldFileInfoArray: [*]PATCH_OLD_FILE_INFO_W,
NewFileName: ?[*:0]const u16,
PatchFileName: ?[*:0]const u16,
OptionFlags: u32,
OptionData: ?*PATCH_OPTION_DATA,
ProgressCallback: ?PPATCH_PROGRESS_CALLBACK,
CallbackContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatchc" fn CreatePatchFileByHandlesEx(
OldFileCount: u32,
OldFileInfoArray: [*]PATCH_OLD_FILE_INFO_H,
NewFileHandle: ?HANDLE,
PatchFileHandle: ?HANDLE,
OptionFlags: u32,
OptionData: ?*PATCH_OPTION_DATA,
ProgressCallback: ?PPATCH_PROGRESS_CALLBACK,
CallbackContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatchc" fn ExtractPatchHeaderToFileA(
PatchFileName: ?[*:0]const u8,
PatchHeaderFileName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatchc" fn ExtractPatchHeaderToFileW(
PatchFileName: ?[*:0]const u16,
PatchHeaderFileName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatchc" fn ExtractPatchHeaderToFileByHandles(
PatchFileHandle: ?HANDLE,
PatchHeaderFileHandle: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatcha" fn TestApplyPatchToFileA(
PatchFileName: ?[*:0]const u8,
OldFileName: ?[*:0]const u8,
ApplyOptionFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatcha" fn TestApplyPatchToFileW(
PatchFileName: ?[*:0]const u16,
OldFileName: ?[*:0]const u16,
ApplyOptionFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatcha" fn TestApplyPatchToFileByHandles(
PatchFileHandle: ?HANDLE,
OldFileHandle: ?HANDLE,
ApplyOptionFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatcha" fn TestApplyPatchToFileByBuffers(
// TODO: what to do with BytesParamIndex 1?
PatchFileBuffer: ?*u8,
PatchFileSize: u32,
// TODO: what to do with BytesParamIndex 3?
OldFileBuffer: ?*u8,
OldFileSize: u32,
NewFileSize: ?*u32,
ApplyOptionFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatcha" fn ApplyPatchToFileA(
PatchFileName: ?[*:0]const u8,
OldFileName: ?[*:0]const u8,
NewFileName: ?[*:0]const u8,
ApplyOptionFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatcha" fn ApplyPatchToFileW(
PatchFileName: ?[*:0]const u16,
OldFileName: ?[*:0]const u16,
NewFileName: ?[*:0]const u16,
ApplyOptionFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatcha" fn ApplyPatchToFileByHandles(
PatchFileHandle: ?HANDLE,
OldFileHandle: ?HANDLE,
NewFileHandle: ?HANDLE,
ApplyOptionFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatcha" fn ApplyPatchToFileExA(
PatchFileName: ?[*:0]const u8,
OldFileName: ?[*:0]const u8,
NewFileName: ?[*:0]const u8,
ApplyOptionFlags: u32,
ProgressCallback: ?PPATCH_PROGRESS_CALLBACK,
CallbackContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatcha" fn ApplyPatchToFileExW(
PatchFileName: ?[*:0]const u16,
OldFileName: ?[*:0]const u16,
NewFileName: ?[*:0]const u16,
ApplyOptionFlags: u32,
ProgressCallback: ?PPATCH_PROGRESS_CALLBACK,
CallbackContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatcha" fn ApplyPatchToFileByHandlesEx(
PatchFileHandle: ?HANDLE,
OldFileHandle: ?HANDLE,
NewFileHandle: ?HANDLE,
ApplyOptionFlags: u32,
ProgressCallback: ?PPATCH_PROGRESS_CALLBACK,
CallbackContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatcha" fn ApplyPatchToFileByBuffers(
// TODO: what to do with BytesParamIndex 1?
PatchFileMapped: ?*u8,
PatchFileSize: u32,
// TODO: what to do with BytesParamIndex 3?
OldFileMapped: ?*u8,
OldFileSize: u32,
// TODO: what to do with BytesParamIndex 5?
NewFileBuffer: ?*?*u8,
NewFileBufferSize: u32,
NewFileActualSize: ?*u32,
NewFileTime: ?*FILETIME,
ApplyOptionFlags: u32,
ProgressCallback: ?PPATCH_PROGRESS_CALLBACK,
CallbackContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatcha" fn GetFilePatchSignatureA(
FileName: ?[*:0]const u8,
OptionFlags: u32,
OptionData: ?*anyopaque,
IgnoreRangeCount: u32,
IgnoreRangeArray: ?[*]PATCH_IGNORE_RANGE,
RetainRangeCount: u32,
RetainRangeArray: ?[*]PATCH_RETAIN_RANGE,
SignatureBufferSize: u32,
// TODO: what to do with BytesParamIndex 7?
SignatureBuffer: ?PSTR,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatcha" fn GetFilePatchSignatureW(
FileName: ?[*:0]const u16,
OptionFlags: u32,
OptionData: ?*anyopaque,
IgnoreRangeCount: u32,
IgnoreRangeArray: ?[*]PATCH_IGNORE_RANGE,
RetainRangeCount: u32,
RetainRangeArray: ?[*]PATCH_RETAIN_RANGE,
SignatureBufferSize: u32,
// TODO: what to do with BytesParamIndex 7?
SignatureBuffer: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatcha" fn GetFilePatchSignatureByHandle(
FileHandle: ?HANDLE,
OptionFlags: u32,
OptionData: ?*anyopaque,
IgnoreRangeCount: u32,
IgnoreRangeArray: ?[*]PATCH_IGNORE_RANGE,
RetainRangeCount: u32,
RetainRangeArray: ?[*]PATCH_RETAIN_RANGE,
SignatureBufferSize: u32,
// TODO: what to do with BytesParamIndex 7?
SignatureBuffer: ?PSTR,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatcha" fn GetFilePatchSignatureByBuffer(
// TODO: what to do with BytesParamIndex 1?
FileBufferWritable: ?*u8,
FileSize: u32,
OptionFlags: u32,
OptionData: ?*anyopaque,
IgnoreRangeCount: u32,
IgnoreRangeArray: ?[*]PATCH_IGNORE_RANGE,
RetainRangeCount: u32,
RetainRangeArray: ?[*]PATCH_RETAIN_RANGE,
SignatureBufferSize: u32,
// TODO: what to do with BytesParamIndex 8?
SignatureBuffer: ?PSTR,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "mspatcha" fn NormalizeFileForPatchSignature(
// TODO: what to do with BytesParamIndex 1?
FileBuffer: ?*anyopaque,
FileSize: u32,
OptionFlags: u32,
OptionData: ?*PATCH_OPTION_DATA,
NewFileCoffBase: u32,
NewFileCoffTime: u32,
IgnoreRangeCount: u32,
IgnoreRangeArray: ?[*]PATCH_IGNORE_RANGE,
RetainRangeCount: u32,
RetainRangeArray: ?[*]PATCH_RETAIN_RANGE,
) callconv(@import("std").os.windows.WINAPI) i32;
pub extern "msdelta" fn GetDeltaInfoB(
Delta: DELTA_INPUT,
lpHeaderInfo: ?*DELTA_HEADER_INFO,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "msdelta" fn GetDeltaInfoA(
lpDeltaName: ?[*:0]const u8,
lpHeaderInfo: ?*DELTA_HEADER_INFO,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "msdelta" fn GetDeltaInfoW(
lpDeltaName: ?[*:0]const u16,
lpHeaderInfo: ?*DELTA_HEADER_INFO,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "msdelta" fn ApplyDeltaGetReverseB(
ApplyFlags: i64,
Source: DELTA_INPUT,
Delta: DELTA_INPUT,
lpReverseFileTime: ?*const FILETIME,
lpTarget: ?*DELTA_OUTPUT,
lpTargetReverse: ?*DELTA_OUTPUT,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "msdelta" fn ApplyDeltaB(
ApplyFlags: i64,
Source: DELTA_INPUT,
Delta: DELTA_INPUT,
lpTarget: ?*DELTA_OUTPUT,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "msdelta" fn ApplyDeltaProvidedB(
ApplyFlags: i64,
Source: DELTA_INPUT,
Delta: DELTA_INPUT,
// TODO: what to do with BytesParamIndex 4?
lpTarget: ?*anyopaque,
uTargetSize: usize,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "msdelta" fn ApplyDeltaA(
ApplyFlags: i64,
lpSourceName: ?[*:0]const u8,
lpDeltaName: ?[*:0]const u8,
lpTargetName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "msdelta" fn ApplyDeltaW(
ApplyFlags: i64,
lpSourceName: ?[*:0]const u16,
lpDeltaName: ?[*:0]const u16,
lpTargetName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "msdelta" fn CreateDeltaB(
FileTypeSet: i64,
SetFlags: i64,
ResetFlags: i64,
Source: DELTA_INPUT,
Target: DELTA_INPUT,
SourceOptions: DELTA_INPUT,
TargetOptions: DELTA_INPUT,
GlobalOptions: DELTA_INPUT,
lpTargetFileTime: ?*const FILETIME,
HashAlgId: u32,
lpDelta: ?*DELTA_OUTPUT,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "msdelta" fn CreateDeltaA(
FileTypeSet: i64,
SetFlags: i64,
ResetFlags: i64,
lpSourceName: ?[*:0]const u8,
lpTargetName: ?[*:0]const u8,
lpSourceOptionsName: ?[*:0]const u8,
lpTargetOptionsName: ?[*:0]const u8,
GlobalOptions: DELTA_INPUT,
lpTargetFileTime: ?*const FILETIME,
HashAlgId: u32,
lpDeltaName: ?[*:0]const u8,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "msdelta" fn CreateDeltaW(
FileTypeSet: i64,
SetFlags: i64,
ResetFlags: i64,
lpSourceName: ?[*:0]const u16,
lpTargetName: ?[*:0]const u16,
lpSourceOptionsName: ?[*:0]const u16,
lpTargetOptionsName: ?[*:0]const u16,
GlobalOptions: DELTA_INPUT,
lpTargetFileTime: ?*const FILETIME,
HashAlgId: u32,
lpDeltaName: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "msdelta" fn GetDeltaSignatureB(
FileTypeSet: i64,
HashAlgId: u32,
Source: DELTA_INPUT,
lpHash: ?*DELTA_HASH,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "msdelta" fn GetDeltaSignatureA(
FileTypeSet: i64,
HashAlgId: u32,
lpSourceName: ?[*:0]const u8,
lpHash: ?*DELTA_HASH,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "msdelta" fn GetDeltaSignatureW(
FileTypeSet: i64,
HashAlgId: u32,
lpSourceName: ?[*:0]const u16,
lpHash: ?*DELTA_HASH,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "msdelta" fn DeltaNormalizeProvidedB(
FileTypeSet: i64,
NormalizeFlags: i64,
NormalizeOptions: DELTA_INPUT,
// TODO: what to do with BytesParamIndex 4?
lpSource: ?*anyopaque,
uSourceSize: usize,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "msdelta" fn DeltaFree(
lpMemory: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn CreateActCtxA(
pActCtx: ?*ACTCTXA,
) callconv(@import("std").os.windows.WINAPI) ?HANDLE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn CreateActCtxW(
pActCtx: ?*ACTCTXW,
) callconv(@import("std").os.windows.WINAPI) ?HANDLE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn AddRefActCtx(
hActCtx: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) void;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn ReleaseActCtx(
hActCtx: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) void;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn ZombifyActCtx(
hActCtx: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn ActivateActCtx(
hActCtx: ?HANDLE,
lpCookie: ?*usize,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn DeactivateActCtx(
dwFlags: u32,
ulCookie: usize,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn GetCurrentActCtx(
lphActCtx: ?*?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn FindActCtxSectionStringA(
dwFlags: u32,
lpExtensionGuid: ?*const Guid,
ulSectionId: u32,
lpStringToFind: ?[*:0]const u8,
ReturnedData: ?*ACTCTX_SECTION_KEYED_DATA,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn FindActCtxSectionStringW(
dwFlags: u32,
lpExtensionGuid: ?*const Guid,
ulSectionId: u32,
lpStringToFind: ?[*:0]const u16,
ReturnedData: ?*ACTCTX_SECTION_KEYED_DATA,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn FindActCtxSectionGuid(
dwFlags: u32,
lpExtensionGuid: ?*const Guid,
ulSectionId: u32,
lpGuidToFind: ?*const Guid,
ReturnedData: ?*ACTCTX_SECTION_KEYED_DATA,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn QueryActCtxW(
dwFlags: u32,
hActCtx: ?HANDLE,
pvSubInstance: ?*anyopaque,
ulInfoClass: u32,
// TODO: what to do with BytesParamIndex 5?
pvBuffer: ?*anyopaque,
cbBuffer: usize,
pcbWrittenOrRequired: ?*usize,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "KERNEL32" fn QueryActCtxSettingsW(
dwFlags: u32,
hActCtx: ?HANDLE,
settingsNameSpace: ?[*:0]const u16,
settingName: ?[*:0]const u16,
// TODO: what to do with BytesParamIndex 5?
pvBuffer: ?PWSTR,
dwBuffer: usize,
pdwWrittenOrRequired: ?*usize,
) callconv(@import("std").os.windows.WINAPI) BOOL;
//--------------------------------------------------------------------------------
// Section: Unicode Aliases (133)
//--------------------------------------------------------------------------------
const thismodule = @This();
pub usingnamespace switch (@import("../zig.zig").unicode_mode) {
.ansi => struct {
pub const INSTALLUI_HANDLER = thismodule.INSTALLUI_HANDLERA;
pub const MSIPATCHSEQUENCEINFO = thismodule.MSIPATCHSEQUENCEINFOA;
pub const PATCH_OLD_FILE_INFO_ = thismodule.PATCH_OLD_FILE_INFO_A;
pub const ACTCTX = thismodule.ACTCTXA;
pub const MsiSetExternalUI = thismodule.MsiSetExternalUIA;
pub const MsiEnableLog = thismodule.MsiEnableLogA;
pub const MsiQueryProductState = thismodule.MsiQueryProductStateA;
pub const MsiGetProductInfo = thismodule.MsiGetProductInfoA;
pub const MsiGetProductInfoEx = thismodule.MsiGetProductInfoExA;
pub const MsiInstallProduct = thismodule.MsiInstallProductA;
pub const MsiConfigureProduct = thismodule.MsiConfigureProductA;
pub const MsiConfigureProductEx = thismodule.MsiConfigureProductExA;
pub const MsiReinstallProduct = thismodule.MsiReinstallProductA;
pub const MsiAdvertiseProductEx = thismodule.MsiAdvertiseProductExA;
pub const MsiAdvertiseProduct = thismodule.MsiAdvertiseProductA;
pub const MsiProcessAdvertiseScript = thismodule.MsiProcessAdvertiseScriptA;
pub const MsiAdvertiseScript = thismodule.MsiAdvertiseScriptA;
pub const MsiGetProductInfoFromScript = thismodule.MsiGetProductInfoFromScriptA;
pub const MsiGetProductCode = thismodule.MsiGetProductCodeA;
pub const MsiGetUserInfo = thismodule.MsiGetUserInfoA;
pub const MsiCollectUserInfo = thismodule.MsiCollectUserInfoA;
pub const MsiApplyPatch = thismodule.MsiApplyPatchA;
pub const MsiGetPatchInfo = thismodule.MsiGetPatchInfoA;
pub const MsiEnumPatches = thismodule.MsiEnumPatchesA;
pub const MsiRemovePatches = thismodule.MsiRemovePatchesA;
pub const MsiExtractPatchXMLData = thismodule.MsiExtractPatchXMLDataA;
pub const MsiGetPatchInfoEx = thismodule.MsiGetPatchInfoExA;
pub const MsiApplyMultiplePatches = thismodule.MsiApplyMultiplePatchesA;
pub const MsiDeterminePatchSequence = thismodule.MsiDeterminePatchSequenceA;
pub const MsiDetermineApplicablePatches = thismodule.MsiDetermineApplicablePatchesA;
pub const MsiEnumPatchesEx = thismodule.MsiEnumPatchesExA;
pub const MsiQueryFeatureState = thismodule.MsiQueryFeatureStateA;
pub const MsiQueryFeatureStateEx = thismodule.MsiQueryFeatureStateExA;
pub const MsiUseFeature = thismodule.MsiUseFeatureA;
pub const MsiUseFeatureEx = thismodule.MsiUseFeatureExA;
pub const MsiGetFeatureUsage = thismodule.MsiGetFeatureUsageA;
pub const MsiConfigureFeature = thismodule.MsiConfigureFeatureA;
pub const MsiReinstallFeature = thismodule.MsiReinstallFeatureA;
pub const MsiProvideComponent = thismodule.MsiProvideComponentA;
pub const MsiProvideQualifiedComponent = thismodule.MsiProvideQualifiedComponentA;
pub const MsiProvideQualifiedComponentEx = thismodule.MsiProvideQualifiedComponentExA;
pub const MsiGetComponentPath = thismodule.MsiGetComponentPathA;
pub const MsiGetComponentPathEx = thismodule.MsiGetComponentPathExA;
pub const MsiProvideAssembly = thismodule.MsiProvideAssemblyA;
pub const MsiQueryComponentState = thismodule.MsiQueryComponentStateA;
pub const MsiEnumProducts = thismodule.MsiEnumProductsA;
pub const MsiEnumProductsEx = thismodule.MsiEnumProductsExA;
pub const MsiEnumRelatedProducts = thismodule.MsiEnumRelatedProductsA;
pub const MsiEnumFeatures = thismodule.MsiEnumFeaturesA;
pub const MsiEnumComponents = thismodule.MsiEnumComponentsA;
pub const MsiEnumComponentsEx = thismodule.MsiEnumComponentsExA;
pub const MsiEnumClients = thismodule.MsiEnumClientsA;
pub const MsiEnumClientsEx = thismodule.MsiEnumClientsExA;
pub const MsiEnumComponentQualifiers = thismodule.MsiEnumComponentQualifiersA;
pub const MsiOpenProduct = thismodule.MsiOpenProductA;
pub const MsiOpenPackage = thismodule.MsiOpenPackageA;
pub const MsiOpenPackageEx = thismodule.MsiOpenPackageExA;
pub const MsiGetPatchFileList = thismodule.MsiGetPatchFileListA;
pub const MsiGetProductProperty = thismodule.MsiGetProductPropertyA;
pub const MsiVerifyPackage = thismodule.MsiVerifyPackageA;
pub const MsiGetFeatureInfo = thismodule.MsiGetFeatureInfoA;
pub const MsiInstallMissingComponent = thismodule.MsiInstallMissingComponentA;
pub const MsiInstallMissingFile = thismodule.MsiInstallMissingFileA;
pub const MsiLocateComponent = thismodule.MsiLocateComponentA;
pub const MsiSourceListClearAll = thismodule.MsiSourceListClearAllA;
pub const MsiSourceListAddSource = thismodule.MsiSourceListAddSourceA;
pub const MsiSourceListForceResolution = thismodule.MsiSourceListForceResolutionA;
pub const MsiSourceListAddSourceEx = thismodule.MsiSourceListAddSourceExA;
pub const MsiSourceListAddMediaDisk = thismodule.MsiSourceListAddMediaDiskA;
pub const MsiSourceListClearSource = thismodule.MsiSourceListClearSourceA;
pub const MsiSourceListClearMediaDisk = thismodule.MsiSourceListClearMediaDiskA;
pub const MsiSourceListClearAllEx = thismodule.MsiSourceListClearAllExA;
pub const MsiSourceListForceResolutionEx = thismodule.MsiSourceListForceResolutionExA;
pub const MsiSourceListSetInfo = thismodule.MsiSourceListSetInfoA;
pub const MsiSourceListGetInfo = thismodule.MsiSourceListGetInfoA;
pub const MsiSourceListEnumSources = thismodule.MsiSourceListEnumSourcesA;
pub const MsiSourceListEnumMediaDisks = thismodule.MsiSourceListEnumMediaDisksA;
pub const MsiGetFileVersion = thismodule.MsiGetFileVersionA;
pub const MsiGetFileHash = thismodule.MsiGetFileHashA;
pub const MsiGetFileSignatureInformation = thismodule.MsiGetFileSignatureInformationA;
pub const MsiGetShortcutTarget = thismodule.MsiGetShortcutTargetA;
pub const MsiIsProductElevated = thismodule.MsiIsProductElevatedA;
pub const MsiNotifySidChange = thismodule.MsiNotifySidChangeA;
pub const MsiBeginTransaction = thismodule.MsiBeginTransactionA;
pub const MsiDatabaseOpenView = thismodule.MsiDatabaseOpenViewA;
pub const MsiViewGetError = thismodule.MsiViewGetErrorA;
pub const MsiDatabaseGetPrimaryKeys = thismodule.MsiDatabaseGetPrimaryKeysA;
pub const MsiDatabaseIsTablePersistent = thismodule.MsiDatabaseIsTablePersistentA;
pub const MsiGetSummaryInformation = thismodule.MsiGetSummaryInformationA;
pub const MsiSummaryInfoSetProperty = thismodule.MsiSummaryInfoSetPropertyA;
pub const MsiSummaryInfoGetProperty = thismodule.MsiSummaryInfoGetPropertyA;
pub const MsiOpenDatabase = thismodule.MsiOpenDatabaseA;
pub const MsiDatabaseImport = thismodule.MsiDatabaseImportA;
pub const MsiDatabaseExport = thismodule.MsiDatabaseExportA;
pub const MsiDatabaseMerge = thismodule.MsiDatabaseMergeA;
pub const MsiDatabaseGenerateTransform = thismodule.MsiDatabaseGenerateTransformA;
pub const MsiDatabaseApplyTransform = thismodule.MsiDatabaseApplyTransformA;
pub const MsiCreateTransformSummaryInfo = thismodule.MsiCreateTransformSummaryInfoA;
pub const MsiRecordSetString = thismodule.MsiRecordSetStringA;
pub const MsiRecordGetString = thismodule.MsiRecordGetStringA;
pub const MsiRecordSetStream = thismodule.MsiRecordSetStreamA;
pub const MsiSetProperty = thismodule.MsiSetPropertyA;
pub const MsiGetProperty = thismodule.MsiGetPropertyA;
pub const MsiFormatRecord = thismodule.MsiFormatRecordA;
pub const MsiDoAction = thismodule.MsiDoActionA;
pub const MsiSequence = thismodule.MsiSequenceA;
pub const MsiEvaluateCondition = thismodule.MsiEvaluateConditionA;
pub const MsiGetFeatureState = thismodule.MsiGetFeatureStateA;
pub const MsiSetFeatureState = thismodule.MsiSetFeatureStateA;
pub const MsiSetFeatureAttributes = thismodule.MsiSetFeatureAttributesA;
pub const MsiGetComponentState = thismodule.MsiGetComponentStateA;
pub const MsiSetComponentState = thismodule.MsiSetComponentStateA;
pub const MsiGetFeatureCost = thismodule.MsiGetFeatureCostA;
pub const MsiEnumComponentCosts = thismodule.MsiEnumComponentCostsA;
pub const MsiGetFeatureValidStates = thismodule.MsiGetFeatureValidStatesA;
pub const MsiGetSourcePath = thismodule.MsiGetSourcePathA;
pub const MsiGetTargetPath = thismodule.MsiGetTargetPathA;
pub const MsiSetTargetPath = thismodule.MsiSetTargetPathA;
pub const MsiPreviewDialog = thismodule.MsiPreviewDialogA;
pub const MsiPreviewBillboard = thismodule.MsiPreviewBillboardA;
pub const CreatePatchFile = thismodule.CreatePatchFileA;
pub const CreatePatchFileEx = thismodule.CreatePatchFileExA;
pub const ExtractPatchHeaderToFile = thismodule.ExtractPatchHeaderToFileA;
pub const TestApplyPatchToFile = thismodule.TestApplyPatchToFileA;
pub const ApplyPatchToFile = thismodule.ApplyPatchToFileA;
pub const ApplyPatchToFileEx = thismodule.ApplyPatchToFileExA;
pub const GetFilePatchSignature = thismodule.GetFilePatchSignatureA;
pub const GetDeltaInfo = thismodule.GetDeltaInfoA;
pub const ApplyDelta = thismodule.ApplyDeltaA;
pub const CreateDelta = thismodule.CreateDeltaA;
pub const GetDeltaSignature = thismodule.GetDeltaSignatureA;
pub const CreateActCtx = thismodule.CreateActCtxA;
pub const FindActCtxSectionString = thismodule.FindActCtxSectionStringA;
},
.wide => struct {
pub const INSTALLUI_HANDLER = thismodule.INSTALLUI_HANDLERW;
pub const MSIPATCHSEQUENCEINFO = thismodule.MSIPATCHSEQUENCEINFOW;
pub const PATCH_OLD_FILE_INFO_ = thismodule.PATCH_OLD_FILE_INFO_W;
pub const ACTCTX = thismodule.ACTCTXW;
pub const MsiSetExternalUI = thismodule.MsiSetExternalUIW;
pub const MsiEnableLog = thismodule.MsiEnableLogW;
pub const MsiQueryProductState = thismodule.MsiQueryProductStateW;
pub const MsiGetProductInfo = thismodule.MsiGetProductInfoW;
pub const MsiGetProductInfoEx = thismodule.MsiGetProductInfoExW;
pub const MsiInstallProduct = thismodule.MsiInstallProductW;
pub const MsiConfigureProduct = thismodule.MsiConfigureProductW;
pub const MsiConfigureProductEx = thismodule.MsiConfigureProductExW;
pub const MsiReinstallProduct = thismodule.MsiReinstallProductW;
pub const MsiAdvertiseProductEx = thismodule.MsiAdvertiseProductExW;
pub const MsiAdvertiseProduct = thismodule.MsiAdvertiseProductW;
pub const MsiProcessAdvertiseScript = thismodule.MsiProcessAdvertiseScriptW;
pub const MsiAdvertiseScript = thismodule.MsiAdvertiseScriptW;
pub const MsiGetProductInfoFromScript = thismodule.MsiGetProductInfoFromScriptW;
pub const MsiGetProductCode = thismodule.MsiGetProductCodeW;
pub const MsiGetUserInfo = thismodule.MsiGetUserInfoW;
pub const MsiCollectUserInfo = thismodule.MsiCollectUserInfoW;
pub const MsiApplyPatch = thismodule.MsiApplyPatchW;
pub const MsiGetPatchInfo = thismodule.MsiGetPatchInfoW;
pub const MsiEnumPatches = thismodule.MsiEnumPatchesW;
pub const MsiRemovePatches = thismodule.MsiRemovePatchesW;
pub const MsiExtractPatchXMLData = thismodule.MsiExtractPatchXMLDataW;
pub const MsiGetPatchInfoEx = thismodule.MsiGetPatchInfoExW;
pub const MsiApplyMultiplePatches = thismodule.MsiApplyMultiplePatchesW;
pub const MsiDeterminePatchSequence = thismodule.MsiDeterminePatchSequenceW;
pub const MsiDetermineApplicablePatches = thismodule.MsiDetermineApplicablePatchesW;
pub const MsiEnumPatchesEx = thismodule.MsiEnumPatchesExW;
pub const MsiQueryFeatureState = thismodule.MsiQueryFeatureStateW;
pub const MsiQueryFeatureStateEx = thismodule.MsiQueryFeatureStateExW;
pub const MsiUseFeature = thismodule.MsiUseFeatureW;
pub const MsiUseFeatureEx = thismodule.MsiUseFeatureExW;
pub const MsiGetFeatureUsage = thismodule.MsiGetFeatureUsageW;
pub const MsiConfigureFeature = thismodule.MsiConfigureFeatureW;
pub const MsiReinstallFeature = thismodule.MsiReinstallFeatureW;
pub const MsiProvideComponent = thismodule.MsiProvideComponentW;
pub const MsiProvideQualifiedComponent = thismodule.MsiProvideQualifiedComponentW;
pub const MsiProvideQualifiedComponentEx = thismodule.MsiProvideQualifiedComponentExW;
pub const MsiGetComponentPath = thismodule.MsiGetComponentPathW;
pub const MsiGetComponentPathEx = thismodule.MsiGetComponentPathExW;
pub const MsiProvideAssembly = thismodule.MsiProvideAssemblyW;
pub const MsiQueryComponentState = thismodule.MsiQueryComponentStateW;
pub const MsiEnumProducts = thismodule.MsiEnumProductsW;
pub const MsiEnumProductsEx = thismodule.MsiEnumProductsExW;
pub const MsiEnumRelatedProducts = thismodule.MsiEnumRelatedProductsW;
pub const MsiEnumFeatures = thismodule.MsiEnumFeaturesW;
pub const MsiEnumComponents = thismodule.MsiEnumComponentsW;
pub const MsiEnumComponentsEx = thismodule.MsiEnumComponentsExW;
pub const MsiEnumClients = thismodule.MsiEnumClientsW;
pub const MsiEnumClientsEx = thismodule.MsiEnumClientsExW;
pub const MsiEnumComponentQualifiers = thismodule.MsiEnumComponentQualifiersW;
pub const MsiOpenProduct = thismodule.MsiOpenProductW;
pub const MsiOpenPackage = thismodule.MsiOpenPackageW;
pub const MsiOpenPackageEx = thismodule.MsiOpenPackageExW;
pub const MsiGetPatchFileList = thismodule.MsiGetPatchFileListW;
pub const MsiGetProductProperty = thismodule.MsiGetProductPropertyW;
pub const MsiVerifyPackage = thismodule.MsiVerifyPackageW;
pub const MsiGetFeatureInfo = thismodule.MsiGetFeatureInfoW;
pub const MsiInstallMissingComponent = thismodule.MsiInstallMissingComponentW;
pub const MsiInstallMissingFile = thismodule.MsiInstallMissingFileW;
pub const MsiLocateComponent = thismodule.MsiLocateComponentW;
pub const MsiSourceListClearAll = thismodule.MsiSourceListClearAllW;
pub const MsiSourceListAddSource = thismodule.MsiSourceListAddSourceW;
pub const MsiSourceListForceResolution = thismodule.MsiSourceListForceResolutionW;
pub const MsiSourceListAddSourceEx = thismodule.MsiSourceListAddSourceExW;
pub const MsiSourceListAddMediaDisk = thismodule.MsiSourceListAddMediaDiskW;
pub const MsiSourceListClearSource = thismodule.MsiSourceListClearSourceW;
pub const MsiSourceListClearMediaDisk = thismodule.MsiSourceListClearMediaDiskW;
pub const MsiSourceListClearAllEx = thismodule.MsiSourceListClearAllExW;
pub const MsiSourceListForceResolutionEx = thismodule.MsiSourceListForceResolutionExW;
pub const MsiSourceListSetInfo = thismodule.MsiSourceListSetInfoW;
pub const MsiSourceListGetInfo = thismodule.MsiSourceListGetInfoW;
pub const MsiSourceListEnumSources = thismodule.MsiSourceListEnumSourcesW;
pub const MsiSourceListEnumMediaDisks = thismodule.MsiSourceListEnumMediaDisksW;
pub const MsiGetFileVersion = thismodule.MsiGetFileVersionW;
pub const MsiGetFileHash = thismodule.MsiGetFileHashW;
pub const MsiGetFileSignatureInformation = thismodule.MsiGetFileSignatureInformationW;
pub const MsiGetShortcutTarget = thismodule.MsiGetShortcutTargetW;
pub const MsiIsProductElevated = thismodule.MsiIsProductElevatedW;
pub const MsiNotifySidChange = thismodule.MsiNotifySidChangeW;
pub const MsiBeginTransaction = thismodule.MsiBeginTransactionW;
pub const MsiDatabaseOpenView = thismodule.MsiDatabaseOpenViewW;
pub const MsiViewGetError = thismodule.MsiViewGetErrorW;
pub const MsiDatabaseGetPrimaryKeys = thismodule.MsiDatabaseGetPrimaryKeysW;
pub const MsiDatabaseIsTablePersistent = thismodule.MsiDatabaseIsTablePersistentW;
pub const MsiGetSummaryInformation = thismodule.MsiGetSummaryInformationW;
pub const MsiSummaryInfoSetProperty = thismodule.MsiSummaryInfoSetPropertyW;
pub const MsiSummaryInfoGetProperty = thismodule.MsiSummaryInfoGetPropertyW;
pub const MsiOpenDatabase = thismodule.MsiOpenDatabaseW;
pub const MsiDatabaseImport = thismodule.MsiDatabaseImportW;
pub const MsiDatabaseExport = thismodule.MsiDatabaseExportW;
pub const MsiDatabaseMerge = thismodule.MsiDatabaseMergeW;
pub const MsiDatabaseGenerateTransform = thismodule.MsiDatabaseGenerateTransformW;
pub const MsiDatabaseApplyTransform = thismodule.MsiDatabaseApplyTransformW;
pub const MsiCreateTransformSummaryInfo = thismodule.MsiCreateTransformSummaryInfoW;
pub const MsiRecordSetString = thismodule.MsiRecordSetStringW;
pub const MsiRecordGetString = thismodule.MsiRecordGetStringW;
pub const MsiRecordSetStream = thismodule.MsiRecordSetStreamW;
pub const MsiSetProperty = thismodule.MsiSetPropertyW;
pub const MsiGetProperty = thismodule.MsiGetPropertyW;
pub const MsiFormatRecord = thismodule.MsiFormatRecordW;
pub const MsiDoAction = thismodule.MsiDoActionW;
pub const MsiSequence = thismodule.MsiSequenceW;
pub const MsiEvaluateCondition = thismodule.MsiEvaluateConditionW;
pub const MsiGetFeatureState = thismodule.MsiGetFeatureStateW;
pub const MsiSetFeatureState = thismodule.MsiSetFeatureStateW;
pub const MsiSetFeatureAttributes = thismodule.MsiSetFeatureAttributesW;
pub const MsiGetComponentState = thismodule.MsiGetComponentStateW;
pub const MsiSetComponentState = thismodule.MsiSetComponentStateW;
pub const MsiGetFeatureCost = thismodule.MsiGetFeatureCostW;
pub const MsiEnumComponentCosts = thismodule.MsiEnumComponentCostsW;
pub const MsiGetFeatureValidStates = thismodule.MsiGetFeatureValidStatesW;
pub const MsiGetSourcePath = thismodule.MsiGetSourcePathW;
pub const MsiGetTargetPath = thismodule.MsiGetTargetPathW;
pub const MsiSetTargetPath = thismodule.MsiSetTargetPathW;
pub const MsiPreviewDialog = thismodule.MsiPreviewDialogW;
pub const MsiPreviewBillboard = thismodule.MsiPreviewBillboardW;
pub const CreatePatchFile = thismodule.CreatePatchFileW;
pub const CreatePatchFileEx = thismodule.CreatePatchFileExW;
pub const ExtractPatchHeaderToFile = thismodule.ExtractPatchHeaderToFileW;
pub const TestApplyPatchToFile = thismodule.TestApplyPatchToFileW;
pub const ApplyPatchToFile = thismodule.ApplyPatchToFileW;
pub const ApplyPatchToFileEx = thismodule.ApplyPatchToFileExW;
pub const GetFilePatchSignature = thismodule.GetFilePatchSignatureW;
pub const GetDeltaInfo = thismodule.GetDeltaInfoW;
pub const ApplyDelta = thismodule.ApplyDeltaW;
pub const CreateDelta = thismodule.CreateDeltaW;
pub const GetDeltaSignature = thismodule.GetDeltaSignatureW;
pub const CreateActCtx = thismodule.CreateActCtxW;
pub const FindActCtxSectionString = thismodule.FindActCtxSectionStringW;
},
.unspecified => if (@import("builtin").is_test) struct {
pub const INSTALLUI_HANDLER = *opaque{};
pub const MSIPATCHSEQUENCEINFO = *opaque{};
pub const PATCH_OLD_FILE_INFO_ = *opaque{};
pub const ACTCTX = *opaque{};
pub const MsiSetExternalUI = *opaque{};
pub const MsiEnableLog = *opaque{};
pub const MsiQueryProductState = *opaque{};
pub const MsiGetProductInfo = *opaque{};
pub const MsiGetProductInfoEx = *opaque{};
pub const MsiInstallProduct = *opaque{};
pub const MsiConfigureProduct = *opaque{};
pub const MsiConfigureProductEx = *opaque{};
pub const MsiReinstallProduct = *opaque{};
pub const MsiAdvertiseProductEx = *opaque{};
pub const MsiAdvertiseProduct = *opaque{};
pub const MsiProcessAdvertiseScript = *opaque{};
pub const MsiAdvertiseScript = *opaque{};
pub const MsiGetProductInfoFromScript = *opaque{};
pub const MsiGetProductCode = *opaque{};
pub const MsiGetUserInfo = *opaque{};
pub const MsiCollectUserInfo = *opaque{};
pub const MsiApplyPatch = *opaque{};
pub const MsiGetPatchInfo = *opaque{};
pub const MsiEnumPatches = *opaque{};
pub const MsiRemovePatches = *opaque{};
pub const MsiExtractPatchXMLData = *opaque{};
pub const MsiGetPatchInfoEx = *opaque{};
pub const MsiApplyMultiplePatches = *opaque{};
pub const MsiDeterminePatchSequence = *opaque{};
pub const MsiDetermineApplicablePatches = *opaque{};
pub const MsiEnumPatchesEx = *opaque{};
pub const MsiQueryFeatureState = *opaque{};
pub const MsiQueryFeatureStateEx = *opaque{};
pub const MsiUseFeature = *opaque{};
pub const MsiUseFeatureEx = *opaque{};
pub const MsiGetFeatureUsage = *opaque{};
pub const MsiConfigureFeature = *opaque{};
pub const MsiReinstallFeature = *opaque{};
pub const MsiProvideComponent = *opaque{};
pub const MsiProvideQualifiedComponent = *opaque{};
pub const MsiProvideQualifiedComponentEx = *opaque{};
pub const MsiGetComponentPath = *opaque{};
pub const MsiGetComponentPathEx = *opaque{};
pub const MsiProvideAssembly = *opaque{};
pub const MsiQueryComponentState = *opaque{};
pub const MsiEnumProducts = *opaque{};
pub const MsiEnumProductsEx = *opaque{};
pub const MsiEnumRelatedProducts = *opaque{};
pub const MsiEnumFeatures = *opaque{};
pub const MsiEnumComponents = *opaque{};
pub const MsiEnumComponentsEx = *opaque{};
pub const MsiEnumClients = *opaque{};
pub const MsiEnumClientsEx = *opaque{};
pub const MsiEnumComponentQualifiers = *opaque{};
pub const MsiOpenProduct = *opaque{};
pub const MsiOpenPackage = *opaque{};
pub const MsiOpenPackageEx = *opaque{};
pub const MsiGetPatchFileList = *opaque{};
pub const MsiGetProductProperty = *opaque{};
pub const MsiVerifyPackage = *opaque{};
pub const MsiGetFeatureInfo = *opaque{};
pub const MsiInstallMissingComponent = *opaque{};
pub const MsiInstallMissingFile = *opaque{};
pub const MsiLocateComponent = *opaque{};
pub const MsiSourceListClearAll = *opaque{};
pub const MsiSourceListAddSource = *opaque{};
pub const MsiSourceListForceResolution = *opaque{};
pub const MsiSourceListAddSourceEx = *opaque{};
pub const MsiSourceListAddMediaDisk = *opaque{};
pub const MsiSourceListClearSource = *opaque{};
pub const MsiSourceListClearMediaDisk = *opaque{};
pub const MsiSourceListClearAllEx = *opaque{};
pub const MsiSourceListForceResolutionEx = *opaque{};
pub const MsiSourceListSetInfo = *opaque{};
pub const MsiSourceListGetInfo = *opaque{};
pub const MsiSourceListEnumSources = *opaque{};
pub const MsiSourceListEnumMediaDisks = *opaque{};
pub const MsiGetFileVersion = *opaque{};
pub const MsiGetFileHash = *opaque{};
pub const MsiGetFileSignatureInformation = *opaque{};
pub const MsiGetShortcutTarget = *opaque{};
pub const MsiIsProductElevated = *opaque{};
pub const MsiNotifySidChange = *opaque{};
pub const MsiBeginTransaction = *opaque{};
pub const MsiDatabaseOpenView = *opaque{};
pub const MsiViewGetError = *opaque{};
pub const MsiDatabaseGetPrimaryKeys = *opaque{};
pub const MsiDatabaseIsTablePersistent = *opaque{};
pub const MsiGetSummaryInformation = *opaque{};
pub const MsiSummaryInfoSetProperty = *opaque{};
pub const MsiSummaryInfoGetProperty = *opaque{};
pub const MsiOpenDatabase = *opaque{};
pub const MsiDatabaseImport = *opaque{};
pub const MsiDatabaseExport = *opaque{};
pub const MsiDatabaseMerge = *opaque{};
pub const MsiDatabaseGenerateTransform = *opaque{};
pub const MsiDatabaseApplyTransform = *opaque{};
pub const MsiCreateTransformSummaryInfo = *opaque{};
pub const MsiRecordSetString = *opaque{};
pub const MsiRecordGetString = *opaque{};
pub const MsiRecordSetStream = *opaque{};
pub const MsiSetProperty = *opaque{};
pub const MsiGetProperty = *opaque{};
pub const MsiFormatRecord = *opaque{};
pub const MsiDoAction = *opaque{};
pub const MsiSequence = *opaque{};
pub const MsiEvaluateCondition = *opaque{};
pub const MsiGetFeatureState = *opaque{};
pub const MsiSetFeatureState = *opaque{};
pub const MsiSetFeatureAttributes = *opaque{};
pub const MsiGetComponentState = *opaque{};
pub const MsiSetComponentState = *opaque{};
pub const MsiGetFeatureCost = *opaque{};
pub const MsiEnumComponentCosts = *opaque{};
pub const MsiGetFeatureValidStates = *opaque{};
pub const MsiGetSourcePath = *opaque{};
pub const MsiGetTargetPath = *opaque{};
pub const MsiSetTargetPath = *opaque{};
pub const MsiPreviewDialog = *opaque{};
pub const MsiPreviewBillboard = *opaque{};
pub const CreatePatchFile = *opaque{};
pub const CreatePatchFileEx = *opaque{};
pub const ExtractPatchHeaderToFile = *opaque{};
pub const TestApplyPatchToFile = *opaque{};
pub const ApplyPatchToFile = *opaque{};
pub const ApplyPatchToFileEx = *opaque{};
pub const GetFilePatchSignature = *opaque{};
pub const GetDeltaInfo = *opaque{};
pub const ApplyDelta = *opaque{};
pub const CreateDelta = *opaque{};
pub const GetDeltaSignature = *opaque{};
pub const CreateActCtx = *opaque{};
pub const FindActCtxSectionString = *opaque{};
} else struct {
pub const INSTALLUI_HANDLER = @compileError("'INSTALLUI_HANDLER' requires that UNICODE be set to true or false in the root module");
pub const MSIPATCHSEQUENCEINFO = @compileError("'MSIPATCHSEQUENCEINFO' requires that UNICODE be set to true or false in the root module");
pub const PATCH_OLD_FILE_INFO_ = @compileError("'PATCH_OLD_FILE_INFO_' requires that UNICODE be set to true or false in the root module");
pub const ACTCTX = @compileError("'ACTCTX' requires that UNICODE be set to true or false in the root module");
pub const MsiSetExternalUI = @compileError("'MsiSetExternalUI' requires that UNICODE be set to true or false in the root module");
pub const MsiEnableLog = @compileError("'MsiEnableLog' requires that UNICODE be set to true or false in the root module");
pub const MsiQueryProductState = @compileError("'MsiQueryProductState' requires that UNICODE be set to true or false in the root module");
pub const MsiGetProductInfo = @compileError("'MsiGetProductInfo' requires that UNICODE be set to true or false in the root module");
pub const MsiGetProductInfoEx = @compileError("'MsiGetProductInfoEx' requires that UNICODE be set to true or false in the root module");
pub const MsiInstallProduct = @compileError("'MsiInstallProduct' requires that UNICODE be set to true or false in the root module");
pub const MsiConfigureProduct = @compileError("'MsiConfigureProduct' requires that UNICODE be set to true or false in the root module");
pub const MsiConfigureProductEx = @compileError("'MsiConfigureProductEx' requires that UNICODE be set to true or false in the root module");
pub const MsiReinstallProduct = @compileError("'MsiReinstallProduct' requires that UNICODE be set to true or false in the root module");
pub const MsiAdvertiseProductEx = @compileError("'MsiAdvertiseProductEx' requires that UNICODE be set to true or false in the root module");
pub const MsiAdvertiseProduct = @compileError("'MsiAdvertiseProduct' requires that UNICODE be set to true or false in the root module");
pub const MsiProcessAdvertiseScript = @compileError("'MsiProcessAdvertiseScript' requires that UNICODE be set to true or false in the root module");
pub const MsiAdvertiseScript = @compileError("'MsiAdvertiseScript' requires that UNICODE be set to true or false in the root module");
pub const MsiGetProductInfoFromScript = @compileError("'MsiGetProductInfoFromScript' requires that UNICODE be set to true or false in the root module");
pub const MsiGetProductCode = @compileError("'MsiGetProductCode' requires that UNICODE be set to true or false in the root module");
pub const MsiGetUserInfo = @compileError("'MsiGetUserInfo' requires that UNICODE be set to true or false in the root module");
pub const MsiCollectUserInfo = @compileError("'MsiCollectUserInfo' requires that UNICODE be set to true or false in the root module");
pub const MsiApplyPatch = @compileError("'MsiApplyPatch' requires that UNICODE be set to true or false in the root module");
pub const MsiGetPatchInfo = @compileError("'MsiGetPatchInfo' requires that UNICODE be set to true or false in the root module");
pub const MsiEnumPatches = @compileError("'MsiEnumPatches' requires that UNICODE be set to true or false in the root module");
pub const MsiRemovePatches = @compileError("'MsiRemovePatches' requires that UNICODE be set to true or false in the root module");
pub const MsiExtractPatchXMLData = @compileError("'MsiExtractPatchXMLData' requires that UNICODE be set to true or false in the root module");
pub const MsiGetPatchInfoEx = @compileError("'MsiGetPatchInfoEx' requires that UNICODE be set to true or false in the root module");
pub const MsiApplyMultiplePatches = @compileError("'MsiApplyMultiplePatches' requires that UNICODE be set to true or false in the root module");
pub const MsiDeterminePatchSequence = @compileError("'MsiDeterminePatchSequence' requires that UNICODE be set to true or false in the root module");
pub const MsiDetermineApplicablePatches = @compileError("'MsiDetermineApplicablePatches' requires that UNICODE be set to true or false in the root module");
pub const MsiEnumPatchesEx = @compileError("'MsiEnumPatchesEx' requires that UNICODE be set to true or false in the root module");
pub const MsiQueryFeatureState = @compileError("'MsiQueryFeatureState' requires that UNICODE be set to true or false in the root module");
pub const MsiQueryFeatureStateEx = @compileError("'MsiQueryFeatureStateEx' requires that UNICODE be set to true or false in the root module");
pub const MsiUseFeature = @compileError("'MsiUseFeature' requires that UNICODE be set to true or false in the root module");
pub const MsiUseFeatureEx = @compileError("'MsiUseFeatureEx' requires that UNICODE be set to true or false in the root module");
pub const MsiGetFeatureUsage = @compileError("'MsiGetFeatureUsage' requires that UNICODE be set to true or false in the root module");
pub const MsiConfigureFeature = @compileError("'MsiConfigureFeature' requires that UNICODE be set to true or false in the root module");
pub const MsiReinstallFeature = @compileError("'MsiReinstallFeature' requires that UNICODE be set to true or false in the root module");
pub const MsiProvideComponent = @compileError("'MsiProvideComponent' requires that UNICODE be set to true or false in the root module");
pub const MsiProvideQualifiedComponent = @compileError("'MsiProvideQualifiedComponent' requires that UNICODE be set to true or false in the root module");
pub const MsiProvideQualifiedComponentEx = @compileError("'MsiProvideQualifiedComponentEx' requires that UNICODE be set to true or false in the root module");
pub const MsiGetComponentPath = @compileError("'MsiGetComponentPath' requires that UNICODE be set to true or false in the root module");
pub const MsiGetComponentPathEx = @compileError("'MsiGetComponentPathEx' requires that UNICODE be set to true or false in the root module");
pub const MsiProvideAssembly = @compileError("'MsiProvideAssembly' requires that UNICODE be set to true or false in the root module");
pub const MsiQueryComponentState = @compileError("'MsiQueryComponentState' requires that UNICODE be set to true or false in the root module");
pub const MsiEnumProducts = @compileError("'MsiEnumProducts' requires that UNICODE be set to true or false in the root module");
pub const MsiEnumProductsEx = @compileError("'MsiEnumProductsEx' requires that UNICODE be set to true or false in the root module");
pub const MsiEnumRelatedProducts = @compileError("'MsiEnumRelatedProducts' requires that UNICODE be set to true or false in the root module");
pub const MsiEnumFeatures = @compileError("'MsiEnumFeatures' requires that UNICODE be set to true or false in the root module");
pub const MsiEnumComponents = @compileError("'MsiEnumComponents' requires that UNICODE be set to true or false in the root module");
pub const MsiEnumComponentsEx = @compileError("'MsiEnumComponentsEx' requires that UNICODE be set to true or false in the root module");
pub const MsiEnumClients = @compileError("'MsiEnumClients' requires that UNICODE be set to true or false in the root module");
pub const MsiEnumClientsEx = @compileError("'MsiEnumClientsEx' requires that UNICODE be set to true or false in the root module");
pub const MsiEnumComponentQualifiers = @compileError("'MsiEnumComponentQualifiers' requires that UNICODE be set to true or false in the root module");
pub const MsiOpenProduct = @compileError("'MsiOpenProduct' requires that UNICODE be set to true or false in the root module");
pub const MsiOpenPackage = @compileError("'MsiOpenPackage' requires that UNICODE be set to true or false in the root module");
pub const MsiOpenPackageEx = @compileError("'MsiOpenPackageEx' requires that UNICODE be set to true or false in the root module");
pub const MsiGetPatchFileList = @compileError("'MsiGetPatchFileList' requires that UNICODE be set to true or false in the root module");
pub const MsiGetProductProperty = @compileError("'MsiGetProductProperty' requires that UNICODE be set to true or false in the root module");
pub const MsiVerifyPackage = @compileError("'MsiVerifyPackage' requires that UNICODE be set to true or false in the root module");
pub const MsiGetFeatureInfo = @compileError("'MsiGetFeatureInfo' requires that UNICODE be set to true or false in the root module");
pub const MsiInstallMissingComponent = @compileError("'MsiInstallMissingComponent' requires that UNICODE be set to true or false in the root module");
pub const MsiInstallMissingFile = @compileError("'MsiInstallMissingFile' requires that UNICODE be set to true or false in the root module");
pub const MsiLocateComponent = @compileError("'MsiLocateComponent' requires that UNICODE be set to true or false in the root module");
pub const MsiSourceListClearAll = @compileError("'MsiSourceListClearAll' requires that UNICODE be set to true or false in the root module");
pub const MsiSourceListAddSource = @compileError("'MsiSourceListAddSource' requires that UNICODE be set to true or false in the root module");
pub const MsiSourceListForceResolution = @compileError("'MsiSourceListForceResolution' requires that UNICODE be set to true or false in the root module");
pub const MsiSourceListAddSourceEx = @compileError("'MsiSourceListAddSourceEx' requires that UNICODE be set to true or false in the root module");
pub const MsiSourceListAddMediaDisk = @compileError("'MsiSourceListAddMediaDisk' requires that UNICODE be set to true or false in the root module");
pub const MsiSourceListClearSource = @compileError("'MsiSourceListClearSource' requires that UNICODE be set to true or false in the root module");
pub const MsiSourceListClearMediaDisk = @compileError("'MsiSourceListClearMediaDisk' requires that UNICODE be set to true or false in the root module");
pub const MsiSourceListClearAllEx = @compileError("'MsiSourceListClearAllEx' requires that UNICODE be set to true or false in the root module");
pub const MsiSourceListForceResolutionEx = @compileError("'MsiSourceListForceResolutionEx' requires that UNICODE be set to true or false in the root module");
pub const MsiSourceListSetInfo = @compileError("'MsiSourceListSetInfo' requires that UNICODE be set to true or false in the root module");
pub const MsiSourceListGetInfo = @compileError("'MsiSourceListGetInfo' requires that UNICODE be set to true or false in the root module");
pub const MsiSourceListEnumSources = @compileError("'MsiSourceListEnumSources' requires that UNICODE be set to true or false in the root module");
pub const MsiSourceListEnumMediaDisks = @compileError("'MsiSourceListEnumMediaDisks' requires that UNICODE be set to true or false in the root module");
pub const MsiGetFileVersion = @compileError("'MsiGetFileVersion' requires that UNICODE be set to true or false in the root module");
pub const MsiGetFileHash = @compileError("'MsiGetFileHash' requires that UNICODE be set to true or false in the root module");
pub const MsiGetFileSignatureInformation = @compileError("'MsiGetFileSignatureInformation' requires that UNICODE be set to true or false in the root module");
pub const MsiGetShortcutTarget = @compileError("'MsiGetShortcutTarget' requires that UNICODE be set to true or false in the root module");
pub const MsiIsProductElevated = @compileError("'MsiIsProductElevated' requires that UNICODE be set to true or false in the root module");
pub const MsiNotifySidChange = @compileError("'MsiNotifySidChange' requires that UNICODE be set to true or false in the root module");
pub const MsiBeginTransaction = @compileError("'MsiBeginTransaction' requires that UNICODE be set to true or false in the root module");
pub const MsiDatabaseOpenView = @compileError("'MsiDatabaseOpenView' requires that UNICODE be set to true or false in the root module");
pub const MsiViewGetError = @compileError("'MsiViewGetError' requires that UNICODE be set to true or false in the root module");
pub const MsiDatabaseGetPrimaryKeys = @compileError("'MsiDatabaseGetPrimaryKeys' requires that UNICODE be set to true or false in the root module");
pub const MsiDatabaseIsTablePersistent = @compileError("'MsiDatabaseIsTablePersistent' requires that UNICODE be set to true or false in the root module");
pub const MsiGetSummaryInformation = @compileError("'MsiGetSummaryInformation' requires that UNICODE be set to true or false in the root module");
pub const MsiSummaryInfoSetProperty = @compileError("'MsiSummaryInfoSetProperty' requires that UNICODE be set to true or false in the root module");
pub const MsiSummaryInfoGetProperty = @compileError("'MsiSummaryInfoGetProperty' requires that UNICODE be set to true or false in the root module");
pub const MsiOpenDatabase = @compileError("'MsiOpenDatabase' requires that UNICODE be set to true or false in the root module");
pub const MsiDatabaseImport = @compileError("'MsiDatabaseImport' requires that UNICODE be set to true or false in the root module");
pub const MsiDatabaseExport = @compileError("'MsiDatabaseExport' requires that UNICODE be set to true or false in the root module");
pub const MsiDatabaseMerge = @compileError("'MsiDatabaseMerge' requires that UNICODE be set to true or false in the root module");
pub const MsiDatabaseGenerateTransform = @compileError("'MsiDatabaseGenerateTransform' requires that UNICODE be set to true or false in the root module");
pub const MsiDatabaseApplyTransform = @compileError("'MsiDatabaseApplyTransform' requires that UNICODE be set to true or false in the root module");
pub const MsiCreateTransformSummaryInfo = @compileError("'MsiCreateTransformSummaryInfo' requires that UNICODE be set to true or false in the root module");
pub const MsiRecordSetString = @compileError("'MsiRecordSetString' requires that UNICODE be set to true or false in the root module");
pub const MsiRecordGetString = @compileError("'MsiRecordGetString' requires that UNICODE be set to true or false in the root module");
pub const MsiRecordSetStream = @compileError("'MsiRecordSetStream' requires that UNICODE be set to true or false in the root module");
pub const MsiSetProperty = @compileError("'MsiSetProperty' requires that UNICODE be set to true or false in the root module");
pub const MsiGetProperty = @compileError("'MsiGetProperty' requires that UNICODE be set to true or false in the root module");
pub const MsiFormatRecord = @compileError("'MsiFormatRecord' requires that UNICODE be set to true or false in the root module");
pub const MsiDoAction = @compileError("'MsiDoAction' requires that UNICODE be set to true or false in the root module");
pub const MsiSequence = @compileError("'MsiSequence' requires that UNICODE be set to true or false in the root module");
pub const MsiEvaluateCondition = @compileError("'MsiEvaluateCondition' requires that UNICODE be set to true or false in the root module");
pub const MsiGetFeatureState = @compileError("'MsiGetFeatureState' requires that UNICODE be set to true or false in the root module");
pub const MsiSetFeatureState = @compileError("'MsiSetFeatureState' requires that UNICODE be set to true or false in the root module");
pub const MsiSetFeatureAttributes = @compileError("'MsiSetFeatureAttributes' requires that UNICODE be set to true or false in the root module");
pub const MsiGetComponentState = @compileError("'MsiGetComponentState' requires that UNICODE be set to true or false in the root module");
pub const MsiSetComponentState = @compileError("'MsiSetComponentState' requires that UNICODE be set to true or false in the root module");
pub const MsiGetFeatureCost = @compileError("'MsiGetFeatureCost' requires that UNICODE be set to true or false in the root module");
pub const MsiEnumComponentCosts = @compileError("'MsiEnumComponentCosts' requires that UNICODE be set to true or false in the root module");
pub const MsiGetFeatureValidStates = @compileError("'MsiGetFeatureValidStates' requires that UNICODE be set to true or false in the root module");
pub const MsiGetSourcePath = @compileError("'MsiGetSourcePath' requires that UNICODE be set to true or false in the root module");
pub const MsiGetTargetPath = @compileError("'MsiGetTargetPath' requires that UNICODE be set to true or false in the root module");
pub const MsiSetTargetPath = @compileError("'MsiSetTargetPath' requires that UNICODE be set to true or false in the root module");
pub const MsiPreviewDialog = @compileError("'MsiPreviewDialog' requires that UNICODE be set to true or false in the root module");
pub const MsiPreviewBillboard = @compileError("'MsiPreviewBillboard' requires that UNICODE be set to true or false in the root module");
pub const CreatePatchFile = @compileError("'CreatePatchFile' requires that UNICODE be set to true or false in the root module");
pub const CreatePatchFileEx = @compileError("'CreatePatchFileEx' requires that UNICODE be set to true or false in the root module");
pub const ExtractPatchHeaderToFile = @compileError("'ExtractPatchHeaderToFile' requires that UNICODE be set to true or false in the root module");
pub const TestApplyPatchToFile = @compileError("'TestApplyPatchToFile' requires that UNICODE be set to true or false in the root module");
pub const ApplyPatchToFile = @compileError("'ApplyPatchToFile' requires that UNICODE be set to true or false in the root module");
pub const ApplyPatchToFileEx = @compileError("'ApplyPatchToFileEx' requires that UNICODE be set to true or false in the root module");
pub const GetFilePatchSignature = @compileError("'GetFilePatchSignature' requires that UNICODE be set to true or false in the root module");
pub const GetDeltaInfo = @compileError("'GetDeltaInfo' requires that UNICODE be set to true or false in the root module");
pub const ApplyDelta = @compileError("'ApplyDelta' requires that UNICODE be set to true or false in the root module");
pub const CreateDelta = @compileError("'CreateDelta' requires that UNICODE be set to true or false in the root module");
pub const GetDeltaSignature = @compileError("'GetDeltaSignature' requires that UNICODE be set to true or false in the root module");
pub const CreateActCtx = @compileError("'CreateActCtx' requires that UNICODE be set to true or false in the root module");
pub const FindActCtxSectionString = @compileError("'FindActCtxSectionString' requires that UNICODE be set to true or false in the root module");
},
};
//--------------------------------------------------------------------------------
// Section: Imports (19)
//--------------------------------------------------------------------------------
const Guid = @import("../zig.zig").Guid;
const ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA = @import("../system/windows_programming.zig").ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA;
const BOOL = @import("../foundation.zig").BOOL;
const BSTR = @import("../foundation.zig").BSTR;
const CERT_CONTEXT = @import("../security/cryptography.zig").CERT_CONTEXT;
const FILETIME = @import("../foundation.zig").FILETIME;
const HANDLE = @import("../foundation.zig").HANDLE;
const HINSTANCE = @import("../foundation.zig").HINSTANCE;
const HKEY = @import("../system/registry.zig").HKEY;
const HRESULT = @import("../foundation.zig").HRESULT;
const HWND = @import("../foundation.zig").HWND;
const IDispatch = @import("../system/com.zig").IDispatch;
const IStream = @import("../system/com.zig").IStream;
const IUnknown = @import("../system/com.zig").IUnknown;
const LARGE_INTEGER = @import("../foundation.zig").LARGE_INTEGER;
const PSTR = @import("../foundation.zig").PSTR;
const PWSTR = @import("../foundation.zig").PWSTR;
const SAFEARRAY = @import("../system/com.zig").SAFEARRAY;
const ULARGE_INTEGER = @import("../foundation.zig").ULARGE_INTEGER;
test {
// The following '_ = <FuncPtrType>' lines are a workaround for https://github.com/ziglang/zig/issues/4476
if (@hasDecl(@This(), "LPDISPLAYVAL")) { _ = LPDISPLAYVAL; }
if (@hasDecl(@This(), "LPEVALCOMCALLBACK")) { _ = LPEVALCOMCALLBACK; }
if (@hasDecl(@This(), "INSTALLUI_HANDLERA")) { _ = INSTALLUI_HANDLERA; }
if (@hasDecl(@This(), "INSTALLUI_HANDLERW")) { _ = INSTALLUI_HANDLERW; }
if (@hasDecl(@This(), "PINSTALLUI_HANDLER_RECORD")) { _ = PINSTALLUI_HANDLER_RECORD; }
if (@hasDecl(@This(), "PPATCH_PROGRESS_CALLBACK")) { _ = PPATCH_PROGRESS_CALLBACK; }
if (@hasDecl(@This(), "PPATCH_SYMLOAD_CALLBACK")) { _ = PPATCH_SYMLOAD_CALLBACK; }
@setEvalBranchQuota(
@import("std").meta.declarations(@This()).len * 3
);
// reference all the pub declarations
if (!@import("builtin").is_test) return;
inline for (@import("std").meta.declarations(@This())) |decl| {
if (decl.is_pub) {
_ = decl;
}
}
}
|
win32/system/application_installation_and_servicing.zig
|
const std = @import("std");
const assert = std.debug.assert;
const allocator = std.heap.page_allocator;
const Computer = @import("./computer.zig").Computer;
pub const Pos = struct {
const OFFSET: usize = 10000;
x: usize,
y: usize,
pub fn init(x: usize, y: usize) Pos {
return Pos{
.x = x,
.y = y,
};
}
pub fn equal(self: Pos, other: Pos) bool {
return self.x == other.x and self.y == other.y;
}
};
pub const Map = struct {
cells: std.AutoHashMap(Pos, Tile),
computer: Computer,
pcur: Pos,
poxy: Pos,
pmin: Pos,
pmax: Pos,
pub const Dir = enum(u8) {
N = 1,
S = 2,
W = 3,
E = 4,
pub fn reverse(d: Dir) Dir {
return switch (d) {
Dir.N => Dir.S,
Dir.S => Dir.N,
Dir.W => Dir.E,
Dir.E => Dir.W,
};
}
pub fn move(p: Pos, d: Dir) Pos {
var q = p;
switch (d) {
Dir.N => q.y -= 1,
Dir.S => q.y += 1,
Dir.W => q.x -= 1,
Dir.E => q.x += 1,
}
return q;
}
};
pub const Status = enum(u8) {
HitWall = 0,
Moved = 1,
MovedToTarget = 2,
};
pub const Tile = enum(u8) {
Empty = 0,
Wall = 1,
Oxygen = 2,
};
pub fn init() Map {
var self = Map{
.cells = std.AutoHashMap(Pos, Tile).init(allocator),
.computer = Computer.init(true),
.poxy = undefined,
.pcur = Pos.init(Pos.OFFSET / 2, Pos.OFFSET / 2),
.pmin = Pos.init(std.math.maxInt(usize), std.math.maxInt(usize)),
.pmax = Pos.init(0, 0),
};
return self;
}
pub fn deinit(self: *Map) void {
self.computer.deinit();
self.cells.deinit();
}
pub fn parse_program(self: *Map, str: []const u8) void {
self.computer.parse(str);
}
pub fn set_pos(self: *Map, pos: Pos, mark: Tile) void {
_ = self.cells.put(pos, mark) catch unreachable;
if (self.pmin.x > pos.x) self.pmin.x = pos.x;
if (self.pmin.y > pos.y) self.pmin.y = pos.y;
if (self.pmax.x < pos.x) self.pmax.x = pos.x;
if (self.pmax.y < pos.y) self.pmax.y = pos.y;
}
pub fn walk_around(self: *Map) void {
std.debug.warn("START droid at {} {}\n", .{ self.pcur.x, self.pcur.y });
self.mark_and_walk(Tile.Empty);
}
fn mark_and_walk(self: *Map, mark: Tile) void {
self.set_pos(self.pcur, mark);
// self.show();
if (mark != Tile.Empty) return;
const pcur = self.pcur;
var j: u8 = 1;
while (j <= 4) : (j += 1) {
const d = @intToEnum(Dir, j);
const r = Dir.reverse(d);
self.pcur = Dir.move(pcur, d);
if (self.cells.contains(self.pcur)) continue;
const status = self.tryMove(d);
switch (status) {
Status.HitWall => {
// std.debug.warn("WALL {} {}\n",.{ self.pcur.x, self.pcur.y});
self.mark_and_walk(Tile.Wall);
},
Status.Moved => {
// std.debug.warn("EMPTY {} {}\n",.{ self.pcur.x, self.pcur.y});
self.mark_and_walk(Tile.Empty);
_ = self.tryMove(r);
},
Status.MovedToTarget => {
std.debug.warn("FOUND oxygen system at {} {}\n", .{ self.pcur.x, self.pcur.y });
self.mark_and_walk(Tile.Empty);
self.poxy = self.pcur;
_ = self.tryMove(r);
},
}
}
self.pcur = pcur;
}
pub fn tryMove(self: *Map, d: Dir) Status {
self.computer.enqueueInput(@enumToInt(d));
self.computer.run();
const output = self.computer.getOutput();
const status = @intToEnum(Status, @intCast(u8, output.?));
return status;
}
const PosDist = struct {
pos: Pos,
dist: usize,
pub fn init(pos: Pos, dist: usize) PosDist {
return PosDist{
.pos = pos,
.dist = dist,
};
}
fn cmp(l: PosDist, r: PosDist) std.math.Order {
if (l.dist < r.dist) return std.math.Order.lt;
if (l.dist > r.dist) return std.math.Order.gt;
if (l.pos.x < r.pos.x) return std.math.Order.lt;
if (l.pos.x > r.pos.x) return std.math.Order.gt;
if (l.pos.y < r.pos.y) return std.math.Order.lt;
if (l.pos.y > r.pos.y) return std.math.Order.gt;
return std.math.Order.eq;
}
};
// Long live the master, <NAME>
// https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
pub fn find_path_to_target(self: *Map) usize {
var Pend = std.AutoHashMap(Pos, void).init(allocator);
defer Pend.deinit();
var Dist = std.AutoHashMap(Pos, usize).init(allocator);
defer Dist.deinit();
var Path = std.AutoHashMap(Pos, Pos).init(allocator);
defer Path.deinit();
// Fill Dist and Pend for all nodes
var y: usize = self.pmin.y;
while (y <= self.pmax.y) : (y += 1) {
var x: usize = self.pmin.x;
while (x <= self.pmax.x) : (x += 1) {
const p = Pos.init(x, y);
_ = Dist.put(p, std.math.maxInt(usize)) catch unreachable;
_ = Pend.put(p, {}) catch unreachable;
}
}
_ = Dist.put(self.pcur, 0) catch unreachable;
while (Pend.count() != 0) {
// Search for a pending node with minimal distance
// TODO: we could use a PriorityQueue here to quickly get at the
// node, but we will also need to update the node's distance later,
// which would mean re-shuffling the PQ; not sure how to do this.
var u: Pos = undefined;
var dmin: usize = std.math.maxInt(usize);
var it = Pend.iterator();
while (it.next()) |v| {
const p = v.key_ptr.*;
if (!Dist.contains(p)) {
continue;
}
const found = Dist.getEntry(p).?;
if (dmin > found.value_ptr.*) {
dmin = found.value_ptr.*;
u = found.key_ptr.*;
}
}
_ = Pend.remove(u);
if (u.equal(self.poxy)) {
// node chosen is our target, we can stop searching now
break;
}
// update dist for all neighbours of u
// add closest neighbour of u to the path
const du = Dist.get(u).?;
var j: u8 = 1;
while (j <= 4) : (j += 1) {
const d = @intToEnum(Dir, j);
var v = Dir.move(u, d);
if (!self.cells.contains(v)) continue;
const tile = self.cells.get(v).?;
if (tile != Tile.Empty) continue;
const dv = Dist.get(v).?;
const alt = du + 1;
if (alt < dv) {
_ = Dist.put(v, alt) catch unreachable;
_ = Path.put(v, u) catch unreachable;
}
}
}
// now count the steps in the path from target to source
var dist: usize = 0;
var n = self.poxy;
while (true) {
if (n.equal(self.pcur)) break;
n = Path.get(n).?;
dist += 1;
}
return dist;
}
// https://en.wikipedia.org/wiki/Flood_fill
// Basically a BFS walk, remembering the distance to the source
pub fn fill_with_oxygen(self: *Map) usize {
var seen = std.AutoHashMap(Pos, void).init(allocator);
defer seen.deinit();
const PQ = std.PriorityQueue(PosDist, PosDist.cmp);
var Pend = PQ.init(allocator);
defer Pend.deinit();
// We start from the oxygen system position, which has already been filled with oxygen
var dmax: usize = 0;
_ = Pend.add(PosDist.init(self.poxy, 0)) catch unreachable;
while (Pend.count() != 0) {
const data = Pend.remove();
if (dmax < data.dist) dmax = data.dist;
_ = self.cells.put(data.pos, Tile.Oxygen) catch unreachable;
// std.debug.warn("MD: {}\n",.{ dmax});
// self.show();
// any neighbours will be filled at the same larger distance
const dist = data.dist + 1;
var j: u8 = 1;
while (j <= 4) : (j += 1) {
const d = @intToEnum(Dir, j);
var v = Dir.move(data.pos, d);
if (!self.cells.contains(v)) continue;
const tile = self.cells.get(v).?;
if (tile != Tile.Empty) continue;
if (seen.contains(v)) continue;
_ = seen.put(v, {}) catch unreachable;
_ = Pend.add(PosDist.init(v, dist)) catch unreachable;
}
}
return dmax;
}
pub fn show(self: Map) void {
const sx = self.pmax.x - self.pmin.x + 1;
const sy = self.pmax.y - self.pmin.y + 1;
std.debug.warn("MAP: {} x {} - {} {} - {} {}\n", .{ sx, sy, self.pmin.x, self.pmin.y, self.pmax.x, self.pmax.y });
var y: usize = self.pmin.y;
while (y <= self.pmax.y) : (y += 1) {
std.debug.warn("{:4} | ", .{y});
var x: usize = self.pmin.x;
while (x <= self.pmax.x) : (x += 1) {
const p = Pos.init(x, y);
const g = self.cells.get(p);
var t: u8 = ' ';
if (g != null) {
switch (g.?.value) {
Tile.Empty => t = '.',
Tile.Wall => t = '#',
Tile.Oxygen => t = 'O',
}
}
if (x == self.pcur.x and y == self.pcur.y) t = 'D';
std.debug.warn("{c}", .{t});
}
std.debug.warn("\n", .{});
}
}
};
test "fill with oxygen" {
var map = Map.init();
defer map.deinit();
const data =
\\ ##
\\#..##
\\#.#..#
\\#.O.#
\\ ###
;
var y: usize = 0;
var itl = std.mem.split(u8, data, "\n");
while (itl.next()) |line| : (y += 1) {
var x: usize = 0;
while (x < line.len) : (x += 1) {
const p = Pos.init(x, y);
var t: Map.Tile = Map.Tile.Empty;
if (line[x] == '#') t = Map.Tile.Wall;
if (line[x] == 'O') {
t = Map.Tile.Oxygen;
map.poxy = p;
}
map.set_pos(p, t);
}
}
const result = map.fill_with_oxygen();
assert(result == 4);
}
|
2019/p15/map.zig
|
const std = @import("std");
const Builder = std.build.Builder;
const path = std.fs.path;
fn addIspcObject(b: *Builder, exe: anytype, in_file: []const u8, target: ?[]const u8, is_release: bool) !void {
// TODO: dependency management. Automatically pick target TODO:
// get cpuid to tell us what target to use instead of just picking
// our lowest common denominator of SSE2
const target_param = try std.mem.concat(b.allocator, u8, &[_][]const u8{
"--target=",
target orelse "sse2-i32x4",
});
const out_file_obj_name = try std.mem.concat(b.allocator, u8, &[_][]const u8{ std.fs.path.basename(in_file), ".obj" });
const out_file = try std.fs.path.join(b.allocator, &[_][]const u8{
b.build_root,
b.cache_root,
out_file_obj_name,
});
const run_cmd = b.addSystemCommand(&[_][]const u8{
"ispc",
in_file,
"-o",
out_file,
"--addressing=64",
target_param,
"-g",
if (is_release) "-O3" else "-O0",
});
exe.step.dependOn(&run_cmd.step);
exe.addObjectFile(out_file);
}
pub fn build(b: *Builder) !void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const 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 = b.addExecutable("ispc-raytracer", "src/main.zig");
exe.setTarget(target);
exe.setBuildMode(mode);
try addIspcObject(b, exe, "src/raytrace.ispc", null, b.is_release);
exe.install();
const run_cmd = exe.run();
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
var main_tests = b.addTest("src/main.zig");
main_tests.setBuildMode(mode);
const test_step = b.step("test", "Run app tests");
test_step.dependOn(&main_tests.step);
}
|
build.zig
|
const std = @import("../../../std.zig");
const linux = std.os.linux;
const socklen_t = linux.socklen_t;
const iovec = linux.iovec;
const iovec_const = linux.iovec_const;
const stack_t = linux.stack_t;
const sigset_t = linux.sigset_t;
const uid_t = linux.uid_t;
const gid_t = linux.gid_t;
pub const SYS_restart_syscall = 0;
pub const SYS_exit = 1;
pub const SYS_fork = 2;
pub const SYS_read = 3;
pub const SYS_write = 4;
pub const SYS_open = 5;
pub const SYS_close = 6;
pub const SYS_creat = 8;
pub const SYS_link = 9;
pub const SYS_unlink = 10;
pub const SYS_execve = 11;
pub const SYS_chdir = 12;
pub const SYS_mknod = 14;
pub const SYS_chmod = 15;
pub const SYS_lchown = 16;
pub const SYS_lseek = 19;
pub const SYS_getpid = 20;
pub const SYS_mount = 21;
pub const SYS_setuid = 23;
pub const SYS_getuid = 24;
pub const SYS_ptrace = 26;
pub const SYS_pause = 29;
pub const SYS_access = 33;
pub const SYS_nice = 34;
pub const SYS_sync = 36;
pub const SYS_kill = 37;
pub const SYS_rename = 38;
pub const SYS_mkdir = 39;
pub const SYS_rmdir = 40;
pub const SYS_dup = 41;
pub const SYS_pipe = 42;
pub const SYS_times = 43;
pub const SYS_brk = 45;
pub const SYS_setgid = 46;
pub const SYS_getgid = 47;
pub const SYS_geteuid = 49;
pub const SYS_getegid = 50;
pub const SYS_acct = 51;
pub const SYS_umount2 = 52;
pub const SYS_ioctl = 54;
pub const SYS_fcntl = 55;
pub const SYS_setpgid = 57;
pub const SYS_umask = 60;
pub const SYS_chroot = 61;
pub const SYS_ustat = 62;
pub const SYS_dup2 = 63;
pub const SYS_getppid = 64;
pub const SYS_getpgrp = 65;
pub const SYS_setsid = 66;
pub const SYS_sigaction = 67;
pub const SYS_setreuid = 70;
pub const SYS_setregid = 71;
pub const SYS_sigsuspend = 72;
pub const SYS_sigpending = 73;
pub const SYS_sethostname = 74;
pub const SYS_setrlimit = 75;
pub const SYS_getrusage = 77;
pub const SYS_gettimeofday = 78;
pub const SYS_settimeofday = 79;
pub const SYS_getgroups = 80;
pub const SYS_setgroups = 81;
pub const SYS_symlink = 83;
pub const SYS_readlink = 85;
pub const SYS_uselib = 86;
pub const SYS_swapon = 87;
pub const SYS_reboot = 88;
pub const SYS_munmap = 91;
pub const SYS_truncate = 92;
pub const SYS_ftruncate = 93;
pub const SYS_fchmod = 94;
pub const SYS_fchown = 95;
pub const SYS_getpriority = 96;
pub const SYS_setpriority = 97;
pub const SYS_statfs = 99;
pub const SYS_fstatfs = 100;
pub const SYS_syslog = 103;
pub const SYS_setitimer = 104;
pub const SYS_getitimer = 105;
pub const SYS_stat = 106;
pub const SYS_lstat = 107;
pub const SYS_fstat = 108;
pub const SYS_vhangup = 111;
pub const SYS_wait4 = 114;
pub const SYS_swapoff = 115;
pub const SYS_sysinfo = 116;
pub const SYS_fsync = 118;
pub const SYS_sigreturn = 119;
pub const SYS_clone = 120;
pub const SYS_setdomainname = 121;
pub const SYS_uname = 122;
pub const SYS_adjtimex = 124;
pub const SYS_mprotect = 125;
pub const SYS_sigprocmask = 126;
pub const SYS_init_module = 128;
pub const SYS_delete_module = 129;
pub const SYS_quotactl = 131;
pub const SYS_getpgid = 132;
pub const SYS_fchdir = 133;
pub const SYS_bdflush = 134;
pub const SYS_sysfs = 135;
pub const SYS_personality = 136;
pub const SYS_setfsuid = 138;
pub const SYS_setfsgid = 139;
pub const SYS__llseek = 140;
pub const SYS_getdents = 141;
pub const SYS__newselect = 142;
pub const SYS_flock = 143;
pub const SYS_msync = 144;
pub const SYS_readv = 145;
pub const SYS_writev = 146;
pub const SYS_getsid = 147;
pub const SYS_fdatasync = 148;
pub const SYS__sysctl = 149;
pub const SYS_mlock = 150;
pub const SYS_munlock = 151;
pub const SYS_mlockall = 152;
pub const SYS_munlockall = 153;
pub const SYS_sched_setparam = 154;
pub const SYS_sched_getparam = 155;
pub const SYS_sched_setscheduler = 156;
pub const SYS_sched_getscheduler = 157;
pub const SYS_sched_yield = 158;
pub const SYS_sched_get_priority_max = 159;
pub const SYS_sched_get_priority_min = 160;
pub const SYS_sched_rr_get_interval = 161;
pub const SYS_nanosleep = 162;
pub const SYS_mremap = 163;
pub const SYS_setresuid = 164;
pub const SYS_getresuid = 165;
pub const SYS_poll = 168;
pub const SYS_nfsservctl = 169;
pub const SYS_setresgid = 170;
pub const SYS_getresgid = 171;
pub const SYS_prctl = 172;
pub const SYS_rt_sigreturn = 173;
pub const SYS_rt_sigaction = 174;
pub const SYS_rt_sigprocmask = 175;
pub const SYS_rt_sigpending = 176;
pub const SYS_rt_sigtimedwait = 177;
pub const SYS_rt_sigqueueinfo = 178;
pub const SYS_rt_sigsuspend = 179;
pub const SYS_pread64 = 180;
pub const SYS_pwrite64 = 181;
pub const SYS_chown = 182;
pub const SYS_getcwd = 183;
pub const SYS_capget = 184;
pub const SYS_capset = 185;
pub const SYS_sigaltstack = 186;
pub const SYS_sendfile = 187;
pub const SYS_vfork = 190;
pub const SYS_ugetrlimit = 191;
pub const SYS_mmap2 = 192;
pub const SYS_truncate64 = 193;
pub const SYS_ftruncate64 = 194;
pub const SYS_stat64 = 195;
pub const SYS_lstat64 = 196;
pub const SYS_fstat64 = 197;
pub const SYS_lchown32 = 198;
pub const SYS_getuid32 = 199;
pub const SYS_getgid32 = 200;
pub const SYS_geteuid32 = 201;
pub const SYS_getegid32 = 202;
pub const SYS_setreuid32 = 203;
pub const SYS_setregid32 = 204;
pub const SYS_getgroups32 = 205;
pub const SYS_setgroups32 = 206;
pub const SYS_fchown32 = 207;
pub const SYS_setresuid32 = 208;
pub const SYS_getresuid32 = 209;
pub const SYS_setresgid32 = 210;
pub const SYS_getresgid32 = 211;
pub const SYS_chown32 = 212;
pub const SYS_setuid32 = 213;
pub const SYS_setgid32 = 214;
pub const SYS_setfsuid32 = 215;
pub const SYS_setfsgid32 = 216;
pub const SYS_getdents64 = 217;
pub const SYS_pivot_root = 218;
pub const SYS_mincore = 219;
pub const SYS_madvise = 220;
pub const SYS_fcntl64 = 221;
pub const SYS_gettid = 224;
pub const SYS_readahead = 225;
pub const SYS_setxattr = 226;
pub const SYS_lsetxattr = 227;
pub const SYS_fsetxattr = 228;
pub const SYS_getxattr = 229;
pub const SYS_lgetxattr = 230;
pub const SYS_fgetxattr = 231;
pub const SYS_listxattr = 232;
pub const SYS_llistxattr = 233;
pub const SYS_flistxattr = 234;
pub const SYS_removexattr = 235;
pub const SYS_lremovexattr = 236;
pub const SYS_fremovexattr = 237;
pub const SYS_tkill = 238;
pub const SYS_sendfile64 = 239;
pub const SYS_futex = 240;
pub const SYS_sched_setaffinity = 241;
pub const SYS_sched_getaffinity = 242;
pub const SYS_io_setup = 243;
pub const SYS_io_destroy = 244;
pub const SYS_io_getevents = 245;
pub const SYS_io_submit = 246;
pub const SYS_io_cancel = 247;
pub const SYS_exit_group = 248;
pub const SYS_lookup_dcookie = 249;
pub const SYS_epoll_create = 250;
pub const SYS_epoll_ctl = 251;
pub const SYS_epoll_wait = 252;
pub const SYS_remap_file_pages = 253;
pub const SYS_set_tid_address = 256;
pub const SYS_timer_create = 257;
pub const SYS_timer_settime = 258;
pub const SYS_timer_gettime = 259;
pub const SYS_timer_getoverrun = 260;
pub const SYS_timer_delete = 261;
pub const SYS_clock_settime = 262;
pub const SYS_clock_gettime = 263;
pub const SYS_clock_getres = 264;
pub const SYS_clock_nanosleep = 265;
pub const SYS_statfs64 = 266;
pub const SYS_fstatfs64 = 267;
pub const SYS_tgkill = 268;
pub const SYS_utimes = 269;
pub const SYS_fadvise64_64 = 270;
pub const SYS_arm_fadvise64_64 = 270;
pub const SYS_pciconfig_iobase = 271;
pub const SYS_pciconfig_read = 272;
pub const SYS_pciconfig_write = 273;
pub const SYS_mq_open = 274;
pub const SYS_mq_unlink = 275;
pub const SYS_mq_timedsend = 276;
pub const SYS_mq_timedreceive = 277;
pub const SYS_mq_notify = 278;
pub const SYS_mq_getsetattr = 279;
pub const SYS_waitid = 280;
pub const SYS_socket = 281;
pub const SYS_bind = 282;
pub const SYS_connect = 283;
pub const SYS_listen = 284;
pub const SYS_accept = 285;
pub const SYS_getsockname = 286;
pub const SYS_getpeername = 287;
pub const SYS_socketpair = 288;
pub const SYS_send = 289;
pub const SYS_sendto = 290;
pub const SYS_recv = 291;
pub const SYS_recvfrom = 292;
pub const SYS_shutdown = 293;
pub const SYS_setsockopt = 294;
pub const SYS_getsockopt = 295;
pub const SYS_sendmsg = 296;
pub const SYS_recvmsg = 297;
pub const SYS_semop = 298;
pub const SYS_semget = 299;
pub const SYS_semctl = 300;
pub const SYS_msgsnd = 301;
pub const SYS_msgrcv = 302;
pub const SYS_msgget = 303;
pub const SYS_msgctl = 304;
pub const SYS_shmat = 305;
pub const SYS_shmdt = 306;
pub const SYS_shmget = 307;
pub const SYS_shmctl = 308;
pub const SYS_add_key = 309;
pub const SYS_request_key = 310;
pub const SYS_keyctl = 311;
pub const SYS_semtimedop = 312;
pub const SYS_vserver = 313;
pub const SYS_ioprio_set = 314;
pub const SYS_ioprio_get = 315;
pub const SYS_inotify_init = 316;
pub const SYS_inotify_add_watch = 317;
pub const SYS_inotify_rm_watch = 318;
pub const SYS_mbind = 319;
pub const SYS_get_mempolicy = 320;
pub const SYS_set_mempolicy = 321;
pub const SYS_openat = 322;
pub const SYS_mkdirat = 323;
pub const SYS_mknodat = 324;
pub const SYS_fchownat = 325;
pub const SYS_futimesat = 326;
pub const SYS_fstatat64 = 327;
pub const SYS_unlinkat = 328;
pub const SYS_renameat = 329;
pub const SYS_linkat = 330;
pub const SYS_symlinkat = 331;
pub const SYS_readlinkat = 332;
pub const SYS_fchmodat = 333;
pub const SYS_faccessat = 334;
pub const SYS_pselect6 = 335;
pub const SYS_ppoll = 336;
pub const SYS_unshare = 337;
pub const SYS_set_robust_list = 338;
pub const SYS_get_robust_list = 339;
pub const SYS_splice = 340;
pub const SYS_sync_file_range2 = 341;
pub const SYS_arm_sync_file_range = 341;
pub const SYS_tee = 342;
pub const SYS_vmsplice = 343;
pub const SYS_move_pages = 344;
pub const SYS_getcpu = 345;
pub const SYS_epoll_pwait = 346;
pub const SYS_kexec_load = 347;
pub const SYS_utimensat = 348;
pub const SYS_signalfd = 349;
pub const SYS_timerfd_create = 350;
pub const SYS_eventfd = 351;
pub const SYS_fallocate = 352;
pub const SYS_timerfd_settime = 353;
pub const SYS_timerfd_gettime = 354;
pub const SYS_signalfd4 = 355;
pub const SYS_eventfd2 = 356;
pub const SYS_epoll_create1 = 357;
pub const SYS_dup3 = 358;
pub const SYS_pipe2 = 359;
pub const SYS_inotify_init1 = 360;
pub const SYS_preadv = 361;
pub const SYS_pwritev = 362;
pub const SYS_rt_tgsigqueueinfo = 363;
pub const SYS_perf_event_open = 364;
pub const SYS_recvmmsg = 365;
pub const SYS_accept4 = 366;
pub const SYS_fanotify_init = 367;
pub const SYS_fanotify_mark = 368;
pub const SYS_prlimit64 = 369;
pub const SYS_name_to_handle_at = 370;
pub const SYS_open_by_handle_at = 371;
pub const SYS_clock_adjtime = 372;
pub const SYS_syncfs = 373;
pub const SYS_sendmmsg = 374;
pub const SYS_setns = 375;
pub const SYS_process_vm_readv = 376;
pub const SYS_process_vm_writev = 377;
pub const SYS_kcmp = 378;
pub const SYS_finit_module = 379;
pub const SYS_sched_setattr = 380;
pub const SYS_sched_getattr = 381;
pub const SYS_renameat2 = 382;
pub const SYS_seccomp = 383;
pub const SYS_getrandom = 384;
pub const SYS_memfd_create = 385;
pub const SYS_bpf = 386;
pub const SYS_execveat = 387;
pub const SYS_userfaultfd = 388;
pub const SYS_membarrier = 389;
pub const SYS_mlock2 = 390;
pub const SYS_copy_file_range = 391;
pub const SYS_preadv2 = 392;
pub const SYS_pwritev2 = 393;
pub const SYS_pkey_mprotect = 394;
pub const SYS_pkey_alloc = 395;
pub const SYS_pkey_free = 396;
pub const SYS_statx = 397;
pub const SYS_rseq = 398;
pub const SYS_io_pgetevents = 399;
pub const SYS_migrate_pages = 400;
pub const SYS_kexec_file_load = 401;
pub const SYS_clock_gettime64 = 403;
pub const SYS_clock_settime64 = 404;
pub const SYS_clock_adjtime64 = 405;
pub const SYS_clock_getres_time64 = 406;
pub const SYS_clock_nanosleep_time64 = 407;
pub const SYS_timer_gettime64 = 408;
pub const SYS_timer_settime64 = 409;
pub const SYS_timerfd_gettime64 = 410;
pub const SYS_timerfd_settime64 = 411;
pub const SYS_utimensat_time64 = 412;
pub const SYS_pselect6_time64 = 413;
pub const SYS_ppoll_time64 = 414;
pub const SYS_io_pgetevents_time64 = 416;
pub const SYS_recvmmsg_time64 = 417;
pub const SYS_mq_timedsend_time64 = 418;
pub const SYS_mq_timedreceive_time64 = 419;
pub const SYS_semtimedop_time64 = 420;
pub const SYS_rt_sigtimedwait_time64 = 421;
pub const SYS_futex_time64 = 422;
pub const SYS_sched_rr_get_interval_time64 = 423;
pub const SYS_pidfd_send_signal = 424;
pub const SYS_io_uring_setup = 425;
pub const SYS_io_uring_enter = 426;
pub const SYS_io_uring_register = 427;
pub const SYS_open_tree = 428;
pub const SYS_move_mount = 429;
pub const SYS_fsopen = 430;
pub const SYS_fsconfig = 431;
pub const SYS_fsmount = 432;
pub const SYS_fspick = 433;
pub const SYS_pidfd_open = 434;
pub const SYS_clone3 = 435;
pub const SYS_breakpoint = 0x0f0001;
pub const SYS_cacheflush = 0x0f0002;
pub const SYS_usr26 = 0x0f0003;
pub const SYS_usr32 = 0x0f0004;
pub const SYS_set_tls = 0x0f0005;
pub const SYS_get_tls = 0x0f0006;
pub const MMAP2_UNIT = 4096;
pub const O_CREAT = 0o100;
pub const O_EXCL = 0o200;
pub const O_NOCTTY = 0o400;
pub const O_TRUNC = 0o1000;
pub const O_APPEND = 0o2000;
pub const O_NONBLOCK = 0o4000;
pub const O_DSYNC = 0o10000;
pub const O_SYNC = 0o4010000;
pub const O_RSYNC = 0o4010000;
pub const O_DIRECTORY = 0o40000;
pub const O_NOFOLLOW = 0o100000;
pub const O_CLOEXEC = 0o2000000;
pub const O_ASYNC = 0o20000;
pub const O_DIRECT = 0o200000;
pub const O_LARGEFILE = 0o400000;
pub const O_NOATIME = 0o1000000;
pub const O_PATH = 0o10000000;
pub const O_TMPFILE = 0o20040000;
pub const O_NDELAY = O_NONBLOCK;
pub const F_DUPFD = 0;
pub const F_GETFD = 1;
pub const F_SETFD = 2;
pub const F_GETFL = 3;
pub const F_SETFL = 4;
pub const F_SETOWN = 8;
pub const F_GETOWN = 9;
pub const F_SETSIG = 10;
pub const F_GETSIG = 11;
pub const F_GETLK = 12;
pub const F_SETLK = 13;
pub const F_SETLKW = 14;
pub const F_SETOWN_EX = 15;
pub const F_GETOWN_EX = 16;
pub const F_GETOWNER_UIDS = 17;
/// stack-like segment
pub const MAP_GROWSDOWN = 0x0100;
/// ETXTBSY
pub const MAP_DENYWRITE = 0x0800;
/// mark it as an executable
pub const MAP_EXECUTABLE = 0x1000;
/// pages are locked
pub const MAP_LOCKED = 0x2000;
/// don't check for reservations
pub const MAP_NORESERVE = 0x4000;
pub const VDSO_CGT_SYM = "__vdso_clock_gettime";
pub const VDSO_CGT_VER = "LINUX_2.6";
pub const HWCAP_SWP = 1 << 0;
pub const HWCAP_HALF = 1 << 1;
pub const HWCAP_THUMB = 1 << 2;
pub const HWCAP_26BIT = 1 << 3;
pub const HWCAP_FAST_MULT = 1 << 4;
pub const HWCAP_FPA = 1 << 5;
pub const HWCAP_VFP = 1 << 6;
pub const HWCAP_EDSP = 1 << 7;
pub const HWCAP_JAVA = 1 << 8;
pub const HWCAP_IWMMXT = 1 << 9;
pub const HWCAP_CRUNCH = 1 << 10;
pub const HWCAP_THUMBEE = 1 << 11;
pub const HWCAP_NEON = 1 << 12;
pub const HWCAP_VFPv3 = 1 << 13;
pub const HWCAP_VFPv3D16 = 1 << 14;
pub const HWCAP_TLS = 1 << 15;
pub const HWCAP_VFPv4 = 1 << 16;
pub const HWCAP_IDIVA = 1 << 17;
pub const HWCAP_IDIVT = 1 << 18;
pub const HWCAP_VFPD32 = 1 << 19;
pub const HWCAP_IDIV = HWCAP_IDIVA | HWCAP_IDIVT;
pub const HWCAP_LPAE = 1 << 20;
pub const HWCAP_EVTSTRM = 1 << 21;
pub const msghdr = extern struct {
msg_name: ?*sockaddr,
msg_namelen: socklen_t,
msg_iov: [*]iovec,
msg_iovlen: i32,
msg_control: ?*c_void,
msg_controllen: socklen_t,
msg_flags: i32,
};
pub const msghdr_const = extern struct {
msg_name: ?*const sockaddr,
msg_namelen: socklen_t,
msg_iov: [*]iovec_const,
msg_iovlen: i32,
msg_control: ?*c_void,
msg_controllen: socklen_t,
msg_flags: i32,
};
pub const blksize_t = i32;
pub const nlink_t = u32;
pub const time_t = isize;
pub const mode_t = u32;
pub const off_t = i64;
pub const ino_t = u64;
pub const dev_t = u64;
pub const blkcnt_t = i64;
/// Renamed to Stat to not conflict with the stat function.
/// atime, mtime, and ctime have functions to return `timespec`,
/// because although this is a POSIX API, the layout and names of
/// the structs are inconsistent across operating systems, and
/// in C, macros are used to hide the differences. Here we use
/// methods to accomplish this.
pub const Stat = extern struct {
dev: dev_t,
__dev_padding: u32,
__ino_truncated: u32,
mode: mode_t,
nlink: nlink_t,
uid: uid_t,
gid: gid_t,
rdev: dev_t,
__rdev_padding: u32,
size: off_t,
blksize: blksize_t,
blocks: blkcnt_t,
atim: timespec,
mtim: timespec,
ctim: timespec,
ino: ino_t,
pub fn atime(self: Stat) timespec {
return self.atim;
}
pub fn mtime(self: Stat) timespec {
return self.mtim;
}
pub fn ctime(self: Stat) timespec {
return self.ctim;
}
};
pub const timespec = extern struct {
tv_sec: i32,
tv_nsec: i32,
};
pub const timeval = extern struct {
tv_sec: i32,
tv_usec: i32,
};
pub const timezone = extern struct {
tz_minuteswest: i32,
tz_dsttime: i32,
};
pub const mcontext_t = extern struct {
trap_no: usize,
error_code: usize,
oldmask: usize,
arm_r0: usize,
arm_r1: usize,
arm_r2: usize,
arm_r3: usize,
arm_r4: usize,
arm_r5: usize,
arm_r6: usize,
arm_r7: usize,
arm_r8: usize,
arm_r9: usize,
arm_r10: usize,
arm_fp: usize,
arm_ip: usize,
arm_sp: usize,
arm_lr: usize,
arm_pc: usize,
arm_cpsr: usize,
fault_address: usize,
};
pub const ucontext_t = extern struct {
flags: usize,
link: *ucontext_t,
stack: stack_t,
mcontext: mcontext_t,
sigmask: sigset_t,
regspace: [64]u64,
};
pub const Elf_Symndx = u32;
|
lib/std/os/bits/linux/arm-eabi.zig
|
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const audio_graph = @import("audio_graph.zig");
const wav = @import("wav.zig");
//;
pub const generators = struct {
// TODO test this
// more generators, sine, tri, square, noise
// generates one period of a sine to the output slice
pub fn genSine(out: []f32) void {
const step = std.math.tau / @intToFloat(f32, out);
var i: usize = 0;
while (i < out.len) : (i += 1) {
out[i] = std.math.sine(i * step);
}
}
};
//;
// TODO frame_ct ?
pub const SampleBuffer = struct {
const Self = @This();
// TODO arraylist?
data: ArrayList(f32),
sample_rate: u32,
channel_ct: u8,
frame_ct: u32,
// TODO have this?
pub fn init(
allocator: *Allocator,
sample_rate: u32,
channel_ct: u8,
) Self {
return .{
.data = ArrayList(f32).init(allocator),
.sample_rate = sample_rate,
.channel_ct = channel_ct,
.frame_ct = 0,
};
}
pub fn initBuffer(
allocator: *Allocator,
sample_rate: u32,
channel_ct: u8,
buf: []f32,
) Self {
return .{
.data = ArrayList(f32).fromOwnedSlice(allocator, buf),
.sample_rate = sample_rate,
.channel_ct = channel_ct,
.frame_ct = buf.len / channel_ct,
};
}
// TODO take workspace alloc
pub fn initWav(allocator: *Allocator, wav_file: []const u8) !Self {
var reader = std.io.fixedBufferStream(wav_file).reader();
const Loader = wav.Loader(@TypeOf(reader), true);
const header = try Loader.readHeader(&reader);
// TODO
// if channel ct is not 1 or 2, error
// if sample rate not supported
var data = try allocator.alloc(f32, header.channel_ct * header.frame_ct);
errdefer allocator.free(data);
try Loader.loadConvert_F32(&reader, header, data, allocator);
return Self{
.data = ArrayList(f32).fromOwnedSlice(allocator, data),
.sample_rate = header.sample_rate,
.channel_ct = @intCast(u8, header.channel_ct),
.frame_ct = header.frame_ct,
};
}
pub fn deinit(self: *Self) void {
self.data.deinit();
}
};
// tests ==
test "load file" {
const file = @embedFile("../content/square.wav");
var sb = try SampleBuffer.initWav(std.testing.allocator, file);
defer sb.deinit();
}
|
src/sample_buffer.zig
|
const std = @import("std");
const math = std.math;
const testing = std.testing;
/// A 2-dimensional vector, representing the quantity x*e1 + y*e2.
pub const Vec2 = extern struct {
x: f32,
y: f32,
/// (0,0)
pub const Zero = init(0, 0);
/// (1,0)
pub const X = init(1, 0);
/// (0,1)
pub const Y = init(0, 1);
/// Creates a vector with the given values
pub fn init(x: f32, y: f32) Vec2 {
return Vec2{
.x = x,
.y = y,
};
}
/// Creates a vector with each component set to the given value
pub fn splat(val: f32) Vec2 {
return Vec2{
.x = val,
.y = val,
};
}
/// Adds the like components of the inputs
pub fn add(self: Vec2, other: Vec2) Vec2 {
return Vec2{
.x = self.x + other.x,
.y = self.y + other.y,
};
}
/// Subtracts the like components of the inputs
pub fn sub(self: Vec2, other: Vec2) Vec2 {
return Vec2{
.x = self.x - other.x,
.y = self.y - other.y,
};
}
/// Returns the vector from self to other.
/// Equivalent to other.sub(self);.
pub fn diff(self: Vec2, other: Vec2) Vec2 {
return other.sub(self);
}
/// Negates each component
pub fn negate(self: Vec2) Vec2 {
return Vec2{
.x = -self.x,
.y = -self.y,
};
}
/// Multiply each component by a constant
pub fn scale(self: Vec2, multiple: f32) Vec2 {
return Vec2{
.x = self.x * multiple,
.y = self.y * multiple,
};
}
/// Component-wise multiply two vectors
pub fn mul(self: Vec2, mult: Vec2) Vec2 {
return Vec2{
.x = self.x * mult.x,
.y = self.y * mult.y,
};
}
/// Scale the vector to length 1.
/// If the vector is too close to zero, this returns error.Singular.
pub fn normalize(self: Vec2) !Vec2 {
const mult = 1.0 / self.len();
if (!math.isFinite(mult)) return error.Singular;
return self.scale(mult);
}
/// Adds the x and y components of the vector
pub fn sum(self: Vec2) f32 {
return self.x + self.y;
}
/// Interpolates alpha percent between self and target.
/// If alpha is < 0 or > 1, will extrapolate.
pub fn lerp(self: Vec2, target: Vec2, alpha: f32) Vec2 {
return Vec2{
.x = self.x + (target.x - self.x) * alpha,
.y = self.y + (target.y - self.y) * alpha,
};
}
/// Returns the square of the length of the vector.
/// Slightly faster than calculating the length.
pub fn lenSquared(self: Vec2) f32 {
return self.x * self.x + self.y * self.y;
}
/// Computes the length of the vector
pub fn len(self: Vec2) f32 {
return math.sqrt(self.lenSquared());
}
/// Computes the dot product of two vectors
pub fn dot(self: Vec2, other: Vec2) f32 {
return self.x * other.x + self.y * other.y;
}
/// Computes the wedge product of two vectors.
/// (A.K.A. the 2D cross product)
pub fn wedge(self: Vec2, other: Vec2) f32 {
return self.x * other.y - self.y * other.x;
}
/// Computes the projection of self along other.
/// If other is near zero, returns error.Singular.
pub fn along(self: Vec2, other: Vec2) !Vec2 {
const mult = self.dot(other) / other.lenSquared();
if (!math.isFinite(mult)) return error.Singular;
return other.scale(mult);
}
/// Computes the projection of self across other.
/// Equivalent to the projection of self along other.left().
/// This is sometimes referred to as the rejection.
/// If other is near zero, returns error.Singular.
pub fn across(self: Vec2, other: Vec2) !Vec2 {
const mult = self.wedge(other) / other.lenSquared();
if (!math.isFinite(mult)) return error.Singular;
return other.scale(mult);
}
/// Reflects self across axis. If axis is near zero,
/// will return error.Singular.
pub fn reflect(self: Vec2, axis: Vec2) !Vec2 {
const invAxisLenSquared = 1.0 / axis.lenSquared();
if (!math.isFinite(invAxisLenSquared)) return error.Singular;
const alongMult = self.dot(axis);
const acrossMult = self.wedge(axis);
const vector = axis.scale(alongMult).sub(axis.left().scale(acrossMult));
return vector.scale(invAxisLenSquared);
}
/// Finds x and y such that x * xVec + y * yVec == self.
/// If xVec ^ yVec is close to zero, returns error.Singular.
pub fn changeBasis(self: Vec2, xVec: Vec2, yVec: Vec2) !Vec2 {
const mult = 1.0 / xVec.wedge(yVec);
if (!math.isFinite(mult)) return error.Singular;
const x = self.wedge(yVec) * mult;
const y = xVec.wedge(self) * mult;
return init(x, y);
}
/// Computes the vector rotated 90 degrees counterclockwise.
/// This is the vector pointing out of the left side of this vector,
/// with the same length as this vector.
pub fn left(self: Vec2) Vec2 {
return Vec2{
.x = -self.y,
.y = self.x,
};
}
/// Computes the vector rotated 90 degrees clockwise.
/// This is the vector pointing out of the right side of this vector,
/// with the same length as this vector.
pub fn right(self: Vec2) Vec2 {
return Vec2{
.x = self.y,
.y = -self.x,
};
}
/// Returns a pointer to the vector's data as a fixed-size buffer.
pub fn asBuf(self: *Vec2) *[2]f32 {
return @ptrCast(*[2]f32, self);
}
/// Returns a pointer to the vector's data as a const fixed-size buffer.
pub fn asConstBuf(self: *const Vec2) *const [2]f32 {
return @ptrCast(*const [2]f32, self);
}
/// Returns a slice of the vector's data.
pub fn asSlice(self: *Vec2) []f32 {
return self.asBuf()[0..];
}
/// Returns a const slice of the vector's data.
pub fn asConstSlice(self: *const Vec2) []const f32 {
return self.asConstBuf()[0..];
}
/// Appends a z value to make a Vec3
pub fn toVec3(self: Vec2, z: f32) Vec3 {
return Vec3.init(self.x, self.y, z);
}
/// Appends z and w values to make a Vec4
pub fn toVec4(self: Vec2, z: f32, w: f32) Vec4 {
return Vec4.init(self.x, self.y, z, w);
}
/// Concatenates two Vec2s into a Vec4
pub fn pack4(xy: Vec2, zw: Vec2) Vec4 {
return Vec4.init(xy.x, xy.y, zw.x, zw.y);
}
pub fn expectNear(expected: Vec2, actual: Vec2, epsilon: f32) void {
if (!math.approxEq(f32, expected.x, actual.x, epsilon) or
!math.approxEq(f32, expected.y, actual.y, epsilon))
{
std.debug.panic("Expected Vec2({}, {}), found Vec2({}, {})", .{
expected.x,
expected.y,
actual.x,
actual.y,
});
}
}
};
/// A 3-dimensional vector, representing the quantity x*e1 + y*e2 + z*e3.
pub const Vec3 = extern struct {
x: f32,
y: f32,
z: f32,
/// (0,0,0)
pub const Zero = init(0, 0, 0);
/// (1,0,0)
pub const X = init(1, 0, 0);
/// (0,1,0)
pub const Y = init(0, 1, 0);
/// (0,0,1)
pub const Z = init(0, 0, 1);
/// Creates a vector with the given values
pub fn init(x: f32, y: f32, z: f32) Vec3 {
return Vec3{
.x = x,
.y = y,
.z = z,
};
}
/// Creates a vector with each component set to the given value
pub fn splat(val: f32) Vec3 {
return Vec3{
.x = val,
.y = val,
.z = val,
};
}
/// Adds the like components of the inputs
pub fn add(self: Vec3, other: Vec3) Vec3 {
return Vec3{
.x = self.x + other.x,
.y = self.y + other.y,
.z = self.z + other.z,
};
}
/// Subtracts the like components of the inputs
pub fn sub(self: Vec3, other: Vec3) Vec3 {
return Vec3{
.x = self.x - other.x,
.y = self.y - other.y,
.z = self.z - other.z,
};
}
/// Returns the vector from self to other.
/// Equivalent to other.sub(self);.
pub fn diff(self: Vec3, other: Vec3) Vec3 {
return other.sub(self);
}
/// Negates each component
pub fn negate(self: Vec3) Vec3 {
return Vec3{
.x = -self.x,
.y = -self.y,
.z = -self.z,
};
}
/// Multiply each component by a constant
pub fn scale(self: Vec3, multiple: f32) Vec3 {
return Vec3{
.x = self.x * multiple,
.y = self.y * multiple,
.z = self.z * multiple,
};
}
/// Component-wise multiply two vectors
pub fn mul(self: Vec3, mult: Vec3) Vec3 {
return Vec3{
.x = self.x * mult.x,
.y = self.y * mult.y,
.z = self.z * mult.z,
};
}
/// Scale the vector to length 1.
/// If the vector is too close to zero, this returns error.Singular.
pub fn normalize(self: Vec3) !Vec3 {
const mult = 1.0 / self.len();
if (!math.isFinite(mult)) return error.Singular;
return self.scale(mult);
}
/// Adds the x, y, and z components of the vector
pub fn sum(self: Vec3) f32 {
return self.x + self.y + self.z;
}
/// Interpolates alpha percent between self and target.
/// If alpha is < 0 or > 1, will extrapolate.
pub fn lerp(self: Vec3, target: Vec3, alpha: f32) Vec3 {
return Vec3{
.x = self.x + (target.x - self.x) * alpha,
.y = self.y + (target.y - self.y) * alpha,
.z = self.z + (target.z - self.z) * alpha,
};
}
/// Returns the square of the length of the vector.
/// Slightly faster than calculating the length.
pub fn lenSquared(self: Vec3) f32 {
return self.x * self.x + self.y * self.y + self.z * self.z;
}
/// Computes the length of the vector
pub fn len(self: Vec3) f32 {
return math.sqrt(self.lenSquared());
}
/// Computes the dot product of two vectors
pub fn dot(self: Vec3, other: Vec3) f32 {
return self.x * other.x + self.y * other.y + self.z * other.z;
}
/// Computes the wedge product of two vectors
pub fn wedge(self: Vec3, other: Vec3) BiVec3 {
return BiVec3{
.xy = self.x * other.y - self.y * other.x,
.yz = self.y * other.z - self.z * other.y,
.zx = self.z * other.x - self.x * other.z,
};
}
/// Computes the cross product of two vectors
pub fn cross(self: Vec3, other: Vec3) Vec3 {
return Vec3{
.x = self.y * other.z - self.z * other.y,
.y = self.z * other.x - self.x * other.z,
.z = self.x * other.y - self.y * other.x,
};
}
/// Computes the projection of self along other.
/// If other is near zero, returns error.Singular.
pub fn along(self: Vec3, other: Vec3) !Vec3 {
const mult = self.dot(other) / other.lenSquared();
if (!math.isFinite(mult)) return error.Singular;
return if (math.isFinite(mult)) other.scale(mult) else Zero;
}
/// Computes the rejection of self along other.
/// If other is near zero, returns error.Singular.
pub fn across(self: Vec3, other: Vec3) !Vec3 {
return self.sub(try self.along(other));
}
/// Returns a vector that is orthogonal to this vector
pub fn orthogonal(v: Vec3) Vec3 {
const x = math.fabs(v.x);
const y = math.fabs(v.y);
const z = math.fabs(v.z);
const other = if (x < y) if (x < z) X else Z else if (y < z) Y else Z;
return v.cross(other);
}
/// Returns a pointer to the vector's data as a fixed-size buffer.
pub fn asBuf(self: *Vec3) *[3]f32 {
return @ptrCast(*[3]f32, self);
}
/// Returns a pointer to the vector's data as a const fixed-size buffer.
pub fn asConstBuf(self: *const Vec3) *const [3]f32 {
return @ptrCast(*const [3]f32, self);
}
/// Returns a slice of the vector's data.
pub fn asSlice(self: *Vec3) []f32 {
return self.asBuf()[0..];
}
/// Returns a const slice of the vector's data.
pub fn asConstSlice(self: *const Vec3) []const f32 {
return self.asConstBuf()[0..];
}
/// Returns a Vec2 representation of this vector
/// Modifications to the returned Vec2 will also
/// modify this vector, and vice versa.
pub fn asVec2(self: *Vec3) *Vec2 {
return @ptrCast(*Vec2, self);
}
/// Returns a vec2 of the x and y components of this vector
pub fn toVec2(self: Vec3) Vec2 {
return Vec2.init(self.x, self.y);
}
/// Appends a w value to make a vec4
pub fn toVec4(self: Vec3, w: f32) Vec4 {
return Vec4.init(self.x, self.y, self.z, w);
}
/// Provides a view over this vector as a BiVec3
pub fn asBiVec3(self: *Vec3) *BiVec3 {
return @ptrCast(*BiVec3, self);
}
/// Returns the BiVec3 representation of this vector.
/// This is the bivector normal to this vector with area
/// equal to the length of this vector. This is equal
/// to this vector times the unit trivector.
pub fn toBiVec3(self: Vec3) BiVec3 {
return @bitCast(BiVec3, self);
}
pub fn expectNear(expected: Vec3, actual: Vec3, epsilon: f32) void {
if (!math.approxEq(f32, expected.x, actual.x, epsilon) or
!math.approxEq(f32, expected.y, actual.y, epsilon) or
!math.approxEq(f32, expected.z, actual.z, epsilon))
{
std.debug.panic("Expected Vec3({}, {}, {}), found Vec3({}, {}, {})", .{
expected.x,
expected.y,
expected.z,
actual.x,
actual.y,
actual.z,
});
}
}
};
/// A 4-dimensional vector, representing the quantity x*e1 + y*e2 + z*e3 + w*e4.
pub const Vec4 = extern struct {
x: f32,
y: f32,
z: f32,
w: f32,
/// (0,0,0,0)
pub const Zero = init(0, 0, 0, 0);
/// (1,0,0,0)
pub const X = init(1, 0, 0, 0);
/// (0,1,0,0)
pub const Y = init(0, 1, 0, 0);
/// (0,0,1,0)
pub const Z = init(0, 0, 1, 0);
/// (0,0,0,1)
pub const W = init(0, 0, 0, 1);
/// Creates a vector with the given values
pub fn init(x: f32, y: f32, z: f32, w: f32) Vec4 {
return Vec4{
.x = x,
.y = y,
.z = z,
.w = w,
};
}
/// Creates a vector with each component set to the given value
pub fn splat(val: f32) Vec4 {
return Vec4{
.x = val,
.y = val,
.z = val,
.w = val,
};
}
/// Adds the like components of the inputs
pub fn add(self: Vec4, other: Vec4) Vec4 {
return Vec4{
.x = self.x + other.x,
.y = self.y + other.y,
.z = self.z + other.z,
.w = self.w + other.w,
};
}
/// Subtracts the like components of the inputs
pub fn sub(self: Vec4, other: Vec4) Vec4 {
return Vec4{
.x = self.x - other.x,
.y = self.y - other.y,
.z = self.z - other.z,
.w = self.w - other.w,
};
}
/// Returns the vector from self to other.
/// Equivalent to other.sub(self);.
pub fn diff(self: Vec4, other: Vec4) Vec4 {
return other.sub(self);
}
/// Negates each component
pub fn negate(self: Vec4) Vec4 {
return Vec4{
.x = -self.x,
.y = -self.y,
.z = -self.z,
.w = -self.w,
};
}
/// Multiply each component by a constant
pub fn scale(self: Vec4, multiple: f32) Vec4 {
return Vec4{
.x = self.x * multiple,
.y = self.y * multiple,
.z = self.z * multiple,
.w = self.w * multiple,
};
}
/// Component-wise multiply two vectors
pub fn mul(self: Vec4, mult: Vec4) Vec4 {
return Vec4{
.x = self.x * mult.x,
.y = self.y * mult.y,
.z = self.z * mult.z,
.w = self.w * mult.w,
};
}
/// Scale the vector to length 1.
/// If the vector is too close to zero, this returns error.Singular.
pub fn normalize(self: Vec4) !Vec4 {
const mult = 1.0 / self.len();
if (!math.isFinite(mult)) return error.Singular;
return self.scale(mult);
}
/// Divides by the w value to do perspective division.
/// If the w value is too close to zero, returns error.Singular.
pub fn perspective(self: Vec4) !Vec3 {
const mult = 1.0 / self.w;
if (!math.isFinite(mult)) return error.Singular;
return self.toVec3().scale(mult);
}
/// Divides by the w value to do perspective division.
/// If the w value is too close to zero, returns error.Singular.
pub fn perspective4(self: Vec4) !Vec4 {
const mult = 1.0 / self.w;
if (!math.isFinite(mult)) return error.Singular;
return self.scale(mult);
}
/// Adds the x, y, and z components of the vector
pub fn sum(self: Vec4) f32 {
return self.x + self.y + self.z;
}
/// Interpolates alpha percent between self and target.
/// If alpha is < 0 or > 1, will extrapolate.
pub fn lerp(self: Vec4, target: Vec4, alpha: f32) Vec4 {
return Vec4{
.x = self.x + (target.x - self.x) * alpha,
.y = self.y + (target.y - self.y) * alpha,
.z = self.z + (target.z - self.z) * alpha,
.w = self.w + (target.w - self.w) * alpha,
};
}
/// Returns the square of the length of the vector.
/// Slightly faster than calculating the length.
pub fn lenSquared(self: Vec4) f32 {
return self.x * self.x + self.y * self.y + self.z * self.z + self.w * self.w;
}
/// Computes the length of the vector
pub fn len(self: Vec4) f32 {
return math.sqrt(self.lenSquared());
}
/// Computes the dot product of two vectors
pub fn dot(self: Vec4, other: Vec4) f32 {
return self.x * other.x + self.y * other.y + self.z * other.z + self.w * other.w;
}
/// Computes the projection of self along other.
/// If other is too close to zero, returns error.Singular.
pub fn along(self: Vec4, other: Vec4) !Vec4 {
const mult = self.dot(other) / other.lenSquared();
if (!math.isFinite(mult)) return error.Singular;
return other.scale(mult);
}
/// Computes the rejection of self along other.
/// If other is too close to zero, returns error.Singular.
pub fn across(self: Vec4, other: Vec4) !Vec4 {
return self.sub(try self.along(other));
}
/// Returns a pointer to the vector's data as a fixed-size buffer.
pub fn asBuf(self: *Vec4) *[4]f32 {
return @ptrCast(*[4]f32, self);
}
/// Returns a pointer to the vector's data as a const fixed-size buffer.
pub fn asConstBuf(self: *const Vec4) *const [4]f32 {
return @ptrCast(*const [4]f32, self);
}
/// Returns a slice of the vector's data.
pub fn asSlice(self: *Vec4) []f32 {
return self.asBuf()[0..];
}
/// Returns a const slice of the vector's data.
pub fn asConstSlice(self: *const Vec4) []const f32 {
return self.asConstBuf()[0..];
}
/// Returns a Vec2 representation of this vector
/// Modifications to the returned Vec2 will also
/// modify this vector, and vice versa.
pub fn asVec2(self: *Vec4) *Vec2 {
return @ptrCast(*Vec2, self);
}
/// Returns a Vec3 representation of this vector
/// Modifications to the returned Vec2 will also
/// modify this vector, and vice versa.
pub fn asVec3(self: *Vec4) *Vec3 {
return @ptrCast(*Vec3, self);
}
/// Returns a vec2 of the x and y components of this vector
pub fn toVec2(self: Vec4) Vec2 {
return Vec2.init(self.x, self.y);
}
/// Returns a vec3 of the xyz components of this vector
pub fn toVec3(self: Vec4) Vec3 {
return Vec3.init(self.x, self.y, self.z);
}
pub fn expectNear(expected: Vec4, actual: Vec4, epsilon: f32) void {
if (!math.approxEq(f32, expected.x, actual.x, epsilon) or
!math.approxEq(f32, expected.y, actual.y, epsilon) or
!math.approxEq(f32, expected.z, actual.z, epsilon) or
!math.approxEq(f32, expected.w, actual.w, epsilon))
{
std.debug.panic("Expected Vec4({}, {}, {}, {}), found Vec4({}, {}, {}, {})", .{
expected.x,
expected.y,
expected.z,
expected.w,
actual.x,
actual.y,
actual.z,
actual.w,
});
}
}
};
/// A 3-dimensional bivector, representing the quantity xy*e1^e2 + yz*e2^e3 + zx*e3^e1.
pub const BiVec3 = extern struct {
// Field order is set up here to match that of Vec3,
// so BitCasting a Vec3 to a BiVec3 is equivalent to
// Vec3.dual(..)
yz: f32,
zx: f32,
xy: f32,
/// (0,0,0)
pub const Zero = init(0, 0, 0);
/// (1,0,0)
pub const YZ = init(1, 0, 0);
/// (0,1,0)
pub const ZX = init(0, 1, 0);
/// (0,0,1)
pub const XY = init(0, 0, 1);
/// Creates a BiVec3 with the given components
pub fn init(yz: f32, zx: f32, xy: f32) BiVec3 {
return BiVec3{
.yz = yz,
.zx = zx,
.xy = xy,
};
}
/// Add two bivectors
pub fn add(self: BiVec3, other: BiVec3) BiVec3 {
return BiVec3{
.yz = self.yz + other.yz,
.zx = self.zx + other.zx,
.xy = self.xy + other.xy,
};
}
/// Reverse the orientation of the bivector without
/// changing its magnitude.
pub fn negate(self: BiVec3) BiVec3 {
return BiVec3{
.yz = -self.yz,
.zx = -self.zx,
.xy = -self.xy,
};
}
/// Dots with another bivector and returns a scalar.
/// Note that this is NOT the same as a vector dot product.
pub fn dot(self: BiVec3, other: BiVec3) f32 {
return -(self.yz * other.yz) - (self.zx * other.zx) - (self.xy * other.xy);
}
/// Wedges with another bivector and returns a bivector.
/// Note that this is NOT the same as a vector wedge/cross product.
pub fn wedge(self: BiVec3, other: BiVec3) BiVec3 {
return BiVec3{
.yz = self.xy * other.zx - self.zx * other.xy,
.zx = self.yz * other.xy - self.xy * other.yz,
.xy = self.zx * other.yz - self.yz * other.zx,
};
}
/// Wedges with a vector and returns a trivector.
/// This value is equivalent to the scalar triple product.
/// Note that this is NOT the same as a vector wedge/cross product.
pub fn wedgeVec(self: BiVec3, other: Vec3) f32 {
return self.yz * other.x + self.zx * other.y + self.xy * other.z;
}
/// Dots with a vector and returns a vector.
/// This value is equivalent to the vector triple product.
/// Note that this is NOT the same as a vector dot product.
pub fn dotVec(self: BiVec3, other: Vec3) Vec3 {
return @bitCast(Vec3, self).cross(other);
}
/// Returns the vec projected onto this plane.
/// If this plane is near zero, returns error.Singular.
pub fn project(plane: BiVec3, vec: Vec3) !Vec3 {
return try vec.across(@bitCast(Vec3, plane));
}
/// Multiply each component by a constant
pub fn scale(self: BiVec3, multiple: f32) BiVec3 {
return BiVec3{
.yz = self.yz * multiple,
.zx = self.zx * multiple,
.xy = self.xy * multiple,
};
}
/// Normalize this vec. Returns error.Singular if
/// this is the zero bivector.
pub fn normalize(self: BiVec3) !BiVec3 {
return (try self.toVec3().normalize()).toBiVec3();
}
/// Returns a pointer to the vector's data as a fixed-size buffer.
pub fn asBuf(self: *Vec4) *[3]f32 {
return @ptrCast(*[3]f32, self);
}
/// Returns a pointer to the vector's data as a const fixed-size buffer.
pub fn asConstBuf(self: *const Vec4) *const [3]f32 {
return @ptrCast(*const [3]f32, self);
}
/// Returns a slice of the vector's data.
pub fn asSlice(self: *Vec4) []f32 {
return self.asBuf()[0..];
}
/// Returns a const slice of the vector's data.
pub fn asConstSlice(self: *const Vec4) []const f32 {
return self.asConstBuf()[0..];
}
/// Provide a Vec3 view over this BiVector.
/// x maps to yz, y maps to zx, z maps to xy.
pub fn asVec3(self: *BiVec3) *Vec3 {
return @ptrCast(*Vec3, self);
}
/// Copies into a Vec3.
/// x maps to yz, y maps to zx, z maps to xy.
pub fn toVec3(self: BiVec3) Vec3 {
return @bitCast(Vec3, self);
}
pub fn expectNear(expected: BiVec3, actual: BiVec3, epsilon: f32) void {
if (!math.approxEq(f32, expected.yz, actual.yz, epsilon) or
!math.approxEq(f32, expected.zx, actual.zx, epsilon) or
!math.approxEq(f32, expected.xy, actual.xy, epsilon))
{
std.debug.panic("Expected BiVec3({}, {}, {}), found BiVec3({}, {}, {})", .{
expected.yz,
expected.zx,
expected.xy,
actual.yz,
actual.zx,
actual.xy,
});
}
}
};
test "compile Vec2" {
var a = Vec2.init(0.5, 0);
var b = Vec2.splat(2);
const c = a.add(b);
_ = a.sub(b);
_ = a.diff(b);
_ = b.negate();
_ = c.scale(5);
_ = a.mul(b);
_ = try c.normalize();
_ = a.sum();
_ = a.lerp(b, 0.25);
_ = b.lenSquared();
_ = c.len();
_ = c.dot(c);
_ = c.wedge(a);
_ = try a.along(b);
_ = try a.across(b);
_ = a.reflect(b) catch a;
_ = try a.changeBasis(b, c);
_ = b.left();
_ = a.right();
_ = b.asBuf();
_ = b.asConstBuf();
const slice = b.asSlice();
_ = b.asConstSlice();
_ = c.asConstBuf();
_ = c.asConstSlice();
_ = b.toVec3(1);
_ = b.toVec4(0, 1);
_ = Vec2.pack4(b, a);
testing.expectEqual(@as(usize, 2), slice.len);
testing.expectEqual(@as(f32, 2), slice[1]);
slice[1] = 4;
testing.expectEqual(@as(f32, 4), b.y);
}
test "compile Vec3" {
var a = Vec3.init(0.5, 0, 1);
var b = Vec3.splat(2);
const c = a.add(b);
_ = a.sub(b);
_ = a.diff(b);
_ = b.negate();
_ = c.scale(5);
_ = a.mul(b);
_ = try c.normalize();
_ = a.sum();
_ = a.lerp(b, 0.75);
_ = b.lenSquared();
_ = c.len();
_ = c.dot(c);
_ = c.wedge(a);
_ = c.cross(a);
_ = try c.along(a);
_ = c.across(a) catch Vec3.Zero;
_ = b.asBuf();
_ = b.asConstBuf();
const slice = b.asSlice();
_ = b.asConstSlice();
_ = c.asConstBuf();
_ = c.asConstSlice();
const as2 = b.asVec2();
const val2 = b.toVec2();
_ = b.toVec4(1);
testing.expectEqual(@as(usize, 3), slice.len);
testing.expectEqual(@as(f32, 2), slice[1]);
slice[1] = 4;
testing.expectEqual(@as(f32, 4), b.y);
testing.expectEqual(@as(f32, 4), as2.y);
as2.x = 7;
testing.expectEqual(@as(f32, 7), b.x);
testing.expectEqual(val2.x, 2);
}
test "compile Vec4" {
var a = Vec4.init(0.5, 0, 1, 1);
var b = Vec4.splat(2);
const c = a.add(b);
_ = a.sub(b);
_ = a.diff(b);
_ = b.negate();
_ = c.scale(5);
_ = a.mul(b);
_ = try c.normalize();
_ = try c.perspective();
_ = try c.perspective4();
_ = a.sum();
_ = a.lerp(b, 0.5);
_ = b.lenSquared();
_ = c.len();
_ = c.dot(c);
_ = try c.along(b);
_ = b.asBuf();
_ = b.asConstBuf();
const slice = b.asSlice();
_ = b.asConstSlice();
_ = c.asConstBuf();
_ = c.asConstSlice();
const as2 = b.asVec2();
const val2 = b.toVec2();
const as3 = b.asVec3();
_ = b.toVec3();
testing.expectEqual(@as(usize, 4), slice.len);
testing.expectEqual(@as(f32, 2), slice[1]);
slice[1] = 4;
testing.expectEqual(@as(f32, 4), b.y);
testing.expectEqual(@as(f32, 4), as2.y);
testing.expectEqual(@as(f32, 4), as3.y);
as2.x = 7;
testing.expectEqual(@as(f32, 7), b.x);
testing.expectEqual(@as(f32, 7), as3.x);
testing.expectEqual(val2.x, 2);
}
test "compile BiVec3" {
var a = BiVec3.init(0.5, 1, 0);
var b = BiVec3.Zero;
_ = a.dot(b);
const c = a.wedge(b);
_ = c.wedgeVec(Vec3.X);
_ = c.dotVec(Vec3.X);
_ = c.scale(4);
_ = a.add(c);
}
|
src/geo/vec.zig
|
const rom = @import("../rom.zig");
const std = @import("std");
const io = std.io;
const mem = std.mem;
// TODO: Replace with Replacing/Escaping streams
pub const all = [_]rom.encoding.Char{
.{ "\\x0000", "\x00\x00" },
.{ "\\x0001", "\x01\x00" },
.{ "ぁ", "\x02\x00" },
.{ "あ", "\x03\x00" },
.{ "ぃ", "\x04\x00" },
.{ "い", "\x05\x00" },
.{ "ぅ", "\x06\x00" },
.{ "う", "\x07\x00" },
.{ "ぇ", "\x08\x00" },
.{ "え", "\x09\x00" },
.{ "ぉ", "\x0A\x00" },
.{ "お", "\x0B\x00" },
.{ "か", "\x0C\x00" },
.{ "が", "\x0D\x00" },
.{ "き", "\x0E\x00" },
.{ "ぎ", "\x0F\x00" },
.{ "く", "\x10\x00" },
.{ "ぐ", "\x11\x00" },
.{ "け", "\x12\x00" },
.{ "げ", "\x13\x00" },
.{ "こ", "\x14\x00" },
.{ "ご", "\x15\x00" },
.{ "さ", "\x16\x00" },
.{ "ざ", "\x17\x00" },
.{ "し", "\x18\x00" },
.{ "じ", "\x19\x00" },
.{ "す", "\x1A\x00" },
.{ "ず", "\x1B\x00" },
.{ "せ", "\x1C\x00" },
.{ "ぜ", "\x1D\x00" },
.{ "そ", "\x1E\x00" },
.{ "ぞ", "\x1F\x00" },
.{ "た", "\x20\x00" },
.{ "だ", "\x21\x00" },
.{ "ち", "\x22\x00" },
.{ "ぢ", "\x23\x00" },
.{ "っ", "\x24\x00" },
.{ "つ", "\x25\x00" },
.{ "づ", "\x26\x00" },
.{ "て", "\x27\x00" },
.{ "で", "\x28\x00" },
.{ "と", "\x29\x00" },
.{ "ど", "\x2A\x00" },
.{ "な", "\x2B\x00" },
.{ "に", "\x2C\x00" },
.{ "ぬ", "\x2D\x00" },
.{ "ね", "\x2E\x00" },
.{ "の", "\x2F\x00" },
.{ "は", "\x30\x00" },
.{ "ば", "\x31\x00" },
.{ "ぱ", "\x32\x00" },
.{ "ひ", "\x33\x00" },
.{ "び", "\x34\x00" },
.{ "ぴ", "\x35\x00" },
.{ "ふ", "\x36\x00" },
.{ "ぶ", "\x37\x00" },
.{ "ぷ", "\x38\x00" },
.{ "へ", "\x39\x00" },
.{ "べ", "\x3A\x00" },
.{ "ぺ", "\x3B\x00" },
.{ "ほ", "\x3C\x00" },
.{ "ぼ", "\x3D\x00" },
.{ "ぽ", "\x3E\x00" },
.{ "ま", "\x3F\x00" },
.{ "み", "\x40\x00" },
.{ "む", "\x41\x00" },
.{ "め", "\x42\x00" },
.{ "も", "\x43\x00" },
.{ "ゃ", "\x44\x00" },
.{ "や", "\x45\x00" },
.{ "ゅ", "\x46\x00" },
.{ "ゆ", "\x47\x00" },
.{ "ょ", "\x48\x00" },
.{ "よ", "\x49\x00" },
.{ "ら", "\x4A\x00" },
.{ "り", "\x4B\x00" },
.{ "る", "\x4C\x00" },
.{ "れ", "\x4D\x00" },
.{ "ろ", "\x4E\x00" },
.{ "わ", "\x4F\x00" },
.{ "を", "\x50\x00" },
.{ "ん", "\x51\x00" },
.{ "ァ", "\x52\x00" },
.{ "ア", "\x53\x00" },
.{ "ィ", "\x54\x00" },
.{ "イ", "\x55\x00" },
.{ "ゥ", "\x56\x00" },
.{ "ウ", "\x57\x00" },
.{ "ェ", "\x58\x00" },
.{ "エ", "\x59\x00" },
.{ "ォ", "\x5A\x00" },
.{ "オ", "\x5B\x00" },
.{ "カ", "\x5C\x00" },
.{ "ガ", "\x5D\x00" },
.{ "キ", "\x5E\x00" },
.{ "ギ", "\x5F\x00" },
.{ "ク", "\x60\x00" },
.{ "グ", "\x61\x00" },
.{ "ケ", "\x62\x00" },
.{ "ゲ", "\x63\x00" },
.{ "コ", "\x64\x00" },
.{ "ゴ", "\x65\x00" },
.{ "サ", "\x66\x00" },
.{ "ザ", "\x67\x00" },
.{ "シ", "\x68\x00" },
.{ "ジ", "\x69\x00" },
.{ "ス", "\x6A\x00" },
.{ "ズ", "\x6B\x00" },
.{ "セ", "\x6C\x00" },
.{ "ゼ", "\x6D\x00" },
.{ "ソ", "\x6E\x00" },
.{ "ゾ", "\x6F\x00" },
.{ "タ", "\x70\x00" },
.{ "ダ", "\x71\x00" },
.{ "チ", "\x72\x00" },
.{ "ヂ", "\x73\x00" },
.{ "ッ", "\x74\x00" },
.{ "ツ", "\x75\x00" },
.{ "ヅ", "\x76\x00" },
.{ "テ", "\x77\x00" },
.{ "デ", "\x78\x00" },
.{ "ト", "\x79\x00" },
.{ "ド", "\x7A\x00" },
.{ "ナ", "\x7B\x00" },
.{ "ニ", "\x7C\x00" },
.{ "ヌ", "\x7D\x00" },
.{ "ネ", "\x7E\x00" },
.{ "ノ", "\x7F\x00" },
.{ "ハ", "\x80\x00" },
.{ "バ", "\x81\x00" },
.{ "パ", "\x82\x00" },
.{ "ヒ", "\x83\x00" },
.{ "ビ", "\x84\x00" },
.{ "ピ", "\x85\x00" },
.{ "フ", "\x86\x00" },
.{ "ブ", "\x87\x00" },
.{ "プ", "\x88\x00" },
.{ "ヘ", "\x89\x00" },
.{ "ベ", "\x8A\x00" },
.{ "ペ", "\x8B\x00" },
.{ "ホ", "\x8C\x00" },
.{ "ボ", "\x8D\x00" },
.{ "ポ", "\x8E\x00" },
.{ "マ", "\x8F\x00" },
.{ "ミ", "\x90\x00" },
.{ "ム", "\x91\x00" },
.{ "メ", "\x92\x00" },
.{ "モ", "\x93\x00" },
.{ "ャ", "\x94\x00" },
.{ "ヤ", "\x95\x00" },
.{ "ュ", "\x96\x00" },
.{ "ユ", "\x97\x00" },
.{ "ョ", "\x98\x00" },
.{ "ヨ", "\x99\x00" },
.{ "ラ", "\x9A\x00" },
.{ "リ", "\x9B\x00" },
.{ "ル", "\x9C\x00" },
.{ "レ", "\x9D\x00" },
.{ "ロ", "\x9E\x00" },
.{ "ワ", "\x9F\x00" },
.{ "ヲ", "\xA0\x00" },
.{ "ン", "\xA1\x00" },
.{ "0", "\xA2\x00" },
.{ "1", "\xA3\x00" },
.{ "2", "\xA4\x00" },
.{ "3", "\xA5\x00" },
.{ "4", "\xA6\x00" },
.{ "5", "\xA7\x00" },
.{ "6", "\xA8\x00" },
.{ "7", "\xA9\x00" },
.{ "8", "\xAA\x00" },
.{ "9", "\xAB\x00" },
.{ "A", "\xAC\x00" },
.{ "B", "\xAD\x00" },
.{ "C", "\xAE\x00" },
.{ "D", "\xAF\x00" },
.{ "E", "\xB0\x00" },
.{ "F", "\xB1\x00" },
.{ "G", "\xB2\x00" },
.{ "H", "\xB3\x00" },
.{ "I", "\xB4\x00" },
.{ "J", "\xB5\x00" },
.{ "K", "\xB6\x00" },
.{ "L", "\xB7\x00" },
.{ "M", "\xB8\x00" },
.{ "N", "\xB9\x00" },
.{ "O", "\xBA\x00" },
.{ "P", "\xBB\x00" },
.{ "Q", "\xBC\x00" },
.{ "R", "\xBD\x00" },
.{ "S", "\xBE\x00" },
.{ "T", "\xBF\x00" },
.{ "U", "\xC0\x00" },
.{ "V", "\xC1\x00" },
.{ "W", "\xC2\x00" },
.{ "X", "\xC3\x00" },
.{ "Y", "\xC4\x00" },
.{ "Z", "\xC5\x00" },
.{ "a", "\xC6\x00" },
.{ "b", "\xC7\x00" },
.{ "c", "\xC8\x00" },
.{ "d", "\xC9\x00" },
.{ "e", "\xCA\x00" },
.{ "f", "\xCB\x00" },
.{ "g", "\xCC\x00" },
.{ "h", "\xCD\x00" },
.{ "i", "\xCE\x00" },
.{ "j", "\xCF\x00" },
.{ "k", "\xD0\x00" },
.{ "l", "\xD1\x00" },
.{ "m", "\xD2\x00" },
.{ "n", "\xD3\x00" },
.{ "o", "\xD4\x00" },
.{ "p", "\xD5\x00" },
.{ "q", "\xD6\x00" },
.{ "r", "\xD7\x00" },
.{ "s", "\xD8\x00" },
.{ "t", "\xD9\x00" },
.{ "u", "\xDA\x00" },
.{ "v", "\xDB\x00" },
.{ "w", "\xDC\x00" },
.{ "x", "\xDD\x00" },
.{ "y", "\xDE\x00" },
.{ "z", "\xDF\x00" },
.{ " (224)", "\xE0\x00" },
.{ "!", "\xE1\x00" },
.{ "?", "\xE2\x00" },
.{ "、", "\xE3\x00" },
.{ "。", "\xE4\x00" },
.{ "…", "\xE5\x00" },
.{ "・", "\xE6\x00" },
.{ "/", "\xE7\x00" },
.{ "「", "\xE8\x00" },
.{ "」", "\xE9\x00" },
.{ "『", "\xEA\x00" },
.{ "』", "\xEB\x00" },
.{ "(", "\xEC\x00" },
.{ ")", "\xED\x00" },
.{ "♂", "\xEE\x00" },
.{ "♀", "\xEF\x00" },
.{ "+", "\xF0\x00" },
.{ "ー", "\xF1\x00" },
.{ "×", "\xF2\x00" },
.{ "÷", "\xF3\x00" },
.{ "=", "\xF4\x00" },
.{ "~", "\xF5\x00" },
.{ ":", "\xF6\x00" },
.{ ";", "\xF7\x00" },
.{ ".", "\xF8\x00" },
.{ ",", "\xF9\x00" },
.{ "♠", "\xFA\x00" },
.{ "♣", "\xFB\x00" },
.{ "♥", "\xFC\x00" },
.{ "♦", "\xFD\x00" },
.{ "★", "\xFE\x00" },
.{ "◎", "\xFF\x00" },
.{ "○", "\x00\x01" },
.{ "□", "\x01\x01" },
.{ "△", "\x02\x01" },
.{ "◇", "\x03\x01" },
.{ "@", "\x04\x01" },
.{ "♪", "\x05\x01" },
.{ "%", "\x06\x01" },
.{ "☀", "\x07\x01" },
.{ "☁", "\x08\x01" },
.{ "☂", "\x09\x01" },
.{ "☃", "\x0A\x01" },
.{ "\\x010B", "\x0B\x01" },
.{ "\\x010C", "\x0C\x01" },
.{ "\\x010D", "\x0D\x01" },
.{ "\\x010E", "\x0E\x01" },
.{ "⤴", "\x0F\x01" },
.{ "⤵", "\x10\x01" },
.{ "\\x0111", "\x11\x01" },
.{ "円", "\x12\x01" },
.{ "\\x0113", "\x13\x01" },
.{ "\\x0114", "\x14\x01" },
.{ "\\x0115", "\x15\x01" },
.{ "✉", "\x16\x01" },
.{ "\\x0117", "\x17\x01" },
.{ "\\x0118", "\x18\x01" },
.{ "\\x0119", "\x19\x01" },
.{ "\\x011A", "\x1A\x01" },
.{ "←", "\x1B\x01" },
.{ "↑", "\x1C\x01" },
.{ "↓", "\x1D\x01" },
.{ "→", "\x1E\x01" },
.{ "\\x011F", "\x1F\x01" },
.{ "&", "\x20\x01" },
.{ "0", "\x21\x01" },
.{ "1", "\x22\x01" },
.{ "2", "\x23\x01" },
.{ "3", "\x24\x01" },
.{ "4", "\x25\x01" },
.{ "5", "\x26\x01" },
.{ "6", "\x27\x01" },
.{ "7", "\x28\x01" },
.{ "8", "\x29\x01" },
.{ "9", "\x2A\x01" },
.{ "A", "\x2B\x01" },
.{ "B", "\x2C\x01" },
.{ "C", "\x2D\x01" },
.{ "D", "\x2E\x01" },
.{ "E", "\x2F\x01" },
.{ "F", "\x30\x01" },
.{ "G", "\x31\x01" },
.{ "H", "\x32\x01" },
.{ "I", "\x33\x01" },
.{ "J", "\x34\x01" },
.{ "K", "\x35\x01" },
.{ "L", "\x36\x01" },
.{ "M", "\x37\x01" },
.{ "N", "\x38\x01" },
.{ "O", "\x39\x01" },
.{ "P", "\x3A\x01" },
.{ "Q", "\x3B\x01" },
.{ "R", "\x3C\x01" },
.{ "S", "\x3D\x01" },
.{ "T", "\x3E\x01" },
.{ "U", "\x3F\x01" },
.{ "V", "\x40\x01" },
.{ "W", "\x41\x01" },
.{ "X", "\x42\x01" },
.{ "Y", "\x43\x01" },
.{ "Z", "\x44\x01" },
.{ "a", "\x45\x01" },
.{ "b", "\x46\x01" },
.{ "c", "\x47\x01" },
.{ "d", "\x48\x01" },
.{ "e", "\x49\x01" },
.{ "f", "\x4A\x01" },
.{ "g", "\x4B\x01" },
.{ "h", "\x4C\x01" },
.{ "i", "\x4D\x01" },
.{ "j", "\x4E\x01" },
.{ "k", "\x4F\x01" },
.{ "l", "\x50\x01" },
.{ "m", "\x51\x01" },
.{ "n", "\x52\x01" },
.{ "o", "\x53\x01" },
.{ "p", "\x54\x01" },
.{ "q", "\x55\x01" },
.{ "r", "\x56\x01" },
.{ "s", "\x57\x01" },
.{ "t", "\x58\x01" },
.{ "u", "\x59\x01" },
.{ "v", "\x5A\x01" },
.{ "w", "\x5B\x01" },
.{ "x", "\x5C\x01" },
.{ "y", "\x5D\x01" },
.{ "z", "\x5E\x01" },
.{ "À", "\x5F\x01" },
.{ "Á", "\x60\x01" },
.{ "Â", "\x61\x01" },
.{ "\\x0162", "\x62\x01" },
.{ "Ä", "\x63\x01" },
.{ "\\x0164", "\x64\x01" },
.{ "\\x0165", "\x65\x01" },
.{ "Ç", "\x66\x01" },
.{ "È", "\x67\x01" },
.{ "É", "\x68\x01" },
.{ "Ê", "\x69\x01" },
.{ "Ë", "\x6A\x01" },
.{ "Ì", "\x6B\x01" },
.{ "Í", "\x6C\x01" },
.{ "Î", "\x6D\x01" },
.{ "Ï", "\x6E\x01" },
.{ "\\x016F", "\x6F\x01" },
.{ "Ñ", "\x70\x01" },
.{ "Ò", "\x71\x01" },
.{ "Ó", "\x72\x01" },
.{ "Ô", "\x73\x01" },
.{ "\\x0174", "\x74\x01" },
.{ "Ö", "\x75\x01" },
.{ "×", "\x76\x01" },
.{ "\\x0177", "\x77\x01" },
.{ "Ù", "\x78\x01" },
.{ "Ú", "\x79\x01" },
.{ "Û", "\x7A\x01" },
.{ "Ü", "\x7B\x01" },
.{ "\\x017C", "\x7C\x01" },
.{ "\\x017D", "\x7D\x01" },
.{ "ß", "\x7E\x01" },
.{ "à", "\x7F\x01" },
.{ "á", "\x80\x01" },
.{ "â", "\x81\x01" },
.{ "\\x0182", "\x82\x01" },
.{ "ä", "\x83\x01" },
.{ "\\x0184", "\x84\x01" },
.{ "\\x0185", "\x85\x01" },
.{ "ç", "\x86\x01" },
.{ "è", "\x87\x01" },
.{ "é", "\x88\x01" },
.{ "ê", "\x89\x01" },
.{ "ë", "\x8A\x01" },
.{ "ì", "\x8B\x01" },
.{ "í", "\x8C\x01" },
.{ "î", "\x8D\x01" },
.{ "ï", "\x8E\x01" },
.{ "\\x018F", "\x8F\x01" },
.{ "ñ", "\x90\x01" },
.{ "ò", "\x91\x01" },
.{ "ó", "\x92\x01" },
.{ "ô", "\x93\x01" },
.{ "\\x0194", "\x94\x01" },
.{ "ö", "\x95\x01" },
.{ "÷", "\x96\x01" },
.{ "\\x0197", "\x97\x01" },
.{ "ù", "\x98\x01" },
.{ "ú", "\x99\x01" },
.{ "û", "\x9A\x01" },
.{ "ü", "\x9B\x01" },
.{ "\\x019C", "\x9C\x01" },
.{ "\\x019D", "\x9D\x01" },
.{ "\\x019E", "\x9E\x01" },
.{ "Œ", "\x9F\x01" },
.{ "œ", "\xA0\x01" },
.{ "\\x01A1", "\xA1\x01" },
.{ "\\x01A2", "\xA2\x01" },
.{ "ª", "\xA3\x01" },
.{ "º", "\xA4\x01" },
.{ "ᵉʳ", "\xA5\x01" },
.{ "ʳᵉ", "\xA6\x01" },
.{ "ʳ", "\xA7\x01" },
.{ "¥", "\xA8\x01" },
.{ "¡", "\xA9\x01" },
.{ "¿", "\xAA\x01" },
.{ "!", "\xAB\x01" },
.{ "?", "\xAC\x01" },
.{ ",", "\xAD\x01" },
.{ ".", "\xAE\x01" },
.{ "…", "\xAF\x01" },
.{ "·", "\xB0\x01" },
.{ "/", "\xB1\x01" },
.{ "‘", "\xB2\x01" },
.{ "'", "\xB3\x01" },
.{ "“", "\xB4\x01" },
.{ "”", "\xB5\x01" },
.{ "„", "\xB6\x01" },
.{ "«", "\xB7\x01" },
.{ "»", "\xB8\x01" },
.{ "(", "\xB9\x01" },
.{ ")", "\xBA\x01" },
.{ "♂", "\xBB\x01" },
.{ "♀", "\xBC\x01" },
.{ "+", "\xBD\x01" },
.{ "-", "\xBE\x01" },
.{ "*", "\xBF\x01" },
.{ "#", "\xC0\x01" },
.{ "=", "\xC1\x01" },
.{ "\\and", "\xC2\x01" },
.{ "~", "\xC3\x01" },
.{ ":", "\xC4\x01" },
.{ ";", "\xC5\x01" },
.{ "♠", "\xC6\x01" },
.{ "♣", "\xC7\x01" },
.{ "♥", "\xC8\x01" },
.{ "♦", "\xC9\x01" },
.{ "★", "\xCA\x01" },
.{ "◎", "\xCB\x01" },
.{ "○", "\xCC\x01" },
.{ "□", "\xCD\x01" },
.{ "△", "\xCE\x01" },
.{ "◇", "\xCF\x01" },
.{ "@", "\xD0\x01" },
.{ "♪", "\xD1\x01" },
.{ "%", "\xD2\x01" },
.{ "☀", "\xD3\x01" },
.{ "☁", "\xD4\x01" },
.{ "☂", "\xD5\x01" },
.{ "☃", "\xD6\x01" },
.{ "\\x01D7", "\xD7\x01" },
.{ "\\x01D8", "\xD8\x01" },
.{ "\\x01D9", "\xD9\x01" },
.{ "\\x01DA", "\xDA\x01" },
.{ "⤴", "\xDB\x01" },
.{ "⤵", "\xDC\x01" },
.{ "\\x01DD", "\xDD\x01" },
.{ " ", "\xDE\x01" },
.{ "\\x01DF", "\xDF\x01" },
.{ "[PK]", "\xE0\x01" },
.{ "[MN]", "\xE1\x01" },
.{ "가", "\x01\x04" },
.{ "갈", "\x05\x04" },
.{ "갑", "\x09\x04" },
.{ "강", "\x0D\x04" },
.{ "개", "\x13\x04" },
.{ "갱", "\x1B\x04" },
.{ "갸", "\x1C\x04" },
.{ "거", "\x25\x04" },
.{ "검", "\x2B\x04" },
.{ "게", "\x34\x04" },
.{ "겔", "\x36\x04" },
.{ "겟", "\x39\x04" },
.{ "고", "\x4D\x04" },
.{ "곤", "\x4F\x04" },
.{ "골", "\x51\x04" },
.{ "곰", "\x55\x04" },
.{ "공", "\x58\x04" },
.{ "광", "\x62\x04" },
.{ "괴", "\x69\x04" },
.{ "구", "\x76\x04" },
.{ "군", "\x78\x04" },
.{ "굴", "\x7A\x04" },
.{ "귀", "\x8B\x04" },
.{ "그", "\x95\x04" },
.{ "근", "\x97\x04" },
.{ "글", "\x99\x04" },
.{ "기", "\xA0\x04" },
.{ "깅", "\xA9\x04" },
.{ "까", "\xAC\x04" },
.{ "깍", "\xAD\x04" },
.{ "깜", "\xB2\x04" },
.{ "깝", "\xB3\x04" },
.{ "깨", "\xB8\x04" },
.{ "꺽", "\xC5\x04" },
.{ "껍", "\xCA\x04" },
.{ "꼬", "\xDB\x04" },
.{ "꼴", "\xDF\x04" },
.{ "꽃", "\xE5\x04" },
.{ "꾸", "\xF5\x04" },
.{ "꿀", "\xF8\x04" },
.{ "나", "\x24\x05" },
.{ "날", "\x29\x05" },
.{ "내", "\x35\x05" },
.{ "냄", "\x39\x05" },
.{ "냥", "\x43\x05" },
.{ "너", "\x44\x05" },
.{ "네", "\x51\x05" },
.{ "노", "\x65\x05" },
.{ "놈", "\x6A\x05" },
.{ "농", "\x6D\x05" },
.{ "뇽", "\x80\x05" },
.{ "누", "\x81\x05" },
.{ "눈", "\x83\x05" },
.{ "느", "\x98\x05" },
.{ "늪", "\xA3\x05" },
.{ "니", "\xA7\x05" },
.{ "다", "\xB1\x05" },
.{ "닥", "\xB2\x05" },
.{ "단", "\xB4\x05" },
.{ "담", "\xBB\x05" },
.{ "대", "\xC3\x05" },
.{ "더", "\xCD\x05" },
.{ "덕", "\xCE\x05" },
.{ "덩", "\xD8\x05" },
.{ "데", "\xDB\x05" },
.{ "델", "\xDE\x05" },
.{ "도", "\xEB\x05" },
.{ "독", "\xEC\x05" },
.{ "돈", "\xED\x05" },
.{ "돌", "\xEF\x05" },
.{ "동", "\xF5\x05" },
.{ "두", "\x04\x06" },
.{ "둔", "\x06\x06" },
.{ "둠", "\x08\x06" },
.{ "둥", "\x0B\x06" },
.{ "드", "\x1B\x06" },
.{ "들", "\x1F\x06" },
.{ "디", "\x26\x06" },
.{ "딘", "\x28\x06" },
.{ "딜", "\x2A\x06" },
.{ "딥", "\x2C\x06" },
.{ "딱", "\x32\x06" },
.{ "딸", "\x34\x06" },
.{ "또", "\x5B\x06" },
.{ "뚜", "\x65\x06" },
.{ "뚝", "\x66\x06" },
.{ "뚤", "\x68\x06" },
.{ "라", "\x87\x06" },
.{ "락", "\x88\x06" },
.{ "란", "\x89\x06" },
.{ "랄", "\x8A\x06" },
.{ "랑", "\x8F\x06" },
.{ "래", "\x93\x06" },
.{ "랜", "\x95\x06" },
.{ "램", "\x97\x06" },
.{ "랩", "\x98\x06" },
.{ "러", "\xA1\x06" },
.{ "럭", "\xA2\x06" },
.{ "런", "\xA3\x06" },
.{ "렁", "\xA9\x06" },
.{ "레", "\xAB\x06" },
.{ "렌", "\xAD\x06" },
.{ "렛", "\xB1\x06" },
.{ "력", "\xB4\x06" },
.{ "로", "\xC0\x06" },
.{ "록", "\xC1\x06" },
.{ "롤", "\xC3\x06" },
.{ "롭", "\xC5\x06" },
.{ "롱", "\xC7\x06" },
.{ "룡", "\xD8\x06" },
.{ "루", "\xD9\x06" },
.{ "룸", "\xDD\x06" },
.{ "륙", "\xEC\x06" },
.{ "르", "\xF3\x06" },
.{ "리", "\xFE\x06" },
.{ "린", "\x00\x07" },
.{ "릴", "\x01\x07" },
.{ "림", "\x02\x07" },
.{ "링", "\x05\x07" },
.{ "마", "\x06\x07" },
.{ "만", "\x08\x07" },
.{ "말", "\x0B\x07" },
.{ "맘", "\x0E\x07" },
.{ "망", "\x11\x07" },
.{ "매", "\x15\x07" },
.{ "맨", "\x17\x07" },
.{ "먹", "\x24\x07" },
.{ "메", "\x2E\x07" },
.{ "모", "\x40\x07" },
.{ "몬", "\x43\x07" },
.{ "몽", "\x49\x07" },
.{ "무", "\x59\x07" },
.{ "물", "\x5E\x07" },
.{ "뭉", "\x64\x07" },
.{ "뮤", "\x70\x07" },
.{ "미", "\x7A\x07" },
.{ "밀", "\x7E\x07" },
.{ "바", "\x87\x07" },
.{ "발", "\x8D\x07" },
.{ "밤", "\x91\x07" },
.{ "방", "\x94\x07" },
.{ "배", "\x96\x07" },
.{ "뱃", "\x9C\x07" },
.{ "버", "\xA4\x07" },
.{ "벅", "\xA5\x07" },
.{ "번", "\xA6\x07" },
.{ "범", "\xAA\x07" },
.{ "베", "\xAF\x07" },
.{ "벨", "\xB3\x07" },
.{ "별", "\xBC\x07" },
.{ "보", "\xC4\x07" },
.{ "복", "\xC5\x07" },
.{ "볼", "\xC8\x07" },
.{ "부", "\xDA\x07" },
.{ "북", "\xDB\x07" },
.{ "분", "\xDC\x07" },
.{ "불", "\xDE\x07" },
.{ "붐", "\xE1\x07" },
.{ "붕", "\xE4\x07" },
.{ "뷰", "\xF0\x07" },
.{ "브", "\xF6\x07" },
.{ "블", "\xF9\x07" },
.{ "비", "\xFD\x07" },
.{ "빈", "\xFF\x07" },
.{ "빌", "\x00\x08" },
.{ "뻐", "\x1F\x08" },
.{ "뽀", "\x31\x08" },
.{ "뿌", "\x3B\x08" },
.{ "뿔", "\x3E\x08" },
.{ "뿡", "\x41\x08" },
.{ "쁘", "\x44\x08" },
.{ "삐", "\x49\x08" },
.{ "사", "\x51\x08" },
.{ "산", "\x54\x08" },
.{ "삼", "\x59\x08" },
.{ "상", "\x5D\x08" },
.{ "새", "\x5F\x08" },
.{ "색", "\x60\x08" },
.{ "샤", "\x68\x08" },
.{ "선", "\x79\x08" },
.{ "설", "\x7B\x08" },
.{ "섯", "\x80\x08" },
.{ "성", "\x82\x08" },
.{ "세", "\x84\x08" },
.{ "섹", "\x85\x08" },
.{ "셀", "\x87\x08" },
.{ "소", "\x9A\x08" },
.{ "손", "\x9D\x08" },
.{ "솔", "\x9E\x08" },
.{ "솜", "\xA0\x08" },
.{ "송", "\xA3\x08" },
.{ "수", "\xBE\x08" },
.{ "술", "\xC2\x08" },
.{ "숭", "\xC6\x08" },
.{ "쉐", "\xCC\x08" },
.{ "쉘", "\xCF\x08" },
.{ "슈", "\xDA\x08" },
.{ "스", "\xE0\x08" },
.{ "슬", "\xE3\x08" },
.{ "시", "\xE9\x08" },
.{ "식", "\xEA\x08" },
.{ "신", "\xEB\x08" },
.{ "실", "\xED\x08" },
.{ "쌩", "\x05\x09" },
.{ "썬", "\x09\x09" },
.{ "쏘", "\x14\x09" },
.{ "쓰", "\x36\x09" },
.{ "씨", "\x42\x09" },
.{ "아", "\x4A\x09" },
.{ "안", "\x4C\x09" },
.{ "알", "\x4F\x09" },
.{ "암", "\x53\x09" },
.{ "애", "\x5A\x09" },
.{ "앤", "\x5C\x09" },
.{ "앱", "\x5F\x09" },
.{ "야", "\x63\x09" },
.{ "어", "\x72\x09" },
.{ "얼", "\x77\x09" },
.{ "엉", "\x7F\x09" },
.{ "에", "\x83\x09" },
.{ "엘", "\x86\x09" },
.{ "엠", "\x87\x09" },
.{ "여", "\x8B\x09" },
.{ "연", "\x8E\x09" },
.{ "염", "\x92\x09" },
.{ "영", "\x97\x09" },
.{ "오", "\xA2\x09" },
.{ "온", "\xA4\x09" },
.{ "옹", "\xAD\x09" },
.{ "와", "\xAF\x09" },
.{ "왈", "\xB2\x09" },
.{ "왕", "\xB7\x09" },
.{ "요", "\xC6\x09" },
.{ "용", "\xCD\x09" },
.{ "우", "\xCE\x09" },
.{ "울", "\xD1\x09" },
.{ "움", "\xD4\x09" },
.{ "원", "\xDA\x09" },
.{ "윈", "\xE9\x09" },
.{ "유", "\xEF\x09" },
.{ "육", "\xF0\x09" },
.{ "윤", "\xF1\x09" },
.{ "을", "\xFB\x09" },
.{ "음", "\xFD\x09" },
.{ "이", "\x0C\x0A" },
.{ "인", "\x0E\x0A" },
.{ "일", "\x0F\x0A" },
.{ "임", "\x13\x0A" },
.{ "입", "\x14\x0A" },
.{ "잉", "\x17\x0A" },
.{ "잎", "\x19\x0A" },
.{ "자", "\x1A\x0A" },
.{ "잠", "\x21\x0A" },
.{ "장", "\x25\x0A" },
.{ "재", "\x27\x0A" },
.{ "쟈", "\x30\x0A" },
.{ "쟝", "\x36\x0A" },
.{ "저", "\x3A\x0A" },
.{ "전", "\x3C\x0A" },
.{ "점", "\x3F\x0A" },
.{ "제", "\x44\x0A" },
.{ "젤", "\x47\x0A" },
.{ "져", "\x4C\x0A" },
.{ "조", "\x54\x0A" },
.{ "죤", "\x72\x0A" },
.{ "주", "\x74\x0A" },
.{ "중", "\x7D\x0A" },
.{ "쥬", "\x88\x0A" },
.{ "즈", "\x8C\x0A" },
.{ "지", "\x94\x0A" },
.{ "직", "\x95\x0A" },
.{ "진", "\x96\x0A" },
.{ "질", "\x98\x0A" },
.{ "짱", "\xAB\x0A" },
.{ "찌", "\xEA\x0A" },
.{ "차", "\xF3\x0A" },
.{ "참", "\xF8\x0A" },
.{ "챙", "\x06\x0B" },
.{ "챠", "\x07\x0B" },
.{ "철", "\x10\x0B" },
.{ "체", "\x16\x0B" },
.{ "초", "\x24\x0B" },
.{ "총", "\x2B\x0B" },
.{ "쵸", "\x37\x0B" },
.{ "충", "\x40\x0B" },
.{ "츄", "\x4C\x0B" },
.{ "츠", "\x51\x0B" },
.{ "치", "\x59\x0B" },
.{ "칠", "\x5D\x0B" },
.{ "침", "\x5F\x0B" },
.{ "카", "\x63\x0B" },
.{ "칸", "\x65\x0B" },
.{ "캐", "\x6B\x0B" },
.{ "캥", "\x73\x0B" },
.{ "컹", "\x80\x0B" },
.{ "케", "\x81\x0B" },
.{ "켄", "\x83\x0B" },
.{ "켈", "\x84\x0B" },
.{ "코", "\x92\x0B" },
.{ "콘", "\x94\x0B" },
.{ "콜", "\x95\x0B" },
.{ "쿠", "\xA5\x0B" },
.{ "쿤", "\xA7\x0B" },
.{ "퀸", "\xB5\x0B" },
.{ "크", "\xBF\x0B" },
.{ "키", "\xC6\x0B" },
.{ "킬", "\xC9\x0B" },
.{ "킹", "\xCD\x0B" },
.{ "타", "\xCE\x0B" },
.{ "탁", "\xCF\x0B" },
.{ "탕", "\xD7\x0B" },
.{ "태", "\xD8\x0B" },
.{ "탱", "\xE0\x0B" },
.{ "터", "\xE3\x0B" },
.{ "턴", "\xE5\x0B" },
.{ "텀", "\xE8\x0B" },
.{ "텅", "\xEC\x0B" },
.{ "테", "\xED\x0B" },
.{ "토", "\xFA\x0B" },
.{ "톡", "\xFB\x0B" },
.{ "톤", "\xFC\x0B" },
.{ "톱", "\xFF\x0B" },
.{ "통", "\x01\x0C" },
.{ "투", "\x0B\x0C" },
.{ "트", "\x22\x0C" },
.{ "틈", "\x28\x0C" },
.{ "티", "\x30\x0C" },
.{ "틱", "\x31\x0C" },
.{ "틸", "\x33\x0C" },
.{ "파", "\x38\x0C" },
.{ "팜", "\x3E\x0C" },
.{ "팡", "\x42\x0C" },
.{ "패", "\x44\x0C" },
.{ "팬", "\x46\x0C" },
.{ "팽", "\x4C\x0C" },
.{ "퍼", "\x4F\x0C" },
.{ "퍽", "\x50\x0C" },
.{ "펄", "\x52\x0C" },
.{ "페", "\x58\x0C" },
.{ "펫", "\x5E\x0C" },
.{ "포", "\x6B\x0C" },
.{ "폭", "\x6C\x0C" },
.{ "폴", "\x6E\x0C" },
.{ "퐁", "\x72\x0C" },
.{ "푸", "\x7C\x0C" },
.{ "풀", "\x80\x0C" },
.{ "풍", "\x85\x0C" },
.{ "프", "\x93\x0C" },
.{ "플", "\x95\x0C" },
.{ "피", "\x99\x0C" },
.{ "픽", "\x9A\x0C" },
.{ "핑", "\xA0\x0C" },
.{ "하", "\xA1\x0C" },
.{ "한", "\xA3\x0C" },
.{ "핫", "\xA8\x0C" },
.{ "해", "\xAA\x0C" },
.{ "핸", "\xAC\x0C" },
.{ "헌", "\xB7\x0C" },
.{ "헤", "\xBE\x0C" },
.{ "헬", "\xC1\x0C" },
.{ "형", "\xCE\x0C" },
.{ "호", "\xD3\x0C" },
.{ "홍", "\xDB\x0C" },
.{ "화", "\xDD\x0C" },
.{ "후", "\xF4\x0C" },
.{ "흉", "\x14\x0D" },
.{ "흔", "\x17\x0D" },
.{ "히", "\x27\x0D" },
.{ "각", "\x02\x04" },
.{ "간", "\x03\x04" },
.{ "감", "\x08\x04" },
.{ "갚", "\x11\x04" },
.{ "객", "\x14\x04" },
.{ "걸", "\x29\x04" },
.{ "겁", "\x2C\x04" },
.{ "격", "\x3D\x04" },
.{ "결", "\x41\x04" },
.{ "경", "\x46\x04" },
.{ "관", "\x5C\x04" },
.{ "교", "\x71\x04" },
.{ "굳", "\x79\x04" },
.{ "권", "\x85\x04" },
.{ "금", "\x9B\x04" },
.{ "길", "\xA4\x04" },
.{ "김", "\xA6\x04" },
.{ "깃", "\xA8\x04" },
.{ "껏", "\xCB\x04" },
.{ "꿈", "\xFA\x04" },
.{ "꿔", "\xFF\x04" },
.{ "꿰", "\x03\x05" },
.{ "끼", "\x1C\x05" },
.{ "난", "\x27\x05" },
.{ "낳", "\x34\x05" },
.{ "냉", "\x3D\x05" },
.{ "널", "\x48\x05" },
.{ "넷", "\x57\x05" },
.{ "념", "\x5E\x05" },
.{ "녹", "\x66\x05" },
.{ "논", "\x67\x05" },
.{ "놀", "\x68\x05" },
.{ "는", "\x9A\x05" },
.{ "늘", "\x9B\x05" },
.{ "닉", "\xA8\x05" },
.{ "달", "\xB6\x05" },
.{ "당", "\xBF\x05" },
.{ "댄", "\xC5\x05" },
.{ "던", "\xD0\x05" },
.{ "둑", "\x05\x06" },
.{ "뒀", "\x0D\x06" },
.{ "등", "\x24\x06" },
.{ "딧", "\x2D\x06" },
.{ "따", "\x31\x06" },
.{ "땅", "\x39\x06" },
.{ "때", "\x3B\x06" },
.{ "떨", "\x47\x06" },
.{ "뚫", "\x69\x06" },
.{ "뛰", "\x6D\x06" },
.{ "람", "\x8B\x06" },
.{ "렉", "\xAC\x06" },
.{ "려", "\xB3\x06" },
.{ "령", "\xBB\x06" },
.{ "례", "\xBC\x06" },
.{ "료", "\xD3\x06" },
.{ "류", "\xEB\x06" },
.{ "름", "\xF7\x06" },
.{ "릎", "\xFD\x06" },
.{ "릭", "\xFF\x06" },
.{ "릿", "\x04\x07" },
.{ "막", "\x07\x07" },
.{ "맹", "\x1D\x07" },
.{ "머", "\x23\x07" },
.{ "멀", "\x26\x07" },
.{ "멍", "\x2B\x07" },
.{ "멧", "\x34\x07" },
.{ "면", "\x39\x07" },
.{ "멸", "\x3A\x07" },
.{ "명", "\x3D\x07" },
.{ "목", "\x41\x07" },
.{ "몸", "\x46\x07" },
.{ "묵", "\x5A\x07" },
.{ "묶", "\x5B\x07" },
.{ "문", "\x5C\x07" },
.{ "믹", "\x7B\x07" },
.{ "민", "\x7C\x07" },
.{ "박", "\x88\x07" },
.{ "반", "\x8B\x07" },
.{ "받", "\x8C\x07" },
.{ "밟", "\x90\x07" },
.{ "밥", "\x92\x07" },
.{ "뱀", "\x9A\x07" },
.{ "벌", "\xA8\x07" },
.{ "법", "\xAB\x07" },
.{ "벤", "\xB1\x07" },
.{ "벽", "\xBA\x07" },
.{ "변", "\xBB\x07" },
.{ "본", "\xC7\x07" },
.{ "봄", "\xC9\x07" },
.{ "봉", "\xCC\x07" },
.{ "빔", "\x02\x08" },
.{ "빙", "\x05\x08" },
.{ "빛", "\x07\x08" },
.{ "뺨", "\x1E\x08" },
.{ "뼈", "\x2A\x08" },
.{ "뽐", "\x35\x08" },
.{ "뿜", "\x3F\x08" },
.{ "쁜", "\x45\x08" },
.{ "살", "\x56\x08" },
.{ "생", "\x67\x08" },
.{ "섀", "\x70\x08" },
.{ "서", "\x75\x08" },
.{ "석", "\x76\x08" },
.{ "속", "\x9B\x08" },
.{ "쇼", "\xB6\x08" },
.{ "숏", "\xBC\x08" },
.{ "순", "\xC0\x08" },
.{ "숟", "\xC1\x08" },
.{ "숨", "\xC3\x08" },
.{ "쉬", "\xD2\x08" },
.{ "습", "\xE6\x08" },
.{ "승", "\xE8\x08" },
.{ "싫", "\xEE\x08" },
.{ "심", "\xEF\x08" },
.{ "싸", "\xF4\x08" },
.{ "악", "\x4B\x09" },
.{ "압", "\x54\x09" },
.{ "앞", "\x59\x09" },
.{ "액", "\x5B\x09" },
.{ "앵", "\x62\x09" },
.{ "양", "\x6B\x09" },
.{ "억", "\x73\x09" },
.{ "언", "\x74\x09" },
.{ "엄", "\x7A\x09" },
.{ "업", "\x7B\x09" },
.{ "역", "\x8C\x09" },
.{ "열", "\x8F\x09" },
.{ "예", "\x9B\x09" },
.{ "옥", "\xA3\x09" },
.{ "운", "\xD0\x09" },
.{ "웅", "\xD7\x09" },
.{ "워", "\xD8\x09" },
.{ "웨", "\xE0\x09" },
.{ "웹", "\xE5\x09" },
.{ "위", "\xE7\x09" },
.{ "으", "\xF8\x09" },
.{ "은", "\xFA\x09" },
.{ "의", "\x07\x0A" },
.{ "작", "\x1B\x0A" },
.{ "잼", "\x2B\x0A" },
.{ "쟁", "\x2F\x0A" },
.{ "적", "\x3B\x0A" },
.{ "절", "\x3D\x0A" },
.{ "정", "\x42\x0A" },
.{ "젠", "\x46\x0A" },
.{ "젬", "\x48\x0A" },
.{ "죽", "\x75\x0A" },
.{ "쥐", "\x81\x0A" },
.{ "즌", "\x8E\x0A" },
.{ "집", "\x9B\x0A" },
.{ "짓", "\x9C\x0A" },
.{ "짖", "\x9E\x0A" },
.{ "짜", "\xA1\x0A" },
.{ "짝", "\xA2\x0A" },
.{ "째", "\xAC\x0A" },
.{ "쪼", "\xC5\x0A" },
.{ "찍", "\xEB\x0A" },
.{ "찝", "\xEF\x0A" },
.{ "채", "\xFE\x0A" },
.{ "챔", "\x02\x0B" },
.{ "처", "\x0D\x0B" },
.{ "천", "\x0F\x0B" },
.{ "청", "\x15\x0B" },
.{ "쳐", "\x1E\x0B" },
.{ "촙", "\x29\x0B" },
.{ "최", "\x30\x0B" },
.{ "추", "\x39\x0B" },
.{ "축", "\x3A\x0B" },
.{ "출", "\x3C\x0B" },
.{ "춤", "\x3D\x0B" },
.{ "취", "\x45\x0B" },
.{ "칼", "\x66\x0B" },
.{ "커", "\x77\x0B" },
.{ "컬", "\x7B\x0B" },
.{ "컷", "\x7E\x0B" },
.{ "콤", "\x96\x0B" },
.{ "쾌", "\xA0\x0B" },
.{ "퀴", "\xB3\x0B" },
.{ "클", "\xC2\x0B" },
.{ "킥", "\xC7\x0B" },
.{ "탄", "\xD0\x0B" },
.{ "탈", "\xD1\x0B" },
.{ "탐", "\xD3\x0B" },
.{ "택", "\xD9\x0B" },
.{ "털", "\xE6\x0B" },
.{ "텍", "\xEE\x0B" },
.{ "텔", "\xF0\x0B" },
.{ "톰", "\xFE\x0B" },
.{ "튀", "\x16\x0C" },
.{ "튜", "\x1D\x0C" },
.{ "판", "\x3B\x0C" },
.{ "팔", "\x3C\x0C" },
.{ "팩", "\x45\x0C" },
.{ "펀", "\x51\x0C" },
.{ "펌", "\x53\x0C" },
.{ "폰", "\x6D\x0C" },
.{ "품", "\x82\x0C" },
.{ "픔", "\x96\x0C" },
.{ "핀", "\x9B\x0C" },
.{ "필", "\x9C\x0C" },
.{ "할", "\xA4\x0C" },
.{ "핥", "\xA5\x0C" },
.{ "함", "\xA6\x0C" },
.{ "합", "\xA7\x0C" },
.{ "항", "\xA9\x0C" },
.{ "햄", "\xAE\x0C" },
.{ "햇", "\xB0\x0C" },
.{ "향", "\xB4\x0C" },
.{ "혈", "\xC9\x0C" },
.{ "혜", "\xCF\x0C" },
.{ "혹", "\xD4\x0C" },
.{ "혼", "\xD5\x0C" },
.{ "홀", "\xD6\x0C" },
.{ "환", "\xDF\x0C" },
.{ "회", "\xE8\x0C" },
.{ "효", "\xEF\x0C" },
.{ "휘", "\x06\x0D" },
.{ "휩", "\x0B\x0D" },
.{ "흑", "\x16\x0D" },
.{ "흙", "\x1B\x0D" },
.{ "흡", "\x1D\x0D" },
.{ "희", "\x21\x0D" },
.{ "흰", "\x22\x0D" },
.{ "힘", "\x2B\x0D" },
.{ "갤", "\x16\x04" },
.{ "건", "\x27\x04" },
.{ "계", "\x48\x04" },
.{ "과", "\x5A\x04" },
.{ "굵", "\x7B\x04" },
.{ "규", "\x92\x04" },
.{ "급", "\x9C\x04" },
.{ "깁", "\xA7\x04" },
.{ "끈", "\x12\x05" },
.{ "낚", "\x26\x05" },
.{ "낡", "\x2A\x05" },
.{ "남", "\x2C\x05" },
.{ "능", "\xA1\x05" },
.{ "닌", "\xA9\x05" },
.{ "닷", "\xBD\x05" },
.{ "뜨", "\x73\x06" },
.{ "띠", "\x80\x06" },
.{ "랭", "\x9B\x06" },
.{ "뢰", "\xCC\x06" },
.{ "룰", "\xDC\x06" },
.{ "른", "\xF5\x06" },
.{ "맛", "\x10\x07" },
.{ "맞", "\x12\x07" },
.{ "맥", "\x16\x07" },
.{ "맵", "\x1A\x07" },
.{ "멘", "\x30\x07" },
.{ "멜", "\x31\x07" },
.{ "멤", "\x32\x07" },
.{ "백", "\x97\x07" },
.{ "밴", "\x98\x07" },
.{ "병", "\xC0\x07" },
.{ "빨", "\x0B\x08" },
.{ "샘", "\x63\x08" },
.{ "셔", "\x8D\x08" },
.{ "셜", "\x90\x08" },
.{ "쇠", "\xB0\x08" },
.{ "숙", "\xBF\x08" },
.{ "숲", "\xC9\x08" },
.{ "슝", "\xDF\x08" },
.{ "싯", "\xF1\x08" },
.{ "쐐", "\x21\x09" },
.{ "않", "\x4E\x09" },
.{ "약", "\x64\x09" },
.{ "없", "\x7C\x09" },
.{ "있", "\x16\x0A" },
.{ "잔", "\x1C\x0A" },
.{ "잘", "\x1F\x0A" },
.{ "좋", "\x5F\x0A" },
.{ "줄", "\x77\x0A" },
.{ "징", "\x9D\x0A" },
.{ "창", "\xFC\x0A" },
.{ "첩", "\x12\x0B" },
.{ "친", "\x5B\x0B" },
.{ "캄", "\x67\x0B" },
.{ "켓", "\x87\x0B" },
.{ "퀵", "\xB4\x0B" },
.{ "큰", "\xC1\x0B" },
.{ "튼", "\x24\x0C" },
.{ "틀", "\x26\x0C" },
.{ "펙", "\x59\x0C" },
.{ "펜", "\x5A\x0C" },
.{ "편", "\x61\x0C" },
.{ "평", "\x66\x0C" },
.{ "표", "\x77\x0C" },
.{ "푼", "\x7E\x0C" },
.{ "학", "\xA2\x0C" },
.{ "행", "\xB2\x0C" },
.{ "허", "\xB5\x0C" },
.{ "험", "\xBA\x0C" },
.{ "활", "\xE0\x0C" },
.{ "힐", "\x2A\x0D" },
.{ "\n", "\x00\xE0" },
.{ "\\p", "\xBC\x25" },
.{ "\\l", "\xBD\x25" },
};
test "all" {
try rom.encoding.testCharMap(&all, "HELLO WORLD", "\x32\x01\x2F\x01\x36\x01\x36\x01\x39\x01\xDE\x01\x41\x01\x39\x01\x3C\x01\x36\x01\x2E\x01");
}
pub fn encode(str: []const u8, writer: anytype) !void {
try rom.encoding.encode(&all, 0, str, writer);
}
pub fn decode(reader: anytype, writer: anytype) !void {
try rom.encoding.encodeEx(&all, 1, reader, writer);
}
pub fn decode2(in: []const u8, writer: anytype) !void {
try decode(io.fixedBufferStream(in).reader(), writer);
}
|
src/core/gen4/encodings.zig
|
const std = @import("std");
const mem = std.mem;
const LinearFifo = std.fifo.LinearFifo;
const ArrayList = std.ArrayList;
const FuncType = @import("common.zig").FuncType;
const ValueType = @import("common.zig").ValueType;
const Global = @import("common.zig").Global;
const Opcode = @import("opcode.zig").Opcode;
pub const Validator = struct {
op_stack: OperandStack = undefined,
ctrl_stack: ControlStack = undefined,
max_depth: usize = 0,
pub fn init(alloc: *mem.Allocator) Validator {
return Validator{
.op_stack = OperandStack.init(alloc),
.ctrl_stack = ControlStack.init(alloc),
};
}
// TODO: deinit?
pub fn validateBlock(v: *Validator, in_operands: []const ValueType, out_operands: []const ValueType) !void {
try v.popOperands(in_operands);
try v.pushControlFrame(.block, in_operands, out_operands);
}
pub fn validateLoop(v: *Validator, in_operands: []const ValueType, out_operands: []const ValueType) !void {
try v.popOperands(in_operands);
try v.pushControlFrame(.loop, in_operands, out_operands);
}
pub fn validateIf(v: *Validator, in_operands: []const ValueType, out_operands: []const ValueType) !void {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I32 });
try v.popOperands(in_operands);
try v.pushControlFrame(.@"if", in_operands, out_operands);
}
pub fn validateBr(v: *Validator, label: usize) !void {
if (label >= v.ctrl_stack.items.len) return error.ValidateBrInvalidLabel;
const frame = v.ctrl_stack.items[v.ctrl_stack.items.len - 1 - label];
try v.popOperands(labelTypes(frame));
try v.setUnreachable();
}
pub fn validateBrIf(v: *Validator, label: usize) !void {
if (label >= v.ctrl_stack.items.len) return error.ValidateBrIfInvalidLabel;
const frame = v.ctrl_stack.items[v.ctrl_stack.items.len - 1 - label];
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I32 });
try v.popOperands(labelTypes(frame));
try v.pushOperands(labelTypes(frame));
}
pub fn validateBrTable(v: *Validator, n_star: []u32, label: u32) !void {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I32 });
if (label >= v.ctrl_stack.items.len) return error.ValidateBrTableInvalidLabel;
const frame = v.ctrl_stack.items[v.ctrl_stack.items.len - 1 - label];
const arity = labelTypes(frame).len;
for (n_star) |n| {
if (n >= v.ctrl_stack.items.len) return error.ValidateBrTableInvalidLabelN;
const frame_n = v.ctrl_stack.items[v.ctrl_stack.items.len - 1 - n];
if (labelTypes(frame_n).len != arity) return error.ValidateBrTableInvalidLabelWrongArity;
if (!(arity <= 64)) return error.TODOAllocation;
var temp = [_]ValueTypeUnknown{.{ .Known = .I32 }} ** 64; // TODO: allocate some memory for this
for (labelTypes(frame_n)) |_, i| {
temp[i] = try v.popOperandExpecting(ValueTypeUnknown{ .Known = labelTypes(frame_n)[arity - i - 1] });
}
for (labelTypes(frame_n)) |_, i| {
try v.pushOperand(temp[arity - 1 - i]);
}
}
try v.popOperands(labelTypes(frame));
try v.setUnreachable();
}
pub fn validateCall(v: *Validator, func_type: FuncType) !void {
try v.popOperands(func_type.params);
try v.pushOperands(func_type.results);
}
pub fn validateCallIndirect(v: *Validator, func_type: FuncType) !void {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I32 });
try v.popOperands(func_type.params);
try v.pushOperands(func_type.results);
}
pub fn validateLocalGet(v: *Validator, local_type: ValueType) !void {
try v.pushOperand(ValueTypeUnknown{ .Known = local_type });
}
pub fn validateLocalSet(v: *Validator, local_type: ValueType) !void {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = local_type });
}
pub fn validateLocalTee(v: *Validator, local_type: ValueType) !void {
const t = try v.popOperandExpecting(ValueTypeUnknown{ .Known = local_type });
try v.pushOperand(t);
}
pub fn validateGlobalGet(v: *Validator, global: Global) !void {
try v.pushOperand(ValueTypeUnknown{ .Known = global.value_type });
}
pub fn validateGlobalSet(v: *Validator, global: Global) !void {
if (global.mutability == .Immutable) return error.ValidatorAttemptToMutateImmutableGlobal;
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = global.value_type });
}
pub fn validateTrunc(v: *Validator, trunc_type: u32) !void {
switch (trunc_type) {
0, 1 => {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F32 });
try v.pushOperand(ValueTypeUnknown{ .Known = .I32 });
},
2, 3 => {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F64 });
try v.pushOperand(ValueTypeUnknown{ .Known = .I32 });
},
4, 5 => {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F32 });
try v.pushOperand(ValueTypeUnknown{ .Known = .I64 });
},
6, 7 => {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F64 });
try v.pushOperand(ValueTypeUnknown{ .Known = .I64 });
},
else => return error.UnknownTruncType,
}
}
pub fn validate(v: *Validator, opcode: Opcode) !void {
switch (opcode) {
.block,
.loop,
.@"if",
.br,
.br_if,
.br_table,
.call,
.call_indirect,
.@"global.get",
.@"global.set",
.@"local.get",
.@"local.set",
.@"local.tee",
.trunc_sat,
=> {
// These instructions are handle separately
unreachable;
},
.@"unreachable" => try v.setUnreachable(),
.nop => {},
.end => {
const frame = try v.popControlFrame();
_ = try v.pushOperands(frame.end_types);
},
.@"else" => {
const frame = try v.popControlFrame();
if (frame.opcode != .@"if") return error.ElseMustOnlyOccurAfterIf;
try v.pushControlFrame(.@"else", frame.start_types, frame.end_types);
},
.@"return" => {
const frame = v.ctrl_stack.items[0];
try v.popOperands(labelTypes(frame));
try v.setUnreachable();
},
.drop => {
_ = try v.popOperand();
},
.select => {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I32 });
const t1 = try v.popOperand();
const t2 = try v.popOperand();
if (!(isNum(t1) and isNum(t2))) return error.ExpectingBothNum;
if (!valueTypeEqual(t1, t2) and !valueTypeEqual(t1, ValueTypeUnknown.Unknown) and !valueTypeEqual(t2, ValueTypeUnknown.Unknown)) return error.ValidatorSelect;
if (valueTypeEqual(t1, ValueTypeUnknown.Unknown)) {
try v.pushOperand(t2);
} else {
try v.pushOperand(t1);
}
},
.@"memory.size" => {
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .I32 });
},
.@"i32.extend8_s",
.@"i32.extend16_s",
.@"i32.eqz",
.@"memory.grow",
.@"i32.load",
.@"i32.load8_u",
.@"i32.load8_s",
.@"i32.load16_u",
.@"i32.load16_s",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I32 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .I32 });
},
.@"i32.add",
.@"i32.sub",
.@"i32.eq",
.@"i32.ne",
.@"i32.le_s",
.@"i32.le_u",
.@"i32.lt_s",
.@"i32.lt_u",
.@"i32.ge_s",
.@"i32.ge_u",
.@"i32.gt_s",
.@"i32.gt_u",
.@"i32.xor",
.@"i32.and",
.@"i32.div_s",
.@"i32.div_u",
.@"i32.mul",
.@"i32.or",
.@"i32.rem_s",
.@"i32.rem_u",
.@"i32.rotl",
.@"i32.rotr",
.@"i32.shl",
.@"i32.shr_s",
.@"i32.shr_u",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I32 });
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I32 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .I32 });
},
.@"i32.store",
.@"i32.store8",
.@"i32.store16",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I32 });
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I32 });
},
.@"i32.clz", .@"i32.ctz", .@"i32.popcnt" => {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I32 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .I32 });
},
.@"i32.wrap_i64" => {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I64 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .I32 });
},
.@"i32.reinterpret_f32",
.@"i32.trunc_f32_s",
.@"i32.trunc_f32_u",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F32 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .I32 });
},
.@"i32.trunc_f64_s",
.@"i32.trunc_f64_u",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F64 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .I32 });
},
.@"i64.extend8_s",
.@"i64.extend16_s",
.@"i64.extend32_s",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I64 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .I64 });
},
.@"i64.add",
.@"i64.sub",
.@"i64.xor",
.@"i64.and",
.@"i64.div_s",
.@"i64.div_u",
.@"i64.mul",
.@"i64.or",
.@"i64.rem_s",
.@"i64.rem_u",
.@"i64.rotl",
.@"i64.rotr",
.@"i64.shl",
.@"i64.shr_s",
.@"i64.shr_u",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I64 });
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I64 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .I64 });
},
.@"i64.store",
.@"i64.store8",
.@"i64.store16",
.@"i64.store32",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I64 });
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I32 });
},
.@"i64.eq",
.@"i64.ne",
.@"i64.le_s",
.@"i64.le_u",
.@"i64.lt_s",
.@"i64.lt_u",
.@"i64.ge_s",
.@"i64.ge_u",
.@"i64.gt_s",
.@"i64.gt_u",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I64 });
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I64 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .I32 });
},
.@"i64.eqz" => {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I64 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .I32 });
},
.@"i64.clz", .@"i64.ctz", .@"i64.popcnt" => {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I64 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .I64 });
},
.@"i64.load",
.@"i64.load8_s",
.@"i64.load8_u",
.@"i64.load16_s",
.@"i64.load16_u",
.@"i64.load32_s",
.@"i64.load32_u",
.@"i64.extend_i32_s",
.@"i64.extend_i32_u",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I32 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .I64 });
},
.@"i64.trunc_f32_s",
.@"i64.trunc_f32_u",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F32 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .I64 });
},
.@"i64.reinterpret_f64",
.@"i64.trunc_f64_s",
.@"i64.trunc_f64_u",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F64 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .I64 });
},
.@"f32.add",
.@"f32.sub",
.@"f32.mul",
.@"f32.div",
.@"f32.min",
.@"f32.max",
.@"f32.copysign",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F32 });
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F32 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .F32 });
},
.@"f32.abs",
.@"f32.neg",
.@"f32.sqrt",
.@"f32.ceil",
.@"f32.floor",
.@"f32.trunc",
.@"f32.nearest",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F32 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .F32 });
},
.@"f32.eq",
.@"f32.ne",
.@"f32.lt",
.@"f32.le",
.@"f32.gt",
.@"f32.ge",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F32 });
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F32 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .I32 });
},
.@"f32.store" => {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F32 });
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I32 });
},
.@"f32.load",
.@"f32.convert_i32_s",
.@"f32.convert_i32_u",
.@"f32.reinterpret_i32",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I32 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .F32 });
},
.@"f32.demote_f64" => {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F64 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .F32 });
},
.@"f32.convert_i64_s",
.@"f32.convert_i64_u",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I64 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .F32 });
},
.@"f64.add",
.@"f64.sub",
.@"f64.mul",
.@"f64.div",
.@"f64.min",
.@"f64.max",
.@"f64.copysign",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F64 });
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F64 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .F64 });
},
.@"f64.abs",
.@"f64.neg",
.@"f64.sqrt",
.@"f64.ceil",
.@"f64.floor",
.@"f64.trunc",
.@"f64.nearest",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F64 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .F64 });
},
.@"f64.eq",
.@"f64.ne",
.@"f64.lt",
.@"f64.le",
.@"f64.gt",
.@"f64.ge",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F64 });
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F64 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .I32 });
},
.@"f64.store" => {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F64 });
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I32 });
},
.@"f64.load",
.@"f64.convert_i32_s",
.@"f64.convert_i32_u",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I32 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .F64 });
},
.@"f64.reinterpret_i64",
.@"f64.convert_i64_s",
.@"f64.convert_i64_u",
=> {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .I64 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .F64 });
},
.@"f64.promote_f32" => {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = .F32 });
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .F64 });
},
.@"i32.const" => {
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .I32 });
},
.@"i64.const" => {
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .I64 });
},
.@"f32.const" => {
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .F32 });
},
.@"f64.const" => {
_ = try v.pushOperand(ValueTypeUnknown{ .Known = .F64 });
},
}
}
fn pushOperand(v: *Validator, t: ValueTypeUnknown) !void {
defer v.trackMaxDepth();
try v.op_stack.append(t);
}
fn popOperand(v: *Validator) !ValueTypeUnknown {
if (v.ctrl_stack.items.len == 0) return error.ControlStackEmpty;
const ctrl_frame = v.ctrl_stack.items[v.ctrl_stack.items.len - 1];
if (v.op_stack.items.len == ctrl_frame.height and ctrl_frame.unreachable_flag) {
return ValueTypeUnknown.Unknown;
}
if (v.op_stack.items.len == ctrl_frame.height) return error.ValidatorPopOperandError;
return v.op_stack.pop();
}
fn popOperandExpecting(v: *Validator, expected: ValueTypeUnknown) !ValueTypeUnknown {
const actual = try v.popOperand();
const actual_type: ValueType = switch (actual) {
.Unknown => return expected,
.Known => |k| k,
};
const expected_type: ValueType = switch (expected) {
.Unknown => return actual,
.Known => |k| k,
};
if (actual_type != expected_type) return error.MismatchedTypes;
return actual;
}
fn pushOperands(v: *Validator, operands: []const ValueType) !void {
for (operands) |op| {
try v.pushOperand(ValueTypeUnknown{ .Known = op });
}
}
fn popOperands(v: *Validator, operands: []const ValueType) !void {
const len = operands.len;
for (operands) |_, i| {
_ = try v.popOperandExpecting(ValueTypeUnknown{ .Known = operands[len - i - 1] });
}
}
fn trackMaxDepth(v: *Validator) void {
if (v.op_stack.items.len > v.max_depth) {
v.max_depth = v.op_stack.items.len;
}
}
pub fn pushControlFrame(v: *Validator, opcode: Opcode, in: []const ValueType, out: []const ValueType) !void {
const frame = ControlFrame{
.opcode = opcode,
.start_types = in,
.end_types = out,
.height = v.op_stack.items.len,
.unreachable_flag = false,
};
try v.ctrl_stack.append(frame);
try v.pushOperands(in);
}
fn popControlFrame(v: *Validator) !ControlFrame {
// TODO: control stack size check should maybe only be in debug builds
if (v.ctrl_stack.items.len == 0) return error.ValidatorPopControlFrameControlStackEmpty;
const frame = v.ctrl_stack.items[v.ctrl_stack.items.len - 1];
try v.popOperands(frame.end_types);
if (v.op_stack.items.len != frame.height) return error.ValidatorPopControlFrameMismatchedSizes;
_ = v.ctrl_stack.pop();
return frame;
}
fn labelTypes(frame: ControlFrame) []const ValueType {
if (frame.opcode == Opcode.loop) {
return frame.start_types;
} else {
return frame.end_types;
}
}
fn setUnreachable(v: *Validator) !void {
// TODO: control stack size check should maybe only be in debug builds
if (v.ctrl_stack.items.len == 0) return error.ValidatorPopControlFrameControlStackEmpty;
const frame = &v.ctrl_stack.items[v.ctrl_stack.items.len - 1];
v.op_stack.shrinkRetainingCapacity(frame.height);
frame.unreachable_flag = true;
}
};
fn isNum(_: ValueTypeUnknown) bool {
// TODO: for version 1.1 value type may be ref type
// so we'll have to update this:
return true;
}
fn valueTypeEqual(v1: ValueTypeUnknown, v2: ValueTypeUnknown) bool {
switch (v1) {
.Known => |t1| {
switch (v2) {
.Known => |t2| return t1 == t2,
.Unknown => return false,
}
},
.Unknown => {
switch (v2) {
.Known => return false,
.Unknown => return true,
}
},
}
}
const ValueTypeUnknownTag = enum {
Known,
Unknown,
};
const ValueTypeUnknown = union(ValueTypeUnknownTag) {
Known: ValueType,
Unknown: void,
};
const OperandStack = ArrayList(ValueTypeUnknown);
const ControlStack = ArrayList(ControlFrame);
const ControlFrame = struct {
opcode: Opcode = undefined,
start_types: []const ValueType,
end_types: []const ValueType,
height: usize = 0,
unreachable_flag: bool = false,
};
const testing = std.testing;
test "validate add i32" {
const ArenaAllocator = std.heap.ArenaAllocator;
var arena = ArenaAllocator.init(testing.allocator);
defer arena.deinit();
var v = Validator.init(&arena.allocator);
var in: [0]ValueType = [_]ValueType{} ** 0;
var out: [1]ValueType = [_]ValueType{.I32} ** 1;
_ = try v.pushControlFrame(.block, in[0..], out[0..]);
_ = try v.validate(.@"i32.const");
_ = try v.validate(.drop);
_ = try v.validate(.@"i32.const");
_ = try v.validate(.@"i32.const");
_ = try v.validate(.@"i32.add");
_ = try v.validate(.end);
}
test "validate add i64" {
const ArenaAllocator = std.heap.ArenaAllocator;
var arena = ArenaAllocator.init(testing.allocator);
defer arena.deinit();
var v = Validator.init(&arena.allocator);
var in: [0]ValueType = [_]ValueType{} ** 0;
var out: [1]ValueType = [_]ValueType{.I64} ** 1;
_ = try v.pushControlFrame(.block, in[0..], out[0..]);
_ = try v.validate(.@"i64.const");
_ = try v.validate(.@"i64.const");
_ = try v.validate(.@"i64.add");
_ = try v.validate(.end);
}
test "validate add f32" {
const ArenaAllocator = std.heap.ArenaAllocator;
var arena = ArenaAllocator.init(testing.allocator);
defer arena.deinit();
var v = Validator.init(&arena.allocator);
var in: [0]ValueType = [_]ValueType{} ** 0;
var out: [1]ValueType = [_]ValueType{.F32} ** 1;
_ = try v.pushControlFrame(.block, in[0..], out[0..]);
_ = try v.validate(.@"f32.const");
_ = try v.validate(.@"f32.const");
_ = try v.validate(.@"f32.add");
_ = try v.validate(.end);
}
test "validate add f64" {
const ArenaAllocator = std.heap.ArenaAllocator;
var arena = ArenaAllocator.init(testing.allocator);
defer arena.deinit();
var v = Validator.init(&arena.allocator);
var in: [0]ValueType = [_]ValueType{} ** 0;
var out: [1]ValueType = [_]ValueType{.F64} ** 1;
_ = try v.pushControlFrame(.block, in[0..], out[0..]);
_ = try v.validate(.@"f64.const");
_ = try v.validate(.@"f64.const");
_ = try v.validate(.@"f64.add");
_ = try v.validate(.end);
}
test "validate: add error on mismatched types" {
const ArenaAllocator = std.heap.ArenaAllocator;
var arena = ArenaAllocator.init(testing.allocator);
defer arena.deinit();
var v = Validator.init(&arena.allocator);
var in: [0]ValueType = [_]ValueType{} ** 0;
var out: [1]ValueType = [_]ValueType{.I32} ** 1;
_ = try v.pushControlFrame(.block, in[0..], out[0..]);
_ = try v.validate(.@"i64.const");
_ = try v.validate(.@"i32.const");
_ = v.validate(.@"i32.add") catch |err| {
if (err == error.MismatchedTypes) return;
};
return error.ExpectedFailure;
}
|
src/validator.zig
|
const std = @import("std");
const builtin = @import("builtin");
const mem = std.mem;
const expect = std.testing.expect;
const expectEqualStrings = std.testing.expectEqualStrings;
// normal comment
/// this is a documentation comment
/// doc comment line 2
fn emptyFunctionWithComments() void {}
test "empty function with comments" {
emptyFunctionWithComments();
}
test "truncate" {
try expect(testTruncate(0x10fd) == 0xfd);
comptime try expect(testTruncate(0x10fd) == 0xfd);
}
fn testTruncate(x: u32) u8 {
return @truncate(u8, x);
}
test "truncate to non-power-of-two integers" {
try testTrunc(u32, u1, 0b10101, 0b1);
try testTrunc(u32, u1, 0b10110, 0b0);
try testTrunc(u32, u2, 0b10101, 0b01);
try testTrunc(u32, u2, 0b10110, 0b10);
try testTrunc(i32, i5, -4, -4);
try testTrunc(i32, i5, 4, 4);
try testTrunc(i32, i5, -28, 4);
try testTrunc(i32, i5, 28, -4);
try testTrunc(i32, i5, std.math.maxInt(i32), -1);
}
fn testTrunc(comptime Big: type, comptime Little: type, big: Big, little: Little) !void {
try expect(@truncate(Little, big) == little);
}
const g1: i32 = 1233 + 1;
var g2: i32 = 0;
test "global variables" {
try expect(g2 == 0);
g2 = g1;
try expect(g2 == 1234);
}
test "comptime keyword on expressions" {
const x: i32 = comptime x: {
break :x 1 + 2 + 3;
};
try expect(x == comptime 6);
}
test "type equality" {
try expect(*const u8 != *u8);
}
test "pointer dereferencing" {
var x = @as(i32, 3);
const y = &x;
y.* += 1;
try expect(x == 4);
try expect(y.* == 4);
}
test "const expression eval handling of variables" {
var x = true;
while (x) {
x = false;
}
}
test "character literals" {
try expect('\'' == single_quote);
}
const single_quote = '\'';
test "non const ptr to aliased type" {
const int = i32;
try expect(?*int == ?*i32);
}
test "cold function" {
thisIsAColdFn();
comptime thisIsAColdFn();
}
fn thisIsAColdFn() void {
@setCold(true);
}
test "unicode escape in character literal" {
var a: u24 = '\u{01f4a9}';
try expect(a == 128169);
}
test "unicode character in character literal" {
try expect('💩' == 128169);
}
fn first4KeysOfHomeRow() []const u8 {
return "aoeu";
}
test "return string from function" {
try expect(mem.eql(u8, first4KeysOfHomeRow(), "aoeu"));
}
test "hex escape" {
try expect(mem.eql(u8, "\x68\x65\x6c\x6c\x6f", "hello"));
}
test "multiline string" {
const s1 =
\\one
\\two)
\\three
;
const s2 = "one\ntwo)\nthree";
try expect(mem.eql(u8, s1, s2));
}
test "multiline string comments at start" {
const s1 =
//\\one
\\two)
\\three
;
const s2 = "two)\nthree";
try expect(mem.eql(u8, s1, s2));
}
test "multiline string comments at end" {
const s1 =
\\one
\\two)
//\\three
;
const s2 = "one\ntwo)";
try expect(mem.eql(u8, s1, s2));
}
test "multiline string comments in middle" {
const s1 =
\\one
//\\two)
\\three
;
const s2 = "one\nthree";
try expect(mem.eql(u8, s1, s2));
}
test "multiline string comments at multiple places" {
const s1 =
\\one
//\\two
\\three
//\\four
\\five
;
const s2 = "one\nthree\nfive";
try expect(mem.eql(u8, s1, s2));
}
test "string concatenation" {
try expect(mem.eql(u8, "OK" ++ " IT " ++ "WORKED", "OK IT WORKED"));
}
test "array mult operator" {
try expect(mem.eql(u8, "ab" ** 5, "ababababab"));
}
const OpaqueA = opaque {};
const OpaqueB = opaque {};
test "opaque types" {
try expect(*OpaqueA != *OpaqueB);
if (!builtin.zig_is_stage2) {
try expect(mem.eql(u8, @typeName(OpaqueA), "OpaqueA"));
try expect(mem.eql(u8, @typeName(OpaqueB), "OpaqueB"));
}
}
const global_a: i32 = 1234;
const global_b: *const i32 = &global_a;
const global_c: *const f32 = @ptrCast(*const f32, global_b);
test "compile time global reinterpret" {
const d = @ptrCast(*const i32, global_c);
try expect(d.* == 1234);
}
test "cast undefined" {
const array: [100]u8 = undefined;
const slice = @as([]const u8, &array);
testCastUndefined(slice);
}
fn testCastUndefined(x: []const u8) void {
_ = x;
}
test "implicit cast after unreachable" {
try expect(outer() == 1234);
}
fn inner() i32 {
return 1234;
}
fn outer() i64 {
return inner();
}
test "comptime if inside runtime while which unconditionally breaks" {
testComptimeIfInsideRuntimeWhileWhichUnconditionallyBreaks(true);
comptime testComptimeIfInsideRuntimeWhileWhichUnconditionallyBreaks(true);
}
fn testComptimeIfInsideRuntimeWhileWhichUnconditionallyBreaks(cond: bool) void {
while (cond) {
if (false) {}
break;
}
}
test "implicit comptime while" {
while (false) {
@compileError("bad");
}
}
fn fnThatClosesOverLocalConst() type {
const c = 1;
return struct {
fn g() i32 {
return c;
}
};
}
test "function closes over local const" {
const x = fnThatClosesOverLocalConst().g();
try expect(x == 1);
}
test "volatile load and store" {
var number: i32 = 1234;
const ptr = @as(*volatile i32, &number);
ptr.* += 1;
try expect(ptr.* == 1235);
}
fn fA() []const u8 {
return "a";
}
fn fB() []const u8 {
return "b";
}
test "call function pointer in struct" {
try expect(mem.eql(u8, f3(true), "a"));
try expect(mem.eql(u8, f3(false), "b"));
}
fn f3(x: bool) []const u8 {
var wrapper: FnPtrWrapper = .{
.fn_ptr = fB,
};
if (x) {
wrapper.fn_ptr = fA;
}
return wrapper.fn_ptr();
}
const FnPtrWrapper = struct {
fn_ptr: fn () []const u8,
};
test "const ptr from var variable" {
var x: u64 = undefined;
var y: u64 = undefined;
x = 78;
copy(&x, &y);
try expect(x == y);
}
fn copy(src: *const u64, dst: *u64) void {
dst.* = src.*;
}
|
test/behavior/basic.zig
|
const std = @import("../std.zig");
const Allocator = std.mem.Allocator;
const AnyErrorOutStream = std.io.OutStream(anyerror);
/// This allocator is used in front of another allocator and logs to the provided stream
/// on every call to the allocator. Stream errors are ignored.
/// If https://github.com/ziglang/zig/issues/2586 is implemented, this API can be improved.
pub const LoggingAllocator = struct {
allocator: Allocator,
parent_allocator: *Allocator,
out_stream: *AnyErrorOutStream,
const Self = @This();
pub fn init(parent_allocator: *Allocator, out_stream: *AnyErrorOutStream) Self {
return Self{
.allocator = Allocator{
.reallocFn = realloc,
.shrinkFn = shrink,
},
.parent_allocator = parent_allocator,
.out_stream = out_stream,
};
}
fn realloc(allocator: *Allocator, old_mem: []u8, old_align: u29, new_size: usize, new_align: u29) ![]u8 {
const self = @fieldParentPtr(Self, "allocator", allocator);
if (old_mem.len == 0) {
self.out_stream.print("allocation of {} ", .{new_size}) catch {};
} else {
self.out_stream.print("resize from {} to {} ", .{ old_mem.len, new_size }) catch {};
}
const result = self.parent_allocator.reallocFn(self.parent_allocator, old_mem, old_align, new_size, new_align);
if (result) |buff| {
self.out_stream.print("success!\n", .{}) catch {};
} else |err| {
self.out_stream.print("failure!\n", .{}) catch {};
}
return result;
}
fn shrink(allocator: *Allocator, old_mem: []u8, old_align: u29, new_size: usize, new_align: u29) []u8 {
const self = @fieldParentPtr(Self, "allocator", allocator);
const result = self.parent_allocator.shrinkFn(self.parent_allocator, old_mem, old_align, new_size, new_align);
if (new_size == 0) {
self.out_stream.print("free of {} bytes success!\n", .{old_mem.len}) catch {};
} else {
self.out_stream.print("shrink from {} bytes to {} bytes success!\n", .{ old_mem.len, new_size }) catch {};
}
return result;
}
};
test "LoggingAllocator" {
var buf: [255]u8 = undefined;
var slice_stream = std.io.SliceOutStream.init(buf[0..]);
const stream = &slice_stream.stream;
const allocator = &LoggingAllocator.init(std.heap.page_allocator, @ptrCast(*AnyErrorOutStream, stream)).allocator;
const ptr = try allocator.alloc(u8, 10);
allocator.free(ptr);
std.testing.expectEqualSlices(u8,
\\allocation of 10 success!
\\free of 10 bytes success!
\\
, slice_stream.getWritten());
}
|
lib/std/heap/logging_allocator.zig
|
const builtin = @import("builtin");
const clap = @import("../clap.zig");
const std = @import("std");
const args = clap.args;
const testing = std.testing;
const heap = std.heap;
const mem = std.mem;
const os = std.os;
/// The result returned from ::StreamingClap.next
pub fn Arg(comptime Id: type) type {
return struct {
const Self = @This();
param: *const clap.Param(Id),
value: ?[]const u8 = null,
};
}
/// A command line argument parser which, given an ::ArgIterator, will parse arguments according
/// to the ::params. ::StreamingClap parses in an iterating manner, so you have to use a loop together with
/// ::StreamingClap.next to parse all the arguments of your program.
pub fn StreamingClap(comptime Id: type, comptime ArgIterator: type) type {
return struct {
const State = union(enum) {
Normal,
Chaining: Chaining,
const Chaining = struct {
arg: []const u8,
index: usize,
};
};
params: []const clap.Param(Id),
iter: *ArgIterator,
state: State = State.Normal,
/// Get the next ::Arg that matches a ::Param.
pub fn next(parser: *@This()) !?Arg(Id) {
const ArgInfo = struct {
const Kind = enum {
Long,
Short,
Positional,
};
arg: []const u8,
kind: Kind,
};
switch (parser.state) {
.Normal => {
const full_arg = (try parser.iter.next()) orelse return null;
const arg_info = if (mem.eql(u8, full_arg, "--") or mem.eql(u8, full_arg, "-"))
ArgInfo{ .arg = full_arg, .kind = .Positional }
else if (mem.startsWith(u8, full_arg, "--"))
ArgInfo{ .arg = full_arg[2..], .kind = .Long }
else if (mem.startsWith(u8, full_arg, "-"))
ArgInfo{ .arg = full_arg[1..], .kind = .Short }
else
ArgInfo{ .arg = full_arg, .kind = .Positional };
const arg = arg_info.arg;
const kind = arg_info.kind;
const eql_index = mem.indexOfScalar(u8, arg, '=');
switch (kind) {
ArgInfo.Kind.Long => {
for (parser.params) |*param| {
const match = param.names.long orelse continue;
const name = if (eql_index) |i| arg[0..i] else arg;
const maybe_value = if (eql_index) |i| arg[i + 1 ..] else null;
if (!mem.eql(u8, name, match))
continue;
if (!param.takes_value) {
if (maybe_value != null)
return error.DoesntTakeValue;
return Arg(Id){ .param = param };
}
const value = blk: {
if (maybe_value) |v|
break :blk v;
break :blk (try parser.iter.next()) orelse return error.MissingValue;
};
return Arg(Id){ .param = param, .value = value };
}
},
ArgInfo.Kind.Short => {
return try parser.chainging(State.Chaining{
.arg = full_arg,
.index = (full_arg.len - arg.len),
});
},
ArgInfo.Kind.Positional => {
for (parser.params) |*param| {
if (param.names.long) |_|
continue;
if (param.names.short) |_|
continue;
return Arg(Id){ .param = param, .value = arg };
}
},
}
return error.InvalidArgument;
},
.Chaining => |state| return try parser.chainging(state),
}
}
fn chainging(parser: *@This(), state: State.Chaining) !?Arg(Id) {
const arg = state.arg;
const index = state.index;
const next_index = index + 1;
for (parser.params) |*param| {
const short = param.names.short orelse continue;
if (short != arg[index])
continue;
// Before we return, we have to set the new state of the clap
defer {
if (arg.len <= next_index or param.takes_value) {
parser.state = State.Normal;
} else {
parser.state = State{
.Chaining = State.Chaining{
.arg = arg,
.index = next_index,
},
};
}
}
if (!param.takes_value)
return Arg(Id){ .param = param };
if (arg.len <= next_index) {
const value = (try parser.iter.next()) orelse return error.MissingValue;
return Arg(Id){ .param = param, .value = value };
}
if (arg[next_index] == '=')
return Arg(Id){ .param = param, .value = arg[next_index + 1 ..] };
return Arg(Id){ .param = param, .value = arg[next_index..] };
}
return error.InvalidArgument;
}
};
}
fn testNoErr(params: []const clap.Param(u8), args_strings: []const []const u8, results: []const Arg(u8)) void {
var iter = args.SliceIterator{ .args = args_strings };
var c = StreamingClap(u8, args.SliceIterator){
.params = params,
.iter = &iter,
};
for (results) |res| {
const arg = (c.next() catch unreachable) orelse unreachable;
testing.expectEqual(res.param, arg.param);
const expected_value = res.value orelse {
testing.expectEqual(@as(@TypeOf(arg.value), null), arg.value);
continue;
};
const actual_value = arg.value orelse unreachable;
testing.expectEqualSlices(u8, expected_value, actual_value);
}
if (c.next() catch unreachable) |_|
unreachable;
}
test "clap.streaming.StreamingClap: short params" {
const params = [_]clap.Param(u8){
clap.Param(u8){
.id = 0,
.names = clap.Names{ .short = 'a' },
},
clap.Param(u8){
.id = 1,
.names = clap.Names{ .short = 'b' },
},
clap.Param(u8){
.id = 2,
.names = clap.Names{ .short = 'c' },
.takes_value = true,
},
};
const a = ¶ms[0];
const b = ¶ms[1];
const c = ¶ms[2];
testNoErr(
¶ms,
&[_][]const u8{
"-a", "-b", "-ab", "-ba",
"-c", "0", "-c=0", "-ac",
"0", "-ac=0",
},
&[_]Arg(u8){
Arg(u8){ .param = a },
Arg(u8){ .param = b },
Arg(u8){ .param = a },
Arg(u8){ .param = b },
Arg(u8){ .param = b },
Arg(u8){ .param = a },
Arg(u8){ .param = c, .value = "0" },
Arg(u8){ .param = c, .value = "0" },
Arg(u8){ .param = a },
Arg(u8){ .param = c, .value = "0" },
Arg(u8){ .param = a },
Arg(u8){ .param = c, .value = "0" },
},
);
}
test "clap.streaming.StreamingClap: long params" {
const params = [_]clap.Param(u8){
clap.Param(u8){
.id = 0,
.names = clap.Names{ .long = "aa" },
},
clap.Param(u8){
.id = 1,
.names = clap.Names{ .long = "bb" },
},
clap.Param(u8){
.id = 2,
.names = clap.Names{ .long = "cc" },
.takes_value = true,
},
};
const aa = ¶ms[0];
const bb = ¶ms[1];
const cc = ¶ms[2];
testNoErr(
¶ms,
&[_][]const u8{
"--aa", "--bb",
"--cc", "0",
"--cc=0",
},
&[_]Arg(u8){
Arg(u8){ .param = aa },
Arg(u8){ .param = bb },
Arg(u8){ .param = cc, .value = "0" },
Arg(u8){ .param = cc, .value = "0" },
},
);
}
test "clap.streaming.StreamingClap: positional params" {
const params = [_]clap.Param(u8){clap.Param(u8){
.id = 0,
.takes_value = true,
}};
testNoErr(
¶ms,
&[_][]const u8{ "aa", "bb" },
&[_]Arg(u8){
Arg(u8){ .param = ¶ms[0], .value = "aa" },
Arg(u8){ .param = ¶ms[0], .value = "bb" },
},
);
}
test "clap.streaming.StreamingClap: all params" {
const params = [_]clap.Param(u8){
clap.Param(u8){
.id = 0,
.names = clap.Names{
.short = 'a',
.long = "aa",
},
},
clap.Param(u8){
.id = 1,
.names = clap.Names{
.short = 'b',
.long = "bb",
},
},
clap.Param(u8){
.id = 2,
.names = clap.Names{
.short = 'c',
.long = "cc",
},
.takes_value = true,
},
clap.Param(u8){
.id = 3,
.takes_value = true,
},
};
const aa = ¶ms[0];
const bb = ¶ms[1];
const cc = ¶ms[2];
const positional = ¶ms[3];
testNoErr(
¶ms,
&[_][]const u8{
"-a", "-b", "-ab", "-ba",
"-c", "0", "-c=0", "-ac",
"0", "-ac=0", "--aa", "--bb",
"--cc", "0", "--cc=0", "something",
"--", "-",
},
&[_]Arg(u8){
Arg(u8){ .param = aa },
Arg(u8){ .param = bb },
Arg(u8){ .param = aa },
Arg(u8){ .param = bb },
Arg(u8){ .param = bb },
Arg(u8){ .param = aa },
Arg(u8){ .param = cc, .value = "0" },
Arg(u8){ .param = cc, .value = "0" },
Arg(u8){ .param = aa },
Arg(u8){ .param = cc, .value = "0" },
Arg(u8){ .param = aa },
Arg(u8){ .param = cc, .value = "0" },
Arg(u8){ .param = aa },
Arg(u8){ .param = bb },
Arg(u8){ .param = cc, .value = "0" },
Arg(u8){ .param = cc, .value = "0" },
Arg(u8){ .param = positional, .value = "something" },
Arg(u8){ .param = positional, .value = "--" },
Arg(u8){ .param = positional, .value = "-" },
},
);
}
|
clap/streaming.zig
|
const std = @import("std");
const panic = std.debug.panic;
const assert = std.debug.assert;
const L = std.unicode.utf8ToUtf16LeStringLiteral;
const zwin32 = @import("zwin32");
const w32 = zwin32.base;
const dwrite = zwin32.dwrite;
const d2d1 = zwin32.d2d1;
pub const GuiRenderer = @import("GuiRenderer.zig");
pub const vectormath = @import("vectormath.zig");
pub const c = @cImport({
@cDefine("CIMGUI_DEFINE_ENUMS_AND_STRUCTS", "");
@cDefine("CIMGUI_NO_EXPORT", "");
@cInclude("cimgui.h");
@cInclude("cgltf.h");
@cInclude("meshoptimizer.h");
@cInclude("stb_image.h");
});
pub const FrameStats = struct {
time: f64,
delta_time: f32,
fps: f32,
average_cpu_time: f32,
timer: std.time.Timer,
previous_time_ns: u64,
fps_refresh_time_ns: u64,
frame_counter: u64,
pub fn init() FrameStats {
return .{
.time = 0.0,
.delta_time = 0.0,
.fps = 0.0,
.average_cpu_time = 0.0,
.timer = std.time.Timer.start() catch unreachable,
.previous_time_ns = 0,
.fps_refresh_time_ns = 0,
.frame_counter = 0,
};
}
pub fn update(self: *FrameStats, window: w32.HWND, window_name: []const u8) void {
const now_ns = self.timer.read();
self.time = @intToFloat(f64, now_ns) / std.time.ns_per_s;
self.delta_time = @intToFloat(f32, now_ns - self.previous_time_ns) / std.time.ns_per_s;
self.previous_time_ns = now_ns;
if ((now_ns - self.fps_refresh_time_ns) >= std.time.ns_per_s) {
const t = @intToFloat(f64, now_ns - self.fps_refresh_time_ns) / std.time.ns_per_s;
const fps = @intToFloat(f64, self.frame_counter) / t;
const ms = (1.0 / fps) * 1000.0;
self.fps = @floatCast(f32, fps);
self.average_cpu_time = @floatCast(f32, ms);
self.fps_refresh_time_ns = now_ns;
self.frame_counter = 0;
}
self.frame_counter += 1;
{
var buffer = [_]u8{0} ** 128;
const text = std.fmt.bufPrint(
buffer[0..],
"FPS: {d:.1} CPU time: {d:.3} ms | {s}",
.{ self.fps, self.average_cpu_time, window_name },
) catch unreachable;
_ = w32.SetWindowTextA(window, @ptrCast([*:0]const u8, text.ptr));
}
}
};
fn processWindowMessage(
window: w32.HWND,
message: w32.UINT,
wparam: w32.WPARAM,
lparam: w32.LPARAM,
) callconv(w32.WINAPI) w32.LRESULT {
assert(c.igGetCurrentContext() != null);
var ui = c.igGetIO().?;
var ui_backend = @ptrCast(*GuiBackendState, @alignCast(8, ui.*.BackendPlatformUserData));
switch (message) {
w32.user32.WM_LBUTTONDOWN,
w32.user32.WM_RBUTTONDOWN,
w32.user32.WM_MBUTTONDOWN,
w32.user32.WM_LBUTTONDBLCLK,
w32.user32.WM_RBUTTONDBLCLK,
w32.user32.WM_MBUTTONDBLCLK,
=> {
var button: u32 = 0;
if (message == w32.user32.WM_LBUTTONDOWN or message == w32.user32.WM_LBUTTONDBLCLK) button = 0;
if (message == w32.user32.WM_RBUTTONDOWN or message == w32.user32.WM_RBUTTONDBLCLK) button = 1;
if (message == w32.user32.WM_MBUTTONDOWN or message == w32.user32.WM_MBUTTONDBLCLK) button = 2;
if (ui_backend.*.mouse_buttons_down == 0 and w32.GetCapture() == null) {
_ = w32.SetCapture(window);
}
ui_backend.*.mouse_buttons_down |= @as(u32, 1) << @intCast(u5, button);
c.ImGuiIO_AddMouseButtonEvent(ui, @intCast(i32, button), true);
},
w32.user32.WM_LBUTTONUP,
w32.user32.WM_RBUTTONUP,
w32.user32.WM_MBUTTONUP,
=> {
var button: u32 = 0;
if (message == w32.user32.WM_LBUTTONUP) button = 0;
if (message == w32.user32.WM_RBUTTONUP) button = 1;
if (message == w32.user32.WM_MBUTTONUP) button = 2;
ui_backend.*.mouse_buttons_down &= ~(@as(u32, 1) << @intCast(u5, button));
if (ui_backend.*.mouse_buttons_down == 0 and w32.GetCapture() == window) {
_ = w32.ReleaseCapture();
}
c.ImGuiIO_AddMouseButtonEvent(ui, @intCast(i32, button), false);
},
w32.user32.WM_MOUSEWHEEL => {
c.ImGuiIO_AddMouseWheelEvent(
ui,
0.0,
@intToFloat(f32, w32.GET_WHEEL_DELTA_WPARAM(wparam)) / @intToFloat(f32, w32.WHEEL_DELTA),
);
},
w32.user32.WM_MOUSEMOVE => {
ui_backend.*.mouse_window = window;
if (ui_backend.*.mouse_tracked == false) {
var tme = w32.TRACKMOUSEEVENT{
.cbSize = @sizeOf(w32.TRACKMOUSEEVENT),
.dwFlags = w32.TME_LEAVE,
.hwndTrack = window,
.dwHoverTime = 0,
};
_ = w32.TrackMouseEvent(&tme);
ui_backend.*.mouse_tracked = true;
}
c.ImGuiIO_AddMousePosEvent(
ui,
@intToFloat(f32, w32.GET_X_LPARAM(lparam)),
@intToFloat(f32, w32.GET_Y_LPARAM(lparam)),
);
},
w32.user32.WM_MOUSELEAVE => {
if (ui_backend.*.mouse_window == window) {
ui_backend.*.mouse_window = null;
}
ui_backend.*.mouse_tracked = false;
c.ImGuiIO_AddMousePosEvent(ui, -c.igGET_FLT_MAX(), -c.igGET_FLT_MAX());
},
w32.user32.WM_KEYDOWN,
w32.user32.WM_KEYUP,
w32.user32.WM_SYSKEYDOWN,
w32.user32.WM_SYSKEYUP,
=> {
if (wparam == w32.VK_ESCAPE) {
w32.user32.PostQuitMessage(0);
}
const down = if (message == w32.user32.WM_KEYDOWN or message == w32.user32.WM_SYSKEYDOWN) true else false;
if (wparam < 256) {
c.ImGuiIO_AddKeyEvent(ui, c.ImGuiKey_ModCtrl, isVkKeyDown(w32.VK_CONTROL));
c.ImGuiIO_AddKeyEvent(ui, c.ImGuiKey_ModShift, isVkKeyDown(w32.VK_SHIFT));
c.ImGuiIO_AddKeyEvent(ui, c.ImGuiKey_ModAlt, isVkKeyDown(w32.VK_MENU));
c.ImGuiIO_AddKeyEvent(ui, c.ImGuiKey_ModSuper, isVkKeyDown(w32.VK_APPS));
var vk = @intCast(i32, wparam);
if (wparam == w32.VK_RETURN and (((lparam >> 16) & 0xffff) & w32.KF_EXTENDED) != 0) {
vk = w32.IM_VK_KEYPAD_ENTER;
}
const key = vkKeyToImGuiKey(wparam);
if (key != c.ImGuiKey_None)
c.ImGuiIO_AddKeyEvent(ui, key, down);
if (vk == w32.VK_SHIFT) {
if (isVkKeyDown(w32.VK_LSHIFT) == down)
c.ImGuiIO_AddKeyEvent(ui, c.ImGuiKey_LeftShift, down);
if (isVkKeyDown(w32.VK_RSHIFT) == down)
c.ImGuiIO_AddKeyEvent(ui, c.ImGuiKey_RightShift, down);
} else if (vk == w32.VK_CONTROL) {
if (isVkKeyDown(w32.VK_LCONTROL) == down)
c.ImGuiIO_AddKeyEvent(ui, c.ImGuiKey_LeftCtrl, down);
if (isVkKeyDown(w32.VK_RCONTROL) == down)
c.ImGuiIO_AddKeyEvent(ui, c.ImGuiKey_RightCtrl, down);
} else if (vk == w32.VK_MENU) {
if (isVkKeyDown(w32.VK_LMENU) == down)
c.ImGuiIO_AddKeyEvent(ui, c.ImGuiKey_LeftAlt, down);
if (isVkKeyDown(w32.VK_RMENU) == down)
c.ImGuiIO_AddKeyEvent(ui, c.ImGuiKey_RightAlt, down);
}
}
},
w32.user32.WM_SETFOCUS,
w32.user32.WM_KILLFOCUS,
=> {
c.ImGuiIO_AddFocusEvent(ui, if (message == w32.user32.WM_SETFOCUS) true else false);
},
w32.user32.WM_CHAR => {
if (wparam > 0 and wparam < 0x10000) {
c.ImGuiIO_AddInputCharacterUTF16(ui, @intCast(u16, wparam & 0xffff));
}
},
w32.user32.WM_DESTROY => {
w32.user32.PostQuitMessage(0);
},
else => {
return w32.user32.defWindowProcA(window, message, wparam, lparam);
},
}
return 0;
}
const GuiBackendState = struct {
window: ?w32.HWND,
mouse_window: ?w32.HWND,
mouse_tracked: bool,
mouse_buttons_down: u32,
};
pub fn initWindow(allocator: std.mem.Allocator, name: [*:0]const u8, width: u32, height: u32) !w32.HWND {
assert(c.igGetCurrentContext() == null);
_ = c.igCreateContext(null);
var ui = c.igGetIO().?;
assert(ui.*.BackendPlatformUserData == null);
const ui_backend = allocator.create(GuiBackendState) catch unreachable;
errdefer allocator.destroy(ui_backend);
ui_backend.* = .{
.window = null,
.mouse_window = null,
.mouse_tracked = false,
.mouse_buttons_down = 0,
};
ui.*.BackendPlatformUserData = ui_backend;
ui.*.BackendFlags |= c.ImGuiBackendFlags_RendererHasVtxOffset;
const winclass = w32.user32.WNDCLASSEXA{
.style = 0,
.lpfnWndProc = processWindowMessage,
.cbClsExtra = 0,
.cbWndExtra = 0,
.hInstance = @ptrCast(w32.HINSTANCE, w32.kernel32.GetModuleHandleW(null)),
.hIcon = null,
.hCursor = w32.LoadCursorA(null, @intToPtr(w32.LPCSTR, 32512)),
.hbrBackground = null,
.lpszMenuName = null,
.lpszClassName = name,
.hIconSm = null,
};
_ = try w32.user32.registerClassExA(&winclass);
const style = w32.user32.WS_OVERLAPPED +
w32.user32.WS_SYSMENU +
w32.user32.WS_CAPTION +
w32.user32.WS_MINIMIZEBOX;
var rect = w32.RECT{ .left = 0, .top = 0, .right = @intCast(i32, width), .bottom = @intCast(i32, height) };
// HACK(mziulek): For exact FullHD window size it is better to stick to requested total window size
// (looks better on 1920x1080 displays).
if (width != 1920 and height != 1080) {
try w32.user32.adjustWindowRectEx(&rect, style, false, 0);
}
const window = try w32.user32.createWindowExA(
0,
name,
name,
style + w32.user32.WS_VISIBLE,
-1,
-1,
rect.right - rect.left,
rect.bottom - rect.top,
null,
null,
winclass.hInstance,
null,
);
ui_backend.*.window = window;
c.igGetStyle().?.*.WindowRounding = 0.0;
return window;
}
pub fn deinitWindow(allocator: std.mem.Allocator) void {
var ui = c.igGetIO().?;
assert(ui.*.BackendPlatformUserData != null);
allocator.destroy(@ptrCast(*GuiBackendState, @alignCast(@sizeOf(usize), ui.*.BackendPlatformUserData)));
c.igDestroyContext(null);
}
pub fn handleWindowEvents() bool {
var message = std.mem.zeroes(w32.user32.MSG);
while (w32.user32.peekMessageA(&message, null, 0, 0, w32.user32.PM_REMOVE) catch false) {
_ = w32.user32.translateMessage(&message);
_ = w32.user32.dispatchMessageA(&message);
if (message.message == w32.user32.WM_QUIT) {
return false;
}
}
return true;
}
fn isVkKeyDown(vk: c_int) bool {
return (@bitCast(u16, w32.GetKeyState(vk)) & 0x8000) != 0;
}
fn vkKeyToImGuiKey(wparam: w32.WPARAM) c.ImGuiKey {
switch (wparam) {
w32.VK_TAB => return c.ImGuiKey_Tab,
w32.VK_LEFT => return c.ImGuiKey_LeftArrow,
w32.VK_RIGHT => return c.ImGuiKey_RightArrow,
w32.VK_UP => return c.ImGuiKey_UpArrow,
w32.VK_DOWN => return c.ImGuiKey_DownArrow,
w32.VK_PRIOR => return c.ImGuiKey_PageUp,
w32.VK_NEXT => return c.ImGuiKey_PageDown,
w32.VK_HOME => return c.ImGuiKey_Home,
w32.VK_END => return c.ImGuiKey_End,
w32.VK_INSERT => return c.ImGuiKey_Insert,
w32.VK_DELETE => return c.ImGuiKey_Delete,
w32.VK_BACK => return c.ImGuiKey_Backspace,
w32.VK_SPACE => return c.ImGuiKey_Space,
w32.VK_RETURN => return c.ImGuiKey_Enter,
w32.VK_ESCAPE => return c.ImGuiKey_Escape,
w32.VK_OEM_7 => return c.ImGuiKey_Apostrophe,
w32.VK_OEM_COMMA => return c.ImGuiKey_Comma,
w32.VK_OEM_MINUS => return c.ImGuiKey_Minus,
w32.VK_OEM_PERIOD => return c.ImGuiKey_Period,
w32.VK_OEM_2 => return c.ImGuiKey_Slash,
w32.VK_OEM_1 => return c.ImGuiKey_Semicolon,
w32.VK_OEM_PLUS => return c.ImGuiKey_Equal,
w32.VK_OEM_4 => return c.ImGuiKey_LeftBracket,
w32.VK_OEM_5 => return c.ImGuiKey_Backslash,
w32.VK_OEM_6 => return c.ImGuiKey_RightBracket,
w32.VK_OEM_3 => return c.ImGuiKey_GraveAccent,
w32.VK_CAPITAL => return c.ImGuiKey_CapsLock,
w32.VK_SCROLL => return c.ImGuiKey_ScrollLock,
w32.VK_NUMLOCK => return c.ImGuiKey_NumLock,
w32.VK_SNAPSHOT => return c.ImGuiKey_PrintScreen,
w32.VK_PAUSE => return c.ImGuiKey_Pause,
w32.VK_NUMPAD0 => return c.ImGuiKey_Keypad0,
w32.VK_NUMPAD1 => return c.ImGuiKey_Keypad1,
w32.VK_NUMPAD2 => return c.ImGuiKey_Keypad2,
w32.VK_NUMPAD3 => return c.ImGuiKey_Keypad3,
w32.VK_NUMPAD4 => return c.ImGuiKey_Keypad4,
w32.VK_NUMPAD5 => return c.ImGuiKey_Keypad5,
w32.VK_NUMPAD6 => return c.ImGuiKey_Keypad6,
w32.VK_NUMPAD7 => return c.ImGuiKey_Keypad7,
w32.VK_NUMPAD8 => return c.ImGuiKey_Keypad8,
w32.VK_NUMPAD9 => return c.ImGuiKey_Keypad9,
w32.VK_DECIMAL => return c.ImGuiKey_KeypadDecimal,
w32.VK_DIVIDE => return c.ImGuiKey_KeypadDivide,
w32.VK_MULTIPLY => return c.ImGuiKey_KeypadMultiply,
w32.VK_SUBTRACT => return c.ImGuiKey_KeypadSubtract,
w32.VK_ADD => return c.ImGuiKey_KeypadAdd,
w32.IM_VK_KEYPAD_ENTER => return c.ImGuiKey_KeypadEnter,
w32.VK_LSHIFT => return c.ImGuiKey_LeftShift,
w32.VK_LCONTROL => return c.ImGuiKey_LeftCtrl,
w32.VK_LMENU => return c.ImGuiKey_LeftAlt,
w32.VK_LWIN => return c.ImGuiKey_LeftSuper,
w32.VK_RSHIFT => return c.ImGuiKey_RightShift,
w32.VK_RCONTROL => return c.ImGuiKey_RightCtrl,
w32.VK_RMENU => return c.ImGuiKey_RightAlt,
w32.VK_RWIN => return c.ImGuiKey_RightSuper,
w32.VK_APPS => return c.ImGuiKey_Menu,
'0' => return c.ImGuiKey_0,
'1' => return c.ImGuiKey_1,
'2' => return c.ImGuiKey_2,
'3' => return c.ImGuiKey_3,
'4' => return c.ImGuiKey_4,
'5' => return c.ImGuiKey_5,
'6' => return c.ImGuiKey_6,
'7' => return c.ImGuiKey_7,
'8' => return c.ImGuiKey_8,
'9' => return c.ImGuiKey_9,
'A' => return c.ImGuiKey_A,
'B' => return c.ImGuiKey_B,
'C' => return c.ImGuiKey_C,
'D' => return c.ImGuiKey_D,
'E' => return c.ImGuiKey_E,
'F' => return c.ImGuiKey_F,
'G' => return c.ImGuiKey_G,
'H' => return c.ImGuiKey_H,
'I' => return c.ImGuiKey_I,
'J' => return c.ImGuiKey_J,
'K' => return c.ImGuiKey_K,
'L' => return c.ImGuiKey_L,
'M' => return c.ImGuiKey_M,
'N' => return c.ImGuiKey_N,
'O' => return c.ImGuiKey_O,
'P' => return c.ImGuiKey_P,
'Q' => return c.ImGuiKey_Q,
'R' => return c.ImGuiKey_R,
'S' => return c.ImGuiKey_S,
'T' => return c.ImGuiKey_T,
'U' => return c.ImGuiKey_U,
'V' => return c.ImGuiKey_V,
'W' => return c.ImGuiKey_W,
'X' => return c.ImGuiKey_X,
'Y' => return c.ImGuiKey_Y,
'Z' => return c.ImGuiKey_Z,
w32.VK_F1 => return c.ImGuiKey_F1,
w32.VK_F2 => return c.ImGuiKey_F2,
w32.VK_F3 => return c.ImGuiKey_F3,
w32.VK_F4 => return c.ImGuiKey_F4,
w32.VK_F5 => return c.ImGuiKey_F5,
w32.VK_F6 => return c.ImGuiKey_F6,
w32.VK_F7 => return c.ImGuiKey_F7,
w32.VK_F8 => return c.ImGuiKey_F8,
w32.VK_F9 => return c.ImGuiKey_F9,
w32.VK_F10 => return c.ImGuiKey_F10,
w32.VK_F11 => return c.ImGuiKey_F11,
w32.VK_F12 => return c.ImGuiKey_F12,
else => return c.ImGuiKey_None,
}
}
pub fn newImGuiFrame(delta_time: f32) void {
assert(c.igGetCurrentContext() != null);
var ui = c.igGetIO().?;
var ui_backend = @ptrCast(*GuiBackendState, @alignCast(@sizeOf(usize), ui.*.BackendPlatformUserData));
assert(ui_backend.*.window != null);
var rect: w32.RECT = undefined;
_ = w32.GetClientRect(ui_backend.*.window.?, &rect);
const viewport_width = @intToFloat(f32, rect.right - rect.left);
const viewport_height = @intToFloat(f32, rect.bottom - rect.top);
ui.*.DisplaySize = c.ImVec2{ .x = viewport_width, .y = viewport_height };
ui.*.DeltaTime = delta_time;
c.igNewFrame();
if (c.igIsKeyDown(c.ImGuiKey_LeftShift) and !isVkKeyDown(w32.VK_LSHIFT)) {
c.ImGuiIO_AddKeyEvent(ui, c.ImGuiKey_LeftShift, false);
}
if (c.igIsKeyDown(c.ImGuiKey_RightShift) and !isVkKeyDown(w32.VK_RSHIFT)) {
c.ImGuiIO_AddKeyEvent(ui, c.ImGuiKey_RightShift, false);
}
if (c.igIsKeyDown(c.ImGuiKey_LeftSuper) and !isVkKeyDown(w32.VK_LWIN)) {
c.ImGuiIO_AddKeyEvent(ui, c.ImGuiKey_LeftSuper, false);
}
if (c.igIsKeyDown(c.ImGuiKey_LeftSuper) and !isVkKeyDown(w32.VK_RWIN)) {
c.ImGuiIO_AddKeyEvent(ui, c.ImGuiKey_RightSuper, false);
}
}
pub fn drawText(
devctx: *d2d1.IDeviceContext6,
text: []const u8,
format: *dwrite.ITextFormat,
layout_rect: *const d2d1.RECT_F,
brush: *d2d1.IBrush,
) void {
var utf16: [128:0]u16 = undefined;
assert(text.len < utf16.len);
const len = std.unicode.utf8ToUtf16Le(utf16[0..], text) catch unreachable;
utf16[len] = 0;
devctx.DrawText(
&utf16,
@intCast(u32, len),
format,
layout_rect,
brush,
d2d1.DRAW_TEXT_OPTIONS_NONE,
.NATURAL,
);
}
pub fn init() void {
_ = w32.ole32.CoInitializeEx(
null,
@enumToInt(w32.COINIT_APARTMENTTHREADED) | @enumToInt(w32.COINIT_DISABLE_OLE1DDE),
);
_ = w32.SetProcessDPIAware();
// Check if Windows version is supported.
var version: w32.OSVERSIONINFOW = undefined;
_ = w32.ntdll.RtlGetVersion(&version);
var os_is_supported = false;
if (version.dwMajorVersion > 10) {
os_is_supported = true;
} else if (version.dwMajorVersion == 10 and version.dwBuildNumber >= 18363) {
os_is_supported = true;
}
const d3d12core_dll = w32.kernel32.LoadLibraryW(L("D3D12Core.dll"));
if (d3d12core_dll == null) {
os_is_supported = false;
} else {
_ = w32.kernel32.FreeLibrary(d3d12core_dll.?);
}
if (!os_is_supported) {
_ = w32.user32.messageBoxA(
null,
\\This application can't run on currently installed version of Windows.
\\Following versions are supported:
\\
\\Windows 10 May 2021 (Build 19043) or newer
\\Windows 10 October 2020 (Build 19042.789+)
\\Windows 10 May 2020 (Build 19041.789+)
\\Windows 10 November 2019 (Build 18363.1350+)
\\
\\Please update your Windows version and try again.
,
"Error",
w32.user32.MB_OK | w32.user32.MB_ICONERROR,
) catch 0;
w32.kernel32.ExitProcess(0);
}
// Change directory to where an executable is located.
var exe_path_buffer: [1024]u8 = undefined;
const exe_path = std.fs.selfExeDirPath(exe_path_buffer[0..]) catch "./";
std.os.chdir(exe_path) catch {};
// Check if 'd3d12' folder is present next to an executable.
const local_d3d12core_dll = w32.kernel32.LoadLibraryW(L("d3d12/D3D12Core.dll"));
if (local_d3d12core_dll == null) {
_ = w32.user32.messageBoxA(
null,
\\Looks like 'd3d12' folder is missing. It has to be distributed together with an application.
,
"Error",
w32.user32.MB_OK | w32.user32.MB_ICONERROR,
) catch 0;
w32.kernel32.ExitProcess(0);
} else {
_ = w32.kernel32.FreeLibrary(local_d3d12core_dll.?);
}
}
pub fn deinit() void {
w32.ole32.CoUninitialize();
}
pub fn parseAndLoadGltfFile(gltf_path: []const u8) *c.cgltf_data {
var data: *c.cgltf_data = undefined;
const options = std.mem.zeroes(c.cgltf_options);
// Parse.
{
const result = c.cgltf_parse_file(&options, gltf_path.ptr, @ptrCast([*c][*c]c.cgltf_data, &data));
assert(result == c.cgltf_result_success);
}
// Load.
{
const result = c.cgltf_load_buffers(&options, data, gltf_path.ptr);
assert(result == c.cgltf_result_success);
}
return data;
}
pub fn appendMeshPrimitive(
data: *c.cgltf_data,
mesh_index: u32,
prim_index: u32,
indices: *std.ArrayList(u32),
positions: *std.ArrayList([3]f32),
normals: ?*std.ArrayList([3]f32),
texcoords0: ?*std.ArrayList([2]f32),
tangents: ?*std.ArrayList([4]f32),
) void {
assert(mesh_index < data.meshes_count);
assert(prim_index < data.meshes[mesh_index].primitives_count);
const num_vertices: u32 = @intCast(u32, data.meshes[mesh_index].primitives[prim_index].attributes[0].data.*.count);
const num_indices: u32 = @intCast(u32, data.meshes[mesh_index].primitives[prim_index].indices.*.count);
// Indices.
{
indices.ensureTotalCapacity(indices.items.len + num_indices) catch unreachable;
const accessor = data.meshes[mesh_index].primitives[prim_index].indices;
assert(accessor.*.buffer_view != null);
assert(accessor.*.stride == accessor.*.buffer_view.*.stride or accessor.*.buffer_view.*.stride == 0);
assert((accessor.*.stride * accessor.*.count) == accessor.*.buffer_view.*.size);
assert(accessor.*.buffer_view.*.buffer.*.data != null);
const data_addr = @alignCast(4, @ptrCast([*]const u8, accessor.*.buffer_view.*.buffer.*.data) +
accessor.*.offset + accessor.*.buffer_view.*.offset);
if (accessor.*.stride == 1) {
assert(accessor.*.component_type == c.cgltf_component_type_r_8u);
const src = @ptrCast([*]const u8, data_addr);
var i: u32 = 0;
while (i < num_indices) : (i += 1) {
indices.appendAssumeCapacity(src[i]);
}
} else if (accessor.*.stride == 2) {
assert(accessor.*.component_type == c.cgltf_component_type_r_16u);
const src = @ptrCast([*]const u16, data_addr);
var i: u32 = 0;
while (i < num_indices) : (i += 1) {
indices.appendAssumeCapacity(src[i]);
}
} else if (accessor.*.stride == 4) {
assert(accessor.*.component_type == c.cgltf_component_type_r_32u);
const src = @ptrCast([*]const u32, data_addr);
var i: u32 = 0;
while (i < num_indices) : (i += 1) {
indices.appendAssumeCapacity(src[i]);
}
} else {
unreachable;
}
}
// Attributes.
{
positions.resize(positions.items.len + num_vertices) catch unreachable;
if (normals != null) normals.?.resize(normals.?.items.len + num_vertices) catch unreachable;
if (texcoords0 != null) texcoords0.?.resize(texcoords0.?.items.len + num_vertices) catch unreachable;
if (tangents != null) tangents.?.resize(tangents.?.items.len + num_vertices) catch unreachable;
const num_attribs: u32 = @intCast(u32, data.meshes[mesh_index].primitives[prim_index].attributes_count);
var attrib_index: u32 = 0;
while (attrib_index < num_attribs) : (attrib_index += 1) {
const attrib = &data.meshes[mesh_index].primitives[prim_index].attributes[attrib_index];
const accessor = attrib.data;
assert(accessor.*.buffer_view != null);
assert(accessor.*.stride == accessor.*.buffer_view.*.stride or accessor.*.buffer_view.*.stride == 0);
assert((accessor.*.stride * accessor.*.count) == accessor.*.buffer_view.*.size);
assert(accessor.*.buffer_view.*.buffer.*.data != null);
const data_addr = @ptrCast([*]const u8, accessor.*.buffer_view.*.buffer.*.data) +
accessor.*.offset + accessor.*.buffer_view.*.offset;
if (attrib.*.type == c.cgltf_attribute_type_position) {
assert(accessor.*.type == c.cgltf_type_vec3);
assert(accessor.*.component_type == c.cgltf_component_type_r_32f);
@memcpy(
@ptrCast([*]u8, &positions.items[positions.items.len - num_vertices]),
data_addr,
accessor.*.count * accessor.*.stride,
);
} else if (attrib.*.type == c.cgltf_attribute_type_normal and normals != null) {
assert(accessor.*.type == c.cgltf_type_vec3);
assert(accessor.*.component_type == c.cgltf_component_type_r_32f);
@memcpy(
@ptrCast([*]u8, &normals.?.items[normals.?.items.len - num_vertices]),
data_addr,
accessor.*.count * accessor.*.stride,
);
} else if (attrib.*.type == c.cgltf_attribute_type_texcoord and texcoords0 != null) {
assert(accessor.*.type == c.cgltf_type_vec2);
assert(accessor.*.component_type == c.cgltf_component_type_r_32f);
@memcpy(
@ptrCast([*]u8, &texcoords0.?.items[texcoords0.?.items.len - num_vertices]),
data_addr,
accessor.*.count * accessor.*.stride,
);
} else if (attrib.*.type == c.cgltf_attribute_type_tangent and tangents != null) {
assert(accessor.*.type == c.cgltf_type_vec4);
assert(accessor.*.component_type == c.cgltf_component_type_r_32f);
@memcpy(
@ptrCast([*]u8, &tangents.?.items[tangents.?.items.len - num_vertices]),
data_addr,
accessor.*.count * accessor.*.stride,
);
}
}
}
}
|
libs/common/src/common.zig
|
const std = @import("std");
const sdl = @import("sdl2");
const Texture = @import("Texture.zig");
const font_franklin = @embedFile("franklin.bmp");
pub const ContextError = error{
InitError,
WindowError,
RendererError,
TextureError,
};
const Context = @This();
window: sdl.Window,
render: sdl.Renderer,
font: sdl.Texture,
offset: struct {
x: f32 = 0,
y: f32 = 0,
z: i32 = 8,
} = .{},
const HintDotsCount = 10;
pub fn init() !Context {
// SDL2 init
try sdl.init(.{ .events = true });
try sdl.image.init(.{ .png = true, .jpg = true });
errdefer sdl.quit();
errdefer sdl.image.quit();
const wflags = sdl.WindowFlags{
.resizable = true,
};
const pos = sdl.WindowPosition.default;
const window = try sdl.createWindow("gert's crochet helper", pos, pos, 1000, 600, wflags);
errdefer window.destroy();
const renderer = sdl.createRenderer(window, null, .{}) catch try sdl.createRenderer(window, null, .{ .software = true });
errdefer renderer.destroy();
const fsurf = try sdl.loadBmpFromConstMem(font_franklin);
defer fsurf.destroy();
try fsurf.setColorKey(true, sdl.Color.magenta);
const ftexture = try sdl.createTextureFromSurface(renderer, fsurf);
return Context{
.window = window,
.render = renderer,
.font = ftexture,
};
}
pub fn deinit(self: Context) void {
self.render.destroy();
self.window.destroy();
sdl.image.quit();
sdl.quit();
}
//////////////////
// FONT DRAWING //
//////////////////
pub fn print_slice(self: Context, str: []const u8, x: i32, y: i32) void {
var ox: i32 = x;
var oy: i32 = y;
for (str) |char| {
if (char == '\n') {
ox = x;
oy += 32;
continue;
} else {
const cx = @intCast(i32, char % 16) * 32;
const cy = @intCast(i32, char / 16) * 32;
const srcRect = sdl.Rectangle{
.x = cx,
.y = cy,
.width = 32,
.height = 32,
};
const dstRect = sdl.Rectangle{
.x = ox,
.y = oy,
.width = 32,
.height = 32,
};
self.render.copy(self.font, dstRect, srcRect) catch {};
}
ox += 18;
}
}
/////////////////////
// REGUALR DRAWING //
/////////////////////
pub fn clear(self: Context) void {
self.render.setColor(sdl.Color.black) catch {};
self.render.clear() catch {};
}
pub fn swap(self: Context) void {
self.render.present();
}
fn set_inverse_color(self: Context, texture: Texture, x: usize, y: usize) void {
const pos = x + y * texture.width;
const pixel = texture.pixel_at_index(pos);
const r = 255 - pixel[0];
const g = 255 - pixel[1];
const b = 255 - pixel[2];
self.render.setColorRGB(r, g, b) catch {};
}
pub fn draw_all(self: Context, texture: Texture, progress: usize) void {
// draw texture
const drawRect = sdl.Rectangle{
.x = @floatToInt(i32, self.offset.x),
.y = @floatToInt(i32, self.offset.y),
.width = @intCast(i32, texture.width) * self.offset.z,
.height = @intCast(i32, texture.height) * self.offset.z,
};
self.render.copy(texture.handle, drawRect, null) catch {};
// draw fully complete lines
self.render.setColor(sdl.Color.red) catch {};
var fullLines: usize = progress / texture.width;
while (fullLines > 0) : (fullLines -= 1) {
const x = @floatToInt(c_int, self.offset.x);
const y = @floatToInt(c_int, self.offset.y) + @intCast(c_int, fullLines) * self.offset.z - @divTrunc(self.offset.z, 2);
const maxX = @intCast(c_int, texture.width) * self.offset.z;
self.render.drawLine(x, y, x + maxX, y) catch {};
}
// draw progress
self.render.setColorRGB(0xFF, 0, 0x7F) catch {};
const y = progress / texture.width;
if (y >= texture.height) {
return;
}
const x = progress % texture.width;
const oy = @floatToInt(c_int, self.offset.y) + @intCast(c_int, y) * self.offset.z + @divTrunc(self.offset.z, 2);
if (y & 1 == 0) {
// left to right
const ox = @floatToInt(c_int, self.offset.x) + @intCast(c_int, x) * self.offset.z;
self.render.drawLine(@floatToInt(i32, self.offset.x), oy, ox, oy) catch {};
var i: u32 = 0;
while (i < HintDotsCount and x + i < texture.width) : (i += 1) {
const hintX = ox + (@intCast(i32, i) * self.offset.z) + @divTrunc(self.offset.z, 2);
self.set_inverse_color(texture, x + i, y);
self.render.drawPoint(hintX, oy) catch {};
}
} else {
// right to left
const ow = @floatToInt(c_int, self.offset.x) + @intCast(c_int, texture.width) * self.offset.z;
const ox = @floatToInt(c_int, self.offset.x) + @intCast(c_int, texture.width - x) * self.offset.z;
self.render.drawLine(ow, oy, ox, oy) catch {};
var i: u32 = 0;
while (i < HintDotsCount and x + i < texture.width) : (i += 1) {
const hintX = ox - (@intCast(i32, i) * self.offset.z) - @divTrunc(self.offset.z, 2);
self.set_inverse_color(texture, texture.width - x - i - 1, y);
self.render.drawPoint(hintX, oy) catch {};
}
}
}
////////////////
// DROP EVENT //
////////////////
pub fn wait_for_file(self: Context) ?[:0]const u8 {
while (true) {
while (sdl.pollEvent()) |e| {
switch (e) {
.drop_file => |file| {
return std.mem.span(file.file);
},
.drop_text => {
self.error_box("Could not understand dropped item, try something else. Was text");
},
.key_down => |key| {
if (key.keycode == .f4 and sdl.getModState().get(sdl.KeyModifierBit.left_alt)) {
return null;
}
},
.quit => {
return null;
},
else => {},
}
}
self.clear();
self.print_slice("Please drag a image onto this window to open it", 20, 80);
self.swap();
sdl.delay(33);
}
return null;
}
pub fn error_box(self: Context, msg: [:0]const u8) void {
sdl.showSimpleMessageBox(.{ .@"error" = true }, "Error!", msg, self.window) catch {};
}
|
src/Context.zig
|
const std = @import("std");
const csv = @import("csv");
pub fn main() !void {
// var gpa = std.heap.GeneralPurposeAllocator(.{}){};
// defer _ = gpa.deinit();
var arena = std.heap.ArenaAllocator.init(std.heap.c_allocator);
defer arena.deinit();
const allocator = &arena.allocator;
const csv_path = std.os.argv[1];
const csv_file = try std.fs.cwd().openFile(std.mem.spanZ(csv_path), .{});
defer csv_file.close();
const out_path = std.os.argv[2];
var out_dir = try std.fs.cwd().openDir(std.mem.spanZ(out_path), .{});
defer out_dir.close();
const columns_path = std.os.argv[3];
const columns_file = try std.fs.cwd().openFile(std.mem.spanZ(columns_path), .{});
defer columns_file.close();
const buffer = try allocator.alloc(u8, 4096);
var tokenizer = try csv.CsvTokenizer(std.fs.File.Reader).init(csv_file.reader(), buffer, .{});
var columns = std.ArrayList([]const u8).init(allocator);
while (try columns_file.reader().readUntilDelimiterOrEofAlloc(allocator, '\n', 4096)) |line| {
try columns.append(line);
}
while (try tokenizer.next()) |token| {
switch (token) {
.field => continue,
.row_end => break,
}
}
var current_id: ?[]const u8 = null;
var current_col: usize = 0;
var current_out_file: ?std.fs.File = null;
while (try tokenizer.next()) |token| {
switch (token) {
.field => |val| {
if (current_id) |_| {
try current_out_file.?.writer().print("** {s}\n\n{s}\n\n", .{ columns.items[current_col], val });
} else {
current_id = val;
current_out_file = try out_dir.createFile(try std.fmt.allocPrint(allocator, "{s}.org", .{current_id}), .{});
}
current_col += 1;
},
.row_end => {
current_id = null;
current_col = 0;
current_out_file.?.close();
},
}
}
}
|
src/main.zig
|
const util = @import("util.zig");
const acpi = @import("acpi.zig");
/// Base Frequency
const oscillator: u32 = 1_193_180;
// I/O Ports
const channel_arg_base_port: u16 = 0x40;
const command_port: u16 = 0x43;
const pc_speaker_port: u16 = 0x61;
// Set Operating Mode of PITs =================================================
// Use this Python to help decode a raw command byte:
// def command(c):
// if c & 1:
// print("BCD")
// print("Mode:", (c >> 1) & 7)
// print("Access:", (c >> 4) & 3)
// print("Channel:", (c >> 6) & 3)
const Mode = enum(u3) {
Terminal,
OneShot,
Rate,
Square,
SwStrobe,
HwStrobe,
RateAgain,
SquareAgain,
};
const Channel = enum(u2) {
Irq0, // (Channel 0)
Channel1, // Assume to be Unusable
Speaker, // (Channel 2)
Channel3, // ?
pub fn get_arg_port(self: Channel) u16 {
return channel_arg_base_port + @enumToInt(self);
}
};
const Command = packed struct {
bcd: bool = false,
mode: Mode,
access: enum(u2) {
Latch,
LowByte,
HighByte,
BothBytes,
},
channel: Channel,
pub fn perform(self: *const Command) void {
util.out8(command_port, @bitCast(u8, self.*));
}
};
pub fn set_pit_both_bytes(channel: Channel, mode: Mode, arg: u16) void {
// Issue Command
const cmd = Command{.channel=channel, .access=.BothBytes, .mode=mode};
cmd.perform();
// Issue Two Byte Argument Required by BothBytes
const port: u16 = channel.get_arg_port();
util.out8(port, @truncate(u8, arg));
util.out8(port, @truncate(u8, arg >> 8));
}
pub fn set_pit_freq(channel: Channel, frequency: u32) void {
set_pit_both_bytes(channel, .Square, @truncate(u16, oscillator / frequency));
}
// PC Speaker =================================================================
fn speaker_enabled(enable: bool) callconv(.Inline) void {
const mask: u8 = 0b10;
const current = util.in8(pc_speaker_port);
const desired = if (enable) current | mask else current & ~mask;
if (current != desired) {
util.out8(pc_speaker_port, desired);
}
}
pub fn beep(frequency: u32, milliseconds: u64) void {
set_pit_freq(.Speaker, frequency);
speaker_enabled(true);
wait_milliseconds(milliseconds);
speaker_enabled(false);
}
// Crude rdtsc-based Timer ====================================================
// Uses the PIC and rdtsc instruction to estimate the clock speed and then use
// rdtsc as a crude timer.
pub fn rdtsc() u64 {
// Based on https://github.com/ziglang/zig/issues/215#issuecomment-261581922
// because I wasn't sure how to handle the fact rdtsc output is broken up
// into two registers.
const low = asm volatile ("rdtsc" : [low] "={eax}" (-> u32));
const high = asm volatile ("movl %%edx, %[high]" : [high] "=r" (-> u32));
return (@as(u64, high) << 32) | @as(u64, low);
}
pub var estimated_ticks_per_second: u64 = 0;
pub var estimated_ticks_per_millisecond: u64 = 0;
pub var estimated_ticks_per_microsecond: u64 = 0;
pub var estimated_ticks_per_nanosecond: u64 = 0;
pub fn estimate_cpu_speed() void {
// Setup the PIT counter to count down oscillator / ticks seconds (About
// 1.138 seconds).
util.out8(pc_speaker_port, (util.in8(pc_speaker_port) & ~@as(u8, 0x02)) | 0x01);
const ticks: u16 = 0xffff;
set_pit_both_bytes(.Speaker, .Terminal, ticks);
// Record Start rdtsc
const start = rdtsc();
// Wait Until PIT Counter is Zero
while ((util.in8(pc_speaker_port) & 0x20) == 0) {}
// Estimate CPU Tick Rate
estimated_ticks_per_second = (rdtsc() - start) * oscillator / ticks;
estimated_ticks_per_millisecond = estimated_ticks_per_second / 1000;
estimated_ticks_per_microsecond = estimated_ticks_per_millisecond / 1000;
estimated_ticks_per_nanosecond = estimated_ticks_per_microsecond / 1000;
}
pub fn seconds_to_ticks(s: u64) u64{
return s * estimated_ticks_per_second;
}
pub fn milliseconds_to_ticks(ms: u64) u64 {
return ms * estimated_ticks_per_millisecond;
}
fn wait_ticks(ticks: u64) callconv(.Inline) void {
const until = rdtsc() + ticks;
while (until > rdtsc()) {
asm volatile ("nop");
}
}
pub fn wait_seconds(s: u64) void {
wait_ticks(s * estimated_ticks_per_second);
}
pub fn wait_milliseconds(ms: u64) void {
wait_ticks(ms * estimated_ticks_per_millisecond);
}
pub fn wait_microseconds(us: u64) void {
wait_ticks(us * estimated_ticks_per_microsecond);
}
pub fn wait_nanoseconds(ns : u64) void {
wait_ticks(ns * estimated_ticks_per_nanosecond);
}
// High Precision Event Timer (HPET) ==========================================
pub const HpetTable = packed struct {
pub const PageProtection = enum(u4) {
None = 0,
For4KibPages,
For64KibPages,
_,
};
header: acpi.TableHeader,
hardware_rev_id: u8,
comparator_count: u5,
counter_size: bool,
reserved: bool,
legacy_replacment: bool,
pci_vendor_id: u16,
base_address: acpi.Address,
hpet_number: u8,
minimum_tick: u16,
page_protection: PageProtection,
oem_attrs: u4,
};
|
kernel/platform/timing.zig
|
const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const data = @embedFile("data/day16.txt");
const EntriesList = std.ArrayList(Field);
const Ticket = [20]u32;
const TicketList = std.ArrayList(Ticket);
const Field = struct {
name: []const u8,
amin: u32,
amax: u32,
bmin: u32,
bmax: u32,
};
pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
const ally = &arena.allocator;
var lines = std.mem.tokenize(data, "\r\n");
var fields = EntriesList.init(ally);
try fields.ensureCapacity(400);
var tickets = TicketList.init(ally);
try tickets.ensureCapacity(400);
var result: usize = 0;
while (lines.next()) |line| {
if (line.len == 0) continue;
if (line[line.len-1] == ':') break;
var parts = std.mem.tokenize(line, ":");
var name = parts.next().?;
parts.delimiter_bytes = ": or-";
try fields.append(.{
.name = name,
.amin = try std.fmt.parseUnsigned(u32, parts.next().?, 10),
.amax = try std.fmt.parseUnsigned(u32, parts.next().?, 10),
.bmin = try std.fmt.parseUnsigned(u32, parts.next().?, 10),
.bmax = try std.fmt.parseUnsigned(u32, parts.next().?, 10),
});
assert(parts.next() == null);
}
while (lines.next()) |line| {
if (line.len == 0) continue;
if (line[line.len-1] == ':') continue;
var ticket: Ticket = undefined;
var count: usize = 0;
var parts = std.mem.tokenize(line, ",");
while (parts.next()) |part| : (count += 1) {
ticket[count] = std.fmt.parseUnsigned(u32, part, 10) catch { @breakpoint(); unreachable; };
}
assert(count == ticket.len);
try tickets.append(ticket);
}
var valid_tickets = TicketList.init(ally);
try valid_tickets.ensureCapacity(tickets.items.len);
for (tickets.items[1..]) |ticket| {
var valid = true;
for (ticket) |field| {
for (fields.items) |ct| {
if ((field >= ct.amin and field <= ct.amax) or
(field >= ct.bmin and field <= ct.bmax)) {
break;
}
} else {
valid = false;
result += field;
}
}
if (valid) {
try valid_tickets.append(ticket);
}
}
print("Result 1: {}, valid: {}/{}\n", .{result, valid_tickets.items.len, tickets.items.len});
var valid = [_]bool{true} ** 20;
var out_order: [20]u32 = undefined;
check_ticket(valid_tickets.items, fields.items, &valid, 0, &out_order) catch {
for (out_order) |item| {
print("{}, ", .{item});
}
print("\n", .{});
var product: u64 = 1;
for (out_order) |item, idx| {
if (std.mem.startsWith(u8, fields.items[item].name, "departure")) {
var value = tickets.items[0][idx];
print("{}: {}\n", .{fields.items[item].name, value});
product *= value;
}
}
print("product: {}\n", .{product});
};
}
fn check_ticket(
tickets: []const Ticket,
fields: []const Field,
valid: *[20]bool,
index: u32,
out_order: *[20]u32,
) error{Complete}!void {
if (index >= 20) return error.Complete;
for (valid) |*v, vi| {
if (v.*) {
valid[vi] = false;
defer valid[vi] = true;
out_order[index] = @intCast(u32, vi);
const ct = fields[vi];
for (tickets) |*tik| {
var item = tik.*[index];
if (!((item >= ct.amin and item <= ct.amax) or
(item >= ct.bmin and item <= ct.bmax))) {
break;
}
} else {
try check_ticket(tickets, fields, valid, index + 1, out_order);
}
}
}
}
|
src/day16.zig
|
const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const clap = @import("clap");
pub fn main() anyerror!void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer assert(gpa.deinit() == false);
const allocator = gpa.allocator();
const params = comptime [_]clap.Param(clap.Help){
clap.parseParam("-h, --help Display this help and exit.") catch unreachable,
clap.parseParam(
\\--root <PATH> Root directory for source files.
\\- Files outside of the root directory are not reported on.
\\- Output paths are relative to the root directory.
\\(default: '.')
) catch unreachable,
clap.parseParam("--output-dir <PATH> Directory to put the results. (default: './coverage')") catch unreachable,
clap.parseParam("--cwd <PATH> Directory to run the valgrind process from. (default: '.')") catch unreachable,
clap.parseParam("--keep-out-file Do not delete the callgrind file that gets generated.") catch unreachable,
clap.parseParam("--out-file-name <PATH> Set the name of the callgrind.out file.\n(default: 'callgrind.out.%p')") catch unreachable,
clap.parseParam("--include <PATH>... Include the specified callgrind file(s) when generating\ncoverage (can be specified multiple times).") catch unreachable,
clap.parseParam("--skip-collect Skip the callgrind data collection step.") catch unreachable,
clap.parseParam("--skip-report Skip the coverage report generation step.") catch unreachable,
clap.parseParam("--skip-summary Skip printing a summary to stdout.") catch unreachable,
clap.parseParam("<CMD...>...") catch unreachable,
};
var diag = clap.Diagnostic{};
var args = clap.parse(clap.Help, ¶ms, .{ .diagnostic = &diag, .allocator = allocator }) catch |err| {
diag.report(std.io.getStdErr().writer(), err) catch {};
return err;
};
defer args.deinit();
const valgrind_available = try checkCommandAvailable(allocator, "valgrind");
if (!valgrind_available) {
std.debug.print("Error: valgrind not found, make sure valgrind is installed.\n", .{});
return error.NoValgrind;
}
const readelf_available = try checkCommandAvailable(allocator, "readelf");
if (!readelf_available) {
std.debug.print("Warning: readelf not found, information about executable lines will not be available.\n", .{});
}
if (args.flag("--skip-collect") and args.flag("--skip-report")) {
std.debug.print("Error: Nothing to do (--skip-collect and --skip-report are both set.)\n", .{});
return error.NothingToDo;
}
if (args.flag("--skip-collect") and args.options("--include").len == 0) {
std.debug.print("Error: --skip-collect is set but no callgrind.out files were specified. At least one callgrind.out file must be specified with --include in order to generate a report when --skip-collect is set.\n", .{});
return error.NoCoverageData;
}
var should_print_usage = !args.flag("--skip-collect") and args.positionals().len == 0;
if (args.flag("--help") or should_print_usage) {
const writer = std.io.getStdErr().writer();
try writer.writeAll("Usage: grindcov [options] -- <cmd> [<args>...]\n\n");
try writer.writeAll("Available options:\n");
try clap.help(writer, ¶ms);
return;
}
const root_dir = root_dir: {
const path = args.option("--root") orelse ".";
const realpath = std.fs.cwd().realpathAlloc(allocator, path) catch |err| switch (err) {
error.FileNotFound => |e| {
std.debug.print("Unable to resolve root directory: '{s}'\n", .{path});
return e;
},
else => return err,
};
break :root_dir realpath;
};
defer allocator.free(root_dir);
var coverage = Coverage.init(allocator);
defer coverage.deinit();
if (!args.flag("--skip-collect")) {
const callgrind_out_path = try genCallgrind(allocator, args.positionals(), args.option("--cwd"), args.option("--out-file-name"));
defer allocator.free(callgrind_out_path);
defer if (!args.flag("--keep-out-file")) {
std.fs.cwd().deleteFile(callgrind_out_path) catch {};
};
if (args.flag("--keep-out-file")) {
std.debug.print("Kept callgrind out file: '{s}'\n", .{callgrind_out_path});
}
try coverage.getCoveredLines(allocator, callgrind_out_path);
}
var got_executable_line_info = false;
if (readelf_available) {
got_executable_line_info = true;
coverage.getExecutableLines(allocator, args.positionals()[0], args.option("--cwd")) catch |err| switch (err) {
error.ReadElfError => {
got_executable_line_info = false;
std.debug.print("Warning: Unable to use readelf to get information about executable lines. This information will not be in the results.\n", .{});
},
else => |e| return e,
};
}
if (!args.flag("--skip-report")) {
for (args.options("--include")) |include_callgrind_out_path| {
coverage.getCoveredLines(allocator, include_callgrind_out_path) catch |err| switch (err) {
error.FileNotFound => |e| {
std.debug.print("Included callgrind out file not found: {s}\n", .{include_callgrind_out_path});
return e;
},
else => |e| return e,
};
}
const output_dir = args.option("--output-dir") orelse "coverage";
try std.fs.cwd().deleteTree(output_dir);
var out_dir = try std.fs.cwd().makeOpenPath(output_dir, .{});
defer out_dir.close();
const num_dumped = try coverage.dumpDiffsToDir(out_dir, root_dir);
if (num_dumped == 0) {
std.debug.print("Warning: No source files were included in the coverage results. ", .{});
std.debug.print("If this is unexpected, check to make sure that the root directory is set appropriately.\n", .{});
std.debug.print(" - Current --root setting: ", .{});
if (args.option("--root")) |setting| {
std.debug.print("'{s}'\n", .{setting});
} else {
std.debug.print("(not specified)\n", .{});
}
std.debug.print(" - Current root directory: '{s}'\n", .{root_dir});
} else {
std.debug.print("Results for {} source files generated in directory '{s}'\n", .{ num_dumped, output_dir });
}
}
if (!args.flag("--skip-summary") and got_executable_line_info) {
std.debug.print("\n", .{});
try coverage.writeSummary(std.io.getStdOut().writer(), root_dir);
}
}
pub fn checkCommandAvailable(allocator: Allocator, cmd: []const u8) !bool {
const result = std.ChildProcess.exec(.{
.allocator = allocator,
.argv = &[_][]const u8{ cmd, "--version" },
}) catch |err| switch (err) {
error.FileNotFound => return false,
else => |e| return e,
};
defer allocator.free(result.stdout);
defer allocator.free(result.stderr);
const failed = switch (result.term) {
.Exited => |exit_code| exit_code != 0,
else => true,
};
return !failed;
}
pub fn genCallgrind(allocator: Allocator, user_args: []const []const u8, cwd: ?[]const u8, custom_out_file_name: ?[]const u8) ![]const u8 {
const valgrind_args = &[_][]const u8{
"valgrind",
"--tool=callgrind",
"--compress-strings=no",
"--compress-pos=no",
"--collect-jumps=yes",
};
var out_file_name = custom_out_file_name orelse "callgrind.out.%p";
var out_file_arg = try std.mem.concat(allocator, u8, &[_][]const u8{
"--callgrind-out-file=",
out_file_name,
});
defer allocator.free(out_file_arg);
const args = try std.mem.concat(allocator, []const u8, &[_][]const []const u8{
valgrind_args,
&[_][]const u8{out_file_arg},
user_args,
});
defer allocator.free(args);
const result = try std.ChildProcess.exec(.{
.allocator = allocator,
.argv = args,
.cwd = cwd,
.max_output_bytes = std.math.maxInt(usize),
});
defer allocator.free(result.stdout);
defer allocator.free(result.stderr);
const failed = switch (result.term) {
.Exited => |exit_code| exit_code != 0,
else => true,
};
if (failed) {
std.debug.print("{s}\n", .{result.stderr});
return error.CallgrindError;
}
// TODO: this would get blown up by %%p which is meant to be an escaped % and a p
var pid_pattern_count = std.mem.count(u8, out_file_name, "%p");
var callgrind_out_path = callgrind_out_path: {
if (pid_pattern_count > 0) {
const maybe_first_equals = std.mem.indexOf(u8, result.stderr, "==");
if (maybe_first_equals == null) {
std.debug.print("{s}\n", .{result.stderr});
return error.UnableToFindPid;
}
const first_equals = maybe_first_equals.?;
const next_equals_offset = std.mem.indexOf(u8, result.stderr[(first_equals + 2)..], "==").?;
const pid_as_string = result.stderr[(first_equals + 2)..(first_equals + 2 + next_equals_offset)];
const delta_mem_needed: i64 = @intCast(i64, pid_pattern_count) * (@intCast(i64, pid_as_string.len) - @as(i64, 2));
const mem_needed = @intCast(usize, @intCast(i64, out_file_name.len) + delta_mem_needed);
const buf = try allocator.alloc(u8, mem_needed);
_ = std.mem.replace(u8, out_file_name, "%p", pid_as_string, buf);
break :callgrind_out_path buf;
} else {
break :callgrind_out_path try allocator.dupe(u8, out_file_name);
}
};
if (cwd) |cwd_path| {
var cwd_callgrind_out_path = try std.fs.path.join(allocator, &[_][]const u8{
cwd_path,
callgrind_out_path,
});
allocator.free(callgrind_out_path);
callgrind_out_path = cwd_callgrind_out_path;
}
return callgrind_out_path;
}
const Coverage = struct {
allocator: Allocator,
paths_to_file_info: Info,
pub const LineSet = std.AutoHashMapUnmanaged(usize, void);
pub const FileInfo = struct {
covered: *LineSet,
executable: *LineSet,
};
pub const Info = std.StringHashMapUnmanaged(FileInfo);
pub fn init(allocator: Allocator) Coverage {
return .{
.allocator = allocator,
.paths_to_file_info = Coverage.Info{},
};
}
pub fn deinit(self: *Coverage) void {
var it = self.paths_to_file_info.iterator();
while (it.next()) |entry| {
entry.value_ptr.covered.deinit(self.allocator);
entry.value_ptr.executable.deinit(self.allocator);
self.allocator.destroy(entry.value_ptr.covered);
self.allocator.destroy(entry.value_ptr.executable);
self.allocator.free(entry.key_ptr.*);
}
self.paths_to_file_info.deinit(self.allocator);
}
pub fn getCoveredLines(coverage: *Coverage, allocator: Allocator, callgrind_file_path: []const u8) !void {
var callgrind_file = try std.fs.cwd().openFile(callgrind_file_path, .{});
defer callgrind_file.close();
var current_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var current_path: ?[]u8 = null;
var reader = std.io.bufferedReader(callgrind_file.reader()).reader();
while (try reader.readUntilDelimiterOrEofAlloc(allocator, '\n', std.math.maxInt(usize))) |_line| {
defer allocator.free(_line);
var line = std.mem.trimRight(u8, _line, "\r");
const is_source_file_path = std.mem.startsWith(u8, line, "fl=") or std.mem.startsWith(u8, line, "fi=") or std.mem.startsWith(u8, line, "fe=");
if (is_source_file_path) {
var path = line[3..];
if (std.fs.cwd().access(path, .{})) {
std.mem.copy(u8, current_path_buf[0..], path);
current_path = current_path_buf[0..path.len];
} else |_| {
current_path = null;
}
continue;
}
if (current_path == null) {
continue;
}
const is_jump = std.mem.startsWith(u8, line, "jump=") or std.mem.startsWith(u8, line, "jncd=");
var line_num: usize = 0;
if (is_jump) {
line = line[5..];
// jcnd seems to use a '/' to separate exe-count and jump-count, although
// https://valgrind.org/docs/manual/cl-format.html doesn't seem to think so
// target-position is always last, though, so just get the last tok
var tok_it = std.mem.tokenize(u8, line, " /");
var last_tok = tok_it.next() orelse continue;
while (tok_it.next()) |tok| {
last_tok = tok;
}
line_num = try std.fmt.parseInt(usize, last_tok, 10);
} else {
var tok_it = std.mem.tokenize(u8, line, " ");
var first_tok = tok_it.next() orelse continue;
line_num = std.fmt.parseInt(usize, first_tok, 10) catch continue;
}
// not sure exactly what causes this, but ignore line nums given as 0
if (line_num == 0) continue;
try coverage.markCovered(current_path.?, line_num);
}
}
pub fn getExecutableLines(coverage: *Coverage, allocator: Allocator, cmd: []const u8, cwd: ?[]const u8) !void {
// TODO: instead of readelf, use Zig's elf/dwarf std lib functions
const result = try std.ChildProcess.exec(.{
.allocator = allocator,
.argv = &[_][]const u8{
"readelf",
// to get DW_AT_comp_dir
"--debug-dump=info",
"--dwarf-depth=1",
// to get the line nums
"--debug-dump=decodedline",
cmd,
},
.cwd = cwd,
.max_output_bytes = std.math.maxInt(usize),
});
defer allocator.free(result.stdout);
defer allocator.free(result.stderr);
const failed = switch (result.term) {
.Exited => |exit_code| exit_code != 0,
else => true,
};
if (failed) {
std.debug.print("{s}\n", .{result.stderr});
return error.ReadElfError;
}
const debug_line_start_line = "Contents of the .debug_line section:\n";
var start_of_debug_line = std.mem.indexOf(u8, result.stdout, debug_line_start_line) orelse return error.MissingDebugLine;
const debug_info_section = result.stdout[0..start_of_debug_line];
const main_comp_dir_start = std.mem.indexOf(u8, debug_info_section, "DW_AT_comp_dir") orelse return error.MissingCompDir;
const main_comp_dir_line_end = std.mem.indexOfScalar(u8, debug_info_section[main_comp_dir_start..], '\n').?;
const main_comp_dir_line = debug_info_section[main_comp_dir_start..(main_comp_dir_start + main_comp_dir_line_end)];
const main_comp_dir_sep_pos = std.mem.lastIndexOf(u8, main_comp_dir_line, "): ").?;
const main_comp_dir = main_comp_dir_line[(main_comp_dir_sep_pos + 3)..];
var line_it = std.mem.split(u8, result.stdout[start_of_debug_line..], "\n");
var past_header = false;
var file_path: ?[]const u8 = null;
var file_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var file_path_basename: ?[]const u8 = null;
while (line_it.next()) |line| {
if (!past_header) {
if (std.mem.startsWith(u8, line, "File name ")) {
past_header = true;
}
continue;
}
if (line.len == 0) {
file_path = null;
file_path_basename = null;
continue;
}
if (file_path == null) {
if (std.mem.endsWith(u8, line, ":")) {
file_path = std.mem.trimRight(u8, line, ":");
}
// some files are relative to the main_comp_dir, they are indicated
// by the suffix [++]
else if (std.mem.endsWith(u8, line, ":[++]")) {
const relative_file_path = line[0..(line.len - (":[++]").len)];
const resolved_path = try std.fs.path.resolve(allocator, &[_][]const u8{ main_comp_dir, relative_file_path });
defer allocator.free(resolved_path);
std.mem.copy(u8, &file_path_buf, resolved_path);
file_path = file_path_buf[0..resolved_path.len];
} else {
std.debug.print("Unhandled line, expecting a file path line: '{s}'\n", .{line});
@panic("Unhandled readelf output");
}
file_path_basename = std.fs.path.basename(file_path.?);
continue;
}
const past_basename = line[(file_path_basename.?.len)..];
var tok_it = std.mem.tokenize(u8, past_basename, " \t");
const line_num_str = tok_it.next() orelse continue;
const line_num = std.fmt.parseInt(usize, line_num_str, 10) catch continue;
try coverage.markExecutable(file_path.?, line_num);
}
}
pub fn getFileInfo(self: *Coverage, path: []const u8) !*FileInfo {
var entry = try self.paths_to_file_info.getOrPut(self.allocator, path);
if (!entry.found_existing) {
entry.key_ptr.* = try self.allocator.dupe(u8, path);
var covered_set = try self.allocator.create(LineSet);
covered_set.* = LineSet{};
var executable_set = try self.allocator.create(LineSet);
executable_set.* = LineSet{};
entry.value_ptr.* = .{
.covered = covered_set,
.executable = executable_set,
};
}
return entry.value_ptr;
}
pub fn markCovered(self: *Coverage, path: []const u8, line_num: usize) !void {
var file_info = try self.getFileInfo(path);
try file_info.covered.put(self.allocator, line_num, {});
}
pub fn markExecutable(self: *Coverage, path: []const u8, line_num: usize) !void {
var file_info = try self.getFileInfo(path);
try file_info.executable.put(self.allocator, line_num, {});
}
pub fn dumpDiffsToDir(self: *Coverage, dir: std.fs.Dir, root_dir_path: []const u8) !usize {
var num_dumped: usize = 0;
var filename_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var it = self.paths_to_file_info.iterator();
while (it.next()) |path_entry| {
const abs_path = path_entry.key_ptr.*;
if (!std.mem.startsWith(u8, abs_path, root_dir_path)) {
continue;
}
var in_file = try std.fs.cwd().openFile(abs_path, .{});
defer in_file.close();
var relative_path = abs_path[root_dir_path.len..];
// trim any preceding separators
while (relative_path.len != 0 and std.fs.path.isSep(relative_path[0])) {
relative_path = relative_path[1..];
}
if (std.fs.path.dirname(relative_path)) |dirname| {
try dir.makePath(dirname);
}
const filename = try std.fmt.bufPrint(&filename_buf, "{s}.diff", .{relative_path});
var out_file = try dir.createFile(filename, .{ .truncate = true });
var has_executable_info = path_entry.value_ptr.executable.count() != 0;
var line_num: usize = 1;
var reader = std.io.bufferedReader(in_file.reader()).reader();
var writer = out_file.writer();
while (try reader.readUntilDelimiterOrEofAlloc(self.allocator, '\n', std.math.maxInt(usize))) |line| {
defer self.allocator.free(line);
if (path_entry.value_ptr.covered.get(line_num) != null) {
try writer.writeAll("> ");
} else {
if (has_executable_info) {
if (path_entry.value_ptr.executable.get(line_num) != null) {
try writer.writeAll("! ");
} else {
try writer.writeAll(" ");
}
} else {
try writer.writeAll("! ");
}
}
try writer.writeAll(line);
try writer.writeByte('\n');
line_num += 1;
}
num_dumped += 1;
}
return num_dumped;
}
pub fn writeSummary(self: *Coverage, stream: anytype, root_dir_path: []const u8) !void {
try stream.print("{s:<36} {s:<11} {s:<14} {s:>8}\n", .{ "File", "Covered LOC", "Executable LOC", "Coverage" });
try stream.print("{s:-<36} {s:-<11} {s:-<14} {s:-<8}\n", .{ "", "", "", "" });
var total_covered_lines: usize = 0;
var total_executable_lines: usize = 0;
var it = self.paths_to_file_info.iterator();
while (it.next()) |path_entry| {
const abs_path = path_entry.key_ptr.*;
if (!std.mem.startsWith(u8, abs_path, root_dir_path)) {
continue;
}
var relative_path = abs_path[root_dir_path.len..];
// trim any preceding separators
while (relative_path.len != 0 and std.fs.path.isSep(relative_path[0])) {
relative_path = relative_path[1..];
}
var has_executable_info = path_entry.value_ptr.executable.count() != 0;
if (!has_executable_info) {
try stream.print("{s:<36} <no executable line info>\n", .{relative_path});
} else {
const covered_lines = path_entry.value_ptr.covered.count();
const executable_lines = path_entry.value_ptr.executable.count();
const percentage_covered = @intToFloat(f64, covered_lines) / @intToFloat(f64, executable_lines);
if (truncatePathLeft(relative_path, 36)) |truncated_path| {
try stream.print("...{s:<33}", .{truncated_path});
} else {
try stream.print("{s:<36}", .{relative_path});
}
try stream.print(" {d:<11} {d:<14} {d:>7.2}%\n", .{ covered_lines, executable_lines, percentage_covered * 100 });
total_covered_lines += covered_lines;
total_executable_lines += executable_lines;
}
}
if (total_executable_lines > 0) {
try stream.print("{s:-<36} {s:-<11} {s:-<14} {s:-<8}\n", .{ "", "", "", "" });
const total_percentage_covered = @intToFloat(f64, total_covered_lines) / @intToFloat(f64, total_executable_lines);
try stream.print("{s:<36} {d:<11} {d:<14} {d:>7.2}%\n", .{ "Total", total_covered_lines, total_executable_lines, total_percentage_covered * 100 });
}
}
};
fn truncatePathLeft(str: []const u8, max_width: usize) ?[]const u8 {
if (str.len <= max_width) return null;
const start_offset = str.len - (max_width - 3);
var truncated = str[start_offset..];
while (truncated.len > 0 and !std.fs.path.isSep(truncated[0])) {
truncated = truncated[1..];
}
// if we got to the end with no path sep found, then just return
// the plain (max widdth - 3) string
if (truncated.len == 0) {
return str[start_offset..];
} else {
return truncated;
}
}
|
src/main.zig
|
const std = @import("std");
const mem = std.mem;
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const parseUnsigned = std.fmt.parseUnsigned;
const net = std.net;
const testing = std.testing;
const expect = testing.expect;
const expectEqualStrings = testing.expectEqualStrings;
const ValueMap = std.StringHashMap([]const u8);
pub const Uri = struct {
scheme: []const u8,
username: []const u8,
password: []const u8,
host: Host,
port: ?u16,
path: []const u8,
query: []const u8,
fragment: []const u8,
len: usize,
/// possible uri host values
pub const Host = union(enum) {
name: []const u8,
};
/// map query string into a hashmap of key value pairs with no value being an empty string
pub fn mapQuery(allocator: *Allocator, query: []const u8) Allocator.Error!ValueMap {
if (query.len == 0) {
return ValueMap.init(allocator);
}
var map = ValueMap.init(allocator);
errdefer map.deinit();
var start: usize = 0;
var mid: usize = 0;
for (query) |c, i| {
if (c == '&') {
if (mid != 0) {
_ = try map.put(query[start..mid], query[mid + 1 .. i]);
} else {
_ = try map.put(query[start..i], "");
}
start = i + 1;
mid = 0;
} else if (c == '=') {
mid = i;
}
}
if (mid != 0) {
_ = try map.put(query[start..mid], query[mid + 1 ..]);
} else {
_ = try map.put(query[start..], "");
}
return map;
}
/// possible errors for decode and encode
pub const EncodeError = error{
InvalidCharacter,
OutOfMemory,
};
/// decode path if it is percent encoded
pub fn decode(allocator: *Allocator, path: []const u8) EncodeError!?[]u8 {
var ret: ?[]u8 = null;
errdefer if (ret) |some| allocator.free(some);
var ret_index: usize = 0;
var i: usize = 0;
while (i < path.len) : (i += 1) {
if (path[i] == '%') {
if (!isPchar(path[i..])) {
return error.InvalidCharacter;
}
if (ret == null) {
ret = try allocator.alloc(u8, path.len);
mem.copy(u8, ret.?, path[0..i]);
ret_index = i;
}
// charToDigit can't fail because the chars are validated earlier
var new = (std.fmt.charToDigit(path[i + 1], 16) catch unreachable) << 4;
new |= std.fmt.charToDigit(path[i + 2], 16) catch unreachable;
ret.?[ret_index] = new;
ret_index += 1;
i += 2;
} else if (path[i] != '/' and !isPchar(path[i..])) {
return error.InvalidCharacter;
} else if (ret != null) {
ret.?[ret_index] = path[i];
ret_index += 1;
}
}
if (ret) |some| return allocator.shrink(some, ret_index);
return null;
}
/// percent encode if path contains characters not allowed in paths
pub fn encode(allocator: *Allocator, path: []const u8) EncodeError!?[]u8 {
var ret: ?[]u8 = null;
var ret_index: usize = 0;
for (path) |c, i| {
if (c != '/' and !isPchar(path[i..])) {
if (ret == null) {
ret = try allocator.alloc(u8, path.len * 3);
mem.copy(u8, ret.?, path[0..i]);
ret_index = i;
}
const hex_digits = "0123456789ABCDEF";
ret.?[ret_index] = '%';
ret.?[ret_index + 1] = hex_digits[(c & 0xF0) >> 4];
ret.?[ret_index + 2] = hex_digits[c & 0x0F];
ret_index += 3;
} else if (ret != null) {
ret.?[ret_index] = c;
ret_index += 1;
}
}
if (ret) |some| return allocator.shrink(some, ret_index);
return null;
}
/// resolves `path`, leaves trailing '/'
/// assumes `path` to be valid
pub fn resolvePath(allocator: *Allocator, path: []const u8) error{OutOfMemory}![]u8 {
assert(path.len > 0);
var list = std.ArrayList([]const u8).init(allocator);
defer list.deinit();
var it = mem.tokenize(path, "/");
while (it.next()) |p| {
if (mem.eql(u8, p, ".")) {
continue;
} else if (mem.eql(u8, p, "..")) {
_ = list.popOrNull();
} else {
try list.append(p);
}
}
var buf = try allocator.alloc(u8, path.len);
errdefer allocator.free(buf);
var len: usize = 0;
for (list.items) |s| {
buf[len] = '/';
len += 1;
mem.copy(u8, buf[len..], s);
len += s.len;
}
if (path[path.len - 1] == '/') {
buf[len] = '/';
len += 1;
}
return allocator.shrink(buf, len);
}
pub const scheme_to_port = std.ComptimeStringMap(u16, .{
.{ "acap", 674 },
.{ "afp", 548 },
.{ "dict", 2628 },
.{ "dns", 53 },
.{ "ftp", 21 },
.{ "git", 9418 },
.{ "gopher", 70 },
.{ "http", 80 },
.{ "https", 443 },
.{ "imap", 143 },
.{ "ipp", 631 },
.{ "ipps", 631 },
.{ "irc", 194 },
.{ "ircs", 6697 },
.{ "ldap", 389 },
.{ "ldaps", 636 },
.{ "mms", 1755 },
.{ "msrp", 2855 },
.{ "mtqp", 1038 },
.{ "nfs", 111 },
.{ "nntp", 119 },
.{ "nntps", 563 },
.{ "pop", 110 },
.{ "prospero", 1525 },
.{ "redis", 6379 },
.{ "rsync", 873 },
.{ "rtsp", 554 },
.{ "rtsps", 322 },
.{ "rtspu", 5005 },
.{ "sftp", 22 },
.{ "smb", 445 },
.{ "snmp", 161 },
.{ "ssh", 22 },
.{ "svn", 3690 },
.{ "telnet", 23 },
.{ "ventrilo", 3784 },
.{ "vnc", 5900 },
.{ "wais", 210 },
.{ "ws", 80 },
.{ "wss", 443 },
});
/// possible errors for parse
pub const Error = error{
/// input is not a valid uri due to a invalid character
/// mostly a result of invalid ipv6
InvalidCharacter,
/// given input was empty
EmptyUri,
};
/// parse URI from input
/// empty input is an error
/// if assume_auth is true then `example.com` will result in `example.com` being the host instead of path
pub fn parse(input: []const u8, assume_auth: bool) Error!Uri {
if (input.len == 0) {
return error.EmptyUri;
}
var uri = Uri{
.scheme = "",
.username = "",
.password = "",
.host = .{ .name = "" },
.port = null,
.path = "",
.query = "",
.fragment = "",
.len = 0,
};
switch (input[0]) {
'a'...'z', 'A'...'Z' => {
uri.parseMaybeScheme(input);
},
else => {},
}
if (input.len > uri.len + 2 and input[uri.len] == '/' and input[uri.len + 1] == '/') {
uri.len += 2; // for the '//'
try uri.parseAuth(input[uri.len..]);
} else if (assume_auth) {
try uri.parseAuth(input[uri.len..]);
}
uri.parsePath(input[uri.len..]);
if (input.len > uri.len + 1 and input[uri.len] == '?') {
uri.parseQuery(input[uri.len + 1 ..]);
}
if (input.len > uri.len + 1 and input[uri.len] == '#') {
uri.parseFragment(input[uri.len + 1 ..]);
}
return uri;
}
fn parseMaybeScheme(u: *Uri, input: []const u8) void {
for (input) |c, i| {
switch (c) {
'a'...'z', 'A'...'Z', '0'...'9', '+', '-', '.' => {
// allowed characters
},
':' => {
u.scheme = input[0..i];
u.port = scheme_to_port.get(u.scheme);
u.len += u.scheme.len + 1; // +1 for the ':'
return;
},
else => {
// not a valid scheme
return;
},
}
}
}
fn parseAuth(u: *Uri, input: []const u8) Error!void {
var i: u32 = 0;
var at_index = i;
while (i < input.len) : (i += 1) {
switch (input[i]) {
'@' => at_index = i,
'[' => {
if (i != 0) return error.InvalidCharacter;
return u.parseIP6(input);
},
else => if (!isPchar(input[i..])) break,
}
}
if (at_index != 0) {
u.username = input[0..at_index];
if (mem.indexOfScalar(u8, u.username, ':')) |colon| {
u.password = u.username[colon + 1 ..];
u.username = u.username[0..colon];
}
at_index += 1;
}
u.host.name = input[at_index..i];
u.len += i;
if (mem.indexOfScalar(u8, u.host.name, ':')) |colon| {
u.port = parseUnsigned(u16, u.host.name[colon + 1 ..], 10) catch return error.InvalidCharacter;
u.host.name = u.host.name[0..colon];
}
}
fn parseIP6(u: *Uri, input: []const u8) Error!void {
_ = u;
_ = input;
return error.InvalidCharacter;
}
fn parsePort(u: *Uri, input: []const u8) Error!void {
var i: u32 = 0;
while (i < input.len) : (i += 1) {
switch (input[i]) {
'0'...'9' => {}, // digits
else => break,
}
}
if (i == 0) return error.InvalidCharacter;
u.port = parseUnsigned(u16, input[0..i], 10) catch return error.InvalidCharacter;
u.len += i;
}
fn parsePath(u: *Uri, input: []const u8) void {
for (input) |c, i| {
if (c != '/' and (c == '?' or c == '#' or !isPchar(input[i..]))) {
u.path = input[0..i];
u.len += u.path.len;
return;
}
}
u.path = input[0..];
u.len += u.path.len;
}
fn parseQuery(u: *Uri, input: []const u8) void {
u.len += 1; // +1 for the '?'
for (input) |c, i| {
if (c == '#' or (c != '/' and c != '?' and !isPchar(input[i..]))) {
u.query = input[0..i];
u.len += u.query.len;
return;
}
}
u.query = input;
u.len += input.len;
}
fn parseFragment(u: *Uri, input: []const u8) void {
u.len += 1; // +1 for the '#'
for (input) |c, i| {
if (c != '/' and c != '?' and !isPchar(input[i..])) {
u.fragment = input[0..i];
u.len += u.fragment.len;
return;
}
}
u.fragment = input;
u.len += u.fragment.len;
}
/// returns true if str starts with a valid path character or a percent encoded octet
pub fn isPchar(str: []const u8) bool {
assert(str.len > 0);
return switch (str[0]) {
'a'...'z', 'A'...'Z', '0'...'9', '-', '.', '_', '~', '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=', ':', '@' => true,
'%' => str.len > 3 and isHex(str[1]) and isHex(str[2]),
else => false,
};
}
/// returns true if c is a hexadecimal digit
pub fn isHex(c: u8) bool {
return switch (c) {
'0'...'9', 'a'...'f', 'A'...'F' => true,
else => false,
};
}
};
test "basic url" {
const uri = try Uri.parse("https://ziglang.org:80/documentation/master/?test#toc-Introduction", false);
expectEqualStrings("https", uri.scheme);
expectEqualStrings("", uri.username);
expectEqualStrings("", uri.password);
expectEqualStrings("ziglang.org", uri.host.name);
expect(uri.port.? == 80);
expectEqualStrings("/documentation/master/", uri.path);
expectEqualStrings("test", uri.query);
expectEqualStrings("toc-Introduction", uri.fragment);
expect(uri.len == 66);
}
test "short" {
const uri = try Uri.parse("telnet://192.0.2.16:80/", false);
expectEqualStrings("telnet", uri.scheme);
expectEqualStrings("", uri.username);
expectEqualStrings("", uri.password);
var buf = [_]u8{0} ** 100;
var ip = std.fmt.bufPrint(buf[0..], "{}", .{uri.host.ip}) catch unreachable;
expectEqualStrings("192.0.2.16:80", ip);
expect(uri.port.? == 80);
expectEqualStrings("/", uri.path);
expectEqualStrings("", uri.query);
expectEqualStrings("", uri.fragment);
expect(uri.len == 23);
}
test "single char" {
const uri = try Uri.parse("a", false);
expectEqualStrings("", uri.scheme);
expectEqualStrings("", uri.username);
expectEqualStrings("", uri.password);
expectEqualStrings("", uri.host.name);
expect(uri.port == null);
expectEqualStrings("a", uri.path);
expectEqualStrings("", uri.query);
expectEqualStrings("", uri.fragment);
expect(uri.len == 1);
}
test "ipv6" {
const uri = try Uri.parse("ldap://[2001:db8::7]/c=GB?objectClass?one", false);
expectEqualStrings("ldap", uri.scheme);
expectEqualStrings("", uri.username);
expectEqualStrings("", uri.password);
var buf = [_]u8{0} ** 100;
var ip = std.fmt.bufPrint(buf[0..], "{}", .{uri.host.ip}) catch unreachable;
expectEqualStrings("[2001:db8::7]:389", ip);
expect(uri.port.? == 389);
expectEqualStrings("/c=GB", uri.path);
expectEqualStrings("objectClass?one", uri.query);
expectEqualStrings("", uri.fragment);
expect(uri.len == 41);
}
test "mailto" {
const uri = try Uri.parse("mailto:<EMAIL>", false);
expectEqualStrings("mailto", uri.scheme);
expectEqualStrings("", uri.username);
expectEqualStrings("", uri.password);
expectEqualStrings("", uri.host.name);
expect(uri.port == null);
expectEqualStrings("<EMAIL>", uri.path);
expectEqualStrings("", uri.query);
expectEqualStrings("", uri.fragment);
expect(uri.len == 27);
}
test "tel" {
const uri = try Uri.parse("tel:+1-816-555-1212", false);
expectEqualStrings("tel", uri.scheme);
expectEqualStrings("", uri.username);
expectEqualStrings("", uri.password);
expectEqualStrings("", uri.host.name);
expect(uri.port == null);
expectEqualStrings("+1-816-555-1212", uri.path);
expectEqualStrings("", uri.query);
expectEqualStrings("", uri.fragment);
expect(uri.len == 19);
}
test "urn" {
const uri = try Uri.parse("urn:oasis:names:specification:docbook:dtd:xml:4.1.2", false);
expectEqualStrings("urn", uri.scheme);
expectEqualStrings("", uri.username);
expectEqualStrings("", uri.password);
expectEqualStrings("", uri.host.name);
expect(uri.port == null);
expectEqualStrings("oasis:names:specification:docbook:dtd:xml:4.1.2", uri.path);
expectEqualStrings("", uri.query);
expectEqualStrings("", uri.fragment);
expect(uri.len == 51);
}
test "userinfo" {
const uri = try Uri.parse("ftp://username:password@host.com/", false);
expectEqualStrings("ftp", uri.scheme);
expectEqualStrings("username", uri.username);
expectEqualStrings("password", uri.password);
expectEqualStrings("host.com", uri.host.name);
expect(uri.port.? == 21);
expectEqualStrings("/", uri.path);
expectEqualStrings("", uri.query);
expectEqualStrings("", uri.fragment);
expect(uri.len == 33);
}
test "map query" {
const uri = try Uri.parse("https://ziglang.org:80/documentation/master/?test;1=true&false#toc-Introduction", false);
expectEqualStrings("https", uri.scheme);
expectEqualStrings("", uri.username);
expectEqualStrings("", uri.password);
expectEqualStrings("ziglang.org", uri.host.name);
expect(uri.port.? == 80);
expectEqualStrings("/documentation/master/", uri.path);
expectEqualStrings("test;1=true&false", uri.query);
expectEqualStrings("toc-Introduction", uri.fragment);
var map = try Uri.mapQuery(std.testing.allocator, uri.query);
defer map.deinit();
expectEqualStrings("true", map.get("test;1").?);
expectEqualStrings("", map.get("false").?);
}
test "ends in space" {
const uri = try Uri.parse("https://ziglang.org/documentation/master/ something else", false);
expectEqualStrings("https", uri.scheme);
expectEqualStrings("", uri.username);
expectEqualStrings("", uri.password);
expectEqualStrings("ziglang.org", uri.host.name);
expectEqualStrings("/documentation/master/", uri.path);
expect(uri.len == 41);
}
test "assume auth" {
const uri = try Uri.parse("ziglang.org", true);
expectEqualStrings("ziglang.org", uri.host.name);
expect(uri.len == 11);
}
test "username contains @" {
const uri = try Uri.parse("https://1.1.1.1&@2.2.2.2%23@3.3.3.3", false);
expectEqualStrings("https", uri.scheme);
expectEqualStrings("1.1.1.1&@2.2.2.2%23", uri.username);
expectEqualStrings("", uri.password);
var buf = [_]u8{0} ** 100;
var ip = std.fmt.bufPrint(buf[0..], "{}", .{uri.host.ip}) catch unreachable;
expectEqualStrings("3.3.3.3:443", ip);
expect(uri.port.? == 443);
expectEqualStrings("", uri.path);
expect(uri.len == 35);
}
test "encode" {
const path = (try Uri.encode(testing.allocator, "/안녕하세요.html")).?;
defer testing.allocator.free(path);
expectEqualStrings("/%EC%95%88%EB%85%95%ED%95%98%EC%84%B8%EC%9A%94.html", path);
}
test "decode" {
const path = (try Uri.decode(testing.allocator, "/%EC%95%88%EB%85%95%ED%95%98%EC%84%B8%EC%9A%94.html")).?;
defer testing.allocator.free(path);
expectEqualStrings("/안녕하세요.html", path);
}
test "resolvePath" {
var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
defer arena.deinit();
const alloc = &arena.allocator;
var a = try Uri.resolvePath(alloc, "/a/b/..");
expectEqualStrings("/a", a);
a = try Uri.resolvePath(alloc, "/a/b/../");
expectEqualStrings("/a/", a);
a = try Uri.resolvePath(alloc, "/a/b/c/../d/../");
expectEqualStrings("/a/b/", a);
a = try Uri.resolvePath(alloc, "/a/b/c/../d/..");
expectEqualStrings("/a/b", a);
a = try Uri.resolvePath(alloc, "/a/b/c/../d/.././");
expectEqualStrings("/a/b/", a);
a = try Uri.resolvePath(alloc, "/a/b/c/../d/../.");
expectEqualStrings("/a/b", a);
a = try Uri.resolvePath(alloc, "/a/../../");
expectEqualStrings("/", a);
}
|
src/zigly/zuri/zuri.zig
|
const std = @import("std");
const Texture = @import("Texture.zig");
const TextureView = @import("TextureView.zig");
const PresentMode = @import("enums.zig").PresentMode;
const SwapChain = @This();
/// The type erased pointer to the SwapChain implementation
/// Equal to c.WGPUSwapChain for NativeInstance.
ptr: *anyopaque,
vtable: *const VTable,
pub const VTable = struct {
reference: fn (ptr: *anyopaque) void,
release: fn (ptr: *anyopaque) void,
configure: fn (ptr: *anyopaque, format: Texture.Format, allowed_usage: Texture.Usage, width: u32, height: u32) void,
getCurrentTextureView: fn (ptr: *anyopaque) TextureView,
present: fn (ptr: *anyopaque) void,
};
pub inline fn reference(swap_chain: SwapChain) void {
swap_chain.vtable.reference(swap_chain.ptr);
}
pub inline fn release(swap_chain: SwapChain) void {
swap_chain.vtable.release(swap_chain.ptr);
}
// TODO: remove this and/or prefix with dawn? Seems to be deprecated / not in upstream webgpu.h
pub inline fn configure(
swap_chain: SwapChain,
format: Texture.Format,
allowed_usage: Texture.Usage,
width: u32,
height: u32,
) void {
swap_chain.vtable.configure(swap_chain.ptr, format, allowed_usage, width, height);
}
pub inline fn getCurrentTextureView(swap_chain: SwapChain) TextureView {
return swap_chain.vtable.getCurrentTextureView(swap_chain.ptr);
}
pub inline fn present(swap_chain: SwapChain) void {
swap_chain.vtable.present(swap_chain.ptr);
}
pub const Descriptor = struct {
label: ?[:0]const u8 = null,
usage: Texture.Usage,
format: Texture.Format,
width: u32,
height: u32,
present_mode: PresentMode,
implementation: u64,
pub fn equal(a: *const Descriptor, b: *const Descriptor) bool {
if ((a.label == null) != (b.label == null)) return false;
if (a.label != null and !std.mem.eql(u8, a.label.?, b.label.?)) return false;
if (!a.usage.equal(b.usage)) return false;
if (a.format != b.format) return false;
if (a.width != b.width) return false;
if (a.height != b.height) return false;
if (a.present_mode != b.present_mode) return false;
if (a.implementation != b.implementation) return false;
return true;
}
};
test {
_ = VTable;
_ = reference;
_ = release;
_ = configure;
_ = getCurrentTextureView;
_ = present;
_ = Descriptor;
}
|
gpu/src/SwapChain.zig
|
const std = @import("std");
const print = std.debug.print;
const Allocator = std.mem.Allocator;
const str = []const u8;
pub const Cli = @This();
allocator: std.mem.Allocator = std.heap.c_allocator,
cmds: *std.BufSet,
matches: *std.BufSet,
opts: std.ArrayList(Arg) = std.ArrayList(Arg).init(std.heap.c_allocator),
args: std.ArrayList([:0]u8) = std.ArrayList([:0]u8).init(std.heap.c_allocator),
pub fn init(a: std.mem.Allocator, ops: []Arg, args: [][:0]u8) !*Cli {
var opt = std.ArrayList(Arg).init(a);
var as = std.ArrayList([:0]u8).init(a);
try as.appendSlice(args);
try opt.appendSlice(ops);
var match = Cli.verify_matches(a, opt);
defer _ = match.deinit();
var cmds = Cli.cmdSet(a, opt);
var cli = Cli{
.opts = opt,
.allocator = a,
.args = as,
.matches = &match,
.cmds = &cmds,
};
return Cli.parse(&cli);
}
pub fn verify_matches(a: Allocator, opts: std.ArrayList(Arg)) std.BufSet {
var match = std.BufSet.init(a);
for (opts.items) |opt| {
if (match.contains(opt.short))
@panic("Short key already exists!")
else if (match.contains(opt.long))
@panic("Long key already exists!")
else {
match.insert(opt.short) catch unreachable;
match.insert(opt.long) catch unreachable;
}
}
return match;
}
pub fn cmdSet(a: Allocator, opts: std.ArrayList(Arg)) std.BufSet {
var cmds = std.BufSet.init(a);
for (opts.items) |o|
if (!Arg.isCmd(o))
continue
else if (cmds.contains(o.short))
@panic("Short cmd already exists!")
else if (cmds.contains(o.long))
@panic("Long cmd already exists!")
else {
cmds.insert(o.short) catch unreachable;
cmds.insert(o.long) catch unreachable;
};
return cmds;
}
pub fn deinit(self: Cli) void {
self.allocator.free(self.opts);
self.matches.deinit();
}
pub fn fromArg(self: Cli, arg: Arg) void {
switch(arg.kind) {
.cmd => |c| if (c) { self.cmd = arg.long; },
.opt => |v| if (v) |val| { @field(self, arg.long) = val; },
.flag => |f| if (f) { @field(self, arg.long) = f; },
}
}
pub fn eq(arg: str, short: str, long: str) bool {
return (std.mem.eql(u8, arg, long) or std.mem.eql(u8, arg, short));
}
pub fn parse(self: *Cli) *Cli {
var fl = false;
var len = self.args.items.len;
for (self.args.items) |arg, i| {
if (fl) { fl = false; continue; }
for (self.opts.items) |op, j| if (op.eq(arg)) {
var nx: ?[:0]u8 = if (i == len - 1) null else self.args.items[i + 1];
self.opts.items[j].pos = i;
switch (op.kind) {
.cmd => |_| {
if (i < 3)
self.opts.items[j].kind = Arg.Kind{.cmd = i}
else
@panic("Command given with position > 2 -- invalid");
},
.flag => |_| { self.opts.items[j].kind = Arg.Kind{ .flag = true }; },
.opt => |_| { self.opts.items[j].kind = Arg.Kind{ .opt = if (nx) |n| n else null }; fl = true; },
}
};
}
return self;
}
pub fn printJson(self: Cli) !void {
try std.json.stringify(self, .{}, std.io.getStdOut().writer());
}
pub fn printCmd(self: Cli) void {
var i: usize = 0;
while (self.cmds.hash_map.keyIterator().next()) |k| : (i += 1) {
std.debug.print("{d}: matches: {s} \n", .{i, k});
}
}
pub fn printMatches(self: Cli) void {
var i: usize = 0;
while (self.matches.hash_map.keyIterator().next()) |k| : (i += 1) {
std.debug.print("{d}: matches: {s} \n", .{i, k});
}
}
pub fn printOpts(sf: *Cli) void {
const ots = sf.opts;
const w: usize = 10;
const shortw: usize = 7;
const valw: usize = 7;
print("\x1b[32;1m{s:<5} \x1b[32;1m{s:[4]} \x1b[32;1m{s:[5]} {s:>[6]}\n", .{"TYPE ", "SHORT", "LONG", "VALUE", shortw, w, valw});
print("\x1b[39;1m{s:-<4} {s:[4]} \x1b[39;1m{s:[5]} {s:>[6]}\n", .{"", "-----", "----", "-----", shortw, w, valw});
for (ots.items) |r| {
switch (r.kind) {
.cmd => |c| print("\x1b[32;1m{s:>5} \x1b[0m\x1b[32m{s:>[4]} \x1b[32;1m{s:>[5]} \x1b[0m{d:>[6]}\n", .{"Cmd", r.short, r.long, c, shortw, w, valw}),
.opt => |o| print("\x1b[31;1m{s:>5} \x1b[0m\x1b[35m{s:>[4]} \x1b[35;1m{s:>[5]} \x1b[0m{s:>[6]}\n", .{"Opt", r.short, r.long, o, shortw, w, valw}),
.flag=> |f| print("\x1b[34;1m{s:>5} \x1b[0m\x1b[36m{s:>[4]} \x1b[36;1m{s:>[5]} \x1b[0m{s:>[6]}\n", .{"Flag", r.short, r.long, f, shortw, w, valw}),
}
}
}
pub const Arg = struct {
short: str,
long: str,
pos: ?usize = null,
kind: Kind,
pub fn isCmd(self: Arg) bool {
return (!std.mem.startsWith(u8, self.short, "-") and !std.mem.startsWith(u8, self.long, "--"));
}
pub fn isSubcmd(self: Arg) ?bool {
if (self.isCmd()) if (self.pos) |pos|
if (pos == 1) return false
else if (pos == 2) return true
else return null; //@panic("Invalid position for cmd");
}
pub fn eq(self: Arg, arg: str) bool {
return (std.mem.eql(u8, arg, self.short) or std.mem.eql(u8, arg, self.long));
}
const Kind = union(enum) {
cmd: ?usize,
flag: bool,
opt: ?[]const u8,
const Cmd = struct {
pos: ?usize = null,
takes_sub: bool = true,
sub: ?[]const u8,
};
};
pub fn opt(comptime short: str, comptime long: str) Arg {
return Arg{ .short = "-"++short, .long = "--"++long, .kind = Kind{.opt = null} };
}
pub fn flag(comptime short: str, comptime long: str) Arg {
return Arg{ .short = "-"++short, .long = "--"++long, .kind = Kind{.flag = false} };
}
pub fn cmd(comptime short: str, comptime long: str) Arg {
return Arg{ .short = short, .long = long, .kind = Kind{.cmd = null} };
}
};
pub var user_opts = [_]Cli.Arg{
Cli.Arg.opt("n", "name"),
Cli.Arg.opt("d", "dir"),
Cli.Arg.opt("P", "profile"),
Cli.Arg.opt("k", "key"),
// };
// pub var user_cmds = [_]Cli.Arg{
Cli.Arg.cmd("b", "build"),
Cli.Arg.cmd("k", "keys"),
Cli.Arg.cmd("i", "init"),
Cli.Arg.cmd("r", "run"),
// Cli.Arg.cmd("R", "repl"),
// Cli.Arg.cmd("a", "auth"),
// Cli.Arg.cmd("s", "sync"),
Cli.Arg.cmd("c", "conf"),
// Cli.Arg.cmd("g", "guide"),
// };
// pub var user_flags = [_]Cli.Arg{
Cli.Arg.flag("I", "info"),
Cli.Arg.flag("Q", "quiet"),
Cli.Arg.flag("C", "colors")
};
|
src/util/cli.zig
|
const std = @import("std");
const arm_m = @import("arm_m");
const timer = @import("ports/" ++ @import("build_options").BOARD ++ "/timer.zig").timer0;
const tzmcfi = @cImport(@cInclude("TZmCFI/Gateway.h"));
const warn = @import("nonsecure-common/debug.zig").warn;
const port = @import("ports/" ++ @import("build_options").BOARD ++ "/nonsecure.zig");
const nonsecure_init = @import("nonsecure-common/init.zig");
// FreeRTOS-related thingy
const os = @cImport({
@cInclude("FreeRTOS.h");
@cInclude("task.h");
@cInclude("timers.h");
@cInclude("semphr.h");
});
comptime {
_ = @import("nonsecure-common/oshooks.zig");
}
// The (unprocessed) Non-Secure exception vector table.
export const raw_exception_vectors linksection(".text.raw_isr_vector") = @import("nonsecure-common/excvector.zig").getDefaultFreertos();
// The entry point. The reset handler transfers the control to this function
// after initializing data sections.
export fn main() void {
port.init();
nonsecure_init.disableNestedExceptionIfDisallowed();
warn("%output-start\r\n", .{});
warn("{{\r\n", .{});
seqmon.mark(0);
// Get the measurement overhead
measure.calculateOverhead();
warn(" \"Overhead\": {}, /* [cycles] (this value is subtracted from all subsequent measurements) */\r\n", .{measure.overhead.*});
global_mutex.* = xSemaphoreCreateBinary();
_ = xSemaphoreGive(global_mutex.*);
_ = os.xTaskCreateRestricted(&task1_params, 0);
os.vTaskStartScheduler();
unreachable;
}
var task1_stack align(32) = [1]u32{0} ** 192;
const regions_with_peripheral_access = [3]os.MemoryRegion_t{
// TODO: It seems that this is actually not needed for measurements to work.
// Investigate why
os.MemoryRegion_t{
.pvBaseAddress = @intToPtr(*c_void, 0x40000000),
.ulLengthInBytes = 0x10000000,
.ulParameters = 0,
},
os.MemoryRegion_t{
.pvBaseAddress = @ptrCast(*c_void, &unpriv_state),
.ulLengthInBytes = @sizeOf(@TypeOf(unpriv_state)) + 32,
.ulParameters = 0,
},
os.MemoryRegion_t{
.pvBaseAddress = null,
.ulLengthInBytes = 0,
.ulParameters = 0,
},
};
const task1_params = os.TaskParameters_t{
.pvTaskCode = task1Main,
.pcName = "task1",
.usStackDepth = task1_stack.len,
.pvParameters = null,
.uxPriority = 2 | os.portPRIVILEGE_BIT,
.puxStackBuffer = &task1_stack,
.xRegions = regions_with_peripheral_access,
.pxTaskBuffer = null,
};
var task2_stack align(32) = [1]u32{0} ** 192;
const task2a_params = os.TaskParameters_t{
.pvTaskCode = task2aMain,
.pcName = "task2a",
.usStackDepth = task2_stack.len,
.pvParameters = null,
.uxPriority = 4, // > task1
.puxStackBuffer = &task2_stack,
.xRegions = regions_with_peripheral_access,
.pxTaskBuffer = null,
};
const task2b_params = os.TaskParameters_t{
.pvTaskCode = task2bMain,
.pcName = "task2b",
.usStackDepth = task2_stack.len,
.pvParameters = null,
.uxPriority = 4, // > task1
.puxStackBuffer = &task2_stack,
.xRegions = regions_with_peripheral_access,
.pxTaskBuffer = null,
};
var task3_stack align(32) = [1]u32{0} ** 32;
const task3_params = os.TaskParameters_t{
.pvTaskCode = badTaskMain,
.pcName = "task3",
.usStackDepth = task3_stack.len,
.pvParameters = null,
.uxPriority = 0, // must be the lowest
.puxStackBuffer = &task3_stack,
.xRegions = regions_with_peripheral_access,
.pxTaskBuffer = null,
};
const global_mutex = &unpriv_state.global_mutex;
fn task1Main(_arg: ?*c_void) callconv(.C) void {
// Disable SysTick
arm_m.sys_tick.regCsr().* = 0;
// Make us unprivileged
os.vResetPrivilege();
// -----------------------------------------------------------------------
seqmon.mark(1);
// `xTaskCreateRestricted` without dispatch
var task3_handle: os.TaskHandle_t = undefined;
measure.start();
_ = os.xTaskCreateRestricted(&task3_params, &task3_handle);
measure.end();
warn(" \"NewTask\": {}, /* [cycles] (Unpriv xTaskCreateRestricted without dispatch) */\r\n", .{measure.getNumCycles()});
// `vTaskDelete`
measure.start();
_ = os.vTaskDelete(task3_handle);
measure.end();
warn(" \"DelTask\": {}, /* [cycles] (Unpriv vTaskDelete without dispatch) */\r\n", .{measure.getNumCycles()});
seqmon.mark(2);
// `xTaskCreateRestricted` without dispatch
var task2_handle: os.TaskHandle_t = undefined;
measure.start();
_ = os.xTaskCreateRestricted(&task2a_params, &task2_handle);
// task2 returns to here by calling `vTaskDelete`
measure.end();
seqmon.mark(4);
warn(" \"DelTask+disp\": {}, /* [cycles] (Unpriv vTaskDelete with dispatch) */\r\n", .{measure.getNumCycles()});
// `xSemaphoreTake` without dispatch
measure.start();
_ = xSemaphoreTake(global_mutex.*, portMAX_DELAY);
measure.end();
warn(" \"SemTake\": {}, /* [cycles] (Unpriv xSemaphoreTake without dispatch) */\r\n", .{measure.getNumCycles()});
// `xSemaphoreGive` without dispatch
measure.start();
_ = xSemaphoreGive(global_mutex.*);
measure.end();
warn(" \"SemGive\": {}, /* [cycles] (Unpriv xSemaphoreGive without dispatch) */\r\n", .{measure.getNumCycles()});
seqmon.mark(5);
_ = xSemaphoreTake(global_mutex.*, portMAX_DELAY);
// Create a high-priority task `task2b` to be dispatched on `xSemaphoreGive`
_ = os.xTaskCreateRestricted(&task2b_params, &task2_handle);
seqmon.mark(7);
// `xSemaphoreTake` with dispatch (to `task2b`)
measure.start();
_ = xSemaphoreGive(global_mutex.*);
seqmon.mark(9);
warn("}}\r\n", .{});
warn("%output-end\r\n", .{});
warn("Done!\r\n", .{});
while (true) {}
}
fn task2aMain(_arg: ?*c_void) callconv(.C) void {
measure.end();
warn(" \"NewTask+disp\": {}, /* [cycles] (Unpriv xTaskCreateRestricted with dispatch) */\r\n", .{measure.getNumCycles()});
seqmon.mark(3);
// `vTaskDelete`
measure.start();
_ = os.vTaskDelete(null);
unreachable;
}
fn task2bMain(_arg: ?*c_void) callconv(.C) void {
seqmon.mark(6);
// This will block and gives the control back to task1
_ = xSemaphoreTake(global_mutex.*, portMAX_DELAY);
measure.end();
warn(" \"SemGive+disp\": {}, /* [cycles] (Unpriv xSemaphoreGive with dispatch) */\r\n", .{measure.getNumCycles()});
seqmon.mark(8);
_ = os.vTaskDelete(null);
unreachable;
}
fn badTaskMain(_arg: ?*c_void) callconv(.C) void {
@panic("this task is not supposed to run");
}
/// unprivilileged state data
var unpriv_state align(32) = struct {
overhead: i32 = 0,
next_ordinal: u32 = 0,
global_mutex: os.SemaphoreHandle_t = undefined,
}{};
/// Measurement routines
const measure = struct {
const TIMER_RESET_VALUE: u32 = 0x800000;
const overhead = &unpriv_state.overhead;
fn __measureStart() void {
tzmcfi.TCDebugStartProfiler();
timer.setValue(TIMER_RESET_VALUE);
timer.start(); // enable
}
fn __measureEnd() void {
timer.stop();
tzmcfi.TCDebugStopProfiler();
tzmcfi.TCDebugDumpProfile();
}
inline fn start() void {
// Defeat inlining for consistent timing
@call(.{ .modifier = .never_inline }, __measureStart, .{});
}
inline fn end() void {
@call(.{ .modifier = .never_inline }, __measureEnd, .{});
}
fn calculateOverhead() void {
start();
end();
overhead.* = getNumCycles();
}
fn getNumCycles() i32 {
return @intCast(i32, TIMER_RESET_VALUE - timer.getValue()) - overhead.*;
}
};
/// Execution sequence monitoring
const seqmon = struct {
const next_ordinal = &unpriv_state.next_ordinal;
/// Declare a checkpoint. `ordinal` is a sequence number that starts at
/// `0`. Aborts the execution on a sequence violation.
fn mark(ordinal: u32) void {
if (ordinal != next_ordinal.*) {
warn("execution sequence violation: expected {}, got {}\r\n", .{ ordinal, next_ordinal.* });
@panic("execution sequence violation");
}
warn(" /* [{}] */\r\n", .{ordinal});
next_ordinal.* += 1;
}
};
// FreeRTOS wrapper
const queueQUEUE_TYPE_MUTEX = 1;
const queueQUEUE_TYPE_BINARY_SEMAPHORE = 3;
const semGIVE_BLOCK_TIME = 0;
const semSEMAPHORE_QUEUE_ITEM_LENGTH = 0;
const portMAX_DELAY = 0xffffffff;
fn xSemaphoreCreateBinary() os.SemaphoreHandle_t {
return os.xQueueGenericCreate(1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE);
}
const xSemaphoreTake = os.xQueueSemaphoreTake;
fn xSemaphoreGive(semaphore: os.SemaphoreHandle_t) @TypeOf(os.xQueueGenericSend).ReturnType {
return os.xQueueGenericSend(semaphore, null, semGIVE_BLOCK_TIME, os.queueSEND_TO_BACK);
}
// Zig panic handler. See `panicking.zig` for details.
const panicking = @import("nonsecure-common/panicking.zig");
pub fn panic(msg: []const u8, error_return_trace: ?*panicking.StackTrace) noreturn {
panicking.panic(msg, error_return_trace);
}
|
examples/nonsecure-bench-rtos.zig
|
//--------------------------------------------------------------------------------
// Section: Types (1)
//--------------------------------------------------------------------------------
const IID_IIsolatedEnvironmentInterop_Value = Guid.initString("85713c2e-8e62-46c5-8de2-c647e1d54636");
pub const IID_IIsolatedEnvironmentInterop = &IID_IIsolatedEnvironmentInterop_Value;
pub const IIsolatedEnvironmentInterop = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetHostHwndInterop: fn(
self: *const IIsolatedEnvironmentInterop,
containerHwnd: ?HWND,
hostHwnd: ?*?HWND,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IIsolatedEnvironmentInterop_GetHostHwndInterop(self: *const T, containerHwnd: ?HWND, hostHwnd: ?*?HWND) callconv(.Inline) HRESULT {
return @ptrCast(*const IIsolatedEnvironmentInterop.VTable, self.vtable).GetHostHwndInterop(@ptrCast(*const IIsolatedEnvironmentInterop, self), containerHwnd, hostHwnd);
}
};}
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 (4)
//--------------------------------------------------------------------------------
const Guid = @import("../../zig.zig").Guid;
const HRESULT = @import("../../foundation.zig").HRESULT;
const HWND = @import("../../foundation.zig").HWND;
const IUnknown = @import("../../system/com.zig").IUnknown;
test {
@setEvalBranchQuota(
@import("std").meta.declarations(@This()).len * 3
);
// reference all the pub declarations
if (!@import("builtin").is_test) return;
inline for (@import("std").meta.declarations(@This())) |decl| {
if (decl.is_pub) {
_ = decl;
}
}
}
|
win32/system/win_rt/isolation.zig
|
const std = @import("std");
pub const Config = struct {};
pub const Mesh = struct {
const Self = @This();
allocator: *std.mem.Allocator,
positions: [][3]f32,
normals: [][3]f32,
uvs: [][2]f32,
indices: []u32,
pub fn deinit(self: *Self) void {
self.allocator.free(self.positions);
self.allocator.free(self.normals);
self.allocator.free(self.uvs);
self.allocator.free(self.indices);
}
};
const Index = struct {
position: u32,
normal: u32,
uv: u32,
};
pub fn parseObjFile(
allocator: *std.mem.Allocator,
reader: anytype,
comptime config: Config,
) !Mesh {
var buffer: [1024]u8 = undefined;
var obj_positions = std.ArrayList([3]f32).init(allocator);
defer obj_positions.deinit();
var obj_normals = std.ArrayList([3]f32).init(allocator);
defer obj_normals.deinit();
var obj_uvs = std.ArrayList([2]f32).init(allocator);
defer obj_uvs.deinit();
var obj_indices = std.ArrayList(Index).init(allocator);
defer obj_indices.deinit();
//Read mesh data from file
while (try reader.readUntilDelimiterOrEof(&buffer, '\n')) |line_with_white_space| {
var line = std.mem.trimLeft(u8, line_with_white_space, " \t");
//Filter out comments
if (line[0] != '#') {
var line_split = std.mem.tokenize(line, " ");
var op = line_split.next().?;
//std.log.info("{s}.{}", .{ op, op.len });
if (std.mem.eql(u8, op, "o")) {
std.log.info("Object: {s}", .{line_split.next().?});
} else if (std.mem.eql(u8, op, "v")) {
var value1 = try std.fmt.parseFloat(f32, line_split.next().?);
var value2 = try std.fmt.parseFloat(f32, line_split.next().?);
var value3 = try std.fmt.parseFloat(f32, line_split.next().?);
try obj_positions.append([3]f32{ value1, value2, value3 });
} else if (std.mem.eql(u8, op, "vn")) {
var value1 = try std.fmt.parseFloat(f32, line_split.next().?);
var value2 = try std.fmt.parseFloat(f32, line_split.next().?);
var value3 = try std.fmt.parseFloat(f32, line_split.next().?);
try obj_normals.append([3]f32{ value1, value2, value3 });
} else if (std.mem.eql(u8, op, "vt")) {
var value1 = try std.fmt.parseFloat(f32, line_split.next().?);
var value2 = try std.fmt.parseFloat(f32, line_split.next().?);
try obj_uvs.append([2]f32{ value1, value2 });
} else if (std.mem.eql(u8, op, "f")) {
//TODO: Triangulate Ngons
var index1 = try parseIndex(line_split.next().?);
var index2 = try parseIndex(line_split.next().?);
var index3 = try parseIndex(line_split.next().?);
try obj_indices.appendSlice(&[_]Index{ index1, index2, index3 });
} else if (std.mem.eql(u8, op, "s")) {
//Do nothing
}
}
}
std.log.info("Positions: {}", .{obj_positions.items.len});
std.log.info("Normals: {}", .{obj_normals.items.len});
std.log.info("Uvs: {}", .{obj_uvs.items.len});
std.log.info("Indices: {}", .{obj_indices.items.len});
//Reorder to indexed arrays and remove duplicate vertices
var positions = std.ArrayList([3]f32).init(allocator);
var normals = std.ArrayList([3]f32).init(allocator);
var uvs = std.ArrayList([2]f32).init(allocator);
var indices = try std.ArrayList(u32).initCapacity(allocator, obj_indices.items.len);
var vertex_to_index_map = std.AutoHashMap(Index, u32).init(allocator);
defer vertex_to_index_map.deinit();
var reused_vertices: usize = 0;
for (obj_indices.items) |index| {
if (vertex_to_index_map.get(index)) |resuse_index| {
try indices.append(resuse_index);
reused_vertices += 1;
} else {
var new_index = @intCast(u32, positions.items.len);
try positions.append(obj_positions.items[index.position - 1]);
try normals.append(obj_normals.items[index.normal - 1]);
try uvs.append(obj_uvs.items[index.uv - 1]);
try vertex_to_index_map.put(index, new_index);
try indices.append(new_index);
}
}
std.log.info("Reused {} vertices!", .{reused_vertices});
return Mesh{
.allocator = allocator,
.positions = positions.toOwnedSlice(),
.normals = normals.toOwnedSlice(),
.uvs = uvs.toOwnedSlice(),
.indices = indices.toOwnedSlice(),
};
}
fn parseIndex(index_string: []const u8) !Index {
var line_split = std.mem.tokenize(index_string, "/");
var position = try std.fmt.parseInt(u32, line_split.next().?, 10);
var uv = try std.fmt.parseInt(u32, line_split.next().?, 10);
var normal = try std.fmt.parseInt(u32, line_split.next().?, 10);
return Index{
.position = position,
.uv = uv,
.normal = normal,
};
}
|
src/lib.zig
|
const std = @import("std");
const math = @import("math.zig");
const daedelus = @import("daedelus.zig");
const Vec3 = math.Vec3;
const Allocator = std.mem.Allocator;
const Random = std.rand.Random;
const Vec3f = Vec3(f32);
const Material = union(enum) {
Metal: struct {
reflectCol: Vec3f,
emitCol: Vec3f,
reflectance: f32,
},
};
const Sphere = struct {
o: Vec3f,
r: f32,
m: Material,
};
const OutputType = enum { Linear, Srgb };
fn f32ToOut8(f: f32, out_type: OutputType) u8 {
return switch (out_type) {
.Srgb => math.f32ToSrgb8(f),
.Linear => math.f32ToLinear8(f),
};
}
extern fn raytraceIspc(u32, u32, [*]daedelus.Pixel, usize, [*]const ExternSphere) void;
const HitRecord = struct {
p: Vec3f,
n: Vec3f,
t: f32,
m: Material,
};
pub const ExternSphere = extern struct { o: Vec3f, r: f32 };
fn sphereToExternSphere(s: Sphere) ExternSphere {
return .{ .o = s.o, .r = s.r };
}
fn reflect(v: Vec3f, n: Vec3f) Vec3f {
return v.sub(n.mulScalar(2 * v.dot(n)));
}
fn hitSphere(s: Sphere, r: math.Ray(f32)) ?HitRecord {
const oc =
r.p.sub(s.o);
const a = r.dir.squareLen();
const half_b =
oc.dot(r.dir);
const c = oc.dot(oc) - (s.r * s.r);
const discriminant = half_b * half_b - a * c;
if (discriminant < 0) {
return null;
} else {
const t1 = -half_b - @sqrt(discriminant) / a;
const t2 = -half_b + @sqrt(discriminant) / a;
if (t1 > 0.001) {
const p = r.pointAtDistance(t1);
const n = p.sub(s.o).normalize();
return HitRecord{
.p = p,
.n = n,
.t = t1,
.m = s.m,
};
} else if (t2 > 0.001) {
const p = r.pointAtDistance(t2);
const n = p.sub(s.o).mulScalar(-1).normalize();
return HitRecord{
.p = p,
.n = n,
.t = t2,
.m = s.m,
};
} else {
return null;
}
}
}
fn rayColor(r: math.Ray(f32), spheres: []const Sphere, rng: *Random) Vec3f {
const max_bounce_count = 8;
var iter = ForwardInterator(u32).init(0, max_bounce_count, 1);
var col = Vec3f.init(0, 0, 0);
var accum = Vec3f.init(1, 1, 1);
var ray = r;
while (iter.next()) |_| {
var min_t = std.math.inf_f32;
var best_hit = @as(?HitRecord, null);
for (spheres) |s| {
if (hitSphere(s, ray)) |hit| {
if (hit.t < min_t) {
best_hit = hit;
min_t = hit.t;
}
}
}
if (best_hit) |h| {
switch (h.m) {
.Metal => |m| {
const pure_bounce = reflect(ray.dir, h.n);
const random_bounce = h.n.add(math.randomInUnitHemisphere(rng, h.n));
var direction = math.lerp(pure_bounce, random_bounce, m.reflectance);
ray = math.Ray(f32){ .p = h.p, .dir = direction.normalize() };
col = col.add(m.emitCol.mul(accum));
accum = accum.mul(m.reflectCol);
},
}
} else {
const t = ray.dir.pos.y * 0.5 + 0.5;
const white = Vec3f.init(1, 1, 1);
const blue = Vec3f.init(0.5, 0.7, 1);
const background = math.lerp(blue, white, t);
col = col.add(background.mul(accum));
break;
}
}
return col;
}
fn raytraceRegion(
bitmap: *daedelus.Bitmap,
spheres: []const Sphere,
full_image_offset_x: usize,
full_image_offset_y: usize,
full_image_width: usize,
full_image_height: usize,
camera_pos: Vec3f,
rng: *Random,
out_type: OutputType,
) void {
const focal_length = 1;
const aspect = @intToFloat(f32, full_image_width) / @intToFloat(f32, full_image_height);
const view_width = 2.0;
const view_height = view_width / aspect;
const horizontal = Vec3f.init(view_width, 0, 0);
const vertical = Vec3f.init(0, view_height, 0);
const upper_left_corner = vertical.divScalar(2).sub(horizontal.divScalar(2)).sub(Vec3f.init(0, 0, focal_length));
var row_iterator = bitmap.rowIterator();
while (row_iterator.next()) |row| {
for (row.pixels) |*p, i| {
{
const sample_count = 25;
var iterator = ForwardInterator(u32).init(0, sample_count, 1);
var col = Vec3f.init(0, 0, 0);
while (iterator.next()) |_| {
const u =
(@intToFloat(f32, i + bitmap.x_offset - full_image_offset_x) +
rng.float(f32)) /
@intToFloat(f32, full_image_width - 1);
const v =
(@intToFloat(f32, row.row + bitmap.y_offset - full_image_offset_y) +
rng.float(f32)) /
@intToFloat(f32, full_image_height - 1);
const ray = math.Ray(f32){
.dir = upper_left_corner.add(horizontal.mulScalar(u)).sub(
vertical.mulScalar(v),
).normalize(),
.p = camera_pos,
};
col = col.add(rayColor(ray, spheres, rng));
}
p.* = .{
.comp = .{
.r = f32ToOut8(col.col.r / sample_count, out_type),
.g = f32ToOut8(col.col.g / sample_count, out_type),
.b = f32ToOut8(col.col.b / sample_count, out_type),
.a = 255,
},
};
}
}
}
}
const RaytraceRegionThreadContext = struct {
bmp: *daedelus.Bitmap,
full_image_width: usize,
full_image_height: usize,
full_image_offset_x: usize,
full_image_offset_y: usize,
camera_pos: Vec3f,
spheres: []const Sphere,
rng_seed: u64,
out_type: OutputType,
};
fn raytraceRegionThread(c: RaytraceRegionThreadContext) void {
var r = std.rand.DefaultPrng.init(c.rng_seed);
raytraceRegion(
c.bmp,
c.spheres,
c.full_image_offset_x,
c.full_image_offset_y,
c.full_image_width,
c.full_image_height,
c.camera_pos,
&r.random,
c.out_type,
);
}
fn raytraceZigScalar(
bitmap: *daedelus.Bitmap,
spheres: []const Sphere,
camera_pos: Vec3f,
out_type: OutputType,
) !void {
var sub_bitmaps = @as([16]daedelus.Bitmap, undefined);
var threads = @as([sub_bitmaps.len]*std.Thread, undefined);
const n = std.math.sqrt(sub_bitmaps.len);
std.debug.assert(n * n == sub_bitmaps.len);
for (sub_bitmaps) |*b, i| {
b.* = bitmap.subBitmap(bitmap.width / n * (i % n), bitmap.height / n * (i / n), bitmap.width / n, bitmap.height / n);
threads[i] = try std.Thread.spawn(RaytraceRegionThreadContext{
.bmp = b,
.full_image_width = bitmap.width,
.full_image_height = bitmap.height,
.full_image_offset_x = 0,
.full_image_offset_y = 0,
.camera_pos = camera_pos,
.spheres = spheres,
.out_type = out_type,
.rng_seed = i,
}, raytraceRegionThread);
}
for (threads) |t| {
t.wait();
}
}
fn renderToBitmap(
allocator: *Allocator,
bitmap: *daedelus.Bitmap,
spheres: []const Sphere,
camera_pos: Vec3f,
out_type: OutputType,
) !void {
const use_ispc = false;
if (use_ispc) {
const espheres = try allocator.alloc(ExternSphere, spheres.len);
defer allocator.free(espheres);
for (espheres) |*s, i| {
s.* = sphereToExternSphere(spheres[i]);
}
raytraceIspc(bitmap.width, bitmap.height, bitmap.pixels.ptr, espheres.len, espheres.ptr);
} else {
try raytraceZigScalar(bitmap, spheres, camera_pos, out_type);
}
}
fn ForwardInterator(comptime T: type) type {
return struct {
steps: usize = 0,
low: T,
high: T,
step: T,
pub fn init(low: T, high: T, step: T) @This() {
std.debug.assert(low < high);
return .{ .low = low, .high = high, .step = step };
}
pub fn next(this: *@This()) ?T {
const i = @intCast(T, this.steps * this.step + this.low);
if (i < this.high) {
this.steps += 1;
return i;
} else {
return null;
}
}
};
}
const default_output_type = .Srgb;
pub fn main() void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = &gpa.allocator;
var daedelus_instance = daedelus.Instance.init(allocator, "ispc_raytracer") catch |err| {
daedelus.fatalErrorMessage(allocator, "Couldn't create instance", "Fatal error");
return;
};
defer daedelus_instance.deinit();
const window = daedelus_instance.createWindow(
"ispc-raytracer",
800,
400,
null,
null,
.{ .resizable = false },
) catch {
daedelus.fatalErrorMessage(allocator, "Couldn't create window", "Fatal error");
return;
};
defer window.close();
const window_dim = window.getSize();
window.show(); // TODO: show loading screen of some kind?
var bitmap = daedelus.Bitmap.create(allocator, window_dim.width, window_dim.height, .TopDown) catch unreachable;
defer bitmap.release(allocator);
const spheres = [_]Sphere{
.{
.o = Vec3f.init(0, 0, -1),
.r = 0.5,
.m = .{
.Metal = .{
.reflectCol = Vec3f.init(0.7, 0.3, 0.3),
.emitCol = Vec3f.init(0, 0, 0),
.reflectance = 0,
},
},
},
.{
.o = Vec3f.init(0, -100.5, -1),
.r = 100,
.m = .{
.Metal = .{
.reflectCol = Vec3f.init(0.8, 0.8, 0),
.emitCol = Vec3f.init(0, 0, 0),
.reflectance = 0,
},
},
},
.{
.o = Vec3f.init(-1, 0, -1),
.r = 0.5,
.m = .{
.Metal = .{
.reflectCol = Vec3f.init(0.8, 0.8, 0.8),
.emitCol = Vec3f.init(0, 0, 0),
.reflectance = 0.7,
},
},
},
.{
.o = Vec3f.init(1, 0, -1),
.r = 0.5,
.m = .{
.Metal = .{
.reflectCol = Vec3f.init(0.8, 0.6, 0.2),
.emitCol = Vec3f.init(0, 0, 0),
.reflectance = 0,
},
},
},
};
const timer = std.time.Timer.start() catch unreachable;
const start_time = timer.read();
renderToBitmap(allocator, &bitmap, spheres[0..], Vec3f.init(0, 0, 1), default_output_type) catch {
daedelus.fatalErrorMessage(allocator, "rendering failed", "rendering error");
};
const end_time = timer.read();
const raycast_time = @intToFloat(f32, (end_time - start_time)) * 1e-9;
const stderr = std.io.getStdErr().writer();
_ = stderr.print("Finished raycasting in {} seconds\n", .{raycast_time}) catch {};
var running = true;
while (running) {
switch (window.getEvent()) {
.CloseRequest => |_| {
running = false;
},
.RedrawRequest => |redraw_request| {
window.blit(bitmap, 0, 0) catch {
unreachable;
};
},
.WindowResize => {
daedelus.fatalErrorMessage(allocator, "How did this resize?", "Fatal error");
return;
},
}
}
}
//pub const log = daedelus.log;
export fn printSizeT(x: usize) void {
std.log.err("{}", .{x});
}
|
src/main.zig
|
const Self = @This();
const std = @import("std");
const mem = std.mem;
const wlr = @import("wlroots");
const wayland = @import("wayland");
const wl = wayland.server.wl;
const zriver = wayland.server.zriver;
const command = @import("command.zig");
const server = &@import("main.zig").server;
const util = @import("util.zig");
const Seat = @import("Seat.zig");
const Server = @import("Server.zig");
const ArgMap = std.AutoHashMap(struct { client: *wl.Client, id: u32 }, std.ArrayListUnmanaged([:0]const u8));
global: *wl.Global,
args_map: ArgMap,
server_destroy: wl.Listener(*wl.Server) = wl.Listener(*wl.Server).init(handleServerDestroy),
pub fn init(self: *Self) !void {
self.* = .{
.global = try wl.Global.create(server.wl_server, zriver.ControlV1, 1, *Self, self, bind),
.args_map = ArgMap.init(util.gpa),
};
server.wl_server.addDestroyListener(&self.server_destroy);
}
fn handleServerDestroy(listener: *wl.Listener(*wl.Server), wl_server: *wl.Server) void {
const self = @fieldParentPtr(Self, "server_destroy", listener);
self.global.destroy();
self.args_map.deinit();
}
/// Called when a client binds our global
fn bind(client: *wl.Client, self: *Self, version: u32, id: u32) callconv(.C) void {
const control = zriver.ControlV1.create(client, version, id) catch {
client.postNoMemory();
return;
};
self.args_map.putNoClobber(.{ .client = client, .id = id }, .{}) catch {
control.destroy();
client.postNoMemory();
return;
};
control.setHandler(*Self, handleRequest, handleDestroy, self);
}
fn handleRequest(control: *zriver.ControlV1, request: zriver.ControlV1.Request, self: *Self) void {
switch (request) {
.destroy => control.destroy(),
.add_argument => |add_argument| {
const owned_slice = util.gpa.dupeZ(u8, mem.span(add_argument.argument)) catch {
control.getClient().postNoMemory();
return;
};
const args = self.args_map.getPtr(.{ .client = control.getClient(), .id = control.getId() }).?;
args.append(util.gpa, owned_slice) catch {
control.getClient().postNoMemory();
util.gpa.free(owned_slice);
return;
};
},
.run_command => |run_command| {
const seat = @intToPtr(*Seat, wlr.Seat.Client.fromWlSeat(run_command.seat).?.seat.data);
const callback = zriver.CommandCallbackV1.create(
control.getClient(),
control.getVersion(),
run_command.callback,
) catch {
control.getClient().postNoMemory();
return;
};
const args = self.args_map.getPtr(.{ .client = control.getClient(), .id = control.getId() }).?;
defer {
for (args.items) |arg| util.gpa.free(arg);
args.items.len = 0;
}
var out: ?[]const u8 = null;
defer if (out) |s| util.gpa.free(s);
command.run(util.gpa, seat, args.items, &out) catch |err| {
const failure_message = switch (err) {
command.Error.OutOfMemory => {
callback.getClient().postNoMemory();
return;
},
command.Error.Other => std.cstr.addNullByte(util.gpa, out.?) catch {
callback.getClient().postNoMemory();
return;
},
else => command.errToMsg(err),
};
defer if (err == command.Error.Other) util.gpa.free(failure_message);
callback.sendFailure(failure_message);
return;
};
const success_message = if (out) |s|
util.gpa.dupeZ(u8, s) catch {
callback.getClient().postNoMemory();
return;
}
else
"";
defer if (out != null) util.gpa.free(success_message);
callback.sendSuccess(success_message);
},
}
}
/// Remove the resource from the hash map and free all stored args
fn handleDestroy(control: *zriver.ControlV1, self: *Self) void {
var args = self.args_map.fetchRemove(
.{ .client = control.getClient(), .id = control.getId() },
).?.value;
for (args.items) |arg| util.gpa.free(arg);
args.deinit(util.gpa);
}
|
source/river-0.1.0/river/Control.zig
|
const std = @import("std");
const pike = @import("pike.zig");
const posix = @import("os/posix.zig");
const Waker = @import("waker.zig").Waker;
const io = std.io;
const os = std.os;
const net = std.net;
const mem = std.mem;
const meta = std.meta;
pub const SocketOptionType = enum(u32) {
debug = os.SO.DEBUG,
listen = os.SO.ACCEPTCONN,
reuse_address = os.SO.REUSEADDR,
keep_alive = os.SO.KEEPALIVE,
dont_route = os.SO.DONTROUTE,
broadcast = os.SO.BROADCAST,
linger = os.SO.LINGER,
oob_inline = os.SO.OOBINLINE,
send_buffer_max_size = os.SO.SNDBUF,
recv_buffer_max_size = os.SO.RCVBUF,
send_buffer_min_size = os.SO.SNDLOWAT,
recv_buffer_min_size = os.SO.RCVLOWAT,
send_timeout = os.SO.SNDTIMEO,
recv_timeout = os.SO.RCVTIMEO,
socket_error = os.SO.ERROR,
socket_type = os.SO.TYPE,
};
pub const SocketOption = union(SocketOptionType) {
debug: bool,
listen: bool,
reuse_address: bool,
keep_alive: bool,
dont_route: bool,
broadcast: bool,
linger: posix.LINGER,
oob_inline: bool,
send_buffer_max_size: u32,
recv_buffer_max_size: u32,
send_buffer_min_size: u32,
recv_buffer_min_size: u32,
send_timeout: u32, // Timeout specified in milliseconds.
recv_timeout: u32, // Timeout specified in milliseconds.
socket_error: void,
socket_type: u32,
};
pub const Connection = struct {
socket: Socket,
address: net.Address,
};
pub const Socket = struct {
pub const Reader = io.Reader(*Self, anyerror, read);
pub const Writer = io.Writer(*Self, anyerror, write);
const Self = @This();
handle: pike.Handle,
readers: Waker = .{},
writers: Waker = .{},
pub fn init(domain: u32, socket_type: u32, protocol: u32, flags: u32) !Self {
return Self{
.handle = .{
.inner = try os.socket(
domain,
socket_type | flags | os.SOCK.CLOEXEC | os.SOCK.NONBLOCK,
protocol,
),
.wake_fn = wake,
},
};
}
pub fn deinit(self: *Self) void {
self.shutdown(posix.SHUT_RDWR) catch {};
if (self.writers.shutdown()) |task| pike.dispatch(task, .{});
if (self.readers.shutdown()) |task| pike.dispatch(task, .{});
os.close(self.handle.inner);
}
pub fn registerTo(self: *const Self, notifier: *const pike.Notifier) !void {
try notifier.register(&self.handle, .{ .read = true, .write = true });
}
fn wake(handle: *pike.Handle, batch: *pike.Batch, opts: pike.WakeOptions) void {
const self = @fieldParentPtr(Self, "handle", handle);
if (opts.write_ready) if (self.writers.notify()) |task| batch.push(task);
if (opts.read_ready) if (self.readers.notify()) |task| batch.push(task);
if (opts.shutdown) {
if (self.writers.shutdown()) |task| batch.push(task);
if (self.readers.shutdown()) |task| batch.push(task);
}
}
fn ErrorUnionOf(comptime func: anytype) std.builtin.TypeInfo.ErrorUnion {
return @typeInfo(@typeInfo(@TypeOf(func)).Fn.return_type.?).ErrorUnion;
}
fn call(self: *Self, comptime function: anytype, args: anytype, comptime opts: pike.CallOptions) !ErrorUnionOf(function).payload {
while (true) {
const result = @call(.{ .modifier = .always_inline }, function, args) catch |err| switch (err) {
error.WouldBlock => {
if (comptime opts.write) {
try self.writers.wait(.{ .use_lifo = true });
} else if (comptime opts.read) {
try self.readers.wait(.{});
}
continue;
},
else => return err,
};
return result;
}
}
pub fn shutdown(self: *const Self, how: c_int) !void {
try posix.shutdown_(self.handle.inner, how);
}
pub fn get(self: *const Self, comptime opt: SocketOptionType) !meta.TagPayload(SocketOption, opt) {
if (opt == .socket_error) {
const errno = try posix.getsockopt(u32, self.handle.inner, os.SOL.SOCKET, @enumToInt(opt));
return switch (errno) {
@enumToInt(os.E.SUCCESS) => {},
@enumToInt(os.E.ACCES) => error.PermissionDenied,
@enumToInt(os.E.PERM) => error.PermissionDenied,
@enumToInt(os.E.ADDRINUSE) => error.AddressInUse,
@enumToInt(os.E.ADDRNOTAVAIL) => error.AddressNotAvailable,
@enumToInt(os.E.AFNOSUPPORT) => error.AddressFamilyNotSupported,
@enumToInt(os.E.AGAIN) => error.SystemResources,
@enumToInt(os.E.ALREADY) => error.AlreadyConnecting,
@enumToInt(os.E.BADF) => error.BadFileDescriptor,
@enumToInt(os.E.CONNREFUSED) => error.ConnectionRefused,
@enumToInt(os.E.FAULT) => error.InvalidParameter,
@enumToInt(os.E.ISCONN) => error.AlreadyConnected,
@enumToInt(os.E.NETUNREACH) => error.NetworkUnreachable,
@enumToInt(os.E.NOTSOCK) => error.NotASocket,
@enumToInt(os.E.PROTOTYPE) => error.UnsupportedProtocol,
@enumToInt(os.E.TIMEDOUT) => error.ConnectionTimedOut,
else => |err| os.unexpectedErrno(@intToEnum(os.E, err)),
};
}
return posix.getsockopt(
meta.TagPayload(SocketOption, opt),
self.handle.inner,
os.SOL.SOCKET,
@enumToInt(opt),
);
}
pub fn set(self: *const Self, comptime opt: SocketOptionType, value: meta.TagPayload(SocketOption, opt)) !void {
const val = switch (@TypeOf(value)) {
bool => @intCast(c_int, @boolToInt(value)),
else => value,
};
try os.setsockopt(
self.handle.inner,
os.SOL.SOCKET,
@enumToInt(opt),
blk: {
if (comptime @typeInfo(@TypeOf(val)) == .Optional) {
break :blk if (val) |v| @as([]const u8, mem.asBytes(&v)[0..@sizeOf(@TypeOf(val))]) else &[0]u8{};
} else {
break :blk @as([]const u8, mem.asBytes(&val)[0..@sizeOf(@TypeOf(val))]);
}
},
);
}
pub fn getBindAddress(self: *const Self) !net.Address {
var addr: os.sockaddr = undefined;
var addr_len: os.socklen_t = @sizeOf(@TypeOf(addr));
try os.getsockname(self.handle.inner, &addr, &addr_len);
return net.Address.initPosix(@alignCast(4, &addr));
}
pub fn bind(self: *Self, address: net.Address) !void {
try os.bind(self.handle.inner, &address.any, address.getOsSockLen());
}
pub fn listen(self: *Self, backlog: usize) !void {
try os.listen(self.handle.inner, @truncate(u31, backlog));
}
pub fn accept(self: *Self) callconv(.Async) !Connection {
var addr: os.sockaddr = undefined;
var addr_len: os.socklen_t = @sizeOf(@TypeOf(addr));
const handle = try self.call(posix.accept_, .{
self.handle.inner,
&addr,
&addr_len,
os.SOCK.NONBLOCK | os.SOCK.CLOEXEC,
}, .{ .read = true });
return Connection{
.socket = Socket{ .handle = .{ .inner = handle, .wake_fn = wake } },
.address = net.Address.initPosix(@alignCast(4, &addr)),
};
}
pub fn connect(self: *Self, address: net.Address) callconv(.Async) !void {
posix.connect_(self.handle.inner, &address.any, address.getOsSockLen()) catch |err| switch (err) {
error.WouldBlock => try self.writers.wait(.{ .use_lifo = true }),
else => return err,
};
try self.get(.socket_error);
}
pub inline fn reader(self: *Self) Reader {
return Reader{ .context = self };
}
pub inline fn writer(self: *Self) Writer {
return Writer{ .context = self };
}
pub fn read(self: *Self, buf: []u8) !usize {
const num_bytes = self.call(posix.read_, .{ self.handle.inner, buf }, .{ .read = true }) catch |err| switch (err) {
error.NotOpenForReading,
error.ConnectionResetByPeer,
error.OperationCancelled,
=> return 0,
else => return err,
};
return num_bytes;
}
pub fn recv(self: *Self, buf: []u8, flags: u32) callconv(.Async) !usize {
return self.recvFrom(buf, flags, null);
}
pub fn recvFrom(self: *Self, buf: []u8, flags: u32, address: ?*net.Address) callconv(.Async) !usize {
var src_addr: os.sockaddr = undefined;
var src_addr_len: os.socklen_t = undefined;
const num_bytes = try self.call(os.recvfrom, .{
self.handle.inner,
buf,
flags,
@as(?*os.sockaddr, if (address != null) &src_addr else null),
@as(?*os.socklen_t, if (address != null) &src_addr_len else null),
}, .{ .read = true });
if (address) |a| {
a.* = net.Address{ .any = src_addr };
}
return num_bytes;
}
pub fn write(self: *Self, buf: []const u8) !usize {
return self.call(os.write, .{ self.handle.inner, buf }, .{ .write = true });
}
pub fn send(self: *Self, buf: []const u8, flags: u32) callconv(.Async) !usize {
return self.sendTo(buf, flags, null);
}
pub fn sendTo(self: *Self, buf: []const u8, flags: u32, address: ?net.Address) callconv(.Async) !usize {
return self.call(posix.sendto_, .{
self.handle.inner,
buf,
flags,
@as(?*const os.sockaddr, if (address) |a| &a.any else null),
if (address) |a| a.getOsSockLen() else 0,
}, .{ .write = true });
}
};
|
socket_posix.zig
|
const std = @import("std");
const debug = std.debug;
const io = std.io;
const math = std.math;
const mem = std.mem;
const meta = std.meta;
const time = std.time;
const Decl = std.builtin.TypeInfo.Declaration;
pub fn benchmark(comptime B: type) !void {
const args = if (@hasDecl(B, "args")) B.args else [_]void{{}};
const arg_names = if (@hasDecl(B, "arg_names")) B.arg_names else [_]u8{};
const min_iterations = if (@hasDecl(B, "min_iterations")) B.min_iterations else 10000;
const max_iterations = if (@hasDecl(B, "max_iterations")) B.max_iterations else 100000;
const max_time = 500 * time.ns_per_ms;
const functions = comptime blk: {
var res: []const Decl = &[_]Decl{};
for (meta.declarations(B)) |decl| {
if (decl.data != Decl.Data.Fn)
continue;
res = res ++ [_]Decl{decl};
}
break :blk res;
};
if (functions.len == 0)
@compileError("No benchmarks to run.");
const min_width = blk: {
const writer = io.null_writer;
var res = [_]u64{ 0, 0, 0 };
res = try printBenchmark(
writer,
res,
"Benchmark",
formatter("{s}", ""),
formatter("{s}", "Iterations"),
formatter("{s}", "Mean(ns)"),
);
inline for (functions) |f| {
var i: usize = 0;
while (i < args.len) : (i += 1) {
const max = math.maxInt(u32);
res = if (i < arg_names.len) blk2: {
const arg_name = formatter("{s}", arg_names[i]);
break :blk2 try printBenchmark(writer, res, f.name, arg_name, max, max);
} else blk2: {
break :blk2 try printBenchmark(writer, res, f.name, i, max, max);
};
}
}
break :blk res;
};
const stderr = std.io.bufferedWriter(std.io.getStdErr().writer()).writer();
try stderr.writeAll("\n");
_ = try printBenchmark(
stderr,
min_width,
"Benchmark",
formatter("{s}", ""),
formatter("{s}", "Iterations"),
formatter("{s}", "Mean(ns)"),
);
try stderr.writeAll("\n");
for (min_width) |w|
try stderr.writeByteNTimes('-', w);
try stderr.writeByteNTimes('-', min_width.len - 1);
try stderr.writeAll("\n");
try stderr.context.flush();
var timer = try time.Timer.start();
inline for (functions) |def| {
inline for (args) |arg, index| {
var runtime_sum: u128 = 0;
var i: usize = 0;
while (i < min_iterations or
(i < max_iterations and runtime_sum < max_time)) : (i += 1)
{
timer.reset();
const res = switch (@TypeOf(arg)) {
void => @field(B, def.name)(),
else => @field(B, def.name)(arg),
};
const runtime = timer.read();
runtime_sum += runtime;
switch (@TypeOf(res)) {
void => {},
else => std.mem.doNotOptimizeAway(&res),
}
}
const runtime_mean = runtime_sum / i;
if (index < arg_names.len) {
const arg_name = formatter("{s}", arg_names[index]);
_ = try printBenchmark(stderr, min_width, def.name, arg_name, i, runtime_mean);
} else {
_ = try printBenchmark(stderr, min_width, def.name, index, i, runtime_mean);
}
try stderr.writeAll("\n");
try stderr.context.flush();
}
}
}
fn printBenchmark(
writer: anytype,
min_widths: [3]u64,
func_name: []const u8,
arg_name: anytype,
iterations: anytype,
runtime: anytype,
) ![3]u64 {
const arg_len = std.fmt.count("{}", .{arg_name});
const name_len = try alignedPrint(writer, .left, min_widths[0], "{s}{s}{}{s}", .{
func_name,
"("[0..@boolToInt(arg_len != 0)],
arg_name,
")"[0..@boolToInt(arg_len != 0)],
});
try writer.writeAll(" ");
const it_len = try alignedPrint(writer, .right, min_widths[1], "{}", .{iterations});
try writer.writeAll(" ");
const runtime_len = try alignedPrint(writer, .right, min_widths[2], "{}", .{runtime});
return [_]u64{ name_len, it_len, runtime_len };
}
fn formatter(comptime fmt_str: []const u8, value: anytype) Formatter(fmt_str, @TypeOf(value)) {
return .{ .value = value };
}
fn Formatter(fmt_str: []const u8, comptime T: type) type {
return struct {
value: T,
pub fn format(
self: @This(),
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
writer: anytype,
) !void {
_ = fmt;
_ = options;
try std.fmt.format(writer, fmt_str, .{self.value});
}
};
}
fn alignedPrint(writer: anytype, dir: enum { left, right }, width: u64, comptime fmt: []const u8, args: anytype) !u64 {
const value_len = std.fmt.count(fmt, args);
var cow = io.countingWriter(writer);
if (dir == .right)
try cow.writer().writeByteNTimes(' ', math.sub(u64, width, value_len) catch 0);
try cow.writer().print(fmt, args);
if (dir == .left)
try cow.writer().writeByteNTimes(' ', math.sub(u64, width, value_len) catch 0);
return cow.bytes_written;
}
test "benchmark" {
try benchmark(struct {
// The functions will be benchmarked with the following inputs.
// If not present, then it is assumed that the functions
// take no input.
const args = [_][]const u8{
&([_]u8{ 1, 10, 100 } ** 16),
&([_]u8{ 1, 10, 100 } ** 32),
&([_]u8{ 1, 10, 100 } ** 64),
&([_]u8{ 1, 10, 100 } ** 128),
&([_]u8{ 1, 10, 100 } ** 256),
&([_]u8{ 1, 10, 100 } ** 512),
};
// You can specify `arg_names` to give the inputs more meaningful
// names. If the index of the input exceeds the available string
// names, the index is used as a backup.
const arg_names = [_][]const u8{
"block=16",
"block=32",
"block=64",
"block=128",
"block=256",
"block=512",
};
// How many iterations to run each benchmark.
// If not present then a default will be used.
const min_iterations = 1000;
const max_iterations = 100000;
fn sum_slice(slice: []const u8) u64 {
var res: u64 = 0;
for (slice) |item|
res += item;
return res;
}
fn sum_reader(slice: []const u8) u64 {
var reader = &io.fixedBufferStream(slice).reader();
var res: u64 = 0;
while (reader.readByte()) |c| {
res += c;
} else |_| {}
return res;
}
});
}
test "benchmark generics" {
try benchmark(struct {
const Vec = @import("std").meta.Vector;
pub const args = [_]type{
Vec(4, f16), Vec(4, f32), Vec(4, f64),
Vec(8, f16), Vec(8, f32), Vec(8, f64),
Vec(16, f16), Vec(16, f32), Vec(16, f64),
};
pub const arg_names = [_][]const u8{
"vec4f16", "vec4f32", "vec4f64",
"vec8f16", "vec8f32", "vec8f64",
"vec16f16", "vec16f32", "vec16f64",
};
pub fn sum_vectors(comptime T: type) T {
const info = @typeInfo(T).Vector;
const one = @splat(info.len, @as(info.child, 1));
const vecs = [1]T{one} ** 512;
var res = one;
for (vecs) |vec| {
res += vec;
}
return res;
}
});
}
|
bench.zig
|
const root = @import("@root");
const std = @import("std");
const builtin = @import("builtin");
var argc_ptr: [*]usize = undefined;
comptime {
const strong_linkage = builtin.GlobalLinkage.Strong;
if (builtin.link_libc) {
@export("main", main, strong_linkage);
} else if (builtin.os == builtin.Os.windows) {
@export("WinMainCRTStartup", WinMainCRTStartup, strong_linkage);
} else {
@export("_start", _start, strong_linkage);
}
}
nakedcc fn _start() noreturn {
switch (builtin.arch) {
builtin.Arch.x86_64 => switch (builtin.os) {
builtin.Os.freebsd => {
argc_ptr = asm ("lea (%%rdi), %[argc]"
: [argc] "=r" (-> [*]usize)
);
},
else => {
argc_ptr = asm ("lea (%%rsp), %[argc]"
: [argc] "=r" (-> [*]usize)
);
},
},
builtin.Arch.i386 => {
argc_ptr = asm ("lea (%%esp), %[argc]"
: [argc] "=r" (-> [*]usize)
);
},
builtin.Arch.aarch64v8 => {
argc_ptr = asm ("mov %[argc], sp"
: [argc] "=r" (-> [*]usize)
);
},
else => @compileError("unsupported arch"),
}
// If LLVM inlines stack variables into _start, they will overwrite
// the command line argument data.
@noInlineCall(posixCallMainAndExit);
}
extern fn WinMainCRTStartup() noreturn {
@setAlignStack(16);
std.os.windows.ExitProcess(callMain());
}
// TODO https://github.com/ziglang/zig/issues/265
fn posixCallMainAndExit() noreturn {
if (builtin.os == builtin.Os.freebsd) {
@setAlignStack(16);
}
const argc = argc_ptr[0];
const argv = @ptrCast([*][*]u8, argc_ptr + 1);
const envp_optional = @ptrCast([*]?[*]u8, argv + argc + 1);
var envp_count: usize = 0;
while (envp_optional[envp_count]) |_| : (envp_count += 1) {}
const envp = @ptrCast([*][*]u8, envp_optional)[0..envp_count];
if (builtin.os == builtin.Os.linux) {
const auxv = @ptrCast([*]usize, envp.ptr + envp_count + 1);
std.os.linux_elf_aux_maybe = @ptrCast([*]std.elf.Auxv, auxv);
std.debug.assert(std.os.linuxGetAuxVal(std.elf.AT_PAGESZ) == std.os.page_size);
}
std.os.posix.exit(callMainWithArgs(argc, argv, envp));
}
// This is marked inline because for some reason LLVM in release mode fails to inline it,
// and we want fewer call frames in stack traces.
inline fn callMainWithArgs(argc: usize, argv: [*][*]u8, envp: [][*]u8) u8 {
std.os.ArgIteratorPosix.raw = argv[0..argc];
std.os.posix_environ_raw = envp;
return callMain();
}
extern fn main(c_argc: i32, c_argv: [*][*]u8, c_envp: [*]?[*]u8) i32 {
var env_count: usize = 0;
while (c_envp[env_count] != null) : (env_count += 1) {}
const envp = @ptrCast([*][*]u8, c_envp)[0..env_count];
return callMainWithArgs(@intCast(usize, c_argc), c_argv, envp);
}
// This is marked inline because for some reason LLVM in release mode fails to inline it,
// and we want fewer call frames in stack traces.
inline fn callMain() u8 {
switch (@typeId(@typeOf(root.main).ReturnType)) {
builtin.TypeId.NoReturn => {
root.main();
},
builtin.TypeId.Void => {
root.main();
return 0;
},
builtin.TypeId.Int => {
if (@typeOf(root.main).ReturnType.bit_count != 8) {
@compileError("expected return type of main to be 'u8', 'noreturn', 'void', or '!void'");
}
return root.main();
},
builtin.TypeId.ErrorUnion => {
root.main() catch |err| {
std.debug.warn("error: {}\n", @errorName(err));
if (builtin.os != builtin.Os.zen) {
if (@errorReturnTrace()) |trace| {
std.debug.dumpStackTrace(trace);
}
}
return 1;
};
return 0;
},
else => @compileError("expected return type of main to be 'u8', 'noreturn', 'void', or '!void'"),
}
}
|
std/special/bootstrap.zig
|
const std = @import("std");
const ArenaAllocator = std.heap.ArenaAllocator;
const Allocator = std.mem.Allocator;
const warn = std.debug.warn;
const semver = @import("semver");
const json = @import("zson");
const PackageInfo = struct {
name: []const u8,
version: ?[]const u8,
source: ?Source,
entry_point: []const u8,
fn encode(self: PackageInfo, a: *Allocator) !json.Value {
var m = json.ObjectMap.init(a);
const name_value = json.Value{ .String = self.name };
_ = try m.put("name", name_value);
if (self.version) |v| {
const version_value = json.Value{ .String = v };
_ = try m.put("version", version_value);
}
if (self.source) |src| {
const src_value = try src.encode(a);
_ = try m.put("source", src_value);
}
const entry_value = json.Value{ .String = self.entry_point };
_ = try m.put("entry_point", entry_value);
return json.Value{ .Object = m };
}
};
const Source = union(enum) {
git: []const u8,
file: []const u8,
fn encode(self: Source, a: *Allocator) !json.Value {
var m = json.ObjectMap.init(a);
switch (self) {
Source.git => |v| {
const value = json.Value{ .String = v };
_ = try m.put("git", value);
},
Source.file => |v| {
const value = json.Value{ .String = v };
_ = try m.put("file", value);
},
else => unreachable,
}
return json.Value{ .Object = m };
}
};
const Version = struct {
name: []const u8,
version: ?[]const u8,
pub fn check(self: *const Version) bool {
if (self.version) |v| {
return semver.isValid(v);
}
return true;
}
fn encode(self: Version, a: *Allocator) json.Value {
if (self.version) |v| {
return json.Value{ .String = self.name ++ "@" ++ v };
}
return json.Value{ .String = self.name };
}
};
test "Version" {
const v = Version{ .name = "zpm", .version = "v0.1.0" };
var a = warn("check {}\n", v.check());
}
test "encode" {
var a = ArenaAllocator.init(std.debug.global_allocator);
defer a.deinit();
var buf = &try std.Buffer.init(std.debug.global_allocator, "");
defer buf.deinit();
var buf_stream = std.io.BufferOutStream.init(buf);
const p = PackageInfo{
.name = "zpm",
.version = "v0.1.0",
.source = Source{ .git = "github.com/gerenst/zpm" },
.entry_point = "src/index.zig",
};
const value = try p.encode(&a.allocator);
try value.dump(&buf_stream.stream);
warn("{}\n", buf.toSlice());
}
pub fn main() void {}
|
src/main.zig
|
const std = @import("../../../std.zig");
const linux = std.os.linux;
const socklen_t = linux.socklen_t;
const iovec = linux.iovec;
const iovec_const = linux.iovec_const;
const uid_t = linux.uid_t;
const gid_t = linux.gid_t;
const pid_t = linux.pid_t;
const stack_t = linux.stack_t;
const sigset_t = linux.sigset_t;
pub const SYS = extern enum(usize) {
restart_syscall = 0,
exit = 1,
fork = 2,
read = 3,
write = 4,
open = 5,
close = 6,
waitpid = 7,
creat = 8,
link = 9,
unlink = 10,
execve = 11,
chdir = 12,
time = 13,
mknod = 14,
chmod = 15,
lchown = 16,
@"break" = 17,
oldstat = 18,
lseek = 19,
getpid = 20,
mount = 21,
umount = 22,
setuid = 23,
getuid = 24,
stime = 25,
ptrace = 26,
alarm = 27,
oldfstat = 28,
pause = 29,
utime = 30,
stty = 31,
gtty = 32,
access = 33,
nice = 34,
ftime = 35,
sync = 36,
kill = 37,
rename = 38,
mkdir = 39,
rmdir = 40,
dup = 41,
pipe = 42,
times = 43,
prof = 44,
brk = 45,
setgid = 46,
getgid = 47,
signal = 48,
geteuid = 49,
getegid = 50,
acct = 51,
umount2 = 52,
lock = 53,
ioctl = 54,
fcntl = 55,
mpx = 56,
setpgid = 57,
ulimit = 58,
oldolduname = 59,
umask = 60,
chroot = 61,
ustat = 62,
dup2 = 63,
getppid = 64,
getpgrp = 65,
setsid = 66,
sigaction = 67,
sgetmask = 68,
ssetmask = 69,
setreuid = 70,
setregid = 71,
sigsuspend = 72,
sigpending = 73,
sethostname = 74,
setrlimit = 75,
getrlimit = 76,
getrusage = 77,
gettimeofday = 78,
settimeofday = 79,
getgroups = 80,
setgroups = 81,
select = 82,
symlink = 83,
oldlstat = 84,
readlink = 85,
uselib = 86,
swapon = 87,
reboot = 88,
readdir = 89,
mmap = 90,
munmap = 91,
truncate = 92,
ftruncate = 93,
fchmod = 94,
fchown = 95,
getpriority = 96,
setpriority = 97,
profil = 98,
statfs = 99,
fstatfs = 100,
ioperm = 101,
socketcall = 102,
syslog = 103,
setitimer = 104,
getitimer = 105,
stat = 106,
lstat = 107,
fstat = 108,
olduname = 109,
iopl = 110,
vhangup = 111,
idle = 112,
vm86 = 113,
wait4 = 114,
swapoff = 115,
sysinfo = 116,
ipc = 117,
fsync = 118,
sigreturn = 119,
clone = 120,
setdomainname = 121,
uname = 122,
modify_ldt = 123,
adjtimex = 124,
mprotect = 125,
sigprocmask = 126,
create_module = 127,
init_module = 128,
delete_module = 129,
get_kernel_syms = 130,
quotactl = 131,
getpgid = 132,
fchdir = 133,
bdflush = 134,
sysfs = 135,
personality = 136,
afs_syscall = 137,
setfsuid = 138,
setfsgid = 139,
_llseek = 140,
getdents = 141,
_newselect = 142,
flock = 143,
msync = 144,
readv = 145,
writev = 146,
getsid = 147,
fdatasync = 148,
_sysctl = 149,
mlock = 150,
munlock = 151,
mlockall = 152,
munlockall = 153,
sched_setparam = 154,
sched_getparam = 155,
sched_setscheduler = 156,
sched_getscheduler = 157,
sched_yield = 158,
sched_get_priority_max = 159,
sched_get_priority_min = 160,
sched_rr_get_interval = 161,
nanosleep = 162,
mremap = 163,
setresuid = 164,
getresuid = 165,
query_module = 166,
poll = 167,
nfsservctl = 168,
setresgid = 169,
getresgid = 170,
prctl = 171,
rt_sigreturn = 172,
rt_sigaction = 173,
rt_sigprocmask = 174,
rt_sigpending = 175,
rt_sigtimedwait = 176,
rt_sigqueueinfo = 177,
rt_sigsuspend = 178,
pread64 = 179,
pwrite64 = 180,
chown = 181,
getcwd = 182,
capget = 183,
capset = 184,
sigaltstack = 185,
sendfile = 186,
getpmsg = 187,
putpmsg = 188,
vfork = 189,
ugetrlimit = 190,
readahead = 191,
mmap2 = 192,
truncate64 = 193,
ftruncate64 = 194,
stat64 = 195,
lstat64 = 196,
fstat64 = 197,
pciconfig_read = 198,
pciconfig_write = 199,
pciconfig_iobase = 200,
multiplexer = 201,
getdents64 = 202,
pivot_root = 203,
fcntl64 = 204,
madvise = 205,
mincore = 206,
gettid = 207,
tkill = 208,
setxattr = 209,
lsetxattr = 210,
fsetxattr = 211,
getxattr = 212,
lgetxattr = 213,
fgetxattr = 214,
listxattr = 215,
llistxattr = 216,
flistxattr = 217,
removexattr = 218,
lremovexattr = 219,
fremovexattr = 220,
futex = 221,
sched_setaffinity = 222,
sched_getaffinity = 223,
tuxcall = 225,
sendfile64 = 226,
io_setup = 227,
io_destroy = 228,
io_getevents = 229,
io_submit = 230,
io_cancel = 231,
set_tid_address = 232,
fadvise64 = 233,
exit_group = 234,
lookup_dcookie = 235,
epoll_create = 236,
epoll_ctl = 237,
epoll_wait = 238,
remap_file_pages = 239,
timer_create = 240,
timer_settime = 241,
timer_gettime = 242,
timer_getoverrun = 243,
timer_delete = 244,
clock_settime = 245,
clock_gettime = 246,
clock_getres = 247,
clock_nanosleep = 248,
swapcontext = 249,
tgkill = 250,
utimes = 251,
statfs64 = 252,
fstatfs64 = 253,
fadvise64_64 = 254,
rtas = 255,
sys_debug_setcontext = 256,
migrate_pages = 258,
mbind = 259,
get_mempolicy = 260,
set_mempolicy = 261,
mq_open = 262,
mq_unlink = 263,
mq_timedsend = 264,
mq_timedreceive = 265,
mq_notify = 266,
mq_getsetattr = 267,
kexec_load = 268,
add_key = 269,
request_key = 270,
keyctl = 271,
waitid = 272,
ioprio_set = 273,
ioprio_get = 274,
inotify_init = 275,
inotify_add_watch = 276,
inotify_rm_watch = 277,
spu_run = 278,
spu_create = 279,
pselect6 = 280,
ppoll = 281,
unshare = 282,
splice = 283,
tee = 284,
vmsplice = 285,
openat = 286,
mkdirat = 287,
mknodat = 288,
fchownat = 289,
futimesat = 290,
fstatat64 = 291,
unlinkat = 292,
renameat = 293,
linkat = 294,
symlinkat = 295,
readlinkat = 296,
fchmodat = 297,
faccessat = 298,
get_robust_list = 299,
set_robust_list = 300,
move_pages = 301,
getcpu = 302,
epoll_pwait = 303,
utimensat = 304,
signalfd = 305,
timerfd_create = 306,
eventfd = 307,
sync_file_range2 = 308,
fallocate = 309,
subpage_prot = 310,
timerfd_settime = 311,
timerfd_gettime = 312,
signalfd4 = 313,
eventfd2 = 314,
epoll_create1 = 315,
dup3 = 316,
pipe2 = 317,
inotify_init1 = 318,
perf_event_open = 319,
preadv = 320,
pwritev = 321,
rt_tgsigqueueinfo = 322,
fanotify_init = 323,
fanotify_mark = 324,
prlimit64 = 325,
socket = 326,
bind = 327,
connect = 328,
listen = 329,
accept = 330,
getsockname = 331,
getpeername = 332,
socketpair = 333,
send = 334,
sendto = 335,
recv = 336,
recvfrom = 337,
shutdown = 338,
setsockopt = 339,
getsockopt = 340,
sendmsg = 341,
recvmsg = 342,
recvmmsg = 343,
accept4 = 344,
name_to_handle_at = 345,
open_by_handle_at = 346,
clock_adjtime = 347,
syncfs = 348,
sendmmsg = 349,
setns = 350,
process_vm_readv = 351,
process_vm_writev = 352,
finit_module = 353,
kcmp = 354,
sched_setattr = 355,
sched_getattr = 356,
renameat2 = 357,
seccomp = 358,
getrandom = 359,
memfd_create = 360,
bpf = 361,
execveat = 362,
switch_endian = 363,
userfaultfd = 364,
membarrier = 365,
mlock2 = 378,
copy_file_range = 379,
preadv2 = 380,
pwritev2 = 381,
kexec_file_load = 382,
statx = 383,
pkey_alloc = 384,
pkey_free = 385,
pkey_mprotect = 386,
rseq = 387,
io_pgetevents = 388,
semget = 393,
semctl = 394,
shmget = 395,
shmctl = 396,
shmat = 397,
shmdt = 398,
msgget = 399,
msgsnd = 400,
msgrcv = 401,
msgctl = 402,
clock_gettime64 = 403,
clock_settime64 = 404,
clock_adjtime64 = 405,
clock_getres_time64 = 406,
clock_nanosleep_time64 = 407,
timer_gettime64 = 408,
timer_settime64 = 409,
timerfd_gettime64 = 410,
timerfd_settime64 = 411,
utimensat_time64 = 412,
pselect6_time64 = 413,
ppoll_time64 = 414,
io_pgetevents_time64 = 416,
recvmmsg_time64 = 417,
mq_timedsend_time64 = 418,
mq_timedreceive_time64 = 419,
semtimedop_time64 = 420,
rt_sigtimedwait_time64 = 421,
futex_time64 = 422,
sched_rr_get_interval_time64 = 423,
pidfd_send_signal = 424,
io_uring_setup = 425,
io_uring_enter = 426,
io_uring_register = 427,
open_tree = 428,
move_mount = 429,
fsopen = 430,
fsconfig = 431,
fsmount = 432,
fspick = 433,
pidfd_open = 434,
clone3 = 435,
close_range = 436,
openat2 = 437,
pidfd_getfd = 438,
faccessat2 = 439,
process_madvise = 440,
};
pub const O_CREAT = 0o100;
pub const O_EXCL = 0o200;
pub const O_NOCTTY = 0o400;
pub const O_TRUNC = 0o1000;
pub const O_APPEND = 0o2000;
pub const O_NONBLOCK = 0o4000;
pub const O_DSYNC = 0o10000;
pub const O_SYNC = 0o4010000;
pub const O_RSYNC = 0o4010000;
pub const O_DIRECTORY = 0o40000;
pub const O_NOFOLLOW = 0o100000;
pub const O_CLOEXEC = 0o2000000;
pub const O_ASYNC = 0o20000;
pub const O_DIRECT = 0o400000;
pub const O_LARGEFILE = 0o200000;
pub const O_NOATIME = 0o1000000;
pub const O_PATH = 0o10000000;
pub const O_TMPFILE = 0o20040000;
pub const O_NDELAY = O_NONBLOCK;
pub const F_DUPFD = 0;
pub const F_GETFD = 1;
pub const F_SETFD = 2;
pub const F_GETFL = 3;
pub const F_SETFL = 4;
pub const F_SETOWN = 8;
pub const F_GETOWN = 9;
pub const F_SETSIG = 10;
pub const F_GETSIG = 11;
pub const F_GETLK = 12;
pub const F_SETLK = 13;
pub const F_SETLKW = 14;
pub const F_SETOWN_EX = 15;
pub const F_GETOWN_EX = 16;
pub const F_GETOWNER_UIDS = 17;
pub const F_RDLCK = 0;
pub const F_WRLCK = 1;
pub const F_UNLCK = 2;
pub const LOCK_SH = 1;
pub const LOCK_EX = 2;
pub const LOCK_UN = 8;
pub const LOCK_NB = 4;
/// stack-like segment
pub const MAP_GROWSDOWN = 0x0100;
/// ETXTBSY
pub const MAP_DENYWRITE = 0x0800;
/// mark it as an executable
pub const MAP_EXECUTABLE = 0x1000;
/// pages are locked
pub const MAP_LOCKED = 0x0080;
/// don't check for reservations
pub const MAP_NORESERVE = 0x0040;
pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
pub const VDSO_CGT_VER = "LINUX_2.6.15";
pub const Flock = extern struct {
l_type: i16,
l_whence: i16,
l_start: off_t,
l_len: off_t,
l_pid: pid_t,
};
pub const msghdr = extern struct {
msg_name: ?*sockaddr,
msg_namelen: socklen_t,
msg_iov: [*]iovec,
msg_iovlen: usize,
msg_control: ?*c_void,
msg_controllen: socklen_t,
msg_flags: i32,
};
pub const msghdr_const = extern struct {
msg_name: ?*const sockaddr,
msg_namelen: socklen_t,
msg_iov: [*]iovec_const,
msg_iovlen: usize,
msg_control: ?*c_void,
msg_controllen: socklen_t,
msg_flags: i32,
};
pub const blksize_t = i32;
pub const nlink_t = u32;
pub const time_t = isize;
pub const mode_t = u32;
pub const off_t = i64;
pub const ino_t = u64;
pub const dev_t = u64;
pub const blkcnt_t = i64;
// The `stat` definition used by the Linux kernel.
pub const kernel_stat = extern struct {
dev: dev_t,
ino: ino_t,
mode: mode_t,
nlink: nlink_t,
uid: uid_t,
gid: gid_t,
rdev: dev_t,
__rdev_padding: i16,
size: off_t,
blksize: blksize_t,
blocks: blkcnt_t,
atim: timespec,
mtim: timespec,
ctim: timespec,
__unused: [2]u32,
pub fn atime(self: @This()) timespec {
return self.atim;
}
pub fn mtime(self: @This()) timespec {
return self.mtim;
}
pub fn ctime(self: @This()) timespec {
return self.ctim;
}
};
// The `stat64` definition used by the libc.
pub const libc_stat = kernel_stat;
pub const timespec = extern struct {
tv_sec: time_t,
tv_nsec: isize,
};
pub const timeval = extern struct {
tv_sec: time_t,
tv_usec: isize,
};
pub const timezone = extern struct {
tz_minuteswest: i32,
tz_dsttime: i32,
};
pub const greg_t = u32;
pub const gregset_t = [48]greg_t;
pub const fpregset_t = [33]f64;
pub const vrregset = extern struct {
vrregs: [32][4]u32,
vrsave: u32,
_pad: [2]u32,
vscr: u32,
};
pub const vrregset_t = vrregset;
pub const mcontext_t = extern struct {
gp_regs: gregset_t,
fp_regs: fpregset_t,
v_regs: vrregset_t align(16),
};
pub const ucontext_t = extern struct {
flags: u32,
link: *ucontext_t,
stack: stack_t,
pad: [7]i32,
regs: *mcontext_t,
sigmask: sigset_t,
pad2: [3]i32,
mcontext: mcontext_t,
};
pub const Elf_Symndx = u32;
pub const MMAP2_UNIT = 4096;
|
lib/std/os/bits/linux/powerpc.zig
|