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/patterns.c | |
| parent | 0b0e0a0a1d41e9574de8dc17c688a4894c5e7f92 (diff) | |
Change how types handle metamethods
Diffstat (limited to 'stdlib/patterns.c')
| -rw-r--r-- | stdlib/patterns.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/stdlib/patterns.c b/stdlib/patterns.c index 3bf2ebfd..f6a7aa85 100644 --- a/stdlib/patterns.c +++ b/stdlib/patterns.c @@ -9,6 +9,7 @@ #include "integers.h" #include "optionals.h" #include "patterns.h" +#include "structs.h" #include "tables.h" #include "text.h" #include "types.h" @@ -1160,6 +1161,7 @@ public const TypeInfo_t Pattern$info = { .align=__alignof__(Pattern_t), .tag=TextInfo, .TextInfo={.lang="Pattern"}, + .metamethods=Text$metamethods, }; static NamedType_t _match_fields[3] = { @@ -1167,6 +1169,12 @@ static NamedType_t _match_fields[3] = { {"index", &Int$info}, {"captures", Array$info(&Text$info)}, }; + +static bool Match$is_none(const void *m, const TypeInfo_t*) +{ + return ((OptionalMatch_t*)m)->index.small == 0; +} + public const TypeInfo_t Match$info = { .size=sizeof(Match_t), .align=__alignof__(Match_t), @@ -1176,6 +1184,13 @@ public const TypeInfo_t Match$info = { .num_fields=3, .fields=_match_fields, }, + .metamethods={ + .as_text=Struct$as_text, + .hash=Struct$hash, + .compare=Struct$compare, + .equal=Struct$equal, + .is_none=Match$is_none, + }, }; // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 |
