Change @return! syntax to require ":" after faults. Update all contracts to consistently use ":" before the description.

This commit is contained in:
Christoffer Lerno
2025-03-05 17:11:45 +01:00
parent cf0405930e
commit c0b80eccad
67 changed files with 645 additions and 637 deletions

View File

@@ -11,7 +11,7 @@ struct Atomic
<*
Loads data atomically, by default this uses SEQ_CONSISTENT ordering.
@param ordering "The ordering, cannot be release or acquire-release."
@param ordering : "The ordering, cannot be release or acquire-release."
@require ordering != RELEASE && ordering != ACQUIRE_RELEASE : "Release and acquire-release are not valid for load"
*>
macro Type Atomic.load(&self, AtomicOrdering ordering = SEQ_CONSISTENT)
@@ -31,7 +31,7 @@ macro Type Atomic.load(&self, AtomicOrdering ordering = SEQ_CONSISTENT)
<*
Stores data atomically, by default this uses SEQ_CONSISTENT ordering.
@param ordering "The ordering, cannot be acquire or acquire-release."
@param ordering : "The ordering, cannot be acquire or acquire-release."
@require ordering != ACQUIRE && ordering != ACQUIRE_RELEASE : "Acquire and acquire-release are not valid for store"
*>
macro void Atomic.store(&self, Type value, AtomicOrdering ordering = SEQ_CONSISTENT)
@@ -183,16 +183,16 @@ macro bool is_native_atomic_type($Type)
}
<*
@param [&in] ptr "the variable or dereferenced pointer to the data."
@param [in] y "the value to be added to ptr."
@param $ordering "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@param [&in] ptr : "the variable or dereferenced pointer to the data."
@param [in] y : "the value to be added to ptr."
@param $ordering : "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@return "returns the old value of ptr"
@require !$alignment || math::is_power_of_2($alignment) : "Alignment must be a power of two."
@require $defined(*ptr) : "Expected a pointer"
@require @is_native_atomic_value(*ptr) : "Only types that are native atomic may be used."
@require $defined(*ptr + y) : "+ must be defined between the values."
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED "Acquire ordering is not valid."
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED : "Acquire ordering is not valid."
*>
macro fetch_add(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT, bool $volatile = false, usz $alignment = 0)
{
@@ -203,16 +203,16 @@ macro fetch_add(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT, bool $volatil
}
<*
@param [&in] ptr "the variable or dereferenced pointer to the data."
@param [in] y "the value to be subtracted from ptr."
@param $ordering "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@param [&in] ptr : "the variable or dereferenced pointer to the data."
@param [in] y : "the value to be subtracted from ptr."
@param $ordering : "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@return "returns the old value of ptr"
@require !$alignment || math::is_power_of_2($alignment) "Alignment must be a power of two."
@require !$alignment || math::is_power_of_2($alignment) : "Alignment must be a power of two."
@require $defined(*ptr) : "Expected a pointer"
@require @is_native_atomic_value(*ptr) : "Only types that are native atomic may be used."
@require $defined(*ptr - y) : "- must be defined between the values."
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED "Acquire ordering is not valid."
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED : "Acquire ordering is not valid."
*>
macro fetch_sub(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT, bool $volatile = false, usz $alignment = 0)
{
@@ -223,15 +223,15 @@ macro fetch_sub(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT, bool $volatil
}
<*
@param [&in] ptr "the variable or dereferenced pointer to the data."
@param [in] y "the value to be multiplied with ptr."
@param $ordering "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@param [&in] ptr : "the variable or dereferenced pointer to the data."
@param [in] y : "the value to be multiplied with ptr."
@param $ordering : "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@return "returns the old value of ptr"
@require $defined(*ptr) : "Expected a pointer"
@require @is_native_atomic_value(*ptr) : "Only types that are native atomic may be used."
@require $defined(*ptr * y) : "* must be defined between the values."
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED "Acquire ordering is not valid."
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED : "Acquire ordering is not valid."
*>
macro fetch_mul(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT)
{
@@ -263,15 +263,15 @@ macro fetch_mul(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT)
}
<*
@param [&in] ptr "the variable or dereferenced pointer to the data."
@param [in] y "the value to divide ptr by."
@param $ordering "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@param [&in] ptr : "the variable or dereferenced pointer to the data."
@param [in] y : "the value to divide ptr by."
@param $ordering : "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@return "returns the old value of ptr"
@require $defined(*ptr) : "Expected a pointer"
@require @is_native_atomic_value(*ptr) : "Only types that are native atomic may be used."
@require $defined(*ptr * y) : "/ must be defined between the values."
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED "Acquire ordering is not valid."
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED : "Acquire ordering is not valid."
*>
macro fetch_div(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT)
{
@@ -303,16 +303,16 @@ macro fetch_div(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT)
}
<*
@param [&in] ptr "the variable or dereferenced pointer to the data."
@param [in] y "the value to perform a bitwise or with."
@param $ordering "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@param [&in] ptr : "the variable or dereferenced pointer to the data."
@param [in] y : "the value to perform a bitwise or with."
@param $ordering : "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@return "returns the old value of ptr"
@require !$alignment || math::is_power_of_2($alignment) "Alignment must be a power of two."
@require !$alignment || math::is_power_of_2($alignment) : "Alignment must be a power of two."
@require $defined(*ptr) : "Expected a pointer"
@require @is_native_atomic_value(*ptr) : "Only types that are native atomic may be used."
@require $defined(*ptr | y) : "| must be defined between the values."
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED "Acquire ordering is not valid."
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED : "Acquire ordering is not valid."
*>
macro fetch_or(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT, bool $volatile = false, usz $alignment = 0)
{
@@ -320,16 +320,16 @@ macro fetch_or(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT, bool $volatile
}
<*
@param [&in] ptr "the variable or dereferenced pointer to the data."
@param [in] y "the value to perform a bitwise xor with."
@param $ordering "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@param [&in] ptr : "the variable or dereferenced pointer to the data."
@param [in] y : "the value to perform a bitwise xor with."
@param $ordering : "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@return "returns the old value of ptr"
@require !$alignment || math::is_power_of_2($alignment) "Alignment must be a power of two."
@require !$alignment || math::is_power_of_2($alignment) : "Alignment must be a power of two."
@require $defined(*ptr) : "Expected a pointer"
@require @is_native_atomic_value(*ptr) : "Only types that are native atomic may be used."
@require $defined(*ptr ^ y) : "^ must be defined between the values."
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED "Acquire ordering is not valid."
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED : "Acquire ordering is not valid."
*>
macro fetch_xor(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT, bool $volatile = false, usz $alignment = 0)
{
@@ -337,16 +337,16 @@ macro fetch_xor(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT, bool $volatil
}
<*
@param [&in] ptr "the variable or dereferenced pointer to the data."
@param [in] y "the value to perform a bitwise and with."
@param $ordering "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@param [&in] ptr : "the variable or dereferenced pointer to the data."
@param [in] y : "the value to perform a bitwise and with."
@param $ordering : "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@return "returns the old value of ptr"
@require !$alignment || math::is_power_of_2($alignment) "Alignment must be a power of two."
@require !$alignment || math::is_power_of_2($alignment) : "Alignment must be a power of two."
@require $defined(*ptr) : "Expected a pointer"
@require @is_native_atomic_value(*ptr) : "Only types that are native atomic may be used."
@require $defined(*ptr ^ y) : "& must be defined between the values."
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED "Acquire ordering is not valid."
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED : "Acquire ordering is not valid."
*>
macro fetch_and(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT, bool $volatile = false, usz $alignment = 0)
{
@@ -354,16 +354,16 @@ macro fetch_and(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT, bool $volatil
}
<*
@param [&in] ptr "the variable or dereferenced pointer to the data."
@param [in] y "the value to shift ptr by."
@param $ordering "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@param [&in] ptr : "the variable or dereferenced pointer to the data."
@param [in] y : "the value to shift ptr by."
@param $ordering : "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@return "returns the old value of ptr"
@require $defined(*ptr) : "Expected a pointer"
@require @is_native_atomic_value(*ptr) : "Only types that are native atomic may be used."
@require types::is_int($typeof(*ptr)) "Only integer pointers may be used."
@require types::is_int($typeof(y)) "The value for shift right must be an integer"
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED "Acquire ordering is not valid."
@require types::is_int($typeof(*ptr)) : "Only integer pointers may be used."
@require types::is_int($typeof(y)) : "The value for shift right must be an integer"
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED : "Acquire ordering is not valid."
*>
macro fetch_shift_right(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT)
{
@@ -396,16 +396,16 @@ macro fetch_shift_right(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT)
}
<*
@param [&in] ptr "the variable or dereferenced pointer to the data."
@param [in] y "the value to shift ptr by."
@param $ordering "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@param [&in] ptr : "the variable or dereferenced pointer to the data."
@param [in] y : "the value to shift ptr by."
@param $ordering : "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@return "returns the old value of ptr"
@require $defined(*ptr) : "Expected a pointer"
@require @is_native_atomic_value(*ptr) : "Only types that are native atomic may be used."
@require types::is_int($typeof(*ptr)) "Only integer pointers may be used."
@require types::is_int($typeof(y)) "The value for shift left must be an integer"
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED "Acquire ordering is not valid."
@require types::is_int($typeof(*ptr)) : "Only integer pointers may be used."
@require types::is_int($typeof(y)) : "The value for shift left must be an integer"
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED : "Acquire ordering is not valid."
*>
macro fetch_shift_left(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT)
{
@@ -438,15 +438,15 @@ macro fetch_shift_left(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT)
}
<*
@param [&in] ptr "the variable or dereferenced pointer to the data."
@param $ordering "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@param [&in] ptr : "the variable or dereferenced pointer to the data."
@param $ordering : "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@return "returns the old value of ptr"
@require $defined(*ptr) : "Expected a pointer"
@require @is_native_atomic_value(*ptr) : "Only types that are native atomic may be used."
@require types::flat_kind($typeof(*ptr)) == BOOL "Only bool pointers may be used."
@require types::flat_kind($typeof(*ptr)) == BOOL : "Only bool pointers may be used."
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED "Acquire ordering is not valid."
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED : "Acquire ordering is not valid."
*>
macro flag_set(ptr, AtomicOrdering $ordering = SEQ_CONSISTENT)
{
@@ -466,8 +466,8 @@ macro flag_set(ptr, AtomicOrdering $ordering = SEQ_CONSISTENT)
}
<*
@param [&in] ptr "the variable or dereferenced pointer to the data."
@param $ordering "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@param [&in] ptr : "the variable or dereferenced pointer to the data."
@param $ordering : "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@return "returns the old value of ptr"
@require $defined(*ptr) : "Expected a pointer"
@@ -493,15 +493,15 @@ macro flag_clear(ptr, AtomicOrdering $ordering = SEQ_CONSISTENT)
}
<*
@param [&in] ptr "the variable or dereferenced pointer to the data."
@param [in] y "the value to be compared to ptr."
@param $ordering "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@param [&in] ptr : "the variable or dereferenced pointer to the data."
@param [in] y : "the value to be compared to ptr."
@param $ordering : "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@return "returns the old value of ptr"
@require $defined(*ptr) : "Expected a pointer"
@require @is_native_atomic_value(*ptr) : "Only types that are native atomic may be used."
@require $defined(*ptr > y) : "Only values that are comparable with > may be used"
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED "Acquire ordering is not valid."
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED : "Acquire ordering is not valid."
*>
macro fetch_max(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT, bool $volatile = false, usz $alignment = 0)
{
@@ -512,15 +512,15 @@ macro fetch_max(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT, bool $volatil
}
<*
@param [&in] ptr "the variable or dereferenced pointer to the data."
@param [in] y "the value to be compared to ptr."
@param $ordering "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@param [&in] ptr : "the variable or dereferenced pointer to the data."
@param [in] y : "the value to be compared to ptr."
@param $ordering : "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@return "returns the old value of ptr"
@require $defined(*ptr) : "Expected a pointer"
@require @is_native_atomic_value(*ptr) : "Only types that are native atomic may be used."
@require $defined(*ptr > y) : "Only values that are comparable with > may be used"
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED "Acquire ordering is not valid."
@require $ordering != AtomicOrdering.NOT_ATOMIC && $ordering != AtomicOrdering.UNORDERED : "Acquire ordering is not valid."
*>
macro fetch_min(ptr, y, AtomicOrdering $ordering = SEQ_CONSISTENT, bool $volatile = false, usz $alignment = 0)
{

View File

@@ -1,12 +1,12 @@
module std::bits;
<*
@require types::is_intlike($typeof(i)) `The input must be an integer or integer vector`
@require types::is_intlike($typeof(i)) : `The input must be an integer or integer vector`
*>
macro reverse(i) => $$bitreverse(i);
<*
@require types::is_intlike($typeof(i)) `The input must be an integer or integer vector`
@require types::is_intlike($typeof(i)) : `The input must be an integer or integer vector`
*>
macro bswap(i) @builtin => $$bswap(i);

View File

@@ -17,8 +17,8 @@ struct AnyList (Printable)
<*
@param [&inout] allocator "The allocator to use"
@param initial_capacity "The initial capacity to reserve"
@param [&inout] allocator : "The allocator to use"
@param initial_capacity : "The initial capacity to reserve"
*>
fn AnyList* AnyList.init(&self, Allocator allocator, usz initial_capacity = 16)
{
@@ -40,7 +40,7 @@ fn AnyList* AnyList.init(&self, Allocator allocator, usz initial_capacity = 16)
<*
Initialize the list using the temp allocator.
@param initial_capacity "The initial capacity to reserve"
@param initial_capacity : "The initial capacity to reserve"
*>
fn AnyList* AnyList.tinit(&self, usz initial_capacity = 16)
{
@@ -295,7 +295,7 @@ fn usz AnyList.len(&self) @operator(len) @inline
}
<*
@require index < self.size "Index out of range"
@require index < self.size : "Index out of range"
*>
macro AnyList.get(&self, usz index, $Type)
{
@@ -303,7 +303,7 @@ macro AnyList.get(&self, usz index, $Type)
}
<*
@require index < self.size "Index out of range"
@require index < self.size : "Index out of range"
*>
fn any AnyList.get_any(&self, usz index) @inline
{
@@ -327,7 +327,7 @@ fn void AnyList.swap(&self, usz i, usz j)
}
<*
@param filter "The function to determine if it should be removed or not"
@param filter : "The function to determine if it should be removed or not"
@return "the number of deleted elements"
*>
fn usz AnyList.remove_if(&self, AnyPredicate filter)
@@ -336,7 +336,7 @@ fn usz AnyList.remove_if(&self, AnyPredicate filter)
}
<*
@param selection "The function to determine if it should be kept or not"
@param selection : "The function to determine if it should be kept or not"
@return "the number of deleted elements"
*>
fn usz AnyList.retain_if(&self, AnyPredicate selection)
@@ -425,7 +425,7 @@ macro any AnyList.@item_at(&self, usz index) @operator([])
}
<*
@require index <= self.size "Index out of range"
@require index <= self.size : "Index out of range"
*>
macro void AnyList.set(&self, usz index, value)
{

View File

@@ -84,7 +84,7 @@ struct GrowableBitSet
<*
@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.init(&self, Allocator allocator, usz initial_capacity = 1)
{

View File

@@ -2,7 +2,7 @@
// Use of self source code is governed by the MIT license
// a copy of which can be found in the LICENSE_STDLIB file.
<*
@require MAX_SIZE >= 1 `The size must be at least 1 element big.`
@require MAX_SIZE >= 1 : `The size must be at least 1 element big.`
*>
module std::collections::elastic_array{Type, MAX_SIZE};
import std::io, std::math, std::collections::list_common;
@@ -51,7 +51,7 @@ fn void! ElasticArray.push_try(&self, Type element) @inline
}
<*
@require self.size < MAX_SIZE `Tried to exceed the max size`
@require self.size < MAX_SIZE : `Tried to exceed the max size`
*>
fn void ElasticArray.push(&self, Type element) @inline
{
@@ -136,7 +136,7 @@ fn usz ElasticArray.add_array_to_limit(&self, Type[] array)
Add the values of an array to this list.
@param [in] array
@require array.len + self.size <= MAX_SIZE `Size would exceed max.`
@require array.len + self.size <= MAX_SIZE : `Size would exceed max.`
@ensure self.size >= array.len
*>
fn void ElasticArray.add_array(&self, Type[] array)
@@ -189,7 +189,7 @@ fn Type[] ElasticArray.array_view(&self)
}
<*
@require self.size < MAX_SIZE `List would exceed max size`
@require self.size < MAX_SIZE : `List would exceed max size`
*>
fn void ElasticArray.push_front(&self, Type type) @inline
{
@@ -197,7 +197,7 @@ fn void ElasticArray.push_front(&self, Type type) @inline
}
<*
@require self.size < MAX_SIZE `List would exceed max size`
@require self.size < MAX_SIZE : `List would exceed max size`
*>
fn void! ElasticArray.push_front_try(&self, Type type) @inline
{
@@ -214,7 +214,7 @@ fn void! ElasticArray.insert_at_try(&self, usz index, Type value)
}
<*
@require self.size < MAX_SIZE `List would exceed max size`
@require self.size < MAX_SIZE : `List would exceed max size`
@require index <= self.size
*>
fn void ElasticArray.insert_at(&self, usz index, Type type)
@@ -285,7 +285,7 @@ fn void ElasticArray.swap(&self, usz i, usz j)
}
<*
@param filter "The function to determine if it should be removed or not"
@param filter : "The function to determine if it should be removed or not"
@return "the number of deleted elements"
*>
fn usz ElasticArray.remove_if(&self, ElementPredicate filter)
@@ -294,7 +294,7 @@ fn usz ElasticArray.remove_if(&self, ElementPredicate filter)
}
<*
@param selection "The function to determine if it should be kept or not"
@param selection : "The function to determine if it should be kept or not"
@return "the number of deleted elements"
*>
fn usz ElasticArray.retain_if(&self, ElementPredicate selection)
@@ -361,8 +361,8 @@ fn bool ElasticArray.equals(&self, ElasticArray other_list) @if(ELEMENT_IS_EQUAT
<*
Check for presence of a value in a list.
@param [&in] self "the list to find elements in"
@param value "The value to search for"
@param [&in] self : "the list to find elements in"
@param value : "The value to search for"
@return "True if the value is found, false otherwise"
*>
fn bool ElasticArray.contains(&self, Type value) @if(ELEMENT_IS_EQUATABLE)
@@ -375,8 +375,8 @@ fn bool ElasticArray.contains(&self, Type value) @if(ELEMENT_IS_EQUATABLE)
}
<*
@param [&inout] self "The list to remove elements from"
@param value "The value to remove"
@param [&inout] self : "The list to remove elements from"
@param value : "The value to remove"
@return "true if the value was found"
*>
fn bool ElasticArray.remove_last_item(&self, Type value) @if(ELEMENT_IS_EQUATABLE)
@@ -385,8 +385,8 @@ fn bool ElasticArray.remove_last_item(&self, Type value) @if(ELEMENT_IS_EQUATABL
}
<*
@param [&inout] self "The list to remove elements from"
@param value "The value to remove"
@param [&inout] self : "The list to remove elements from"
@param value : "The value to remove"
@return "true if the value was found"
*>
fn bool ElasticArray.remove_first_item(&self, Type value) @if(ELEMENT_IS_EQUATABLE)
@@ -395,8 +395,8 @@ fn bool ElasticArray.remove_first_item(&self, Type value) @if(ELEMENT_IS_EQUATAB
}
<*
@param [&inout] self "The list to remove elements from"
@param value "The value to remove"
@param [&inout] self : "The list to remove elements from"
@param value : "The value to remove"
@return "the number of deleted elements."
*>
fn usz ElasticArray.remove_item(&self, Type value) @if(ELEMENT_IS_EQUATABLE)

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by the MIT license
// a copy of which can be found in the LICENSE_STDLIB file.
<*
@require $defined((Key){}.hash()) `No .hash function found on the key`
@require $defined((Key){}.hash()) : `No .hash function found on the key`
*>
module std::collections::map{Key, Value};
import std::math;
@@ -132,7 +132,7 @@ fn HashMap* HashMap.tinit_from_keys_and_values(&self, Key[] keys, Value[] values
<*
Has this hash map been initialized yet?
@param [&in] map "The hash map we are testing"
@param [&in] map : "The hash map we are testing"
@return "Returns true if it has been initialized, false otherwise"
*>
fn bool HashMap.is_initialized(&map)
@@ -153,7 +153,7 @@ fn HashMap* HashMap.init_from_map(&self, Allocator allocator, HashMap* other_map
}
<*
@param [&in] other_map "The map to copy from."
@param [&in] other_map : "The map to copy from."
@require !map.is_initialized() : "Map was already initialized"
*>
fn HashMap* HashMap.tinit_from_map(&map, HashMap* other_map)

View File

@@ -21,7 +21,7 @@ struct LinkedList
}
<*
@param [&inout] allocator "The allocator to use, defaults to the heap allocator"
@param [&inout] allocator : "The allocator to use, defaults to the heap allocator"
@return "the initialized list"
*>
fn LinkedList* LinkedList.init(&self, Allocator allocator)

View File

@@ -24,8 +24,8 @@ struct List (Printable)
}
<*
@param initial_capacity "The initial capacity to reserve"
@param [&inout] allocator "The allocator to use, defaults to the heap allocator"
@param initial_capacity : "The initial capacity to reserve"
@param [&inout] allocator : "The allocator to use, defaults to the heap allocator"
*>
fn List* List.init(&self, Allocator allocator, usz initial_capacity = 16)
{
@@ -41,7 +41,7 @@ fn List* List.init(&self, Allocator allocator, usz initial_capacity = 16)
<*
Initialize the list using the temp allocator.
@param initial_capacity "The initial capacity to reserve"
@param initial_capacity : "The initial capacity to reserve"
*>
fn List* List.tinit(&self, usz initial_capacity = 16)
{
@@ -51,8 +51,8 @@ fn List* List.tinit(&self, usz initial_capacity = 16)
<*
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"
@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)
{
@@ -64,8 +64,8 @@ fn List* List.init_with_array(&self, Allocator allocator, Type[] values)
<*
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"
@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)
{
@@ -75,7 +75,7 @@ fn List* List.tinit_with_array(&self, Type[] values)
}
<*
@require self.capacity == 0 "The List must not be allocated"
@require self.capacity == 0 : "The List must not be allocated"
*>
fn void List.init_wrapping_array(&self, Allocator allocator, Type[] types)
{
@@ -131,7 +131,7 @@ fn Type! List.pop_first(&self)
}
<*
@require index < self.size `Removed element out of bounds`
@require index < self.size : `Removed element out of bounds`
*>
fn void List.remove_at(&self, usz index)
{
@@ -210,7 +210,7 @@ fn void List.push_front(&self, Type type) @inline
}
<*
@require index <= self.size `Insert was out of bounds`
@require index <= self.size : `Insert was out of bounds`
*>
fn void List.insert_at(&self, usz index, Type type)
{
@@ -271,7 +271,7 @@ fn usz List.len(&self) @operator(len) @inline
}
<*
@require index < self.size `Access out of bounds`
@require index < self.size : `Access out of bounds`
*>
fn Type List.get(&self, usz index) @inline
{
@@ -295,7 +295,7 @@ fn void List.free(&self)
}
<*
@require i < self.size && j < self.size `Access out of bounds`
@require i < self.size && j < self.size : `Access out of bounds`
*>
fn void List.swap(&self, usz i, usz j)
{
@@ -303,7 +303,7 @@ fn void List.swap(&self, usz i, usz j)
}
<*
@param filter "The function to determine if it should be removed or not"
@param filter : "The function to determine if it should be removed or not"
@return "the number of deleted elements"
*>
fn usz List.remove_if(&self, ElementPredicate filter)
@@ -312,7 +312,7 @@ fn usz List.remove_if(&self, ElementPredicate filter)
}
<*
@param selection "The function to determine if it should be kept or not"
@param selection : "The function to determine if it should be kept or not"
@return "the number of deleted elements"
*>
fn usz List.retain_if(&self, ElementPredicate selection)
@@ -371,7 +371,7 @@ fn void List.ensure_capacity(&self, usz min_capacity) @local
}
<*
@require index < self.size `Access out of bounds`
@require index < self.size : `Access out of bounds`
*>
macro Type List.@item_at(&self, usz index) @operator([])
{
@@ -379,7 +379,7 @@ macro Type List.@item_at(&self, usz index) @operator([])
}
<*
@require index < self.size `Access out of bounds`
@require index < self.size : `Access out of bounds`
*>
fn Type* List.get_ref(&self, usz index) @operator(&[]) @inline
{
@@ -387,7 +387,7 @@ fn Type* List.get_ref(&self, usz index) @operator(&[]) @inline
}
<*
@require index < self.size `Access out of bounds`
@require index < self.size : `Access out of bounds`
*>
fn void List.set(&self, usz index, Type value) @operator([]=)
{
@@ -475,8 +475,8 @@ fn bool List.equals(&self, List other_list) @if(ELEMENT_IS_EQUATABLE)
<*
Check for presence of a value in a list.
@param [&in] self "the list to find elements in"
@param value "The value to search for"
@param [&in] self : "the list to find elements in"
@param value : "The value to search for"
@return "True if the value is found, false otherwise"
*>
fn bool List.contains(&self, Type value) @if(ELEMENT_IS_EQUATABLE)
@@ -489,8 +489,8 @@ fn bool List.contains(&self, Type value) @if(ELEMENT_IS_EQUATABLE)
}
<*
@param [&inout] self "The list to remove elements from"
@param value "The value to remove"
@param [&inout] self : "The list to remove elements from"
@param value : "The value to remove"
@return "true if the value was found"
*>
fn bool List.remove_last_item(&self, Type value) @if(ELEMENT_IS_EQUATABLE)
@@ -499,8 +499,8 @@ fn bool List.remove_last_item(&self, Type value) @if(ELEMENT_IS_EQUATABLE)
}
<*
@param [&inout] self "The list to remove elements from"
@param value "The value to remove"
@param [&inout] self : "The list to remove elements from"
@param value : "The value to remove"
@return "true if the value was found"
*>
fn bool List.remove_first_item(&self, Type value) @if(ELEMENT_IS_EQUATABLE)
@@ -508,8 +508,8 @@ fn bool List.remove_first_item(&self, Type value) @if(ELEMENT_IS_EQUATABLE)
return @ok(self.remove_at(self.index_of(value)));
}
<*
@param [&inout] self "The list to remove elements from"
@param value "The value to remove"
@param [&inout] self : "The list to remove elements from"
@param value : "The value to remove"
@return "the number of deleted elements."
*>
fn usz List.remove_item(&self, Type value) @if(ELEMENT_IS_EQUATABLE)

View File

@@ -292,7 +292,7 @@ fn void Object.set_object_at(&self, usz index, Object* to_set)
}
<*
@require $Type.kindof.is_int() "Expected an integer type."
@require $Type.kindof.is_int() : "Expected an integer type."
*>
macro get_integer_value(Object* value, $Type)
{

View File

@@ -67,9 +67,9 @@ import std::io;
The function returns an optional, which can either be a QOIError
or the number of bytes written on success.
@param [in] filename `The file's name to write the image to`
@param [in] input `The raw RGB or RGBA pixels to encode`
@param [&in] desc `The descriptor of the image`
@param [in] filename : `The file's name to write the image to`
@param [in] input : `The raw RGB or RGBA pixels to encode`
@param [&in] desc : `The descriptor of the image`
*>
fn usz! write(String filename, char[] input, QOIDesc* desc) => @pool()
{
@@ -98,9 +98,9 @@ fn usz! write(String filename, char[] input, QOIDesc* desc) => @pool()
The returned pixel data should be free()d after use, or the decoding
and use of the data should be wrapped in a @pool() { ... }; block.
@param [in] filename `The file's name to read the image from`
@param [&out] desc `The descriptor to fill with the image's info`
@param channels `The channels to be used`
@param [in] filename : `The file's name to read the image from`
@param [&out] desc : `The descriptor to fill with the image's info`
@param channels : `The channels to be used`
*>
fn char[]! read(Allocator allocator, String filename, QOIDesc* desc, QOIChannels channels = AUTO) => @pool(allocator)
{
@@ -126,8 +126,8 @@ import std::bits;
and use of the data should be wrapped in a @pool() { ... }; block.
See the write() function for an example.
@param [in] input `The raw RGB or RGBA pixels to encode`
@param [&in] desc `The descriptor of the image`
@param [in] input : `The raw RGB or RGBA pixels to encode`
@param [&in] desc : `The descriptor of the image`
*>
fn char[]! encode(Allocator allocator, char[] input, QOIDesc* desc) @nodiscard
{
@@ -279,9 +279,9 @@ fn char[]! encode(Allocator allocator, char[] input, QOIDesc* desc) @nodiscard
The returned pixel data should be free()d after use, or the decoding
and use of the data should be wrapped in a @pool() { ... }; block.
@param [in] data `The QOI image data to decode`
@param [&out] desc `The descriptor to fill with the image's info`
@param channels `The channels to be used`
@param [in] data : `The QOI image data to decode`
@param [&out] desc : `The descriptor to fill with the image's info`
@param channels : `The channels to be used`
*>
fn char[]! decode(Allocator allocator, char[] data, QOIDesc* desc, QOIChannels channels = AUTO) @nodiscard
{

View File

@@ -55,7 +55,7 @@ fn void ArenaAllocator.reset(&self, usz mark) @dynamic => self.used = mark;
<*
@require !alignment || math::is_power_of_2(alignment)
@require alignment <= mem::MAX_MEMORY_ALIGNMENT `alignment too big`
@require alignment <= mem::MAX_MEMORY_ALIGNMENT : `alignment too big`
@require size > 0
*>
fn void*! ArenaAllocator.acquire(&self, usz size, AllocInitType init_type, usz alignment) @dynamic
@@ -77,7 +77,7 @@ fn void*! ArenaAllocator.acquire(&self, usz size, AllocInitType init_type, usz a
<*
@require !alignment || math::is_power_of_2(alignment)
@require alignment <= mem::MAX_MEMORY_ALIGNMENT `alignment too big`
@require alignment <= mem::MAX_MEMORY_ALIGNMENT : `alignment too big`
@require old_pointer != null
@require size > 0
*>

View File

@@ -62,7 +62,7 @@ struct DynamicArenaChunk @local
<*
@require ptr != null
@require self.page != null `tried to free pointer on invalid allocator`
@require self.page != null : `tried to free pointer on invalid allocator`
*>
fn void DynamicArenaAllocator.release(&self, void* ptr, bool) @dynamic
{
@@ -75,9 +75,9 @@ fn void DynamicArenaAllocator.release(&self, void* ptr, bool) @dynamic
}
<*
@require size > 0 `Resize doesn't support zeroing`
@require old_pointer != null `Resize doesn't handle null pointers`
@require self.page != null `tried to realloc pointer on invalid allocator`
@require size > 0 : `Resize doesn't support zeroing`
@require old_pointer != null : `Resize doesn't handle null pointers`
@require self.page != null : `tried to realloc pointer on invalid allocator`
*>
fn void*! DynamicArenaAllocator.resize(&self, void* old_pointer, usz size, usz alignment) @dynamic
{
@@ -157,7 +157,7 @@ fn void*! DynamicArenaAllocator._alloc_new(&self, usz size, usz alignment) @loca
}
<*
@require size > 0 `acquire expects size > 0`
@require size > 0 : `acquire expects size > 0`
@require !alignment || math::is_power_of_2(alignment)
*>
fn void*! DynamicArenaAllocator.acquire(&self, usz size, AllocInitType init_type, usz alignment) @dynamic

View File

@@ -12,8 +12,8 @@ struct SimpleHeapAllocator (Allocator)
}
<*
@require allocator != null "An underlying memory provider must be given"
@require !self.free_list "The allocator may not be already initialized"
@require allocator != null : "An underlying memory provider must be given"
@require !self.free_list : "The allocator may not be already initialized"
*>
fn void SimpleHeapAllocator.init(&self, MemoryAllocFn allocator)
{

View File

@@ -102,7 +102,7 @@ fn OnStackAllocatorExtraChunk* on_stack_allocator_find_chunk(OnStackAllocator* a
<*
@require size > 0
@require old_pointer != null
@require alignment <= mem::MAX_MEMORY_ALIGNMENT `alignment too big`
@require alignment <= mem::MAX_MEMORY_ALIGNMENT : `alignment too big`
*>
fn void*! OnStackAllocator.resize(&self, void* old_pointer, usz size, usz alignment) @dynamic
{
@@ -121,7 +121,7 @@ fn void*! OnStackAllocator.resize(&self, void* old_pointer, usz size, usz alignm
}
<*
@require alignment <= mem::MAX_MEMORY_ALIGNMENT `alignment too big`
@require alignment <= mem::MAX_MEMORY_ALIGNMENT : `alignment too big`
@require size > 0
*>
fn void*! OnStackAllocator.acquire(&self, usz size, AllocInitType init_type, usz alignment) @dynamic

View File

@@ -137,7 +137,7 @@ fn void*! TempAllocator.resize(&self, void* pointer, usz size, usz alignment) @d
<*
@require size > 0
@require !alignment || math::is_power_of_2(alignment)
@require alignment <= mem::MAX_MEMORY_ALIGNMENT `alignment too big`
@require alignment <= mem::MAX_MEMORY_ALIGNMENT : `alignment too big`
*>
fn void*! TempAllocator.acquire(&self, usz size, AllocInitType init_type, usz alignment) @dynamic
{

View File

@@ -29,7 +29,7 @@ struct TrackingAllocator (Allocator)
<*
Initialize a tracking allocator to wrap (and track) another allocator.
@param [&inout] allocator "The allocator to track"
@param [&inout] allocator : "The allocator to track"
*>
fn void TrackingAllocator.init(&self, Allocator allocator)
{

View File

@@ -50,10 +50,10 @@ macro rindex_of(array, element)
@param [in] arr1
@param [in] arr2
@param [&inout] allocator "The allocator to use, default is the heap allocator"
@param [&inout] allocator : "The allocator to use, default is the heap allocator"
@require @typekind(arr1) == SLICE || @typekind(arr1) == ARRAY
@require @typekind(arr2) == SLICE || @typekind(arr2) == ARRAY
@require @typeis(arr1[0], $typeof(arr2[0])) "Arrays must have the same type"
@require @typeis(arr1[0], $typeof(arr2[0])) : "Arrays must have the same type"
@ensure result.len == arr1.len + arr2.len
*>
macro concat(Allocator allocator, arr1, arr2) @nodiscard
@@ -78,7 +78,7 @@ macro concat(Allocator allocator, arr1, arr2) @nodiscard
@param [in] arr2
@require @typekind(arr1) == SLICE || @typekind(arr1) == ARRAY
@require @typekind(arr2) == SLICE || @typekind(arr2) == ARRAY
@require @typeis(arr1[0], $typeof(arr2[0])) "Arrays must have the same type"
@require @typeis(arr1[0], $typeof(arr2[0])) : "Arrays must have the same type"
@ensure return.len == arr1.len + arr2.len
*>
macro tconcat(arr1, arr2) @nodiscard => concat(allocator::temp(), arr1, arr2);

View File

@@ -88,8 +88,8 @@ bitstruct UInt128LE : uint128 @littleendian
}
<*
@require is_array_or_slice_of_char(bytes) "argument must be an array, a pointer to an array or a slice of char"
@require is_bitorder($Type) "type must be a bitorder integer"
@require is_array_or_slice_of_char(bytes) : "argument must be an array, a pointer to an array or a slice of char"
@require is_bitorder($Type) : "type must be a bitorder integer"
*>
macro read(bytes, $Type)
{
@@ -104,8 +104,8 @@ macro read(bytes, $Type)
}
<*
@require is_arrayptr_or_slice_of_char(bytes) "argument must be a pointer to an array or a slice of char"
@require is_bitorder($Type) "type must be a bitorder integer"
@require is_arrayptr_or_slice_of_char(bytes) : "argument must be a pointer to an array or a slice of char"
@require is_bitorder($Type) : "type must be a bitorder integer"
*>
macro write(x, bytes, $Type)
{

View File

@@ -51,7 +51,7 @@ def VoidFn = fn void();
Stores a variable on the stack, then restores it at the end of the
macro scope.
@param #variable `the variable to store and restore`
@param #variable : `the variable to store and restore`
@require values::@is_lvalue(#variable)
*>
macro void @scope(#variable; @body) @builtin
@@ -63,7 +63,7 @@ macro void @scope(#variable; @body) @builtin
<*
Swap two variables
@require $defined(#a = #b, #b = #a) `The values must be mutually assignable`
@require $defined(#a = #b, #b = #a) : `The values must be mutually assignable`
*>
macro void @swap(#a, #b) @builtin
{
@@ -75,8 +75,8 @@ macro void @swap(#a, #b) @builtin
<*
Convert an `any` type to a type, returning an failure if there is a type mismatch.
@param v `the any to convert to the given type.`
@param $Type `the type to convert to`
@param v : `the any to convert to the given type.`
@param $Type : `the type to convert to`
@return `The any.ptr converted to its type.`
@ensure @typeis(return, $Type*)
@return! CastResult.TYPE_MISMATCH
@@ -181,7 +181,7 @@ fn void panicf(String fmt, String file, String function, uint line, args...)
<*
Marks the path as unreachable. This will panic in safe mode, and in fast will simply be assumed
never happens.
@param [in] string "The panic message or format string"
@param [in] string : "The panic message or format string"
*>
macro void unreachable(String string = "Unreachable statement reached.", ...) @builtin @noreturn
{
@@ -193,7 +193,7 @@ macro void unreachable(String string = "Unreachable statement reached.", ...) @b
<*
Marks the path as unsupported, this is similar to unreachable.
@param [in] string "The error message"
@param [in] string : "The error message"
*>
macro void unsupported(String string = "Unsupported function invoked") @builtin @noreturn
{
@@ -225,10 +225,10 @@ macro any.as_inner(&self)
}
<*
@param expr "the expression to cast"
@param $Type "the type to cast to"
@param expr : "the expression to cast"
@param $Type : "the type to cast to"
@require $sizeof(expr) == $Type.sizeof "Cannot bitcast between types of different size."
@require $sizeof(expr) == $Type.sizeof : "Cannot bitcast between types of different size."
@ensure @typeis(return, $Type)
*>
macro bitcast(expr, $Type) @builtin
@@ -243,9 +243,9 @@ macro bitcast(expr, $Type) @builtin
}
<*
@param $Type `The type of the enum`
@param [in] enum_name `The name of the enum to search for`
@require $Type.kindof == ENUM `Only enums may be used`
@param $Type : `The type of the enum`
@param [in] enum_name : `The name of the enum to search for`
@require $Type.kindof == ENUM : `Only enums may be used`
@ensure @typeis(return, $Type)
@return! SearchResult.MISSING
*>
@@ -260,10 +260,10 @@ macro enum_by_name($Type, String enum_name) @builtin
}
<*
@param $Type `The type of the enum`
@require $Type.kindof == ENUM `Only enums may be used`
@require $defined($Type.#value) `Expected '#value' to match an enum associated value`
@require $assignable(value, $typeof(($Type){}.#value)) `Expected the value to match the type of the associated value`
@param $Type : `The type of the enum`
@require $Type.kindof == ENUM : `Only enums may be used`
@require $defined($Type.#value) : `Expected '#value' to match an enum associated value`
@require $assignable(value, $typeof(($Type){}.#value)) : `Expected the value to match the type of the associated value`
@ensure @typeis(return, $Type)
@return! SearchResult.MISSING
*>
@@ -280,8 +280,8 @@ macro @enum_from_value($Type, #value, value) @builtin
<*
Mark an expression as likely to be true
@param #value "expression to be marked likely"
@param $probability "in the range 0 - 1"
@param #value : "expression to be marked likely"
@param $probability : "in the range 0 - 1"
@require $probability >= 0 && $probability <= 1.0
*>
macro bool @likely(bool #value, $probability = 1.0) @builtin
@@ -299,8 +299,8 @@ macro bool @likely(bool #value, $probability = 1.0) @builtin
<*
Mark an expression as unlikely to be true
@param #value "expression to be marked unlikely"
@param $probability "in the range 0 - 1"
@param #value : "expression to be marked unlikely"
@param $probability : "in the range 0 - 1"
@require $probability >= 0 && $probability <= 1.0
*>
macro bool @unlikely(bool #value, $probability = 1.0) @builtin
@@ -347,9 +347,9 @@ enum PrefetchLocality
<*
Prefetch a pointer.
@param [in] ptr `Pointer to prefetch`
@param $locality `Locality ranging from none to extremely local`
@param $write `Prefetch for write, otherwise prefetch for read.`
@param [in] ptr : `Pointer to prefetch`
@param $locality : `Locality ranging from none to extremely local`
@param $write : `Prefetch for write, otherwise prefetch for read.`
*>
macro @prefetch(void* ptr, PrefetchLocality $locality = VERY_NEAR, bool $write = false) @builtin
{
@@ -392,7 +392,7 @@ macro bool @ok(#expr) @builtin
}
<*
@require $defined(&#value, (char*)&#value) "This must be a value that can be viewed as a char array"
@require $defined(&#value, (char*)&#value) : "This must be a value that can be viewed as a char array"
*>
macro char[] @as_char_view(#value) @builtin
{

View File

@@ -78,7 +78,7 @@ macro greater_eq(a, b) @builtin
}
<*
@require types::@equatable_value(a) && types::@equatable_value(b) `values must be equatable`
@require types::@equatable_value(a) && types::@equatable_value(b) : `values must be equatable`
*>
macro bool equals(a, b) @builtin
{

View File

@@ -10,8 +10,8 @@ const uint UTF16_SURROGATE_LOW_VALUE @private = 0xDC00;
const uint UTF16_SURROGATE_HIGH_VALUE @private = 0xD800;
<*
@param c `The utf32 codepoint to convert`
@param [out] output `the resulting buffer`
@param c : `The utf32 codepoint to convert`
@param [out] output : `the resulting buffer`
*>
fn usz! char32_to_utf8(Char32 c, char[] output)
{
@@ -48,8 +48,8 @@ fn usz! char32_to_utf8(Char32 c, char[] output)
<*
Convert a code pointer into 1-2 UTF16 characters.
@param c `The character to convert.`
@param [inout] output `the resulting UTF16 buffer to write to.`
@param c : `The character to convert.`
@param [inout] output : `the resulting UTF16 buffer to write to.`
*>
fn void char32_to_utf16_unsafe(Char32 c, Char16** output)
{
@@ -69,9 +69,9 @@ fn void char32_to_utf16_unsafe(Char32 c, Char16** output)
<*
Convert 1-2 UTF16 data points into UTF8.
@param [in] ptr `The UTF16 data to convert.`
@param [inout] available `amount of UTF16 data available.`
@param [inout] output `the resulting utf8 buffer to write to.`
@param [in] ptr : `The UTF16 data to convert.`
@param [inout] available : `amount of UTF16 data available.`
@param [inout] output : `the resulting utf8 buffer to write to.`
*>
fn void! char16_to_utf8_unsafe(Char16 *ptr, usz *available, char** output)
{
@@ -101,8 +101,8 @@ fn void! char16_to_utf8_unsafe(Char16 *ptr, usz *available, char** output)
*available = 2;
}
<*
@param c `The utf32 codepoint to convert`
@param [inout] output `the resulting buffer`
@param c : `The utf32 codepoint to convert`
@param [inout] output : `the resulting buffer`
*>
fn usz char32_to_utf8_unsafe(Char32 c, char** output)
{
@@ -130,8 +130,8 @@ fn usz char32_to_utf8_unsafe(Char32 c, char** output)
}
<*
@param [in] ptr `pointer to the first character to parse`
@param [inout] size `Set to max characters to read, set to characters read`
@param [in] ptr : `pointer to the first character to parse`
@param [inout] size : `Set to max characters to read, set to characters read`
@return `the parsed 32 bit codepoint`
*>
fn Char32! utf8_to_char32(char* ptr, usz* size)
@@ -185,7 +185,7 @@ fn Char32! utf8_to_char32(char* ptr, usz* size)
}
<*
@param utf8 `An UTF-8 encoded slice of bytes`
@param utf8 : `An UTF-8 encoded slice of bytes`
@return `the number of encoded code points`
*>
fn usz utf8_codepoints(String utf8)
@@ -200,7 +200,7 @@ fn usz utf8_codepoints(String utf8)
<*
Calculate the UTF8 length required to encode an UTF32 array.
@param [in] utf32 `the utf32 data to calculate from`
@param [in] utf32 : `the utf32 data to calculate from`
@return `the length of the resulting UTF8 array`
*>
fn usz utf8len_for_utf32(Char32[] utf32)
@@ -225,7 +225,7 @@ fn usz utf8len_for_utf32(Char32[] utf32)
<*
Calculate the UTF8 length required to encode an UTF16 array.
@param [in] utf16 `the utf16 data to calculate from`
@param [in] utf16 : `the utf16 data to calculate from`
@return `the length of the resulting UTF8 array`
*>
fn usz utf8len_for_utf16(Char16[] utf16)
@@ -257,7 +257,7 @@ fn usz utf8len_for_utf16(Char16[] utf16)
<*
Calculate the UTF16 length required to encode a UTF8 array.
@param utf8 `the utf8 data to calculate from`
@param utf8 : `the utf8 data to calculate from`
@return `the length of the resulting UTF16 array`
*>
fn usz utf16len_for_utf8(String utf8)
@@ -280,7 +280,7 @@ fn usz utf16len_for_utf8(String utf8)
}
<*
@param [in] utf32 `the UTF32 array to check the length for`
@param [in] utf32 : `the UTF32 array to check the length for`
@return `the required length of an UTF16 array to hold the UTF32 data.`
*>
fn usz utf16len_for_utf32(Char32[] utf32)
@@ -344,8 +344,8 @@ fn usz! utf8to32(String utf8, Char32[] utf32_buffer)
checking. This will assume the buffer is sufficiently large to hold
the converted data.
@param [in] utf16 `The UTF16 array containing the data to convert.`
@param [out] utf8_buffer `the (sufficiently large) buffer to hold the UTF16 data.`
@param [in] utf16 : `The UTF16 array containing the data to convert.`
@param [out] utf8_buffer : `the (sufficiently large) buffer to hold the UTF16 data.`
*>
fn void! utf16to8_unsafe(Char16[] utf16, char* utf8_buffer)
{
@@ -363,8 +363,8 @@ fn void! utf16to8_unsafe(Char16[] utf16, char* utf8_buffer)
checking. This will assume the buffer is sufficiently large to hold
the converted data.
@param [in] utf8 `The UTF8 buffer containing the data to convert.`
@param [out] utf32_buffer `the (sufficiently large) buffer to hold the UTF8 data.`
@param [in] utf8 : `The UTF8 buffer containing the data to convert.`
@param [out] utf32_buffer : `the (sufficiently large) buffer to hold the UTF8 data.`
*>
fn void! utf8to32_unsafe(String utf8, Char32* utf32_buffer)
{
@@ -383,8 +383,8 @@ fn void! utf8to32_unsafe(String utf8, Char32* utf32_buffer)
checking. This will assume the buffer is sufficiently large to hold
the converted data.
@param [in] utf8 `The UTF8 buffer containing the data to convert.`
@param [out] utf16_buffer `the (sufficiently large) buffer to hold the UTF8 data.`
@param [in] utf8 : `The UTF8 buffer containing the data to convert.`
@param [out] utf16_buffer : `the (sufficiently large) buffer to hold the UTF8 data.`
*>
fn void! utf8to16_unsafe(String utf8, Char16* utf16_buffer)
{
@@ -403,8 +403,8 @@ fn void! utf8to16_unsafe(String utf8, Char16* utf16_buffer)
checking. This will assume the buffer is sufficiently large to hold
the converted data.
@param [in] utf32 `The UTF32 buffer containing the data to convert.`
@param [out] utf8_buffer `the (sufficiently large) buffer to hold the UTF8 data.`
@param [in] utf32 : `The UTF32 buffer containing the data to convert.`
@param [out] utf8_buffer : `the (sufficiently large) buffer to hold the UTF8 data.`
*>
fn void utf32to8_unsafe(Char32[] utf32, char* utf8_buffer)
{

View File

@@ -7,7 +7,7 @@ distinct DStringOpaque = void;
const usz MIN_CAPACITY @private = 16;
<*
@require !self.data() "String already initialized"
@require !self.data() : "String already initialized"
*>
fn DString DString.init(&self, Allocator allocator, usz capacity = MIN_CAPACITY)
{
@@ -20,7 +20,7 @@ fn DString DString.init(&self, Allocator allocator, usz capacity = MIN_CAPACITY)
}
<*
@require !self.data() "String already initialized"
@require !self.data() : "String already initialized"
*>
fn DString DString.tinit(&self, usz capacity = MIN_CAPACITY)
{
@@ -156,7 +156,7 @@ fn String DString.str_view(self)
<*
@require index < self.len()
@require self.data() != null "Empty string"
@require self.data() != null : "Empty string"
*>
fn char DString.char_at(self, usz index) @operator([])
{
@@ -165,7 +165,7 @@ fn char DString.char_at(self, usz index) @operator([])
<*
@require index < self.len()
@require self.data() != null "Empty string"
@require self.data() != null : "Empty string"
*>
fn char* DString.char_ref(&self, usz index) @operator(&[])
{
@@ -349,7 +349,7 @@ fn void DString.append_char(&self, char c)
<*
@require start < self.len()
@require end < self.len()
@require end >= start "End must be same or equal to the start"
@require end >= start : "End must be same or equal to the start"
*>
fn void DString.delete_range(&self, usz start, usz end)
{

View File

@@ -16,9 +16,9 @@ macro bool @constant_is_power_of_2($x) @const @private
<*
Load a vector from memory according to a mask assuming default alignment.
@param ptr "The pointer address to load from."
@param mask "The mask for the load"
@param passthru "The value to use for non masked values"
@param ptr : "The pointer address to load from."
@param mask : "The mask for the load"
@param passthru : "The value to use for non masked values"
@require $assignable(&&passthru, $typeof(ptr)) : "Pointer and passthru must match"
@require @typekind(passthru) == VECTOR : "Expected passthru to be a vector"
@require passthru.len == mask.len : "Mask and passthru must have the same length"
@@ -33,10 +33,10 @@ macro masked_load(ptr, bool[<?>] mask, passthru)
<*
Load a vector from memory according to a mask.
@param ptr "The pointer address to load from."
@param mask "The mask for the load"
@param passthru "The value to use for non masked values"
@param $alignment "The alignment to assume for the pointer"
@param ptr : "The pointer address to load from."
@param mask : "The mask for the load"
@param passthru : "The value to use for non masked values"
@param $alignment : "The alignment to assume for the pointer"
@require $assignable(&&passthru, $typeof(ptr)) : "Pointer and passthru must match"
@require @typekind(passthru) == VECTOR : "Expected passthru to be a vector"
@@ -53,9 +53,9 @@ macro @masked_load_aligned(ptr, bool[<?>] mask, passthru, usz $alignment)
<*
Load values from a pointer vector, assuming default alignment.
@param ptrvec "The vector of pointers to load from."
@param mask "The mask for the load"
@param passthru "The value to use for non masked values"
@param ptrvec : "The vector of pointers to load from."
@param mask : "The mask for the load"
@param passthru : "The value to use for non masked values"
@require @typekind(ptrvec) == VECTOR : "Expected ptrvec to be a vector"
@require @typekind(passthru) == VECTOR : "Expected passthru to be a vector"
@@ -74,10 +74,10 @@ macro gather(ptrvec, bool[<?>] mask, passthru)
<*
Load values from a pointer vector.
@param ptrvec "The vector of pointers to load from."
@param mask "The mask for the load"
@param passthru "The value to use for non masked values"
@param $alignment "The alignment to assume for the pointers"
@param ptrvec : "The vector of pointers to load from."
@param mask : "The mask for the load"
@param passthru : "The value to use for non masked values"
@param $alignment : "The alignment to assume for the pointers"
@require @typekind(ptrvec) == VECTOR : "Expected ptrvec to be a vector"
@require @typekind(passthru) == VECTOR : "Expected passthru to be a vector"
@@ -97,9 +97,9 @@ macro @gather_aligned(ptrvec, bool[<?>] mask, passthru, usz $alignment)
<*
Store parts of a vector according to the mask, assuming default alignment.
@param ptr "The pointer address to store to."
@param value "The value to store masked"
@param mask "The mask for the store"
@param ptr : "The pointer address to store to."
@param value : "The value to store masked"
@param mask : "The mask for the store"
@require $assignable(&&value, $typeof(ptr)) : "Pointer and value must match"
@require @typekind(value) == VECTOR : "Expected value to be a vector"
@@ -111,10 +111,10 @@ macro masked_store(ptr, value, bool[<?>] mask)
}
<*
@param ptr "The pointer address to store to."
@param value "The value to store masked"
@param mask "The mask for the store"
@param $alignment "The alignment of the pointer"
@param ptr : "The pointer address to store to."
@param value : "The value to store masked"
@param mask : "The mask for the store"
@param $alignment : "The alignment of the pointer"
@require $assignable(&&value, $typeof(ptr)) : "Pointer and value must match"
@require @typekind(value) == VECTOR : "Expected value to be a vector"
@@ -128,9 +128,9 @@ macro @masked_store_aligned(ptr, value, bool[<?>] mask, usz $alignment)
}
<*
@param ptrvec "The vector pointer containing the addresses to store to."
@param value "The value to store masked"
@param mask "The mask for the store"
@param ptrvec : "The vector pointer containing the addresses to store to."
@param value : "The value to store masked"
@param mask : "The mask for the store"
@require @typekind(ptrvec) == VECTOR : "Expected ptrvec to be a vector"
@require @typekind(value) == VECTOR : "Expected value to be a vector"
@require $assignable(&&value[0], $typeof(ptrvec[0])) : "Pointer and value must match"
@@ -144,10 +144,10 @@ macro scatter(ptrvec, value, bool[<?>] mask)
}
<*
@param ptrvec "The vector pointer containing the addresses to store to."
@param value "The value to store masked"
@param mask "The mask for the store"
@param $alignment "The alignment of the load"
@param ptrvec : "The vector pointer containing the addresses to store to."
@param value : "The value to store masked"
@param mask : "The mask for the store"
@param $alignment : "The alignment of the load"
@require @typekind(ptrvec) == VECTOR : "Expected ptrvec to be a vector"
@require @typekind(value) == VECTOR : "Expected value to be a vector"
@@ -162,8 +162,8 @@ macro @scatter_aligned(ptrvec, value, bool[<?>] mask, usz $alignment)
}
<*
@param #x "The variable or dereferenced pointer to load."
@param $alignment "The alignment to assume for the load"
@param #x : "The variable or dereferenced pointer to load."
@param $alignment : "The alignment to assume for the load"
@return "The value of the variable"
@require @constant_is_power_of_2($alignment) : "The alignment must be a power of two"
@@ -175,9 +175,9 @@ macro @unaligned_load(#x, usz $alignment) @builtin
}
<*
@param #x "The variable or dereferenced pointer to store to."
@param value "The value to store."
@param $alignment "The alignment to assume for the store"
@param #x : "The variable or dereferenced pointer to store to."
@param value : "The value to store."
@param $alignment : "The alignment to assume for the store"
@return "The value stored"
@require $defined(&#x) : "This must be a variable or dereferenced pointer"
@@ -190,7 +190,7 @@ macro @unaligned_store(#x, value, usz $alignment) @builtin
}
<*
@param #x "The variable or dereferenced pointer to load."
@param #x : "The variable or dereferenced pointer to load."
@return "The value of the variable"
@require $defined(&#x) : "This must be a variable or dereferenced pointer"
@@ -201,8 +201,8 @@ macro @volatile_load(#x) @builtin
}
<*
@param #x "The variable or dereferenced pointer to store to."
@param value "The value to store."
@param #x : "The variable or dereferenced pointer to store to."
@param value : "The value to store."
@return "The value stored"
@require $defined(&#x) : "This must be a variable or dereferenced pointer"
@@ -225,15 +225,15 @@ enum AtomicOrdering : int
}
<*
@param #x "the variable or dereferenced pointer to load."
@param $ordering "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@param $volatile "whether the load should be volatile, defaults to 'false'"
@param #x : "the variable or dereferenced pointer to load."
@param $ordering : "atomic ordering of the load, defaults to SEQ_CONSISTENT"
@param $volatile : "whether the load should be volatile, defaults to 'false'"
@return "returns the value of x"
@require $defined(&#x) : "This must be a variable or dereferenced pointer"
@require $ordering != AtomicOrdering.RELEASE "Release ordering is not valid for load."
@require $ordering != AtomicOrdering.ACQUIRE_RELEASE "Acquire release is not valid for load."
@require types::may_load_atomic($typeof(#x)) "Only integer, float and pointers may be used."
@require $ordering != AtomicOrdering.RELEASE : "Release ordering is not valid for load."
@require $ordering != AtomicOrdering.ACQUIRE_RELEASE : "Acquire release is not valid for load."
@require types::may_load_atomic($typeof(#x)) : "Only integer, float and pointers may be used."
*>
macro @atomic_load(#x, AtomicOrdering $ordering = SEQ_CONSISTENT, $volatile = false) @builtin
{
@@ -241,14 +241,14 @@ macro @atomic_load(#x, AtomicOrdering $ordering = SEQ_CONSISTENT, $volatile = fa
}
<*
@param #x "the variable or dereferenced pointer to store to."
@param value "the value to store."
@param $ordering "the atomic ordering of the store, defaults to SEQ_CONSISTENT"
@param $volatile "whether the store should be volatile, defaults to 'false'"
@param #x : "the variable or dereferenced pointer to store to."
@param value : "the value to store."
@param $ordering : "the atomic ordering of the store, defaults to SEQ_CONSISTENT"
@param $volatile : "whether the store should be volatile, defaults to 'false'"
@require $ordering != AtomicOrdering.ACQUIRE "Acquire ordering is not valid for store."
@require $ordering != AtomicOrdering.ACQUIRE_RELEASE "Acquire release is not valid for store."
@require types::may_load_atomic($typeof(#x)) "Only integer, float and pointers may be used."
@require $ordering != AtomicOrdering.ACQUIRE : "Acquire ordering is not valid for store."
@require $ordering != AtomicOrdering.ACQUIRE_RELEASE : "Acquire release is not valid for store."
@require types::may_load_atomic($typeof(#x)) : "Only integer, float and pointers may be used."
@require $defined(&#x) : "This must be a variable or dereferenced pointer"
@require $defined(#x = value) : "The value doesn't match the variable"
*>
@@ -258,8 +258,8 @@ macro void @atomic_store(#x, value, AtomicOrdering $ordering = SEQ_CONSISTENT, $
}
<*
@require $success != AtomicOrdering.NOT_ATOMIC && $success != AtomicOrdering.UNORDERED "Acquire ordering is not valid."
@require $failure != AtomicOrdering.RELEASE && $failure != AtomicOrdering.ACQUIRE_RELEASE "Acquire release is not valid."
@require $success != AtomicOrdering.NOT_ATOMIC && $success != AtomicOrdering.UNORDERED : "Acquire ordering is not valid."
@require $failure != AtomicOrdering.RELEASE && $failure != AtomicOrdering.ACQUIRE_RELEASE : "Acquire release is not valid."
*>
macro compare_exchange(ptr, compare, value, AtomicOrdering $success = SEQ_CONSISTENT, AtomicOrdering $failure = SEQ_CONSISTENT, bool $volatile = true, bool $weak = false, usz $alignment = 0)
{
@@ -267,8 +267,8 @@ macro compare_exchange(ptr, compare, value, AtomicOrdering $success = SEQ_CONSIS
}
<*
@require $success != AtomicOrdering.NOT_ATOMIC && $success != AtomicOrdering.UNORDERED "Acquire ordering is not valid."
@require $failure != AtomicOrdering.RELEASE && $failure != AtomicOrdering.ACQUIRE_RELEASE "Acquire release is not valid."
@require $success != AtomicOrdering.NOT_ATOMIC && $success != AtomicOrdering.UNORDERED : "Acquire ordering is not valid."
@require $failure != AtomicOrdering.RELEASE && $failure != AtomicOrdering.ACQUIRE_RELEASE : "Acquire release is not valid."
*>
macro compare_exchange_volatile(ptr, compare, value, AtomicOrdering $success = SEQ_CONSISTENT, AtomicOrdering $failure = SEQ_CONSISTENT)
{
@@ -314,12 +314,12 @@ macro void clear_inline(void* dst, usz $len, usz $dst_align = 0, bool $is_volati
<*
Copy memory from src to dst efficiently, assuming the memory ranges do not overlap.
@param [&out] dst "The destination to copy to"
@param [&in] src "The source to copy from"
@param len "The number of bytes to copy"
@param $dst_align "the alignment of the destination if different from the default, 0 assumes the default"
@param $src_align "the alignment of the destination if different from the default, 0 assumes the default"
@param $is_volatile "True if this copy should be treated as volatile, i.e. it can't be optimized away."
@param [&out] dst : "The destination to copy to"
@param [&in] src : "The source to copy from"
@param len : "The number of bytes to copy"
@param $dst_align : "the alignment of the destination if different from the default, 0 assumes the default"
@param $src_align : "the alignment of the destination if different from the default, 0 assumes the default"
@param $is_volatile : "True if this copy should be treated as volatile, i.e. it can't be optimized away."
@require len == 0 || dst + len <= src || src + len <= dst : "Ranges may not overlap"
*>
@@ -332,12 +332,12 @@ macro void copy(void* dst, void* src, usz len, usz $dst_align = 0, usz $src_alig
Copy memory from src to dst efficiently, assuming the memory ranges do not overlap, it
will always be inlined and never call memcopy
@param [&out] dst "The destination to copy to"
@param [&in] src "The source to copy from"
@param $len "The number of bytes to copy"
@param $dst_align "the alignment of the destination if different from the default, 0 assumes the default"
@param $src_align "the alignment of the destination if different from the default, 0 assumes the default"
@param $is_volatile "True if this copy should be treated as volatile, i.e. it can't be optimized away."
@param [&out] dst : "The destination to copy to"
@param [&in] src : "The source to copy from"
@param $len : "The number of bytes to copy"
@param $dst_align : "the alignment of the destination if different from the default, 0 assumes the default"
@param $src_align : "the alignment of the destination if different from the default, 0 assumes the default"
@param $is_volatile : "True if this copy should be treated as volatile, i.e. it can't be optimized away."
@require $len == 0 || dst + $len <= src || src + $len <= dst : "Ranges may not overlap"
*>
@@ -349,12 +349,12 @@ macro void copy_inline(void* dst, void* src, usz $len, usz $dst_align = 0, usz $
<*
Copy memory from src to dst but correctly handle the possibility of overlapping ranges.
@param [&out] dst "The destination to copy to"
@param [&in] src "The source to copy from"
@param len "The number of bytes to copy"
@param $dst_align "the alignment of the destination if different from the default, 0 assumes the default"
@param $src_align "the alignment of the destination if different from the default, 0 assumes the default"
@param $is_volatile "True if this copy should be treated as volatile, i.e. it can't be optimized away."
@param [&out] dst : "The destination to copy to"
@param [&in] src : "The source to copy from"
@param len : "The number of bytes to copy"
@param $dst_align : "the alignment of the destination if different from the default, 0 assumes the default"
@param $src_align : "the alignment of the destination if different from the default, 0 assumes the default"
@param $is_volatile : "True if this copy should be treated as volatile, i.e. it can't be optimized away."
*>
macro void move(void* dst, void* src, usz len, usz $dst_align = 0, usz $src_align = 0, bool $is_volatile = false)
{
@@ -364,11 +364,11 @@ macro void move(void* dst, void* src, usz len, usz $dst_align = 0, usz $src_alig
<*
Sets all memory in a region to that of the provided byte.
@param [&out] dst "The destination to copy to"
@param val "The value to copy into memory"
@param len "The number of bytes to copy"
@param $dst_align "the alignment of the destination if different from the default, 0 assumes the default"
@param $is_volatile "True if this copy should be treated as volatile, i.e. it can't be optimized away."
@param [&out] dst : "The destination to copy to"
@param val : "The value to copy into memory"
@param len : "The number of bytes to copy"
@param $dst_align : "the alignment of the destination if different from the default, 0 assumes the default"
@param $is_volatile : "True if this copy should be treated as volatile, i.e. it can't be optimized away."
@ensure !len || (dst[0] == val && dst[len - 1] == val)
*>
@@ -380,11 +380,11 @@ macro void set(void* dst, char val, usz len, usz $dst_align = 0, bool $is_volati
<*
Sets all memory in a region to that of the provided byte. Never calls OS memset.
@param [&out] dst "The destination to copy to"
@param val "The value to copy into memory"
@param $len "The number of bytes to copy"
@param $dst_align "the alignment of the destination if different from the default, 0 assumes the default"
@param $is_volatile "True if this copy should be treated as volatile, i.e. it can't be optimized away."
@param [&out] dst : "The destination to copy to"
@param val : "The value to copy into memory"
@param $len : "The number of bytes to copy"
@param $dst_align : "the alignment of the destination if different from the default, 0 assumes the default"
@param $is_volatile : "True if this copy should be treated as volatile, i.e. it can't be optimized away."
@ensure !$len || (dst[0] == val && dst[$len - 1] == val)
*>
@@ -471,7 +471,7 @@ macro void @scoped(Allocator allocator; @body())
Run the tracking allocator in the scope, then
print out stats.
@param $enabled "Set to false to disable tracking"
@param $enabled : "Set to false to disable tracking"
*>
macro void @report_heap_allocs_in_scope($enabled = true; @body())
{
@@ -493,7 +493,7 @@ macro void @report_heap_allocs_in_scope($enabled = true; @body())
<*
Assert on memory leak in the scope of the macro body.
@param $report "Set to false to disable memory report"
@param $report : "Set to false to disable memory report"
*>
macro void @assert_leak($report = true; @body()) @builtin
{
@@ -530,7 +530,7 @@ macro void @assert_leak($report = true; @body()) @builtin
Release everything on scope exit.
@param $size `the size of the buffer`
@param $size : `the size of the buffer`
*>
macro void @stack_mem(usz $size; @body(Allocator mem)) @builtin
{
@@ -585,7 +585,7 @@ fn void temp_pop(TempState old_state)
}
<*
@require @is_empty_macro_slot(#other_temp) ||| $assignable(#other_temp, Allocator) "Must be an allocator"
@require @is_empty_macro_slot(#other_temp) ||| $assignable(#other_temp, Allocator) : "Must be an allocator"
*>
macro void @pool(#other_temp = EMPTY_MACRO_SLOT; @body) @builtin
{

View File

@@ -22,13 +22,13 @@ interface Allocator
fn usz mark() @optional;
<*
@require !alignment || math::is_power_of_2(alignment)
@require alignment <= mem::MAX_MEMORY_ALIGNMENT `alignment too big`
@require alignment <= mem::MAX_MEMORY_ALIGNMENT : `alignment too big`
@require size > 0
*>
fn void*! acquire(usz size, AllocInitType init_type, usz alignment = 0);
<*
@require !alignment || math::is_power_of_2(alignment)
@require alignment <= mem::MAX_MEMORY_ALIGNMENT `alignment too big`
@require alignment <= mem::MAX_MEMORY_ALIGNMENT : `alignment too big`
@require ptr != null
@require new_size > 0
*>

View File

@@ -26,8 +26,8 @@ def ErrorCallback = fn void (ZString);
NOTE This function is not thread-safe because no two threads can poison or
unpoison memory in the same memory region simultaneously.
@param addr "Start of memory region."
@param size "Size of memory region."
@param addr : "Start of memory region."
@param size : "Size of memory region."
*>
macro poison_memory_region(void* addr, usz size)
{
@@ -47,8 +47,8 @@ macro poison_memory_region(void* addr, usz size)
NOTE This function is not thread-safe because no two threads can
poison or unpoison memory in the same memory region simultaneously.
@param addr "Start of memory region."
@param size "Size of memory region."
@param addr : "Start of memory region."
@param size : "Size of memory region."
*>
macro unpoison_memory_region(void* addr, usz size)
{
@@ -60,7 +60,7 @@ macro unpoison_memory_region(void* addr, usz size)
<*
Checks if an address is poisoned.
@return "True if 'addr' is poisoned (that is, 1-byte read/write access to this address would result in an error report from ASan). Otherwise returns false."
@param addr "Address to check."
@param addr : "Address to check."
*>
macro bool address_is_poisoned(void* addr)
{
@@ -77,8 +77,8 @@ macro bool address_is_poisoned(void* addr)
If at least one byte in [beg, beg+size) is poisoned, returns the
address of the first such byte. Otherwise returns 0.
@param beg "Start of memory region."
@param size "Start of memory region."
@param beg : "Start of memory region."
@param size : "Start of memory region."
@return "Address of first poisoned byte."
*>
macro void* region_is_poisoned(void* beg, usz size)

View File

@@ -57,7 +57,7 @@ macro Char16[] @char16(String $string) @builtin
<*
Return a temporary ZString created using the formatting function.
@param [in] fmt `The formatting string`
@param [in] fmt : `The formatting string`
*>
fn ZString tformat_zstr(String fmt, args...)
{
@@ -69,8 +69,8 @@ fn ZString tformat_zstr(String fmt, args...)
<*
Return a new String created using the formatting function.
@param [inout] allocator `The allocator to use`
@param [in] fmt `The formatting string`
@param [inout] allocator : `The allocator to use`
@param [in] fmt : `The formatting string`
*>
fn String format(Allocator allocator, String fmt, args...) => @pool(allocator)
{
@@ -82,7 +82,7 @@ fn String format(Allocator allocator, String fmt, args...) => @pool(allocator)
<*
Return a temporary String created using the formatting function.
@param [in] fmt `The formatting string`
@param [in] fmt : `The formatting string`
*>
fn String tformat(String fmt, args...)
{
@@ -94,8 +94,8 @@ fn String tformat(String fmt, args...)
<*
Check if a character is in a set.
@param c `the character to check`
@param [in] set `The formatting string`
@param c : `the character to check`
@param [in] set : `The formatting string`
@pure
@return `True if a character is in the set`
*>
@@ -133,8 +133,8 @@ fn String join(Allocator allocator, String[] s, String joiner)
<*
Remove characters from the front and end of a string.
@param [in] string `The string to trim`
@param [in] to_trim `The set of characters to trim, defaults to whitespace`
@param [in] string : `The string to trim`
@param [in] to_trim : `The set of characters to trim, defaults to whitespace`
@pure
@return `a substring of the string passed in`
*>
@@ -146,8 +146,8 @@ fn String String.trim(string, String to_trim = "\t\n\r ")
<*
Remove characters from the front of a string.
@param [in] string `The string to trim`
@param [in] to_trim `The set of characters to trim, defaults to whitespace`
@param [in] string : `The string to trim`
@param [in] to_trim : `The set of characters to trim, defaults to whitespace`
@pure
@return `a substring of the string passed in`
*>
@@ -163,8 +163,8 @@ fn String String.trim_left(string, String to_trim = "\t\n\r ")
<*
Remove characters from the end of a string.
@param [in] string `The string to trim`
@param [in] to_trim `The set of characters to trim, defaults to whitespace`
@param [in] string : `The string to trim`
@param [in] to_trim : `The set of characters to trim, defaults to whitespace`
@pure
@return `a substring of the string passed in`
*>
@@ -239,11 +239,11 @@ fn String String.strip_end(string, String needle)
@param [in] s
@param [in] needle
@param max "Max number of elements, 0 means no limit, defaults to 0"
@param skip_empty "True to skip empty elements"
@param [&inout] allocator "The allocator to use for the String[]"
@param max : "Max number of elements, 0 means no limit, defaults to 0"
@param skip_empty : "True to skip empty elements"
@param [&inout] allocator : "The allocator to use for the String[]"
@require needle.len > 0 "The needle must be at least 1 character long"
@require needle.len > 0 : "The needle must be at least 1 character long"
@ensure return.len > 0
*>
fn String[] String.split(s, Allocator allocator, String needle, usz max = 0, bool skip_empty = false)
@@ -288,8 +288,8 @@ fn String[] String.split(s, Allocator allocator, String needle, usz max = 0, boo
@param [in] s
@param [in] needle
@param max "Max number of elements, 0 means no limit, defaults to 0"
@param skip_empty "True to skip empty elements"
@param max : "Max number of elements, 0 means no limit, defaults to 0"
@param skip_empty : "True to skip empty elements"
*>
fn String[] String.tsplit(s, String needle, usz max = 0, bool skip_empty = false) => s.split(tmem(), needle, max, skip_empty) @inline;
@@ -301,10 +301,10 @@ fault SplitResult { BUFFER_EXCEEDED }
@param [in] s
@param [in] needle
@param [inout] buffer
@param max "Max number of elements, 0 means no limit, defaults to 0"
@require needle.len > 0 "The needle must be at least 1 character long"
@param max : "Max number of elements, 0 means no limit, defaults to 0"
@require needle.len > 0 : "The needle must be at least 1 character long"
@ensure return.len > 0
@return! SplitResult.BUFFER_EXCEEDED `If there are more elements than would fit the buffer`
@return! SplitResult.BUFFER_EXCEEDED : `If there are more elements than would fit the buffer`
*>
fn String[]! String.split_to_buffer(s, String needle, String[] buffer, usz max = 0, bool skip_empty = false)
{
@@ -342,7 +342,7 @@ fn String[]! String.split_to_buffer(s, String needle, String[] buffer, usz max =
Check if a substring is found in the string.
@param [in] s
@param [in] needle "The string to look for."
@param [in] needle : "The string to look for."
@pure
@return "true if the string contains the substring, false otherwise"
*>
@@ -355,11 +355,11 @@ fn bool String.contains(s, String needle)
Find the index of the first incidence of a string.
@param [in] s
@param needle "The character to look for"
@param needle : "The character to look for"
@pure
@ensure return < s.len
@return "the index of the needle"
@return! SearchResult.MISSING "if the needle cannot be found"
@return! SearchResult.MISSING : "if the needle cannot be found"
*>
fn usz! String.index_of_char(s, char needle)
{
@@ -374,11 +374,11 @@ fn usz! String.index_of_char(s, char needle)
Find the index of the first incidence of a one of the chars.
@param [in] s
@param [in] needle "The characters to look for"
@param [in] needle : "The characters to look for"
@pure
@ensure return < s.len
@return "the index of the needle"
@return! SearchResult.MISSING "if the needle cannot be found"
@return! SearchResult.MISSING : "if the needle cannot be found"
*>
fn usz! String.index_of_chars(String s, char[] needle)
{
@@ -397,12 +397,12 @@ fn usz! String.index_of_chars(String s, char[] needle)
Find the index of the first incidence of a character.
@param [in] s
@param needle "The character to look for"
@param start_index "The index to start with, may exceed max index."
@param needle : "The character to look for"
@param start_index : "The index to start with, may exceed max index."
@pure
@ensure return < s.len
@return "the index of the needle"
@return! SearchResult.MISSING "if the needle cannot be found starting from the start_index"
@return! SearchResult.MISSING : "if the needle cannot be found starting from the start_index"
*>
fn usz! String.index_of_char_from(s, char needle, usz start_index)
{
@@ -419,11 +419,11 @@ fn usz! String.index_of_char_from(s, char needle, usz start_index)
Find the index of the first incidence of a character starting from the end.
@param [in] s
@param needle "the character to find"
@param needle : "the character to find"
@pure
@ensure return < s.len
@return "the index of the needle"
@return! SearchResult.MISSING "if the needle cannot be found"
@return! SearchResult.MISSING : "if the needle cannot be found"
*>
fn usz! String.rindex_of_char(s, char needle)
{
@@ -443,7 +443,7 @@ fn usz! String.rindex_of_char(s, char needle)
@ensure return < s.len
@require needle.len > 0 : "The needle must be len 1 or more"
@return "the index of the needle"
@return! SearchResult.MISSING "if the needle cannot be found"
@return! SearchResult.MISSING : "if the needle cannot be found"
*>
fn usz! String.index_of(s, String needle)
{
@@ -466,9 +466,9 @@ fn usz! String.index_of(s, String needle)
@param [in] needle
@pure
@ensure return < s.len
@require needle.len > 0 "The needle must be len 1 or more"
@require needle.len > 0 : "The needle must be len 1 or more"
@return "the index of the needle"
@return! SearchResult.MISSING "if the needle cannot be found"
@return! SearchResult.MISSING : "if the needle cannot be found"
*>
fn usz! String.rindex_of(s, String needle)
{
@@ -570,8 +570,8 @@ fn String ZString.tcopy(z)
<*
Convert an UTF-8 string to UTF-16
@return "The UTF-16 string as a slice, allocated using the given allocator"
@return! UnicodeResult.INVALID_UTF8 "If the string contained an invalid UTF-8 sequence"
@return! AllocationFailure "If allocation of the string fails"
@return! UnicodeResult.INVALID_UTF8 : "If the string contained an invalid UTF-8 sequence"
@return! AllocationFailure : "If allocation of the string fails"
*>
fn Char16[]! String.to_utf16(s, Allocator allocator)
{

View File

@@ -44,11 +44,11 @@ import std::math, std::io, libc;
<*
Initializes test case context.
@param setup_fn `initializer function for test case`
@param teardown_fn `cleanup function for test context (may be null)`
@param setup_fn : `initializer function for test case`
@param teardown_fn : `cleanup function for test context (may be null)`
@require runtime::test_context != null "Only allowed in @test functions"
@require setup_fn != null "setup_fn must always be set"
@require runtime::test_context != null : "Only allowed in @test functions"
@require setup_fn != null : "setup_fn must always be set"
*>
macro @setup(TestFn setup_fn, TestFn teardown_fn = null)
{
@@ -60,10 +60,10 @@ macro @setup(TestFn setup_fn, TestFn teardown_fn = null)
<*
Checks condition and fails assertion if not true
@param #condition `any boolean condition, will be expanded by text`
@param format `printf compatible format`
@param args `vargs for format`
@require runtime::test_context != null "Only allowed in @test functions"
@param #condition : `any boolean condition, will be expanded by text`
@param format : `printf compatible format`
@param args : `vargs for format`
@require runtime::test_context != null : "Only allowed in @test functions"
*>
macro @check(#condition, String format = "", args...)
{
@@ -83,9 +83,9 @@ macro @check(#condition, String format = "", args...)
<*
Check if function returns specific error
@param #funcresult `result of function execution`
@param error_expected `expected error of function execution`
@require runtime::test_context != null "Only allowed in @test functions"
@param #funcresult : `result of function execution`
@param error_expected : `expected error of function execution`
@require runtime::test_context != null : "Only allowed in @test functions"
*>
macro @error(#funcresult, anyfault error_expected)
{
@@ -104,9 +104,9 @@ macro @error(#funcresult, anyfault error_expected)
<*
Check if left == right
@param left `left argument of any comparable type`
@param right `right argument of any comparable type`
@require runtime::test_context != null "Only allowed in @test functions"
@param left : `left argument of any comparable type`
@param right : `right argument of any comparable type`
@require runtime::test_context != null : "Only allowed in @test functions"
*>
macro eq(left, right)
{
@@ -119,13 +119,13 @@ macro eq(left, right)
<*
Check left floating point value is approximately equals to right value
@param places `number of decimal places to compare (default: 7)`
@param delta `minimal allowed difference (overrides places parameter)`
@param equal_nan `allows comparing nan values, if left and right both nans result is ok`
@param places : `number of decimal places to compare (default: 7)`
@param delta : `minimal allowed difference (overrides places parameter)`
@param equal_nan : `allows comparing nan values, if left and right both nans result is ok`
@require places > 0, places <= 20 "too many decimal places"
@require delta >= 0, delta <= 1 "delta must be a small number"
@require runtime::test_context != null "Only allowed in @test functions"
@require places > 0, places <= 20 : "too many decimal places"
@require delta >= 0, delta <= 1 : "delta must be a small number"
@require runtime::test_context != null : "Only allowed in @test functions"
*>
macro void eq_approx(double left, double right, uint places = 7, double delta = 0, bool equal_nan = true)
{
@@ -143,9 +143,9 @@ macro void eq_approx(double left, double right, uint places = 7, double delta =
<*
Check if left != right
@param left `left argument of any comparable type`
@param right `right argument of any comparable type`
@require runtime::test_context != null "Only allowed in @test functions"
@param left : `left argument of any comparable type`
@param right : `right argument of any comparable type`
@require runtime::test_context != null : "Only allowed in @test functions"
*>
macro void ne(left, right)
{
@@ -158,9 +158,9 @@ macro void ne(left, right)
<*
Check if left > right
@param left `left argument of any comparable type`
@param right `right argument of any comparable type`
@require runtime::test_context != null "Only allowed in @test functions"
@param left : `left argument of any comparable type`
@param right : `right argument of any comparable type`
@require runtime::test_context != null : "Only allowed in @test functions"
*>
macro gt(left, right)
{
@@ -173,9 +173,9 @@ macro gt(left, right)
<*
Check if left >= right
@param left `left argument of any comparable type`
@param right `right argument of any comparable type`
@require runtime::test_context != null "Only allowed in @test functions"
@param left : `left argument of any comparable type`
@param right : `right argument of any comparable type`
@require runtime::test_context != null : "Only allowed in @test functions"
*>
macro ge(left, right)
{
@@ -188,9 +188,9 @@ macro ge(left, right)
<*
Check if left < right
@param left `left argument of any comparable type`
@param right `right argument of any comparable type`
@require runtime::test_context != null "Only allowed in @test functions"
@param left : `left argument of any comparable type`
@param right : `right argument of any comparable type`
@require runtime::test_context != null : "Only allowed in @test functions"
*>
macro lt(left, right)
{
@@ -203,9 +203,9 @@ macro lt(left, right)
<*
Check if left <= right
@param left `left argument of any comparable type`
@param right `right argument of any comparable type`
@require runtime::test_context != null "Only allowed in @test functions"
@param left : `left argument of any comparable type`
@param right : `right argument of any comparable type`
@require runtime::test_context != null : "Only allowed in @test functions"
*>
macro le(left, right)
{

View File

@@ -10,8 +10,8 @@ fault ConversionResult
}
<*
@require $Type.kindof.is_int() "Type was not an integer"
@require v.type.kindof == ENUM "Value was not an enum"
@require $Type.kindof.is_int() : "Type was not an integer"
@require v.type.kindof == ENUM : "Value was not an enum"
*>
macro any_to_enum_ordinal(any v, $Type)
{
@@ -19,8 +19,8 @@ macro any_to_enum_ordinal(any v, $Type)
}
<*
@require $Type.kindof.is_int() "Type was not an integer"
@require v.type.kindof.is_int() "Value was not an integer"
@require $Type.kindof.is_int() : "Type was not an integer"
@require v.type.kindof.is_int() : "Value was not an integer"
*>
macro any_to_int(any v, $Type)
{
@@ -130,7 +130,7 @@ macro bool is_bool($Type) @const => $Type.kindof == TypeKind.BOOL;
macro bool is_int($Type) @const => $Type.kindof == TypeKind.SIGNED_INT || $Type.kindof == TypeKind.UNSIGNED_INT;
<*
@require is_numerical($Type) "Expected a numerical type"
@require is_numerical($Type) : "Expected a numerical type"
*>
macro bool is_signed($Type) @const
{
@@ -146,7 +146,7 @@ macro bool is_signed($Type) @const
}
<*
@require is_numerical($Type) "Expected a numerical type"
@require is_numerical($Type) : "Expected a numerical type"
*>
macro bool is_unsigned($Type) @const
{

View File

@@ -33,7 +33,7 @@ macro promote_int(x)
This acts like `$bool ? #value_1 : #value_2` but at compile time.
@param $bool `true for picking the first value, false for the other`
@param $bool : `true for picking the first value, false for the other`
@param #value_1
@param #value_2
@returns `The selected value.`

View File

@@ -12,8 +12,8 @@ struct Rc4
<*
Initialize the RC4 state.
@param [in] key "The key to use"
@require key.len > 0 "The key must be at least 1 byte long"
@param [in] key : "The key to use"
@require key.len > 0 : "The key must be at least 1 byte long"
*>
fn void Rc4.init(&self, char[] key)
{
@@ -43,9 +43,9 @@ fn void crypt(char[] key, char[] data)
<*
Encrypt or decrypt a sequence of bytes.
@param [in] in "The input"
@param [out] out "The output"
@require in.len <= out.len "Output would overflow"
@param [in] in : "The input"
@param [out] out : "The output"
@require in.len <= out.len : "Output would overflow"
*>
fn void Rc4.crypt(&self, char[] in, char[] out)
{
@@ -67,7 +67,7 @@ fn void Rc4.crypt(&self, char[] in, char[] out)
<*
Clear the rc4 state.
@param [&out] self "The RC4 State"
@param [&out] self : "The RC4 State"
*>
fn void Rc4.destroy(&self)
{

View File

@@ -14,10 +14,10 @@ const char DEFAULT_PAD = '=';
<*
Encode the content of src into a newly allocated string
@param [in] src "The input to be encoded."
@param padding "The padding character or 0 if none"
@param alphabet "The alphabet to use"
@require padding < 0xFF "Invalid padding character"
@param [in] src : "The input to be encoded."
@param padding : "The padding character or 0 if none"
@param alphabet : "The alphabet to use"
@require padding < 0xFF : "Invalid padding character"
@return "The encoded string."
*>
fn String! encode(Allocator allocator, char[] src, char padding = DEFAULT_PAD, Base32Alphabet* alphabet = &STANDARD)
@@ -28,10 +28,10 @@ fn String! encode(Allocator allocator, char[] src, char padding = DEFAULT_PAD, B
<*
Decode the content of src into a newly allocated char array.
@param [in] src "The input to be encoded."
@param padding "The padding character or 0 if none"
@param alphabet "The alphabet to use"
@require padding < 0xFF "Invalid padding character"
@param [in] src : "The input to be encoded."
@param padding : "The padding character or 0 if none"
@param alphabet : "The alphabet to use"
@require padding < 0xFF : "Invalid padding character"
@return "The decoded data."
*>
fn char[]! decode(Allocator allocator, char[] src, char padding = DEFAULT_PAD, Base32Alphabet* alphabet = &STANDARD)
@@ -45,9 +45,9 @@ fn char[]! tdecode(char[] code, char padding = DEFAULT_PAD, Base32Alphabet* alph
<*
Calculate the length in bytes of the decoded data.
@param n "Length in bytes of input."
@param padding "The padding character or 0 if none"
@require padding < 0xFF "Invalid padding character"
@param n : "Length in bytes of input."
@param padding : "The padding character or 0 if none"
@require padding < 0xFF : "Invalid padding character"
@return "Length in bytes of the decoded data."
*>
fn usz decode_len(usz n, char padding)
@@ -60,9 +60,9 @@ fn usz decode_len(usz n, char padding)
<*
Calculate the length in bytes of the encoded data.
@param n "Length in bytes on input."
@param padding "The padding character or 0 if none"
@require padding < 0xFF "Invalid padding character"
@param n : "Length in bytes on input."
@param padding : "The padding character or 0 if none"
@require padding < 0xFF : "Invalid padding character"
@return "Length in bytes of the encoded data."
*>
fn usz encode_len(usz n, char padding)
@@ -77,12 +77,12 @@ fn usz encode_len(usz n, char padding)
<*
Decode the content of src into dst, which must be properly sized.
@param src "The input to be decoded."
@param dst "The decoded input."
@param padding "The padding character or 0 if none"
@param alphabet "The alphabet to use"
@require padding < 0xFF "Invalid padding character"
@require dst.len >= decode_len(src.len, padding) "Destination buffer too small"
@param src : "The input to be decoded."
@param dst : "The decoded input."
@param padding : "The padding character or 0 if none"
@param alphabet : "The alphabet to use"
@require padding < 0xFF : "Invalid padding character"
@require dst.len >= decode_len(src.len, padding) : "Destination buffer too small"
@return "The resulting dst buffer"
@return! DecodingFailure
*>
@@ -160,12 +160,12 @@ fn char[]! decode_buffer(char[] src, char[] dst, char padding = DEFAULT_PAD, Bas
<*
Encode the content of src into dst, which must be properly sized.
@param [in] src "The input to be encoded."
@param [inout] dst "The encoded input."
@param padding "The padding character or 0 if none"
@param alphabet "The alphabet to use"
@require padding < 0xFF "Invalid padding character"
@require dst.len >= encode_len(src.len, padding) "Destination buffer too small"
@param [in] src : "The input to be encoded."
@param [inout] dst : "The encoded input."
@param padding : "The padding character or 0 if none"
@param alphabet : "The alphabet to use"
@require padding < 0xFF : "Invalid padding character"
@require dst.len >= encode_len(src.len, padding) : "Destination buffer too small"
@return "The encoded size."
*>
fn String encode_buffer(char[] src, char[] dst, char padding = DEFAULT_PAD, Base32Alphabet* alphabet = &STANDARD)

View File

@@ -61,9 +61,9 @@ fn char[]! tdecode(char[] code, char padding = DEFAULT_PAD, Base64Alphabet* alph
<*
Calculate the size of the encoded data.
@param n "Size of the input to be encoded."
@param padding "The padding character or 0 if none"
@require padding < 0xFF "Invalid padding character"
@param n : "Size of the input to be encoded."
@param padding : "The padding character or 0 if none"
@require padding < 0xFF : "Invalid padding character"
@return "The size of the input once encoded."
*>
fn usz encode_len(usz n, char padding)
@@ -75,9 +75,9 @@ fn usz encode_len(usz n, char padding)
<*
Calculate the size of the decoded data.
@param n "Size of the input to be decoded."
@param padding "The padding character or 0 if none"
@require padding < 0xFF "Invalid padding character"
@param n : "Size of the input to be decoded."
@param padding : "The padding character or 0 if none"
@require padding < 0xFF : "Invalid padding character"
@return "The size of the input once decoded."
@return! DecodingFailure.INVALID_PADDING
*>
@@ -97,11 +97,11 @@ fn usz! decode_len(usz n, char padding)
<*
Encode the content of src into dst, which must be properly sized.
@param src "The input to be encoded."
@param dst "The encoded input."
@param padding "The padding character or 0 if none"
@param alphabet "The alphabet to use"
@require padding < 0xFF "Invalid padding character"
@param src : "The input to be encoded."
@param dst : "The encoded input."
@param padding : "The padding character or 0 if none"
@param alphabet : "The alphabet to use"
@require padding < 0xFF : "Invalid padding character"
@return "The encoded size."
*>
fn String encode_buffer(char[] src, char[] dst, char padding = DEFAULT_PAD, Base64Alphabet* alphabet = &STANDARD)
@@ -156,12 +156,12 @@ fn String encode_buffer(char[] src, char[] dst, char padding = DEFAULT_PAD, Base
<*
Decode the content of src into dst, which must be properly sized.
@param src "The input to be decoded."
@param dst "The decoded input."
@param padding "The padding character or 0 if none"
@param alphabet "The alphabet to use"
@require (decode_len(src.len, padding) ?? 0) <= dst.len "Destination buffer too small"
@require padding < 0xFF "Invalid padding character"
@param src : "The input to be decoded."
@param dst : "The decoded input."
@param padding : "The padding character or 0 if none"
@param alphabet : "The alphabet to use"
@require (decode_len(src.len, padding) ?? 0) <= dst.len : "Destination buffer too small"
@require padding < 0xFF : "Invalid padding character"
@return "The decoded data."
@return! DecodingFailure
*>

View File

@@ -55,7 +55,7 @@ fn CsvRow! CsvReader.tread_row(self)
}
<*
@require self.allocator != null `Row already freed`
@require self.allocator != null : `Row already freed`
*>
fn void CsvRow.free(&self)
{

View File

@@ -31,17 +31,17 @@ fn char[]! tdecode(char[] code) @inline => decode(tmem(), code);
<*
Calculate the size of the encoded data.
@param n "Size of the input to be encoded."
@param n : "Size of the input to be encoded."
@return "The size of the input once encoded."
*>
fn usz encode_len(usz n) => n * 2;
<*
Encode the content of src into dst, which must be properly sized.
@param src "The input to be encoded."
@param dst "The encoded input."
@param src : "The input to be encoded."
@param dst : "The encoded input."
@return "The encoded size."
@require dst.len >= encode_len(src.len) "Destination array is not large enough"
@require dst.len >= encode_len(src.len) : "Destination array is not large enough"
*>
fn usz encode_bytes(char[] src, char[] dst)
{
@@ -57,7 +57,7 @@ fn usz encode_bytes(char[] src, char[] dst)
<*
Calculate the size of the decoded data.
@param n "Size of the input to be decoded."
@param n : "Size of the input to be decoded."
@return "The size of the input once decoded."
*>
macro usz decode_len(usz n) => n / 2;
@@ -68,10 +68,10 @@ macro usz decode_len(usz n) => n / 2;
Expects that src only contains hexadecimal characters and that src has even
length.
@param src "The input to be decoded."
@param dst "The decoded input."
@require src.len % 2 == 0 "src is not of even length"
@require dst.len >= decode_len(src.len) "Destination array is not large enough"
@param src : "The input to be decoded."
@param dst : "The decoded input."
@require src.len % 2 == 0 : "src is not of even length"
@require dst.len >= decode_len(src.len) : "Destination array is not large enough"
@return! DecodingFailure.INVALID_CHARACTER
*>
fn usz! decode_bytes(char[] src, char[] dst)

View File

@@ -15,8 +15,8 @@ fn char[HASH_BYTES] hash(char[] key, char[] message)
}
<*
@require output.len > 0 "Output must be greater than zero"
@require output.len < int.max / HASH_BYTES "Output is too large"
@require output.len > 0 : "Output must be greater than zero"
@require output.len < int.max / HASH_BYTES : "Output is too large"
*>
fn void pbkdf2(char[] pw, char[] salt, uint iterations, char[] output)
{

View File

@@ -136,7 +136,7 @@ fn usz! File.read(&self, char[] buffer) @dynamic
<*
@param [out] buffer
@require self.file != null `File must be initialized`
@require self.file != null : `File must be initialized`
*>
fn usz! File.write(&self, char[] buffer) @dynamic
{
@@ -164,8 +164,8 @@ fn char! File.read_byte(&self) @dynamic
Load up to buffer.len characters. Returns IoError.OVERFLOW if the file is longer
than the buffer.
@param filename "The path to the file to read"
@param [in] buffer "The buffer to read to"
@param filename : "The path to the file to read"
@param [in] buffer : "The buffer to read to"
*>
fn char[]! load_buffer(String filename, char[] buffer)
{
@@ -222,7 +222,7 @@ fn void! save(String filename, char[] data)
}
<*
@require self.file != null `File must be initialized`
@require self.file != null : `File must be initialized`
*>
fn void! File.flush(&self) @dynamic
{

View File

@@ -33,7 +33,7 @@ macro bool is_struct_with_default_print($Type)
<*
Introspect a struct and print it to a formatter
@require @typekind(value) == STRUCT `This macro is only valid on macros`
@require @typekind(value) == STRUCT : `This macro is only valid on macros`
*>
macro usz! struct_to_format(value, Formatter* f, bool $force_dump)
{

View File

@@ -138,9 +138,9 @@ fn FloatType! float_from_any(any arg) @private
<*
Read a simple integer value, typically for formatting.
@param [inout] len_ptr "the length remaining."
@param [in] buf "the buf to read from."
@param maxlen "the maximum len that can be read."
@param [inout] len_ptr : "the length remaining."
@param [in] buf : "the buf to read from."
@param maxlen : "the maximum len that can be read."
@return "The result of the atoi."
*>
fn uint simple_atoi(char* buf, usz maxlen, usz* len_ptr) @inline @private

View File

@@ -50,9 +50,9 @@ fault IoError
or to the end of the stream, whatever comes first.
"\r" will be filtered from the String.
@param stream `The stream to read from.`
@require @is_instream(stream) `The stream must implement InStream.`
@param [inout] allocator `the allocator to use.`
@param stream : `The stream to read from.`
@require @is_instream(stream) : `The stream must implement InStream.`
@param [inout] allocator : `the allocator to use.`
@return `The string containing the data read.`
*>
macro String! readline(Allocator allocator, stream = io::stdin())
@@ -94,8 +94,8 @@ macro String! readline(Allocator allocator, stream = io::stdin())
Reads a string, see `readline`, except the it is allocated
on the temporary allocator and does not need to be freed.
@param stream `The stream to read from.`
@require @is_instream(stream) `The stream must implement InStream.`
@param stream : `The stream to read from.`
@require @is_instream(stream) : `The stream must implement InStream.`
@return `The temporary string containing the data read.`
*>
macro String! treadline(stream = io::stdin())
@@ -106,9 +106,9 @@ macro String! treadline(stream = io::stdin())
<*
Print a value to a stream.
@param out `the stream to print to`
@param x `the value to print`
@require @is_outstream(out) `The output must implement OutStream.`
@param out : `the stream to print to`
@param x : `the value to print`
@require @is_outstream(out) : `The output must implement OutStream.`
@return `the number of bytes printed.`
*>
macro usz! fprint(out, x)
@@ -137,8 +137,8 @@ macro usz! fprint(out, x)
Prints using a 'printf'-style formatting string.
See `printf` for details on formatting.
@param [inout] out `The OutStream to print to`
@param [in] format `The printf-style format string`
@param [inout] out : `The OutStream to print to`
@param [in] format : `The printf-style format string`
@return `the number of characters printed`
*>
fn usz! fprintf(OutStream out, String format, args...)
@@ -152,8 +152,8 @@ fn usz! fprintf(OutStream out, String format, args...)
Prints using a 'printf'-style formatting string,
appending '\n' at the end. See `printf`.
@param [inout] out `The OutStream to print to`
@param [in] format `The printf-style format string`
@param [inout] out : `The OutStream to print to`
@param [in] format : `The printf-style format string`
@return `the number of characters printed`
*>
fn usz! fprintfn(OutStream out, String format, args...) @maydiscard
@@ -167,7 +167,7 @@ fn usz! fprintfn(OutStream out, String format, args...) @maydiscard
}
<*
@require @is_outstream(out) "The output must implement OutStream"
@require @is_outstream(out) : "The output must implement OutStream"
*>
macro usz! fprintn(out, x = "")
{
@@ -193,7 +193,7 @@ macro void print(x)
<*
Print any value to stdout, appending an '\n after.
@param x "The value to print"
@param x : "The value to print"
*>
macro void printn(x = "")
{
@@ -211,7 +211,7 @@ macro void eprint(x)
<*
Print any value to stderr, appending an '\n after.
@param x "The value to print"
@param x : "The value to print"
*>
macro void eprintn(x)
{
@@ -248,7 +248,7 @@ fn void! out_putchar_fn(void* data @unused, char c) @private
To create a custom output for a type, implement
the Printable interface.
@param [in] format `The printf-style format string`
@param [in] format : `The printf-style format string`
@return `the number of characters printed`
*>
fn usz! printf(String format, args...) @maydiscard
@@ -262,7 +262,7 @@ fn usz! printf(String format, args...) @maydiscard
Prints using a 'printf'-style formatting string,
appending '\n' at the end. See `printf`.
@param [in] format `The printf-style format string`
@param [in] format : `The printf-style format string`
@return `the number of characters printed`
*>
fn usz! printfn(String format, args...) @maydiscard
@@ -279,7 +279,7 @@ fn usz! printfn(String format, args...) @maydiscard
Prints using a 'printf'-style formatting string
to stderr.
@param [in] format `The printf-style format string`
@param [in] format : `The printf-style format string`
@return `the number of characters printed`
*>
fn usz! eprintf(String format, args...) @maydiscard
@@ -295,7 +295,7 @@ fn usz! eprintf(String format, args...) @maydiscard
Prints using a 'printf'-style formatting string,
to stderr appending '\n' at the end. See `printf`.
@param [in] format `The printf-style format string`
@param [in] format : `The printf-style format string`
@return `the number of characters printed`
*>
fn usz! eprintfn(String format, args...) @maydiscard
@@ -313,8 +313,8 @@ fn usz! eprintfn(String format, args...) @maydiscard
Prints using a 'printf'-style formatting string,
to a string buffer. See `printf`.
@param [inout] buffer `The buffer to print to`
@param [in] format `The printf-style format string`
@param [inout] buffer : `The buffer to print to`
@param [in] format : `The printf-style format string`
@return `a slice formed from the "buffer" with the resulting length.`
*>
fn char[]! bprintf(char[] buffer, String format, args...) @maydiscard

View File

@@ -92,10 +92,10 @@ enum MkdirPermissions
<*
Create a directory on a given path, optionally recursive.
@param path `The path to create`
@param path : `The path to create`
@require @is_pathlike(path) : "Expected a Path or String to chdir"
@param recursive `If directories in between should be created if they're missing, defaults to false`
@param permissions `The permissions to set on the directory`
@param recursive : `If directories in between should be created if they're missing, defaults to false`
@param permissions : `The permissions to set on the directory`
*>
macro bool! mkdir(Path path, bool recursive = false, MkdirPermissions permissions = NORMAL)
{
@@ -110,10 +110,10 @@ macro bool! mkdir(Path path, bool recursive = false, MkdirPermissions permission
<*
Tries to delete directory, which must be empty.
@param path `The path to delete`
@param path : `The path to delete`
@require @is_pathlike(path) : "Expected a Path or String to chdir"
@return `true if there was a directory to delete, false otherwise`
@return! PathResult.INVALID_PATH `if the path was invalid`
@return! PathResult.INVALID_PATH : `if the path was invalid`
*>
macro bool! rmdir(path)
{
@@ -140,7 +140,7 @@ fn void! rmtree(Path path)
<*
Creates a new path.
@return! PathResult.INVALID_PATH `if the path was invalid`
@return! PathResult.INVALID_PATH : `if the path was invalid`
*>
fn Path! new(Allocator allocator, String path, PathEnv path_env = DEFAULT_ENV)
{
@@ -150,7 +150,7 @@ fn Path! new(Allocator allocator, String path, PathEnv path_env = DEFAULT_ENV)
<*
Creates a new path using the temp allocator.
@return! PathResult.INVALID_PATH `if the path was invalid`
@return! PathResult.INVALID_PATH : `if the path was invalid`
*>
fn Path! temp(String path, PathEnv path_env = DEFAULT_ENV)
{
@@ -316,7 +316,7 @@ fn String Path.dirname(self)
Test if the path has the given extension, so given the path /foo/bar.c3
this would be true matching the extension "c3"
@param [in] extension `The extension name (not including the leading '.')`
@param [in] extension : `The extension name (not including the leading '.')`
@require extension.len > 0 : `The extension cannot be empty`
@return `true if the extension matches`
*>
@@ -396,7 +396,7 @@ fn usz! volume_name_len(String path, PathEnv path_env) @local
of the path itself.
@return `The parent of the path as a non-allocated path`
@return! PathResult.NO_PARENT `if this path does not have a parent`
@return! PathResult.NO_PARENT : `if this path does not have a parent`
*>
fn Path! Path.parent(self)
{

View File

@@ -57,7 +57,7 @@ macro usz! read_any(stream, any ref)
}
<*
@param [&in] ref "the object to write."
@param [&in] ref : "the object to write."
@require @is_outstream(stream)
@ensure return == ref.type.sizeof
*>
@@ -393,7 +393,7 @@ macro void! write_be_int128(stream, uint128 s)
<*
@require @is_outstream(stream)
@require data.len < 256 "Data exceeded 255"
@require data.len < 256 : "Data exceeded 255"
*>
macro usz! write_tiny_bytearray(stream, char[] data)
{
@@ -415,7 +415,7 @@ macro char[]! read_tiny_bytearray(stream, Allocator allocator)
<*
@require @is_outstream(stream)
@require data.len < 0x1000 "Data exceeded 65535"
@require data.len < 0x1000 : "Data exceeded 65535"
*>
macro usz! write_short_bytearray(stream, char[] data)
{

View File

@@ -12,7 +12,7 @@ struct ReadBuffer (InStream)
Buffer reads from a stream.
@param [inout] self
@require bytes.len > 0
@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"
*>
fn ReadBuffer* ReadBuffer.init(&self, InStream wrapped_stream, char[] bytes)
{
@@ -71,8 +71,8 @@ struct WriteBuffer (OutStream)
<*
Buffer writes to a stream. Call `flush` when done writing to the buffer.
@param [inout] self
@require bytes.len > 0 "Non-empty buffer required"
@require self.bytes.len == 0 "Init may not run on already initialized data"
@require bytes.len > 0 : "Non-empty buffer required"
@require self.bytes.len == 0 : "Init may not run on already initialized data"
*>
fn WriteBuffer* WriteBuffer.init(&self, OutStream wrapped_stream, char[] bytes)
{

View File

@@ -14,7 +14,7 @@ struct ByteBuffer (InStream, OutStream)
<*
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."
@require self.bytes.len == 0 : "Buffer already initialized."
*>
fn ByteBuffer* ByteBuffer.init(&self, Allocator allocator, usz max_read, usz initial_capacity = 16)
{
@@ -31,7 +31,7 @@ fn ByteBuffer* ByteBuffer.tinit(&self, usz max_read, usz initial_capacity = 16)
<*
@require buf.len > 0
@require self.bytes.len == 0 "Buffer already initialized."
@require self.bytes.len == 0 : "Buffer already initialized."
*>
fn ByteBuffer* ByteBuffer.init_with_buffer(&self, char[] buf)
{

View File

@@ -11,7 +11,7 @@ struct ByteWriter (OutStream)
<*
@param [&inout] self
@param [&inout] allocator
@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
*>
fn ByteWriter* ByteWriter.init(&self, Allocator allocator)
@@ -22,7 +22,7 @@ fn ByteWriter* ByteWriter.init(&self, Allocator allocator)
<*
@param [&inout] self
@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
*>
fn ByteWriter* ByteWriter.tinit(&self)

View File

@@ -7,8 +7,8 @@ struct LimitReader (InStream)
}
<*
@param [&inout] wrapped_stream "The stream to read from"
@param limit "The max limit to read"
@param [&inout] wrapped_stream : "The stream to read from"
@param limit : "The max limit to read"
*>
fn LimitReader* LimitReader.init(&self, InStream wrapped_stream, usz limit)
{

View File

@@ -15,7 +15,7 @@ struct MultiReader (InStream)
<*
@param [&inout] self
@param [&inout] allocator
@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
*>
fn MultiReader* MultiReader.init(&self, Allocator allocator, InStream... readers)
@@ -28,7 +28,7 @@ fn MultiReader* MultiReader.init(&self, Allocator allocator, InStream... readers
<*
@param [&inout] self
@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
*>
fn MultiReader* MultiReader.tinit(&self, InStream... readers)

View File

@@ -13,7 +13,7 @@ struct MultiWriter (OutStream)
@param [&inout] self
@param [&inout] allocator
@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.init(&self, Allocator allocator, OutStream... writers)
{
@@ -26,7 +26,7 @@ fn MultiWriter* MultiWriter.init(&self, Allocator allocator, OutStream... writer
<*
@param [&inout] self
@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.tinit(&self, OutStream... writers)
{

View File

@@ -13,8 +13,8 @@ struct Scanner (InStream)
The supplied buffer must be at least as large as the expected data length
including its pattern.
@param [&in] stream "The stream to read data from."
@require buffer.len > 0 "Non-empty buffer required."
@param [&in] stream : "The stream to read data from."
@require buffer.len > 0 : "Non-empty buffer required."
*>
fn void Scanner.init(&self, InStream stream, char[] buffer)
{
@@ -42,8 +42,8 @@ fn void! Scanner.close(&self) @dynamic
<*
Scan the stream for the next split character and return data up to the match.
@require pattern.len > 0 "Non-empty pattern required."
@require self.buf.len > pattern.len "Pattern too large."
@require pattern.len > 0 : "Non-empty pattern required."
@require self.buf.len > pattern.len : "Pattern too large."
*>
fn char[]! Scanner.scan(&self, String pattern = "\n")
{

View File

@@ -9,15 +9,15 @@ struct TeeReader (InStream)
<* Returns a reader that implements InStream and that will write any data read
from the wrapped reader r to the writer w. There is no internal buffering.
@param [&inout] r "Stream r to read from."
@param [&inout] w "Stream w to write to what it reads from r."
@param [&inout] r : "Stream r to read from."
@param [&inout] w : "Stream w to write to what it reads from r."
*>
macro TeeReader tee_reader(InStream r, OutStream w) => { r, w };
<*
@param [&inout] self
@param [&inout] r "Stream r to read from."
@param [&inout] w "Stream w to write to what it reads from r."
@param [&inout] r : "Stream r to read from."
@param [&inout] w : "Stream w to write to what it reads from r."
*>
fn TeeReader* TeeReader.init(&self, InStream r, OutStream w)
{

View File

@@ -520,7 +520,7 @@ fn String BigInt.to_string(&self, Allocator allocator) @dynamic
}
<*
@require radix > 1 && radix <= 36 "Radix must be 2-36"
@require radix > 1 && radix <= 36 : "Radix must be 2-36"
*>
fn String BigInt.to_string_with_radix(&self, int radix, Allocator allocator)
{
@@ -562,7 +562,7 @@ fn String BigInt.to_string_with_radix(&self, int radix, Allocator allocator)
}
<*
@require !exp.is_negative() "Positive exponents only"
@require !exp.is_negative() : "Positive exponents only"
*>
fn BigInt BigInt.mod_pow(&self, BigInt exp, BigInt mod)
{
@@ -846,7 +846,7 @@ fn BigInt BigInt.lcm(&self, BigInt other)
}
<*
@require bits >> 5 < MAX_LEN "Required bits > maxlength"
@require bits >> 5 < MAX_LEN : "Required bits > maxlength"
*>
fn void BigInt.randomize_bits(&self, Random random, int bits)
{

View File

@@ -120,20 +120,20 @@ def MATRIX4F_IDENTITY = matrix::IDENTITY4{float} @builtin;
<*
@require types::is_numerical($typeof(x)) `The input must be a numerical value or numerical vector`
@require types::is_numerical($typeof(x)) : `The input must be a numerical value or numerical vector`
*>
macro deg_to_rad(x) {
return x * PI / 180;
}
<*
@require types::is_numerical($typeof(x)) `The input must be a numerical value or numerical vector`
@require types::is_numerical($typeof(x)) : `The input must be a numerical value or numerical vector`
*>
macro abs(x) => $$abs(x);
<*
@require values::@is_int(x) || values::@is_float(x) "Expected an integer or floating point value"
@require values::@is_int(y) || values::@is_float(y) "Expected an integer or floating point value"
@require values::@is_int(x) || values::@is_float(x) : "Expected an integer or floating point value"
@require values::@is_int(y) || values::@is_float(y) : "Expected an integer or floating point value"
*>
macro is_approx(x, y, eps)
{
@@ -143,8 +143,8 @@ macro is_approx(x, y, eps)
}
<*
@require values::@is_int(x) || values::@is_float(x) "Expected an integer or floating point value"
@require values::@is_int(y) || values::@is_float(y) "Expected an integer or floating point value"
@require values::@is_int(x) || values::@is_float(x) : "Expected an integer or floating point value"
@require values::@is_int(y) || values::@is_float(y) : "Expected an integer or floating point value"
*>
macro is_approx_rel(x, y, eps)
{
@@ -154,7 +154,7 @@ macro is_approx_rel(x, y, eps)
}
<*
@require values::@is_int(x) `The input must be an integer`
@require values::@is_int(x) : `The input must be an integer`
*>
macro sign(x)
{
@@ -167,8 +167,8 @@ macro sign(x)
}
<*
@require values::@is_int(x) || values::@is_float(x) "Expected an integer or floating point value"
@require values::@is_int(y) || values::@is_float(y) "Expected an integer or floating point value"
@require values::@is_int(x) || values::@is_float(x) : "Expected an integer or floating point value"
@require values::@is_int(y) || values::@is_float(y) : "Expected an integer or floating point value"
*>
macro atan2(x, y)
{
@@ -180,10 +180,10 @@ macro atan2(x, y)
}
<*
@require values::@is_int(x) || values::@is_float(x) "Expected an integer or floating point value"
@require @typekind(sinp) == POINTER "Expected sinp to be a pointer"
@require values::@is_same_type(sinp, cosp) "Expected sinp and cosp to have the same type"
@require $assignable(x, $typeof(*sinp)) "Expected x and sinp/cosp to have the same type"
@require values::@is_int(x) || values::@is_float(x) : "Expected an integer or floating point value"
@require @typekind(sinp) == POINTER : "Expected sinp to be a pointer"
@require values::@is_same_type(sinp, cosp) : "Expected sinp and cosp to have the same type"
@require $assignable(x, $typeof(*sinp)) : "Expected x and sinp/cosp to have the same type"
*>
macro sincos_ref(x, sinp, cosp)
{
@@ -197,8 +197,8 @@ macro sincos_ref(x, sinp, cosp)
<*
Return a vector with sin / cos of the given angle.
@param x `the angle in radians`
@require values::@is_int(x) || values::@is_float(x) "Expected an integer or floating point value"
@param x : `the angle in radians`
@require values::@is_int(x) || values::@is_float(x) : "Expected an integer or floating point value"
*>
macro sincos(x)
{
@@ -213,7 +213,7 @@ macro sincos(x)
}
<*
@require values::@is_int(x) || values::@is_float(x) "Expected an integer or floating point value"
@require values::@is_int(x) || values::@is_float(x) : "Expected an integer or floating point value"
*>
macro atan(x)
{
@@ -225,7 +225,7 @@ macro atan(x)
}
<*
@require values::@is_int(x) || values::@is_float(x) "Expected an integer or floating point value"
@require values::@is_int(x) || values::@is_float(x) : "Expected an integer or floating point value"
*>
macro atanh(x)
{
@@ -237,7 +237,7 @@ macro atanh(x)
}
<*
@require values::@is_int(x) || values::@is_float(x) "Expected an integer or floating point value"
@require values::@is_int(x) || values::@is_float(x) : "Expected an integer or floating point value"
*>
macro acos(x)
{
@@ -249,7 +249,7 @@ macro acos(x)
}
<*
@require values::@is_int(x) || values::@is_float(x) "Expected an integer or floating point value"
@require values::@is_int(x) || values::@is_float(x) : "Expected an integer or floating point value"
*>
macro acosh(x)
{
@@ -261,7 +261,7 @@ macro acosh(x)
}
<*
@require values::@is_int(x) || values::@is_float(x) "Expected an integer or floating point value"
@require values::@is_int(x) || values::@is_float(x) : "Expected an integer or floating point value"
*>
macro asin(x)
{
@@ -273,7 +273,7 @@ macro asin(x)
}
<*
@require values::@is_int(x) || values::@is_float(x) "Expected an integer or floating point value"
@require values::@is_int(x) || values::@is_float(x) : "Expected an integer or floating point value"
*>
macro asinh(x)
{
@@ -285,100 +285,100 @@ macro asinh(x)
}
<*
@require values::@is_floatlike(x) `The input must be a floating point value or float vector`
@require values::@is_floatlike(x) : `The input must be a floating point value or float vector`
*>
macro ceil(x) => $$ceil(x);
<*
Constrain the value to lie within the given interval.
@param x "the value to clamp, may be a number or a numerical vector."
@param lower "the lower bounds"
@param upper "the upper bounds"
@param x : "the value to clamp, may be a number or a numerical vector."
@param lower : "the lower bounds"
@param upper : "the upper bounds"
@return "lower if x < lower, upper if x > upper, otherwise return x."
@require types::is_numerical($typeof(x)) `The input must be a numerical value or numerical vector`
@require values::@assign_to(lower, x) `The lower bound must be convertable to the value type.`
@require values::@assign_to(upper, x) `The upper bound must be convertable to the value type.`
@require types::is_numerical($typeof(x)) : `The input must be a numerical value or numerical vector`
@require values::@assign_to(lower, x) : `The lower bound must be convertable to the value type.`
@require values::@assign_to(upper, x) : `The upper bound must be convertable to the value type.`
*>
macro clamp(x, lower, upper) => $$max(($typeof(x))lower, $$min(x, ($typeof(x))upper));
<*
@require values::@is_promotable_to_floatlike(mag) `The input must be a number value or float vector`
@require $defined(($typeof(values::promote_int(mag)))mag) `It's not possible to cast the sign to the type of the magnitude`
@require values::@is_promotable_to_floatlike(mag) : `The input must be a number value or float vector`
@require $defined(($typeof(values::promote_int(mag)))mag) : `It's not possible to cast the sign to the type of the magnitude`
*>
macro copysign(mag, sgn) => $$copysign(values::promote_int_same(mag, sgn), ($typeof(values::promote_int_same(mag, sgn)))sgn);
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number value or float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number value or float vector`
*>
macro cos(x) => $$cos(values::promote_int(x));
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number value or float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number value or float vector`
*>
macro cosec(x) => 1 / sin(x);
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number value or float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number value or float vector`
*>
macro cosech(x) => 2 / (exp(x) - exp(-x));
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number value or float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number value or float vector`
*>
macro cosh(x) => (exp(x) + exp(-x)) / 2.0;
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number value or float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number value or float vector`
*>
macro cotan(x) => cos(x) / sin(x);
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number value or float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number value or float vector`
*>
macro cotanh(x) => (exp(2.0 * x) + 1.0) / (exp(2.0 * x) - 1.0);
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number value or float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number value or float vector`
*>
macro exp(x) => $$exp(values::promote_int(x));
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number value or float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number value or float vector`
*>
macro exp2(x) => $$exp2(values::promote_int(x));
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number value or float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number value or float vector`
*>
macro floor(x) => $$floor(values::promote_int(x));
<*
@require values::@is_promotable_to_floatlike(a) `The input must be a number or float vector`
@require values::@is_promotable_to_floatlike(b) `The input must be a number or float vector`
@require values::@is_promotable_to_floatlike(c) `The input must be a number or float vector`
@require values::@is_same_vector_type(a, b) `The input types must be equal`
@require values::@is_same_vector_type(a, c) `The input types must match`
@require values::@is_promotable_to_floatlike(a) : `The input must be a number or float vector`
@require values::@is_promotable_to_floatlike(b) : `The input must be a number or float vector`
@require values::@is_promotable_to_floatlike(c) : `The input must be a number or float vector`
@require values::@is_same_vector_type(a, b) : `The input types must be equal`
@require values::@is_same_vector_type(a, c) : `The input types must match`
*>
macro fma(a, b, c) => $$fma(a, b, c);
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number or a float vector`
@require values::@is_promotable_to_floatlike(y) `The input must be a number or a float vector`
@require values::@is_same_vector_type(x, y) `The input types must match`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number or a float vector`
@require values::@is_promotable_to_floatlike(y) : `The input must be a number or a float vector`
@require values::@is_same_vector_type(x, y) : `The input types must match`
*>
macro hypot(x, y) => sqrt(sqr(x) + sqr(y));
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number or a float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number or a float vector`
*>
macro ln(x) => $$log(values::promote_int(x));
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number or a float vector`
@require values::@is_promotable_to_floatlike(base) `The base must be a number or a float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number or a float vector`
@require values::@is_promotable_to_floatlike(base) : `The base must be a number or a float vector`
*>
macro log(x, base)
{
@@ -386,18 +386,18 @@ macro log(x, base)
}
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number or a float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number or a float vector`
*>
macro log2(x) => $$log2(values::promote_int(x));
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number or a float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number or a float vector`
*>
macro log10(x) => $$log10(values::promote_int(x));
<*
@require types::is_numerical($typeof(x)) `The input must be a floating point value or float vector`
@require types::is_same($typeof(x), $typeof(y)) `The input types must be equal`
@require types::is_numerical($typeof(x)) : `The input must be a floating point value or float vector`
@require types::is_same($typeof(x), $typeof(y)) : `The input types must be equal`
*>
macro max(x, y, ...)
{
@@ -413,8 +413,8 @@ macro max(x, y, ...)
}
<*
@require types::is_numerical($typeof(x)) `The input must be a numerical value or numerical vector`
@require types::is_same($typeof(x), $typeof(y)) `The input types must be equal`
@require types::is_numerical($typeof(x)) : `The input must be a numerical value or numerical vector`
@require types::is_same($typeof(x), $typeof(y)) : `The input types must be equal`
*>
macro min(x, y, ...)
{
@@ -430,19 +430,19 @@ macro min(x, y, ...)
}
<*
@require types::@is_float(a) `The input must be a floating point value`
@require types::@has_same(a, b, c) `The input types must be equal`
@require types::@is_float(a) : `The input must be a floating point value`
@require types::@has_same(a, b, c) : `The input types must be equal`
*>
macro muladd(a, b, c) => $$fmuladd(a, b, c);
<*
@require values::@is_floatlike(x) `The input must be a floating point value or float vector`
@require values::@is_floatlike(x) : `The input must be a floating point value or float vector`
*>
macro nearbyint(x) => $$nearbyint(x);
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number or a float vector`
@require $assignable(exp, $typeof(values::promote_int(x))) || values::@is_int(exp) `The input must be an integer, castable to the type of x`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number or a float vector`
@require $assignable(exp, $typeof(values::promote_int(x))) || values::@is_int(exp) : `The input must be an integer, castable to the type of x`
*>
macro pow(x, exp)
{
@@ -482,18 +482,18 @@ macro int signbit(x)
}
<*
@require values::@is_floatlike(x) `The input must be a number or a float vector`
@require values::@is_floatlike(x) : `The input must be a number or a float vector`
*>
macro rint(x) => $$rint(x);
<*
@require values::@is_floatlike(x) `The input must be a floating point value or float vector`
@require values::@is_floatlike(x) : `The input must be a floating point value or float vector`
*>
macro round(x) => $$round(x);
<*
@require values::@is_floatlike(x) `The input must be a floating point value or float vector`
@require values::@is_floatlike(x) : `The input must be a floating point value or float vector`
*>
macro round_to_decimals(x, int decimal_places)
{
@@ -502,42 +502,42 @@ macro round_to_decimals(x, int decimal_places)
}
<*
@require values::@is_floatlike(x) `The input must be a floating point value or float vector`
@require values::@is_floatlike(x) : `The input must be a floating point value or float vector`
*>
macro roundeven(x) => $$roundeven(x);
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number or a float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number or a float vector`
*>
macro sec(x) => 1 / cos(x);
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number or a float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number or a float vector`
*>
macro sech(x) => 2 / (exp(x) + exp(-x));
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number or a float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number or a float vector`
*>
macro sin(x) => $$sin(values::promote_int(x));
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number or a float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number or a float vector`
*>
macro sinh(x) => (exp(x) - exp(-x)) / 2.0;
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number or a float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number or a float vector`
*>
macro sqr(x) => values::promote_int(x) * values::promote_int(x);
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number or a float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number or a float vector`
*>
macro sqrt(x) => $$sqrt(values::promote_int(x));
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number or a float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number or a float vector`
*>
macro tan(x)
{
@@ -553,7 +553,7 @@ macro tan(x)
}
<*
@require values::@is_promotable_to_float(x) `The input must be a float`
@require values::@is_promotable_to_float(x) : `The input must be a float`
*>
macro bool is_finite(x)
{
@@ -567,7 +567,7 @@ macro bool is_finite(x)
}
<*
@require values::@is_promotable_to_float(x) `The input must be a float`
@require values::@is_promotable_to_float(x) : `The input must be a float`
*>
macro is_nan(x)
{
@@ -581,7 +581,7 @@ macro is_nan(x)
}
<*
@require values::@is_promotable_to_float(x) `The input must be a float`
@require values::@is_promotable_to_float(x) : `The input must be a float`
*>
macro is_inf(x)
{
@@ -595,12 +595,12 @@ macro is_inf(x)
}
<*
@require values::@is_promotable_to_floatlike(x) `The input must be a number or a float vector`
@require values::@is_promotable_to_floatlike(x) : `The input must be a number or a float vector`
*>
macro tanh(x) => (exp(2.0 * x) - 1.0) / (exp(2.0 * x) + 1.0);
<*
@require values::@is_floatlike(x) `The input must be a floating point value or float vector`
@require values::@is_floatlike(x) : `The input must be a floating point value or float vector`
*>
macro trunc(x) => $$trunc(x);
@@ -620,12 +620,12 @@ macro normalize(x) @private
<*
Use a mask to select values from either "then" or "else" vectors.
@param mask "The mask to use for the select, 'true' will pick the then_value, 'false' the else_value"
@param then_value "The vector to get elements from where the mask is 'true'"
@param else_value "The vector to get elements from where the mask is 'false'"
@require values::@is_vector(then_value) && values::@is_vector(else_value) "'Then' and 'else' must be vectors."
@require values::@is_same_type(then_value, else_value) "'Then' and 'else' vectors must be of the same type."
@require then_value.len == mask.len "Mask and selected vectors must be of the same width."
@param mask : "The mask to use for the select, 'true' will pick the then_value, 'false' the else_value"
@param then_value : "The vector to get elements from where the mask is 'true'"
@param else_value : "The vector to get elements from where the mask is 'false'"
@require values::@is_vector(then_value) && values::@is_vector(else_value) : "'Then' and 'else' must be vectors."
@require values::@is_same_type(then_value, else_value) : "'Then' and 'else' vectors must be of the same type."
@require then_value.len == mask.len : "Mask and selected vectors must be of the same width."
@return "a vector of the same type as then/else"
*>
@@ -974,12 +974,12 @@ macro int128! int128.overflow_add(int128 x, int128 y) => overflow_add_helper(x,
macro int128! int128.overflow_sub(int128 x, int128 y) => overflow_sub_helper(x, y);
macro int128! int128.overflow_mul(int128 x, int128 y) => overflow_mul_helper(x, y);
<*
@require values::@is_int(x) `The input must be an integer`
@require values::@is_int(x) : `The input must be an integer`
*>
macro bool is_odd(x) => (bool)(x & 1);
<*
@require values::@is_int(x) `The input must be an integer`
@require values::@is_int(x) : `The input must be an integer`
*>
macro bool is_even(x) => !is_odd(x);
@@ -1175,31 +1175,31 @@ macro bool @is_same_vector_or_scalar(#vector_value, #vector_or_scalar) @private
}
<*
@require @is_same_vector_or_scalar(self, mul) `mul must be a vector of the same type as self, or be an integer scalar`
@require @is_same_vector_or_scalar(self, div) `div must be a vector of the same type as self, or be an integer scalar`
@require @is_same_vector_or_scalar(self, mul) : `mul must be a vector of the same type as self, or be an integer scalar`
@require @is_same_vector_or_scalar(self, div) : `div must be a vector of the same type as self, or be an integer scalar`
*>
macro char[<?>] char[<?>].muldiv(self, mul, div) => mul_div_helper(self, mul, div);
<*
@require @is_same_vector_or_scalar(self, mul) `mul must be a vector of the same type as self, or be an integer scalar`
@require @is_same_vector_or_scalar(self, div) `div must be a vector of the same type as self, or be an integer scalar`
@require @is_same_vector_or_scalar(self, mul) : `mul must be a vector of the same type as self, or be an integer scalar`
@require @is_same_vector_or_scalar(self, div) : `div must be a vector of the same type as self, or be an integer scalar`
*>
macro ichar[<?>] ichar[<?>].muldiv(self, mul, div) => mul_div_helper(self, mul, div);
<*
@require @is_same_vector_or_scalar(self, mul) `mul must be a vector of the same type as self, or be an integer scalar`
@require @is_same_vector_or_scalar(self, div) `div must be a vector of the same type as self, or be an integer scalar`
@require @is_same_vector_or_scalar(self, mul) : `mul must be a vector of the same type as self, or be an integer scalar`
@require @is_same_vector_or_scalar(self, div) : `div must be a vector of the same type as self, or be an integer scalar`
*>
macro short[<?>] short[<?>].muldiv(self, mul, div) => mul_div_helper(self, mul, div);
<*
@require @is_same_vector_or_scalar(self, mul) `mul must be a vector of the same type as self, or be an integer scalar`
@require @is_same_vector_or_scalar(self, div) `div must be a vector of the same type as self, or be an integer scalar`
@require @is_same_vector_or_scalar(self, mul) : `mul must be a vector of the same type as self, or be an integer scalar`
@require @is_same_vector_or_scalar(self, div) : `div must be a vector of the same type as self, or be an integer scalar`
*>
macro ushort[<?>] ushort[<?>].muldiv(self, mul, div) => mul_div_helper(self, mul, div);
<*
@require @is_same_vector_or_scalar(self, mul) `mul must be a vector of the same type as self, or be an integer scalar`
@require @is_same_vector_or_scalar(self, mul) : `mul must be a vector of the same type as self, or be an integer scalar`
@require @is_same_vector_or_scalar(self, div) `div must be a vector of the same type as self, or be an integer scalar`
*>
macro int[<?>] int[<?>].muldiv(self, mul, div) => mul_div_helper(self, mul, div);

View File

@@ -2,8 +2,8 @@
Randoms:
General usage -
1. Create a Random (see std/math/random for various alternatives), or pick DefaultRandom
2. Define it `DefaultRandom my_random;`
3. Seed it: `random::seed(&my_random, some_seed);` or `rand::seed_entropy(&my_random);`
2. Define it : `DefaultRandom my_random;`
3. Seed it: `random::seed(&my_random, some_seed);` or : `rand::seed_entropy(&my_random);`
4. Use it with the functions in random: `float random_float = random::next_float(&my_random);`
For just a simple integer between 0 and n (not including n), you can use `rand(n)`.

View File

@@ -54,7 +54,7 @@ struct Poll
<*
@param [inout] polls
@param timeout "duration to poll (clamped to CInt.max ms), or POLL_FOREVER."
@param timeout : "duration to poll (clamped to CInt.max ms), or POLL_FOREVER."
*>
fn ulong! poll(Poll[] polls, Duration timeout)
{
@@ -63,7 +63,7 @@ fn ulong! poll(Poll[] polls, Duration timeout)
<*
@param [inout] polls
@param timeout_ms "duration to poll in ms or -1. Clamped to CInt.max"
@param timeout_ms : "duration to poll in ms or -1. Clamped to CInt.max"
*>
fn ulong! poll_ms(Poll[] polls, long timeout_ms)
{

View File

@@ -46,7 +46,7 @@ struct Url(Printable)
Parse a URL string into a Url struct.
@param [in] url_string
@require url_string.len > 0 "the url_string must be len 1 or more"
@require url_string.len > 0 : "the url_string must be len 1 or more"
@return "the parsed Url"
*>
fn Url! tparse(String url_string) => parse(tmem(), url_string);
@@ -55,7 +55,7 @@ fn Url! tparse(String url_string) => parse(tmem(), url_string);
Parse a URL string into a Url struct.
@param [in] url_string
@require url_string.len > 0 "the url_string must be len 1 or more"
@require url_string.len > 0 : "the url_string must be len 1 or more"
@return "the parsed Url"
*>
fn Url! parse(Allocator allocator, String url_string)

View File

@@ -23,8 +23,8 @@ fault UrlDecodingError
<*
Returns true if char c should be encoded according to RFC 3986.
@param c "Character to check if it should be encoded."
@param mode "Url encoding mode."
@param c : "Character to check if it should be encoded."
@param mode : "Url encoding mode."
*>
fn bool should_encode(char c, UrlEncodingMode mode) @private
{
@@ -62,8 +62,8 @@ fn usz encode_len(String s, UrlEncodingMode mode) @inline
Encode the string s for a given encoding mode.
Returned string must be freed.
@param s "String to encode"
@param mode "Url encoding mode"
@param s : "String to encode"
@param mode : "Url encoding mode"
@param [inout] allocator
@return "Percent-encoded String"
*>
@@ -99,8 +99,8 @@ fn String encode(Allocator allocator, String s, UrlEncodingMode mode) => @pool(a
<*
Encode string s for a given encoding mode, stored on the temp allocator.
@param s "String to encode"
@param mode "Url encoding mode"
@param s : "String to encode"
@param mode : "Url encoding mode"
@return "Percent-encoded String"
*>
fn String tencode(String s, UrlEncodingMode mode) => encode(tmem(), s, mode);
@@ -129,8 +129,8 @@ fn usz! decode_len(String s, UrlEncodingMode mode) @inline
Decode string s for a given encoding mode.
Returned string must be freed.
@param s "String to decode"
@param mode "Url encoding mode"
@param s : "String to decode"
@param mode : "Url encoding mode"
@param [inout] allocator
@return "Percent-decoded String"
*>
@@ -166,8 +166,8 @@ fn String! decode(Allocator allocator, String s, UrlEncodingMode mode) => @pool
<*
Decode string s for a given encoding mode, stored on the temp allocator.
@param s "String to decode"
@param mode "Url encoding mode"
@param s : "String to decode"
@param mode : "Url encoding mode"
@return "Percent-decoded String"
*>
fn String! tdecode(String s, UrlEncodingMode mode) => decode(tmem(), s, mode);

View File

@@ -3,9 +3,9 @@ module std::sort;
<*
Perform a binary search over the sorted array and return the index
in [0, array.len) where x would be inserted or cmp(i) is true and cmp(j) is true for j in [i, array.len).
@require @is_sortable(list) "The list must be sortable"
@require @is_valid_cmp_fn(cmp, list, context) "Expected a comparison function which compares values"
@require @is_valid_context(cmp, context) "Expected a valid context"
@require @is_sortable(list) : "The list must be sortable"
@require @is_valid_cmp_fn(cmp, list, context) : "Expected a comparison function which compares values"
@require @is_valid_context(cmp, context) : "Expected a valid context"
*>
macro usz binarysearch(list, x, cmp = EMPTY_MACRO_SLOT, context = EMPTY_MACRO_SLOT) @builtin
{

View File

@@ -5,8 +5,8 @@ import std::sort::qs;
<*
Sort list using the counting sort algorithm.
@require @is_sortable(list) "The list must be indexable and support .len or .len()"
@require @is_cmp_key_fn(key_fn, list) "Expected a transformation function which returns an unsigned integer."
@require @is_sortable(list) : "The list must be indexable and support .len or .len()"
@require @is_cmp_key_fn(key_fn, list) : "Expected a transformation function which returns an unsigned integer."
*>
macro countingsort(list, key_fn = EMPTY_MACRO_SLOT) @builtin
{

View File

@@ -3,8 +3,8 @@ import std::sort::is;
<*
Sort list using the quick sort algorithm.
@require @is_sortable(list) "The list must be indexable and support .len or .len()"
@require @is_valid_cmp_fn(cmp, list, context) "Expected a comparison function which compares values"
@require @is_sortable(list) : "The list must be indexable and support .len or .len()"
@require @is_valid_cmp_fn(cmp, list, context) : "Expected a comparison function which compares values"
*>
macro insertionsort(list, cmp = EMPTY_MACRO_SLOT, context = EMPTY_MACRO_SLOT) @builtin @safemacro
{

View File

@@ -3,9 +3,9 @@ import std::sort::qs;
<*
Sort list using the quick sort algorithm.
@require @is_sortable(list) "The list must be indexable and support .len or .len()"
@require @is_valid_cmp_fn(cmp, list, context) "Expected a comparison function which compares values"
@require @is_valid_context(cmp, context) "Expected a valid context"
@require @is_sortable(list) : "The list must be indexable and support .len or .len()"
@require @is_valid_cmp_fn(cmp, list, context) : "Expected a comparison function which compares values"
@require @is_valid_context(cmp, context) : "Expected a valid context"
*>
macro quicksort(list, cmp = EMPTY_MACRO_SLOT, context = EMPTY_MACRO_SLOT) @builtin
{
@@ -23,9 +23,9 @@ Select the (k+1)th smallest element in an unordered list using Hoare's
selection algorithm (Quickselect). k should be between 0 and len-1. The data
list will be partially sorted.
@require @is_sortable(list) "The list must be indexable and support .len or .len()"
@require @is_valid_cmp_fn(cmp, list, context) "expected a comparison function which compares values"
@require @is_valid_context(cmp, context) "Expected a valid context"
@require @is_sortable(list) : "The list must be indexable and support .len or .len()"
@require @is_valid_cmp_fn(cmp, list, context) : "expected a comparison function which compares values"
@require @is_valid_context(cmp, context) : "Expected a valid context"
*>
macro quickselect(list, isz k, cmp = EMPTY_MACRO_SLOT, context = EMPTY_MACRO_SLOT) @builtin
{
@@ -82,8 +82,8 @@ fn void qsort(Type list, isz low, isz high, CmpFn cmp, Context context)
}
<*
@require low <= k "kth smalles element is smaller than lower bounds"
@require k <= high "kth smalles element is larger than upper bounds"
@require low <= k : "kth smalles element is smaller than lower bounds"
@require k <= high : "kth smalles element is larger than upper bounds"
*>
fn ElementType! qselect(Type list, isz low, isz high, isz k, CmpFn cmp, Context context)
{

View File

@@ -2,9 +2,9 @@ module std::sort;
<*
Returns true if list is sorted in either ascending or descending order.
@require @is_sortable(list) "The list must be indexable and support .len or .len()"
@require @is_valid_cmp_fn(cmp, list, ctx) "Expected a comparison function which compares values"
@require @is_valid_context(cmp, ctx) "Expected a valid context"
@require @is_sortable(list) : "The list must be indexable and support .len or .len()"
@require @is_valid_cmp_fn(cmp, list, ctx) : "Expected a comparison function which compares values"
@require @is_valid_context(cmp, ctx) : "Expected a valid context"
*>
macro bool is_sorted(list, cmp = EMPTY_MACRO_SLOT, ctx = EMPTY_MACRO_SLOT) @builtin
{

View File

@@ -171,7 +171,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.init(&self, int size, String name, Allocator allocator, void* monitor_context)
{

View File

@@ -32,9 +32,9 @@ struct QueueItem @private
}
<*
@require !self.initialized "ThreadPool must not be already initialized"
@require threads > 0 && threads < 0x1000 `Threads should be greater than 0 and less than 0x1000`
@require queue_size < 0x10000 `Queue size must be less than 65536`
@require !self.initialized : "ThreadPool must not be already initialized"
@require threads > 0 && threads < 0x1000 : `Threads should be greater than 0 and less than 0x1000`
@require queue_size < 0x10000 : `Queue size must be less than 65536`
*>
fn void! FixedThreadPool.init(&self, usz threads, usz queue_size = 0)
{

View File

@@ -89,7 +89,7 @@ fn void! NativeMutex.lock(&mtx)
<*
@require mtx.timed "Only available for timed locks"
@require mtx.timed : "Only available for timed locks"
*>
fn void! NativeMutex.lock_timeout(&mtx, ulong ms)
{

View File

@@ -24,7 +24,7 @@ struct QueueItem @private
}
<*
@require !self.initialized "ThreadPool must not be already initialized"
@require !self.initialized : "ThreadPool must not be already initialized"
*>
fn void! ThreadPool.init(&self)
{

View File

@@ -22,6 +22,7 @@
- `$for` "()" replaced by trailing ":" `$for (var $x = 0; $x < FOO; $x++)` -> `$for var $x = 0; $x < FOO; $x++:`
- `$switch` "()" replaced by trailing ":" `$switch ($Type)` -> `$switch $Type:`
- Empty `$switch` requires trailing ":" `$switch` -> `$switch:`
- Change `@return!` syntax to require ":" after faults.
### Fixes
- Fix address sanitizer to work on MachO targets (e.g. MacOS).

View File

@@ -10,7 +10,7 @@ fn void main()
"こんにちは世界!",
"你好世界!",
"नमस्ते दुनिया!",
"👋🌎!"
: "👋🌎!"
};
foreach (greeting : greetings)
{

View File

@@ -2633,7 +2633,7 @@ static inline bool parse_doc_contract(ParseContext *c, AstId *docs, AstId **docs
}
/**
* param_contract ::= '@param' inout_attribute? any_identifier ( (':' STRING) | STRING )?
* param_contract ::= '@param' inout_attribute? any_identifier ( ':' STRING )?
* inout_attribute ::= '[' '&'? ('in' | 'inout' | 'out') ']'
*/
static inline bool parse_contract_param(ParseContext *c, AstId *docs, AstId **docs_next)
@@ -2742,7 +2742,14 @@ static inline bool parse_doc_optreturn(ParseContext *c, AstId *docs, AstId **doc
}
RANGE_EXTEND_PREV(ast);
// Just ignore our potential string:
(void)try_consume(c, TOKEN_STRING);
if (try_consume(c, TOKEN_COLON))
{
CONSUME_OR_RET(TOKEN_STRING, false);
}
else if (try_consume(c, TOKEN_STRING))
{
RETURN_PRINT_ERROR_LAST("Expected a ':' before the description.");
}
ast->contract_stmt.faults = returns;
append_docs(docs_next, docs, ast);
return true;