fix: incorrect typing

This commit is contained in:
LordMZTE 2022-07-18 17:32:43 +02:00
parent 1ebe62869b
commit 53c4751f31
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6

View file

@ -11,12 +11,11 @@ pub fn log(
/// The length of the buffer used for the formatted output. /// The length of the buffer used for the formatted output.
/// This is the maximum length of log messages. /// This is the maximum length of log messages.
comptime buf_size: usize, comptime buf_size: usize,
) fn ( ) @TypeOf(LogStruct(c, module_name, buf_size).log) {
comptime std.log.Level, return LogStruct(c, module_name, buf_size).log;
comptime @TypeOf(.EnumLiteral), }
comptime format: []const u8,
anytype, fn LogStruct(c: anytype, comptime module_name: []const u8, comptime buf_size: usize) type {
) void {
return struct { return struct {
pub fn log( pub fn log(
comptime level: std.log.Level, comptime level: std.log.Level,
@ -44,7 +43,14 @@ pub fn log(
var fields = [_]c.GLogField{ var fields = [_]c.GLogField{
c.GLogField{ c.GLogField{
.key = "GLIB_DOMAIN", .key = "GLIB_DOMAIN",
.value = module_name ++ "-" ++ @tagName(scope), .value = @ptrCast(
*const anyopaque,
// don't include scope name if not explicitly specified
if (std.mem.eql(u8, @tagName(scope), "default"))
module_name
else
module_name ++ "-" ++ @tagName(scope),
),
.length = -1, .length = -1,
}, },
c.GLogField{ c.GLogField{
@ -60,10 +66,5 @@ pub fn log(
fields.len, fields.len,
); );
} }
}.log; };
} }
export fn add(a: i32, b: i32) i32 {
return a + b;
}