anchor.diff:        (defmethod get-typed-to-foreign ((type-name (eql ',name)))
           #',to))))
   
  -(defun+ format-slot-for-cstruct (slot)
  +(defun+ format-slot-for-cstruct (slot layout)
     (if (s-arrayp slot)
  -      (format-array-slot-for-cstruct slot)
  -      (list (s-name slot) (s-type slot))))
  -
  -(defun+ format-array-slot-for-cstruct (slot)
  +      (format-array-slot-for-cstruct slot layout)
  +      `(,(s-name slot)
  +         ,(s-type slot)
  +         ,@(when layout `(:offset ,(layout-base-offset layout))))))
  +
  +(defun+ format-array-slot-for-cstruct (slot layout)
     (when (> (length (s-dimensions slot)) 1)
       (error "Cannot currently support multi dimensional arrays"))
  -  (list (s-name slot)
  -        `(:array ,(s-element-type slot) ,(reduce #'* (s-dimensions slot)))))
  +  ;; As we cant encode stride in defcstruct we instead make a byte array of
  +  ;; the correct size and rely on c-array to handle the stride correctly.
  +  (if layout
  +      `(,(s-name slot)
  +         (:array :uint8 ,(layout-machine-unit-size layout))
  +         :offset ,(layout-base-offset layout))
  +      `(,(s-name slot)
  +         (:array ,(s-element-type slot) ,(reduce #'* (s-dimensions slot))))))
   
   ;;{TODO} should be setting fields here
  -(defun+ make-make-struct (constructor-name awrap-type-name slots)
  +(defun+ make-make-struct (constructor-name
  +                          wrapper-constructor-name
  +                          awrap-type-name
  +                          slots)
     (let ((vars (loop :for s :in slots :collect (s-name s))))
       `(defun+ ,constructor-name ,(cons '&key vars)
  -       (let ((result (foreign-alloc ',awrap-type-name)))
  +       (let ((result (,wrapper-constructor-name
  +                      (foreign-alloc ',awrap-type-name))))
            ,@(loop :for s :in slots :for v :in vars :collect
                 `(when ,v (setf (,(s-writer s) result) ,v)))
            result))))
   
   ;;------------------------------------------------------------
   
  -(defun+ make-slot-getter (get-ptr slot type-name foreign-struct-name)
  +(defun+ make-slot-getter (get-ptr slot type-name foreign-struct-name layout)
     (when (s-reader slot)
       (cond
         ((not (s-arrayp slot)) (make-t-slot-getter
                                 get-ptr slot type-name foreign-struct-name))
         ((s-arrayp slot) (make-array-slot-getter
  -                        get-ptr slot type-name foreign-struct-name))
  +                        get-ptr slot type-name foreign-struct-name layout))
         (t (error "Dont know what to do with slot ~a" slot)))))
   
   (defun+ make-t-slot-getter (get-ptr slot type-name foreign-struct-name)
  
positive.code:      (uses-method-p :initarg :uses-method-p :reader s-uses-method-p))))
  
  (defmethod v-type-of ((gss gl-struct-slot))
    (type-spec->type (s-type gss)))
  
  (defmethod s-arrayp ((object gl-struct-slot))
    (eq (s-type object) :array))
  
negative.code:                          ',foreign-struct-name
                           ',(s-name slot))))
  
  (defun+ make-array-slot-getter (get-ptr slot type-name foreign-struct-name
                                          layout)
    `(,(s-def slot) ,(s-reader slot)
       ,(s-slot-args slot `((wrapped-object ,type-name)))
       (cepl.c-arrays::make-c-array-from-pointer
        ',(s-dimensions slot) ',(s-element-type slot)
        (foreign-slot-pointer (,get-ptr wrapped-object)
                              ',foreign-struct-name
                              ',(s-name slot))
        ,@(when layout `(:element-byte-size
                         ,(layout-machine-unit-size
                           (layout-element-layout layout)))))))
  
  (defun+ make-slot-setter (get-ptr slot type-name foreign-struct-name layout)
    (when (s-writer slot)
      (cond
        ((or (member (s-type slot) cffi:*built-in-foreign-types*)
             (assoc (s-type slot) cffi::*extra-primitive-types*))
         (make-eprim-slot-setter get-ptr slot type-name foreign-struct-name layout))
        ((not (s-arrayp slot))
         (make-t-slot-setter slot type-name layout))
        ((s-arrayp slot)
         (make-array-slot-setter slot type-name layout))
        (t (error "Dont know what to do with slot ~a" slot)))))
  
  (defun+ make-eprim-slot-setter (get-ptr
                                  slot
                                  type-name
                                  foreign-struct-name
                                  layout)
    (declare (ignore layout))
    `(,(s-def slot) (setf ,(s-writer slot))
       ,(s-slot-args slot `(value (wrapped-object ,type-name)))
       (setf (mem-ref (foreign-slot-pointer (,get-ptr wrapped-object)
  