res := allocator.func(allocator.data, aa, size, align, oldptr);
use package core { printf }
- printf("%s with size %i, align %i, oldptr %p returns %p\n",
+ printf("{} with size {}, align {}, oldptr {} returns {}\n",
Allocation_Action_Strings[cast(u32) aa], size, align, oldptr, res);
return res;
return str.{ data = c + 1, count = len };
}
+#if false {
@Hack @Cleanup // This is a big hack but it will work for now
f64_to_str :: (f: f64, buf: [] u8) -> str {
f *= 10000.0;
return str.{ buf.data, len };
}
+}
+
+// This is better than the above version, but still relies on converting the integer
+// part of the float to an integer, which could overflow.
+f64_to_str :: (f: f64, buf: [] u8) -> str {
+ math :: package core.math
+
+ len := 0;
+
+ if f < 0 {
+ f = -f;
+ buf[0] = #char "-";
+ len += 1;
+ }
+
+ dec_part := f - math.trunc(f);
+ int_part := f - dec_part;
+ dec_part = math.abs(dec_part);
+
+ s1 := i64_to_str(~~int_part, 10, buf);
+ for i: 0 .. s1.count do buf.data[i + len] = s1.data[i];
+ buf.data[s1.count + len] = #char ".";
+ len += s1.count + 1;
+
+ digits := "0123456789";
+
+ decimals :: 4;
+ for i: decimals {
+ dec_part *= 10;
+ v := math.trunc(dec_part);
+ dec_part -= v;
+
+ buf.data[len + i] = digits[cast(i32) v];
+ }
+ len += decimals;
+
+ return str.{ buf.data, len };
+}
+
+str_format :: (format: str, buffer: [] u8, va: ..any) -> str {
+ return str_format_va(format, buffer, ~~va);
+}
+
+str_format_va :: (format: str, buffer: [] u8, va: [] any) -> str {
+ @Cleanup
+ Output :: struct {
+ data: ^u8;
+ count: u32;
+ capacity: u32;
+
+ write :: #match {
+ (use output: ^Output, c: u8) {
+ if count >= capacity do return;
+
+ data[count] = c;
+ count += 1;
+ },
+
+ (use output: ^Output, s: str) {
+ for c: s do output->write(c);
+ }
+ }
+ }
+
+ output := Output.{ buffer.data, 0, buffer.count };
+
+ Format :: struct {
+ digits_after_decimal := cast(u32) 4;
+ }
+ formatting := Format.{};
+
+ vararg_index := 0;
+
+ while i := 0; i < format.count {
+ defer i += 1;
+
+ ch := format[i];
+
+ if ch == #char "{" {
+ if format[i + 1] == #char "{" {
+ output->write(#char "{");
+ i += 1;
+ continue;
+ }
+
+ while true {
+ i += 1;
+ ch = format[i];
+
+ switch ch {
+ case #char "." {
+ i += 1;
+
+ digits := 0;
+ while format[i] >= #char "0" && format[i] <= #char "9" {
+ digits *= 10;
+ digits += ~~(format[i] - #char "0");
+ i += 1;
+ }
+
+ formatting.digits_after_decimal = digits;
+ }
+ case #default do break break;
+ }
+ }
+ }
+
+ if ch == #char "}" {
+ if format[i + 1] == #char "}" {
+ output->write(#char "}");
+ i += 1;
+ continue;
+ }
+
+ arg := va[vararg_index];
+ vararg_index += 1;
+ print_any(^output, arg);
+
+ continue;
+ }
+
+ output->write(ch);
+ }
+
+ return .{ output.data, output.count };
+
+ print_any :: (output: ^Output, v: any) {
+ use package builtin.type_info
+ array :: package core.array
+
+ switch v.type {
+ case bool {
+ value := *(cast(^bool) v.data);
+ if value do output->write("true");
+ else do output->write("false");
+ }
+
+ case i32, u32 {
+ value := *(cast(^i32) v.data);
+
+ ibuf : [128] u8;
+ istr := i64_to_str(~~value, 10, ~~ibuf);
+ output->write(istr);
+ }
+
+ case i64, u64 {
+ value := *(cast(^i64) v.data);
+
+ ibuf : [128] u8;
+ istr := i64_to_str(~~value, 10, ~~ibuf);
+ output->write(istr);
+ }
+
+ case f32 {
+ value := *(cast(^f32) v.data);
+
+ fbuf : [128] u8;
+ fstr := f64_to_str(~~value, ~~fbuf);
+ output->write(fstr);
+ }
+
+ case f64 {
+ value := *(cast(^f64) v.data);
+
+ fbuf : [128] u8;
+ fstr := f64_to_str(~~value, ~~fbuf);
+ output->write(fstr);
+ }
+
+ case str do output->write(*(cast(^str) v.data));
+
+ case rawptr {
+ value := *(cast(^rawptr) v.data);
+
+ ibuf : [128] u8;
+ istr := i64_to_str(~~value, 16, ~~ibuf);
+ output->write(istr);
+ }
+
+ case #default {
+ info := get_type_info(v.type);
+
+ if info.kind == .Struct {
+ s := cast(^Type_Info_Struct) info;
+
+ if s.name.count > 0 do output->write(s.name);
+ output->write(" { ");
+
+ for ^member: s.members {
+ if member != s.members.data do output->write(", ");
+
+ output->write(member.name);
+ output->write(" = ");
+
+ print_any(output, .{ ~~(cast(^u8) v.data + member.offset), member.type });
+ }
+
+ output->write(" }");
+ }
+
+ if info.kind == .Function do output->write("<function>");
+
+ if info.kind == .Pointer {
+ value := *(cast(^rawptr) v.data);
+
+ ibuf : [128] u8;
+ istr := i64_to_str(~~value, 16, ~~ibuf);
+ output->write(istr);
+ }
+
+ // This assumes that the following type_info kinds are basically the same.
+ if info.kind == .Dynamic_Array || info.kind == .Slice || info.kind == .Variadic_Argument {
+ output->write("[ ");
+
+ a := cast(^Type_Info_Dynamic_Array) info;
+ arr := cast(^array.Untyped_Array) v.data;
+ data := arr.data;
+ count := arr.count;
+
+ for i: count {
+ if i != 0 do output->write(", ");
+
+ print_any(output, .{ ~~(cast(^u8) data + get_type_info(a.of).size * i), a.of });
+ }
+
+ output->write(" ]");
+ }
+
+ if info.kind == .Array {
+ output->write("[ ");
+
+ a := cast(^Type_Info_Array) info;
+ data := v.data;
+
+ for i: a.count {
+ if i != 0 do output->write(", ");
+
+ print_any(output, .{ ~~(cast(^u8) data + get_type_info(a.of).size * i), a.of });
+ }
+
+ output->write(" ]");
+ }
+
+ if info.kind == .Enum {
+ e := cast(^Type_Info_Enum) info;
+
+ value: u64;
+ switch e.backing_type {
+ case i8, u8 do value = cast(u64) *(cast(^u8) v.data);
+ case i16, u16 do value = cast(u64) *(cast(^u16) v.data);
+ case i32, u32 do value = cast(u64) *(cast(^u32) v.data);
+ case i64, u64 do value = cast(u64) *(cast(^u64) v.data);
+ case #default do assert(false, "Bad enum backing type");
+ }
+
+ {
+ for ^member: e.members {
+ if value == member.value {
+ output->write(member.name);
+ break break;
+ }
+ }
+
+ output->write("UNKNOWN");
+ }
+ }
+ }
+ }
+ }
+}
+
+
+// Old % style print formatting
+#if false {
str_format :: (format: str, buffer: [] u8, va: ...) -> str {
return str_format_va(format, buffer, va);
}
return str.{ ~~buffer.data, len };
}
+}
+
}
}
-write_format :: (use writer: ^Writer, format: str, va: ...) {
+write_format :: (use writer: ^Writer, format: str, va: ..any) {
// POTENTIAL BUG: this buffer will need to be bigger (or dynamic).
buffer: [2048] u8;
- write_str(writer, conv.str_format_va(format, ~~buffer, va));
+ write_str(writer, conv.str_format_va(format, ~~buffer, ~~va));
}
write_escaped_str :: (use writer: ^Writer, s: str) {
#load "./runtime/build_opts"
#load "./runtime/common"
+#load "./type_info/helper"
+
#private_file runtime :: package runtime
#if runtime.Runtime == runtime.Runtime_Wasi {
#load "./runtime/wasi"
#load "./wasi/env"
#load "./wasi/clock"
#load "./io/file"
-
- #load "./type_info/helper"
}
#if runtime.Runtime == runtime.Runtime_Js {
print("\n");
}
-printf :: (format: str, va: ...) {
+printf :: (format: str, va: ..any) {
buffer: [2048] u8;
- print(conv.str_format_va(format, buffer[0 .. 2048], va));
+ print(conv.str_format_va(format, buffer[0 .. 2048], ~~va));
}
// This works on both slices and arrays
case .Array {
arr := cast(^Type_Info_Array) info;
- io.write_format(writer, "[%i] ", arr.count);
+ io.write_format(writer, "[{}] ", arr.count);
write_type_name(writer, arr.of);
}
success := true;
if gl.getShaderParameter(shader, gl.COMPILE_STATUS) == 0 {
- printf("Error compiling shader.");
+ println("Error compiling shader.");
gl.printShaderInfoLog(shader);
success = false;
}
success := true;
if gl.getProgramParameter(program, gl.LINK_STATUS) == 0 {
- printf("Error linking program.");
+ println("Error linking program.");
gl.printProgramInfoLog(program);
success = false;
}
i8* strdata = bh_alloc_array(global_heap_allocator, i8, strlit->token->length + 1);
i32 length = string_process_escape_seqs(strdata, strlit->token->text, strlit->token->length);
+ // Warning for having '%' in a string literal (because that probably is being used for a old print format)
+ /*
+ if (charset_contains((const char *) strdata, '%')) {
+ onyx_report_warning(strlit->token->pos, "Found string literal with '%%'");
+ }
+ */
+
if (bh_table_has(StrLitInfo, mod->string_literals, (char *) strdata)) {
StrLitInfo sti = bh_table_get(StrLitInfo, mod->string_literals, (char *) strdata);
strlit->addr = sti.addr;
for i: nums do for j: nums do for k: nums {
if j + i + k == 2020 {
- printf("Answer: %i\n", i * j * k);
+ printf("Answer: {}\n", i * j * k);
// Break out of all of the loops
break break break;
for i: 1 .. nums.count do diffs[nums[i] - nums[i - 1] - 1] += 1;
diffs[2] += 1;
- printf("Diff prod: %i\n", diffs[0] * diffs[2]);
- printf("Arrangements: %l\n", count_ending_paths(nums));
+ printf("Diff prod: {}\n", diffs[0] * diffs[2]);
+ printf("Arrangements: {}\n", count_ending_paths(nums));
}
occupied := 0;
for s: gos.seats do if s == SeatState.Occupied do occupied += 1;
- printf("Occupied: %i\n", occupied);
+ printf("Occupied: {}\n", occupied);
}
}
}
- printf("Ship distance: %i\n", math.abs(ship.x) + math.abs(ship.y));
+ printf("Ship distance: {}\n", math.abs(ship.x) + math.abs(ship.y));
}
// }
// result := take_bus * (depart - est);
- // printf("Bus: %i\n", take_bus);
- // printf("Depart at: %i\n", depart);
- // printf("Result: %i\n", result);
+ // printf("Bus: {}\n", take_bus);
+ // printf("Depart at: {}\n", depart);
+ // printf("Result: {}\n", result);
// Part 2
result := chinese_remainder_theorem(buses, rems);
- printf("Result: %l\n", result);
+ printf("Result: {}\n", result);
}
s: u64 = 0;
for e: mem.entries do s += e.value;
- printf("Sum: %l\n", s);
+ printf("Sum: {}\n", s);
}
turn += 1;
}
- printf("2020th: %i\n", last_num);
+ printf("2020th: {}\n", last_num);
}
}
}
- printf("Scanning error: %i\n", total_scanning_error);
+ printf("Scanning error: {}\n", total_scanning_error);
cols_to_assign := array.make(u32, fields.count);
defer array.free(^cols_to_assign);
if string.starts_with(field.name, "departure") do prod *= ~~my_ticket[field.column];
}
- printf("Departure multiply: %l\n", prod);
+ printf("Departure multiply: {}\n", prod);
}
active_count := 0;
for ^cube_entry: cubes.entries do if cube_entry.value.alive do active_count += 1;
- printf("Active count: %i\n", active_count);
+ printf("Active count: {}\n", active_count);
}
total += parse_expression_mul(^file);
}
- printf("Total: %l\n", total);
+ printf("Total: {}\n", total);
}
if cyk_algorithm(^grammar, line) do valid_count += 1;
}
- printf("Valid count: %i\n", valid_count);
+ printf("Valid count: {}\n", valid_count);
}
if count == 1 do valid += 1;
}
- printf("Number valid: %i\n", valid);
+ printf("Number valid: {}\n", valid);
}
}
}
- printf("Corner product: %l\n", prod);
+ printf("Corner product: {}\n", prod);
grid : [12 * 12] u32;
memory.set(^grid, 0, sizeof [12 * 12] u32);
safe_count := 0;
for c: forest do if c == #char "#" do safe_count += 1;
- printf("Safe count: %i\n", safe_count);
+ printf("Safe count: {}\n", safe_count);
}
map.delete(^ingredient_map, safe);
}
- printf("Total safe: %i\n", total_safe);
+ printf("Total safe: {}\n", total_safe);
matched_ingredients := array.make(Ingredient);
defer array.free(^matched_ingredients);
return string.compare(i1.allergen, i2.allergen);
});
- for ^mi: matched_ingredients do printf("%s -> %s\n", mi.name, mi.allergen);
- for ^mi: matched_ingredients do printf("%s,", mi.name);
+ for ^mi: matched_ingredients do printf("{} -> {}\n", mi.name, mi.allergen);
+ for ^mi: matched_ingredients do printf("{},", mi.name);
println("\n(Don't copy the last ','!)");
}
defer array.free(^player2_copy);
combat_score := combat(^player1_copy, ^player2_copy);
- printf("Answer: %i\n", combat_score);
+ printf("Answer: {}\n", combat_score);
}
{
if winner == 1 do score = score_player(^player1_copy);
if winner == 2 do score = score_player(^player2_copy);
- printf("Recursive answer: %i\n", score);
+ printf("Recursive answer: {}\n", score);
}
}
// Part 1
// one_idx := get_idx(array.to_slice(^cups), 1);
// for i: 1 .. 9 {
- // printf("%i", cast(i32) cups[w(one_idx + i)]);
+ // printf("{}", cast(i32) cups[w(one_idx + i)]);
// }
// printf("\n");
// Part 2
one_idx := get_idx(array.to_slice(^cups), 1);
prod: i64 = cast(i64) (cups[w(one_idx + 1)]) * cast(i64) (cups[w(one_idx + 2)]);
- printf("Cup product: %l\n", prod);
+ printf("Cup product: {}\n", prod);
}
for ^cell: grid.entries {
if cell.value.alive do black_count += 1;
}
- printf("Black count: %i\n", black_count);
+ printf("Black count: {}\n", black_count);
// Part 2
cells_to_consider := array.make(Vec2);
for ^cell: grid.entries {
if cell.value.alive do black_count += 1;
}
- printf("GOL black count: %i\n", black_count);
+ printf("GOL black count: {}\n", black_count);
}
get_neighbor_count :: (grid: ^map.Map(Vec2, Cell), pos: Vec2) -> u32 {
encryption_key_0 := transform_subject(door_pub_key, card_loop_secret);
encryption_key_1 := transform_subject(card_pub_key, door_loop_secret);
- printf("%i == %i\n", encryption_key_0, encryption_key_1);
+ printf("{} == {}\n", encryption_key_0, encryption_key_1);
}
tree_prod *= tree_count;
}
- printf("Tree product: %l\n", tree_prod);
+ printf("Tree product: {}\n", tree_prod);
}
if field_count == 7 do valid_passports += 1;
}
- printf("Valid passports: %i\n", valid_passports);
+ printf("Valid passports: {}\n", valid_passports);
}
if vals[i + 1] - vals[i] != 1 do missing = vals[i] + 1;
}
- printf("Max val: %i\n", max_val);
- printf("Your seat: %i\n", missing);
+ printf("Max val: {}\n", max_val);
+ printf("Your seat: {}\n", missing);
}
cmp_asc :: (a: $T, b: T) -> i32 do return ~~(a - b);
unique_sum += unique;
}
- printf("Unique sum: %i\n", unique_sum);
+ printf("Unique sum: {}\n", unique_sum);
}
//
// for container: bag.contained_in {
// if !array.contains(^processed_bags, container.bag) && !array.contains(^to_process_bags, container.bag) {
- // // printf("Adding %s to process.\n", container.bag.color);
+ // // printf("Adding {} to process.\n", container.bag.color);
// array.push(^to_process_bags, container.bag);
// }
// }
// }
- // printf("Count: %i\n", processed_bags.count - 1);
+ // printf("Count: {}\n", processed_bags.count - 1);
// Part 2
to_process := array.make(#type ^BagNode);
}
}
- printf("Count: %i\n", count - 1);
+ printf("Count: {}\n", count - 1);
}
elseif instr.opcode == OpCode.Jmp do instr.opcode = OpCode.Nop;
}
- printf("Accumulator value: %i\n", acc);
+ printf("Accumulator value: {}\n", acc);
}
}
}
- printf("Invalid number: %l\n", invalid);
+ printf("Invalid number: {}\n", invalid);
start, end := find_contiguous_subarray_with_sum(nums, invalid);
max := array.fold(nums.data[start .. end + 1], cast(u64) 0, math.max_poly);
min := array.fold(nums.data[start .. end + 1], cast(u64) max, math.min_poly);
- printf("Extrema sum: %l\n", min + max);
+ printf("Extrema sum: {}\n", min + max);
}
// Overload print() to print Vec2's.
#add_match io.write, (use writer: ^io.Writer, use v: Vec2) {
- io.write_format(writer, "Vec2(%i, %i)", x, y);
+ io.write_format(writer, "Vec2({}, {})", x, y);
}
EntityStore :: struct {
use package core
count_to :: ($N: i32) {
- for i: 0 .. N do printf("%i ", i);
+ for i: 0 .. N do printf("{} ", i);
print("\n");
}
print_age :: (ages: ^map.Map(str, u32), name: str) {
age := map.get(ages, name);
- printf("%s's age is %i.\n", name, age);
+ printf("{}'s age is {}.\n", name, age);
}
print_age(^ages, "Dwight");
}
main :: (args: [] cstr) {
- printf("%i\n", "Hello World!".count);
+ printf("{}\n", "Hello World!".count);
println(get_foo().name);
println(get_foo().x);
i := 0;
while i < 10 {
defer i += 1;
- defer printf("Index is %i\n", i);
+ defer printf("Index is {}\n", i);
if i == 3 {
- printf("Skipping %i!!\n", i);
+ printf("Skipping {}!!\n", i);
continue;
}
- printf("Doing something with ");
+ print("Doing something with ");
}
- printf("i is %i\n", i);
+ printf("i is {}\n", i);
println("\n\n===================================");
i = 0;
while i < 10 {
defer i += 1;
- defer printf("Index is %i\n", i);
+ defer printf("Index is {}\n", i);
if i == 3 {
- printf("Skipping %i!!\n", i);
+ printf("Skipping {}!!\n", i);
break;
}
- printf("Doing something with ");
+ print("Doing something with ");
}
- printf("i is %i\n", i);
+ printf("i is {}\n", i);
println("\n\n===================================");
switch i {
12.0000
12.0000
8.0000
-12.3400
+12.3399
0.3399
2.0000
1.0000
println(map.has(^imap, 50));
println(map.has(^imap, 51));
- printf("%s%s\n", map.get(^imap, 50), map.get(^imap, 1234));
+ printf("{}{}\n", map.get(^imap, 50), map.get(^imap, 1234));
map.delete(^imap, 50);
println(map.has(^imap, 50));
|> iter.zip(iter.const(42.0f));
for value: zipped_iterator {
- printf("%i %f\n", value.first, value.second);
+ printf("{} {}\n", value.first, value.second);
}
}
least, greatest := get_extrema(i32.[ -5, 20, 5, -10, 200, 8 ]);
- printf("%i to %i\n", least, greatest);
+ printf("{} to {}\n", least, greatest);
iarr, farr := return_multiple_arrays();
array_print(iarr);
main :: (args: [] cstr) {
foo :: (x: i32, y: f32) {
- printf("x is %i\n", x);
- printf("y is %f\n", y);
+ printf("x is {}\n", x);
+ printf("y is {}\n", y);
}
foo(10, 20);
println(x);
println(y);
- for elem: z do printf("%f ", elem);
- printf("\n");
+ for elem: z do printf("{} ", elem);
+ print("\n");
}
overload_with_varargs(10, 20, 30, 40, 50);
options_f := false,
options_g := true,
) {
- printf("%b %b %b %b %b %b %b\n",
+ printf("{} {} {} {} {} {} {}\n",
options_a, options_b,
options_c, options_d,
options_e, options_f,
--- /dev/null
+123 Test { } false 0x4E8
--- /dev/null
+#load "core/std"
+
+use package core
+
+main :: (args: [] cstr) {
+ printf("{} {} {{ }} {} {}\n", 123, "Test", false, ^stdio.print_writer);
+}
println(foo.some_constant);
person := Foo2.SubStruct.{ name = "Joe", age = 30 };
- printf("%s is %i.\n", person.name, person.age);
+ printf("{} is {}.\n", person.name, person.age);
{
BasicallyANamespace.function_3();
v := Vec3.{ 4, 9, 16 };
- printf("V3(%f, %f, %f)\n", v.x, v.y, v.z);
+ printf("V3({}, {}, {})\n", v.x, v.y, v.z);
}
BasicallyANamespace :: struct {
b := C(0, 1);
c := a + b;
- printf("(%f, %f)\n", c.re, c.im);
+ printf("({}, {})\n", c.re, c.im);
c = a - b;
- printf("(%f, %f)\n", c.re, c.im);
+ printf("({}, {})\n", c.re, c.im);
c = a * b;
- printf("(%f, %f)\n", c.re, c.im);
+ printf("({}, {})\n", c.re, c.im);
}
{
a := make_vec(f32.[10, 20]);
b := make_vec(f32.[3, 4]);
c := a + b;
- printf("(%f, %f)\n", c.data[0], c.data[1]);
+ printf("({}, {})\n", c.data[0], c.data[1]);
d := make_vec(f32.[2, 3, 5, 7]);
e := join(d, c);
- for v: e.data do printf("%f ", v);
+ for v: e.data do printf("{} ", v);
print("\n");
}
a := make_vec(Complex.[C(2, 3), C(0, 1)]);
b := make_vec(Complex.[C(1, 0), C(3, 7)]);
c := a * b;
- printf("(%f, %f)\n", c.re, c.im);
+ printf("({}, {})\n", c.re, c.im);
}
println(test_overload("World!", "Hello!"));
main :: (args: [] cstr) {
arr := u32.[ 1, 2, 3, 4, 5 ];
- for elem: array_to_slice(arr) do printf("%i ", elem);
+ for elem: array_to_slice(arr) do printf("{} ", elem);
roots : [20] f32;
compute_roots(roots);
ss: SimpleStruct = SimpleStruct.{ 41, 67, "Steve" };
use ss;
- printf("SimpleStruct<%i, %i>(%i, %i, %s)\n",
+ printf("SimpleStruct<{}, {}>({}, {}, {})\n",
sizeof SimpleStruct,
alignof SimpleStruct,
cast(u32) age, height, name);
u : SimpleUnion;
u.float_val = 0.5;
- printf("%p == 0x3F000000\n", u.int_val);
+ printf("{} == 0x3F000000\n", cast(rawptr) u.int_val);
}
test_default_values :: () {
print_defaulted(ds2);
print_defaulted :: (use ds: DefaultedStruct) {
- printf("DefaultedStruct(%i, %f, %l, %d)\n", i, f, l, d);
+ printf("DefaultedStruct({}, {}, {}, {})\n", i, f, l, d);
}
}
// swu3 := StructWithUse.{ 1234, 1, 2, 5678 };
print_swu :: (use swu: StructWithUse) {
- printf("StructWithUse(%i, (%f, %f), %i)\n",
+ printf("StructWithUse({}, ({}, {}), {})\n",
first_member, x, y, last_member);
}
ps1.t_data = 1234;
ps1.r_data = 5678;
- printf("PolyStruct<i32, f32>(%i, %f)\n", ps1.t_data, ps1.r_data);
+ printf("PolyStruct<i32, f32>({}, {})\n", ps1.t_data, ps1.r_data);
// Currently, this is how you have to do this.
ps2 := <PolyStruct(f32, i32)>.{ 1234, 5678 };
- printf("PolyStruct<f32, i32>(%f, %i)\n", ps2.t_data, ps2.r_data);
+ printf("PolyStruct<f32, i32>({}, {})\n", ps2.t_data, ps2.r_data);
}
test_polymorphic_with_defaults :: () {
PolyStructTyped :: <PolyStruct(i32, f32)>;
ps := PolyStructTyped.{};
- printf("PolyStruct<i32, f32>(%i, %f)\n", ps.t_data, ps.r_data);
+ printf("PolyStruct<i32, f32>({}, {})\n", ps.t_data, ps.r_data);
}
test_polymorphic_union_with_use :: () {
};
}
- printf("%i == 16\n", sizeof PolyStruct(i32, [] u32));
+ printf("{} == 16\n", sizeof PolyStruct(i32, [] u32));
ps : PolyStruct(i32, f64);
ps.t_data = 1234;
ps.r_data = 5678;
- printf("%i, %d\n", ps.t_data, ps.r_data);
+ printf("{}, {}\n", ps.t_data, ps.r_data);
}
test_union_with_use :: () {
u : Union;
u.x = 10;
u.y = 20;
- printf("Union(%i, %i)\n", u.x, u.y);
+ printf("Union({}, {})\n", u.x, u.y);
u.name = "Joe";
- printf("Union(%s)\n", u.name);
+ printf("Union({})\n", u.name);
}
test_polymorphic_union :: () {
pu : PolyUnion(str, i32);
pu.t_data = "Hello World.";
- printf("PolyUnion(%s)\n", pu.t_data);
+ printf("PolyUnion({})\n", pu.t_data);
pu.r_data = 0x4D2;
- printf("PolyUnion(%i)\n", pu.r_data);
+ printf("PolyUnion({})\n", pu.r_data);
}
}
new_va_test("foo", 1, 2, 3.0f, 5.0f);
old_va_test("bar", 1);
- printf("Hello, %i, %s!\n", 1234, "World");
+ printf("Hello, {}, {}!\n", 1234, "World");
}