diff --git a/lib/generate_functions.py b/lib/generate_functions.py index c027a14..c4d0c4f 100755 --- a/lib/generate_functions.py +++ b/lib/generate_functions.py @@ -331,6 +331,7 @@ def parse_header(header_name: str, output_file: str, ext_file: str, prefix: str, manual = [ "TextFormat", + "TraceLog", "LoadShader", "ExportDataAsCode", "LoadFileData", diff --git a/lib/preludes/raylib-prelude.zig b/lib/preludes/raylib-prelude.zig index b4ba784..cc6cfd2 100644 --- a/lib/preludes/raylib-prelude.zig +++ b/lib/preludes/raylib-prelude.zig @@ -2182,6 +2182,24 @@ pub fn textFormat(text: [*:0]const u8, args: anytype) [*:0]const u8 { return std.mem.span(@call(.auto, cdef.TextFormat, .{@as([*c]const u8, @ptrCast(text))} ++ args)); } +/// Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...) +pub fn traceLog(logLevel: TraceLogLevel, text: [*:0]const u8, args: anytype) void { + comptime { + const info = @typeInfo(@TypeOf(args)); + switch (info) { + .Struct => { + if (!info.Struct.is_tuple) + @compileError("Args should be in a tuple (call this function like traceLog(.{arg1, arg2, ...});)!"); + }, + else => { + @compileError("Args should be in a tuple (call this function like traceLog(.{arg1, arg2, ...});)!"); + }, + } + } + + @call(.auto, cdef.TraceLog, .{ logLevel, @as([*c]const u8, @ptrCast(text)) } ++ args); +} + /// Split text into multiple strings pub fn textSplit(text: [*:0]const u8, delimiter: u8) [][*:0]const u8 { var count: i32 = 0; diff --git a/lib/raylib.zig b/lib/raylib.zig index 62ee335..a539d48 100644 --- a/lib/raylib.zig +++ b/lib/raylib.zig @@ -2182,6 +2182,24 @@ pub fn textFormat(text: [*:0]const u8, args: anytype) [*:0]const u8 { return std.mem.span(@call(.auto, cdef.TextFormat, .{@as([*c]const u8, @ptrCast(text))} ++ args)); } +/// Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...) +pub fn traceLog(logLevel: TraceLogLevel, text: [*:0]const u8, args: anytype) void { + comptime { + const info = @typeInfo(@TypeOf(args)); + switch (info) { + .Struct => { + if (!info.Struct.is_tuple) + @compileError("Args should be in a tuple (call this function like traceLog(.{arg1, arg2, ...});)!"); + }, + else => { + @compileError("Args should be in a tuple (call this function like traceLog(.{arg1, arg2, ...});)!"); + }, + } + } + + @call(.auto, cdef.TraceLog, .{ logLevel, @as([*c]const u8, @ptrCast(text)) } ++ args); +} + /// Split text into multiple strings pub fn textSplit(text: [*:0]const u8, delimiter: u8) [][*:0]const u8 { var count: i32 = 0; @@ -2860,11 +2878,6 @@ pub fn openURL(url: [*:0]const u8) void { cdef.OpenURL(@as([*c]const u8, @ptrCast(url))); } -/// Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...) -pub fn traceLog(logLevel: TraceLogLevel, text: [*:0]const u8) void { - cdef.TraceLog(logLevel, @as([*c]const u8, @ptrCast(text))); -} - /// Set the current threshold (minimum) log level pub fn setTraceLogLevel(logLevel: TraceLogLevel) void { cdef.SetTraceLogLevel(logLevel);