mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
- Added $kindof compile time function.
- Deprecated `@typekind` macro in favour of `$kindof`. - Deprecated `@typeis` macro in favour of `$typeof(#foo) == int`.
This commit is contained in:
@@ -8,7 +8,7 @@ Sort list using the quick sort algorithm.
|
||||
*>
|
||||
macro insertionsort(list, cmp = EMPTY_MACRO_SLOT, context = EMPTY_MACRO_SLOT) @builtin @safemacro
|
||||
{
|
||||
$if @typekind(list) == POINTER &&& (@typekind(*list) == ARRAY || @typekind(*list) == VECTOR):
|
||||
$if $kindof(list) == POINTER &&& ($kindof(*list) == ARRAY || $kindof(*list) == VECTOR):
|
||||
$typeof((*list)[0])[] list2 = list;
|
||||
is::isort{$typeof(list2), $typeof(cmp), $typeof(context)}(list2, 0, list.len, cmp, context);
|
||||
$else
|
||||
|
||||
@@ -9,7 +9,7 @@ Sort list using the quick sort algorithm.
|
||||
*>
|
||||
macro quicksort(list, cmp = EMPTY_MACRO_SLOT, context = EMPTY_MACRO_SLOT) @builtin
|
||||
{
|
||||
$if @typekind(list) == POINTER &&& (@typekind(*list) == ARRAY || @typekind(*list) == VECTOR):
|
||||
$if $kindof(list) == POINTER &&& ($kindof(*list) == ARRAY || $kindof(*list) == VECTOR):
|
||||
$typeof((*list)[0])[] list2 = list;
|
||||
qs::qsort{$typeof(list2), $typeof(cmp), $typeof(context)}(list2, 0, (isz)list.len - 1, cmp, context);
|
||||
$else
|
||||
|
||||
@@ -16,7 +16,7 @@ macro bool @is_sortable(#list)
|
||||
return false;
|
||||
$case !$defined(#list.len):
|
||||
return false;
|
||||
$case @typekind(#list) == VECTOR || @typekind(#list) == ARRAY:
|
||||
$case $kindof(#list) == VECTOR || $kindof(#list) == ARRAY:
|
||||
return false;
|
||||
$case $defined(&#list[0]) &&& !types::is_same($typeof(&#list[0]), $typeof(#list[0])*):
|
||||
return false;
|
||||
@@ -49,7 +49,7 @@ macro bool @is_cmp_key_fn(#key_fn, #list)
|
||||
{
|
||||
$switch:
|
||||
$case @is_empty_macro_slot(#key_fn): return true;
|
||||
$case $typeof(#key_fn).kindof != FUNC: return false;
|
||||
$case $kindof(#key_fn) != FUNC: return false;
|
||||
$case $typeof(#key_fn).returns.kindof != UNSIGNED_INT: return false;
|
||||
$case $defined(#key_fn(#list[0])): return true;
|
||||
$case $defined(#key_fn(&&(#list[0]))): return true;
|
||||
|
||||
Reference in New Issue
Block a user