port to latest jai version
This commit is contained in:
parent
e2da734dcd
commit
0bb4cffbd6
@ -152,7 +152,7 @@ Iprof :: #import "Iprof"(IMPORT_MODE = .METAPROGRAM);
|
||||
root_opts := get_build_options();
|
||||
w := compiler_create_workspace("Target");
|
||||
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.os_target = root_opts.os_target;
|
||||
|
||||
@ -203,7 +203,7 @@ DONE
|
||||
get :: (json_val: JSON_Value, key: string, expected_type: JSON_Type) -> JSON_Value {
|
||||
assert(json_val.type == .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(val.type == expected_type);
|
||||
return val;
|
||||
@ -212,7 +212,7 @@ DONE
|
||||
// Check for version number that may or may not exist
|
||||
version: float64 = -1;
|
||||
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 val.type == .NUMBER {
|
||||
version = val.number;
|
||||
|
||||
@ -83,7 +83,7 @@ print_val :: (using val: JSON_Value) {
|
||||
for array print_val(it);
|
||||
print("]");
|
||||
case .OBJECT;
|
||||
print("%", <<object);
|
||||
print("%", (.*)object);
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ json_write_json_value :: (builder: *String_Builder, using val: JSON_Value, inden
|
||||
keys: [..] string;
|
||||
defer array_free(keys);
|
||||
array_reserve(*keys, obj.count);
|
||||
for v, k: <<obj {
|
||||
for v, k: (.*)obj {
|
||||
array_add(*keys, k);
|
||||
}
|
||||
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);
|
||||
append(builder, ": ");
|
||||
found, v := table_find_new(obj, it);
|
||||
found, v := table_find(obj, it);
|
||||
assert(found, "Missing table value %", it);
|
||||
json_write_json_value(builder, v, indent_char, level + 1);
|
||||
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 !remainder.count return false;
|
||||
|
||||
success, next_value := table_find_new(obj, next);
|
||||
success, next_value := table_find(obj, next);
|
||||
next_obj: *JSON_Object;
|
||||
if success {
|
||||
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 {
|
||||
return #string END
|
||||
assert(val.type == .OBJECT, "Expected a % but got %", T, val.type);
|
||||
return <<val.object;
|
||||
return (.*)val.object;
|
||||
END;
|
||||
} else {
|
||||
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);
|
||||
case #char "{";
|
||||
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);
|
||||
case;
|
||||
result.type = JSON_Type.NUMBER;
|
||||
|
||||
@ -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) {
|
||||
if info.type == {
|
||||
case .BOOL;
|
||||
append(builder, ifx <<(cast(*bool) data) "true" else "false");
|
||||
append(builder, ifx (.*)(cast(*bool) data) "true" else "false");
|
||||
case .INTEGER; #through;
|
||||
case .FLOAT;
|
||||
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);
|
||||
append(builder, #char "\"");
|
||||
case .STRING;
|
||||
json_append_escaped(builder, <<(cast(*string) data));
|
||||
json_append_escaped(builder, (.*)(cast(*string) data));
|
||||
case .ARRAY;
|
||||
info_array := cast(*Type_Info_Array) info;
|
||||
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_count := info_array.array_count;
|
||||
if info_array.array_count == -1 {
|
||||
array_count = << cast(*s64) data;
|
||||
array_count = (.*) cast(*s64) data;
|
||||
|
||||
array_dest: **void = data + 8;
|
||||
array_data = << array_dest;
|
||||
array_data = (.*) array_dest;
|
||||
}
|
||||
|
||||
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;
|
||||
if is_generic_json_value(info) {
|
||||
value := cast(*JSON_Value) data;
|
||||
json_write_json_value(builder, <<value, indent_char, level);
|
||||
json_write_json_value(builder, (.*)value, indent_char, level);
|
||||
} else {
|
||||
append(builder, #char "{");
|
||||
first := true;
|
||||
@ -105,7 +105,7 @@ json_write_native :: (builder: *String_Builder, data: *void, info: *Type_Info, i
|
||||
}
|
||||
case .POINTER;
|
||||
ptr_info := cast(*Type_Info_Pointer) info;
|
||||
ptr := << cast(**void) data;
|
||||
ptr := (.*) cast(**void) data;
|
||||
if ptr {
|
||||
json_write_native(builder, ptr, ptr_info.pointer_to, indent_char, ignore, rename, level);
|
||||
} else {
|
||||
@ -126,8 +126,8 @@ json_write_native_members :: (builder: *String_Builder, data: *void, members: []
|
||||
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);
|
||||
} else {
|
||||
if !<<first append(builder, ",");
|
||||
<<first = false;
|
||||
if !(.*)first append(builder, ",");
|
||||
(.*)first = false;
|
||||
|
||||
if indent_char.count {
|
||||
append(builder, "\n");
|
||||
@ -198,7 +198,7 @@ parse_value :: (to_parse: string, slot: *u8, info: *Type_Info, ignore_unknown: b
|
||||
} else {
|
||||
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;
|
||||
} else {
|
||||
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 slot {
|
||||
if info.type == .POINTER {
|
||||
<<cast(**void) slot = null;
|
||||
(.*)cast(**void) slot = null;
|
||||
} else {
|
||||
builder: String_Builder;
|
||||
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 {
|
||||
json_set(cast(*JSON_Value)value_slot, true);
|
||||
} 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 {
|
||||
json_set(cast(*JSON_Value)value_slot, false);
|
||||
} 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 {
|
||||
json_set(cast(*JSON_Value)value_slot, value);
|
||||
} else {
|
||||
<<cast(*string)value_slot = value;
|
||||
(.*)cast(*string)value_slot = value;
|
||||
}
|
||||
stored = true;
|
||||
}
|
||||
@ -297,7 +297,7 @@ parse_value :: (to_parse: string, slot: *u8, info: *Type_Info, ignore_unknown: b
|
||||
if success {
|
||||
if is_generic {
|
||||
value := New(JSON_Object);
|
||||
<<value, remainder, success = parse_object(remainder);
|
||||
(.*)value, remainder, success = parse_object(remainder);
|
||||
json_set(cast(*JSON_Value)value_slot, value);
|
||||
} else {
|
||||
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);
|
||||
} else {
|
||||
if value_info.runtime_size == 4 {
|
||||
(<< cast(*float) slot) = cast(float) float_value;
|
||||
((.*) cast(*float) slot) = cast(float) float_value;
|
||||
} else {
|
||||
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;
|
||||
} else if info.array_count == -1 {
|
||||
// Resizable array
|
||||
<<(cast(*Resizable_Array) slot) = array;
|
||||
(.*)(cast(*Resizable_Array) slot) = array;
|
||||
} else {
|
||||
// Fixed-size array
|
||||
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 {
|
||||
offset := base_offset + member.offset_in_bytes;
|
||||
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});
|
||||
if (member.flags & .USING) && (member.type.type == .STRUCT) {
|
||||
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;
|
||||
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_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_info = member_offset.member.type;
|
||||
} else if !ignore_unknown {
|
||||
log_error("Missing member % in %", key, <<info);
|
||||
log_error("Missing member % in %", key, (.*)info);
|
||||
return remainder, false;
|
||||
}
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ main :: () {
|
||||
print("\n");
|
||||
|
||||
if success {
|
||||
found, entry := table_find_new(*package.lookup, "this is item2");
|
||||
found, entry := table_find(*package.lookup, "this is item2");
|
||||
|
||||
if found {
|
||||
print("Found the entry!: %\n", entry.*);
|
||||
|
||||
@ -72,7 +72,7 @@ init_from_memory :: (package: *Load_Package, data: [] u8, name_for_debugging :=
|
||||
}
|
||||
|
||||
_header := cast(*Package_Header) data.data;
|
||||
package.header = << _header;
|
||||
package.header = (.*) _header;
|
||||
|
||||
header_success := check_header(*package.header, name_for_debugging, data.count);
|
||||
if !header_success return false;
|
||||
@ -156,8 +156,8 @@ load_table_of_contents :: (package: *Load_Package, data: [] u8, base_file_data_i
|
||||
|
||||
#scope_file
|
||||
|
||||
MAGIC :: #run << cast(*u32) "simp".data;
|
||||
TABLE_OF_CONTENTS_MAGIC :: #run << cast(*u32) "toc!".data;
|
||||
MAGIC :: #run (.*) cast(*u32) "simp".data;
|
||||
TABLE_OF_CONTENTS_MAGIC :: #run (.*) cast(*u32) "toc!".data;
|
||||
|
||||
FILE_VERSION :: 1;
|
||||
TARGET_IS_LITTLE_ENDIAN :: true; // @Endian: Need a way to change this based on target CPU!
|
||||
|
||||
@ -41,7 +41,7 @@ init_asset_pack_load :: () {
|
||||
}
|
||||
|
||||
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 {
|
||||
print("Failed to find font % from pack...\n", path);
|
||||
return;
|
||||
@ -50,7 +50,7 @@ add_font_from_pack :: (path: string) {
|
||||
}
|
||||
|
||||
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 {
|
||||
print("Failed to find texture % from pack...\n", path);
|
||||
img : sg_image;
|
||||
@ -69,7 +69,7 @@ create_texture_from_pack :: (path: string) -> (sg_image, s32, s32) {
|
||||
size = xx (x * y * 4)
|
||||
};
|
||||
|
||||
sg_init_image(*img, *(sg_image_desc.{
|
||||
sg_init_image(img, *(sg_image_desc.{
|
||||
width = x,
|
||||
height = y,
|
||||
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 {
|
||||
ok, entry := table_find_new(*g_asset_pack.lookup, path);
|
||||
ok, entry := table_find(*g_asset_pack.lookup, path);
|
||||
if !ok {
|
||||
print("Failed to load string from pack: %\n", path);
|
||||
return "";
|
||||
|
||||
@ -86,7 +86,7 @@ draw_trile_side_triangles :: (vecs: *[]float, normals: *[]float, index: *int, si
|
||||
index.* = index.* + 3;
|
||||
}
|
||||
|
||||
for #v2 < 0..2 {
|
||||
for < 0..2 {
|
||||
vecs.*[index.*] = (x + points[it][0]) * TRIXEL_SIZE;
|
||||
vecs.*[index.*+1] = (y + points[it][1]) * TRIXEL_SIZE;
|
||||
vecs.*[index.*+2] = (z + points[it][2]) * TRIXEL_SIZE;
|
||||
|
||||
@ -25,7 +25,7 @@ get_trile_table_ptr :: () -> *Table(string, Trile) {
|
||||
// once it's more clear how this whole trile storage thing
|
||||
// will pan out. -ktjst
|
||||
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 {
|
||||
// Check if such a trile exists.
|
||||
trile, success_with_trile := get_trile(name);
|
||||
|
||||
@ -127,7 +127,7 @@ texture_load_from_memory :: (texture: *Ui_Texture, memory: []u8, srgb: bool, bui
|
||||
size = xx (x * y * 4)
|
||||
};
|
||||
|
||||
sg_init_image(*img, *(sg_image_desc.{
|
||||
sg_init_image(img, *(sg_image_desc.{
|
||||
width = x,
|
||||
height = y,
|
||||
pixel_format = sg_pixel_format.RGBA8,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user