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/threads.c | |
| parent | 0b0e0a0a1d41e9574de8dc17c688a4894c5e7f92 (diff) | |
Change how types handle metamethods
Diffstat (limited to 'stdlib/threads.c')
| -rw-r--r-- | stdlib/threads.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/stdlib/threads.c b/stdlib/threads.c index 3ae2980b..860b4880 100644 --- a/stdlib/threads.c +++ b/stdlib/threads.c @@ -53,19 +53,25 @@ public void Thread$detach(Thread_t thread) pthread_detach(*thread); } -Text_t Thread$as_text(const Thread_t *thread, bool colorize, const TypeInfo_t *type) +Text_t Thread$as_text(const void *thread, bool colorize, const TypeInfo_t*) { - (void)type; if (!thread) { return colorize ? Text("\x1b[34;1mThread\x1b[m") : Text("Thread"); } - return Text$format(colorize ? "\x1b[34;1mThread(%p)\x1b[m" : "Thread(%p)", *thread); + return Text$format(colorize ? "\x1b[34;1mThread(%p)\x1b[m" : "Thread(%p)", *(Thread_t**)thread); +} + +static bool Thread$is_none(const void *obj, const TypeInfo_t*) +{ + return *(Thread_t*)obj == NULL; } public const TypeInfo_t Thread$info = { .size=sizeof(Thread_t), .align=__alignof(Thread_t), - .tag=CustomInfo, - .CustomInfo={.as_text=(void*)Thread$as_text}, + .metamethods={ + .as_text=Thread$as_text, + .is_none=Thread$is_none, + }, }; // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 |
