forked from AbleOS/ableos
almost enums
This commit is contained in:
parent
d0bd3714ee
commit
d2cb73c2ce
|
@ -149,14 +149,13 @@ fmt_nullable := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint {
|
||||||
|
|
||||||
fmt_enum := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint {
|
fmt_enum := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint {
|
||||||
T := @TypeOf(v)
|
T := @TypeOf(v)
|
||||||
// len := @len(@nameof(T));
|
len := @len(@nameof(T));
|
||||||
// *@as(^[u8; @len(@nameof(T))], @bitcast(str)) = *@bitcast(@nameof(T));
|
*@as(^[u8; @len(@nameof(T))], @bitcast(str)) = *@bitcast(@nameof(T));
|
||||||
// *@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(".(\0")
|
*@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(".(\0")
|
||||||
// len += 2
|
len += 2
|
||||||
// len += @inline(fmt_int, @as(usize(T), @bitcast(v)), str + len, 10);
|
len += @inline(fmt_int, @as(usize(T), @bitcast(v)), str + len, 10);
|
||||||
// *@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(".)\0")
|
*@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(".)\0")
|
||||||
// return len + 2
|
return len + 2
|
||||||
return fmt_int(@as(usize(T), @bitcast(v)), str, 10)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SAFETY:
|
/* SAFETY:
|
||||||
|
|
|
@ -24,7 +24,7 @@ print_buffer := memory.dangling(u8)
|
||||||
|
|
||||||
print := fn(v: @Any(), opts: fmt.FormatOptions): void {
|
print := fn(v: @Any(), opts: fmt.FormatOptions): void {
|
||||||
if @TypeOf(v) == ^u8 {
|
if @TypeOf(v) == ^u8 {
|
||||||
info(v)
|
@inline(log, opts.log, v)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if print_buffer == memory.dangling(u8) {
|
if print_buffer == memory.dangling(u8) {
|
||||||
|
|
|
@ -12,9 +12,15 @@ SubThingy := struct {
|
||||||
b: bool,
|
b: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OtherThingy := enum {
|
||||||
|
TheOther,
|
||||||
|
TheOtherer,
|
||||||
|
}
|
||||||
|
|
||||||
test := fn(): uint {
|
test := fn(): uint {
|
||||||
log.print("Hello, World!\0", .{log: .Error})
|
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(SubThingy.(-math.E, false), .{})
|
||||||
log.print(Color.{r: 255, g: 254, b: 253, a: 252}, .{radix: 2})
|
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})
|
log.print(@as(f64, math.LN_2), .{radix: 16, decimal_digits: 1 << 32})
|
||||||
|
|
Loading…
Reference in a new issue