[Openmcl-devel] OS X 10.6 Gestures in CCL 1.6: how to define missing objc method interfaces?

Gary Byers gb at clozure.com
Sat Dec 4 01:47:42 PST 2010


The easiest way to invoke an ObjC method that's not defined in the
interfaces is to use OBJC:OBJC-MESSAGE-SEND, which isn't documented
but probably should be.  (Among other things, the documentation should
stress that using it's a little more error-prone than #/, and that it
shouldn't be used casually.)

(OBJC:OBJC-MESSAGE-SEND receiver message-name {arg-type arg-value}* [result-type])

where :
   receiver = the ObjC object which responds to the message
   message-name = the message name as a Lisp string constant
   arg-type, arg-value, result-type = as per FF-CALL.

The magnification method on NSEvent takes no other arguments besides
the receiver and returns a CGFloat, so one could call it via:

(objc:objc-message-send some-event "magnification" #>CGFloat)

That's probably adequate if you only have to do it occasionally and if the
method in question returns a scalar value.  If the method returns a structure, 
... well, let's ignore that case because it's complicated and ugly.

If you really want to be able to use #/ and/or want to use a (much) larger
subset of Snow Leopard, there's no simple way to do that manually, but it's
not too hard to generate Snow Leopard interfaces.  The Wiki page at

<http://trac.clozure.com/ccl/wiki/BuildFFIGEN>

describes how to build and install the translator, and the manual describes
how to use it.

You'd want to follow the instructions for builing the Leopard FFI translator.
That can handle most of the constructs used in the Snow Leopard headers; one
notable exception is the new "block" data type.  I think that I have a version
(based on a newer version of Apple's GCC) that handles that somewhere, and
IIRC it seemed to even work ...




On Fri, 3 Dec 2010, Alexander Repenning wrote:

> In ccl 1.6 I can setup very easily event handlers to get all the 10.6 track pad / touch screen gestures:
>
>
> (objc:defmethod (#/beginGestureWithEvent: :void) ((self native-window-view) Event)
> (print Event))
>
>
> (objc:defmethod (#/magnifyWithEvent: :void) ((self native-window-view) Event)
> (print Event))
>
>
> (objc:defmethod (#/rotateWithEvent: :void) ((self native-window-view) Event)
> (print Event))
>
>
> (objc:defmethod (#/endGestureWithEvent: :void) ((self native-window-view) Event)
> (print Event))
>
>
> e.g., I get
>
> #<NS-EVENT NSEvent: type=BeginGesture loc=(558,493) time=223033.4 flags=0x100 win=0x24d5c2e0 winNum=4575 ctxt=0x0 (#x26C9C1D0)>
> #<NS-EVENT NSEvent: type=Rotate loc=(558,493) time=223033.6 flags=0x100 win=0x24d5c2e0 winNum=4575 ctxt=0x0 rotation=0.122397 (#x26707BA0)>
> ... many more
> ... and finally
> #<NS-EVENT NSEvent: type=EndGesture loc=(558,493) time=223035.6 flags=0x100 win=0x24d5c2e0 winNum=4575 ctxt=0x0 (#x26CA2240)>
>
> Nice, but CCL 1.6 does not include the OS 10.6 framework interface for methods to access the new information contained in these gesture events.
>
> Trying to call (#/magnification Event) will result in an error:  > Undefined function NEXTSTEP-FUNCTIONS:|magnification|
>
> How does one manually define #/<name> callable method interfaces (missing in the 10.5 headers), NOT #_<name> callable functions manually? More specifically, how do I need to define the objc "magnification"method interface? This must be somewhere in the doc but I cannot find it.
>
> Alex
>
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>



More information about the Openmcl-devel mailing list