[Openmcl-devel] Errors Creating NSTimer
Andrew Shalit
alms at clozure.com
Wed Oct 24 04:19:52 PDT 2007
We pushed a demonstration Clozure CL image out because of the
immediate concerns of MCL users. We'd rather get it packaged up a
little more nicely (so, for example, you can rebuild it yourself
without hirsute instructions) before putting it out for general use.
But that'll be soon.
On Oct 24, 2007, at 1:34 AM, Brent Fulgham wrote:
> Doh! Of course...
>
> I guess I'm still reeling from the recent Clozure Common Lisp
> announcement! Why wasn't that shown on this list (did I miss it?)
>
> -Brent
>
> On Oct 23, 2007, at 10:20 PM, Gary Byers wrote:
>
>> The first argument to any ObjC method should be the "receiver" (the
>> object - instance (usually) or class (sometimes) - that might
>> implement
>> a method on the message. If this were CLOS, we might call the
>> receiver
>> the first and only specialized parameter.)
>>
>> In the case of
>> #/scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:,
>> the receiver is the class "NSTimer" (which happens to be the value
>> of the variable NS:NS-TIMER.) The bridge is complaining because
>> the first argument in your calls below either isn't a pointer at
>> all or isn't a pointer to an ObjC class or instance; getting a lisp-
>> level
>> error like that is probably better than trying to send a message to
>> 0.01d0 ...
>>
>>
>> On Tue, 23 Oct 2007, Brent Fulgham wrote:
>>
>>> I'm trying to get the right Cocoa bridge syntax for calling:
>>>
>>> scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:
>>> Returns a new NSTimer object and adds it to the current NSRunLoop
>>> object in the default mode.
>>>
>>> + (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds
>>> target:(id)target selector:(SEL)aSelectoruserInfo:(id)userInfo
>>> repeats:(BOOL)repeats
>>>
>>> NSTimeInterval is just a typedef to double, so I thought that I
>>> could just pass the double value to the function, since this is how
>>> many of the example Objective C programs are written, but this does
>>> not work for a variety of reasons:
>>>
>>> 1. If I attempt to simply use a bare double, it's not happy:
>>>
>>> (let* ((TimerInterval (ccl::%double-float 0.01)))
>>> (Timer (#/
>>> scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:
>>> TimeInterval (cocoa-view self) (objc:@selector #/animate) (ccl::
>>> %null-ptr) #$YES)))
>>>
>>>> Error: value 0.009999999776482582D0 is not of the expected type
>>>> MACPTR.
>>>> While executing: CCL::SEND-UNAMBIGUOUS-MESSAGE, in process
>>>> listener(1).
>>>
>>> 2. If I attempt to use an RLET to allocate the C Type, it's still
>>> not happy:
>>>
>>> (rlet ((TimeInterval :<NST>ime<I>nterval (ccl::%double-float 0.01)))
>>> (let* (
>>> (Timer (#/
>>> scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:
>>> TimeInterval (cocoa-view self) (objc:@selector #/animate) (ccl::
>>> %null-ptr) #$YES))))
>>> ;; add myself to list
>>> (pushnew Self (animated-views Self))))
>>>
>>>> Error: value #<A Foreign Pointer [stack-allocated] (:* DOUBLE-
>>>> FLOAT) #xB029BE70> is not of the expected type OBJC:OBJC-OBJECT.
>>>> While executing: CCL::SEND-UNAMBIGUOUS-MESSAGE, in process
>>>> listener(1).
>>>
>>> I vaguely remember a mechanism to convert native C types to Cocoa
>>> analogs, but I cannot find documentation of this, and may be mixing
>>> Objective C up with something up.
>>>
>>> What's the correct way to deal with this particular API call?
>>>
>>> Thanks,
>>>
>>> -Brent
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
More information about the Openmcl-devel
mailing list