From 55c88408beb7144ddc43912705b9222a10e2a01f Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Sat, 1 Mar 2025 23:58:28 +0100 Subject: [PATCH] Remove some deprecated use. --- lib/std/collections/map.c3 | 2 +- lib/std/collections/priorityqueue.c3 | 6 ++-- test/unit/stdlib/collections/bitset.c3 | 6 ++-- test/unit/stdlib/collections/copy_map.c3 | 2 +- test/unit/stdlib/collections/list.c3 | 4 +-- test/unit/stdlib/collections/map.c3 | 10 +++---- test/unit/stdlib/io/bits.c3 | 36 ++++++++++++------------ test/unit/stdlib/io/bufferstream.c3 | 8 +++--- test/unit/stdlib/io/bytebuffer.c3 | 2 +- test/unit/stdlib/io/bytestream.c3 | 4 +-- test/unit/stdlib/io/dstringstream.c3 | 2 +- test/unit/stdlib/io/multireader.c3 | 4 +-- test/unit/stdlib/io/multiwriter.c3 | 2 +- test/unit/stdlib/io/stream.c3 | 12 ++++---- test/unit/stdlib/io/teereader.c3 | 2 +- test/unit/stdlib/sort/countingsort.c3 | 2 +- test/unit/stdlib/sort/insertionsort.c3 | 2 +- test/unit/stdlib/sort/quicksort.c3 | 2 +- test/unit/stdlib/threads/channel.c3 | 28 +++++++++--------- 19 files changed, 68 insertions(+), 68 deletions(-) diff --git a/lib/std/collections/map.c3 b/lib/std/collections/map.c3 index 0e4e999ff..bb5c1077c 100644 --- a/lib/std/collections/map.c3 +++ b/lib/std/collections/map.c3 @@ -26,7 +26,7 @@ struct MapImpl @require load_factor > 0.0 "The load factor must be higher than 0" @require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum" *> -fn Map new(uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR, Allocator allocator = allocator::heap()) @deprecated("Map is deprecated") +fn Map new(uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR, Allocator allocator = allocator::heap()) { MapImpl* map = allocator::alloc(allocator, MapImpl); _init(map, capacity, load_factor, allocator); diff --git a/lib/std/collections/priorityqueue.c3 b/lib/std/collections/priorityqueue.c3 index a4d0a3144..6fd1a58dc 100644 --- a/lib/std/collections/priorityqueue.c3 +++ b/lib/std/collections/priorityqueue.c3 @@ -38,17 +38,17 @@ struct PrivatePriorityQueue (Printable) fn void PrivatePriorityQueue.init(&self, Allocator allocator, usz initial_capacity = 16, ) @inline { - self.heap.new_init(initial_capacity, allocator); + self.heap.init(allocator, initial_capacity); } fn void PrivatePriorityQueue.new_init(&self, usz initial_capacity = 16, Allocator allocator = allocator::heap()) @inline { - self.heap.new_init(initial_capacity, allocator); + self.heap.init(allocator, initial_capacity); } fn void PrivatePriorityQueue.temp_init(&self, usz initial_capacity = 16) @inline { - self.heap.new_init(initial_capacity, allocator::temp()) @inline; + self.heap.init(allocator::temp(), initial_capacity) @inline; } diff --git a/test/unit/stdlib/collections/bitset.c3 b/test/unit/stdlib/collections/bitset.c3 index 732c3fed6..83b0e41ee 100644 --- a/test/unit/stdlib/collections/bitset.c3 +++ b/test/unit/stdlib/collections/bitset.c3 @@ -24,7 +24,7 @@ fn void set_get() assert(bs.cardinality() == 2); List found; - found.temp_init(); + found.tinit(); foreach (i, x : bs) { switch (i) @@ -50,7 +50,7 @@ def GrowableBitSet = GrowableBitSet(); fn void growable_set_get() { GrowableBitSet bs; - bs.temp_init(); + bs.tinit(); assert(bs.cardinality() == 0, "Invalid cardinality"); assert(!bs.get(0), "Get was true"); @@ -68,7 +68,7 @@ fn void growable_set_get() assert(bs.len() == 2001, "Len should be 2001"); List found; - found.temp_init(); + found.tinit(); foreach (i, x : bs) { switch (i) diff --git a/test/unit/stdlib/collections/copy_map.c3 b/test/unit/stdlib/collections/copy_map.c3 index 56613e544..aef3f89bd 100644 --- a/test/unit/stdlib/collections/copy_map.c3 +++ b/test/unit/stdlib/collections/copy_map.c3 @@ -43,7 +43,7 @@ fn void copy_keys() @test @pool() { IntMap x; - x.temp_init(); + x.tinit(); x.set("hello", 0); // keys copied into temp hashmap y = x.copy_keys(allocator::heap()); // keys copied out // end of pool: hashmap and its copied-in keys dropped diff --git a/test/unit/stdlib/collections/list.c3 b/test/unit/stdlib/collections/list.c3 index 6d7b0e11c..91c57ced9 100644 --- a/test/unit/stdlib/collections/list.c3 +++ b/test/unit/stdlib/collections/list.c3 @@ -105,7 +105,7 @@ fn void init_with_array() { IntList foo; defer foo.free(); - foo.new_init_with_array({ 1, 2, 3}); + foo.init_with_array(mem, { 1, 2, 3}); assert(foo.len() == 3); assert(foo[2] == 3); } @@ -113,7 +113,7 @@ fn void init_with_array() fn void init_with_temp_array() { IntList foo; - foo.temp_init_with_array({ 1, 2, 3}); + foo.tinit_with_array({ 1, 2, 3}); assert(foo.len() == 3); assert(foo[2] == 3); } diff --git a/test/unit/stdlib/collections/map.c3 b/test/unit/stdlib/collections/map.c3 index b450e2744..319d4caea 100644 --- a/test/unit/stdlib/collections/map.c3 +++ b/test/unit/stdlib/collections/map.c3 @@ -18,7 +18,7 @@ fn void map() { TestHashMap m; assert(!m.is_initialized()); - m.temp_init(); + m.tinit(); assert(m.is_initialized()); assert(m.is_empty()); assert(m.len() == 0); @@ -42,7 +42,7 @@ fn void map() } List list; - list.temp_init(); + list.tinit(); m.@each(;String key, usz value) { list.push({key, value}); @@ -83,7 +83,7 @@ fn void map_remove() { TestHashMap m; assert(!@ok(m.remove("A"))); - m.temp_init(); + m.tinit(); assert(!@ok(m.remove("A"))); m.set("A", 0); assert(@ok(m.remove("A"))); @@ -92,14 +92,14 @@ fn void map_remove() fn void map_copy() { TestHashMap hash_map; - hash_map.temp_init(); + hash_map.tinit(); hash_map.set("aa", 1); hash_map.set("b", 2); hash_map.set("bb", 1); TestHashMap hash_map_copy; - hash_map_copy.temp_init_from_map(&hash_map); + hash_map_copy.tinit_from_map(&hash_map); assert(hash_map_copy.len() == hash_map.len()); diff --git a/test/unit/stdlib/io/bits.c3 b/test/unit/stdlib/io/bits.c3 index bd2afd9bc..7a7402979 100644 --- a/test/unit/stdlib/io/bits.c3 +++ b/test/unit/stdlib/io/bits.c3 @@ -3,7 +3,7 @@ import std::io; fn void test_write_0b1() { ByteWriter w; - w.temp_init(); + w.tinit(); BitWriter bw; bw.init(&w); @@ -16,7 +16,7 @@ fn void test_write_0b1() { fn void test_write_0b1111() { ByteWriter w; - w.temp_init(); + w.tinit(); BitWriter bw; bw.init(&w); @@ -29,7 +29,7 @@ fn void test_write_0b1111() { fn void test_write_0b1111_1111() { ByteWriter w; - w.temp_init(); + w.tinit(); BitWriter bw; bw.init(&w); @@ -42,7 +42,7 @@ fn void test_write_0b1111_1111() { fn void test_write_0b1000() { ByteWriter w; - w.temp_init(); + w.tinit(); BitWriter bw; bw.init(&w); @@ -55,7 +55,7 @@ fn void test_write_0b1000() { fn void test_write_0b01000() { ByteWriter w; - w.temp_init(); + w.tinit(); BitWriter bw; bw.init(&w); @@ -68,7 +68,7 @@ fn void test_write_0b01000() { fn void test_write_0b0001() { ByteWriter w; - w.temp_init(); + w.tinit(); BitWriter bw; bw.init(&w); @@ -82,7 +82,7 @@ fn void test_write_0b0001() { fn void test_write_0b0000_0001() { ByteWriter w; - w.temp_init(); + w.tinit(); BitWriter bw; bw.init(&w); @@ -95,7 +95,7 @@ fn void test_write_0b0000_0001() { fn void test_write_10_bits() { ByteWriter w; - w.temp_init(); + w.tinit(); BitWriter bw; bw.init(&w); @@ -109,7 +109,7 @@ fn void test_write_10_bits() { fn void test_write_16_bits() { ByteWriter w; - w.temp_init(); + w.tinit(); BitWriter bw; bw.init(&w); @@ -122,7 +122,7 @@ fn void test_write_16_bits() { fn void test_write_24_bits() { ByteWriter w; - w.temp_init(); + w.tinit(); BitWriter bw; bw.init(&w); @@ -135,7 +135,7 @@ fn void test_write_24_bits() { fn void test_write_30_bits() { ByteWriter w; - w.temp_init(); + w.tinit(); BitWriter bw; bw.init(&w); @@ -148,7 +148,7 @@ fn void test_write_30_bits() { fn void test_write_32_bits() { ByteWriter w; - w.temp_init(); + w.tinit(); BitWriter bw; bw.init(&w); @@ -161,7 +161,7 @@ fn void test_write_32_bits() { fn void test_write_2_bits_multiple() { ByteWriter w; - w.temp_init(); + w.tinit(); BitWriter bw; bw.init(&w); @@ -176,7 +176,7 @@ fn void test_write_2_bits_multiple() { fn void test_write_10_bits_multiple() { ByteWriter w; - w.temp_init(); + w.tinit(); BitWriter bw; bw.init(&w); @@ -192,7 +192,7 @@ fn void test_write_10_bits_multiple() { fn void test_write_24_bits_multiple() { ByteWriter w; - w.temp_init(); + w.tinit(); BitWriter bw; bw.init(&w); @@ -206,7 +206,7 @@ fn void test_write_24_bits_multiple() { fn void test_write_30_bits_multiple() { ByteWriter w; - w.temp_init(); + w.tinit(); BitWriter bw; bw.init(&w); @@ -220,7 +220,7 @@ fn void test_write_30_bits_multiple() { fn void test_write_32_bits_multiple() { ByteWriter w; - w.temp_init(); + w.tinit(); BitWriter bw; bw.init(&w); @@ -234,7 +234,7 @@ fn void test_write_32_bits_multiple() { fn void test_write_mixed_multiple() { ByteWriter w; - w.temp_init(); + w.tinit(); BitWriter bw; bw.init(&w); diff --git a/test/unit/stdlib/io/bufferstream.c3 b/test/unit/stdlib/io/bufferstream.c3 index 76a3b0d89..a308d03e3 100644 --- a/test/unit/stdlib/io/bufferstream.c3 +++ b/test/unit/stdlib/io/bufferstream.c3 @@ -27,7 +27,7 @@ fn void readbuffer() reader_buf.init(&src, buf[..]); ByteWriter bw; - bw.temp_init(); + bw.tinit(); usz n = io::copy_to(&reader_buf, &bw)!!; @@ -39,7 +39,7 @@ fn void readbuffer() fn void writebuffer_large() { ByteWriter out; - out.temp_init(); + out.tinit(); char[16] buf; WriteBuffer write_buf; write_buf.init(&out, buf[..]); @@ -56,7 +56,7 @@ fn void writebuffer() ByteReader br; br.init(DATA); ByteWriter out; - out.temp_init(); + out.tinit(); char[3] buf; WriteBuffer write_buf; write_buf.init(&out, buf[..]); @@ -71,7 +71,7 @@ fn void writebuffer() fn void writebuffer_write_byte() { ByteWriter out; - out.temp_init(); + out.tinit(); char[2] buf; WriteBuffer write_buf; write_buf.init(&out, buf[..]); diff --git a/test/unit/stdlib/io/bytebuffer.c3 b/test/unit/stdlib/io/bytebuffer.c3 index eafbe9ec9..a83669c5b 100644 --- a/test/unit/stdlib/io/bytebuffer.c3 +++ b/test/unit/stdlib/io/bytebuffer.c3 @@ -4,7 +4,7 @@ import std::io; fn void write_read() { ByteBuffer buffer; - buffer.new_init(0); + buffer.init(mem, 0); defer buffer.free(); buffer.write("hello")!!; diff --git a/test/unit/stdlib/io/bytestream.c3 b/test/unit/stdlib/io/bytestream.c3 index 3c9384090..d88f9db4d 100644 --- a/test/unit/stdlib/io/bytestream.c3 +++ b/test/unit/stdlib/io/bytestream.c3 @@ -12,7 +12,7 @@ fn void bytestream() usz len = s.read(&buffer)!!; assert((String)buffer[:len] == "abc"); ByteWriter w; - w.new_init(); + w.init(mem); defer (void)w.destroy(); OutStream ws = &w; ws.write("helloworld")!!; @@ -44,7 +44,7 @@ fn void bytewriter_read_from() InStream s = &r; ByteWriter bw; - bw.temp_init(); + bw.tinit(); bw.read_from(s)!!; assert(bw.str_view() == data); diff --git a/test/unit/stdlib/io/dstringstream.c3 b/test/unit/stdlib/io/dstringstream.c3 index adc101bc1..aa7bfaf33 100644 --- a/test/unit/stdlib/io/dstringstream.c3 +++ b/test/unit/stdlib/io/dstringstream.c3 @@ -3,7 +3,7 @@ module std::io @test; fn void test_writing() { DString foo; - foo.new_init(); + foo.init(mem); defer foo.free(); OutStream s = &foo; s.write("hello")!!; diff --git a/test/unit/stdlib/io/multireader.c3 b/test/unit/stdlib/io/multireader.c3 index 747f9b219..b4c054d36 100644 --- a/test/unit/stdlib/io/multireader.c3 +++ b/test/unit/stdlib/io/multireader.c3 @@ -3,7 +3,7 @@ module std::io @test; fn void test_multireader() { MultiReader mr; - mr.temp_init( + mr.init(mem, &&wrap_bytes("foo"), &&wrap_bytes(" "), &&wrap_bytes("bar"), @@ -12,7 +12,7 @@ fn void test_multireader() defer mr.free(); ByteWriter w; - io::copy_to(&mr, w.temp_init())!!; + io::copy_to(&mr, w.tinit())!!; String want = "foo bar!"; assert(w.str_view() == want, diff --git a/test/unit/stdlib/io/multiwriter.c3 b/test/unit/stdlib/io/multiwriter.c3 index 8261bab34..2bf5d0295 100644 --- a/test/unit/stdlib/io/multiwriter.c3 +++ b/test/unit/stdlib/io/multiwriter.c3 @@ -4,7 +4,7 @@ fn void test_multiwriter() { ByteWriter w1, w2; MultiWriter mw; - mw.temp_init(w1.temp_init(), w2.temp_init()); + mw.tinit(w1.tinit(), w2.tinit()); defer mw.free(); String want = "foobar"; diff --git a/test/unit/stdlib/io/stream.c3 b/test/unit/stdlib/io/stream.c3 index 14e960d66..74fe81d65 100644 --- a/test/unit/stdlib/io/stream.c3 +++ b/test/unit/stdlib/io/stream.c3 @@ -27,7 +27,7 @@ fn void read_uint128_test() fn void write_ushort_test() { ByteWriter bw; - bw.temp_init(); + bw.tinit(); io::write_be_short(&bw, 0x348a)!!; assert(bw.str_view() == &&x'348a'); } @@ -35,7 +35,7 @@ fn void write_ushort_test() fn void write_uint_test() { ByteWriter bw; - bw.temp_init(); + bw.tinit(); io::write_be_int(&bw, 0x3421348a)!!; assert(bw.str_view() == &&x'3421348a'); } @@ -43,7 +43,7 @@ fn void write_uint_test() fn void write_ulong_test() { ByteWriter bw; - bw.temp_init(); + bw.tinit(); io::write_be_long(&bw, 0xaabbccdd3421348a)!!; assert(bw.str_view() == &&x'aabbccdd3421348a'); } @@ -51,7 +51,7 @@ fn void write_ulong_test() fn void write_uint128_test() { ByteWriter bw; - bw.temp_init(); + bw.tinit(); io::write_be_int128(&bw, 0xaabbccdd3421348aaabbccdd3421348a)!!; assert(bw.str_view() == &&x'aabbccdd3421348aaabbccdd3421348a'); } @@ -59,7 +59,7 @@ fn void write_uint128_test() fn void write_tiny_bytearray_test() { ByteWriter bw; - bw.temp_init(); + bw.tinit(); io::write_tiny_bytearray(&bw, &&x"aabbcc00112233")!!; assert(bw.str_view() == &&x'07aabbcc00112233'); } @@ -67,7 +67,7 @@ fn void write_tiny_bytearray_test() fn void write_short_bytearray_test() { ByteWriter bw; - bw.temp_init(); + bw.tinit(); io::write_short_bytearray(&bw, &&x"aabbcc00112233")!!; assert(bw.str_view() == &&x'0007aabbcc00112233'); } diff --git a/test/unit/stdlib/io/teereader.c3 b/test/unit/stdlib/io/teereader.c3 index c76181f5f..5e07b4447 100644 --- a/test/unit/stdlib/io/teereader.c3 +++ b/test/unit/stdlib/io/teereader.c3 @@ -5,7 +5,7 @@ fn void test_teereader() String want = "foobar"; ByteWriter w; - TeeReader r = tee_reader((ByteReader){}.init(want), w.temp_init()); + TeeReader r = tee_reader((ByteReader){}.init(want), w.tinit()); char[16] buf; usz n = r.read(buf[..])!!; diff --git a/test/unit/stdlib/sort/countingsort.c3 b/test/unit/stdlib/sort/countingsort.c3 index a43997918..563715993 100644 --- a/test/unit/stdlib/sort/countingsort.c3 +++ b/test/unit/stdlib/sort/countingsort.c3 @@ -77,7 +77,7 @@ module sort_test @test; fn void countingsort_list() { CountingSortTestList list; - list.temp_init(); + list.tinit(); list.add_array({ 2, 1, 3}); sort::countingsort(list, &sort::key_int_value); assert(check::int_ascending_sort(list.array_view())); diff --git a/test/unit/stdlib/sort/insertionsort.c3 b/test/unit/stdlib/sort/insertionsort.c3 index 32b3539a4..568abc228 100644 --- a/test/unit/stdlib/sort/insertionsort.c3 +++ b/test/unit/stdlib/sort/insertionsort.c3 @@ -83,7 +83,7 @@ def InsertionSortTestList = List(); fn void insertionsort_list() { InsertionSortTestList list; - list.temp_init(); + list.tinit(); list.add_array({ 2, 1, 3}); sort::insertionsort(list, &sort::cmp_int_value); assert(check::int_ascending_sort(list.array_view())); diff --git a/test/unit/stdlib/sort/quicksort.c3 b/test/unit/stdlib/sort/quicksort.c3 index b2810bb36..177e2ea1f 100644 --- a/test/unit/stdlib/sort/quicksort.c3 +++ b/test/unit/stdlib/sort/quicksort.c3 @@ -83,7 +83,7 @@ def List = List(); fn void quicksort_list() { List list; - list.temp_init(); + list.tinit(); list.add_array({ 2, 1, 3}); sort::quicksort(list, &sort::cmp_int_value); assert(check::int_sort(list.array_view())); diff --git a/test/unit/stdlib/threads/channel.c3 b/test/unit/stdlib/threads/channel.c3 index 1ba742cdb..8b15ade54 100644 --- a/test/unit/stdlib/threads/channel.c3 +++ b/test/unit/stdlib/threads/channel.c3 @@ -20,7 +20,7 @@ fn void init_destroy_unbuffered() @test for (usz i = 0; i < 20; i++) { UnbufferedChannel() c; - c.new_init()!!; + c.init(mem)!!; defer c.destroy()!!; } } @@ -37,7 +37,7 @@ fn void push_to_buffered_channel_no_lock() @test fn void push_pop_buffered_no_locks() @test { BufferedChannel() c; - c.new_init(1)!!; + c.init(mem, 1)!!; defer c.destroy()!!; c.push(123)!!; @@ -48,7 +48,7 @@ fn void push_pop_buffered_no_locks() @test fn void push_pop_unbuffered_with_locks() @test { UnbufferedChannel() c; - c.new_init()!!; + c.init(mem)!!; defer c.destroy()!!; Thread thread; @@ -71,7 +71,7 @@ fn void push_pop_unbuffered_with_locks() @test fn void sending_to_closed_unbuffered_chan_is_forbidden() @test { UnbufferedChannel() c; - c.new_init()!!; + c.init(mem)!!; defer c.destroy()!!; c.close()!!; @@ -87,7 +87,7 @@ fn void sending_to_closed_unbuffered_chan_is_forbidden() @test fn void sending_to_closed_buffered_chan_is_forbidden() @test { BufferedChannel() c; - c.new_init(1)!!; + c.init(mem, 1)!!; defer c.destroy()!!; c.close()!!; @@ -103,7 +103,7 @@ fn void sending_to_closed_buffered_chan_is_forbidden() @test fn void reading_from_empty_closed_unbuffered_chan_is_forbidden() @test { UnbufferedChannel() c; - c.new_init()!!; + c.init(mem)!!; defer c.destroy()!!; c.close()!!; @@ -119,7 +119,7 @@ fn void reading_from_empty_closed_unbuffered_chan_is_forbidden() @test fn void reading_from_empty_closed_buffered_chan_is_forbidden() @test { BufferedChannel() c; - c.new_init(1)!!; + c.init(mem, 1)!!; defer c.destroy()!!; c.close()!!; @@ -135,7 +135,7 @@ fn void reading_from_empty_closed_buffered_chan_is_forbidden() @test fn void reading_from_non_empty_closed_buffered_chan_is_ok() @test { BufferedChannel() c; - c.new_init(3)!!; + c.init(mem, 3)!!; defer c.destroy()!!; c.push(1)!!; @@ -164,7 +164,7 @@ fn void reading_from_non_empty_closed_buffered_chan_is_ok() @test fn void reading_from_empty_buffered_chan_aborted_by_close() @test { BufferedChannel() c; - c.new_init(3)!!; + c.init(mem, 3)!!; defer c.destroy()!!; Thread thread; @@ -190,7 +190,7 @@ fn void reading_from_empty_buffered_chan_aborted_by_close() @test fn void reading_from_unbuffered_chan_aborted_by_close() @test { UnbufferedChannel() c; - c.new_init()!!; + c.init(mem)!!; defer c.destroy()!!; Thread thread; @@ -216,7 +216,7 @@ fn void reading_from_unbuffered_chan_aborted_by_close() @test fn void sending_to_full_buffered_chan_aborted_by_close() @test { BufferedChannel() c; - c.new_init(1)!!; + c.init(mem, 1)!!; defer c.destroy()!!; c.push(1)!!; @@ -244,7 +244,7 @@ fn void sending_to_full_buffered_chan_aborted_by_close() @test fn void sending_to_unbuffered_chan_aborted_by_close() @test { UnbufferedChannel() c; - c.new_init()!!; + c.init(mem, )!!; defer c.destroy()!!; Thread thread; @@ -270,7 +270,7 @@ fn void sending_to_unbuffered_chan_aborted_by_close() @test fn void multiple_actions_unbuffered() @test { UnbufferedChannel() c; - c.new_init()!!; + c.init(mem, )!!; defer c.destroy()!!; Thread thread; @@ -304,7 +304,7 @@ fn void multiple_actions_unbuffered() @test fn void multiple_actions_buffered() @test { BufferedChannel() c; - c.new_init(10)!!; + c.init(mem, 10)!!; defer c.destroy()!!; Thread thread;