chickadee » jiffi » define-array-copy!

(define-array-copy! COPY! ...)syntax

Defines a destructive array copier, and generates a type declaration for the procedure.


(define-array-copy! COPY!

COPY! is the procedure name to define.

ARMOR-NAME is the record type name for the array, such as the record name passed to define-armor-type.

"STRUCT_NAME" is a string containing the name of the C struct/union, exactly as it appears in C.

PRED is an existing type predicate for the array record type, such as a procedure defined with define-armor-type.

UNWRAP is an existing armor unwrapper procedure, such as a procedure defined with define-armor-type.

LENGTH is an existing procedure that returns the array length, such as an extra slot getter defined with define-armor-type.


(define-array-copy! event-array-copy!
  (event-array "FOO_Event" event-array?
               unwrap-event-array event-array-length))

;; Define a non-destructive version which creates a new array.
(define (event-array-copy from #!optional
                          (start 0)
                          (end (event-array-length from)))
  (let ((new-array (make-event-array (- end start))))
    (event-array-copy! new-array 0 from start end)