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

Two questions



I've been doing some low-level Quickdraw hacking from MACL and am
having problems.  I don't know if these represent a lack of
understanding on my part (probably) or bugs.  Could someone give me a
few hints on the following two unrelated questions?

1.  I define a file of macros, say mac.lisp, which contain (among
other things) the following:
    (in-package :ccl)
    (export '(with-region))
    (defmacro with-region (var &body body)
      `(let ((,var nil))
	 (unwind-protect
	   (progn
	     (setq ,var (#_NewRgn))
	     ,@body)
	   (#_DisposeRgn ,var))))
I then compile this file, saving it as mac.fasl.  I then start a fresh
MCL and load the fasl file.

In another file, say test.lisp, I define a procedure such as
    (defun foo ()
      (with-region foo (print t)))
When I eval this form, however, I get the warnings:
    ;Compiler warnings :
    ;   Undefined function TRAPS::_DISPOSERGN, in FOO.
    ;   Undefined function TRAPS::_NEWRGN, in FOO.
which seem to imply that the appropriate macros are not being found
and expanded.

If instead of loading the .fasl file, I load the .lisp file, all seems
fine.  Seems like an eval-when problem? Right?  But looking at the
expansion of defmacro looks like it's trying to do the right thing.
What am I missing?

2.  I am blowing up my Mac by trying to do the following:  I have some
CLOS objects of class IND that inherits from simple-view and some
other mixins, and I want to define a view-draw-contents method that
caches a somewhat complex pict in the object; the cache is then
cleared by other code when the image needs to change.  In the course
of defining the pict, I need to use a region for clipping.  Question
one is: can I DisposeRgn of this temporary region after it has gotten
used within a start-picture/get-picture context, or does the region
need to be retained as long as the picture it helped define is
retained?  I have perused both MCL documentation and I-M without finding
conclusive evidence.  Question two is: is my way of trying to do this
roughly right, or is there a different method that works better?  What
I am essentially doing is something like
  (with-focused-view i
    (with-region new-clip
      (unwind-protect (progn (open-region i)
			     ... define new-clip region ...
			     )
	(close-region new-clip)
      (with-region old-clip-region
	 (unwind-protect		; to make sure clip region is reset
	     (progn (#_GetClip old-clip-region)
		    (#_SetClip diamond)
		    (start-picture i r)
		    ... draw the picture ...
		    (get-picture i))
	   (#_SetClip old-clip-region))))))
i is one of these IND objects.  If it's roughly right, then why am I
crashing a burning?

Thanks for any help.  --Pete Szolovits