[Openmcl-devel] How to access Objective-C propperties

Alexander Repenning ralex at cs.colorado.edu
Tue Dec 28 22:11:00 UTC 2010


objc:objc-message-send-stret does the trick!  Thanks

alex


On Dec 28, 2010, at 1:40 PM, R. Matthew Emerson wrote:

> 
> On Dec 28, 2010, at 2:55 PM, Alexander Repenning wrote:
> 
>> I am having a problem with accessing certain (10.6 and later) objective-C properties which I try to access via objc:objc-message-send
>> 
>> something like this works: (objc:objc-message-send some-event "magnification" #>CGFloat)
>> 
>> 
>> 
>> but when I specify an NSPoint return type things fall apart:
>> 
>> (objc:objc-message-send touch-return "normalizedPosition" #>NSPoint)
>> 
>> 
>> Error: (TOUCH-RETURN :<SEL> (OBJC:@SELECTOR "normalizedPosition")) should be an even-length list of alternating foreign types and values
>>> While executing: X8664::EXPAND-FF-CALL, in process Listener(6).
>> 
>> 
>> I have tried to replace  #>NSPoint with :id which does return something that Lisp does not like:
>> 
>> Error: Invalid memory operation.
>>> While executing: CCL::%SAFE-GET-PTR, in process Listener(6).
> 
> 
> Objective-C methods that return structs have to be called differently from methods that return scalars.  The details of why this is so are complicated and probably not that interesting.
> 
> Something like this (warning, typed in mail) is probably what you want.
> 
> (rlet ((pt #>NSPoint))
>  (objc:objc-message-send-stret pt touch-return "normalizedPosition" #>NSPoint))
> 
> Note that you pass an additional first argument, which is a pointer to some memory into which the returned struct will be stored.
> 
> 

Prof. Alexander Repenning

University of Colorado
Computer Science Department
Boulder, CO 80309-430

vCard: http://www.cs.colorado.edu/~ralex/AlexanderRepenning.vcf


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clozure.com/pipermail/openmcl-devel/attachments/20101228/bb199e52/attachment.html>


More information about the Openmcl-devel mailing list