summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-06-09 20:56:34 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-06-09 20:56:34 -0700
commit947047e06b24d025749c136e04f8a49d940e2e36 (patch)
treeca18da908fc3e35cc9c7e900ac4a5964113eb103
parent3420284a02f816d3e5208ea1489c7b6afed6539a (diff)
downloadtxr-947047e06b24d025749c136e04f8a49d940e2e36.tar.gz
txr-947047e06b24d025749c136e04f8a49d940e2e36.tar.bz2
txr-947047e06b24d025749c136e04f8a49d940e2e36.zip
ffi: support ref, refset and indexing on carray.
* lib.c (generic_funcall): Handle carray object via the same cas that handles vectors, lists and strings. That in turn works via ref and other lower-level functions (not all of which support carray yet). (ref): Handle carray object via carray_ref. (refset): Handle carray_object via carray_refset.
-rw-r--r--lib.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index d43107a1..525a7824 100644
--- a/lib.c
+++ b/lib.c
@@ -5866,6 +5866,7 @@ val generic_funcall(val fun, struct args *args_in)
case STR:
case LIT:
case LSTR:
+ carray:
bug_unless (args->argc >= ARGS_MIN);
args_normalize(args, 3);
@@ -5928,6 +5929,10 @@ val generic_funcall(val fun, struct args *args_in)
default:
callerror(fun, lit("too many arguments"));
}
+#if HAVE_LIBFFI
+ } else if (fun->co.cls == carray_s) {
+ goto carray;
+#endif
} else if (structp(fun)) {
fun = method(fun, lambda_s);
break;
@@ -9197,6 +9202,10 @@ val ref(val seq, val ind)
case COBJ:
if (seq->co.cls == hash_s)
return gethash(seq, ind);
+#if HAVE_LIBFFI
+ if (seq->co.cls == carray_s)
+ return carray_ref(seq, ind);
+#endif
/* fallthrough */
case CONS:
case LCONS:
@@ -9228,6 +9237,10 @@ val refset(val seq, val ind, val newval)
case COBJ:
if (seq->co.cls == hash_s)
return sethash(seq, ind, newval);
+#if HAVE_LIBFFI
+ if (seq->co.cls == carray_s)
+ return carray_refset(seq, ind, newval);
+#endif
default:
type_mismatch(lit("ref: ~s is not a sequence"), seq, nao);
}