port to latest jai version

This commit is contained in:
Tuomas Katajisto 2025-12-16 17:59:55 +02:00
parent e2da734dcd
commit 0bb4cffbd6
10 changed files with 40 additions and 40 deletions

View File

@ -152,7 +152,7 @@ Iprof :: #import "Iprof"(IMPORT_MODE = .METAPROGRAM);
root_opts := get_build_options(); root_opts := get_build_options();
w := compiler_create_workspace("Target"); w := compiler_create_workspace("Target");
opts := get_build_options(w); opts := get_build_options(w);
copy_commonly_propagated_fields(*opts, *root_opts); copy_commonly_propagated_fields(opts, *root_opts);
opts.cpu_target = root_opts.cpu_target; opts.cpu_target = root_opts.cpu_target;
opts.os_target = root_opts.os_target; opts.os_target = root_opts.os_target;

View File

@ -203,7 +203,7 @@ DONE
get :: (json_val: JSON_Value, key: string, expected_type: JSON_Type) -> JSON_Value { get :: (json_val: JSON_Value, key: string, expected_type: JSON_Type) -> JSON_Value {
assert(json_val.type == .OBJECT); assert(json_val.type == .OBJECT);
table := json_val.object; table := json_val.object;
success, val := Hash_Table.table_find_new(table, key); success, val := Hash_Table.table_find(table, key);
assert(success); assert(success);
assert(val.type == expected_type); assert(val.type == expected_type);
return val; return val;
@ -212,7 +212,7 @@ DONE
// Check for version number that may or may not exist // Check for version number that may or may not exist
version: float64 = -1; version: float64 = -1;
assert(root.type == .OBJECT); assert(root.type == .OBJECT);
success2, val := Hash_Table.table_find_new(root.object, "version"); success2, val := Hash_Table.table_find(root.object, "version");
if success2 { if success2 {
if val.type == .NUMBER { if val.type == .NUMBER {
version = val.number; version = val.number;

View File

@ -83,7 +83,7 @@ print_val :: (using val: JSON_Value) {
for array print_val(it); for array print_val(it);
print("]"); print("]");
case .OBJECT; case .OBJECT;
print("%", <<object); print("%", (.*)object);
} }
} }
@ -166,7 +166,7 @@ json_write_json_value :: (builder: *String_Builder, using val: JSON_Value, inden
keys: [..] string; keys: [..] string;
defer array_free(keys); defer array_free(keys);
array_reserve(*keys, obj.count); array_reserve(*keys, obj.count);
for v, k: <<obj { for v, k: (.*)obj {
array_add(*keys, k); array_add(*keys, k);
} }
intro_sort(keys, compare); intro_sort(keys, compare);
@ -177,7 +177,7 @@ json_write_json_value :: (builder: *String_Builder, using val: JSON_Value, inden
} }
json_append_escaped(builder, it); json_append_escaped(builder, it);
append(builder, ": "); append(builder, ": ");
found, v := table_find_new(obj, it); found, v := table_find(obj, it);
assert(found, "Missing table value %", it); assert(found, "Missing table value %", it);
json_write_json_value(builder, v, indent_char, level + 1); json_write_json_value(builder, v, indent_char, level + 1);
if it_index != obj.count - 1 append(builder, ","); if it_index != obj.count - 1 append(builder, ",");
@ -202,7 +202,7 @@ json_set :: (obj: *JSON_Object, path: string, val: JSON_Value) -> bool {
if !next.count return false; if !next.count return false;
if !remainder.count return false; if !remainder.count return false;
success, next_value := table_find_new(obj, next); success, next_value := table_find(obj, next);
next_obj: *JSON_Object; next_obj: *JSON_Object;
if success { if success {
if next_value.type != JSON_Type.OBJECT return false; if next_value.type != JSON_Type.OBJECT return false;
@ -242,7 +242,7 @@ get_as :: (val: JSON_Value, $T: Type) -> T {
} else if T == JSON_Object { } else if T == JSON_Object {
return #string END return #string END
assert(val.type == .OBJECT, "Expected a % but got %", T, val.type); assert(val.type == .OBJECT, "Expected a % but got %", T, val.type);
return <<val.object; return (.*)val.object;
END; END;
} else { } else {
compiler_report("Unsupported type"); compiler_report("Unsupported type");
@ -283,7 +283,7 @@ parse_value :: (to_parse: string) -> JSON_Value, remainder: string, success: boo
result.array, remainder, success = parse_array(remainder); result.array, remainder, success = parse_array(remainder);
case #char "{"; case #char "{";
obj := cast(*JSON_Object) alloc(size_of(JSON_Object)); obj := cast(*JSON_Object) alloc(size_of(JSON_Object));
<<obj, remainder, success = parse_object(remainder); (.*)obj, remainder, success = parse_object(remainder);
result = json_value(obj); result = json_value(obj);
case; case;
result.type = JSON_Type.NUMBER; result.type = JSON_Type.NUMBER;

View File

@ -39,7 +39,7 @@ json_parse_file :: (filename: string, $T: Type, ignore_unknown := true, rename :
json_write_native :: (builder: *String_Builder, data: *void, info: *Type_Info, indent_char := "\t", ignore := ignore_by_note, rename := rename_by_note, level := 0) { json_write_native :: (builder: *String_Builder, data: *void, info: *Type_Info, indent_char := "\t", ignore := ignore_by_note, rename := rename_by_note, level := 0) {
if info.type == { if info.type == {
case .BOOL; case .BOOL;
append(builder, ifx <<(cast(*bool) data) "true" else "false"); append(builder, ifx (.*)(cast(*bool) data) "true" else "false");
case .INTEGER; #through; case .INTEGER; #through;
case .FLOAT; case .FLOAT;
any_val: Any; any_val: Any;
@ -55,7 +55,7 @@ json_write_native :: (builder: *String_Builder, data: *void, info: *Type_Info, i
print_item_to_builder(builder, any_val); print_item_to_builder(builder, any_val);
append(builder, #char "\""); append(builder, #char "\"");
case .STRING; case .STRING;
json_append_escaped(builder, <<(cast(*string) data)); json_append_escaped(builder, (.*)(cast(*string) data));
case .ARRAY; case .ARRAY;
info_array := cast(*Type_Info_Array) info; info_array := cast(*Type_Info_Array) info;
element_size := info_array.element_type.runtime_size; element_size := info_array.element_type.runtime_size;
@ -65,10 +65,10 @@ json_write_native :: (builder: *String_Builder, data: *void, info: *Type_Info, i
array_data := data; array_data := data;
array_count := info_array.array_count; array_count := info_array.array_count;
if info_array.array_count == -1 { if info_array.array_count == -1 {
array_count = << cast(*s64) data; array_count = (.*) cast(*s64) data;
array_dest: **void = data + 8; array_dest: **void = data + 8;
array_data = << array_dest; array_data = (.*) array_dest;
} }
append(builder, "["); append(builder, "[");
@ -92,7 +92,7 @@ json_write_native :: (builder: *String_Builder, data: *void, info: *Type_Info, i
struct_info := cast(*Type_Info_Struct) info; struct_info := cast(*Type_Info_Struct) info;
if is_generic_json_value(info) { if is_generic_json_value(info) {
value := cast(*JSON_Value) data; value := cast(*JSON_Value) data;
json_write_json_value(builder, <<value, indent_char, level); json_write_json_value(builder, (.*)value, indent_char, level);
} else { } else {
append(builder, #char "{"); append(builder, #char "{");
first := true; first := true;
@ -105,7 +105,7 @@ json_write_native :: (builder: *String_Builder, data: *void, info: *Type_Info, i
} }
case .POINTER; case .POINTER;
ptr_info := cast(*Type_Info_Pointer) info; ptr_info := cast(*Type_Info_Pointer) info;
ptr := << cast(**void) data; ptr := (.*) cast(**void) data;
if ptr { if ptr {
json_write_native(builder, ptr, ptr_info.pointer_to, indent_char, ignore, rename, level); json_write_native(builder, ptr, ptr_info.pointer_to, indent_char, ignore, rename, level);
} else { } else {
@ -126,8 +126,8 @@ json_write_native_members :: (builder: *String_Builder, data: *void, members: []
info := cast(*Type_Info_Struct) member.type; info := cast(*Type_Info_Struct) member.type;
json_write_native_members(builder, data + member.offset_in_bytes, info.members, indent_char, ignore, rename, level, first); json_write_native_members(builder, data + member.offset_in_bytes, info.members, indent_char, ignore, rename, level, first);
} else { } else {
if !<<first append(builder, ","); if !(.*)first append(builder, ",");
<<first = false; (.*)first = false;
if indent_char.count { if indent_char.count {
append(builder, "\n"); append(builder, "\n");
@ -198,7 +198,7 @@ parse_value :: (to_parse: string, slot: *u8, info: *Type_Info, ignore_unknown: b
} else { } else {
memset(value_slot, 0, value_info.runtime_size); memset(value_slot, 0, value_info.runtime_size);
} }
<<cast(**u8)slot = value_slot; (.*)cast(**u8)slot = value_slot;
return value_slot, true, is_generic, value_info; return value_slot, true, is_generic, value_info;
} else { } else {
return slot, true, is_generic, value_info; return slot, true, is_generic, value_info;
@ -212,7 +212,7 @@ parse_value :: (to_parse: string, slot: *u8, info: *Type_Info, ignore_unknown: b
if !success return remainder, false; if !success return remainder, false;
if slot { if slot {
if info.type == .POINTER { if info.type == .POINTER {
<<cast(**void) slot = null; (.*)cast(**void) slot = null;
} else { } else {
builder: String_Builder; builder: String_Builder;
print_type_to_builder(*builder, info); print_type_to_builder(*builder, info);
@ -231,7 +231,7 @@ parse_value :: (to_parse: string, slot: *u8, info: *Type_Info, ignore_unknown: b
if is_generic { if is_generic {
json_set(cast(*JSON_Value)value_slot, true); json_set(cast(*JSON_Value)value_slot, true);
} else { } else {
<<cast(*bool)value_slot = true; (.*)cast(*bool)value_slot = true;
} }
} }
} }
@ -245,7 +245,7 @@ parse_value :: (to_parse: string, slot: *u8, info: *Type_Info, ignore_unknown: b
if is_generic { if is_generic {
json_set(cast(*JSON_Value)value_slot, false); json_set(cast(*JSON_Value)value_slot, false);
} else { } else {
<<cast(*bool)value_slot = false; (.*)cast(*bool)value_slot = false;
} }
} }
} }
@ -267,7 +267,7 @@ parse_value :: (to_parse: string, slot: *u8, info: *Type_Info, ignore_unknown: b
if is_generic { if is_generic {
json_set(cast(*JSON_Value)value_slot, value); json_set(cast(*JSON_Value)value_slot, value);
} else { } else {
<<cast(*string)value_slot = value; (.*)cast(*string)value_slot = value;
} }
stored = true; stored = true;
} }
@ -297,7 +297,7 @@ parse_value :: (to_parse: string, slot: *u8, info: *Type_Info, ignore_unknown: b
if success { if success {
if is_generic { if is_generic {
value := New(JSON_Object); value := New(JSON_Object);
<<value, remainder, success = parse_object(remainder); (.*)value, remainder, success = parse_object(remainder);
json_set(cast(*JSON_Value)value_slot, value); json_set(cast(*JSON_Value)value_slot, value);
} else { } else {
remainder, success = parse_object(remainder, value_slot, cast(*Type_Info_Struct) value_info, ignore_unknown, rename=rename); remainder, success = parse_object(remainder, value_slot, cast(*Type_Info_Struct) value_info, ignore_unknown, rename=rename);
@ -316,10 +316,10 @@ parse_value :: (to_parse: string, slot: *u8, info: *Type_Info, ignore_unknown: b
json_set(cast(*JSON_Value)value_slot, float_value); json_set(cast(*JSON_Value)value_slot, float_value);
} else { } else {
if value_info.runtime_size == 4 { if value_info.runtime_size == 4 {
(<< cast(*float) slot) = cast(float) float_value; ((.*) cast(*float) slot) = cast(float) float_value;
} else { } else {
assert(value_info.runtime_size == 8); assert(value_info.runtime_size == 8);
(<< cast(*float64) slot) = float_value; ((.*) cast(*float64) slot) = float_value;
} }
} }
} }
@ -481,7 +481,7 @@ parse_array :: (str: string, slot: *u8, info: *Type_Info_Array, ignore_unknown:
view.data = array.data; view.data = array.data;
} else if info.array_count == -1 { } else if info.array_count == -1 {
// Resizable array // Resizable array
<<(cast(*Resizable_Array) slot) = array; (.*)(cast(*Resizable_Array) slot) = array;
} else { } else {
// Fixed-size array // Fixed-size array
if (info.array_count != array.count) { if (info.array_count != array.count) {
@ -519,7 +519,7 @@ fill_member_table :: (table: *Table(string, Member_Offset), info: *Type_Info_Str
for * member: info.members { for * member: info.members {
offset := base_offset + member.offset_in_bytes; offset := base_offset + member.offset_in_bytes;
name := rename(member); name := rename(member);
assert(!table_find_pointer(table, name), "Redeclaration of member \"%\": % vs. %", name, <<member, <<table_find_pointer(table, name)); assert(!table_find_pointer(table, name), "Redeclaration of member \"%\": % vs. %", name, (.*)member, (.*)table_find_pointer(table, name));
table_set(table, name, .{member, offset}); table_set(table, name, .{member, offset});
if (member.flags & .USING) && (member.type.type == .STRUCT) { if (member.flags & .USING) && (member.type.type == .STRUCT) {
fill_member_table(table, cast(*Type_Info_Struct)member.type, rename, offset); fill_member_table(table, cast(*Type_Info_Struct)member.type, rename, offset);
@ -554,7 +554,7 @@ parse_object :: (str: string, slot: *u8, info: *Type_Info_Struct, ignore_unknown
if !success return remainder, false; if !success return remainder, false;
defer free(key); defer free(key);
member_found, member_offset := table_find_new(*member_table, key); member_found, member_offset := table_find(*member_table, key);
member_slot: *u8; member_slot: *u8;
member_info: *Type_Info; member_info: *Type_Info;
@ -562,7 +562,7 @@ parse_object :: (str: string, slot: *u8, info: *Type_Info_Struct, ignore_unknown
member_slot = slot + member_offset.offset_in_bytes; member_slot = slot + member_offset.offset_in_bytes;
member_info = member_offset.member.type; member_info = member_offset.member.type;
} else if !ignore_unknown { } else if !ignore_unknown {
log_error("Missing member % in %", key, <<info); log_error("Missing member % in %", key, (.*)info);
return remainder, false; return remainder, false;
} }

View File

@ -56,7 +56,7 @@ main :: () {
print("\n"); print("\n");
if success { if success {
found, entry := table_find_new(*package.lookup, "this is item2"); found, entry := table_find(*package.lookup, "this is item2");
if found { if found {
print("Found the entry!: %\n", entry.*); print("Found the entry!: %\n", entry.*);

View File

@ -72,7 +72,7 @@ init_from_memory :: (package: *Load_Package, data: [] u8, name_for_debugging :=
} }
_header := cast(*Package_Header) data.data; _header := cast(*Package_Header) data.data;
package.header = << _header; package.header = (.*) _header;
header_success := check_header(*package.header, name_for_debugging, data.count); header_success := check_header(*package.header, name_for_debugging, data.count);
if !header_success return false; if !header_success return false;
@ -156,8 +156,8 @@ load_table_of_contents :: (package: *Load_Package, data: [] u8, base_file_data_i
#scope_file #scope_file
MAGIC :: #run << cast(*u32) "simp".data; MAGIC :: #run (.*) cast(*u32) "simp".data;
TABLE_OF_CONTENTS_MAGIC :: #run << cast(*u32) "toc!".data; TABLE_OF_CONTENTS_MAGIC :: #run (.*) cast(*u32) "toc!".data;
FILE_VERSION :: 1; FILE_VERSION :: 1;
TARGET_IS_LITTLE_ENDIAN :: true; // @Endian: Need a way to change this based on target CPU! TARGET_IS_LITTLE_ENDIAN :: true; // @Endian: Need a way to change this based on target CPU!

View File

@ -41,7 +41,7 @@ init_asset_pack_load :: () {
} }
add_font_from_pack :: (path: string) { add_font_from_pack :: (path: string) {
ok, entry := table_find_new(*g_asset_pack.lookup, path); ok, entry := table_find(*g_asset_pack.lookup, path);
if !ok { if !ok {
print("Failed to find font % from pack...\n", path); print("Failed to find font % from pack...\n", path);
return; return;
@ -50,7 +50,7 @@ add_font_from_pack :: (path: string) {
} }
create_texture_from_pack :: (path: string) -> (sg_image, s32, s32) { create_texture_from_pack :: (path: string) -> (sg_image, s32, s32) {
ok, entry := table_find_new(*g_asset_pack.lookup, path); ok, entry := table_find(*g_asset_pack.lookup, path);
if !ok { if !ok {
print("Failed to find texture % from pack...\n", path); print("Failed to find texture % from pack...\n", path);
img : sg_image; img : sg_image;
@ -69,7 +69,7 @@ create_texture_from_pack :: (path: string) -> (sg_image, s32, s32) {
size = xx (x * y * 4) size = xx (x * y * 4)
}; };
sg_init_image(*img, *(sg_image_desc.{ sg_init_image(img, *(sg_image_desc.{
width = x, width = x,
height = y, height = y,
pixel_format = sg_pixel_format.RGBA8, pixel_format = sg_pixel_format.RGBA8,
@ -84,7 +84,7 @@ create_texture_from_pack :: (path: string) -> (sg_image, s32, s32) {
} }
load_string_from_pack :: (path: string) -> string { load_string_from_pack :: (path: string) -> string {
ok, entry := table_find_new(*g_asset_pack.lookup, path); ok, entry := table_find(*g_asset_pack.lookup, path);
if !ok { if !ok {
print("Failed to load string from pack: %\n", path); print("Failed to load string from pack: %\n", path);
return ""; return "";

View File

@ -86,7 +86,7 @@ draw_trile_side_triangles :: (vecs: *[]float, normals: *[]float, index: *int, si
index.* = index.* + 3; index.* = index.* + 3;
} }
for #v2 < 0..2 { for < 0..2 {
vecs.*[index.*] = (x + points[it][0]) * TRIXEL_SIZE; vecs.*[index.*] = (x + points[it][0]) * TRIXEL_SIZE;
vecs.*[index.*+1] = (y + points[it][1]) * TRIXEL_SIZE; vecs.*[index.*+1] = (y + points[it][1]) * TRIXEL_SIZE;
vecs.*[index.*+2] = (z + points[it][2]) * TRIXEL_SIZE; vecs.*[index.*+2] = (z + points[it][2]) * TRIXEL_SIZE;

View File

@ -25,7 +25,7 @@ get_trile_table_ptr :: () -> *Table(string, Trile) {
// once it's more clear how this whole trile storage thing // once it's more clear how this whole trile storage thing
// will pan out. -ktjst // will pan out. -ktjst
get_trile_gfx :: (name: string) -> (Trile_GFX, success: bool) { get_trile_gfx :: (name: string) -> (Trile_GFX, success: bool) {
success, value := table_find_new(*trile_gfx_table, name); success, value := table_find(*trile_gfx_table, name);
if !success { if !success {
// Check if such a trile exists. // Check if such a trile exists.
trile, success_with_trile := get_trile(name); trile, success_with_trile := get_trile(name);

View File

@ -127,7 +127,7 @@ texture_load_from_memory :: (texture: *Ui_Texture, memory: []u8, srgb: bool, bui
size = xx (x * y * 4) size = xx (x * y * 4)
}; };
sg_init_image(*img, *(sg_image_desc.{ sg_init_image(img, *(sg_image_desc.{
width = x, width = x,
height = y, height = y,
pixel_format = sg_pixel_format.RGBA8, pixel_format = sg_pixel_format.RGBA8,