diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-06-15 22:29:09 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-06-15 22:29:09 -0700 |
commit | 74c61cc4ee63bbca2cf202eba531c1d388829e5b (patch) | |
tree | c6c8390ab876c6a224b8dc2a63b4b9e122ec4318 /ffi.c | |
parent | e227120527ab35fa9a8c5356296bb799f62d0c86 (diff) | |
download | txr-74c61cc4ee63bbca2cf202eba531c1d388829e5b.tar.gz txr-74c61cc4ee63bbca2cf202eba531c1d388829e5b.tar.bz2 txr-74c61cc4ee63bbca2cf202eba531c1d388829e5b.zip |
ffi: copy-carray, hooked into copy.
* ffi.c (copy_carray): New function
(ffi_init): Register copy-carray intrinsic.
* ffi.h (copy_carray): Declared.
* lib.c (copy): Call copy_array for carray objects.
* txr.1: Documented copy-carray and updated
copy description.
Diffstat (limited to 'ffi.c')
-rw-r--r-- | ffi.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -4407,6 +4407,14 @@ val length_carray(val carray) return if3(scry->nelem < 0, nil, num(scry->nelem)); } +val copy_carray(val carray) +{ + struct carray *scry = carray_struct_checked(carray); + val copy = make_carray(scry->eltype, scry->data, scry->nelem, nil); + carray_dup(copy); + return copy; +} + mem_t *carray_ptr(val carray, val type, val self) { struct carray *scry = carray_struct_checked(carray); @@ -5014,6 +5022,7 @@ void ffi_init(void) reg_fun(intern(lit("carray-free"), user_package), func_n1(carray_free)); reg_fun(intern(lit("carray-type"), user_package), func_n1(carray_type)); reg_fun(intern(lit("length-carray"), user_package), func_n1(length_carray)); + reg_fun(intern(lit("copy-carray"), user_package), func_n1(copy_carray)); reg_fun(intern(lit("carray-vec"), user_package), func_n3o(carray_vec, 2)); reg_fun(intern(lit("carray-list"), user_package), func_n3o(carray_list, 2)); reg_fun(intern(lit("carray-blank"), user_package), func_n2(carray_blank)); |