core tests passed
This commit is contained in:
parent
6618e20e31
commit
96cf0a50ea
|
|
@ -83,9 +83,8 @@ pub fn dumpTimeline(filename: []const u8) !void {
|
|||
|
||||
core.engine_log("1 {s}", .{filename});
|
||||
|
||||
var obuf = std.ArrayList(u8).init(timeline.timelineAllocator);
|
||||
defer obuf.deinit();
|
||||
var writer = obuf.writer();
|
||||
var obuf = std.ArrayList(u8){};
|
||||
defer obuf.deinit(timeline.timelineAllocator);
|
||||
|
||||
var i: usize = 0;
|
||||
|
||||
|
|
@ -93,20 +92,20 @@ pub fn dumpTimeline(filename: []const u8) !void {
|
|||
const event = timeline.events.get(i);
|
||||
const timestamp = timeline.timestamps.get(i);
|
||||
|
||||
try writer.print("{d}: callstack: {x} @0x{x} ", .{
|
||||
try obuf.print(timeline.timelineAllocator, "{d}: callstack: {x} @0x{x} ", .{
|
||||
timestamp.*,
|
||||
event.callstackId,
|
||||
event.address,
|
||||
});
|
||||
switch (event.event) {
|
||||
.alloc => |x| {
|
||||
try writer.print("alloc {d} bytes\n", .{x.size});
|
||||
try obuf.print(timeline.timelineAllocator, "alloc {d} bytes\n", .{x.size});
|
||||
},
|
||||
.free => |x| {
|
||||
try writer.print("free {d} bytes\n", .{x.size});
|
||||
try obuf.print(timeline.timelineAllocator, "free {d} bytes\n", .{x.size});
|
||||
},
|
||||
.resize => |x| {
|
||||
try writer.print("resize {d} -> {d} bytes\n", .{ x.oldSize, x.newSize });
|
||||
try obuf.print(timeline.timelineAllocator, "resize {d} -> {d} bytes\n", .{ x.oldSize, x.newSize });
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -114,12 +113,12 @@ pub fn dumpTimeline(filename: []const u8) !void {
|
|||
while (iter.next()) |x| {
|
||||
const callstackId = x.key_ptr.*;
|
||||
const stack = x.value_ptr.*;
|
||||
try writer.print("{x}:\n", .{callstackId});
|
||||
try obuf.print(timeline.timelineAllocator, "{x}:\n", .{callstackId});
|
||||
for (stack.debugStr) |frame| {
|
||||
if (frame) |f| {
|
||||
try writer.print("{s}\n", .{f});
|
||||
try obuf.print(timeline.timelineAllocator, "{s}\n", .{f});
|
||||
} else {
|
||||
try writer.print("no file\n", .{});
|
||||
try obuf.print(timeline.timelineAllocator, "no file\n", .{});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -187,7 +186,7 @@ pub fn allocator(self: *@This()) std.mem.Allocator {
|
|||
}
|
||||
|
||||
pub fn alloc(ctx: *anyopaque, len: usize, ptr_align: std.mem.Alignment, ret_addr: usize) ?[*]u8 {
|
||||
var self: *@This() = @alignCast(@ptrCast(ctx));
|
||||
var self: *@This() = @ptrCast(@alignCast(ctx));
|
||||
const rv = self.backingAllocator.vtable.alloc(self.backingAllocator.ptr, len, ptr_align, ret_addr);
|
||||
|
||||
{
|
||||
|
|
@ -213,7 +212,7 @@ pub fn alloc(ctx: *anyopaque, len: usize, ptr_align: std.mem.Alignment, ret_addr
|
|||
}
|
||||
|
||||
pub fn resize(ctx: *anyopaque, buf: []u8, buf_align: std.mem.Alignment, new_len: usize, ret_addr: usize) bool {
|
||||
var self: *@This() = @alignCast(@ptrCast(ctx));
|
||||
var self: *@This() = @ptrCast(@alignCast(ctx));
|
||||
{
|
||||
self.lock.lock();
|
||||
defer self.lock.unlock();
|
||||
|
|
@ -235,7 +234,7 @@ pub fn resize(ctx: *anyopaque, buf: []u8, buf_align: std.mem.Alignment, new_len:
|
|||
}
|
||||
|
||||
pub fn free(ctx: *anyopaque, buf: []u8, buf_align: std.mem.Alignment, ret_addr: usize) void {
|
||||
var self: *@This() = @alignCast(@ptrCast(ctx));
|
||||
var self: *@This() = @ptrCast(@alignCast(ctx));
|
||||
{
|
||||
self.lock.lock();
|
||||
defer self.lock.unlock();
|
||||
|
|
|
|||
|
|
@ -72,11 +72,11 @@ pub fn start() !void {
|
|||
pub fn shutdown() void {}
|
||||
|
||||
pub fn addCommand(funcName: []const u8, func: ConsoleFunc) !void {
|
||||
try getConsole.addConsoleCommand(funcName, func);
|
||||
try getConsole().addConsoleCommand(funcName, func);
|
||||
}
|
||||
|
||||
pub fn evaluate(cmd: []const u8) void {
|
||||
getConsole.eval(cmd);
|
||||
getConsole().eval(cmd);
|
||||
}
|
||||
|
||||
const core = @import("core.zig");
|
||||
|
|
|
|||
|
|
@ -28,7 +28,20 @@ pub const debugLine = debug_draw.debugLine;
|
|||
pub const misc = @import("misc.zig");
|
||||
pub const engineTime = @import("engineTime.zig");
|
||||
pub const engineObject = @import("engineObject.zig");
|
||||
pub const EngineObjectVTable = engineObject.EngineObjectVTable;
|
||||
pub const MakeTypeName = engineObject.MakeTypeName;
|
||||
pub const PatchStruct = engineObject.PatchStruct;
|
||||
pub const InterfaceRef = engineObject.InterfaceRef;
|
||||
pub const updateEngineVTable = engineObject.updateEngineVTable;
|
||||
pub const EngineDataEventError = engineObject.EngineDataEventError;
|
||||
pub const EngineObjectDelegate = engineObject.EngineObjectDelegate;
|
||||
pub const FieldInfo = engineObject.FieldInfo;
|
||||
|
||||
pub const jobs = @import("jobs.zig");
|
||||
pub const JobContext = jobs.JobContext;
|
||||
pub const JobManager = jobs.JobManager;
|
||||
pub const JobWorker = jobs.JobWorker;
|
||||
|
||||
pub const file_utils = @import("file_utils.zig");
|
||||
pub const string_utils = @import("string_utils.zig");
|
||||
pub const type_utils = @import("type_utils.zig");
|
||||
|
|
@ -44,17 +57,56 @@ pub const zm = @import("zmath");
|
|||
|
||||
pub const p2 = @import("p2");
|
||||
pub const assert = p2.assert;
|
||||
pub const asserts = p2.asserts;
|
||||
pub const assertf = p2.assertf;
|
||||
pub const stringStrip = p2.stringStrip;
|
||||
|
||||
pub const names = p2.names;
|
||||
pub const BumpArena = p2.BumpArena;
|
||||
pub const ObjectHandle = p2.ObjectHandle;
|
||||
pub const SparseSet = p2.SparseSet;
|
||||
pub const RingQueue = p2.RingQueue;
|
||||
pub const RingQueueU = p2.RingQueueU;
|
||||
pub const ConcurrentQueueU = p2.ConcurrentQueueU;
|
||||
pub const Name = p2.Name;
|
||||
pub const StaticVector = p2.StaticVector;
|
||||
|
||||
pub const SparseSet = p2.SparseSet;
|
||||
pub const SparseMap = p2.SparseMap;
|
||||
pub const SparseMultiSet = p2.SparseMultiSet;
|
||||
pub const SparseSetAdvanced = p2.SparseSetAdvanced;
|
||||
pub const SparseMultiSetAdvanced = p2.SparseMultiSetAdvanced;
|
||||
pub const SetHandle = p2.SetHandle;
|
||||
|
||||
pub const EcsContainerInterface = p2.EcsContainerInterface;
|
||||
pub const IndexPoolHandle = p2.IndexPoolHandle;
|
||||
pub const PagedVector = p2.PagedVector;
|
||||
pub const IndexPool = p2.IndexPool;
|
||||
pub const MakeName = p2.MakeName;
|
||||
pub const DefineName = p2.DefineName;
|
||||
pub const createNameRegistry = p2.createNameRegistry;
|
||||
pub const destroyNameRegistry = p2.destroyNameRegistry;
|
||||
pub const setNameRegistry = p2.setNameRegistry;
|
||||
pub const NameRegistry = p2.NameRegistry;
|
||||
|
||||
pub const MergedSpans = p2.MergedSpans;
|
||||
pub const Span = p2.Span;
|
||||
pub const shell = p2.shell;
|
||||
|
||||
pub const algorithm = @import("p2");
|
||||
pub const math = @import("math.zig");
|
||||
pub const Mat = math.Mat;
|
||||
pub const Transform = math.Transform;
|
||||
pub const Quat = math.Quat;
|
||||
pub const Vectorf = math.Vectorf;
|
||||
pub const Vector = math.Vector;
|
||||
pub const Vector4 = math.Vector4;
|
||||
pub const Vector4f = math.Vector4f;
|
||||
pub const Vector2 = math.Vector2;
|
||||
pub const Vector2c = math.Vector2c;
|
||||
pub const Vector2u = math.Vector2u;
|
||||
pub const Vector2f = math.Vector2f;
|
||||
pub const Rotation = math.Rotation;
|
||||
|
||||
pub const launchArgs = @import("args.zig");
|
||||
|
||||
pub const panickers = @import("panickers.zig");
|
||||
|
|
@ -70,12 +122,21 @@ pub const MemoryTracker = @import("MemoryTracker.zig");
|
|||
|
||||
pub const DefaultSavePath = "Saved";
|
||||
|
||||
const logging = @import("logging.zig");
|
||||
pub const logging = @import("logging.zig");
|
||||
pub const LoggerSys = logging.LoggerSys;
|
||||
|
||||
const c = @This();
|
||||
pub const getLogger = logging.getLogger;
|
||||
|
||||
pub const console_log = logging.console_log;
|
||||
pub const console_logs = logging.console_logs;
|
||||
|
||||
pub const engine_logs = logging.engine_logs;
|
||||
pub const engine_log = logging.engine_log;
|
||||
|
||||
pub const engine_err = logging.engine_err;
|
||||
pub const engine_errs = logging.engine_errs;
|
||||
|
||||
pub const packer = @import("packer");
|
||||
|
||||
pub const FileSystem = packer.PackerFS;
|
||||
|
|
@ -116,6 +177,7 @@ pub const ModuleLoaderArgs = externModule.ModuleLoaderArgs;
|
|||
|
||||
pub const ecs = @import("ecs.zig");
|
||||
pub const Entity = ecs.Entity;
|
||||
pub const createEntity = ecs.createEntity;
|
||||
|
||||
// pub const script = @import("script.zig");
|
||||
|
||||
|
|
@ -338,7 +400,7 @@ pub fn addEngineDelegateBinding(comptime event: []const u8, func: anytype, ctx:
|
|||
return handle;
|
||||
}
|
||||
|
||||
const getEngineTime = @import("engineTime.zig").getEngineTime;
|
||||
pub const getEngineTime = @import("engineTime.zig").getEngineTime;
|
||||
|
||||
pub fn getEngineUptime() f64 {
|
||||
return getEngineTime() - gEngine.engineStartTime;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ pub const ModuleLoaderArgs = extern struct {
|
|||
packerFS: *core.PackerFS,
|
||||
// luaState: *anyopaque,
|
||||
// luaAllocator: *anyopaque,
|
||||
debugDrawInterface: *debug.DebugDrawInterface,
|
||||
debugDrawInterface: ?*debug.DebugDrawInterface,
|
||||
};
|
||||
|
||||
pub const LoadedModule = struct {
|
||||
|
|
@ -225,7 +225,7 @@ pub fn getModuleLoaderArgs(first: bool) ModuleLoaderArgs {
|
|||
.packerFS = core.fs(),
|
||||
// .luaState = @ptrCast(core.script.gLuaState.l),
|
||||
// .luaAllocator = &core.script.gLuaAllocator,
|
||||
.debugDrawInterface = debug.gDebugDrawInterface.?,
|
||||
.debugDrawInterface = debug.gDebugDrawInterface,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
const std = @import("std");
|
||||
const core = @import("core.zig");
|
||||
const tracy = @import("tracy");
|
||||
const tracy = @import("tracy").t;
|
||||
|
||||
const builtin = @import("builtin");
|
||||
const slow_logging = core.BuildOption("slow_logging");
|
||||
|
|
@ -13,16 +13,17 @@ var gLoggerSys: ?*LoggerSys = null;
|
|||
pub const LogBuffer = struct {
|
||||
lock: std.Thread.Mutex = .{},
|
||||
buffer: std.ArrayList(u8),
|
||||
allocator: std.mem.Allocator,
|
||||
|
||||
pub fn init(allocator: std.mem.Allocator) @This() {
|
||||
return .{
|
||||
.buffer = std.ArrayList(u8).init(allocator),
|
||||
.allocator = allocator,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn lockWriter(self: *@This()) std.ArrayList(u8).Writer {
|
||||
pub fn lockWriter(self: *@This()) void {
|
||||
self.lock.lock();
|
||||
return self.buffer.writer();
|
||||
}
|
||||
|
||||
pub fn unlock(self: *@This()) void {
|
||||
|
|
@ -31,8 +32,8 @@ pub const LogBuffer = struct {
|
|||
|
||||
pub fn deinit(self: *@This()) void {
|
||||
self.lock.lock();
|
||||
self.lock.unlock();
|
||||
self.buffer.deinit();
|
||||
defer self.lock.unlock();
|
||||
self.buffer.deinit(self.allocator);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -245,7 +246,7 @@ pub const LoggerSys = struct {
|
|||
|
||||
pub fn flushWriteBuffer(self: *@This()) !void {
|
||||
self.lock.lock();
|
||||
try self.logFile.writer().writeAll(self.writeOutBuffer.items);
|
||||
try self.logFile.writeAll(self.writeOutBuffer.items);
|
||||
if (builtin.is_test) {
|
||||
std.debug.print("{s}", .{self.flushBuffer.items});
|
||||
} else {
|
||||
|
|
@ -257,7 +258,7 @@ pub const LoggerSys = struct {
|
|||
|
||||
pub fn flushFromJob(self: *@This()) !void {
|
||||
self.lock.lock();
|
||||
try self.logFile.writer().writeAll(self.flushBuffer.items);
|
||||
try self.logFile.writeAll(self.flushBuffer.items);
|
||||
if (builtin.is_test) {
|
||||
std.debug.print("{s}", .{self.flushBuffer.items});
|
||||
} else {
|
||||
|
|
@ -272,16 +273,19 @@ pub const LoggerSys = struct {
|
|||
var slice: [4096]u8 = undefined;
|
||||
pub fn print(self: *@This(), highlight: core.colors.Color, comptime fmt: []const u8, args: anytype) !void {
|
||||
self.lock.lock();
|
||||
try self.writeOutBuffer.writer().print(fmt, args);
|
||||
try self.writeOutBuffer.print(self.allocator, fmt, args);
|
||||
self.lock.unlock();
|
||||
|
||||
blk: {
|
||||
if (self.sessionBuffer != null and !core.getEngine().isShuttingDown()) {
|
||||
self.sessionBuffer.?.lockWriter().print(fmt, args) catch {
|
||||
self.sessionBuffer.?.unlock();
|
||||
if (self.sessionBuffer) |sb| {
|
||||
sb.lockWriter();
|
||||
sb.buffer.print(sb.allocator, fmt, args) catch {
|
||||
sb.unlock();
|
||||
break :blk;
|
||||
};
|
||||
self.sessionBuffer.?.unlock();
|
||||
sb.unlock();
|
||||
}
|
||||
|
||||
const s = std.fmt.bufPrint(&slice, fmt, args) catch {
|
||||
break :blk;
|
||||
|
|
@ -311,7 +315,7 @@ pub const LoggerSys = struct {
|
|||
.flushBuffer = std.ArrayList(u8).initCapacity(allocator, LogBufferSize) catch unreachable,
|
||||
.logFilePath = ofile,
|
||||
.logFile = cwd.createFile(ofile, .{}) catch unreachable,
|
||||
.consoleFile = std.io.getStdOut(),
|
||||
.consoleFile = std.fs.File.stdout(),
|
||||
};
|
||||
|
||||
return self;
|
||||
|
|
@ -322,8 +326,8 @@ pub const LoggerSys = struct {
|
|||
self.allocator.free(self.logFilePath);
|
||||
self.logFile.close();
|
||||
|
||||
self.writeOutBuffer.deinit();
|
||||
self.flushBuffer.deinit();
|
||||
self.writeOutBuffer.deinit(self.allocator);
|
||||
self.flushBuffer.deinit(self.allocator);
|
||||
|
||||
self.allocator.destroy(self);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
var gAllocator: std.mem.Allocator = undefined;
|
||||
|
||||
pub export fn startup(p_allocator: *anyopaque, args: ?*anyopaque) bool {
|
||||
pub export fn startup_module(p_allocator: *anyopaque, args: ?*anyopaque) bool {
|
||||
_ = args;
|
||||
|
||||
gAllocator = @as(*std.mem.Allocator, @ptrCast(@alignCast(p_allocator))).*;
|
||||
|
|
@ -15,6 +15,6 @@ pub export fn startup(p_allocator: *anyopaque, args: ?*anyopaque) bool {
|
|||
return true;
|
||||
}
|
||||
|
||||
pub export fn shutdown() void {}
|
||||
pub export fn shutdown_module() void {}
|
||||
|
||||
const std = @import("std");
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ pub const loadFileAlloc = utils.loadFileAlloc;
|
|||
const ArrayList = std.ArrayList;
|
||||
const ArrayListUnmanaged = std.ArrayListUnmanaged;
|
||||
pub const interface = @import("structures/interface.zig");
|
||||
pub const MakeInterface = interface.MakeInterface;
|
||||
pub const Reference = interface.Reference;
|
||||
pub const refFromPtr = interface.refFromPtr;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue