code stringlengths 38 801k | repo_path stringlengths 6 263 |
|---|---|
const std = @import("std");
const Self = @This();
fn root() []const u8 {
return std.fs.path.dirname(@src().file) orelse ".";
}
const root_path = root() ++ "/";
pub const include_dir = root_path ++ "ffmpeg";
pub const config_dir = root_path ++ "config";
pub const Library = struct {
avcodec: *std.build.LibExeO... | ffmpeg.zig |
const std = @import("std");
/// wraps either a free function or a bound function that takes an Event as a parameter
pub fn Delegate(comptime Event: type) type {
return struct {
const Self = @This();
ctx_ptr_address: usize = 0,
callback: union(enum) {
free: fn (Event) void,
... | src/signals/delegate.zig |
const std = @import("std");
const stdx = @import("stdx");
const uv = @import("uv");
const v8 = @import("v8");
const t = stdx.testing;
const Null = stdx.ds.CompactNull(u32);
const RuntimeContext = @import("runtime.zig").RuntimeContext;
const EventDispatcher = stdx.events.EventDispatcher;
const log = stdx.log.scoped(.ti... | runtime/timer.zig |
const std = @import("std");
const builtin = @import("builtin");
const ThreadPool = @This();
mutex: std.Thread.Mutex = .{},
cond: std.Thread.Condition = .{},
run_queue: RunQueue = .{},
is_running: bool = true,
allocator: std.mem.Allocator,
threads: []std.Thread,
const RunQueue = std.SinglyLinkedList(Runnable);
const R... | src/ThreadPool.zig |
const kernel = @import("../../kernel.zig");
pub const Spinlock = @import("spinlock.zig");
pub const sync = @import("sync.zig");
pub const DeviceTree = @import("device_tree.zig");
pub const Timer = @import("timer.zig");
pub const Paging = @import("paging.zig");
pub const Physical = @import("physical.zig");
pub const Vi... | src/kernel/arch/riscv64/riscv64.zig |
const std = @import("std");
const mem = std.mem;
const Narrow = @This();
allocator: *mem.Allocator,
array: []bool,
lo: u21 = 32,
hi: u21 = 10630,
pub fn init(allocator: *mem.Allocator) !Narrow {
var instance = Narrow{
.allocator = allocator,
.array = try allocator.alloc(bool, 10599),
};
... | src/components/autogen/DerivedEastAsianWidth/Narrow.zig |
const std = @import("std");
const Builder = std.build.Builder;
const builtin = std.builtin;
const assert = std.debug.assert;
// var source_blob: *std.build.RunStep = undefined;
// var source_blob_path: []u8 = undefined;
// fn make_source_blob(b: *Builder) void {
// source_blob_path =
// std.mem.concat(b.allocat... | build.zig |
const std = @import("std");
const math = std.math;
const glfw = @import("glfw");
const zgpu = @import("zgpu");
const gpu = zgpu.gpu;
const c = zgpu.cimgui;
const zm = @import("zmath");
const content_dir = @import("build_options").content_dir;
const window_title = "zig-gamedev: textured quad (wgpu)";
// zig fmt: off
c... | samples/textured_quad_wgpu/src/textured_quad_wgpu.zig |
const tty = @import("tty.zig");
const x86 = @import("x86.zig");
// GDT segment selectors.
pub const KERNEL_CODE = 0x08;
pub const KERNEL_DATA = 0x10;
pub const USER_CODE = 0x18;
pub const USER_DATA = 0x20;
pub const TSS_DESC = 0x28;
// Privilege level of segment selector.
pub const KERNEL_RPL = 0b00;
pub const... | kernel/gdt.zig |
const xcb = @import("../xcb.zig");
pub const id = xcb.Extension{ .name = "MIT-SCREEN-SAVER", .global_id = 0 };
pub const Kind = extern enum(c_uint) {
@"Blanked" = 0,
@"Internal" = 1,
@"External" = 2,
};
pub const Event = extern enum(c_uint) {
@"NotifyMask" = 1,
@"CycleMask" = 2,
};
pub const St... | src/auto/screensaver.zig |
const std = @import("std");
const Builder = std.build.Builder;
const builtin = std.builtin;
const assert = std.debug.assert;
const sabaton = @import("boot/Sabaton/build.zig");
const Context = enum {
kernel,
blobspace,
userspace,
};
var source_blob: *std.build.RunStep = undefined;
var source_blob_path: []... | build.zig |
const std = @import("std");
const mem = std.mem;
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const ir = @import("ir.zig");
const Module = @import("Module.zig");
const fs = std.fs;
const elf = std.elf;
const codegen = @import("codegen.zig");
const default_entry_addr = 0x8000000;
pub const Opt... | src-self-hosted/link.zig |
const std = @import("std");
const mem = std.mem;
const meta = std.meta;
const net = std.net;
const ArrayList = std.ArrayList;
usingnamespace @import("../frame.zig");
usingnamespace @import("../primitive_types.zig");
const testing = @import("../testing.zig");
/// SUPPORTED is sent by a node in response to a OPTIONS fr... | src/frames/supported.zig |
const std = @import("std");
const zp = @import("../../zplay.zig");
const ShaderProgram = zp.graphics.common.ShaderProgram;
const alg = zp.deps.alg;
const Vec3 = alg.Vec3;
const Self = @This();
/// light type
pub const Type = enum {
directional,
point,
spot,
};
/// light properties
pub const Data = union(T... | src/graphics/3d/Light.zig |
const std = @import("std");
const interop = @import("../interop.zig");
const iup = @import("../iup.zig");
const Impl = @import("../impl.zig").Impl;
const CallbackHandler = @import("../callback_handler.zig").CallbackHandler;
const debug = std.debug;
const trait = std.meta.trait;
const Element = iup.Element;
const H... | src/elements/file_dlg.zig |
const std = @import("std");
const backend = @import("backend.zig");
const Size = @import("data.zig").Size;
const DataWrapper = @import("data.zig").DataWrapper;
const Container_Impl = @import("containers.zig").Container_Impl;
/// A button component. Instantiated using `Button(.{ })`
pub const Button_Impl = struct {
... | src/button.zig |
const std = @import("std");
const log = std.debug.warn;
const stdout = &std.io.getStdOut().outStream();
const c = @import("c.zig");
const gmp = c.gmp;
const gw = c.gw;
const glue = @import("glue.zig");
/// caller owns the result
pub fn calculate_N(k: u32, n: u32) gmp.mpz_t {
var N: gmp.mpz_t = undefined;
gmp... | u_zero.zig |
const std = @import("std");
const lexer = @import("lexer.zig");
const Allocator = std.mem.Allocator;
const ArenaAllocator = std.heap.ArenaAllocator;
const ArrayList = std.ArrayList;
const Token = lexer.Token;
const TokenType = lexer.TokenType;
pub const Ast = struct {
/// Root node of our tree.
root: AstNode,
... | zig/src/parser.zig |
const std = @import("std");
const aoc = @import("aoc-lib.zig");
fn part1(alloc: std.mem.Allocator, in: [][]const u8) usize {
var mem = std.AutoHashMap(usize, usize).init(alloc);
defer mem.deinit();
var mask0: usize = undefined;
var mask1: usize = undefined;
for (in) |line| {
if (line[1] == ... | 2020/14/aoc.zig |
const DebugSymbols = @This();
const std = @import("std");
const assert = std.debug.assert;
const fs = std.fs;
const log = std.log.scoped(.link);
const macho = std.macho;
const mem = std.mem;
const DW = std.dwarf;
const leb = std.leb;
const Allocator = mem.Allocator;
const build_options = @import("build_options");
con... | src/link/MachO/DebugSymbols.zig |
const std = @import("../std.zig");
const mem = std.mem;
/// Allocator that fails after N allocations, useful for making sure out of
/// memory conditions are handled correctly.
///
/// To use this, first initialize it and get an allocator with
///
/// `const failing_allocator = &FailingAllocator.init(<allocator>,
///... | lib/std/debug/failing_allocator.zig |
const std = @import("std");
const debug = std.debug.print;
const testing = std.testing;
pub const HttpMethod = enum {
CONNECT,
DELETE,
GET,
HEAD,
OPTIONS,
PATCH,
POST,
PUT,
TRACE,
pub fn string(self: HttpMethod) [:0]const u8 {
return @tagName(self);
}
pub fn cre... | server/main.zig |
const std = @import("std");
const testing = std.testing;
const debug = std.debug.print;
const daya = @import("daya");
const main = @import("main.zig");
pub const OutputFormat = enum {
dot,
png,
svg
};
pub const AppArgs = struct {
input_file: []const u8,
output_file: []const u8,
output_format: ... | compiler/src/argparse.zig |
const std = @import("std");
const fs = std.fs;
const Image = @import("../image.zig").Image;
const upaya = @import("../upaya.zig");
const math = upaya.math;
const stb = upaya.stb;
pub const TexturePacker = struct {
pub const Sprite = struct {
name: []const u8,
source: math.Rect,
origin: math... | src/utils/texture_packer.zig |
const std = @import("std");
const bigInt = std.math.big.int.Managed;
const Point = struct {
x: *bigInt,
y: *bigInt,
};
pub fn main() !void {
var gpa: std.heap.GeneralPurposeAllocator(.{}) = .{};
defer _ = gpa.deinit();
const alloc = &gpa.allocator;
var gx = try bigInt.init(alloc);
defer g... | src/crypto.zig |
const c = @import("../../c_global.zig").c_imp;
const std = @import("std");
// dross-zig
const FramebufferType = @import("../framebuffer.zig").FramebufferType;
const FramebufferAttachmentType = @import("../framebuffer.zig").FramebufferAttachmentType;
const texture = @import("../texture.zig");
const Texture = texture.Tex... | src/renderer/backend/framebuffer_opengl.zig |
const std = @import("std");
const c = @import("c.zig");
const Mat4 = @import("math3d.zig").Mat4;
const Vec3 = @import("math3d.zig").Vec3;
const glsl = @cImport({
@cInclude("sokol/sokol_gfx.h");
@cInclude("shaders/cube.glsl.h");
});
const SampleCount = 4;
const State = struct {
pass_action: c.sg_pass_actio... | src/example_cube.zig |
usingnamespace @import("root").preamble;
const log = lib.output.log.scoped(.{
.prefix = "PCI",
.filter = .info,
});
const paging = os.memory.paging;
const range = lib.util.range.range;
pub const Handler = struct { function: fn (*os.platform.InterruptFrame, u64) void, context: u64 };
var handlers: [0x100]Ha... | subprojects/flork/src/platform/pci.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const col = @import("color.zig");
const Image = @This();
const colormap_len = 0x100;
width: u32,
height: u32,
pixels: []u8,
colormap: ?[]u8 = null,
allocator: Allocator,
pub fn initEmptyRgba(allocator: Allocator, width: u32, height: u32) !Image {
... | src/Image.zig |
const std = @import("std");
const assert = std.debug.assert;
pub const OffsetType = enum {
linear,
periodic,
step,
non_ideal,
};
pub const Time = struct {
const Self = @This();
/// The duration of a single tick in nanoseconds.
resolution: u64,
offset_type: OffsetType,
/// Co-eff... | src/test/time.zig |
const build_options = @import("build_options");
const std = @import("std");
const warn = std.log.warn;
const mem = std.mem;
const fs = std.fs;
const sapp = @import("sokol").app;
const host = @import("host");
const gfx = host.gfx;
const audio = host.audio;
const time = host.time;
const Args = host.Args;
c... | src/main.zig |
const std = @import("std");
const mem = std.mem;
const unicode = std.unicode;
const ascii = @import("ascii.zig");
const ziglyph = @import("ziglyph");
const CodePointIterator = ziglyph.CodePointIterator;
const Grapheme = ziglyph.Grapheme;
const GraphemeIterator = Grapheme.GraphemeIterator;
const prop_list = ziglyph.pro... | src/Zigstr.zig |
const std = @import("std");
const logger = std.log.scoped(.qoi);
pub const Color = extern struct {
r: u8,
g: u8,
b: u8,
a: u8 = 0xFF,
fn hash(c: Color) u6 {
return @truncate(u6, c.r *% 3 +% c.g *% 5 +% c.b *% 7 +% c.a *% 11);
}
pub fn eql(a: Color, b: Color) bool {
return ... | sharing-part2/ZigAdventures/zighello/src/qoi.zig |
const std = @import("std");
const Op = @import("op.zig");
const Module = @import("module.zig");
const Instance = @import("instance.zig");
const Memory = @import("Memory.zig");
const util = @import("util.zig");
const Execution = @This();
memory: *Memory,
funcs: []const Instance.Func,
allocator: *std.mem.Allocator,
ins... | src/execution.zig |
const std = @import("std");
const generator = @import("generator");
const Handle = generator.Handle;
const Generator = generator.Generator;
const Map = generator.Map;
pub const io_mode = .evented;
const expect = std.testing.expect;
pub fn main() !void {
try benchDrain();
try benchGeneratorVsCallback();
}
p... | benchmarks.zig |
const std = @import("../std.zig");
const math = std.math;
const expect = std.testing.expect;
pub fn Frexp(comptime T: type) type {
return struct {
significand: T,
exponent: i32,
};
}
/// Breaks x into a normalized fraction and an integral power of two.
/// f == frac * 2^exp, with |frac| in th... | lib/std/math/frexp.zig |
const std = @import("std");
const zupnp = @import("zupnp");
pub fn main() !void {
var lib = try zupnp.ZUPnP.init(std.heap.page_allocator, .{});
defer lib.deinit();
lib.server.static_root_dir = "static";
try lib.server.start();
const zig_png = "/zig.png";
const zig_png_url = try std.fmt.allocPri... | samples/mediaserver/src/main.zig |
const getty = @import("../../lib.zig");
const std = @import("std");
pub fn Map(
comptime Context: type,
comptime Error: type,
comptime nextKeySeed: @TypeOf(struct {
fn f(_: Context, _: ?std.mem.Allocator, seed: anytype) Error!?@TypeOf(seed).Value {
unreachable;
}
}.f),
c... | src/de/interface/map.zig |
const std = @import("std");
const debug = std.debug;
const mem = std.mem;
const debug_logging: bool = false;
pub fn main() !void {
var allocator = &std.heap.DirectAllocator.init().allocator;
debug.warn("10-1:");
try printMessage(allocator, input_lights);
const result2 = try getTimeOfSmallestBounding... | 2018/day_10.zig |
const std = @import("std");
const Condition = @import("./Condition.zig").Condition;
const ArrayBlockingQueue = @import("./ArrayBlockingQueue.zig").ArrayBlockingQueue;
//const LinkedBlockingQueue = @import("./LinkedBlockingQueue.zig").LinkedBlockingQueue;
const CountDownLatch = @import("./CountDownLatch.zig").Coun... | example.zig |
const std = @import("std");
const virtual_keys = v: {
@setEvalBranchQuota(100000);
const list = @embedFile("c/vk_list");
var i: usize = 0;
var vks = [_]VirtualKey{std.mem.zeroes(VirtualKey)} ** (std.mem.count(u8, list, "\n") + 1);
var lines = std.mem.split(u8, list, "\n");
while (... | src/types.zig |
const std = @import("std");
const builtin = @import("builtin");
const mem = std.mem;
const expect = std.testing.expect;
test "@select vectors" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
if (builtin.zig... | test/behavior/select.zig |
const inputFile = @embedFile("./input/day16.txt");
const std = @import("std");
const Allocator = std.mem.Allocator;
const List = std.ArrayList;
const Str = []const u8;
const BitSet = std.DynamicBitSet;
const StrMap = std.StringHashMap;
const HashMap = std.HashMap;
const Map = std.AutoHashMap;
const PriorityQueue = std... | src/day16.zig |
const std = @import("std");
const config = @import("config.zig");
const main = @import("main.zig");
const linux = std.os.linux;
const c = @import("c.zig");
pub fn windowClose(window: u64, arg: config.Arg) void {
var workspace = main.manager.getActiveScreen().getActiveWorkspace();
var win = workspace.getFocuse... | src/commands.zig |
const std = @import("std");
const print = std.debug.print;
const util = @import("util.zig");
const gpa = util.gpa;
const data = @embedFile("../data/day13.txt");
pub fn main() !void {
var timer = try std.time.Timer.start();
const width : u32 = 1500;
var paper = std.StaticBitSet(width * width).initEmpty();
... | src/day13.zig |
const std = @import("std");
const Client = @import("requestz").Client;
pub const Update = struct {
updateId: i64,
chatId: i64,
text: []const u8,
};
const GetUpdatesError = error{
NoMessages
};
pub fn main() anyerror!void {
try runEchoBot();
}
pub fn runEchoBot() anyerror!void {
var buffer: [... | src/main.zig |
const std = @import("std");
const exec = @import("../../buildutil/exec.zig");
const config = @import("../../config/config.zig");
const Copernicus = @import("../copernicus/build.zig");
const Arch = if (@hasField(std.builtin, "Arch")) std.builtin.Arch else std.Target.Cpu.Arch;
pub fn buildKernel(params: struct {
b... | subprojects/flork/build.zig |
const std = @import("std");
const testing = std.testing;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Public API:
/// Serializes the given `value: T` into the `stream`.
/// - `stream` is a instance of `std.io.Writer... | s2s.zig |
const std = @import("std");
const expect = std.testing.expect;
const test_allocator = std.testing.allocator;
const Allocator = std.mem.Allocator;
const Syntax = struct {
const Self = @This();
allocator: Allocator,
lines: [][]const u8,
pub fn load(allocator: Allocator, str: []const u8) !Self {
... | day10/src/main.zig |
const std = @import("std");
const pow = std.math.pow;
const Vector = std.meta.Vector;
const Random = std.rand.Random;
const zm = @import("zmath");
const Ray = @import("ray.zig").Ray;
const Hit = @import("ray.zig").Hit;
const ScatteredRay = @import("ray.zig").ScatteredRay;
fn randomInUnitSphere(rng: Random) Vector(4,... | src/materials.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const stdout = std.io.getStdOut().writer();
const stderr = std.io.getStdErr().writer();
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
const allocator = &arena.allocator;
const States = enum {
initial,
maybeStartTagBlock,
... | src/main.zig |
const std = @import("std");
const helper = @import("helper.zig");
const Allocator = std.mem.Allocator;
const HashMap = std.AutoHashMap;
const input = @embedFile("../inputs/day21.txt");
pub fn run(alloc: Allocator, stdout_: anytype) !void {
const nums = try parseInput(input);
const res1 = part1(nums);
con... | src/day21.zig |
const std = @import("std");
const fs = std.fs;
const ROWS: usize = 12;
const COLS: usize = 12;
const MIMG_ROWS = ROWS * (10 - 2);
const MIMG_COLS = COLS * (10 - 2);
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = &gpa.allocator;
const input = try fs.cwd().readFi... | 2020/src/day_20.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const Map = std.AutoHashMap;
const StrMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
const Str = []const u8;
const util = @import("util.zig");
const gpa = util.gpa;
const data = @embedFile("../data/puzzle/day... | src/day08.zig |
const std = @import("std");
const j = @import("jzignet");
comptime {
const current_version = std.SemanticVersion.parse("0.9.0-dev.1678+7747bf07c") catch unreachable;
const comparison = @import("builtin").zig_version.order(current_version);
if (comparison == .lt) @compileError("Zig version must be at least ... | src/main.zig |
const std = @import("std");
const util = @import("util.zig");
const data = @embedFile("../data/day17.txt");
const Input = struct {
x_min: i64,
x_max: i64,
y_min: i64,
y_max: i64,
pub fn init(input_text: []const u8, allocator: std.mem.Allocator) !@This() {
_ = allocator;
var nums ... | src/day17.zig |
const debugger_el = @import("build_options").debugger_el;
const proto = @import("proto");
const host = @import("host");
pub const Frame = proto.aarch64.ElFrame(debugger_el);
fn elReg(comptime prefix: []const u8, comptime el: comptime_int) []const u8 {
return prefix ++ "_EL" ++ [1]u8{'0' + el};
}
export fn int_ha... | src/host/arch/aarch64/main.zig |
const std = @import("std");
const fs = std.fs;
const mem = std.mem;
const Builder = std.build.Builder;
const Pkg = std.build.Pkg;
const cwd = std.fs.cwd;
pub fn build(b: *Builder) !void {
const target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions();
// Open the build root as an ite... | build.zig |
const std = @import("std");
usingnamespace @import("itertools.zig");
const IsEqual = std.testing.expectEqual;
test "range" {
{
var range_iter = range(i32, .{ .start = 0, .end = 5, .step = 1 });
var total: i32 = 0;
while (range_iter.next()) |value| {
total += value;
}
... | src/tests.zig |
const std = @import("std");
const errors = @import("errors.zig");
const fmt = std.fmt;
const data_types = @import("data_types.zig");
const parser = @import("parser.zig");
const StackNumberType = data_types.UsedNumberType;
const StackType = enum {
String,
Atom,
Number,
TokenList,
NumberList,
};
con... | src/executor.zig |
const std = @import("std");
const core = @import("core");
const game_server = @import("../server/game_server.zig");
const SomeQueues = @import("../client/game_engine_client.zig").SomeQueues;
const Socket = core.protocol.Socket;
const Request = core.protocol.Request;
const Response = core.protocol.Response;
const alloc... | src/server/server_main.zig |
const gpio = @import("../gpio.zig");
const cpu = @import("../cpu.zig");
// hacked from
// from https://github.com/RobTillaart/Arduino/tree/master/libraries/DHTlib
// and the spec: https://www.gotronic.fr/pj-1052.pdf
// clang11? doesn't seem to like error unions...
// --> hack it for now
const HackError = enum(u8) {... | src/lib/dht.zig |
// // ----------------------------------------------------------------------------
// // Second stage boot code
// // Copyright (c) 2019-2021 Raspberry Pi (Trading) Ltd.
// // SPDX-License-Identifier: BSD-3-Clause
// End of the original license notice.
// The long story about why I rewrite the bootloader in Zig:
// ... | src/ipl/w25q080.zig |
const std = @import("std");
const vector = @import("vector.zig");
const Vec4 = Vec4;
const initPoint = vector.initPoint;
const initVector = vector.initVector;
const Mat4 = @import("matrix.zig").Mat4;
const Canvas = @import("canvas.zig").Canvas;
const Color = @import("color.zig").Color;
const canvasToPPM = @import("pp... | draw_sphere.zig |
const std = @import("std");
const zgt = @import("zgt");
pub usingnamespace zgt.cross_platform;
// Short names to avoid writing 'zgt.' each time
const Button = zgt.Button;
const Margin = zgt.Margin;
const Expanded = zgt.Expanded;
const Row = zgt.Row;
const Allocator = std.mem.Allocator;
var computationLabel: zgt.Labe... | examples/calculator.zig |
const MachO = @This();
const std = @import("std");
const build_options = @import("build_options");
const builtin = @import("builtin");
const assert = std.debug.assert;
const fmt = std.fmt;
const fs = std.fs;
const log = std.log.scoped(.link);
const macho = std.macho;
const math = std.math;
const mem = std.mem;
const m... | src/link/MachO.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArenaAllocator = std.heap.ArenaAllocator;
const json = std.json;
const builtin = std.builtin;
// probably only StrMgmt.copy should ever be used
// StrMgmt.move seems ill
// sex field's behaviour is not affected
pub const StrMgmt = enum {
copy, ... | src/util.zig |
usingnamespace @import("../bits.zig");
pub fn syscall0(number: SYS) usize {
return asm volatile (
\\ syscall
\\ blez $7, 1f
\\ subu $2, $0, $2
\\ 1:
: [ret] "={$2}" (-> usize)
: [number] "{$2}" (@enumToInt(number))
: "memory", "cc", "$7"
);
}
pub fn sysc... | lib/std/os/linux/mips.zig |
const std = @import("../../std.zig");
const debug = std.debug;
const math = std.math;
const cmath = math.complex;
const Complex = cmath.Complex;
/// Returns exp(z) scaled to avoid overflow.
pub fn ldexp_cexp(z: var, expt: i32) @typeOf(z) {
const T = @typeOf(z.re);
return switch (T) {
f32 => ldexp_cex... | lib/std/math/complex/ldexp.zig |
const std = @import("std");
const liu = @import("liu");
const editor = @import("./editor.zig");
const util = @import("./util.zig");
const rows = util.rows;
const camera = util.camera;
const KeyCode = liu.gamescreen.KeyCode;
const Timer = liu.gamescreen.Timer;
const FrameInput = liu.gamescreen.FrameInput;
// https://... | src/routes/erlang/erlang.zig |
const std = @import("std");
const aoc = @import("aoc-lib.zig");
const Cup = struct {
val: usize,
cw: *Cup,
ccw: *Cup,
alloc: std.mem.Allocator,
pub fn init(alloc: std.mem.Allocator, val: usize) *Cup {
var self = alloc.create(Cup) catch unreachable;
self.val = val;
self.cw =... | 2020/23/aoc.zig |
const std = @import("std");
const aoc = @import("aoc-lib.zig");
const Diag = struct {
bits: usize,
maxbit: usize,
nums: []usize,
allocator: std.mem.Allocator,
pub fn fromInput(allocator: std.mem.Allocator, inp: anytype) !*Diag {
var nums = try allocator.alloc(usize, inp.len);
var d... | 2021/03/aoc.zig |
const Allocator = std.mem.Allocator;
const File = std.fs.File;
const FormatInterface = @import("../format_interface.zig").FormatInterface;
const ImageFormat = image.ImageFormat;
const ImageReader = image.ImageReader;
const ImageInfo = image.ImageInfo;
const ImageSeekStream = image.ImageSeekStream;
const PixelFormat = @... | src/formats/bmp.zig |
const std = @import("std");
const mem = std.mem;
const UppercaseLetter = @This();
allocator: *mem.Allocator,
array: []bool,
lo: u21 = 65,
hi: u21 = 125217,
pub fn init(allocator: *mem.Allocator) !UppercaseLetter {
var instance = UppercaseLetter{
.allocator = allocator,
.array = try allocator.all... | src/components/autogen/DerivedGeneralCategory/UppercaseLetter.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const Target = std.Target;
const log = std.log.scoped(.codegen);
const spec = @import("spirv/spec.zig");
const Opcode = spec.Opcode;
const Module = @import("../Module.zig");
const Decl = Module.Decl;
const Type = @import("../type.zig").Type;
const Value... | src/codegen/spirv.zig |
const std = @import("std");
const cast = std.meta.cast;
const mode = std.builtin.mode; // Checked arithmetic is disabled in non-debug modes to avoid side channels
// The type MontgomeryDomainFieldElement is a field element in the Montgomery domain.
// Bounds: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xfffff... | fiat-zig/src/p384_32.zig |
pub const XTRIM = struct {
key: []const u8,
strategy: Strategy,
/// Instantiates a new XTRIM command.
pub fn init(key: []const u8, strategy: Strategy) XTRIM {
return .{ .key = key, .strategy = strategy };
}
/// Validates if the command is syntactically correct.
pub fn validate(sel... | src/commands/streams/xtrim.zig |
const std = @import("std");
const win = std.os.windows;
const W = std.unicode.utf8ToUtf16LeStringLiteral;
const vk = @import("vk_codes.zig");
const DWORD = win.DWORD;
const ULONG_PTR = win.ULONG_PTR;
const HWND = win.HWND;
const WINAPI = win.WINAPI;
const HANDLE = win.HANDLE;
const WPARAM = win.WPARAM;
const LPARAM = ... | src/main.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const AutoHashMap = std.AutoHashMap;
const PriorityQueue = std.PriorityQueue;
const StringHashMap = std.StringHashMap;
// Useful stdlib functions
const tokenize = std.mem.tokenize;
const split = std.mem.split;
const trim ... | src/day25.zig |
const std = @import("std");
const builtin = @import("builtin");
const testing = std.testing;
const mem = std.mem;
const expect = testing.expect;
const expectEqual = testing.expectEqual;
test "arrays" {
var array: [5]u32 = undefined;
var i: u32 = 0;
while (i < 5) {
array[i] = i + 1;
i = arr... | test/behavior/array.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const List = std.ArrayList;
const Map = std.AutoHashMap;
const StrMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
const Str = []const u8;
const int = i64;
const util = @import("util.zig");
const gpa = util.gpa;
const data = @embedFile("../dat... | src/day08.zig |
const std = @import("std");
const Location = @import("Location.zig");
const GenericToken = @import("token.zig").Token;
pub const Matcher = fn (str: []const u8) ?usize;
pub fn Pattern(comptime TokenType: type) type {
return struct {
const Self = @This();
type: TokenType,
match: Matcher,
... | src/tokenizer.zig |
const std = @import("std");
const curses = @import("curses.zig");
pub const KeyBinding = struct { key: []const u8, help: []const u8 };
const Wrapper = struct {
s: []const u8,
maxlen: usize,
fn nextLine(self: *Wrapper) ?[]const u8 {
if (self.s.len == 0) {
return null;
}
... | src/help.zig |
const std = @import("std");
const range = @import("range").range;
// // the naïve recursive implementation
// pub fn leven(comptime T: type, a: []const T, b: []const T) usize {
// if (b.len == 0) return a.len;
// if (a.len == 0) return b.len;
// if (a[0] == b[0]) return leven(T, a[1..], b[1..]);
// r... | src/lib.zig |
const std = @import("std");
const warn = std.debug.print;
const Allocator = std.mem.Allocator;
var allocator: *Allocator = undefined;
const ipc = @import("./ipc/epoll.zig");
const config = @import("./config.zig");
const c = @cImport({
@cInclude("unistd.h");
@cInclude("pthread.h");
@cInclude("sys/epoll.h");... | src/thread.zig |
const std = @import("std");
const builtin = @import("builtin");
const zbox = @import("zbox");
const Channel = @import("utils/channel.zig").Channel;
const Chat = @import("Chat.zig");
const main = @import("main.zig");
const senseUrl = @import("./utils/url.zig").sense;
const GlobalEventUnion = main.Event;
const BorkConfig... | src/Terminal.zig |
const std = @import("std");
const assert = std.debug.assert;
const IO_Uring = std.os.linux.IO_Uring;
const io_uring_cqe = std.os.linux.io_uring_cqe;
/// Using non-blocking io_uring, write a page, fsync the write, then read the page back in.
/// Rinse and repeat to iterate across a large file.
///
/// Note that this is... | demos/io_uring/fs_io_uring.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
fn ActiveSpots(comptime C: type) type { return std.AutoHashMap(C, void); }
pub fn Conway(comptime C: type) type {
return struct {
const Self = @This();
allocator: Allocator,
active_spots: ActiveSpots(C),
pub fn init... | src/main/zig/lib/conway.zig |
const std = @import("std");
const meta = std.meta;
const print = std.debug.print;
const Needle = @import("needle.zig").Needle;
const call_fn_with_union_type = @import("needle.zig").call_fn_with_union_type;
const testing = std.testing;
pub fn parseStringForType(string: []const u8) !Needle {
if (string.len == 0) ret... | src/input.zig |
const std = @import("std");
const Parser = @import("parser.zig").Parser;
const nodes = @import("nodes.zig");
const scanners = @import("scanners.zig");
const strings = @import("strings.zig");
pub fn matches(allocator: *std.mem.Allocator, line: []const u8) !bool {
var r = try row(allocator, line);
var result = r... | src/table.zig |
const std = @import("std");
const png = @import("types.zig");
const imgio = @import("../../io.zig");
const utils = @import("../../utils.zig");
const color = @import("../../color.zig");
const PixelStorage = @import("../../pixel_storage.zig").PixelStorage;
const PixelFormat = @import("../../pixel_format.zig").PixelFormat... | src/formats/png/reader.zig |
const std = @import("std");
const zang = @import("zang");
const zangscript = @import("zangscript");
const common = @import("common.zig");
const c = @import("common/c.zig");
const modules = @import("modules.zig");
pub const AUDIO_FORMAT: zang.AudioFormat = .signed16_lsb;
pub const AUDIO_SAMPLE_RATE = 44100;
pub const A... | examples/example_script_runtime_mono.zig |
const std = @import("std");
const ray = @import("translate-c/raylib_all.zig");
const ArrayList = std.ArrayList;
const EnvItem = struct { rect: ray.Rectangle, blocking: bool, color: ray.Color };
const Player = struct {
const G = 400;
const hor_speed = 200.0;
const jump_speed = 350.0;
position: ray.Vecto... | src/examples/2d_camera_flatformer.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/day03.txt");
p... | src/day03.zig |
const std = @import("std");
const assert = std.debug.assert;
pub const FT_LOAD_DEFAULT = 0x0;
pub const FT_LOAD_NO_SCALE = ( 1 << 0 );
pub const FT_LOAD_NO_HINTING = ( 1 << 1 );
pub const FT_LOAD_RENDER = ( 1 << 2 );
pub const FT_LOAD_NO_BITMAP ... | freetype2.zig |
const std = @import("std");
/// A custom N-bit floating point type, representing `f * 2^e`.
/// e is biased, so it be directly shifted into the exponent bits.
/// Negative exponent indicates an invalid result.
pub fn BiasedFp(comptime T: type) type {
const MantissaT = mantissaType(T);
return struct {
... | lib/std/fmt/parse_float/common.zig |
const std = @import("std");
const ast = @import("./ast.zig");
const tok = @import("./token.zig");
const lex = @import("./lexer.zig");
const expr = @import("./expr.zig");
const tfmt = @import("./fmt.zig");
const ExprBlock = expr.ExprBlock;
const Cursor = expr.Cursor;
pub const Op = @import("./token/op.zig").Op;
pub cons... | src/lang/parser.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/day04.txt");
c... | src/day04.zig |
const std = @import("std");
const Arena = std.heap.ArenaAllocator;
const expectEqual = std.testing.expectEqual;
const expectEqualStrings = std.testing.expectEqualStrings;
const yeti = @import("yeti");
const initCodebase = yeti.initCodebase;
const tokenize = yeti.tokenize;
const parse = yeti.parse;
const analyzeSemanti... | src/tests/test_function.zig |
const std = @import("std");
const root = @import("root");
pub const STEP_SIZE = if (@hasDecl(root, "step_size")) root.step_size else 64;
comptime {
if (!(STEP_SIZE == 64 or STEP_SIZE == 128)) @compileError("step-size must be either 64 or 128");
}
pub const DEFAULT_MAX_DEPTH = 1024;
pub const u8xstep_size = std.met... | src/common.zig |