diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-11-29 12:55:14 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-11-29 12:55:14 -0500 |
| commit | 4b5e4cd1f21582f5e5fa682ab4e4bff252963468 (patch) | |
| tree | e8fecb01f444c1d392c09255adba5cf6b312b326 /stdlib/channels.c | |
| parent | 0b0e0a0a1d41e9574de8dc17c688a4894c5e7f92 (diff) | |
Change how types handle metamethods
Diffstat (limited to 'stdlib/channels.c')
| -rw-r--r-- | stdlib/channels.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/stdlib/channels.c b/stdlib/channels.c index ac3d697f..8ab4e665 100644 --- a/stdlib/channels.c +++ b/stdlib/channels.c @@ -99,25 +99,23 @@ public void Channel$clear(Channel_t *channel) (void)pthread_cond_signal(&channel->cond); } -PUREFUNC public uint64_t Channel$hash(Channel_t **channel, const TypeInfo_t *type) +PUREFUNC public uint64_t Channel$hash(const void *channel, const TypeInfo_t *type) { (void)type; - return siphash24((void*)*channel, sizeof(Channel_t*)); + return siphash24(*(void**)channel, sizeof(Channel_t*)); } -PUREFUNC public int32_t Channel$compare(Channel_t **x, Channel_t **y, const TypeInfo_t *type) +PUREFUNC public int32_t Channel$compare(const void *x, const void *y, const TypeInfo_t*) { - (void)type; - return (*x > *y) - (*x < *y); + return (*(Channel_t**)x > *(Channel_t**)y) - (*(Channel_t**)x < *(Channel_t**)y); } -PUREFUNC public bool Channel$equal(Channel_t **x, Channel_t **y, const TypeInfo_t *type) +PUREFUNC public bool Channel$equal(const void *x, const void *y, const TypeInfo_t*) { - (void)type; - return (*x == *y); + return (*(void**)x == *(void**)y); } -public Text_t Channel$as_text(Channel_t **channel, bool colorize, const TypeInfo_t *type) +public Text_t Channel$as_text(const void *channel, bool colorize, const TypeInfo_t *type) { const TypeInfo_t *item_type = type->ChannelInfo.item; if (!channel) { @@ -129,9 +127,14 @@ public Text_t Channel$as_text(Channel_t **channel, bool colorize, const TypeInfo colorize ? Text("\x1b[34;1m|:") : Text("|:"), typename, Text("|<"), - Int64$hex((int64_t)(void*)*channel, I_small(0), true, true), + Int64$hex(*(int64_t*)channel, I_small(0), true, true), colorize ? Text(">\x1b[m") : Text(">") ); } +public PUREFUNC bool Channel$is_none(const void *obj, const TypeInfo_t*) +{ + return *(void**)obj == NULL; +} + // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 |
