From f30990943abba9a73bf0f2396c996c612e7862d3 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 25 Jun 2019 07:16:03 -0700 Subject: list_collect: handle objects. * lib.c (list_collect): Handle sequence-like COBJ objects. We can add an item to using their respective replace functions. (replace_obj): Change to external linkage. * lib.h (replace_obj): Declared. --- lib.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib.c') diff --git a/lib.c b/lib.c index 57cdae51..e133c854 100644 --- a/lib.c +++ b/lib.c @@ -1047,6 +1047,15 @@ loc list_collect(loc ptail, val obj) case LSTR: replace_str(tailobj, items, t, t); return ptail; + case COBJ: + if (tailobj->co.cls == carray_s) { + carray_replace(tailobj, items, t, t); + return ptail; + } + if (obj_struct_p(tailobj)) { + replace_obj(tailobj, items, t, t); + return ptail; + } default: uw_throwf(error_s, lit("cannot append ~s"), deref(ptail), nao); } @@ -7277,7 +7286,7 @@ val replace_vec(val vec_in, val items, val from, val to) return vec_in; } -static val replace_obj(val obj, val items, val from, val to) +val replace_obj(val obj, val items, val from, val to) { val self = lit("replace"); val lambda_set_meth = maybe_slot(obj, lambda_set_s); -- cgit v1.2.3