summaryrefslogtreecommitdiffstats
path: root/buf.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-04-26 05:57:37 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-04-26 05:57:37 -0700
commitbe83bc717db0375e19431fe38c0490ff1a9e40ec (patch)
tree354d2107e8a5d4b518b5081a036894b87fc82c68 /buf.h
parentd081a595dfa053c78f7e3f580f82ca7823f02f74 (diff)
downloadtxr-be83bc717db0375e19431fe38c0490ff1a9e40ec.tar.gz
txr-be83bc717db0375e19431fe38c0490ff1a9e40ec.tar.bz2
txr-be83bc717db0375e19431fe38c0490ff1a9e40ec.zip
ffi: support buf objects.
* buf.c (make_duplicate_buf, buf_get, buf_fill): New functions. * buf.h (make_duplicate_buf, buf_get, buf_fill): Declared. * ffi.c (struct txr_ffi_type): New member, nelem. Keeps track of number of elements, for types that are FFI pointers. This lets us support the get method so that a buf can be a C function return value, if its size is declared in our FFI type system. (ffi_buf_put, ffi_buf_get, ffi_buf_fill): New functions. (ffi_type_compile): Handle two new cases of syntax for buffers: (buf <size>) and buf.
Diffstat (limited to 'buf.h')
-rw-r--r--buf.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/buf.h b/buf.h
index 56a04c7e..8102fff8 100644
--- a/buf.h
+++ b/buf.h
@@ -27,9 +27,12 @@
val make_buf(val len, val init_val, val alloc_size);
val make_borrowed_buf(val len, mem_t *data);
+val make_duplicate_buf(val len, mem_t *data);
val buf_trim(val buf);
val buf_set_length(val obj, val len, val init_val);
val length_buf(val buf);
+mem_t *buf_get(val buf, val self);
+void buf_fill(val buf, mem_t *src, val self);
#if HAVE_I8
val buf_put_i8(val buf, val pos, val num);