a
This commit is contained in:
parent
22026ad078
commit
d57830079c
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
material
|
||||
zig-cache
|
13
src/main.zig
13
src/main.zig
|
@ -6,17 +6,4 @@ const write = @import("./qtshit/write.zig");
|
|||
pub fn main() !void {
|
||||
const stdout = std.io.getStdOut().writer();
|
||||
try stdout.print("Hello, {s}!\n", .{"world"});
|
||||
|
||||
var byteList = std.ArrayList(u8).init(std.heap.page_allocator);
|
||||
defer byteList.deinit();
|
||||
|
||||
// Write
|
||||
try write.add_int(byteList.writer(), 9999);
|
||||
try write.add_byte(byteList.writer(), 'a');
|
||||
|
||||
// Read
|
||||
var fBS = std.io.fixedBufferStream(byteList.items);
|
||||
try stdout.print("int: {d} \n", .{try read.get_int(fBS.reader())});
|
||||
try stdout.print("byte: {c} \n", .{try read.get_byte(fBS.reader())});
|
||||
|
||||
}
|
||||
|
|
0
src/qtshit/qvariant.zig
Normal file
0
src/qtshit/qvariant.zig
Normal file
|
@ -1,24 +1,34 @@
|
|||
const std = @import("std");
|
||||
|
||||
|
||||
pub fn get_int(reader: anytype) !u32 {
|
||||
return try reader.readIntBig(u32);
|
||||
return try reader.readIntBig(u32);
|
||||
}
|
||||
|
||||
pub fn get_short(reader: anytype) !u16 {
|
||||
return try reader.readIntBig(u16);
|
||||
return try reader.readIntBig(u16);
|
||||
}
|
||||
|
||||
pub fn get_byte(reader: anytype) !u8 {
|
||||
return try reader.readByte();
|
||||
return try reader.readByte();
|
||||
}
|
||||
|
||||
pub fn get_string(reader: anytype, allocator: *std.mem.Allocator) ![]u8 {
|
||||
var buffer: [1024]u8 = undefined;
|
||||
var buffer: [1024]u8 = undefined;
|
||||
|
||||
return try reader.readUntilDelimiterAlloc(
|
||||
allocator,
|
||||
'\x00',
|
||||
1024,
|
||||
);
|
||||
}
|
||||
return try reader.readUntilDelimiterAlloc(
|
||||
allocator,
|
||||
'\x00',
|
||||
1024,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn get_stringlist(reader: anytype, allocator: *std.mem.Allocator) !std.ArrayList([]const u8) {
|
||||
var strList = std.ArrayList([]const u8).init(allocator);
|
||||
var size = try get_int(reader);
|
||||
var i: u32 = 0;
|
||||
while (i < size) {
|
||||
try strList.append(try get_string(reader, allocator));
|
||||
i = i + 1;
|
||||
}
|
||||
return strList;
|
||||
}
|
||||
|
|
|
@ -52,4 +52,26 @@ test "read/write string" {
|
|||
var val = try read.get_string(fBS.reader(), std.heap.page_allocator);
|
||||
|
||||
try expect(std.mem.eql(u8, val, "Hello World!"));
|
||||
}
|
||||
|
||||
test "read/write stringlist" {
|
||||
var byteList = std.ArrayList(u8).init(std.heap.page_allocator);
|
||||
defer byteList.deinit();
|
||||
|
||||
var arr = std.ArrayList([]const u8).init(std.heap.page_allocator);
|
||||
defer arr.deinit();
|
||||
try arr.append("Hewwo");
|
||||
try arr.append("World");
|
||||
|
||||
|
||||
try write.add_stringlist(byteList.writer(), arr);
|
||||
|
||||
var fBS = std.io.fixedBufferStream(byteList.items);
|
||||
var val = try read.get_stringlist(fBS.reader(), std.heap.page_allocator);
|
||||
|
||||
|
||||
try expect(arr.items.len == val.items.len);
|
||||
for (arr.items) |str, index| {
|
||||
try expect(std.mem.eql(u8, str, val.items[index]));
|
||||
}
|
||||
}
|
|
@ -1,16 +1,25 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub fn add_int(writer: anytype, number: u32) !void {
|
||||
try writer.writeIntBig(u32, number);
|
||||
try writer.writeIntBig(u32, number);
|
||||
}
|
||||
|
||||
pub fn add_short(writer: anytype, number: u16) !void {
|
||||
try writer.writeIntBig(u16, number);
|
||||
try writer.writeIntBig(u16, number);
|
||||
}
|
||||
|
||||
pub fn add_byte(writer: anytype, byte: u8) !void {
|
||||
try writer.writeByte(byte);
|
||||
try writer.writeByte(byte);
|
||||
}
|
||||
|
||||
pub fn add_string(writer: anytype, str: []const u8) !void {
|
||||
try writer.writeAll(str);
|
||||
try writer.writeByte('\x00');
|
||||
}
|
||||
try writer.writeAll(str);
|
||||
try writer.writeByte('\x00');
|
||||
}
|
||||
|
||||
pub fn add_stringlist(writer: anytype, strList: std.ArrayList([]const u8)) !void {
|
||||
try add_int(writer, @intCast(u32, strList.items.len));
|
||||
for (strList.items) |string| {
|
||||
try add_string(writer, string);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
1460 1052843 1622542926812273719 1cda0203593f0bff7b4c0428d9cabadb /home/username/Projects/QuasselClient/src/qtshit/test.zig
|
||||
5588 1081028 1622401981000000000 b28e8846a1fb551a569b56fcf123a093 /home/username/Zig/lib/std/std.zig
|
||||
23635 1081029 1622401981000000000 00fbb8fea25ef05eeba646e26bb20cb6 /home/username/Zig/lib/std/builtin.zig
|
||||
5086 1080039 1622401981000000000 d6192441c7258db0547cd11c747ddbd1 /home/username/Zig/lib/std/special/test_runner.zig
|
||||
18282 1081153 1622401981000000000 c0d058ca884fd934a4f43772515ed826 /home/username/Zig/lib/std/start.zig
|
||||
57926 1081063 1622401981000000000 ba9d80f4cc927315081961166c8c064f /home/username/Zig/lib/std/target.zig
|
||||
85319 1081087 1622401981000000000 0a2500be811fa3aa250ce61f7121590b /home/username/Zig/lib/std/target/x86.zig
|
||||
53217 1081066 1622401981000000000 a9590499d5dc3a7d3cd7aa9b375738cb /home/username/Zig/lib/std/math.zig
|
||||
47037 1081173 1622401981000000000 1d2192661909773f951eface449f4c97 /home/username/Zig/lib/std/meta.zig
|
||||
76171 1080872 1622401981000000000 e42b2515d2bd2ca1a758f94674ca1b4f /home/username/Zig/lib/std/debug.zig
|
||||
49868 1081071 1622401981000000000 579c8d5bf9a8971a2e20fad1dbd9adce /home/username/Zig/lib/std/array_list.zig
|
||||
102633 1080836 1622401981000000000 826ba94a31dac302fd13d076454534d6 /home/username/Zig/lib/std/mem.zig
|
||||
20541 1081068 1622401981000000000 df4b1840f51e60f5bdbc1dbedc7e092a /home/username/Zig/lib/std/mem/Allocator.zig
|
||||
44450 1080705 1622401981000000000 61ecf1dfc1bbc08a4fc62b44be4f2fcc /home/username/Zig/lib/std/heap.zig
|
||||
397 1068873 1622542904155510143 b895c1d606d849b64504a3a6cd360971 /home/username/Projects/QuasselClient/src/qtshit/write.zig
|
||||
6937 1081250 1622401981000000000 13d91209e7be79b263b6bdba75c5d7bd /home/username/Zig/lib/std/io.zig
|
||||
3733 1081259 1622401981000000000 21a631d05e989504b4ff3183a5d4268d /home/username/Zig/lib/std/io/writer.zig
|
||||
5865 1081271 1622401981000000000 e4969eefc8d5e0daa48c3e49f4d7bf71 /home/username/Zig/lib/std/io/fixed_buffer_stream.zig
|
||||
463 1061251 1622542961032420085 8ee4d73272b01493368324a481b35af9 /home/username/Projects/QuasselClient/src/qtshit/read.zig
|
||||
14707 1081262 1622401981000000000 ef35513a84751410d70fd0001a426f7c /home/username/Zig/lib/std/io/reader.zig
|
||||
17680 1081150 1622401981000000000 d776aafb7ce0e1372623be706e5dba7c /home/username/Zig/lib/std/testing.zig
|
||||
22756 1081122 1622401981000000000 d07ee73ddafae63b19ceef726d648e26 /home/username/Zig/lib/std/Thread.zig
|
||||
8975 1080902 1622401981000000000 b3d72eb864f407db2c95dd6627fba4d3 /home/username/Zig/lib/std/Thread/Mutex.zig
|
||||
111311 1080904 1622401981000000000 dd71f5dee8eb8d5b7b14ba6c7d2974b6 /home/username/Zig/lib/std/fs.zig
|
||||
34154 1081054 1622401981000000000 06743bf9e2e200fec8f39a1d3596ba9f /home/username/Zig/lib/std/fs/file.zig
|
||||
244016 1081022 1622401981000000000 ba35dc375979b529726bc588db1db177 /home/username/Zig/lib/std/os.zig
|
||||
1777 1080910 1622401981000000000 8d2a34ac655098558374af64bfaa8252 /home/username/Zig/lib/std/os/bits.zig
|
||||
63204 1081019 1622401981000000000 527fdf9fee2bc4585f4c6fc3e3ff4757 /home/username/Zig/lib/std/os/bits/linux.zig
|
||||
8916 1081013 1622401981000000000 e9a3f40802d95a6a4b68af3fcfd14cd8 /home/username/Zig/lib/std/os/bits/linux/netlink.zig
|
||||
6793 1081003 1622401981000000000 a2a3eb5025cf366e1f9966fbd4b73635 /home/username/Zig/lib/std/os/bits/linux/prctl.zig
|
||||
1569 1081007 1622401981000000000 762bf41249b51deb66386a42d8c2719f /home/username/Zig/lib/std/os/bits/linux/securebits.zig
|
||||
13413 1081014 1622401981000000000 b0c4c5f4b2828077f67ffc53afd1aadd /home/username/Zig/lib/std/os/bits/linux/x86_64.zig
|
||||
8548 1081004 1622401981000000000 fa7bade920f4bed7f523840a46fbc2a7 /home/username/Zig/lib/std/os/bits/linux/errno-generic.zig
|
||||
14029 1080900 1622401981000000000 1fdc14e8e375f22a75ecc60ad1866209 /home/username/Zig/lib/std/Thread/StaticResetEvent.zig
|
||||
43314 1081064 1622401981000000000 fa699e8243a100850c5d5ef6739f9f0e /home/username/Zig/lib/std/elf.zig
|
||||
51539 1081020 1622401981000000000 6912bc84bcc9b0d4c8dd68ffab1347fd /home/username/Zig/lib/std/os/linux.zig
|
||||
58894 1080954 1622401981000000000 693949a4b33972d972d761d11c735c16 /home/username/Zig/lib/std/os/linux/io_uring.zig
|
||||
3110 1080969 1622401981000000000 64788af658af91aafa790c4fd9d2f68c /home/username/Zig/lib/std/os/linux/x86_64.zig
|
||||
14677 1080870 1622401981000000000 53c4bacaf2f06eacd48d428a2cbee72b /home/username/Zig/lib/std/dynamic_library.zig
|
||||
13621 1080966 1622401981000000000 6768b7411b814161e8130498164dc03e /home/username/Zig/lib/std/os/linux/tls.zig
|
||||
91467 1081024 1622401981000000000 9b053d1b135054334a57f9f37742f26d /home/username/Zig/lib/std/fmt.zig
|
||||
41711 1081154 1622401981000000000 9c0bfafff5f40ab6809a9bcf07c3f824 /home/username/Zig/lib/std/hash_map.zig
|
||||
36045 1081061 1622401981000000000 bf40545c6085dd9a95de9c3549569c30 /home/username/Zig/lib/std/dwarf.zig
|
||||
23094 1080834 1622401981000000000 881b06f481df15d27be7b371a34f40bd /home/username/Zig/lib/std/dwarf_bits.zig
|
||||
1393 1081265 1622401981000000000 ecc3a07871d2612484a07b8c2229ca48 /home/username/Zig/lib/std/io/seekable_stream.zig
|
||||
15171 1081026 1622401981000000000 4a3fd55af64b0c2a9867644f4800cdaa /home/username/Zig/lib/std/leb128.zig
|
||||
48533 1081056 1622401981000000000 7be360cbd3f5fd156ac043f8c36629e6 /home/username/Zig/lib/std/fs/path.zig
|
||||
19148 1080810 1622401981000000000 5bd88f6706c5aaac347999ed9d72a5ab /home/username/Zig/lib/std/meta/trait.zig
|
||||
30378 1081172 1622401981000000000 903fea5054a61a51eb818b59fca3831c /home/username/Zig/lib/std/unicode.zig
|
||||
1590 1081117 1622401981000000000 0470f80d54ee5336adc3025569e3cdb7 /home/username/Zig/lib/std/hash.zig
|
||||
10488 1081133 1622401981000000000 6b6234564c92515584e44ecd5dbac933 /home/username/Zig/lib/std/hash/wyhash.zig
|
||||
4819 1081125 1622401981000000000 d4a704c39f8aa1e9295ed986271ba38a /home/username/Zig/lib/std/heap/arena_allocator.zig
|
||||
13726 1081060 1622401981000000000 a3dea3a6bff91acfde117f119fa1e87f /home/username/Zig/lib/std/linked_list.zig
|
||||
31051 1081123 1622401981000000000 a0782dc50610af33cad5afc3abd630a6 /home/username/Zig/lib/std/process.zig
|
||||
9567 1080898 1622401981000000000 3ddcb10ecc92045bf775fa1dc83f4b43 /home/username/Zig/lib/std/Thread/ResetEvent.zig
|
||||
1229 1080707 1622401981000000000 71465cfdef84e6cacd7bd5313fa61382 /home/username/Zig/lib/std/event.zig
|
||||
65139 1081145 1622401981000000000 52ce51e5a0a76235f1b09712e220e861 /home/username/Zig/lib/std/event/loop.zig
|
||||
647 1081116 1622401981000000000 fb95ab826a4142627b810d4d1c9272a8 /home/username/Zig/lib/std/atomic.zig
|
||||
12428 1081112 1622401981000000000 852f2786036bc86d716a3e0dd8f95b19 /home/username/Zig/lib/std/atomic/queue.zig
|
||||
11169 1081115 1622401981000000000 3f1bc5a75fa18752b21011adf71fa35e /home/username/Zig/lib/std/time.zig
|
||||
7627 1080897 1622401981000000000 d90d890f52a10090385569db9b0a8cab /home/username/Zig/lib/std/Thread/AutoResetEvent.zig
|
||||
6056 1081111 1622401981000000000 5c7d3bd9a8fa7c1a4f2f56ee043cab0b /home/username/Zig/lib/std/atomic/stack.zig
|
||||
10409 1081152 1622401981000000000 82d9b7a5ac066966cc76ef90b7ffc386 /home/username/Zig/lib/std/log.zig
|
||||
14139 1080906 1622401981000000000 57d3057cff5514ee4c4247e643dc44b0 /home/username/Zig/lib/std/Progress.zig
|
||||
39937 1081127 1622401981000000000 d36f67bbcf5a94287681bd0af7e22bb5 /home/username/Zig/lib/std/heap/general_purpose_allocator.zig
|
||||
6737 1081215 1622401981000000000 71c99558fef7c3c78f503a55f7e85aba /home/username/Zig/lib/std/math/log2.zig
|
||||
74644 1080908 1622401981000000000 5a43b9b2b90c39f471532633bbb982a9 /home/username/Zig/lib/std/os/windows.zig
|
||||
52182 1080977 1622401981000000000 4c9986516439dfc2c85364d7b6180cbb /home/username/Zig/lib/std/os/windows/bits.zig
|
||||
131685 1080986 1622401981000000000 bc3fa898ee7db34328396faef199063e /home/username/Zig/lib/std/os/windows/win32error.zig
|
||||
237754 1080989 1622401981000000000 767e8595d34a54317caabb7b29ad507f /home/username/Zig/lib/std/os/windows/ntstatus.zig
|
||||
4196 1080972 1622401981000000000 e7c9e02ed8010ba45d6d9188cb663baf /home/username/Zig/lib/std/os/linux/vdso.zig
|
||||
55667 1080702 1622401981000000000 91feab183766968b9b062a208734c37d /home/username/Zig/lib/std/macho.zig
|
||||
21315 1081065 1622401981000000000 d477ff615228bc7577f8332fc1314e65 /home/username/Zig/lib/std/pdb.zig
|
||||
11334 1080871 1622401981000000000 9a28b5cba8b4531decae0ad1c44bc2e4 /home/username/Zig/lib/std/coff.zig
|
|
@ -1,104 +0,0 @@
|
|||
const std = @import("std");
|
||||
/// Zig version. When writing code that supports multiple versions of Zig, prefer
|
||||
/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.
|
||||
pub const zig_version = std.SemanticVersion.parse("0.8.0-dev.2711+11ae6c42c") catch unreachable;
|
||||
/// Temporary until self-hosted is feature complete.
|
||||
pub const zig_is_stage2 = false;
|
||||
/// Temporary until self-hosted supports the `cpu.arch` value.
|
||||
pub const stage2_arch: std.Target.Cpu.Arch = .x86_64;
|
||||
|
||||
pub const output_mode = std.builtin.OutputMode.Exe;
|
||||
pub const link_mode = std.builtin.LinkMode.Static;
|
||||
pub const is_test = true;
|
||||
pub const single_threaded = false;
|
||||
pub const abi = std.Target.Abi.gnu;
|
||||
pub const cpu: std.Target.Cpu = .{
|
||||
.arch = .x86_64,
|
||||
.model = &std.Target.x86.cpu.broadwell,
|
||||
.features = std.Target.x86.featureSet(&[_]std.Target.x86.Feature{
|
||||
.@"64bit",
|
||||
.adx,
|
||||
.aes,
|
||||
.avx,
|
||||
.avx2,
|
||||
.bmi,
|
||||
.bmi2,
|
||||
.cmov,
|
||||
.cx16,
|
||||
.cx8,
|
||||
.ermsb,
|
||||
.f16c,
|
||||
.false_deps_lzcnt_tzcnt,
|
||||
.false_deps_popcnt,
|
||||
.fast_15bytenop,
|
||||
.fast_scalar_fsqrt,
|
||||
.fast_shld_rotate,
|
||||
.fast_variable_shuffle,
|
||||
.fma,
|
||||
.fsgsbase,
|
||||
.fxsr,
|
||||
.idivq_to_divl,
|
||||
.invpcid,
|
||||
.lzcnt,
|
||||
.macrofusion,
|
||||
.mmx,
|
||||
.movbe,
|
||||
.nopl,
|
||||
.pclmul,
|
||||
.popcnt,
|
||||
.prfchw,
|
||||
.rdrnd,
|
||||
.rdseed,
|
||||
.sahf,
|
||||
.slow_3ops_lea,
|
||||
.sse,
|
||||
.sse2,
|
||||
.sse3,
|
||||
.sse4_1,
|
||||
.sse4_2,
|
||||
.ssse3,
|
||||
.vzeroupper,
|
||||
.x87,
|
||||
.xsave,
|
||||
.xsaveopt,
|
||||
}),
|
||||
};
|
||||
pub const os = std.Target.Os{
|
||||
.tag = .linux,
|
||||
.version_range = .{ .linux = .{
|
||||
.range = .{
|
||||
.min = .{
|
||||
.major = 5,
|
||||
.minor = 10,
|
||||
.patch = 41,
|
||||
},
|
||||
.max = .{
|
||||
.major = 5,
|
||||
.minor = 10,
|
||||
.patch = 41,
|
||||
},
|
||||
},
|
||||
.glibc = .{
|
||||
.major = 2,
|
||||
.minor = 17,
|
||||
.patch = 0,
|
||||
},
|
||||
}},
|
||||
};
|
||||
pub const target = std.Target{
|
||||
.cpu = cpu,
|
||||
.os = os,
|
||||
.abi = abi,
|
||||
};
|
||||
pub const object_format = std.Target.ObjectFormat.elf;
|
||||
pub const mode = std.builtin.Mode.Debug;
|
||||
pub const link_libc = false;
|
||||
pub const link_libcpp = false;
|
||||
pub const have_error_return_tracing = true;
|
||||
pub const valgrind_support = true;
|
||||
pub const position_independent_code = false;
|
||||
pub const position_independent_executable = false;
|
||||
pub const strip_debug_info = false;
|
||||
pub const code_model = std.builtin.CodeModel.default;
|
||||
pub var test_functions: []std.builtin.TestFn = undefined; // overwritten later
|
||||
pub const test_io_mode = .blocking;
|
|
@ -1 +0,0 @@
|
|||
75055f28f06f4f90c24164e5a3f6ae2300
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue