[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Q: Understanding rlet and print-record (retry)



On Fri, 1 Jul, Rob Browning reposts a query about rlet and print-record

> The following two pieces of code have me confused.   They are both
> basically trying to do the same thing, but with slightly different calls.
> In both cases, even though xxx and p are eql (which I thought meant that
> they pointed to the same record), print-record produces different
> descriptions for each one.  Form the looks of things, xxx's output is
> correct, and p's is bogus.  Can someone explain to me why this is so?  Am I
> using the low level functions correctly?

I've run your example and detected no difference. The records are equal.
I've eliminated the second call to (make-instance 'window) and added
debugging information, and reformatted the print-record output

(setf www (make-instance 'window))
(with-port (wptr www)
  (rlet ((p :GrafPtr))
    (#_GetPort p)
    (let ((xxx (%get-ptr p 0)))
      (print-db (wptr www) xxx (eql xxx (wptr www)))
      (print-record (wptr www) :GrafPort) (terpri)
      (print-record (pref xxx :GrafPort) :GrafPort)
      (terpri)))
  (values))
;;; (wptr www) and xxx are equal!
(WPTR WWW) #<A Mac Zone Pointer Size 156 #x47B614>
XXX #<A Mac Zone Pointer Size 156 #x47B614>
(EQL XXX (WPTR WWW)) T
#<Record 
 
:GRAFPORT  
:DEVICE 0  
:PORTBITS #<Record  
:BITMAP  
:BASEADDR #<A Mac Non-zone Pointer #xF9900020>  
:ROWBYTES 80  
:BOUNDS #<Record  
:RECT  
:TOP -44  
:LEFT -6  
:BOTTOM 436  
:RIGHT 634>>  
:PORTRECT #<Record  
:RECT  
:TOP 0  
:LEFT 0  
:BOTTOM 150  
:RIGHT 502>  
:VISRGN #<A Mac Handle, Unlocked, Size 36 #x47A80C>  
:CLIPRGN #<A Mac Handle, Unlocked, Size 10 #x47A808>  
:BKPAT #<Record  
:PATTERN  
:ARRAY #<A Mac Non-zone Pointer #x47B634>>  
:FILLPAT #<Record  
:PATTERN  
:ARRAY #<A Mac Non-zone Pointer #x47B63C>>  
:PNLOC #@(0 0)  
:PNSIZE #@(1 1)  
:PNMODE 8  
:PNPAT #<Record  
:PATTERN  
:ARRAY #<A Mac Non-zone Pointer #x47B64E>>  
:PNVIS 0  
:TXFONT 4  
:TXFACE 0  
:TXMODE 1  
:TXSIZE 9  
:SPEXTRA 0  
:FGCOLOR 33  
:BKCOLOR 30  
:COLRBIT 0  
:PATSTRETCH 0  
:PICSAVE #<A Null Mac Pointer>  
:RGNSAVE #<A Null Mac Pointer>  
:POLYSAVE #<A Null Mac Pointer>  
:GRAFPROCS #<A Null Mac Pointer>>
#<Record  
:GRAFPORT  
:DEVICE 0  
:PORTBITS #<Record  
:BITMAP  
:BASEADDR #<A Mac Non-zone Pointer #xF9900020>  
:ROWBYTES 80  
:BOUNDS #<Record  
:RECT  
:TOP -44  
:LEFT -6  
:BOTTOM 436  
:RIGHT 634>>  
:PORTRECT #<Record  
:RECT  
:TOP 0  
:LEFT 0  
:BOTTOM 150  
:RIGHT 502>  
:VISRGN #<A Mac Handle, Unlocked, Size 36 #x47A80C>  
:CLIPRGN #<A Mac Handle, Unlocked, Size 10 #x47A808>  
:BKPAT #<Record  
:PATTERN  
:ARRAY #<A Mac Non-zone Pointer #x47B634>>  
:FILLPAT #<Record  
:PATTERN  
:ARRAY #<A Mac Non-zone Pointer #x47B63C>>  
:PNLOC #@(0 0)  
:PNSIZE #@(1 1)  
:PNMODE 8  
:PNPAT #<Record  
:PATTERN  
:ARRAY #<A Mac Non-zone Pointer #x47B64E>>  
:PNVIS 0  
:TXFONT 4  
:TXFACE 0  
:TXMODE 1  
:TXSIZE 9  
:SPEXTRA 0  
:FGCOLOR 33  
:BKCOLOR 30  
:COLRBIT 0  
:PATSTRETCH 0  
:PICSAVE #<A Null Mac Pointer>  
:RGNSAVE #<A Null Mac Pointer>  
:POLYSAVE #<A Null Mac Pointer>  
:GRAFPROCS #<A Null Mac Pointer>>

;; --> Rob's example contained another call to (setf www (make-instance 
'window))
;; this has been eliminated
(with-port (wptr www)
  (rlet ((p :GrafPtr))
    (#_GetPort p)
    (let ((xxx (pref p :ptr)))
      (print-db (wptr www) xxx (eql xxx (wptr www)))
      (print-record (wptr www) :GrafPort) (terpri)
      (print-record (pref xxx :GrafPort) :GrafPort)
      (terpri)))
  (values))

;; this code produces the same results as previously


As for your second query, about the update region, I'm sure someone else
can answer it.


mark