From c455e7b67d2e55e6ed03e3449203d4e307f5a7dd Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 13 Sep 2024 20:18:08 -0400 Subject: Rename builtins/ -> stdlib/ --- builtins/bools.c | 54 ------------------------------------------------------ 1 file changed, 54 deletions(-) delete mode 100644 builtins/bools.c (limited to 'builtins/bools.c') diff --git a/builtins/bools.c b/builtins/bools.c deleted file mode 100644 index d7b3718f..00000000 --- a/builtins/bools.c +++ /dev/null @@ -1,54 +0,0 @@ -// Boolean methods/type info -#include -#include -#include -#include -#include -#include -#include - -#include "bools.h" -#include "optionals.h" -#include "text.h" -#include "util.h" - -PUREFUNC public Text_t Bool$as_text(const bool *b, bool colorize, const TypeInfo *type) -{ - (void)type; - if (!b) return Text("Bool"); - if (colorize) - return *b ? Text("\x1b[35myes\x1b[m") : Text("\x1b[35mno\x1b[m"); - else - return *b ? Text("yes") : Text("no"); -} - -PUREFUNC public OptionalBool_t Bool$from_text(Text_t text) -{ - if (Text$equal_ignoring_case(text, Text("yes")) - || Text$equal_ignoring_case(text, Text("on")) - || Text$equal_ignoring_case(text, Text("true")) - || Text$equal_ignoring_case(text, Text("1"))) { - return yes; - } else if (Text$equal_ignoring_case(text, Text("no")) - || Text$equal_ignoring_case(text, Text("off")) - || Text$equal_ignoring_case(text, Text("false")) - || Text$equal_ignoring_case(text, Text("0"))) { - return no; - } else { - return NULL_BOOL; - } -} - -public Bool_t Bool$random(double p) -{ - return (drand48() < p); -} - -public const TypeInfo Bool$info = { - .size=sizeof(bool), - .align=__alignof__(bool), - .tag=CustomInfo, - .CustomInfo={.as_text=(void*)Bool$as_text}, -}; - -// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 -- cgit v1.2.3