[Openmcl-devel] record field initializer shorthand dot notation

John Wiseman jjwiseman at yahoo.com
Sun Dec 1 00:11:30 PST 2002


I missed the ability from MCL to initialize foreign records using the
shorthand dot notation, like this:

   (rlet ((r :<NSR>ect
	    :origin.x 0.0
	    :origin.y 0.0
	    :size.width 400.0
	    :size.height 400.0))
     ...)


The following slightly modified definition of
%foreign-record-field-forms seems to do the trick.

   (defun %foreign-record-field-forms (ptr record-type record-name inits)
     (unless (evenp (length inits))
       (error "Unexpected or malformed initialization forms: ~s in field type: ~s"
                        inits record-name))
     (let* ((result ()))
       (do* ()
            ((null inits) (nreverse result))
         (let* ((accessor (decompose-record-accessor (pop inits)))
                (valform (pop inits)))
           (push `(setf ,(%foreign-access-form ptr record-type 0 accessor) ,valform)
                 result)))))


John Wiseman


_______________________________________________
Openmcl-devel mailing list
Openmcl-devel at clozure.com
http://clozure.com/cgi-bin/mailman/listinfo/openmcl-devel



More information about the Openmcl-devel mailing list