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:                      ((string= layout :std140)
                        (calc-struct-layout-from-name-type-pairs
                         name (mapcar (lambda (x)
                                        (list (s-name x) (v-type-of x)))
                                      slots)))
                       ((string= layout :std430)
                        (error 'std430-not-yet-implemented))))
             (slot-layouts (if layout
                             (layout-members layout)
                             (n-of nil (length slots))))
             (wrapper-constructor-name (hidden-symb name :make)))
        (assert (= (length slot-layouts) (length slots)))
        (when (validate-defstruct-g-form name slots)
          `(progn
             (eval-when (:compile-toplevel :load-toplevel :execute)
               ,(make-varjo-struct-def name slots))
             ,@(make-instance-wrapper-def name
                                          foreign-struct-name
                                          wrapper-constructor-name
                                          get-ptr-name
                                          slots typed-populate slot-layouts)
             ,@(when (and readers accesors)
                 (remove nil (mapcar (lambda (slot slot-layout)
                                       (make-slot-getter get-ptr-name slot name
                                                         qualified-struct-name
                                                         slot-layout))
                                     slots
                                     slot-layouts)))
             ,@(when (and writers accesors)
                 (remove nil (mapcar (lambda (slot slot-layout)
                                       (make-slot-setter get-ptr-name slot name
                                                         qualified-struct-name
                                                         slot-layout))
                                     slots
                                     slot-layouts)))
             ,(when constructor (make-make-struct constructor
                                                  wrapper-constructor-name
                                                  name
                                                  slots))
             ,(when attribs (make-struct-attrib-assigner name slots))
             ,@(when populate (make-populate name typed-populate slots))
             ,(make-struct-pixel-format name slots)
  