Added missing variadic arguments to traceLog() (#186)

* Added missing variadic arguments to `traceLog()`

* Made changes resillient to `generate_function.py`
This commit is contained in:
raugl 2025-01-06 18:26:37 +02:00 committed by GitHub
parent 57041e707c
commit 4e05ee5a3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 37 additions and 5 deletions

View File

@ -331,6 +331,7 @@ def parse_header(header_name: str, output_file: str, ext_file: str, prefix: str,
manual = [
"TextFormat",
"TraceLog",
"LoadShader",
"ExportDataAsCode",
"LoadFileData",

View File

@ -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;

View File

@ -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);