aboutsummaryrefslogtreecommitdiff
path: root/stdlib/channels.h
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-11-29 12:55:14 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-11-29 12:55:14 -0500
commit4b5e4cd1f21582f5e5fa682ab4e4bff252963468 (patch)
treee8fecb01f444c1d392c09255adba5cf6b312b326 /stdlib/channels.h
parent0b0e0a0a1d41e9574de8dc17c688a4894c5e7f92 (diff)
Change how types handle metamethods
Diffstat (limited to 'stdlib/channels.h')
-rw-r--r--stdlib/channels.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/stdlib/channels.h b/stdlib/channels.h
index c960452a..9a848107 100644
--- a/stdlib/channels.h
+++ b/stdlib/channels.h
@@ -20,9 +20,22 @@ void Channel$peek(Channel_t *channel, void *out, bool front, int64_t item_size);
#define Channel$peek_value(channel, front, t) ({ t _val; Channel$peek(channel, &_val, front, sizeof(t)); _val; })
void Channel$clear(Channel_t *channel);
Array_t Channel$view(Channel_t *channel);
-PUREFUNC uint64_t Channel$hash(Channel_t **channel, const TypeInfo_t *type);
-PUREFUNC int32_t Channel$compare(Channel_t **x, Channel_t **y, const TypeInfo_t *type);
-PUREFUNC bool Channel$equal(Channel_t **x, Channel_t **y, const TypeInfo_t *type);
-Text_t Channel$as_text(Channel_t **channel, bool colorize, const TypeInfo_t *type);
+PUREFUNC uint64_t Channel$hash(const void *channel, const TypeInfo_t *type);
+PUREFUNC int32_t Channel$compare(const void *x, const void *y, const TypeInfo_t *type);
+PUREFUNC bool Channel$equal(const void *x, const void *y, const TypeInfo_t *type);
+Text_t Channel$as_text(const void *channel, bool colorize, const TypeInfo_t *type);
+PUREFUNC bool Channel$is_none(const void *obj, const TypeInfo_t*);
+
+#define Channel$metamethods ((metamethods_t){ \
+ .as_text=Channel$as_text, \
+ .compare=Channel$compare, \
+ .equal=Channel$equal, \
+ .hash=Channel$hash, \
+ .is_none=Channel$is_none, \
+})
+
+#define Channel$info(item_info) &((TypeInfo_t){.size=sizeof(Channel_t), .align=__alignof__(Channel_t), \
+ .tag=ChannelInfo, .ChannelInfo.item=item_info, \
+ .metamethods=Channel$metamethods})
// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0