[Openmcl-devel] Why is my pointer not a pointer?

Gary Byers gb at clozure.com
Thu Jul 17 05:18:42 UTC 2008


The function GUI::WINDOWS returns a list of open windows (ordered in some 
way,
but if there's just a single listener, the order doesn't matter.)  So:

? (car (gui::windows))
#<HEMLOCK-LISTENER-FRAME <HemlockListenerFrame: 0x1345b950> (#x1345B950)>
? (typep * 'macptr)
T
? (type-of **)
GUI::HEMLOCK-LISTENER-FRAME
? (typep (car (gui::windows)) 'ns:ns-window)
T
? (pprint (class-precedence-list (class-of (car (gui::windows)))))

(#<OBJC:OBJC-CLASS GUI::HEMLOCK-LISTENER-FRAME (#x1367D0)>
 #<OBJC:OBJC-CLASS GUI::HEMLOCK-FRAME (#x135F80)>
 #<OBJC:OBJC-CLASS NS:NS-WINDOW (#x7FFF70528200)>
 #<OBJC:OBJC-CLASS NS:NS-RESPONDER (#x7FFF704D85A0)>
 #<OBJC:OBJC-CLASS NS:NS-OBJECT (#x7FFF703701C0)>
 #<STANDARD-CLASS OBJC:OBJC-OBJECT>
 #<STANDARD-CLASS FOREIGN-STANDARD-OBJECT>
 #<STANDARD-CLASS STANDARD-OBJECT>
 #<BUILT-IN-CLASS MACPTR>    ; <<<<
 #<BUILT-IN-CLASS T>)
?

All ObjC objects are MACPTRs.  Some MACPTRs are ObjC objects.

With a lot of stuff like this, I'm under the impression that
it's documented ("haven't I already written about this at
great length?"), but I don't think that anything that anyone's
written about exactly how the bridge tries to integrate ObjC
into CLOS is part of the documentation.  It should be,
and it shouldn't be surprising that something could be both
"an instance of a class for which certain ObjC and CLOS
methods are applicable" and "a pointer to foreign memory."


--On July 16, 2008 12:13:54 PM -0700 Ron Garret <ron at awun.net> wrote:

> I'm trying to capture still images from an iSight camera (without using
> Quartz).  My current approach is:
>
>
> 1.  Set up a QTCaptureView and connect it to a QTCaptureSession which is
> in turn connected to the camera.
>
>
> 2.  Install a delegate in the QTCaptureView to intercept the images and
> make copies of them when needed.
>
>
> (Just grabbing the images directly from the QTCaptureView turns out not
> to work.)
>
>
> The type signature for the relevant delegate method is:
>
>
> - (CIImage *)view:(QTCaptureView *)view willDisplayImage :(CIImage *)image
>
>
> This method is generally used for applying filters to the image.  I'm
> just passing the image straight through and grabbing a handle to it (or
> trying to):
>
>
>
> (defclass qtc-window-delegate (ns:ns-object)
>   ((container :initarg :container))
>   (:metaclass ns:+ns-object))
>
>
> (objc:defmethod (#/view:willDisplayImage: (:* (:struct #>CIImage)))
>                 ((self qtc-window-delegate)
>                  (viewptr (:* (:struct #>QTCaptureView)))
>                  (imgptr (:* (:struct #>CIImage))))
>   (setf *imgptr-type* (type-of imgptr))  ; For debugging
>   imgptr)
>
>
> This actually works (insofar as the video stream is displayed and Lisp
> doesn't crash) but there is a weird thing going on: I would expect
> *imgptr-type* to be MACPTR given the way the method signature is
> declared, but it's not, it's CIImage:
>
>
>
> ? *imgptr-type*
> NS:C-I-IMAGE
>
>
> Why?
>
>
> rg
>







More information about the Openmcl-devel mailing list