diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-08-08 12:27:11 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-08-08 12:27:11 -0700 |
commit | 46bc67ee1b42f8f7587e87b0ba604e0541bd24f1 (patch) | |
tree | d49347325e08425e4f3cf46670c6f00bc0556184 /ffi.c | |
parent | 391abdde2d48aac8fc18978a1f3a26b9f0ae6bc8 (diff) | |
download | txr-46bc67ee1b42f8f7587e87b0ba604e0541bd24f1.tar.gz txr-46bc67ee1b42f8f7587e87b0ba604e0541bd24f1.tar.bz2 txr-46bc67ee1b42f8f7587e87b0ba604e0541bd24f1.zip |
ffi: new buf-carray function.
* ffi.c (buf_carray): New function.
(ffi_init): Registered buf-carray intrinsic.
* ffi.c (buf_carray): Declared.
* txr.1: Documented.
Diffstat (limited to 'ffi.c')
-rw-r--r-- | ffi.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -4838,6 +4838,14 @@ val carray_buf_sync(val carray) return buf; } +val buf_carray(val carray) +{ + struct carray *scry = carray_struct_checked(carray); + struct txr_ffi_type *etft = scry->eltft; + cnum bytes = scry->nelem * etft->size; + return make_duplicate_buf(num(bytes), scry->data); +} + val carray_cptr(val cptr, val type, val len) { mem_t *data = cptr_get(cptr); @@ -5580,6 +5588,7 @@ void ffi_init(void) reg_fun(intern(lit("carray-blank"), user_package), func_n2(carray_blank)); reg_fun(intern(lit("carray-buf"), user_package), func_n3o(carray_buf, 2)); reg_fun(intern(lit("carray-buf-sync"), user_package), func_n1(carray_buf_sync)); + reg_fun(intern(lit("buf-carray"), user_package), func_n1(buf_carray)); reg_fun(intern(lit("carray-cptr"), user_package), func_n3o(carray_cptr, 2)); reg_fun(intern(lit("vec-carray"), user_package), func_n2o(vec_carray, 1)); reg_fun(intern(lit("list-carray"), user_package), func_n2o(list_carray, 1)); |