get-primitive-array-region array &key start end buffer buffer-size => target-buffer, foreign-type
A Java array of primitive type.
Bounding index designators for array.
An FLI pointer.
A non-negative integer.
The function get-primitive-array-region
copies from a Java array of primitive type to a buffer specified by a foreign pointer.
The function set-primitive-array-region
copies from a buffer specified by a foreign pointer to a Java array of primitive type.
buffer, if supplied, must be a foreign pointer pointing to a suitable buffer, which means large enough to receive the data in get-primitive-array-region
, or containing the desired data in set-primitive-array-region
.
start and end are bounding index designators for array, specifying the region to copy in number of elements.
buffer-size is used only when buffer is also supplied. buffer-size specifies the number of bytes to copy into buffer. If copying the required number of elements requires more bytes, get-primitive-array-region
signals an error. Note that buffer-size is specified in bytes, while start and end are specified in elements.
If buffer is not supplied to get-primitive-array-region
it creates a buffer of the correct size using fli:allocate-foreign-object
. In this case you will need to free the buffer using fli:free-foreign-object
when the program has finished with it.
get-primitive-array-region
copies the required number of elements into the buffer, and returns two values: the target buffer (either the buffer argument or the new buffer) and the foreign-type corresponding to the Java primitive type (one of jbyte, jshort. jint. jlong, jfloat, jdouble, jboolean and jchar).
set-primitive-array-region
copies the required number of elements from buffer to array, and returns two values: t
and the foreign type.
These functions are useful when you need to pass the data to foreign code. If you need the data in Lisp, use lisp-array-to-primitive-array or primitive-array-to-lisp-array instead.
LispWorks User Guide and Reference Manual - 20 Sep 2017