fmt code.

This commit is contained in:
Kitteh 2021-06-04 17:48:50 +01:00
parent 1ec3cfb28f
commit 67c9353455
35 changed files with 48 additions and 42 deletions

View file

@ -6,7 +6,6 @@ const prettyPrintQVariant = @import("./qtshit/utils/prettyPrintQVariant.zig").pr
const freeQVariant = @import("./qtshit/utils/free/freeQVariant.zig").freeQVariant;
const QVariantMapToQVariantList = @import("./qtshit/utils/QVariantMapToQVariantList.zig").QVariantMapToQVariantList;
fn dumpDebug(name: []const u8, list: std.ArrayList(u8)) !void {
std.debug.print("dumpDebug list len {d}\n", .{list.items.len});
@ -28,7 +27,7 @@ pub const Client = struct {
//try write.writeUInt(s.stream.writer(), magic);
//try write.writeUInt(s.stream.writer(), 0x80000002);
try s.stream.writer().writeAll(&[_]u8{0x42, 0xb3, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00});
try s.stream.writer().writeAll(&[_]u8{ 0x42, 0xb3, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00 });
var flags = try read.readByte(s.stream.reader());
var extra = try read.readShort(s.stream.reader());

View file

@ -16,7 +16,7 @@ pub fn main() !void {
var username = try argIter.next(allocator).?;
var password = try argIter.next(allocator).?;
std.debug.print("host={s} port={d}\n", .{host, portInt});
std.debug.print("host={s} port={d}\n", .{ host, portInt });
var sock = try std.net.tcpConnectToHost(allocator, host, portInt);
var client = initClient(allocator, &sock);

View file

@ -18,7 +18,7 @@ const readUserType = @import("./usertypes/readUserType.zig").readUserType;
const QVariant = @import("../types/QVariant.zig").QVariant;
const QVariantTypes = @import("../types/QVariantTypes.zig").QVariantTypes;
pub fn readQVariantT(reader: anytype, type_id: u32, allocator: *std.mem.Allocator) (@TypeOf(reader).Error || error{EndOfStream} || error{OutOfMemory} || error{DecodeError} || ReadStringErrors ) !QVariant {
pub fn readQVariantT(reader: anytype, type_id: u32, allocator: *std.mem.Allocator) (@TypeOf(reader).Error || error{EndOfStream} || error{OutOfMemory} || error{DecodeError} || ReadStringErrors)!QVariant {
switch (type_id) {
@enumToInt(QVariantTypes.Byte) => {
var byte = try readByte(reader);

View file

@ -6,7 +6,7 @@ pub fn readShort(reader: anytype) !u16 {
}
test "deserialize short" {
var bytes = &[_]u8{0x13, 0x12};
var bytes = &[_]u8{ 0x13, 0x12 };
var fBS = std.io.fixedBufferStream(bytes);
var short = try readShort(fBS.reader());

View file

@ -26,7 +26,18 @@ pub fn readString(reader: anytype, allocator: *std.mem.Allocator) (@TypeOf(reade
}
test "deserialize String" {
var bytes = &[_]u8{ 0, 0, 0, 6, 0, 111, 0, 119, 0, 111, };
var bytes = &[_]u8{
0,
0,
0,
6,
0,
111,
0,
119,
0,
111,
};
var fBS = std.io.fixedBufferStream(bytes);
var str = try readString(fBS.reader(), std.testing.allocator);
@ -34,4 +45,3 @@ test "deserialize String" {
try std.testing.expectEqualStrings("owo", str);
}

View file

@ -10,7 +10,6 @@ const readQVariantMap = @import("../readQVariantMap.zig").readQVariantMap;
const readBufferInfo = @import("./readBufferInfo.zig").readBufferInfo;
const readMessage = @import("./readMessage.zig").readMessage;
pub fn readUserType(reader: anytype, allocator: *std.mem.Allocator) !UserType {
var userTypeName = try readQByteArray(reader, allocator);
userTypeName = userTypeName[0 .. userTypeName.len - 1];
@ -64,7 +63,7 @@ pub fn readUserType(reader: anytype, allocator: *std.mem.Allocator) !UserType {
return UserType{
.Message = try readMessage(reader, allocator),
};
}else {
} else {
std.debug.print("Unknown UserType With Name: {s}\n", .{userTypeName});
@panic("Unknown Usertype.");
}

View file

@ -11,7 +11,7 @@ pub fn QVariantMapToQVariantList(varMap: std.StringHashMap(QVariant), allocator:
while (iter.next()) |i| {
if (i % 2 == 1) continue;
var item = varMapIter.next().?;
variantList[i] = QVariant{.String = item.key};
variantList[i] = QVariant{ .String = item.key };
variantList[i + 1] = item.value;
}
return variantList;

View file

@ -7,7 +7,6 @@ const freeQByteArray = @import("./freeQByteArray.zig").freeQByteArray;
const freeString = @import("./freeString.zig").freeString;
const freeUserType = @import("./freeUserType.zig").freeUserType;
pub fn freeQVariant(variant: QVariant, allocator: *std.mem.Allocator) void {
switch (variant) {
.Byte, .Int, .UInt, .Short, .QDateTime => {

View file

@ -4,7 +4,6 @@ const writeString = @import("./writeString.zig").writeString;
const writeUInt = @import("./writeUInt.zig").writeUInt;
const writeQVariant = @import("./writeQVariant.zig").writeQVariant;
pub fn writeQVariantMap(writer: anytype, allocator: *std.mem.Allocator, map: std.StringHashMap(QVariantType)) !void {
var data = std.ArrayList(u8).init(allocator);
defer data.deinit();