From 3d05c94b9d8aa964e4ff848c95d5999cec170e04 Mon Sep 17 00:00:00 2001 From: Taylan Kammer Date: Sun, 30 Mar 2025 18:34:00 +0200 Subject: Big cleanup. --- src/zisp/value/seq.zig | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/zisp/value/seq.zig (limited to 'src/zisp/value/seq.zig') diff --git a/src/zisp/value/seq.zig b/src/zisp/value/seq.zig new file mode 100644 index 0000000..3418a5a --- /dev/null +++ b/src/zisp/value/seq.zig @@ -0,0 +1,57 @@ +const builtin = @import("builtin"); +const std = @import("std"); + +const value = @import("../value.zig"); +const gc = @import("../gc.zig"); + +const Value = value.Value; + +const Endian = enum(u1) { + little, + big, + + const native: Endian = switch (builtin.target.cpu.arch.endian()) { + .little => .little, + .big => .big, + }; +}; + +pub const Header = packed struct(u64) { + type: enum(u2) { + values, + string, + ints, + floats, + }, + info: packed union { + values: packed struct(u14) { + weak: bool = false, + _: u13 = 0, + }, + string: packed struct(u14) { + enc: enum(u4) { utf8, utf16, utf24, utf32 }, + endian: Endian = .native, + quoted: bool, + interned: bool, + _: u7 = 0, + }, + ints: packed struct(u14) { + signed: bool, + endian: Endian = .native, + size: u12, + }, + floats: packed struct(u14) { + double: bool, + endian: Endian = .native, + _: u12 = 0, + }, + }, + size: u48, + + pub fn bytes(self: *Header) []u8 { + const hs = @sizeOf(Header); + const ptr: [*]u8 = @ptrCast(self); + const end = hs + self.size; + return ptr[hs..end]; + } +}; -- cgit v1.2.3