mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
More deprecations in lib6, and updates to lib7
This commit is contained in:
@@ -21,7 +21,7 @@ struct AnyList (Printable)
|
|||||||
|
|
||||||
@param initial_capacity "The initial capacity to reserve"
|
@param initial_capacity "The initial capacity to reserve"
|
||||||
*>
|
*>
|
||||||
fn AnyList* AnyList.new_init(&self, usz initial_capacity = 16, Allocator allocator = null)
|
fn AnyList* AnyList.new_init(&self, usz initial_capacity = 16, Allocator allocator = null) @deprecated("Use init(mem)")
|
||||||
{
|
{
|
||||||
return self.init(allocator ?: allocator::heap(), initial_capacity) @inline;
|
return self.init(allocator ?: allocator::heap(), initial_capacity) @inline;
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,18 @@ fn AnyList* AnyList.init(&self, Allocator allocator, usz initial_capacity = 16)
|
|||||||
|
|
||||||
@param initial_capacity "The initial capacity to reserve"
|
@param initial_capacity "The initial capacity to reserve"
|
||||||
*>
|
*>
|
||||||
fn AnyList* AnyList.temp_init(&self, usz initial_capacity = 16)
|
fn AnyList* AnyList.temp_init(&self, usz initial_capacity = 16) @deprecated("Use tinit")
|
||||||
|
{
|
||||||
|
return self.init(allocator::temp(), initial_capacity) @inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
<*
|
||||||
|
Initialize the list using the temp allocator.
|
||||||
|
|
||||||
|
@param initial_capacity "The initial capacity to reserve"
|
||||||
|
*>
|
||||||
|
fn AnyList* AnyList.tinit(&self, usz initial_capacity = 16)
|
||||||
{
|
{
|
||||||
return self.init(allocator::temp(), initial_capacity) @inline;
|
return self.init(allocator::temp(), initial_capacity) @inline;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,15 +86,30 @@ struct GrowableBitSet
|
|||||||
@param initial_capacity
|
@param initial_capacity
|
||||||
@param [&inout] allocator "The allocator to use, defaults to the heap allocator"
|
@param [&inout] allocator "The allocator to use, defaults to the heap allocator"
|
||||||
*>
|
*>
|
||||||
fn GrowableBitSet* GrowableBitSet.new_init(&self, usz initial_capacity = 1, Allocator allocator = allocator::heap())
|
fn GrowableBitSet* GrowableBitSet.new_init(&self, usz initial_capacity = 1, Allocator allocator = allocator::heap()) @deprecated("Use init(mem)")
|
||||||
{
|
{
|
||||||
self.data.new_init(initial_capacity, allocator);
|
self.data.init(allocator, initial_capacity);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn GrowableBitSet* GrowableBitSet.temp_init(&self, usz initial_capacity = 1)
|
<*
|
||||||
|
@param initial_capacity
|
||||||
|
@param [&inout] allocator "The allocator to use, defaults to the heap allocator"
|
||||||
|
*>
|
||||||
|
fn GrowableBitSet* GrowableBitSet.init(&self, Allocator allocator, usz initial_capacity = 1)
|
||||||
{
|
{
|
||||||
return self.new_init(initial_capacity, allocator::temp()) @inline;
|
self.data.init(allocator, initial_capacity);
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn GrowableBitSet* GrowableBitSet.temp_init(&self, usz initial_capacity = 1) @deprecated("Use tinit()")
|
||||||
|
{
|
||||||
|
return self.init(allocator::temp(), initial_capacity) @inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn GrowableBitSet* GrowableBitSet.tinit(&self, usz initial_capacity = 1)
|
||||||
|
{
|
||||||
|
return self.init(allocator::temp(), initial_capacity) @inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn void GrowableBitSet.free(&self)
|
fn void GrowableBitSet.free(&self)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ struct HashMap (Printable)
|
|||||||
@require !self.allocator "Map was already initialized"
|
@require !self.allocator "Map was already initialized"
|
||||||
@require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
@require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
||||||
*>
|
*>
|
||||||
fn HashMap* HashMap.new_init(&self, uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR, Allocator allocator = null)
|
fn HashMap* HashMap.new_init(&self, uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR, Allocator allocator = null) @deprecated("Use init(mem)")
|
||||||
{
|
{
|
||||||
return self.init(allocator ?: allocator::heap(), capacity, load_factor);
|
return self.init(allocator ?: allocator::heap(), capacity, load_factor);
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,18 @@ fn HashMap* HashMap.init(&self, Allocator allocator, uint capacity = DEFAULT_INI
|
|||||||
@require !self.allocator "Map was already initialized"
|
@require !self.allocator "Map was already initialized"
|
||||||
@require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
@require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
||||||
*>
|
*>
|
||||||
fn HashMap* HashMap.temp_init(&self, uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR)
|
fn HashMap* HashMap.temp_init(&self, uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR) @deprecated("Use tinit()")
|
||||||
|
{
|
||||||
|
return self.init(allocator::temp(), capacity, load_factor) @inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
<*
|
||||||
|
@require capacity > 0 "The capacity must be 1 or higher"
|
||||||
|
@require load_factor > 0.0 "The load factor must be higher than 0"
|
||||||
|
@require !self.allocator "Map was already initialized"
|
||||||
|
@require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
||||||
|
*>
|
||||||
|
fn HashMap* HashMap.tinit(&self, uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR)
|
||||||
{
|
{
|
||||||
return self.init(allocator::temp(), capacity, load_factor) @inline;
|
return self.init(allocator::temp(), capacity, load_factor) @inline;
|
||||||
}
|
}
|
||||||
@@ -65,9 +76,9 @@ fn HashMap* HashMap.temp_init(&self, uint capacity = DEFAULT_INITIAL_CAPACITY, f
|
|||||||
@require !self.allocator "Map was already initialized"
|
@require !self.allocator "Map was already initialized"
|
||||||
@require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
@require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
||||||
*>
|
*>
|
||||||
macro HashMap* HashMap.new_init_with_key_values(&self, ..., uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR, Allocator allocator = allocator::heap())
|
macro HashMap* HashMap.new_init_with_key_values(&self, ..., uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR, Allocator allocator = allocator::heap()) @deprecated("Use init_with_key_values(mem)")
|
||||||
{
|
{
|
||||||
self.new_init(capacity, load_factor, allocator);
|
self.init(capacity, load_factor, allocator);
|
||||||
$for (var $i = 0; $i < $vacount; $i += 2)
|
$for (var $i = 0; $i < $vacount; $i += 2)
|
||||||
self.set($vaarg[$i], $vaarg[$i+1]);
|
self.set($vaarg[$i], $vaarg[$i+1]);
|
||||||
$endfor
|
$endfor
|
||||||
@@ -84,10 +95,10 @@ macro HashMap* HashMap.new_init_with_key_values(&self, ..., uint capacity = DEFA
|
|||||||
@require !self.allocator "Map was already initialized"
|
@require !self.allocator "Map was already initialized"
|
||||||
@require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
@require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
||||||
*>
|
*>
|
||||||
fn HashMap* HashMap.new_init_from_keys_and_values(&self, Key[] keys, Value[] values, uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR, Allocator allocator = allocator::heap())
|
fn HashMap* HashMap.new_init_from_keys_and_values(&self, Key[] keys, Value[] values, uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR, Allocator allocator = allocator::heap()) @deprecated("Use init_from_keys_and_values(mem)")
|
||||||
{
|
{
|
||||||
assert(keys.len == values.len);
|
assert(keys.len == values.len);
|
||||||
self.new_init(capacity, load_factor, allocator);
|
self.init(allocator, capacity, load_factor);
|
||||||
for (usz i = 0; i < keys.len; i++)
|
for (usz i = 0; i < keys.len; i++)
|
||||||
{
|
{
|
||||||
self.set(keys[i], values[i]);
|
self.set(keys[i], values[i]);
|
||||||
@@ -102,9 +113,25 @@ fn HashMap* HashMap.new_init_from_keys_and_values(&self, Key[] keys, Value[] val
|
|||||||
@require !self.allocator "Map was already initialized"
|
@require !self.allocator "Map was already initialized"
|
||||||
@require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
@require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
||||||
*>
|
*>
|
||||||
macro HashMap* HashMap.temp_init_with_key_values(&self, ..., uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR)
|
macro HashMap* HashMap.temp_init_with_key_values(&self, ..., uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR) @deprecated("Use tinit_with_key_values")
|
||||||
{
|
{
|
||||||
self.temp_init(capacity, load_factor);
|
self.tinit(capacity, load_factor);
|
||||||
|
$for (var $i = 0; $i < $vacount; $i += 2)
|
||||||
|
self.set($vaarg[$i], $vaarg[$i+1]);
|
||||||
|
$endfor
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
<*
|
||||||
|
@require $vacount % 2 == 0 "There must be an even number of arguments provided for keys and values"
|
||||||
|
@require capacity > 0 "The capacity must be 1 or higher"
|
||||||
|
@require load_factor > 0.0 "The load factor must be higher than 0"
|
||||||
|
@require !self.allocator "Map was already initialized"
|
||||||
|
@require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
||||||
|
*>
|
||||||
|
macro HashMap* HashMap.tinit_with_key_values(&self, ..., uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR)
|
||||||
|
{
|
||||||
|
self.tinit(capacity, load_factor);
|
||||||
$for (var $i = 0; $i < $vacount; $i += 2)
|
$for (var $i = 0; $i < $vacount; $i += 2)
|
||||||
self.set($vaarg[$i], $vaarg[$i+1]);
|
self.set($vaarg[$i], $vaarg[$i+1]);
|
||||||
$endfor
|
$endfor
|
||||||
@@ -121,10 +148,31 @@ macro HashMap* HashMap.temp_init_with_key_values(&self, ..., uint capacity = DEF
|
|||||||
@require !self.allocator "Map was already initialized"
|
@require !self.allocator "Map was already initialized"
|
||||||
@require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
@require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
||||||
*>
|
*>
|
||||||
fn HashMap* HashMap.temp_init_from_keys_and_values(&self, Key[] keys, Value[] values, uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR, Allocator allocator = allocator::heap())
|
fn HashMap* HashMap.temp_init_from_keys_and_values(&self, Key[] keys, Value[] values, uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR, Allocator allocator = allocator::heap()) @deprecated("Use tinit_from_keys_and_values")
|
||||||
{
|
{
|
||||||
assert(keys.len == values.len);
|
assert(keys.len == values.len);
|
||||||
self.temp_init(capacity, load_factor);
|
self.tinit(capacity, load_factor);
|
||||||
|
for (usz i = 0; i < keys.len; i++)
|
||||||
|
{
|
||||||
|
self.set(keys[i], values[i]);
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
<*
|
||||||
|
@param [in] keys "The keys for the HashMap entries"
|
||||||
|
@param [in] values "The values for the HashMap entries"
|
||||||
|
@param [&inout] allocator "The allocator to use"
|
||||||
|
@require keys.len == values.len "Both keys and values arrays must be the same length"
|
||||||
|
@require capacity > 0 "The capacity must be 1 or higher"
|
||||||
|
@require load_factor > 0.0 "The load factor must be higher than 0"
|
||||||
|
@require !self.allocator "Map was already initialized"
|
||||||
|
@require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
||||||
|
*>
|
||||||
|
fn HashMap* HashMap.tinit_from_keys_and_values(&self, Key[] keys, Value[] values, uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR, Allocator allocator = allocator::heap())
|
||||||
|
{
|
||||||
|
assert(keys.len == values.len);
|
||||||
|
self.tinit(capacity, load_factor);
|
||||||
for (usz i = 0; i < keys.len; i++)
|
for (usz i = 0; i < keys.len; i++)
|
||||||
{
|
{
|
||||||
self.set(keys[i], values[i]);
|
self.set(keys[i], values[i]);
|
||||||
@@ -146,18 +194,18 @@ fn bool HashMap.is_initialized(&map)
|
|||||||
<*
|
<*
|
||||||
@param [&in] other_map "The map to copy from."
|
@param [&in] other_map "The map to copy from."
|
||||||
*>
|
*>
|
||||||
fn HashMap* HashMap.new_init_from_map(&self, HashMap* other_map)
|
fn HashMap* HashMap.new_init_from_map(&self, HashMap* other_map) @deprecated("Use init_from_map(mem, map)")
|
||||||
{
|
{
|
||||||
return self.init_from_map(other_map, allocator::heap()) @inline;
|
return self.init_from_map(allocator::heap(), other_map) @inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
<*
|
<*
|
||||||
@param [&inout] allocator "The allocator to use"
|
@param [&inout] allocator "The allocator to use"
|
||||||
@param [&in] other_map "The map to copy from."
|
@param [&in] other_map "The map to copy from."
|
||||||
*>
|
*>
|
||||||
fn HashMap* HashMap.init_from_map(&self, HashMap* other_map, Allocator allocator)
|
fn HashMap* HashMap.init_from_map(&self, Allocator allocator, HashMap* other_map)
|
||||||
{
|
{
|
||||||
self.new_init(other_map.table.len, other_map.load_factor, allocator);
|
self.init(allocator, other_map.table.len, other_map.load_factor);
|
||||||
self.put_all_for_create(other_map);
|
self.put_all_for_create(other_map);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@@ -165,9 +213,17 @@ fn HashMap* HashMap.init_from_map(&self, HashMap* other_map, Allocator allocator
|
|||||||
<*
|
<*
|
||||||
@param [&in] other_map "The map to copy from."
|
@param [&in] other_map "The map to copy from."
|
||||||
*>
|
*>
|
||||||
fn HashMap* HashMap.temp_init_from_map(&map, HashMap* other_map)
|
fn HashMap* HashMap.temp_init_from_map(&map, HashMap* other_map) @deprecated("Use tinit_from_map")
|
||||||
{
|
{
|
||||||
return map.init_from_map(other_map, allocator::temp()) @inline;
|
return map.init_from_map(allocator::temp(), other_map) @inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
<*
|
||||||
|
@param [&in] other_map "The map to copy from."
|
||||||
|
*>
|
||||||
|
fn HashMap* HashMap.tinit_from_map(&map, HashMap* other_map)
|
||||||
|
{
|
||||||
|
return map.init_from_map(allocator::temp(), other_map) @inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bool HashMap.is_empty(&map) @inline
|
fn bool HashMap.is_empty(&map) @inline
|
||||||
@@ -240,7 +296,7 @@ fn bool HashMap.set(&map, Key key, Value value) @operator([]=)
|
|||||||
// If the map isn't initialized, use the defaults to initialize it.
|
// If the map isn't initialized, use the defaults to initialize it.
|
||||||
if (!map.allocator)
|
if (!map.allocator)
|
||||||
{
|
{
|
||||||
map.new_init();
|
map.init(allocator::heap());
|
||||||
}
|
}
|
||||||
uint hash = rehash(key.hash());
|
uint hash = rehash(key.hash());
|
||||||
uint index = index_for(hash, map.table.len);
|
uint index = index_for(hash, map.table.len);
|
||||||
|
|||||||
@@ -33,13 +33,18 @@ fn LinkedList* LinkedList.init(&self, Allocator allocator)
|
|||||||
<*
|
<*
|
||||||
@return "the initialized list"
|
@return "the initialized list"
|
||||||
*>
|
*>
|
||||||
fn LinkedList* LinkedList.new_init(&self)
|
fn LinkedList* LinkedList.new_init(&self) @deprecated("Use init(mem)")
|
||||||
{
|
{
|
||||||
return self.init(allocator::heap()) @inline;
|
return self.init(allocator::heap()) @inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn LinkedList* LinkedList.temp_init(&self)
|
fn LinkedList* LinkedList.temp_init(&self) @deprecated("Use tinit()")
|
||||||
|
{
|
||||||
|
return self.init(allocator::temp()) @inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn LinkedList* LinkedList.tinit(&self)
|
||||||
{
|
{
|
||||||
return self.init(allocator::temp()) @inline;
|
return self.init(allocator::temp()) @inline;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ fn List* List.init(&self, Allocator allocator, usz initial_capacity = 16)
|
|||||||
@param initial_capacity "The initial capacity to reserve"
|
@param initial_capacity "The initial capacity to reserve"
|
||||||
@param [&inout] allocator "The allocator to use, defaults to the heap allocator"
|
@param [&inout] allocator "The allocator to use, defaults to the heap allocator"
|
||||||
*>
|
*>
|
||||||
fn List* List.new_init(&self, usz initial_capacity = 16, Allocator allocator = allocator::heap())
|
fn List* List.new_init(&self, usz initial_capacity = 16, Allocator allocator = allocator::heap()) @deprecated("Use init(mem)")
|
||||||
{
|
{
|
||||||
self.allocator = allocator;
|
self.allocator = allocator;
|
||||||
self.size = 0;
|
self.size = 0;
|
||||||
@@ -52,7 +52,17 @@ fn List* List.new_init(&self, usz initial_capacity = 16, Allocator allocator = a
|
|||||||
|
|
||||||
@param initial_capacity "The initial capacity to reserve"
|
@param initial_capacity "The initial capacity to reserve"
|
||||||
*>
|
*>
|
||||||
fn List* List.temp_init(&self, usz initial_capacity = 16)
|
fn List* List.temp_init(&self, usz initial_capacity = 16) @deprecated("Use tinit()")
|
||||||
|
{
|
||||||
|
return self.init(allocator::temp(), initial_capacity) @inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
<*
|
||||||
|
Initialize the list using the temp allocator.
|
||||||
|
|
||||||
|
@param initial_capacity "The initial capacity to reserve"
|
||||||
|
*>
|
||||||
|
fn List* List.tinit(&self, usz initial_capacity = 16)
|
||||||
{
|
{
|
||||||
return self.init(allocator::temp(), initial_capacity) @inline;
|
return self.init(allocator::temp(), initial_capacity) @inline;
|
||||||
}
|
}
|
||||||
@@ -63,9 +73,20 @@ fn List* List.temp_init(&self, usz initial_capacity = 16)
|
|||||||
@param [in] values `The values to initialize the list with.`
|
@param [in] values `The values to initialize the list with.`
|
||||||
@require self.size == 0 "The List must be empty"
|
@require self.size == 0 "The List must be empty"
|
||||||
*>
|
*>
|
||||||
fn List* List.new_init_with_array(&self, Type[] values, Allocator allocator = allocator::heap())
|
fn List* List.new_init_with_array(&self, Type[] values, Allocator allocator = allocator::heap()) @deprecated("Use init_with_array(mem)")
|
||||||
{
|
{
|
||||||
self.new_init(values.len, allocator) @inline;
|
return self.init_with_array(allocator, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
<*
|
||||||
|
Initialize a new list with an array.
|
||||||
|
|
||||||
|
@param [in] values `The values to initialize the list with.`
|
||||||
|
@require self.size == 0 "The List must be empty"
|
||||||
|
*>
|
||||||
|
fn List* List.init_with_array(&self, Allocator allocator, Type[] values)
|
||||||
|
{
|
||||||
|
self.init(allocator, values.len) @inline;
|
||||||
self.add_array(values) @inline;
|
self.add_array(values) @inline;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@@ -76,9 +97,22 @@ fn List* List.new_init_with_array(&self, Type[] values, Allocator allocator = al
|
|||||||
@param [in] values `The values to initialize the list with.`
|
@param [in] values `The values to initialize the list with.`
|
||||||
@require self.size == 0 "The List must be empty"
|
@require self.size == 0 "The List must be empty"
|
||||||
*>
|
*>
|
||||||
fn List* List.temp_init_with_array(&self, Type[] values)
|
fn List* List.temp_init_with_array(&self, Type[] values) @deprecated("Use tinit_with_array()")
|
||||||
{
|
{
|
||||||
self.temp_init(values.len) @inline;
|
self.tinit(values.len) @inline;
|
||||||
|
self.add_array(values) @inline;
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
<*
|
||||||
|
Initialize a temporary list with an array.
|
||||||
|
|
||||||
|
@param [in] values `The values to initialize the list with.`
|
||||||
|
@require self.size == 0 "The List must be empty"
|
||||||
|
*>
|
||||||
|
fn List* List.tinit_with_array(&self, Type[] values)
|
||||||
|
{
|
||||||
|
self.tinit(values.len) @inline;
|
||||||
self.add_array(values) @inline;
|
self.add_array(values) @inline;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ struct MapImpl
|
|||||||
@require load_factor > 0.0 "The load factor must be higher than 0"
|
@require load_factor > 0.0 "The load factor must be higher than 0"
|
||||||
@require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
@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())
|
fn Map new(uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR, Allocator allocator = allocator::heap()) @deprecated("Map is deprecated")
|
||||||
{
|
{
|
||||||
MapImpl* map = allocator::alloc(allocator, MapImpl);
|
MapImpl* map = allocator::alloc(allocator, MapImpl);
|
||||||
_init(map, capacity, load_factor, allocator);
|
_init(map, capacity, load_factor, allocator);
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ fn void Object.init_map_if_needed(&self) @private
|
|||||||
if (self.is_empty())
|
if (self.is_empty())
|
||||||
{
|
{
|
||||||
self.type = ObjectInternalMap.typeid;
|
self.type = ObjectInternalMap.typeid;
|
||||||
self.map.new_init(allocator: self.allocator);
|
self.map.init(self.allocator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ fn void Object.init_array_if_needed(&self) @private
|
|||||||
if (self.is_empty())
|
if (self.is_empty())
|
||||||
{
|
{
|
||||||
self.type = ObjectInternalList.typeid;
|
self.type = ObjectInternalList.typeid;
|
||||||
self.array.new_init(allocator: self.allocator);
|
self.array.init(self.allocator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ struct TrackingAllocator (Allocator)
|
|||||||
fn void TrackingAllocator.init(&self, Allocator allocator)
|
fn void TrackingAllocator.init(&self, Allocator allocator)
|
||||||
{
|
{
|
||||||
*self = { .inner_allocator = allocator };
|
*self = { .inner_allocator = allocator };
|
||||||
self.map.new_init(allocator: allocator);
|
self.map.init(allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
<*
|
<*
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ fn void panicf(String fmt, String file, String function, uint line, args...)
|
|||||||
@stack_mem(512; Allocator allocator)
|
@stack_mem(512; Allocator allocator)
|
||||||
{
|
{
|
||||||
DString s;
|
DString s;
|
||||||
s.new_init(allocator: allocator);
|
s.init(allocator);
|
||||||
s.appendf(fmt, ...args);
|
s.appendf(fmt, ...args);
|
||||||
in_panic = false;
|
in_panic = false;
|
||||||
panic(s.str_view(), file, function, line);
|
panic(s.str_view(), file, function, line);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const usz MIN_CAPACITY @private = 16;
|
|||||||
<*
|
<*
|
||||||
@require !self.data() "String already initialized"
|
@require !self.data() "String already initialized"
|
||||||
*>
|
*>
|
||||||
fn DString DString.new_init(&self, usz capacity = MIN_CAPACITY, Allocator allocator = allocator::heap())
|
fn DString DString.new_init(&self, usz capacity = MIN_CAPACITY, Allocator allocator = allocator::heap()) @deprecated("Use init(mem)")
|
||||||
{
|
{
|
||||||
if (capacity < MIN_CAPACITY) capacity = MIN_CAPACITY;
|
if (capacity < MIN_CAPACITY) capacity = MIN_CAPACITY;
|
||||||
StringData* data = allocator::alloc_with_padding(allocator, StringData, capacity)!!;
|
StringData* data = allocator::alloc_with_padding(allocator, StringData, capacity)!!;
|
||||||
@@ -22,15 +22,37 @@ fn DString DString.new_init(&self, usz capacity = MIN_CAPACITY, Allocator alloca
|
|||||||
<*
|
<*
|
||||||
@require !self.data() "String already initialized"
|
@require !self.data() "String already initialized"
|
||||||
*>
|
*>
|
||||||
fn DString DString.temp_init(&self, usz capacity = MIN_CAPACITY)
|
fn DString DString.init(&self, Allocator allocator, usz capacity = MIN_CAPACITY)
|
||||||
{
|
{
|
||||||
self.new_init(capacity, allocator::temp()) @inline;
|
if (capacity < MIN_CAPACITY) capacity = MIN_CAPACITY;
|
||||||
|
StringData* data = allocator::alloc_with_padding(allocator, StringData, capacity)!!;
|
||||||
|
data.allocator = allocator;
|
||||||
|
data.len = 0;
|
||||||
|
data.capacity = capacity;
|
||||||
|
return *self = (DString)data;
|
||||||
|
}
|
||||||
|
|
||||||
|
<*
|
||||||
|
@require !self.data() "String already initialized"
|
||||||
|
*>
|
||||||
|
fn DString DString.temp_init(&self, usz capacity = MIN_CAPACITY) @deprecated("Use tinit()")
|
||||||
|
{
|
||||||
|
self.init(allocator::temp(), capacity) @inline;
|
||||||
|
return *self;
|
||||||
|
}
|
||||||
|
|
||||||
|
<*
|
||||||
|
@require !self.data() "String already initialized"
|
||||||
|
*>
|
||||||
|
fn DString DString.tinit(&self, usz capacity = MIN_CAPACITY)
|
||||||
|
{
|
||||||
|
self.init(allocator::temp(), capacity) @inline;
|
||||||
return *self;
|
return *self;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn DString new_with_capacity(usz capacity, Allocator allocator = allocator::heap())
|
fn DString new_with_capacity(usz capacity, Allocator allocator = allocator::heap())
|
||||||
{
|
{
|
||||||
return (DString){}.new_init(capacity, allocator);
|
return (DString){}.init(allocator, capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn DString temp_with_capacity(usz capacity) => new_with_capacity(capacity, allocator::temp()) @inline;
|
fn DString temp_with_capacity(usz capacity) => new_with_capacity(capacity, allocator::temp()) @inline;
|
||||||
@@ -99,16 +121,25 @@ fn void DString.replace(&self, String needle, String replacement)
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn DString DString.new_concat(self, DString b, Allocator allocator = allocator::heap())
|
fn DString DString.new_concat(self, DString b, Allocator allocator = allocator::heap()) @deprecated("Use concat(mem)")
|
||||||
{
|
{
|
||||||
DString string;
|
DString string;
|
||||||
string.new_init(self.len() + b.len(), allocator);
|
string.init(allocator, self.len() + b.len());
|
||||||
string.append(self);
|
string.append(self);
|
||||||
string.append(b);
|
string.append(b);
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn DString DString.temp_concat(self, DString b) => self.new_concat(b, allocator::temp());
|
fn DString DString.concat(self, Allocator allocator, DString b)
|
||||||
|
{
|
||||||
|
DString string;
|
||||||
|
string.init(allocator, self.len() + b.len());
|
||||||
|
string.append(self);
|
||||||
|
string.append(b);
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn DString DString.temp_concat(self, DString b) => self.concat(allocator::temp(), b);
|
||||||
|
|
||||||
fn ZString DString.zstr_view(&self)
|
fn ZString DString.zstr_view(&self)
|
||||||
{
|
{
|
||||||
@@ -543,7 +574,7 @@ macro void DString.insert_at(&self, usz index, value)
|
|||||||
|
|
||||||
fn usz! DString.appendf(&self, String format, args...) @maydiscard
|
fn usz! DString.appendf(&self, String format, args...) @maydiscard
|
||||||
{
|
{
|
||||||
if (!self.data()) self.new_init(format.len + 20);
|
if (!self.data()) self.init(mem, format.len + 20);
|
||||||
@pool(self.data().allocator)
|
@pool(self.data().allocator)
|
||||||
{
|
{
|
||||||
Formatter formatter;
|
Formatter formatter;
|
||||||
@@ -554,7 +585,7 @@ fn usz! DString.appendf(&self, String format, args...) @maydiscard
|
|||||||
|
|
||||||
fn usz! DString.appendfn(&self, String format, args...) @maydiscard
|
fn usz! DString.appendfn(&self, String format, args...) @maydiscard
|
||||||
{
|
{
|
||||||
if (!self.data()) self.new_init(format.len + 20);
|
if (!self.data()) self.init(mem, format.len + 20);
|
||||||
@pool(self.data().allocator)
|
@pool(self.data().allocator)
|
||||||
{
|
{
|
||||||
Formatter formatter;
|
Formatter formatter;
|
||||||
|
|||||||
@@ -870,7 +870,7 @@ macro String new_struct_to_str(x, Allocator allocator = allocator::heap())
|
|||||||
DString s;
|
DString s;
|
||||||
@stack_mem(512; Allocator mem)
|
@stack_mem(512; Allocator mem)
|
||||||
{
|
{
|
||||||
s.new_init(allocator: mem);
|
s.init(mem);
|
||||||
io::fprint(&s, x)!!;
|
io::fprint(&s, x)!!;
|
||||||
return s.copy_str(allocator);
|
return s.copy_str(allocator);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ macro @check(#condition, String format = "", args...)
|
|||||||
@stack_mem(512; Allocator allocator)
|
@stack_mem(512; Allocator allocator)
|
||||||
{
|
{
|
||||||
DString s;
|
DString s;
|
||||||
s.new_init(allocator: allocator);
|
s.init(allocator);
|
||||||
s.appendf("check `%s` failed. ", $stringify(#condition));
|
s.appendf("check `%s` failed. ", $stringify(#condition));
|
||||||
s.appendf(format, ...args);
|
s.appendf(format, ...args);
|
||||||
print_panicf(s.str_view());
|
print_panicf(s.str_view());
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import std::io, std::os;
|
|||||||
fn PathList! native_ls(Path dir, bool no_dirs, bool no_symlinks, String mask, Allocator allocator)
|
fn PathList! native_ls(Path dir, bool no_dirs, bool no_symlinks, String mask, Allocator allocator)
|
||||||
{
|
{
|
||||||
PathList list;
|
PathList list;
|
||||||
list.new_init(allocator: allocator);
|
list.init(allocator);
|
||||||
DIRPtr directory = posix::opendir(dir.str_view() ? dir.as_zstr() : (ZString)".");
|
DIRPtr directory = posix::opendir(dir.str_view() ? dir.as_zstr() : (ZString)".");
|
||||||
defer if (directory) posix::closedir(directory);
|
defer if (directory) posix::closedir(directory);
|
||||||
if (!directory) return (path::is_dir(dir) ? IoError.CANNOT_READ_DIR : IoError.FILE_NOT_DIR)?;
|
if (!directory) return (path::is_dir(dir) ? IoError.CANNOT_READ_DIR : IoError.FILE_NOT_DIR)?;
|
||||||
@@ -27,7 +27,7 @@ import std::time, std::os, std::io;
|
|||||||
fn PathList! native_ls(Path dir, bool no_dirs, bool no_symlinks, String mask, Allocator allocator)
|
fn PathList! native_ls(Path dir, bool no_dirs, bool no_symlinks, String mask, Allocator allocator)
|
||||||
{
|
{
|
||||||
PathList list;
|
PathList list;
|
||||||
list.new_init(allocator: allocator);
|
list.init(allocator);
|
||||||
|
|
||||||
@pool(allocator)
|
@pool(allocator)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -80,7 +80,23 @@ macro usz! read_all(stream, char[] buffer)
|
|||||||
<*
|
<*
|
||||||
@require @is_instream(stream)
|
@require @is_instream(stream)
|
||||||
*>
|
*>
|
||||||
macro char[]! read_new_fully(stream, Allocator allocator = allocator::heap())
|
macro char[]! read_new_fully(stream, Allocator allocator = allocator::heap()) @deprecated("Use read_fully(mem)")
|
||||||
|
{
|
||||||
|
usz len = available(stream)!;
|
||||||
|
char* data = allocator::malloc_try(allocator, len)!;
|
||||||
|
defer catch allocator::free(allocator, data);
|
||||||
|
usz read = 0;
|
||||||
|
while (read < len)
|
||||||
|
{
|
||||||
|
read += stream.read(data[read:len - read])!;
|
||||||
|
}
|
||||||
|
return data[:len];
|
||||||
|
}
|
||||||
|
|
||||||
|
<*
|
||||||
|
@require @is_instream(stream)
|
||||||
|
*>
|
||||||
|
macro char[]! read_fully(Allocator allocator, stream)
|
||||||
{
|
{
|
||||||
usz len = available(stream)!;
|
usz len = available(stream)!;
|
||||||
char* data = allocator::malloc_try(allocator, len)!;
|
char* data = allocator::malloc_try(allocator, len)!;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ struct ByteBuffer (InStream, OutStream)
|
|||||||
max_read defines how many bytes might be kept before its internal buffer is shrinked.
|
max_read defines how many bytes might be kept before its internal buffer is shrinked.
|
||||||
@require self.bytes.len == 0 "Buffer already initialized."
|
@require self.bytes.len == 0 "Buffer already initialized."
|
||||||
*>
|
*>
|
||||||
fn ByteBuffer* ByteBuffer.new_init(&self, usz max_read, usz initial_capacity = 16, Allocator allocator = allocator::heap())
|
fn ByteBuffer* ByteBuffer.init(&self, Allocator allocator, usz max_read, usz initial_capacity = 16)
|
||||||
{
|
{
|
||||||
*self = { .allocator = allocator, .max_read = max_read };
|
*self = { .allocator = allocator, .max_read = max_read };
|
||||||
initial_capacity = max(initial_capacity, 16);
|
initial_capacity = max(initial_capacity, 16);
|
||||||
@@ -24,9 +24,27 @@ fn ByteBuffer* ByteBuffer.new_init(&self, usz max_read, usz initial_capacity = 1
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ByteBuffer* ByteBuffer.temp_init(&self, usz max_read, usz initial_capacity = 16)
|
<*
|
||||||
|
ByteBuffer provides a streamable read/write buffer.
|
||||||
|
max_read defines how many bytes might be kept before its internal buffer is shrinked.
|
||||||
|
@require self.bytes.len == 0 "Buffer already initialized."
|
||||||
|
*>
|
||||||
|
fn ByteBuffer* ByteBuffer.new_init(&self, usz max_read, usz initial_capacity = 16, Allocator allocator = allocator::heap()) @deprecated("Use init(mem)")
|
||||||
{
|
{
|
||||||
return self.new_init(max_read, initial_capacity, allocator::temp());
|
*self = { .allocator = allocator, .max_read = max_read };
|
||||||
|
initial_capacity = max(initial_capacity, 16);
|
||||||
|
self.grow(initial_capacity);
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ByteBuffer* ByteBuffer.tinit(&self, usz max_read, usz initial_capacity = 16)
|
||||||
|
{
|
||||||
|
return self.init(allocator::temp(), max_read, initial_capacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ByteBuffer* ByteBuffer.temp_init(&self, usz max_read, usz initial_capacity = 16) @deprecated("Use tinit()")
|
||||||
|
{
|
||||||
|
return self.init(allocator::temp(), max_read, initial_capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
<*
|
<*
|
||||||
|
|||||||
@@ -14,7 +14,19 @@ struct ByteWriter (OutStream)
|
|||||||
@require self.bytes.len == 0 "Init may not run on already initialized data"
|
@require self.bytes.len == 0 "Init may not run on already initialized data"
|
||||||
@ensure (bool)allocator, self.index == 0
|
@ensure (bool)allocator, self.index == 0
|
||||||
*>
|
*>
|
||||||
fn ByteWriter* ByteWriter.new_init(&self, Allocator allocator = allocator::heap())
|
fn ByteWriter* ByteWriter.new_init(&self, Allocator allocator = allocator::heap()) @deprecated("Use init(mem)")
|
||||||
|
{
|
||||||
|
*self = { .bytes = {}, .allocator = allocator };
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
<*
|
||||||
|
@param [&inout] self
|
||||||
|
@param [&inout] allocator
|
||||||
|
@require self.bytes.len == 0 "Init may not run on already initialized data"
|
||||||
|
@ensure (bool)allocator, self.index == 0
|
||||||
|
*>
|
||||||
|
fn ByteWriter* ByteWriter.init(&self, Allocator allocator)
|
||||||
{
|
{
|
||||||
*self = { .bytes = {}, .allocator = allocator };
|
*self = { .bytes = {}, .allocator = allocator };
|
||||||
return self;
|
return self;
|
||||||
@@ -25,9 +37,19 @@ fn ByteWriter* ByteWriter.new_init(&self, Allocator allocator = allocator::heap(
|
|||||||
@require self.bytes.len == 0 "Init may not run on already initialized data"
|
@require self.bytes.len == 0 "Init may not run on already initialized data"
|
||||||
@ensure self.index == 0
|
@ensure self.index == 0
|
||||||
*>
|
*>
|
||||||
fn ByteWriter* ByteWriter.temp_init(&self)
|
fn ByteWriter* ByteWriter.tinit(&self)
|
||||||
{
|
{
|
||||||
return self.new_init(allocator::temp()) @inline;
|
return self.init(allocator::temp()) @inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
<*
|
||||||
|
@param [&inout] self
|
||||||
|
@require self.bytes.len == 0 "Init may not run on already initialized data"
|
||||||
|
@ensure self.index == 0
|
||||||
|
*>
|
||||||
|
fn ByteWriter* ByteWriter.temp_init(&self) @deprecated("Use tinit")
|
||||||
|
{
|
||||||
|
return self.init(allocator::temp()) @inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ByteWriter* ByteWriter.init_with_buffer(&self, char[] data)
|
fn ByteWriter* ByteWriter.init_with_buffer(&self, char[] data)
|
||||||
|
|||||||
@@ -18,7 +18,21 @@ struct MultiReader (InStream)
|
|||||||
@require self.readers.len == 0 "Init may not run on already initialized data"
|
@require self.readers.len == 0 "Init may not run on already initialized data"
|
||||||
@ensure self.index == 0
|
@ensure self.index == 0
|
||||||
*>
|
*>
|
||||||
fn MultiReader* MultiReader.new_init(&self, InStream... readers, Allocator allocator = allocator::heap())
|
fn MultiReader* MultiReader.new_init(&self, InStream... readers, Allocator allocator = allocator::heap()) @deprecated("Use init(mem)")
|
||||||
|
{
|
||||||
|
InStream []copy = allocator::new_array(allocator, InStream, readers.len);
|
||||||
|
copy[..] = readers[..];
|
||||||
|
*self = { .readers = copy, .allocator = allocator };
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
<*
|
||||||
|
@param [&inout] self
|
||||||
|
@param [&inout] allocator
|
||||||
|
@require self.readers.len == 0 "Init may not run on already initialized data"
|
||||||
|
@ensure self.index == 0
|
||||||
|
*>
|
||||||
|
fn MultiReader* MultiReader.init(&self, Allocator allocator, InStream... readers)
|
||||||
{
|
{
|
||||||
InStream []copy = allocator::new_array(allocator, InStream, readers.len);
|
InStream []copy = allocator::new_array(allocator, InStream, readers.len);
|
||||||
copy[..] = readers[..];
|
copy[..] = readers[..];
|
||||||
@@ -31,9 +45,19 @@ fn MultiReader* MultiReader.new_init(&self, InStream... readers, Allocator alloc
|
|||||||
@require self.readers.len == 0 "Init may not run on already initialized data"
|
@require self.readers.len == 0 "Init may not run on already initialized data"
|
||||||
@ensure self.index == 0
|
@ensure self.index == 0
|
||||||
*>
|
*>
|
||||||
fn MultiReader* MultiReader.temp_init(&self, InStream... readers)
|
fn MultiReader* MultiReader.temp_init(&self, InStream... readers) @deprecated("Use tinit()")
|
||||||
{
|
{
|
||||||
return self.new_init(...readers, allocator: allocator::temp());
|
return self.init(allocator::temp(), ...readers);
|
||||||
|
}
|
||||||
|
|
||||||
|
<*
|
||||||
|
@param [&inout] self
|
||||||
|
@require self.readers.len == 0 "Init may not run on already initialized data"
|
||||||
|
@ensure self.index == 0
|
||||||
|
*>
|
||||||
|
fn MultiReader* MultiReader.tinit(&self, InStream... readers)
|
||||||
|
{
|
||||||
|
return self.init(allocator::temp(), ...readers);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn void MultiReader.free(&self)
|
fn void MultiReader.free(&self)
|
||||||
|
|||||||
@@ -15,7 +15,21 @@ struct MultiWriter (OutStream)
|
|||||||
@require writers.len > 0
|
@require writers.len > 0
|
||||||
@require self.writers.len == 0 "Init may not run on already initialized data"
|
@require self.writers.len == 0 "Init may not run on already initialized data"
|
||||||
*>
|
*>
|
||||||
fn MultiWriter* MultiWriter.new_init(&self, OutStream... writers, Allocator allocator = allocator::heap())
|
fn MultiWriter* MultiWriter.init(&self, Allocator allocator, OutStream... writers)
|
||||||
|
{
|
||||||
|
OutStream[] copy = allocator::new_array(allocator, OutStream, writers.len);
|
||||||
|
copy[..] = writers[..];
|
||||||
|
*self = { .writers = copy, .allocator = allocator };
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
<*
|
||||||
|
@param [&inout] self
|
||||||
|
@param [&inout] allocator
|
||||||
|
@require writers.len > 0
|
||||||
|
@require self.writers.len == 0 "Init may not run on already initialized data"
|
||||||
|
*>
|
||||||
|
fn MultiWriter* MultiWriter.new_init(&self, OutStream... writers, Allocator allocator = allocator::heap()) @deprecated("Use init(mem)")
|
||||||
{
|
{
|
||||||
OutStream[] copy = allocator::new_array(allocator, OutStream, writers.len);
|
OutStream[] copy = allocator::new_array(allocator, OutStream, writers.len);
|
||||||
copy[..] = writers[..];
|
copy[..] = writers[..];
|
||||||
@@ -28,9 +42,19 @@ fn MultiWriter* MultiWriter.new_init(&self, OutStream... writers, Allocator allo
|
|||||||
@require writers.len > 0
|
@require writers.len > 0
|
||||||
@require self.writers.len == 0 "Init may not run on already initialized data"
|
@require self.writers.len == 0 "Init may not run on already initialized data"
|
||||||
*>
|
*>
|
||||||
fn MultiWriter* MultiWriter.temp_init(&self, OutStream... writers)
|
fn MultiWriter* MultiWriter.temp_init(&self, OutStream... writers) @deprecated("Use tinit")
|
||||||
{
|
{
|
||||||
return self.new_init(...writers, allocator: allocator::temp());
|
return self.init(allocator::temp(), ...writers);
|
||||||
|
}
|
||||||
|
|
||||||
|
<*
|
||||||
|
@param [&inout] self
|
||||||
|
@require writers.len > 0
|
||||||
|
@require self.writers.len == 0 "Init may not run on already initialized data"
|
||||||
|
*>
|
||||||
|
fn MultiWriter* MultiWriter.tinit(&self, OutStream... writers)
|
||||||
|
{
|
||||||
|
return self.init(allocator::temp(), ...writers);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn void MultiWriter.free(&self)
|
fn void MultiWriter.free(&self)
|
||||||
|
|||||||
@@ -531,7 +531,7 @@ fn String BigInt.to_string_with_radix(&self, int radix, Allocator allocator)
|
|||||||
{
|
{
|
||||||
BigInt a = *self;
|
BigInt a = *self;
|
||||||
DString str;
|
DString str;
|
||||||
str.new_init(4096, allocator: mem);
|
str.init(mem, 4096);
|
||||||
bool negative = self.is_negative();
|
bool negative = self.is_negative();
|
||||||
if (negative)
|
if (negative)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ fn char[8 * 4] entropy() @if(!env::WASM_NOLIBC)
|
|||||||
hash(&entropy),
|
hash(&entropy),
|
||||||
random_int,
|
random_int,
|
||||||
hash(clock::now()),
|
hash(clock::now()),
|
||||||
hash(&DString.new_init),
|
hash(&DString.init),
|
||||||
hash(allocator::heap())
|
hash(allocator::heap())
|
||||||
};
|
};
|
||||||
return bitcast(entropy_data, char[8 * 4]);
|
return bitcast(entropy_data, char[8 * 4]);
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ fn UrlQueryValues parse_query(String query, Allocator allocator)
|
|||||||
{
|
{
|
||||||
UrlQueryValues vals;
|
UrlQueryValues vals;
|
||||||
vals.map.init(allocator);
|
vals.map.init(allocator);
|
||||||
vals.key_order.new_init(allocator: allocator);
|
vals.key_order.init(allocator);
|
||||||
|
|
||||||
Splitter raw_vals = query.tokenize("&");
|
Splitter raw_vals = query.tokenize("&");
|
||||||
while (try String rv = raw_vals.next())
|
while (try String rv = raw_vals.next())
|
||||||
@@ -309,7 +309,7 @@ fn UrlQueryValues* UrlQueryValues.add(&self, String key, String value)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
UrlQueryValueList new_list;
|
UrlQueryValueList new_list;
|
||||||
new_list.new_init_with_array({ value_copy }, self.allocator);
|
new_list.init_with_array(self.allocator, { value_copy });
|
||||||
(*self)[key] = new_list;
|
(*self)[key] = new_list;
|
||||||
self.key_order.push(key.copy(self.allocator));
|
self.key_order.push(key.copy(self.allocator));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ fn void! backtrace_add_element(BacktraceList *list, void* addr, Allocator alloca
|
|||||||
fn BacktraceList! symbolize_backtrace(void*[] backtrace, Allocator allocator)
|
fn BacktraceList! symbolize_backtrace(void*[] backtrace, Allocator allocator)
|
||||||
{
|
{
|
||||||
BacktraceList list;
|
BacktraceList list;
|
||||||
list.new_init(backtrace.len, allocator);
|
list.init(allocator, backtrace.len);
|
||||||
defer catch
|
defer catch
|
||||||
{
|
{
|
||||||
foreach (trace : list)
|
foreach (trace : list)
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ fn BacktraceList! symbolize_backtrace(void*[] backtrace, Allocator allocator)
|
|||||||
{
|
{
|
||||||
void *load_addr = (void *)load_address()!;
|
void *load_addr = (void *)load_address()!;
|
||||||
BacktraceList list;
|
BacktraceList list;
|
||||||
list.new_init(backtrace.len, allocator);
|
list.init(allocator, backtrace.len);
|
||||||
defer catch
|
defer catch
|
||||||
{
|
{
|
||||||
foreach (trace : list)
|
foreach (trace : list)
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ Win32_DWORD64 displacement;
|
|||||||
fn BacktraceList! symbolize_backtrace(void*[] backtrace, Allocator allocator)
|
fn BacktraceList! symbolize_backtrace(void*[] backtrace, Allocator allocator)
|
||||||
{
|
{
|
||||||
BacktraceList list;
|
BacktraceList list;
|
||||||
list.new_init(backtrace.len, allocator);
|
list.init(allocator, backtrace.len);
|
||||||
Win32_HANDLE process = getCurrentProcess();
|
Win32_HANDLE process = getCurrentProcess();
|
||||||
symInitialize(process, null, 1);
|
symInitialize(process, null, 1);
|
||||||
defer symCleanup(process);
|
defer symCleanup(process);
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ struct BufferedChannelImpl @private
|
|||||||
Type[?] buf;
|
Type[?] buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn void! BufferedChannel.new_init(&self, usz size = 1)
|
fn void! BufferedChannel.new_init(&self, usz size = 1) @deprecated("Use init(mem)")
|
||||||
{
|
{
|
||||||
return self.init(size, allocator::heap());
|
return self.init(mem, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn void! BufferedChannel.init(&self, usz size = 1, Allocator allocator)
|
fn void! BufferedChannel.init(&self, Allocator allocator, usz size = 1)
|
||||||
{
|
{
|
||||||
BufferedChannelImpl* channel = allocator::new_with_padding(allocator, BufferedChannelImpl, Type.sizeof * size)!;
|
BufferedChannelImpl* channel = allocator::new_with_padding(allocator, BufferedChannelImpl, Type.sizeof * size)!;
|
||||||
defer catch allocator::free(allocator, channel);
|
defer catch allocator::free(allocator, channel);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ struct UnbufferedChannelImpl @private
|
|||||||
ConditionVariable read_cond;
|
ConditionVariable read_cond;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn void! UnbufferedChannel.new_init(&self) => self.init(allocator::heap());
|
fn void! UnbufferedChannel.new_init(&self) @deprecated("Use init") => self.init(allocator::heap());
|
||||||
|
|
||||||
fn void! UnbufferedChannel.init(&self, Allocator allocator)
|
fn void! UnbufferedChannel.init(&self, Allocator allocator)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -107,29 +107,13 @@ macro AnyList.pop(&self, $Type)
|
|||||||
Pop the last value and allocate the copy using the given allocator.
|
Pop the last value and allocate the copy using the given allocator.
|
||||||
@return! IteratorResult.NO_MORE_ELEMENT
|
@return! IteratorResult.NO_MORE_ELEMENT
|
||||||
*>
|
*>
|
||||||
fn any! AnyList.copy_pop(&self, Allocator allocator = allocator::heap())
|
fn any! AnyList.copy_pop(&self, Allocator allocator)
|
||||||
{
|
{
|
||||||
if (!self.size) return IteratorResult.NO_MORE_ELEMENT?;
|
if (!self.size) return IteratorResult.NO_MORE_ELEMENT?;
|
||||||
defer self.free_element(self.entries[self.size]);
|
defer self.free_element(self.entries[self.size]);
|
||||||
return allocator::clone_any(allocator, self.entries[--self.size]);
|
return allocator::clone_any(allocator, self.entries[--self.size]);
|
||||||
}
|
}
|
||||||
|
|
||||||
<*
|
|
||||||
Pop the last value and allocate the copy using the given allocator.
|
|
||||||
@return! IteratorResult.NO_MORE_ELEMENT
|
|
||||||
@deprecated `use copy_pop`
|
|
||||||
*>
|
|
||||||
fn any! AnyList.new_pop(&self, Allocator allocator = allocator::heap())
|
|
||||||
{
|
|
||||||
return self.copy_pop(allocator);
|
|
||||||
}
|
|
||||||
|
|
||||||
<*
|
|
||||||
Pop the last value and allocate the copy using the temp allocator
|
|
||||||
@return! IteratorResult.NO_MORE_ELEMENT
|
|
||||||
@deprecated `use tcopy_pop`
|
|
||||||
*>
|
|
||||||
fn any! AnyList.temp_pop(&self) => self.copy_pop(tmem());
|
|
||||||
|
|
||||||
<*
|
<*
|
||||||
Pop the last value and allocate the copy using the temp allocator
|
Pop the last value and allocate the copy using the temp allocator
|
||||||
@@ -176,17 +160,9 @@ fn any! AnyList.pop_first_retained(&self)
|
|||||||
return self.entries[0];
|
return self.entries[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
<*
|
|
||||||
Same as new_pop() but pops the first value instead.
|
|
||||||
@deprecated `use copy_pop_first`
|
|
||||||
*>
|
|
||||||
fn any! AnyList.new_pop_first(&self, Allocator allocator = allocator::heap())
|
|
||||||
{
|
|
||||||
return self.copy_pop_first(allocator) @inline;
|
|
||||||
}
|
|
||||||
|
|
||||||
<*
|
<*
|
||||||
Same as new_pop() but pops the first value instead.
|
Same as copy_pop() but pops the first value instead.
|
||||||
*>
|
*>
|
||||||
fn any! AnyList.copy_pop_first(&self, Allocator allocator = allocator::heap())
|
fn any! AnyList.copy_pop_first(&self, Allocator allocator = allocator::heap())
|
||||||
{
|
{
|
||||||
@@ -201,12 +177,6 @@ fn any! AnyList.copy_pop_first(&self, Allocator allocator = allocator::heap())
|
|||||||
*>
|
*>
|
||||||
fn any! AnyList.tcopy_pop_first(&self) => self.copy_pop_first(tmem());
|
fn any! AnyList.tcopy_pop_first(&self) => self.copy_pop_first(tmem());
|
||||||
|
|
||||||
<*
|
|
||||||
Same as temp_pop() but pops the first value instead.
|
|
||||||
@deprecated `use tcopy_pop_first`
|
|
||||||
*>
|
|
||||||
fn any! AnyList.temp_pop_first(&self) => self.new_pop_first(tmem());
|
|
||||||
|
|
||||||
<*
|
<*
|
||||||
@require index < self.size
|
@require index < self.size
|
||||||
*>
|
*>
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ fn DString new_with_capacity(Allocator allocator, usz capacity)
|
|||||||
return (DString){}.init(allocator, capacity);
|
return (DString){}.init(allocator, capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn DString tnew_with_capacity(usz capacity) => new_with_capacity(tmem(), capacity) @inline;
|
fn DString temp_with_capacity(usz capacity) => new_with_capacity(tmem(), capacity) @inline;
|
||||||
|
|
||||||
fn DString new(Allocator allocator, String c = "")
|
fn DString new(Allocator allocator, String c = "")
|
||||||
{
|
{
|
||||||
@@ -46,7 +46,7 @@ fn DString new(Allocator allocator, String c = "")
|
|||||||
return (DString)data;
|
return (DString)data;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn DString tnew(String s = "") => new(tmem(), s) @inline;
|
fn DString temp(String s = "") => new(tmem(), s) @inline;
|
||||||
|
|
||||||
|
|
||||||
fn void DString.replace_char(self, char ch, char replacement)
|
fn void DString.replace_char(self, char ch, char replacement)
|
||||||
@@ -297,7 +297,7 @@ fn void DString.append_chars(&self, String str)
|
|||||||
if (!other_len) return;
|
if (!other_len) return;
|
||||||
if (!*self)
|
if (!*self)
|
||||||
{
|
{
|
||||||
*self = tnew(str);
|
*self = temp(str);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.reserve(other_len);
|
self.reserve(other_len);
|
||||||
@@ -339,7 +339,7 @@ fn void DString.append_char(&self, char c)
|
|||||||
{
|
{
|
||||||
if (!*self)
|
if (!*self)
|
||||||
{
|
{
|
||||||
*self = tnew_with_capacity(MIN_CAPACITY);
|
*self = temp_with_capacity(MIN_CAPACITY);
|
||||||
}
|
}
|
||||||
self.reserve(1);
|
self.reserve(1);
|
||||||
StringData* data = self.data();
|
StringData* data = self.data();
|
||||||
@@ -607,7 +607,7 @@ fn void DString.reserve(&self, usz addition)
|
|||||||
StringData* data = self.data();
|
StringData* data = self.data();
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
*self = dstring::tnew_with_capacity(addition);
|
*self = dstring::temp_with_capacity(addition);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
usz len = data.len + addition;
|
usz len = data.len + addition;
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ fn bool run_benchmarks(BenchmarkUnit[] benchmarks) @if(!$$OLD_TEST)
|
|||||||
|
|
||||||
usz len = max_name + 9;
|
usz len = max_name + 9;
|
||||||
|
|
||||||
DString name = dstring::tnew_with_capacity(64);
|
DString name = dstring::temp_with_capacity(64);
|
||||||
name.append_repeat('-', len / 2);
|
name.append_repeat('-', len / 2);
|
||||||
name.append(" BENCHMARKS ");
|
name.append(" BENCHMARKS ");
|
||||||
name.append_repeat('-', len - len / 2);
|
name.append_repeat('-', len - len / 2);
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ fn bool run_tests(String[] args, TestUnit[] tests) @private
|
|||||||
int tests_passed = 0;
|
int tests_passed = 0;
|
||||||
int tests_skipped = 0;
|
int tests_skipped = 0;
|
||||||
int test_count = tests.len;
|
int test_count = tests.len;
|
||||||
DString name = dstring::tnew_with_capacity(64);
|
DString name = dstring::temp_with_capacity(64);
|
||||||
usz len = max_name + 9;
|
usz len = max_name + 9;
|
||||||
name.append_repeat('-', len / 2);
|
name.append_repeat('-', len / 2);
|
||||||
name.append(" TESTS ");
|
name.append(" TESTS ");
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ fault NumberConversion
|
|||||||
*>
|
*>
|
||||||
fn ZString tformat_zstr(String fmt, args...)
|
fn ZString tformat_zstr(String fmt, args...)
|
||||||
{
|
{
|
||||||
DString str = dstring::tnew_with_capacity(fmt.len + args.len * 8);
|
DString str = dstring::temp_with_capacity(fmt.len + args.len * 8);
|
||||||
str.appendf(fmt, ...args);
|
str.appendf(fmt, ...args);
|
||||||
return str.zstr_view();
|
return str.zstr_view();
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ fn ZString tformat_zstr(String fmt, args...)
|
|||||||
*>
|
*>
|
||||||
fn String format(Allocator allocator, String fmt, args...) => @pool(allocator)
|
fn String format(Allocator allocator, String fmt, args...) => @pool(allocator)
|
||||||
{
|
{
|
||||||
DString str = dstring::tnew_with_capacity(fmt.len + args.len * 8);
|
DString str = dstring::temp_with_capacity(fmt.len + args.len * 8);
|
||||||
str.appendf(fmt, ...args);
|
str.appendf(fmt, ...args);
|
||||||
return str.copy_str(allocator);
|
return str.copy_str(allocator);
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ fn String format(Allocator allocator, String fmt, args...) => @pool(allocator)
|
|||||||
*>
|
*>
|
||||||
fn String tformat(String fmt, args...)
|
fn String tformat(String fmt, args...)
|
||||||
{
|
{
|
||||||
DString str = dstring::tnew_with_capacity(fmt.len + args.len * 8);
|
DString str = dstring::temp_with_capacity(fmt.len + args.len * 8);
|
||||||
str.appendf(fmt, ...args);
|
str.appendf(fmt, ...args);
|
||||||
return str.str_view();
|
return str.str_view();
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ fn String join(Allocator allocator, String[] s, String joiner)
|
|||||||
}
|
}
|
||||||
@pool(allocator)
|
@pool(allocator)
|
||||||
{
|
{
|
||||||
DString res = dstring::tnew_with_capacity(total_size);
|
DString res = dstring::temp_with_capacity(total_size);
|
||||||
res.append(s[0]);
|
res.append(s[0]);
|
||||||
foreach (String* &str : s[1..])
|
foreach (String* &str : s[1..])
|
||||||
{
|
{
|
||||||
@@ -671,8 +671,8 @@ fn String! new_from_wstring(Allocator allocator, WString wstring)
|
|||||||
return new_from_utf16(allocator, utf16);
|
return new_from_utf16(allocator, utf16);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn String! tnew_from_wstring(WString wstring) => new_from_wstring(tmem(), wstring) @inline;
|
fn String! temp_from_wstring(WString wstring) => new_from_wstring(tmem(), wstring) @inline;
|
||||||
fn String! tnew_from_utf16(Char16[] utf16) => new_from_utf16(tmem(), utf16) @inline;
|
fn String! temp_from_utf16(Char16[] utf16) => new_from_utf16(tmem(), utf16) @inline;
|
||||||
|
|
||||||
fn usz String.utf8_codepoints(s)
|
fn usz String.utf8_codepoints(s)
|
||||||
{
|
{
|
||||||
@@ -831,4 +831,4 @@ macro String new_from_struct(Allocator allocator, x)
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro String tnew_from_struct(x) => new_from_struct(tmem(), x);
|
macro String temp_from_struct(x) => new_from_struct(tmem(), x);
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ macro bool is_struct_with_default_print($Type)
|
|||||||
{
|
{
|
||||||
return $Type.kindof == STRUCT
|
return $Type.kindof == STRUCT
|
||||||
&&& !$defined($Type.to_format)
|
&&& !$defined($Type.to_format)
|
||||||
&&& !$defined($Type.to_new_string)
|
&&& !$defined($Type.to_constant_string);
|
||||||
&&& !$defined($Type.to_string);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<*
|
<*
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ macro String! readline(Allocator allocator, stream = io::stdin())
|
|||||||
if (val == '\n') return "";
|
if (val == '\n') return "";
|
||||||
@pool(allocator)
|
@pool(allocator)
|
||||||
{
|
{
|
||||||
DString str = dstring::tnew_with_capacity(256);
|
DString str = dstring::temp_with_capacity(256);
|
||||||
if (val != '\r') str.append(val);
|
if (val != '\r') str.append(val);
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ fn PathList! native_ls(Path dir, bool no_dirs, bool no_symlinks, String mask, Al
|
|||||||
if (no_dirs && (find_data.dwFileAttributes & win32::FILE_ATTRIBUTE_DIRECTORY)) continue;
|
if (no_dirs && (find_data.dwFileAttributes & win32::FILE_ATTRIBUTE_DIRECTORY)) continue;
|
||||||
@pool(allocator)
|
@pool(allocator)
|
||||||
{
|
{
|
||||||
String filename = string::tnew_from_wstring((WString)&find_data.cFileName)!;
|
String filename = string::temp_from_wstring((WString)&find_data.cFileName)!;
|
||||||
if (filename == ".." || filename == ".") continue;
|
if (filename == ".." || filename == ".") continue;
|
||||||
list.push(path::new(allocator, filename)!);
|
list.push(path::new(allocator, filename)!);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ fn Path! native_temp_directory(Allocator allocator) @if(env::WIN32) => @pool(all
|
|||||||
if (!len) return IoError.GENERAL_ERROR?;
|
if (!len) return IoError.GENERAL_ERROR?;
|
||||||
Char16[] buff = mem::temp_alloc_array(Char16, len + (usz)1);
|
Char16[] buff = mem::temp_alloc_array(Char16, len + (usz)1);
|
||||||
if (!win32::getTempPathW(len, buff)) return IoError.GENERAL_ERROR?;
|
if (!win32::getTempPathW(len, buff)) return IoError.GENERAL_ERROR?;
|
||||||
return path::new(allocator, string::tnew_from_utf16(buff[:len]));
|
return path::new(allocator, string::temp_from_utf16(buff[:len]));
|
||||||
}
|
}
|
||||||
|
|
||||||
module std::io::os @if(env::NO_LIBC);
|
module std::io::os @if(env::NO_LIBC);
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ macro void! chdir(path)
|
|||||||
$if @typeis(path, String):
|
$if @typeis(path, String):
|
||||||
@pool()
|
@pool()
|
||||||
{
|
{
|
||||||
return os::native_chdir(tnew(path));
|
return os::native_chdir(temp(path));
|
||||||
};
|
};
|
||||||
$else
|
$else
|
||||||
return os::native_chdir(path) @inline;
|
return os::native_chdir(path) @inline;
|
||||||
@@ -100,7 +100,7 @@ enum MkdirPermissions
|
|||||||
macro bool! mkdir(Path path, bool recursive = false, MkdirPermissions permissions = NORMAL)
|
macro bool! mkdir(Path path, bool recursive = false, MkdirPermissions permissions = NORMAL)
|
||||||
{
|
{
|
||||||
$if @typeis(path, String):
|
$if @typeis(path, String):
|
||||||
@pool() { return _mkdir(tnew(path), recursive, permissions); };
|
@pool() { return _mkdir(temp(path), recursive, permissions); };
|
||||||
$else
|
$else
|
||||||
return _mkdir(path, recursive, permissions);
|
return _mkdir(path, recursive, permissions);
|
||||||
$endif
|
$endif
|
||||||
@@ -118,7 +118,7 @@ macro bool! mkdir(Path path, bool recursive = false, MkdirPermissions permission
|
|||||||
macro bool! rmdir(path)
|
macro bool! rmdir(path)
|
||||||
{
|
{
|
||||||
$if @typeis(path, String):
|
$if @typeis(path, String):
|
||||||
@pool() { return _rmdir(tnew(path)); };
|
@pool() { return _rmdir(temp(path)); };
|
||||||
$else
|
$else
|
||||||
return _mkdir(path);
|
return _mkdir(path);
|
||||||
$endif
|
$endif
|
||||||
@@ -152,14 +152,14 @@ fn Path! new(Allocator allocator, String path, PathEnv path_env = DEFAULT_ENV)
|
|||||||
|
|
||||||
@return! PathResult.INVALID_PATH `if the path was invalid`
|
@return! PathResult.INVALID_PATH `if the path was invalid`
|
||||||
*>
|
*>
|
||||||
fn Path! tnew(String path, PathEnv path_env = DEFAULT_ENV)
|
fn Path! temp(String path, PathEnv path_env = DEFAULT_ENV)
|
||||||
{
|
{
|
||||||
return new(tmem(), path, path_env);
|
return new(tmem(), path, path_env);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Path! from_win32_wstring(Allocator allocator, WString path) => @pool(allocator)
|
fn Path! from_win32_wstring(Allocator allocator, WString path) => @pool(allocator)
|
||||||
{
|
{
|
||||||
return path::new(allocator, string::tnew_from_wstring(path)!);
|
return path::new(allocator, string::temp_from_wstring(path)!);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Path! for_windows(Allocator allocator, String path)
|
fn Path! for_windows(Allocator allocator, String path)
|
||||||
@@ -189,7 +189,7 @@ fn Path! Path.append(self, Allocator allocator, String filename)
|
|||||||
|
|
||||||
@pool(allocator)
|
@pool(allocator)
|
||||||
{
|
{
|
||||||
DString dstr = dstring::tnew_with_capacity(self.path_string.len + 1 + filename.len);
|
DString dstr = dstring::temp_with_capacity(self.path_string.len + 1 + filename.len);
|
||||||
dstr.append(self.path_string);
|
dstr.append(self.path_string);
|
||||||
dstr.append(PREFERRED_SEPARATOR);
|
dstr.append(PREFERRED_SEPARATOR);
|
||||||
dstr.append(filename);
|
dstr.append(filename);
|
||||||
@@ -223,7 +223,7 @@ fn usz! start_of_base_name(String str, PathEnv path_env) @local
|
|||||||
|
|
||||||
fn bool! String.is_absolute_path(self) => @pool()
|
fn bool! String.is_absolute_path(self) => @pool()
|
||||||
{
|
{
|
||||||
return tnew(self).is_absolute();
|
return temp(self).is_absolute();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bool! Path.is_absolute(self)
|
fn bool! Path.is_absolute(self)
|
||||||
@@ -238,7 +238,7 @@ fn bool! Path.is_absolute(self)
|
|||||||
|
|
||||||
fn Path! String.to_absolute_path(self, Allocator allocator) => @pool(allocator)
|
fn Path! String.to_absolute_path(self, Allocator allocator) => @pool(allocator)
|
||||||
{
|
{
|
||||||
return tnew(self).absolute(allocator);
|
return temp(self).absolute(allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
<*
|
<*
|
||||||
@@ -274,7 +274,7 @@ fn Path! Path.absolute(self, Allocator allocator)
|
|||||||
|
|
||||||
fn String! String.file_basename(self, Allocator allocator) => @pool(allocator)
|
fn String! String.file_basename(self, Allocator allocator) => @pool(allocator)
|
||||||
{
|
{
|
||||||
return tnew(self).basename().copy(allocator);
|
return temp(self).basename().copy(allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn String! String.file_tbasename(self) => self.file_basename(tmem());
|
fn String! String.file_tbasename(self) => self.file_basename(tmem());
|
||||||
@@ -291,7 +291,7 @@ fn String! String.path_tdirname(self) => self.path_dirname(tmem());
|
|||||||
|
|
||||||
fn String! String.path_dirname(self, Allocator allocator) => @pool(allocator)
|
fn String! String.path_dirname(self, Allocator allocator) => @pool(allocator)
|
||||||
{
|
{
|
||||||
return tnew(self).dirname().copy(allocator);
|
return temp(self).dirname().copy(allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn String Path.dirname(self)
|
fn String Path.dirname(self)
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ macro usz! read_all(stream, char[] buffer)
|
|||||||
<*
|
<*
|
||||||
@require @is_instream(stream)
|
@require @is_instream(stream)
|
||||||
*>
|
*>
|
||||||
macro char[]! read_new_fully(stream, Allocator allocator = allocator::heap())
|
macro char[]! read_fully(Allocator allocator, stream)
|
||||||
{
|
{
|
||||||
usz len = available(stream)!;
|
usz len = available(stream)!;
|
||||||
char* data = allocator::malloc_try(allocator, len)!;
|
char* data = allocator::malloc_try(allocator, len)!;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ struct ByteBuffer (InStream, OutStream)
|
|||||||
max_read defines how many bytes might be kept before its internal buffer is shrinked.
|
max_read defines how many bytes might be kept before its internal buffer is shrinked.
|
||||||
@require self.bytes.len == 0 "Buffer already initialized."
|
@require self.bytes.len == 0 "Buffer already initialized."
|
||||||
*>
|
*>
|
||||||
fn ByteBuffer* ByteBuffer.new_init(&self, usz max_read, usz initial_capacity = 16, Allocator allocator = allocator::heap())
|
fn ByteBuffer* ByteBuffer.init(&self, Allocator allocator, usz max_read, usz initial_capacity = 16)
|
||||||
{
|
{
|
||||||
*self = { .allocator = allocator, .max_read = max_read };
|
*self = { .allocator = allocator, .max_read = max_read };
|
||||||
initial_capacity = max(initial_capacity, 16);
|
initial_capacity = max(initial_capacity, 16);
|
||||||
@@ -24,9 +24,9 @@ fn ByteBuffer* ByteBuffer.new_init(&self, usz max_read, usz initial_capacity = 1
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ByteBuffer* ByteBuffer.temp_init(&self, usz max_read, usz initial_capacity = 16)
|
fn ByteBuffer* ByteBuffer.tinit(&self, usz max_read, usz initial_capacity = 16)
|
||||||
{
|
{
|
||||||
return self.new_init(max_read, initial_capacity, allocator::temp());
|
return self.init(tmem(), max_read, initial_capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
<*
|
<*
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ struct ByteWriter (OutStream)
|
|||||||
@require self.bytes.len == 0 "Init may not run on already initialized data"
|
@require self.bytes.len == 0 "Init may not run on already initialized data"
|
||||||
@ensure (bool)allocator, self.index == 0
|
@ensure (bool)allocator, self.index == 0
|
||||||
*>
|
*>
|
||||||
fn ByteWriter* ByteWriter.new_init(&self, Allocator allocator = allocator::heap())
|
fn ByteWriter* ByteWriter.init(&self, Allocator allocator)
|
||||||
{
|
{
|
||||||
*self = { .bytes = {}, .allocator = allocator };
|
*self = { .bytes = {}, .allocator = allocator };
|
||||||
return self;
|
return self;
|
||||||
@@ -25,9 +25,9 @@ fn ByteWriter* ByteWriter.new_init(&self, Allocator allocator = allocator::heap(
|
|||||||
@require self.bytes.len == 0 "Init may not run on already initialized data"
|
@require self.bytes.len == 0 "Init may not run on already initialized data"
|
||||||
@ensure self.index == 0
|
@ensure self.index == 0
|
||||||
*>
|
*>
|
||||||
fn ByteWriter* ByteWriter.temp_init(&self)
|
fn ByteWriter* ByteWriter.tinit(&self)
|
||||||
{
|
{
|
||||||
return self.new_init(allocator::temp()) @inline;
|
return self.init(tmem()) @inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ByteWriter* ByteWriter.init_with_buffer(&self, char[] data)
|
fn ByteWriter* ByteWriter.init_with_buffer(&self, char[] data)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ struct MultiReader (InStream)
|
|||||||
@require self.readers.len == 0 "Init may not run on already initialized data"
|
@require self.readers.len == 0 "Init may not run on already initialized data"
|
||||||
@ensure self.index == 0
|
@ensure self.index == 0
|
||||||
*>
|
*>
|
||||||
fn MultiReader* MultiReader.new_init(&self, InStream... readers, Allocator allocator = allocator::heap())
|
fn MultiReader* MultiReader.init(&self, Allocator allocator, InStream... readers)
|
||||||
{
|
{
|
||||||
InStream []copy = allocator::new_array(allocator, InStream, readers.len);
|
InStream []copy = allocator::new_array(allocator, InStream, readers.len);
|
||||||
copy[..] = readers[..];
|
copy[..] = readers[..];
|
||||||
@@ -31,9 +31,9 @@ fn MultiReader* MultiReader.new_init(&self, InStream... readers, Allocator alloc
|
|||||||
@require self.readers.len == 0 "Init may not run on already initialized data"
|
@require self.readers.len == 0 "Init may not run on already initialized data"
|
||||||
@ensure self.index == 0
|
@ensure self.index == 0
|
||||||
*>
|
*>
|
||||||
fn MultiReader* MultiReader.temp_init(&self, InStream... readers)
|
fn MultiReader* MultiReader.tinit(&self, InStream... readers)
|
||||||
{
|
{
|
||||||
return self.new_init(...readers, allocator: allocator::temp());
|
return self.init(tmem(), ...readers);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn void MultiReader.free(&self)
|
fn void MultiReader.free(&self)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ struct MultiWriter (OutStream)
|
|||||||
@require writers.len > 0
|
@require writers.len > 0
|
||||||
@require self.writers.len == 0 "Init may not run on already initialized data"
|
@require self.writers.len == 0 "Init may not run on already initialized data"
|
||||||
*>
|
*>
|
||||||
fn MultiWriter* MultiWriter.new_init(&self, OutStream... writers, Allocator allocator = allocator::heap())
|
fn MultiWriter* MultiWriter.init(&self, Allocator allocator, OutStream... writers)
|
||||||
{
|
{
|
||||||
OutStream[] copy = allocator::new_array(allocator, OutStream, writers.len);
|
OutStream[] copy = allocator::new_array(allocator, OutStream, writers.len);
|
||||||
copy[..] = writers[..];
|
copy[..] = writers[..];
|
||||||
@@ -28,9 +28,9 @@ fn MultiWriter* MultiWriter.new_init(&self, OutStream... writers, Allocator allo
|
|||||||
@require writers.len > 0
|
@require writers.len > 0
|
||||||
@require self.writers.len == 0 "Init may not run on already initialized data"
|
@require self.writers.len == 0 "Init may not run on already initialized data"
|
||||||
*>
|
*>
|
||||||
fn MultiWriter* MultiWriter.temp_init(&self, OutStream... writers)
|
fn MultiWriter* MultiWriter.tinit(&self, OutStream... writers)
|
||||||
{
|
{
|
||||||
return self.new_init(...writers, allocator: allocator::temp());
|
return self.init(tmem(), ...writers);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn void MultiWriter.free(&self)
|
fn void MultiWriter.free(&self)
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ fn bool InetAddress.is_multicast_link_local(InetAddress* addr)
|
|||||||
fn AddrInfo*! addrinfo(String host, uint port, AIFamily ai_family, AISockType ai_socktype) @if(os::SUPPORTS_INET) => @pool()
|
fn AddrInfo*! addrinfo(String host, uint port, AIFamily ai_family, AISockType ai_socktype) @if(os::SUPPORTS_INET) => @pool()
|
||||||
{
|
{
|
||||||
ZString zhost = host.zstr_tcopy();
|
ZString zhost = host.zstr_tcopy();
|
||||||
DString str = dstring::tnew_with_capacity(32);
|
DString str = dstring::temp_with_capacity(32);
|
||||||
str.appendf("%d", port);
|
str.appendf("%d", port);
|
||||||
AddrInfo hints = { .ai_family = ai_family, .ai_socktype = ai_socktype };
|
AddrInfo hints = { .ai_family = ai_family, .ai_socktype = ai_socktype };
|
||||||
AddrInfo* ai;
|
AddrInfo* ai;
|
||||||
|
|||||||
@@ -254,15 +254,7 @@ struct UrlQueryValues
|
|||||||
@param [in] query
|
@param [in] query
|
||||||
@return "a UrlQueryValues HashMap"
|
@return "a UrlQueryValues HashMap"
|
||||||
*>
|
*>
|
||||||
fn UrlQueryValues temp_parse_query(String query) => parse_query(query, allocator::temp());
|
fn UrlQueryValues parse_query_to_temp(String query) => parse_query(tmem(), query);
|
||||||
|
|
||||||
<*
|
|
||||||
Parse the query parameters of the Url into a UrlQueryValues map.
|
|
||||||
|
|
||||||
@param [in] query
|
|
||||||
@return "a UrlQueryValues HashMap"
|
|
||||||
*>
|
|
||||||
fn UrlQueryValues new_parse_query(String query) => parse_query(query, allocator::heap());
|
|
||||||
|
|
||||||
<*
|
<*
|
||||||
Parse the query parameters of the Url into a UrlQueryValues map.
|
Parse the query parameters of the Url into a UrlQueryValues map.
|
||||||
@@ -271,7 +263,7 @@ fn UrlQueryValues new_parse_query(String query) => parse_query(query, allocator:
|
|||||||
@param [inout] allocator
|
@param [inout] allocator
|
||||||
@return "a UrlQueryValues HashMap"
|
@return "a UrlQueryValues HashMap"
|
||||||
*>
|
*>
|
||||||
fn UrlQueryValues parse_query(String query, Allocator allocator)
|
fn UrlQueryValues parse_query(Allocator allocator, String query)
|
||||||
{
|
{
|
||||||
UrlQueryValues vals;
|
UrlQueryValues vals;
|
||||||
vals.map.init(allocator);
|
vals.map.init(allocator);
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ fn usz encode_len(String s, UrlEncodingMode mode) @inline
|
|||||||
fn String encode(Allocator allocator, String s, UrlEncodingMode mode) => @pool(allocator)
|
fn String encode(Allocator allocator, String s, UrlEncodingMode mode) => @pool(allocator)
|
||||||
{
|
{
|
||||||
usz n = encode_len(s, mode);
|
usz n = encode_len(s, mode);
|
||||||
DString builder = dstring::tnew_with_capacity(n);
|
DString builder = dstring::temp_with_capacity(n);
|
||||||
|
|
||||||
foreach(i, c: s)
|
foreach(i, c: s)
|
||||||
{
|
{
|
||||||
@@ -137,7 +137,7 @@ fn usz! decode_len(String s, UrlEncodingMode mode) @inline
|
|||||||
fn String! decode(Allocator allocator, String s, UrlEncodingMode mode) => @pool(allocator)
|
fn String! decode(Allocator allocator, String s, UrlEncodingMode mode) => @pool(allocator)
|
||||||
{
|
{
|
||||||
usz n = decode_len(s, mode)!;
|
usz n = decode_len(s, mode)!;
|
||||||
DString builder = dstring::tnew_with_capacity(n);
|
DString builder = dstring::temp_with_capacity(n);
|
||||||
|
|
||||||
for (usz i = 0; i < s.len; i++)
|
for (usz i = 0; i < s.len; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -77,15 +77,11 @@ fn String! get_home_dir(Allocator using = allocator::heap())
|
|||||||
return get_var(using, home);
|
return get_var(using, home);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Path! get_config_dir(Allocator allocator = allocator::heap()) @deprecated("use new_get_config_dir()")
|
|
||||||
{
|
|
||||||
return new_get_config_dir(allocator) @inline;
|
|
||||||
}
|
|
||||||
|
|
||||||
<*
|
<*
|
||||||
Returns the current user's config directory.
|
Returns the current user's config directory.
|
||||||
*>
|
*>
|
||||||
fn Path! new_get_config_dir(Allocator allocator) => @pool(allocator)
|
fn Path! get_config_dir(Allocator allocator) => @pool(allocator)
|
||||||
{
|
{
|
||||||
$if env::WIN32:
|
$if env::WIN32:
|
||||||
return path::new(allocator, tget_var("AppData"));
|
return path::new(allocator, tget_var("AppData"));
|
||||||
@@ -97,7 +93,7 @@ fn Path! new_get_config_dir(Allocator allocator) => @pool(allocator)
|
|||||||
String s = tget_var("XDG_CONFIG_HOME") ?? tget_var("HOME")!;
|
String s = tget_var("XDG_CONFIG_HOME") ?? tget_var("HOME")!;
|
||||||
const DIR = ".config";
|
const DIR = ".config";
|
||||||
$endif
|
$endif
|
||||||
return path::tnew(s).append(allocator, DIR);
|
return path::temp(s).append(allocator, DIR);
|
||||||
$endif
|
$endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ fn void! create_named_pipe_helper(void** rd, void **wr) @local @if(env::WIN32)
|
|||||||
|
|
||||||
fn WString convert_command_line_win32(String[] command_line) @inline @if(env::WIN32) @local
|
fn WString convert_command_line_win32(String[] command_line) @inline @if(env::WIN32) @local
|
||||||
{
|
{
|
||||||
DString str = dstring::tnew_with_capacity(512);
|
DString str = dstring::temp_with_capacity(512);
|
||||||
foreach LINE: (i, s : command_line)
|
foreach LINE: (i, s : command_line)
|
||||||
{
|
{
|
||||||
if (i != 0) str.append(' ');
|
if (i != 0) str.append(' ');
|
||||||
@@ -138,7 +138,7 @@ fn SubProcess! create(String[] command_line, SubProcessOptions options = {}, Str
|
|||||||
WString used_environment = null;
|
WString used_environment = null;
|
||||||
if (!options.inherit_environment)
|
if (!options.inherit_environment)
|
||||||
{
|
{
|
||||||
DString env = dstring::tnew_with_capacity(64);
|
DString env = dstring::temp_with_capacity(64);
|
||||||
if (!environment.len)
|
if (!environment.len)
|
||||||
{
|
{
|
||||||
env.append("\0");
|
env.append("\0");
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ fn void remove_all_pool_threads(EventThreadPool* pool) @local
|
|||||||
<*
|
<*
|
||||||
@require size > 0 "Must have at least one thread"
|
@require size > 0 "Must have at least one thread"
|
||||||
*>
|
*>
|
||||||
fn EventThreadPool* EventThreadPool.new_init(&self, int size, String name, Allocator allocator, void* monitor_context)
|
fn EventThreadPool* EventThreadPool.init(&self, int size, String name, Allocator allocator, void* monitor_context)
|
||||||
{
|
{
|
||||||
*self = { .is_alive = true, .name = name.copy(allocator), .monitor_context = monitor_context, .allocator = allocator };
|
*self = { .is_alive = true, .name = name.copy(allocator), .monitor_context = monitor_context, .allocator = allocator };
|
||||||
self.pool.init(allocator);
|
self.pool.init(allocator);
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ fn usz! NanoDuration.to_format(&self, Formatter* formatter) @dynamic
|
|||||||
bool neg = nd < 0;
|
bool neg = nd < 0;
|
||||||
if (neg) nd = -nd;
|
if (neg) nd = -nd;
|
||||||
|
|
||||||
DString str = dstring::tnew_with_capacity(64);
|
DString str = dstring::temp_with_capacity(64);
|
||||||
if (nd < 1_000_000_000)
|
if (nd < 1_000_000_000)
|
||||||
{
|
{
|
||||||
// Less than 1s: print milliseconds, microseconds and nanoseconds.
|
// Less than 1s: print milliseconds, microseconds and nanoseconds.
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ fn DString bin(int x)
|
|||||||
{
|
{
|
||||||
int bits = x == 0 ? 1 : 1 + (int)math::log2(x);
|
int bits = x == 0 ? 1 : 1 + (int)math::log2(x);
|
||||||
DString str;
|
DString str;
|
||||||
str.new_init();
|
str.init(mem);
|
||||||
str.append_repeat('0', bits);
|
str.append_repeat('0', bits);
|
||||||
for (int i = 0; i < bits; i++)
|
for (int i = 0; i < bits; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -476,7 +476,7 @@ fn void test_file(Path file_path)
|
|||||||
io::printfn(`FAILED - %s did not contain: "%s"`, file.name, next);
|
io::printfn(`FAILED - %s did not contain: "%s"`, file.name, next);
|
||||||
io::printfn("\n\n\n---------------------------------------------------> %s\n\n", file.name);
|
io::printfn("\n\n\n---------------------------------------------------> %s\n\n", file.name);
|
||||||
(void)file_ll.seek(0);
|
(void)file_ll.seek(0);
|
||||||
(void)io::printn((String)io::read_new_fully(&file_ll, allocator: allocator::temp()));
|
(void)io::printn((String)io::read_fully(tmem(), &file_ll));
|
||||||
io::printfn("<---------------------------------------------------- %s\n", file_path);
|
io::printfn("<---------------------------------------------------- %s\n", file_path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import std::io::path;
|
|||||||
|
|
||||||
fn void! process_dir(String dir_name)
|
fn void! process_dir(String dir_name)
|
||||||
{
|
{
|
||||||
path::Path p = path::tnew(dir_name)!;
|
path::Path p = path::temp(dir_name)!;
|
||||||
path::PathWalker fnwalk = fn bool!(Path p, bool is_dir, void*) { // #error: issing return statement at the end
|
path::PathWalker fnwalk = fn bool!(Path p, bool is_dir, void*) { // #error: issing return statement at the end
|
||||||
io::printfn("path is %s", p);
|
io::printfn("path is %s", p);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import std::collections::list;
|
|||||||
fn void! load_corpus2(String code, String path) @local
|
fn void! load_corpus2(String code, String path) @local
|
||||||
{
|
{
|
||||||
for(;;) io::printfn("hi");
|
for(;;) io::printfn("hi");
|
||||||
path::Path p = path::tnew(path)!; // #warning: This code will never execute
|
path::Path p = path::temp(path)!; // #warning: This code will never execute
|
||||||
|
|
||||||
if (!path::exists(p))
|
if (!path::exists(p))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ fn void copy_map() @test
|
|||||||
mem::@scoped(&alloc)
|
mem::@scoped(&alloc)
|
||||||
{
|
{
|
||||||
IntMap x;
|
IntMap x;
|
||||||
x.new_init();
|
x.init(mem);
|
||||||
DString y;
|
DString y;
|
||||||
y.append("hello");
|
y.append("hello");
|
||||||
x.set(y.str_view(), 123);
|
x.set(y.str_view(), 123);
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ fn void test_append()
|
|||||||
|
|
||||||
DString str2 = dstring::new("yyy");
|
DString str2 = dstring::new("yyy");
|
||||||
defer str2.free();
|
defer str2.free();
|
||||||
DString str3 = str.new_concat(str2);
|
DString str3 = str.concat(mem, str2);
|
||||||
defer str3.free();
|
defer str3.free();
|
||||||
s = str3.str_view();
|
s = str3.str_view();
|
||||||
assert(s == "xxxyyy", "got '%s'; want 'xxxyyy'", s);
|
assert(s == "xxxyyy", "got '%s'; want 'xxxyyy'", s);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import std::io;
|
|||||||
fn void write_read()
|
fn void write_read()
|
||||||
{
|
{
|
||||||
ByteBuffer buf;
|
ByteBuffer buf;
|
||||||
buf.temp_init(16);
|
buf.tinit(16);
|
||||||
usz n;
|
usz n;
|
||||||
uint x;
|
uint x;
|
||||||
uint y;
|
uint y;
|
||||||
@@ -45,7 +45,7 @@ fn void samples()
|
|||||||
foreach (tc : tcases)
|
foreach (tc : tcases)
|
||||||
{
|
{
|
||||||
ByteWriter bw;
|
ByteWriter bw;
|
||||||
bw.temp_init();
|
bw.tinit();
|
||||||
usz n = io::write_varint(&bw, tc.in)!!;
|
usz n = io::write_varint(&bw, tc.in)!!;
|
||||||
assert(n == tc.bytes.len, "got %d; want %d", n, tc.bytes.len);
|
assert(n == tc.bytes.len, "got %d; want %d", n, tc.bytes.len);
|
||||||
char[] bytes = bw.bytes[:bw.index];
|
char[] bytes = bw.bytes[:bw.index];
|
||||||
|
|||||||
@@ -396,7 +396,7 @@ fn void test_query_values_withempty()
|
|||||||
fn void test_url_idempotence()
|
fn void test_url_idempotence()
|
||||||
{
|
{
|
||||||
UrlQueryValues query_builder;
|
UrlQueryValues query_builder;
|
||||||
query_builder.new_init();
|
query_builder.init(mem);
|
||||||
defer query_builder.free();
|
defer query_builder.free();
|
||||||
|
|
||||||
query_builder.add("profileSQL", "true");
|
query_builder.add("profileSQL", "true");
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ fn void sorted()
|
|||||||
|
|
||||||
// with list
|
// with list
|
||||||
List(<int>) list;
|
List(<int>) list;
|
||||||
list.temp_init();
|
list.tinit();
|
||||||
list.add_array(tc.input);
|
list.add_array(tc.input);
|
||||||
|
|
||||||
got = is_sorted(list);
|
got = is_sorted(list);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ fn void init_destroy_buffered() @test
|
|||||||
for (usz i = 0; i < 20; i++)
|
for (usz i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
BufferedChannel(<int>) c;
|
BufferedChannel(<int>) c;
|
||||||
c.new_init(1)!!;
|
c.init(mem, 1)!!;
|
||||||
defer c.destroy()!!;
|
defer c.destroy()!!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ fn void init_destroy_unbuffered() @test
|
|||||||
fn void push_to_buffered_channel_no_lock() @test
|
fn void push_to_buffered_channel_no_lock() @test
|
||||||
{
|
{
|
||||||
BufferedChannel(<int>) c;
|
BufferedChannel(<int>) c;
|
||||||
c.new_init(1)!!;
|
c.init(mem, 1)!!;
|
||||||
defer c.destroy()!!;
|
defer c.destroy()!!;
|
||||||
|
|
||||||
c.push(1)!!;
|
c.push(1)!!;
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ fn void test_join()
|
|||||||
|
|
||||||
fn void test_insert_at()
|
fn void test_insert_at()
|
||||||
{
|
{
|
||||||
DString str = dstring::tnew(" world");
|
DString str = dstring::temp(" world");
|
||||||
String s;
|
String s;
|
||||||
|
|
||||||
str.insert_at(0, "");
|
str.insert_at(0, "");
|
||||||
@@ -208,7 +208,7 @@ fn void test_insert_at()
|
|||||||
|
|
||||||
fn void test_insert_at_overlaps()
|
fn void test_insert_at_overlaps()
|
||||||
{
|
{
|
||||||
DString str = dstring::tnew("abc");
|
DString str = dstring::temp("abc");
|
||||||
String s;
|
String s;
|
||||||
String v;
|
String v;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import std::io;
|
|||||||
|
|
||||||
fn void test_write_0b1() {
|
fn void test_write_0b1() {
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
w.temp_init();
|
w.tinit();
|
||||||
|
|
||||||
BitWriter bw;
|
BitWriter bw;
|
||||||
bw.init(&w);
|
bw.init(&w);
|
||||||
@@ -16,7 +16,7 @@ fn void test_write_0b1() {
|
|||||||
|
|
||||||
fn void test_write_0b1111() {
|
fn void test_write_0b1111() {
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
w.temp_init();
|
w.tinit();
|
||||||
|
|
||||||
BitWriter bw;
|
BitWriter bw;
|
||||||
bw.init(&w);
|
bw.init(&w);
|
||||||
@@ -29,7 +29,7 @@ fn void test_write_0b1111() {
|
|||||||
|
|
||||||
fn void test_write_0b1111_1111() {
|
fn void test_write_0b1111_1111() {
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
w.temp_init();
|
w.tinit();
|
||||||
|
|
||||||
BitWriter bw;
|
BitWriter bw;
|
||||||
bw.init(&w);
|
bw.init(&w);
|
||||||
@@ -42,7 +42,7 @@ fn void test_write_0b1111_1111() {
|
|||||||
|
|
||||||
fn void test_write_0b1000() {
|
fn void test_write_0b1000() {
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
w.temp_init();
|
w.tinit();
|
||||||
|
|
||||||
BitWriter bw;
|
BitWriter bw;
|
||||||
bw.init(&w);
|
bw.init(&w);
|
||||||
@@ -55,7 +55,7 @@ fn void test_write_0b1000() {
|
|||||||
|
|
||||||
fn void test_write_0b01000() {
|
fn void test_write_0b01000() {
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
w.temp_init();
|
w.tinit();
|
||||||
|
|
||||||
BitWriter bw;
|
BitWriter bw;
|
||||||
bw.init(&w);
|
bw.init(&w);
|
||||||
@@ -68,7 +68,7 @@ fn void test_write_0b01000() {
|
|||||||
|
|
||||||
fn void test_write_0b0001() {
|
fn void test_write_0b0001() {
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
w.temp_init();
|
w.tinit();
|
||||||
|
|
||||||
BitWriter bw;
|
BitWriter bw;
|
||||||
bw.init(&w);
|
bw.init(&w);
|
||||||
@@ -82,7 +82,7 @@ fn void test_write_0b0001() {
|
|||||||
|
|
||||||
fn void test_write_0b0000_0001() {
|
fn void test_write_0b0000_0001() {
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
w.temp_init();
|
w.tinit();
|
||||||
|
|
||||||
BitWriter bw;
|
BitWriter bw;
|
||||||
bw.init(&w);
|
bw.init(&w);
|
||||||
@@ -95,7 +95,7 @@ fn void test_write_0b0000_0001() {
|
|||||||
|
|
||||||
fn void test_write_10_bits() {
|
fn void test_write_10_bits() {
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
w.temp_init();
|
w.tinit();
|
||||||
|
|
||||||
BitWriter bw;
|
BitWriter bw;
|
||||||
bw.init(&w);
|
bw.init(&w);
|
||||||
@@ -109,7 +109,7 @@ fn void test_write_10_bits() {
|
|||||||
|
|
||||||
fn void test_write_16_bits() {
|
fn void test_write_16_bits() {
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
w.temp_init();
|
w.tinit();
|
||||||
|
|
||||||
BitWriter bw;
|
BitWriter bw;
|
||||||
bw.init(&w);
|
bw.init(&w);
|
||||||
@@ -122,7 +122,7 @@ fn void test_write_16_bits() {
|
|||||||
|
|
||||||
fn void test_write_24_bits() {
|
fn void test_write_24_bits() {
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
w.temp_init();
|
w.tinit();
|
||||||
|
|
||||||
BitWriter bw;
|
BitWriter bw;
|
||||||
bw.init(&w);
|
bw.init(&w);
|
||||||
@@ -135,7 +135,7 @@ fn void test_write_24_bits() {
|
|||||||
|
|
||||||
fn void test_write_30_bits() {
|
fn void test_write_30_bits() {
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
w.temp_init();
|
w.tinit();
|
||||||
|
|
||||||
BitWriter bw;
|
BitWriter bw;
|
||||||
bw.init(&w);
|
bw.init(&w);
|
||||||
@@ -148,7 +148,7 @@ fn void test_write_30_bits() {
|
|||||||
|
|
||||||
fn void test_write_32_bits() {
|
fn void test_write_32_bits() {
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
w.temp_init();
|
w.tinit();
|
||||||
|
|
||||||
BitWriter bw;
|
BitWriter bw;
|
||||||
bw.init(&w);
|
bw.init(&w);
|
||||||
@@ -161,7 +161,7 @@ fn void test_write_32_bits() {
|
|||||||
|
|
||||||
fn void test_write_2_bits_multiple() {
|
fn void test_write_2_bits_multiple() {
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
w.temp_init();
|
w.tinit();
|
||||||
|
|
||||||
BitWriter bw;
|
BitWriter bw;
|
||||||
bw.init(&w);
|
bw.init(&w);
|
||||||
@@ -176,7 +176,7 @@ fn void test_write_2_bits_multiple() {
|
|||||||
|
|
||||||
fn void test_write_10_bits_multiple() {
|
fn void test_write_10_bits_multiple() {
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
w.temp_init();
|
w.tinit();
|
||||||
|
|
||||||
BitWriter bw;
|
BitWriter bw;
|
||||||
bw.init(&w);
|
bw.init(&w);
|
||||||
@@ -192,7 +192,7 @@ fn void test_write_10_bits_multiple() {
|
|||||||
|
|
||||||
fn void test_write_24_bits_multiple() {
|
fn void test_write_24_bits_multiple() {
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
w.temp_init();
|
w.tinit();
|
||||||
|
|
||||||
BitWriter bw;
|
BitWriter bw;
|
||||||
bw.init(&w);
|
bw.init(&w);
|
||||||
@@ -206,7 +206,7 @@ fn void test_write_24_bits_multiple() {
|
|||||||
|
|
||||||
fn void test_write_30_bits_multiple() {
|
fn void test_write_30_bits_multiple() {
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
w.temp_init();
|
w.tinit();
|
||||||
|
|
||||||
BitWriter bw;
|
BitWriter bw;
|
||||||
bw.init(&w);
|
bw.init(&w);
|
||||||
@@ -220,7 +220,7 @@ fn void test_write_30_bits_multiple() {
|
|||||||
|
|
||||||
fn void test_write_32_bits_multiple() {
|
fn void test_write_32_bits_multiple() {
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
w.temp_init();
|
w.tinit();
|
||||||
|
|
||||||
BitWriter bw;
|
BitWriter bw;
|
||||||
bw.init(&w);
|
bw.init(&w);
|
||||||
@@ -234,7 +234,7 @@ fn void test_write_32_bits_multiple() {
|
|||||||
|
|
||||||
fn void test_write_mixed_multiple() {
|
fn void test_write_mixed_multiple() {
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
w.temp_init();
|
w.tinit();
|
||||||
|
|
||||||
BitWriter bw;
|
BitWriter bw;
|
||||||
bw.init(&w);
|
bw.init(&w);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ fn void readbuffer()
|
|||||||
reader_buf.init(&src, buf[..]);
|
reader_buf.init(&src, buf[..]);
|
||||||
|
|
||||||
ByteWriter bw;
|
ByteWriter bw;
|
||||||
bw.temp_init();
|
bw.tinit();
|
||||||
|
|
||||||
usz n = io::copy_to(&reader_buf, &bw)!!;
|
usz n = io::copy_to(&reader_buf, &bw)!!;
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ fn void readbuffer()
|
|||||||
fn void writebuffer_large()
|
fn void writebuffer_large()
|
||||||
{
|
{
|
||||||
ByteWriter out;
|
ByteWriter out;
|
||||||
out.temp_init();
|
out.tinit();
|
||||||
char[16] buf;
|
char[16] buf;
|
||||||
WriteBuffer write_buf;
|
WriteBuffer write_buf;
|
||||||
write_buf.init(&out, buf[..]);
|
write_buf.init(&out, buf[..]);
|
||||||
@@ -56,7 +56,7 @@ fn void writebuffer()
|
|||||||
ByteReader br;
|
ByteReader br;
|
||||||
br.init(DATA);
|
br.init(DATA);
|
||||||
ByteWriter out;
|
ByteWriter out;
|
||||||
out.temp_init();
|
out.tinit();
|
||||||
char[3] buf;
|
char[3] buf;
|
||||||
WriteBuffer write_buf;
|
WriteBuffer write_buf;
|
||||||
write_buf.init(&out, buf[..]);
|
write_buf.init(&out, buf[..]);
|
||||||
@@ -71,7 +71,7 @@ fn void writebuffer()
|
|||||||
fn void writebuffer_write_byte()
|
fn void writebuffer_write_byte()
|
||||||
{
|
{
|
||||||
ByteWriter out;
|
ByteWriter out;
|
||||||
out.temp_init();
|
out.tinit();
|
||||||
char[2] buf;
|
char[2] buf;
|
||||||
WriteBuffer write_buf;
|
WriteBuffer write_buf;
|
||||||
write_buf.init(&out, buf[..]);
|
write_buf.init(&out, buf[..]);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import std::io;
|
|||||||
fn void write_read()
|
fn void write_read()
|
||||||
{
|
{
|
||||||
ByteBuffer buffer;
|
ByteBuffer buffer;
|
||||||
buffer.new_init(0);
|
buffer.init(mem, 0);
|
||||||
defer buffer.free();
|
defer buffer.free();
|
||||||
buffer.write("hello")!!;
|
buffer.write("hello")!!;
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ fn void bytestream()
|
|||||||
usz len = s.read(&buffer)!!;
|
usz len = s.read(&buffer)!!;
|
||||||
assert((String)buffer[:len] == "abc");
|
assert((String)buffer[:len] == "abc");
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
w.new_init();
|
w.init(mem);
|
||||||
defer (void)w.destroy();
|
defer (void)w.destroy();
|
||||||
OutStream ws = &w;
|
OutStream ws = &w;
|
||||||
ws.write("helloworld")!!;
|
ws.write("helloworld")!!;
|
||||||
@@ -44,7 +44,7 @@ fn void bytewriter_read_from()
|
|||||||
InStream s = &r;
|
InStream s = &r;
|
||||||
|
|
||||||
ByteWriter bw;
|
ByteWriter bw;
|
||||||
bw.temp_init();
|
bw.tinit();
|
||||||
bw.read_from(s)!!;
|
bw.read_from(s)!!;
|
||||||
|
|
||||||
assert(bw.str_view() == data);
|
assert(bw.str_view() == data);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ module std::io @test;
|
|||||||
fn void test_multireader()
|
fn void test_multireader()
|
||||||
{
|
{
|
||||||
MultiReader mr;
|
MultiReader mr;
|
||||||
mr.temp_init(
|
mr.tinit(
|
||||||
&&wrap_bytes("foo"),
|
&&wrap_bytes("foo"),
|
||||||
&&wrap_bytes(" "),
|
&&wrap_bytes(" "),
|
||||||
&&wrap_bytes("bar"),
|
&&wrap_bytes("bar"),
|
||||||
@@ -12,7 +12,7 @@ fn void test_multireader()
|
|||||||
defer mr.free();
|
defer mr.free();
|
||||||
|
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
io::copy_to(&mr, w.temp_init())!!;
|
io::copy_to(&mr, w.tinit())!!;
|
||||||
|
|
||||||
String want = "foo bar!";
|
String want = "foo bar!";
|
||||||
assert(w.str_view() == want,
|
assert(w.str_view() == want,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ fn void test_multiwriter()
|
|||||||
{
|
{
|
||||||
ByteWriter w1, w2;
|
ByteWriter w1, w2;
|
||||||
MultiWriter mw;
|
MultiWriter mw;
|
||||||
mw.temp_init(w1.temp_init(), w2.temp_init());
|
mw.tinit(w1.tinit(), w2.tinit());
|
||||||
defer mw.free();
|
defer mw.free();
|
||||||
|
|
||||||
String want = "foobar";
|
String want = "foobar";
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ fn void read_uint128_test()
|
|||||||
fn void write_ushort_test()
|
fn void write_ushort_test()
|
||||||
{
|
{
|
||||||
ByteWriter bw;
|
ByteWriter bw;
|
||||||
bw.temp_init();
|
bw.tinit();
|
||||||
io::write_be_short(&bw, 0x348a)!!;
|
io::write_be_short(&bw, 0x348a)!!;
|
||||||
assert(bw.str_view() == &&x'348a');
|
assert(bw.str_view() == &&x'348a');
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ fn void write_ushort_test()
|
|||||||
fn void write_uint_test()
|
fn void write_uint_test()
|
||||||
{
|
{
|
||||||
ByteWriter bw;
|
ByteWriter bw;
|
||||||
bw.temp_init();
|
bw.tinit();
|
||||||
io::write_be_int(&bw, 0x3421348a)!!;
|
io::write_be_int(&bw, 0x3421348a)!!;
|
||||||
assert(bw.str_view() == &&x'3421348a');
|
assert(bw.str_view() == &&x'3421348a');
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ fn void write_uint_test()
|
|||||||
fn void write_ulong_test()
|
fn void write_ulong_test()
|
||||||
{
|
{
|
||||||
ByteWriter bw;
|
ByteWriter bw;
|
||||||
bw.temp_init();
|
bw.tinit();
|
||||||
io::write_be_long(&bw, 0xaabbccdd3421348a)!!;
|
io::write_be_long(&bw, 0xaabbccdd3421348a)!!;
|
||||||
assert(bw.str_view() == &&x'aabbccdd3421348a');
|
assert(bw.str_view() == &&x'aabbccdd3421348a');
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ fn void write_ulong_test()
|
|||||||
fn void write_uint128_test()
|
fn void write_uint128_test()
|
||||||
{
|
{
|
||||||
ByteWriter bw;
|
ByteWriter bw;
|
||||||
bw.temp_init();
|
bw.tinit();
|
||||||
io::write_be_int128(&bw, 0xaabbccdd3421348aaabbccdd3421348a)!!;
|
io::write_be_int128(&bw, 0xaabbccdd3421348aaabbccdd3421348a)!!;
|
||||||
assert(bw.str_view() == &&x'aabbccdd3421348aaabbccdd3421348a');
|
assert(bw.str_view() == &&x'aabbccdd3421348aaabbccdd3421348a');
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ fn void write_uint128_test()
|
|||||||
fn void write_tiny_bytearray_test()
|
fn void write_tiny_bytearray_test()
|
||||||
{
|
{
|
||||||
ByteWriter bw;
|
ByteWriter bw;
|
||||||
bw.temp_init();
|
bw.tinit();
|
||||||
io::write_tiny_bytearray(&bw, &&x"aabbcc00112233")!!;
|
io::write_tiny_bytearray(&bw, &&x"aabbcc00112233")!!;
|
||||||
assert(bw.str_view() == &&x'07aabbcc00112233');
|
assert(bw.str_view() == &&x'07aabbcc00112233');
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ fn void write_tiny_bytearray_test()
|
|||||||
fn void write_short_bytearray_test()
|
fn void write_short_bytearray_test()
|
||||||
{
|
{
|
||||||
ByteWriter bw;
|
ByteWriter bw;
|
||||||
bw.temp_init();
|
bw.tinit();
|
||||||
io::write_short_bytearray(&bw, &&x"aabbcc00112233")!!;
|
io::write_short_bytearray(&bw, &&x"aabbcc00112233")!!;
|
||||||
assert(bw.str_view() == &&x'0007aabbcc00112233');
|
assert(bw.str_view() == &&x'0007aabbcc00112233');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ fn void test_teereader()
|
|||||||
String want = "foobar";
|
String want = "foobar";
|
||||||
|
|
||||||
ByteWriter w;
|
ByteWriter w;
|
||||||
TeeReader r = tee_reader((ByteReader){}.init(want), w.temp_init());
|
TeeReader r = tee_reader((ByteReader){}.init(want), w.tinit());
|
||||||
|
|
||||||
char[16] buf;
|
char[16] buf;
|
||||||
usz n = r.read(buf[..])!!;
|
usz n = r.read(buf[..])!!;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import std::io;
|
|||||||
fn void write_read()
|
fn void write_read()
|
||||||
{
|
{
|
||||||
ByteBuffer buf;
|
ByteBuffer buf;
|
||||||
buf.temp_init(16);
|
buf.tinit(16);
|
||||||
usz n;
|
usz n;
|
||||||
uint x;
|
uint x;
|
||||||
uint y;
|
uint y;
|
||||||
@@ -45,7 +45,7 @@ fn void samples()
|
|||||||
foreach (tc : tcases)
|
foreach (tc : tcases)
|
||||||
{
|
{
|
||||||
ByteWriter bw;
|
ByteWriter bw;
|
||||||
bw.temp_init();
|
bw.tinit();
|
||||||
usz n = io::write_varint(&bw, tc.in)!!;
|
usz n = io::write_varint(&bw, tc.in)!!;
|
||||||
assert(n == tc.bytes.len, "got %d; want %d", n, tc.bytes.len);
|
assert(n == tc.bytes.len, "got %d; want %d", n, tc.bytes.len);
|
||||||
char[] bytes = bw.bytes[:bw.index];
|
char[] bytes = bw.bytes[:bw.index];
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ fn void test_query_values1()
|
|||||||
Url url = url::parse(mem, "foo://example.com:8042/over/there?name=ferret=ok#nose")!!;
|
Url url = url::parse(mem, "foo://example.com:8042/over/there?name=ferret=ok#nose")!!;
|
||||||
defer url.free();
|
defer url.free();
|
||||||
|
|
||||||
UrlQueryValues vals = url::temp_parse_query(url.query);
|
UrlQueryValues vals = url::parse_query_to_temp(url.query);
|
||||||
defer vals.free();
|
defer vals.free();
|
||||||
|
|
||||||
assert(vals.len() == 1);
|
assert(vals.len() == 1);
|
||||||
@@ -352,7 +352,7 @@ fn void test_query_values2()
|
|||||||
Url url = url::parse(mem, "foo://example.com:8042/over/there?name=ferret&age=99&age=11#nose")!!;
|
Url url = url::parse(mem, "foo://example.com:8042/over/there?name=ferret&age=99&age=11#nose")!!;
|
||||||
defer url.free();
|
defer url.free();
|
||||||
|
|
||||||
UrlQueryValues vals = url::new_parse_query(url.query);
|
UrlQueryValues vals = url::parse_query(mem, url.query);
|
||||||
defer vals.free();
|
defer vals.free();
|
||||||
assert(vals.len() == 2);
|
assert(vals.len() == 2);
|
||||||
|
|
||||||
@@ -371,7 +371,7 @@ fn void test_escaped_query_values()
|
|||||||
Url url = url::parse(mem, "foo://example.com:8042/over/there?k%3Bey=%3Ckey%3A+0x90%3E&age=99&age=11#nose")!!;
|
Url url = url::parse(mem, "foo://example.com:8042/over/there?k%3Bey=%3Ckey%3A+0x90%3E&age=99&age=11#nose")!!;
|
||||||
defer url.free();
|
defer url.free();
|
||||||
|
|
||||||
UrlQueryValues vals = url::new_parse_query(url.query);
|
UrlQueryValues vals = url::parse_query(mem, url.query);
|
||||||
defer vals.free();
|
defer vals.free();
|
||||||
assert(vals.len() == 2);
|
assert(vals.len() == 2);
|
||||||
|
|
||||||
@@ -385,7 +385,7 @@ fn void test_query_values_withempty()
|
|||||||
Url url = url::parse(mem, "foo://example.com:8042/over/there?name=ferret&&&age=99&age=11")!!;
|
Url url = url::parse(mem, "foo://example.com:8042/over/there?name=ferret&&&age=99&age=11")!!;
|
||||||
defer url.free();
|
defer url.free();
|
||||||
|
|
||||||
UrlQueryValues vals = url::new_parse_query(url.query);
|
UrlQueryValues vals = url::parse_query(mem, url.query);
|
||||||
defer vals.free();
|
defer vals.free();
|
||||||
assert(vals.len() == 2);
|
assert(vals.len() == 2);
|
||||||
}
|
}
|
||||||
@@ -426,7 +426,7 @@ fn void test_url_idempotence()
|
|||||||
Url parsed = url::parse(mem, url_string)!!;
|
Url parsed = url::parse(mem, url_string)!!;
|
||||||
defer parsed.free();
|
defer parsed.free();
|
||||||
|
|
||||||
UrlQueryValues vals = url::new_parse_query(parsed.query);
|
UrlQueryValues vals = url::parse_query(mem, parsed.query);
|
||||||
defer vals.free();
|
defer vals.free();
|
||||||
assert(vals.len() == 2);
|
assert(vals.len() == 2);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user