Skip to content

Commit 984b3c8

Browse files
committed
Rename inner_kind and inner_type.
1 parent df91ee3 commit 984b3c8

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

lib/std/core/mem.c3

+5-5
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,10 @@ macro void set_inline(void* dst, char val, usz $len, usz $dst_align = 0, bool $i
373373
$$memset_inline(dst, val, $len, $is_volatile, $dst_align);
374374
}
375375
/**
376-
* @require values::@inner_kind(a) == TypeKind.SLICE || values::@inner_kind(a) == TypeKind.POINTER
377-
* @require values::@inner_kind(b) == TypeKind.SLICE || values::@inner_kind(b) == TypeKind.POINTER
378-
* @require values::@inner_kind(a) != TypeKind.SLICE || len == -1
379-
* @require values::@inner_kind(a) != TypeKind.POINTER || len > -1
376+
* @require values::@remove_distinct_kind(a) == TypeKind.SLICE || values::@remove_distinct_kind(a) == TypeKind.POINTER
377+
* @require values::@remove_distinct_kind(b) == TypeKind.SLICE || values::@remove_distinct_kind(b) == TypeKind.POINTER
378+
* @require values::@remove_distinct_kind(a) != TypeKind.SLICE || len == -1
379+
* @require values::@remove_distinct_kind(a) != TypeKind.POINTER || len > -1
380380
* @require values::@assign_to(a, b) && values::@assign_to(b, a)
381381
**/
382382
macro bool equals(a, b, isz len = -1, usz $align = 0)
@@ -386,7 +386,7 @@ macro bool equals(a, b, isz len = -1, usz $align = 0)
386386
$endif
387387
void* x @noinit;
388388
void* y @noinit;
389-
$if values::@inner_kind(a) == TypeKind.SLICE:
389+
$if values::@remove_distinct_kind(a) == TypeKind.SLICE:
390390
len = a.len;
391391
if (len != b.len) return false;
392392
x = a.ptr;

lib/std/core/types.c3

+15-6
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ macro bool is_int($Type) @const => $Type.kindof == TypeKind.SIGNED_INT || $Type
128128
**/
129129
macro bool is_signed($Type) @const
130130
{
131-
$switch (inner_kind($Type))
131+
$switch (remove_distinct_kind($Type))
132132
$case SIGNED_INT:
133133
$case FLOAT:
134134
return true;
@@ -144,7 +144,7 @@ macro bool is_signed($Type) @const
144144
**/
145145
macro bool is_unsigned($Type) @const
146146
{
147-
$switch (inner_kind($Type))
147+
$switch (remove_distinct_kind($Type))
148148
$case UNSIGNED_INT:
149149
return true;
150150
$case VECTOR:
@@ -209,20 +209,29 @@ macro bool is_vector($Type) @const
209209
return $Type.kindof == TypeKind.VECTOR;
210210
}
211211

212-
macro typeid inner_type($Type) @const
212+
/**
213+
* Recursively remove distinct to get the innermost type.
214+
**/
215+
macro typeid remove_distinct($Type) @const
213216
{
214217
$if $Type.kindof == TypeKind.DISTINCT:
215-
return inner_type($typefrom($Type.inner));
218+
return remove_distinct($typefrom($Type.inner));
216219
$else
217220
return $Type.typeid;
218221
$endif
219222
}
220223

221-
macro TypeKind inner_kind($Type) @const
224+
/**
225+
* Recursively remove distinct to get the innermost TypeKind.
226+
**/
227+
macro TypeKind remove_distinct_kind($Type) @const
222228
{
223-
return inner_type($Type).kindof;
229+
return remove_distinct($Type).kindof;
224230
}
225231

232+
macro typeid inner_type($Type) @const @deprecated("Use remove_distinct") => remove_distinct($Type);
233+
macro TypeKind inner_kind($Type) @const @deprecated("Use remove_distinct_kind") => remove_distinct_kind($Type);
234+
226235
macro bool is_same($TypeA, $TypeB) @const
227236
{
228237
return $TypeA.typeid == $TypeB.typeid;

lib/std/core/values.c3

+3-2
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,6 @@ macro promote_int_same(x, y)
4242
$endif
4343
}
4444

45-
macro TypeKind @inner_kind(#value) @const => types::inner_kind($typeof(#value));
46-
45+
macro typeid @remove_distinct(#value) @const => types::remove_distinct($typeof(#value));
46+
macro TypeKind @remove_distinct_kind(#value) @const => types::remove_distinct_kind($typeof(#value));
47+
macro TypeKind @inner_kind(#value) @const @deprecated("Use @remove_distinct_kind") => @remove_distinct_kind(#value);

releasenotes.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
*None yet*
1010

1111
### Stdlib changes
12-
*None yet*
12+
- Added `types::remove_distinct`, `types::remove_distinct_kind`, `values::@remove_distinct`, `values::@remove_distinct_kind`.
13+
- Deprecated `types::inner_kind`, `types::inner_type`, `values::@inner_kind`.
1314

1415
## 0.6.2 Change list
1516

0 commit comments

Comments
 (0)