From f43fda4e635370689fc248bb7e94e5861151df2c Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 9 Jul 2021 08:21:15 -0700 Subject: defstruct: diagnose built-in type being redefined. * eval.c (eval_init): Register built-in-type-p intrinsic. * lib.c (buitin_type_p): Rename to built_in_type_p since the word built-in is hyphenated. The function also tests whether the argument is a COBJ class. (cobj_class_exists): Function removed. * stdlib/doc-syms.tl: Updated. * stdlib/struct.tl (defstruct): Add built-in-type-p check. * struct.c (make_struct_type): Call only built_in_type_p; cobj_class_exists is gone. * txr.1: Document built-in-type-p. --- lib.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'lib.c') diff --git a/lib.c b/lib.c index 06f2ba71..b0f0a64f 100644 --- a/lib.c +++ b/lib.c @@ -209,7 +209,7 @@ static val code2type(int code) return nil; } -val builtin_type_p(val sym) +val built_in_type_p(val sym) { type_t i; @@ -219,6 +219,9 @@ val builtin_type_p(val sym) return t; } + if (gethash(cobj_hash, sym)) + return t; + return nil; } @@ -9206,11 +9209,6 @@ static void cobj_populate_hash(void) sethash(cobj_hash, ptr->cls_sym, num_fast(ptr - cobj_class)); } -int cobj_class_exists(val cls_sym) -{ - return gethash(cobj_hash, cls_sym) != nil; -} - val cobj(mem_t *handle, struct cobj_class *cls, struct cobj_ops *ops) { if (cls != 0) { -- cgit v1.2.3