From 88a32bd43ad3ff3e03c0faa4dd94991afc1bdeb1 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 20 May 2017 08:49:12 -0700 Subject: ffi: turn carray-ref into accessor. * lisplib.c (ffi_set_entries): Add carray-ref to list of autoload names. * share/txr/stdlib/ffi.tl (carray-ref, carray-refset): Registered function pair as a simple accessor. * txr.1: Updated carray-ref doc. --- lisplib.c | 2 +- share/txr/stdlib/ffi.tl | 2 ++ txr.1 | 9 ++++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lisplib.c b/lisplib.c index 39159edd..acc7b6b6 100644 --- a/lisplib.c +++ b/lisplib.c @@ -524,7 +524,7 @@ static val ffi_set_entries(val dlt, val fun) { val name[] = { lit("with-dyn-lib"), lit("deffi"), lit("deffi-type"), lit("deffi-cb"), - lit("typedef"), lit("sizeof"), lit("ffi"), + lit("typedef"), lit("sizeof"), lit("ffi"), lit("carray-ref"), nil }; set_dlt_entries(dlt, name, fun); diff --git a/share/txr/stdlib/ffi.tl b/share/txr/stdlib/ffi.tl index 902605fa..12f9dab6 100644 --- a/share/txr/stdlib/ffi.tl +++ b/share/txr/stdlib/ffi.tl @@ -101,3 +101,5 @@ (defmacro ffi (type) ^(ffi-type-compile ',type)) + +(define-accessor carray-ref carray-refset) diff --git a/txr.1 b/txr.1 index c5fcee5c..5b3614c9 100644 --- a/txr.1 +++ b/txr.1 @@ -55107,9 +55107,10 @@ operation). This creates a potentially unsafe situation in which the length requires a larger amount of backing storage than is provided by the buffer. -.coNP Function @ carray-ref +.coNP Accessor @ carray-ref .synb .mets (carray-ref < carray << idx ) +.mets (set (carray-ref < carray << idx ) << new-val ) .syne .desc The @@ -55149,6 +55150,12 @@ Then, the get semantics of the element type is invoked to convert, to a Lisp object, a region of data starting at calculated byte offset in the array storage. The resulting object is returned. +Assigning an a value to a +.code caddr-ref +form is equivalent to using +.code caddr-refset +to store the value. + .coNP Function @ carray-refset .synb .mets (carray-refset < carray < idx << new-val ) -- cgit v1.2.3