code
stringlengths
38
801k
repo_path
stringlengths
6
263
const std = @import("std"); const t = @import("testing.zig"); const Input = @import("input.zig"); usingnamespace @import("ghost_party.zig"); usingnamespace @import("meta.zig"); usingnamespace @import("result.zig"); usingnamespace @import("string_parser.zig"); /// /// Base type constructor for ParZig parsers /// ///...
src/parser.zig
const std = @import("std"); const webgpu = @import("./webgpu.zig"); pub const Device = struct { pub const VTable = struct { destroy_fn: fn(*Device) void, create_buffer_fn: fn(*Device, webgpu.BufferDescriptor) CreateBufferError!*webgpu.Buffer, create_texture_fn: fn(*Device, webgpu.TextureDe...
src/device.zig
const std = @import("std"); const stdx = @import("stdx"); const graphics = @import("graphics"); const Graphics = graphics.Graphics; const builtin = @import("builtin"); const ds = stdx.ds; const v8 = @import("v8"); const platform = @import("platform"); const KeyCode = platform.KeyCode; const t = stdx.testing; const Mock...
runtime/api.zig
const std = @import("std"); const mem = std.mem; const default_out = "./colorstorm-out"; const flag_prefix_long = "--"; const flag_prefix_short = "-"; const allocator = std.heap.page_allocator; var settings = std.BufMap.init(allocator); pub const Gen = enum { vim, vscode, sublime, atom, iterm2, all }; pub const Flag...
src/cli.zig
const std = @import("std"); const mach = @import("mach"); const gpu = @import("gpu"); const zm = @import("zmath"); const glfw = @import("glfw"); pub const Vertex = struct { pos: @Vector(4, f32), uv: @Vector(2, f32), }; // Simple triangle const WINDOW_WIDTH = 640; const WINDOW_HEIGHT = 480; const TRIANGLE_SCAL...
examples/gkurve/main.zig
//! Reference: "SIMD-friendly algorithms for substring searching" by <NAME>. const std = @import("std"); const ArrayList = std.ArrayList; const Allocator = std.mem.Allocator; const AutoHashMap = std.AutoHashMap; const expect = std.testing.expect; const print = std.debug.print; const Vector = std.meta.Vector; const u...
src/str_match.zig
const std = @import("std"); const n = @import("node.zig"); const Node = n.Node; const NodeKind = n.NodeKind; const t = std.testing; fn isWhitespace(chr: u8) bool { return chr == ' ' or chr == '\t' or chr == '\n' or chr == '\r'; } fn isNumberLike(chr: u8) bool { return chr == '0' or chr == '1' or chr == '2' or...
zig/parser.zig
const std = @import("std"); const assert = std.debug.assert; const tools = @import("tools"); const CupIndex = u24; const Cup = packed struct { next: CupIndex }; fn PackedArray(comptime T: type, comptime stride: usize, comptime count: usize) type { return struct { mem: [count * stride]u8, inline fn...
2020/day23.zig
const c = @import("../../c_global.zig").c_imp; const std = @import("std"); // dross-zig const glfb = @import("backend/framebuffer_opengl.zig"); const FramebufferGl = glfb.FramebufferGl; const texture = @import("texture.zig"); const Texture = texture.Texture; const renderer = @import("renderer.zig"); const selected_api ...
src/renderer/framebuffer.zig
const std = @import("std"); const fs = std.fs; const mem = std.mem; const tmpDir = std.testing.tmpDir; var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const alloc = &gpa.allocator; pub fn main() !void { const args = try std.process.argsAlloc(std.heap.page_allocator); var tmp = tmpDir(.{}); defer tmp.c...
src/main.zig
const xcb = @import("../xcb.zig"); pub const id = xcb.Extension{ .name = "MIT-SHM", .global_id = 0 }; pub const SEG = u32; /// Opcode for Completion. pub const CompletionOpcode = 0; /// @brief CompletionEvent pub const CompletionEvent = struct { @"response_type": u8, @"pad0": u8, @"sequence": u16, ...
src/auto/shm.zig
const std = @import("std"); const util = @import("util.zig"); const data = @embedFile("../data/day05.txt"); // Takes in lines, returns number of intersections pub fn numberOfIntersections(lines: []const util.Line(i32), consider_diagonals: bool) !usize { var map = util.Map(util.Point(i32), usize).init(util.gpa); ...
src/day05.zig
const std = @import("std"); const mem = std.mem; const os = std.os; const assert = std.debug.assert; const cmn = @import("common.zig"); const dom = @import("dom.zig"); const Logger = @import("Logger.zig"); const number_parsing = @import("number_parsing.zig"); const string_parsing = @import("string_parsing.zig"); const...
src/ondemand.zig
// SPDX-License-Identifier: MIT // This file is part of the Termelot project under the MIT license. const std = @import("std"); const termelot = @import("../termelot.zig"); usingnamespace termelot.style; usingnamespace termelot.event; const BackendName = termelot.backend.BackendName; const Config = termelot.Config; ...
src/backend/windows.zig
const std = @import("../index.zig"); const builtin = @import("builtin"); const fmt = std.fmt; const Endian = builtin.Endian; const readIntSliceLittle = std.mem.readIntSliceLittle; const writeIntSliceLittle = std.mem.writeIntSliceLittle; // Based on Supercop's ref10 implementation. pub const X25519 = struct { pub...
std/crypto/x25519.zig
const std = @import("std"); const build_options = @import("build_options"); const builtin = std.builtin; const mem = std.mem; const testing = std.testing; const process = std.process; const log = std.log.scoped(.tests); const ChildProcess = std.ChildProcess; const Target = std.Target; const CrossTarget = std.zig.Cross...
src/test.zig
const std = @import("std"); const mem = std.mem; const Compilation = @import("../Compilation.zig"); const Pragma = @import("../Pragma.zig"); const Diagnostics = @import("../Diagnostics.zig"); const Preprocessor = @import("../Preprocessor.zig"); const Parser = @import("../Parser.zig"); const TokenIndex = @import("../Tre...
src/pragmas/gcc.zig
const std = @import("std"); const math = std.math; const testing = std.testing; const maxInt = std.math.maxInt; pub fn __log10h(a: f16) callconv(.C) f16 { // TODO: more efficient implementation return @floatCast(f16, log10f(a)); } pub fn log10f(x_: f32) callconv(.C) f32 { const ivln10hi: f32 = 4.34326171...
lib/std/special/compiler_rt/log10.zig
const std = @import("std"); usingnamespace @import("ast.zig"); usingnamespace @import("intrinsics.zig"); usingnamespace @import("gc.zig"); usingnamespace @import("linereader.zig"); usingnamespace @import("sourcelocation.zig"); /// The expression reader and evaluator pub const Interpreter = struct { env: *Env, ...
src/interpreter.zig
const std = @import("index.zig"); const builtin = @import("builtin"); const AtomicOrder = builtin.AtomicOrder; const AtomicRmwOp = builtin.AtomicRmwOp; const assert = std.debug.assert; const SpinLock = std.SpinLock; const linux = std.os.linux; /// Lock may be held only once. If the same thread /// tries to acquire the...
std/mutex.zig
const fmath = @import("index.zig"); pub fn isInf(x: var) -> bool { const T = @typeOf(x); switch (T) { f32 => { const bits = @bitCast(u32, x); bits & 0x7FFFFFFF == 0x7F800000 }, f64 => { const bits = @bitCast(u64, x); bits & (@maxValue(u64)...
src/isinf.zig
pub const DXGI_USAGE_SHADER_INPUT = @as(u32, 16); pub const DXGI_USAGE_RENDER_TARGET_OUTPUT = @as(u32, 32); pub const DXGI_USAGE_BACK_BUFFER = @as(u32, 64); pub const DXGI_USAGE_SHARED = @as(u32, 128); pub const DXGI_USAGE_READ_ONLY = @as(u32, 256); pub const DXGI_USAGE_DISCARD_ON_PRESENT = @as(u32, 512); pub const DXG...
win32/graphics/dxgi.zig
const std = @import("std"); const os = std.os; const assert = std.debug.assert; const Time = @import("../time.zig").Time; const IO = @import("../io.zig").IO; // 1 MB: larger than socket buffer so forces io_pending on darwin // Configure this value to smaller amounts to test IO scheduling overhead const buffer_size = ...
src/io/benchmark.zig
pub const Bit = enum { Zero, One, }; pub const BITPOS = struct { //! ``` //! const cmd = BITPOS.init("test", .Zero, -3, null); //! ``` key: []const u8, bit: Bit, bounds: Bounds, pub fn init(key: []const u8, bit: Bit, start: ?isize, end: ?isize) BITPOS { return .{ ...
src/commands/strings/bitpos.zig
const std = @import("std"); const io = std.io; const ArrayList = std.ArrayList; const expect = std.testing.expect; const Allocator = std.mem.Allocator; const test_allocator = std.testing.allocator; pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer { _ = gpa.deinit(); } ...
day02/src/main.zig
const std = @import("std"); const assert = std.debug.assert; const Key = union(enum) { None, DottedIdent: DottedIdentifier, Ident: []const u8, }; pub const DynamicArray = std.TailQueue(Value); /// utility function helping to index the DynamicArray pub fn indexArray(array: DynamicArray, index: usize) ?Val...
src/toml.zig
const builtin = @import("builtin"); const std = @import("std"); const Builder = std.build.Builder; pub fn build(b: *std.build.Builder) !void { _ = b; } pub fn linkArtifact(b: *Builder, exe: *std.build.LibExeObjStep, target: std.zig.CrossTarget, comptime prefix_path: []const u8) void { _ = target; if (pref...
gamekit/deps/sdl/build.zig
const std = @import("std"); const log = std.log.scoped(.jni); const android = @import("android-support.zig"); pub const JNI = struct { const Self = @This(); activity: *android.ANativeActivity, env: *android.JNIEnv, activity_class: android.jclass, pub fn init(activity: *android.ANativeActivity) Se...
src/jni.zig
const std = @import("std"); const builtin = @import("builtin"); pub const path_seperator = if (builtin.os.tag == builtin.Os.Tag.windows) "\\" else "/"; // Loads file into memory (plus a zero byte) and stores file struct in the given pointer // The file is _not_ closed pub fn loadFileWithNullTerminator2(file_path: []c...
src/Files.zig
const std = @import("std"); const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; const Tag = std.meta.Tag; const Foo = union { float: f64, int: i32, }; test "basic unions" { var foo = Foo{ .int = 1 }; try expect(foo.int == 1); foo = Foo{ .float = 12.34 }; try expect(...
test/behavior/union.zig
usingnamespace @import("../preamble.zig"); pub const kernel = .{ // Build mode .build_mode = .ReleaseSafe, // Max number of CPU cores to use .max_cpus = 0x200, // True if symbols should be stripped .strip_symbols = false, // True if source blob should be created .build_source_blob = ...
config/config.zig
const std = @import("std"); const parser = @import("parser.zig"); const ast = @import("ast.zig"); const errors = @import("error.zig"); const lir = @import("ir.zig"); const Allocator = std.mem.Allocator; const testing = std.testing; const Type = @import("Value.zig").Type; //! Contains the Compiler internals. //! This c...
src/compiler.zig
const std = @import("std"); const gemtext = @import("../gemtext.zig"); const Fragment = gemtext.Fragment; fn fmtHtmlText( data: []const u8, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype, ) !void { _ = fmt; _ = options; const illegal = "<>&\"\'"; const repla...
src/renderers/html.zig
const std = @import("std"); const math = @import("../pkg/zlm.zig"); const assert = std.debug.assert; // Fair bit of code duplication here for specialized shape algorithms. // Much credit goes to this incredible resource: // http://www.jeffreythompson.org/collision-detection/index.php pub fn isPointInCircle(point: mat...
src/zt/physics.zig
const std = @import("std"); const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; const builtin = @import("builtin"); test "atomic store" { var x: u32 = 0; @atomicStore(u32, &x, 1, .SeqCst); try expect(@atomicLoad(u32, &x, .SeqCst) == 1); @atomicStore(u32, &x, 12345678, .SeqCs...
test/behavior/atomics_stage1.zig
const std = @import("std"); const windows = @import("windows.zig"); const WINAPI = windows.WINAPI; const HRESULT = windows.HRESULT; const LPCSTR = windows.LPCSTR; const UINT = windows.UINT; const SIZE_T = windows.SIZE_T; const d3dcommon = @import("d3dcommon.zig"); pub const COMPILE_FLAG = UINT; pub const COMPILE_DEB...
modules/platform/vendored/zwin32/src/d3dcompiler.zig
const std = @import("std"); const stdx = @import("stdx"); const builtin = @import("builtin"); const runtime = @import("runtime.zig"); /// Wraps environment ops so they can be overridden for testing. pub const Environment = struct { const Self = @This(); // Overrides the main script source instead of doing a ...
runtime/env.zig
const std = @import("std"); const gl = @import("zgl"); const glfw = @import("glfz"); const ui = @import("znt-ui").ui(Scene); const znt = @import("znt"); const Scene = znt.Scene(struct { box: ui.Box, rect: ui.Rect, }, .{}); const Systems = struct { layout: ui.LayoutSystem, render: ui.RenderSystem, ...
example/main.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const empty_arr = [0]*Triev{}; const empty_str = [0]u8{}; // a wrapper for Triev that keeps track of metadata so i can more efficiently walk the triev. // no wraper for Triev.get because it doesn't generate metadata. use TrievManager.t.get instead. pub ...
triev.zig
const std = @import("std"); const mem = std.mem; const io = std.io; const fs = std.fs; const fmt = std.fmt; const testing = std.testing; const Target = std.Target; const CrossTarget = std.zig.CrossTarget; const assert = std.debug.assert; const SparcCpuinfoImpl = struct { model: ?*const Target.Cpu.Model = null, ...
lib/std/zig/system/linux.zig
const std = @import("std"); const mem = std.mem; const builtin = @import("builtin"); const expect = std.testing.expect; test "vector wrap operators" { const S = struct { fn doTheTest() void { var v: @Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 }; var x: @Vector(4, i32) = [4]i32{...
test/stage1/behavior/vector.zig
const std = @import("std"); const assert = std.debug.assert; const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; const AutoHashMap = std.AutoHashMap; const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const ExecError = error{ InvalidOpcode, InvalidParamMode, }; f...
zig/19.zig
const std = @import("std"); const time = @import("time.zig"); const April = time.Month.April; const December = time.Month.December; const January = time.Month.January; const Location = time.Location; const Monday = time.Weekday.Monday; const Saturday = time.Weekday.Saturday; const September = time.Month.September; co...
src/time/time_test.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"); const Coord = struct { x: u32, y: u32, }; const Fold = struct { axis: []const u8, val: u32, }; pub fn main() !void { var split = try u...
2021/src/day13.zig
const std = @import("std"); const Fundude = @import("../main.zig"); const Op = @import("Op.zig"); test "DAA add" { const DAA = [3]u8{ 0x27, 0, 0 }; const OP_ADD_A = 0xC6; var cpu: Fundude.Cpu = undefined; var mmu: Fundude.Mmu = undefined; { cpu.reg._8.set(.A, 0x0); _ = cpu.opExec...
src/Cpu/impl_daa_test.zig
const std = @import("std"); pub fn build(b: *std.build.Builder) !void { // I am creating an executable. This will generate an ELF executable, which // the Raspberry Pi bootloader cannot run directly. Later it will be // converted to something more appropriate to our needs. const exe = b.addExecutable(...
build.zig
const sg = @import("sokol").gfx; // // #version:1# (machine generated, don't edit!) // // Generated by sokol-shdc (https://github.com/floooh/sokol-tools) // // Cmdline: sokol-shdc -i shaders.glsl -o shaders.glsl.zig -l glsl330:metal_macos:hlsl4 -f sokol_zig // // Overview: // // Shader program 'display': // ...
src/host/shaders/shaders.glsl.zig
const std = @import("std"); const testing = std.testing; const meta = std.meta; const trait = std.meta.trait; const log = std.log.scoped(.wasm_zig); var CALLBACK: usize = undefined; // @TODO: Split these up into own error sets pub const Error = error{ /// Failed to initialize a `Config` ConfigInit, /// Fa...
src/main.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const assert = std.debug.assert; const math = std.math; const config = @import("../config.zig"); const Message = @import("../message_pool.zig").MessagePool.Message; const vsr = @import("../vsr.zig"); const Header = vsr.Header; const log = std.log.scope...
src/vsr/journal.zig
const std = @import("std"); const core = @import("../core.zig"); const debug = std.debug; const heap = std.heap; const rand = std.rand; const time = std.time; test "bench" { const str = try heap.direct_allocator.alloc(u8, 1024 * 1024 * 1024); defer heap.direct_allocator.free(str); rand.DefaultPrng.init(0...
src/core/text_bench.zig
const std = @import("std"); const assert = std.debug.assert; const log = std.log.scoped(.concurrent_ranges); pub const ConcurrentRanges = struct { name: []const u8, /// A queue of ranges acquired and in progress: acquired: ?*Range = null, pub fn acquire(self: *ConcurrentRanges, range: *Range) void { ...
src/concurrent_ranges.zig
const sf = @import("../sfml.zig"); const std = @import("std"); const assert = std.debug.assert; pub const Image = struct { const Self = @This(); // Constructor/destructor /// Creates a new image pub fn init(size: sf.Vector2u, color: sf.Color) !Self { var img = sf.c.sfImage_createFromColor(si...
src/sfml/graphics/image.zig
const std = @import("std"); const testing = std.testing; const ValueTree = std.json.ValueTree; const Value = std.json.Value; const base64url = std.base64.url_safe_no_pad; const Algorithm = enum { const Self = @This(); HS256, HS384, HS512, pub fn jsonStringify(value: Self, options: std.json.String...
jwt.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const assert = std.debug.assert; const print = std.debug.print; const data = @embedFile("data/day08"); const EntriesList = std.ArrayList(Inst); const Op = enum { nop, acc, jmp, }; const Inst = struct { op: Op, val: isize, execu...
src/day08.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const assert = std.debug.assert; const print = std.debug.print; const data = @embedFile("data/day04.txt"); const Record = struct { byr: bool = false, iyr: bool = false, eyr: bool = false, hgt: bool = false, hcl: bool = false, ecl...
src/day04.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const assert = std.debug.assert; const print = std.debug.print; const data = @embedFile("data/day14.txt"); const EntriesList = std.ArrayList(Record); const Record = struct { x: usize = 0, }; var mem = std.AutoArrayHashMap(u36, u36).init(std.heap.p...
src/day14.zig
const std = @import("std"); const dtb = @import("dtb.zig"); usingnamespace @import("util.zig"); const traverser = @import("traverser.zig"); pub const Error = traverser.Error || std.mem.Allocator.Error || error{ MissingCells, UnsupportedCells, BadValue, }; pub fn parse(allocator: *std.mem.Allocator, fdt: [...
src/parser.zig
const std = @import("std"); const ArrayList = std.ArrayList; const mem = std.mem; const Allocator = mem.Allocator; const page_size = mem.page_size; const assert = std.debug.assert; /// Global structure to hold allocations that leave their origining thread /// Not directly accessible var global_collector: LostAndFound ...
src/adma.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const assert = std.debug.assert; const getNodeType = @import("node.zig").Node; pub fn BTreeMap(comptime K: type, comptime V: type) type { return struct { const Self = @This(); root: ?*Node, allocator: Allocator, con...
src/btreemap.zig
pub const font_icon_filename_far = "fa-regular-400.ttf"; pub const font_icon_filename_fas = "fa-solid-900.ttf"; pub const icon_range_min = 0xf000; pub const icon_range_max = 0xf976; pub const ad = "\u{f641}"; pub const address_book = "\u{f2b9}"; pub const address_card = "\u{f2bb}"; pub const adjust = "\u{f042}"; pub c...
gamekit/deps/imgui/font_awesome.zig
const std = @import("std"); const Color = @import("color.zig").Color; const Canvas = @import("canvas.zig").Canvas; inline fn byteColorValue(val: f64) u8 { const v = std.math.clamp(val * 256.0, 0.0, 255.0); return @floatToInt(u8, v); } pub fn canvasToPPM(canvas: Canvas, anywriter: anytype) !void { var buf...
ppm.zig