From d151853a6be4548c8a4d02b839b7dce689217a7d Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 15 Jul 2017 10:22:53 -0700 Subject: carray: add offset to carray-buf. * ffi.c (struct carray): New member, offs. (make_carray): Initiialize offs member from new argument. (copy_carray, carray_blank, carry_ptr, carray_sub, carray_pun, carray_unum, carray_num): Pass zero offset to (carray_buf): New optional parameter off_in. (carray_buf_sync): Handle offset. (ffi_init): Update registration of carray-buf. * ffi.h (make_carray, carray_buf): Declaration updated. * txr.1: Documented. --- txr.1 | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index d55a2839..8fbe698d 100644 --- a/txr.1 +++ b/txr.1 @@ -57707,7 +57707,7 @@ function, and of .coNP Function @ carray-buf .synb -.mets (carray-buf < buf << type ) +.mets (carray-buf < buf < type <> [ offset ]) .syne .desc The @@ -57718,15 +57718,39 @@ object which refers to the storage provided and managed by the buffer object .metn buf , providing a view of that storage, and manipulation thereof, as an array. +The optional +.meta offset +parameter specifies an offset from the start of the buffer to the +location which is interpreted as the start of the +.codn carray , +which extends from that offset to the end of the buffer. + +The default value is zero: the +.code carray +covers the entire buffer. + +If a value is specified, it must be in the range zero to the length of +.metn buf . + The .meta type argument must be a compiled FFI type whose size is nonzero. -The bytewise length of + +The +.code carray +is overlaid onto the storage of +.meta buf +as follows: + +First, +.meta offs +is subtracted from the bytewise length of .metn buf , as reported by .code length-buf -function , -is divided by the size of +function to produce the effective length of the storage to be used for the array. + +The effective length is divided by the size of .metn type , as reported by .codn ffi-size . -- cgit v1.2.3