From 0687743dcfad79dba202b4411a5b51f6954cf3b2 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 11 Jun 2017 11:03:40 -0700 Subject: ffi: support sel operation on carray. Thus (select ca '(0 3 4 ...)) works and so does the sytnax [ca '(0 3 4 ...)]. This is inefficiently implemented. The selected elements are extracted to a list which is then converted to a carray of the same kind agan. * ffi.c (carray_list): New function. (ffi_init): Register carray-list intrinsic. * ffi.h (carray_list): Declared. * lib.c (make_like): Add carray case, so we can turn a list into a carray based on an example carray. This uses carray_list, with the type pulled from the original carray. The target isn't null terminated. (sel): Handle carray via vector case. * txr.1: Document changes in select and make-like. --- lib.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib.c') diff --git a/lib.c b/lib.c index 95016a33..6e14e618 100644 --- a/lib.c +++ b/lib.c @@ -718,6 +718,8 @@ val make_like(val list, val thatobj) if (from_list_meth) return funcall1(from_list_meth, list); } + if (thatobj->co.cls == carray_s) + return carray_list(list, carray_type(thatobj), nil); break; case NIL: case CONS: @@ -9633,6 +9635,8 @@ val sel(val seq_in, val where_in) return newhash; } + if (seq->co.cls == carray_s) + goto carray; /* fallthrough */ case CONS: case LCONS: @@ -9650,6 +9654,7 @@ val sel(val seq_in, val where_in) } } break; + carray: default: { val len = length(seq); -- cgit v1.2.3