diff --git a/sysdata/libraries/stn/src/fmt.hb b/sysdata/libraries/stn/src/fmt.hb index eaa6b8c6..3adc1dd5 100644 --- a/sysdata/libraries/stn/src/fmt.hb +++ b/sysdata/libraries/stn/src/fmt.hb @@ -149,14 +149,13 @@ fmt_nullable := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint { fmt_enum := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint { T := @TypeOf(v) - // len := @len(@nameof(T)); - // *@as(^[u8; @len(@nameof(T))], @bitcast(str)) = *@bitcast(@nameof(T)); - // *@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(".(\0") - // len += 2 - // len += @inline(fmt_int, @as(usize(T), @bitcast(v)), str + len, 10); - // *@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(".)\0") - // return len + 2 - return fmt_int(@as(usize(T), @bitcast(v)), str, 10) + len := @len(@nameof(T)); + *@as(^[u8; @len(@nameof(T))], @bitcast(str)) = *@bitcast(@nameof(T)); + *@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(".(\0") + len += 2 + len += @inline(fmt_int, @as(usize(T), @bitcast(v)), str + len, 10); + *@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(".)\0") + return len + 2 } /* SAFETY: diff --git a/sysdata/libraries/stn/src/log.hb b/sysdata/libraries/stn/src/log.hb index 67a95b41..8420e79d 100644 --- a/sysdata/libraries/stn/src/log.hb +++ b/sysdata/libraries/stn/src/log.hb @@ -24,7 +24,7 @@ print_buffer := memory.dangling(u8) print := fn(v: @Any(), opts: fmt.FormatOptions): void { if @TypeOf(v) == ^u8 { - info(v) + @inline(log, opts.log, v) return } if print_buffer == memory.dangling(u8) { diff --git a/sysdata/programs/test/src/tests/stn/fmt.hb b/sysdata/programs/test/src/tests/stn/fmt.hb index cfb29379..02ff093f 100644 --- a/sysdata/programs/test/src/tests/stn/fmt.hb +++ b/sysdata/programs/test/src/tests/stn/fmt.hb @@ -12,9 +12,15 @@ SubThingy := struct { b: bool, } +OtherThingy := enum { + TheOther, + TheOtherer, +} + test := fn(): uint { log.print("Hello, World!\0", .{log: .Error}) - log.print(Thingy.(-100, -100, .(-math.PI, true)), .{}) + log.print(OtherThingy.TheOther, .{}) + log.print(Thingy.(-100, -100, .(-math.PI, true)), .{log: .Warn}) log.print(SubThingy.(-math.E, false), .{}) log.print(Color.{r: 255, g: 254, b: 253, a: 252}, .{radix: 2}) log.print(@as(f64, math.LN_2), .{radix: 16, decimal_digits: 1 << 32})