[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: MCL 2.0b1p3 bitmap problems
- To: Adnan Hamid <ahamid@clarity.Princeton.EDU>
- Subject: Re: MCL 2.0b1p3 bitmap problems
- From: Bill St. Clair <bill>
- Date: Sat, 22 Jun 91 14:03:33 -0400
- Cc: info-mcl@cambridge.apple.com
- In-reply-to: Your message of Thu, 20 Jun 91 17:19:50 -0400. <9106202119.AA02820@clarity.Princeton.EDU>
Date: Thu, 20 Jun 91 17:19:50 EDT
From: Adnan Hamid <ahamid@clarity.Princeton.EDU>
To: info-mcl@cambridge.apple.com
Subject: MCL 2.0b1p3 bitmap problems
A while back a patch was sent out for make-bitmap, with the :storage keys for
rref/rset explicitly defined to be :pointer. However the same problem occurs
in various other situations:
? (setq bm (make-bitmap 0 0 10 10))
#<A Mac Zone Pointer Size 34 #x2C425C>
? (rref bm :bitmap.bounds)
> Error: Illegal attempt to get a pointer to a :RECT within a handle
> While executing: CCL::EXPAND-HANDLE-RECORD-GET
> Type Command-. to abort.
See the RestartsI menu item for further choices.
1 >
and the results returned from (copy-record bm :bitmap) contains garbage values.
Could the problem instead be in interfaces;QUICKDRAW.lisp where
(defrecord (BitMap :handle)
(baseAddr :pointer)
(rowBytes :signed-integer)
(bounds :rect)
)
should be defined as
(defrecord (BitMap :pointer)
(baseAddr :pointer)
(rowBytes :signed-integer)
(bounds :rect)
)
?
As I think I said when I sent out the MAKE-BITMAP patch, the only way
around these problems is to always be explicit about :STORAGE type.
Our Pascal->Lisp translator makes the default :STORAGE type for a
record be :HANDLE if there is a handle type defined that points at it:
BitMapPtr = ^BitMap;
BitMapHandle = ^BitMapPtr;
BitMap = RECORD
baseAddr: Ptr;
rowBytes: INTEGER;
bounds: Rect;
END;
becomes:
BitMapPtr = ^BitMap;
BitMapHandle = ^BitMapPtr;
BitMap = RECORD
baseAddr: Ptr;
rowBytes: INTEGER;
bounds: Rect;
END;
but:
PenState = RECORD
pnLoc: Point;
pnSize: Point;
pnMode: INTEGER;
pnPat: Pattern;
END;
becomes:
(defrecord PenState
(pnLoc :point)
(pnSize :point)
(pnMode :signed-integer)
(pnPat :pattern)
)
The default :STORAGE types are likely to change for at least a few of
the records each time a new set of interface files is released (each
time the OS is updated). Hence, your code (and ours) needs to take
responsibility for ensuring that you get a pointer when you want a
pointer and a handle when you want a handle. The following macros
should help (these will be included in the next round of patches for
2.0b1):
(defmacro href (pointer accessor)
`(rref ,pointer ,accessor :storage :handle))
(defmacro pref (pointer accessor)
`(rref ,pointer ,accessor :storage :pointer))
(defmacro hset (pointer accessor thing)
`(rset ,pointer ,accessor ,thing :storage :handle))
(defmacro pset (pointer accessor thing)
`(rset ,pointer ,accessor ,thing :storage :pointer))
(defmacro make-record-handle (record-type &rest initforms)
`(make-record
,(if (consp record-type)
`(,(car record-type) :storage :handle ,@(cdr record-type))
`(,record-type :storage :handle))
,@initforms))
(defmacro make-record-pointer (record-type &rest initforms)
`(make-record
,(if (consp record-type)
`(,(car record-type) :storage :pointer ,@(cdr record-type))
`(,record-type :storage :handle))
,@initforms))
Incedently, (copy-record) fails to work if the optional record-type argument
is not provided:
[...]
Thank you. Will be fixed.
And for anyone who is doing source patches (from p1&2 etc.), it might be
useful to include in the patch release notes instructions to do
(reindex-interfaces)
after completeing the patches.
Many people have had problems because we forgot to mention this.