enum_to_string fix; enum count, min_value, max_value

This commit is contained in:
Ginger Bill
2016-09-19 22:26:07 +01:00
parent 9561dc33ce
commit 3b266b194f
14 changed files with 174 additions and 77 deletions
+24 -4
View File
@@ -437,10 +437,30 @@ print_any_to_buffer :: proc(buf: ^[]byte, arg: any) {
print_pointer_to_buffer(buf, v)
case Enum:
v: any
v.data = arg.data
v.type_info = info.base
print_any_to_buffer(buf, v)
value: i64 = 0
match type i : info.base {
case Integer:
if i.signed {
if arg.data != null {
match i.size {
case 1: value = (arg.data as ^i8)^ as i64
case 2: value = (arg.data as ^i16)^ as i64
case 4: value = (arg.data as ^i32)^ as i64
case 8: value = (arg.data as ^i64)^ as i64
}
}
} else {
if arg.data != null {
match i.size {
case 1: value = (arg.data as ^u8)^ as i64
case 2: value = (arg.data as ^u16)^ as i64
case 4: value = (arg.data as ^u32)^ as i64
case 8: value = (arg.data as ^u64)^ as i64
}
}
}
}
print_string_to_buffer(buf, __enum_to_string(arg.type_info, value))
case Array:
-1
View File
@@ -354,7 +354,6 @@ __enum_to_string :: proc(info: ^Type_Info, value: i64) -> string {
match type ti : info {
case Type_Info.Enum:
fmt.println("Here: ", ti.values.count)
for i := 0; i < ti.values.count; i++ {
if ti.values[i] == value {
return ti.names[i]