bug in rlet? (fwd)

Gary Byers <[email protected]> Sun, 22 Sep 2002 22:21:48 -0600 (MDT)
Newsgroups gmane.lisp.openmcl.bugs
Message-ID <[email protected]>
(setf <pointer-to-record-type> <other-pointer-to-record-type>)

has to expand into some sort of record-copying operation.

"Some sort of record-copying operation" - short of #_bcopy or the like -
has to be understood at a fairly low level.

Until those things happen, it'd be nice if (setf (pref ...) ...) told
you that it didn't really know how to do that ...


---------- Forwarded message ----------
Date: Sun, 22 Sep 2002 11:54:51 -0700
From: mikel evins <[email protected]>
To: Gary Byers <[email protected]>
Cc: mikel evins <[email protected]>, Hamilton Link <[email protected]>
Subject: bug in rlet?

Gary,

I'm experimenting with some cocoa drawing code, some of which works,
some of which doesn't. I ran across a macroexpansion of RLET that
doesn't seem to be quite right.

First, a little context:

I'm drawing the contents of an NSView (subclass) in drawRect:. Here's a
trimmed version of the code in the body of that method:

[[(@class "NSColor") "blackColor"] "set"]
[(@class "NSBezierPath") "fillRect:" :<NSR>ect rect]
(rlet ((origin :<NSP>oint :x (* i 10.0) :y (* j 10.0))
			 (size :<NSS>ize :width 10.0 :height 10.0)
			 (newrect :<NSR>ect :origin origin :size size))
			[[(@class "NSColor") "whiteColor"] "set"]
			[(@class "NSBezierPath") "fillRect:" :<NSR>ect newrect])

The first two lines work; the RLET expression does not. The 'rect'
variable in the second line is an <NSR>ect passed in to drawRect: by
the Cocoa framework.

Macroexpanding the RLET yields

(let* ((origin (ccl::%new-ptr 8 nil))
	   (size (ccl::%new-ptr 8 nil))
	   (newrect (ccl::%new-ptr 16 nil)))
   (declare (dynamic-extent newrect size origin))
   (declare (type macptr newrect size origin))
   (declare (ccl::unsettable newrect size origin))
   (setf (%get-single-float origin (/ 0 8)) (* i 10.0))
   (setf (%get-single-float origin (/ 32 8)) (* j 10.0))
   (setf (%get-single-float size (/ 0 8)) 10.0)
   (setf (%get-single-float size (/ 32 8)) 10.0)
   (setf (%inc-ptr newrect (/ 0 8)) origin)
   (setf (%inc-ptr newrect (/ 64 8)) size)
   (ccl::objc-message-send (ccl::objc-message-send (@class "NSColor")
"whiteColor")
						  "set")
   (ccl::objc-message-send (@class "NSBezierPath")
						  "fillRect:"
						  :<NSR>ect newrect))

...which mostly seems reasonable except for

(setf (%inc-ptr newrect (/ 0 8)) origin)
(setf (%inc-ptr newrect (/ 64 8)) size)

...which causes lisp to complain that there is no SETF method for
%inc-ptr (and indeed, given the documented behavior of %inc-ptr it
doesn't seem as though there would be a SETF method for it).

Is this an unanticipated expanssion of RLET?

--me