Some data struct now use file instead of = struct {

This commit is contained in:
Adrien Bouvais 2025-01-11 19:24:15 +01:00
parent 78213df3ff
commit ee9d5c92f2
3 changed files with 90 additions and 91 deletions

View File

@ -2,7 +2,8 @@ const std = @import("std");
const UUID = @import("dtype").UUID; const UUID = @import("dtype").UUID;
const ArenaAllocator = std.heap.ArenaAllocator; const ArenaAllocator = std.heap.ArenaAllocator;
pub const UUIDIndexMap = struct { pub const UUIDIndexMap = @This();
arena: *ArenaAllocator, arena: *ArenaAllocator,
map: *std.AutoHashMap(UUID, usize), map: *std.AutoHashMap(UUID, usize),
@ -44,7 +45,6 @@ pub const UUIDIndexMap = struct {
pub fn get(self: UUIDIndexMap, uuid: UUID) ?usize { pub fn get(self: UUIDIndexMap, uuid: UUID) ?usize {
return self.map.get(uuid); return self.map.get(uuid);
} }
};
test "Create empty UUIDIndexMap" { test "Create empty UUIDIndexMap" {
const allocator = std.testing.allocator; const allocator = std.testing.allocator;

View File

@ -9,7 +9,8 @@ const DataType = dtype.DataType;
const ZipponError = @import("errors.zig").ZipponError; const ZipponError = @import("errors.zig").ZipponError;
/// This is the [] part /// This is the [] part
pub const AdditionalData = struct { pub const AdditionalData = @This();
allocator: Allocator, allocator: Allocator,
limit: usize = 0, limit: usize = 0,
childrens: std.ArrayList(AdditionalDataMember), childrens: std.ArrayList(AdditionalDataMember),
@ -31,7 +32,6 @@ pub const AdditionalData = struct {
pub fn addMember(self: *AdditionalData, name: []const u8, index: usize) ZipponError!void { pub fn addMember(self: *AdditionalData, name: []const u8, index: usize) ZipponError!void {
self.childrens.append(AdditionalDataMember.init(self.allocator, name, index)) catch return ZipponError.MemoryError; self.childrens.append(AdditionalDataMember.init(self.allocator, name, index)) catch return ZipponError.MemoryError;
} }
};
// This is name in: [name] // This is name in: [name]
// There is an additional data because it can be [friend [1; name]] // There is an additional data because it can be [friend [1; name]]

View File

@ -28,7 +28,7 @@ pub const JsonString = struct {
init: bool = false, init: bool = false,
}; };
pub const RelationMap = struct { pub const RelationMap = @This();
struct_name: []const u8, struct_name: []const u8,
member_name: []const u8, member_name: []const u8,
additional_data: AdditionalData, additional_data: AdditionalData,
@ -72,4 +72,3 @@ pub const RelationMap = struct {
} }
return start; return start;
} }
};