[Openmcl-devel] Getting a double-float from ObjC

Gary Byers gb at clozure.com
Sat Jun 12 18:45:47 PDT 2004



On Sun, 13 Jun 2004, Sebastian Nozzi wrote:

>
> Hi,
>
> I need to call a method which returns a double-float.
> OpenMCL says I need to call it with send/sret (it assumes that it's a
> structure since the return value is big, more than 4 bytes; I don't know
> if the assumption is correct ...?). So I do that, using rlet and all...

A DOUBLE-FLOAT isn't a structure; you should be able to just use SEND to
call a method that returns a DOUBLE-FLOAT.


>
> (rlet ((the-time :double-float))
> 	(send/stret the-time
> 		(send (@class ns-date) :date-with-time-interval-since-now 10000.0d0)
> 		'time-interval-since-reference-date))
>
> ...but it crashes openMCL. In the docs it says that the body evaluates
> and returns whatever type I specified. How do I get a lisp-usable
> number? What I am doing wrong so it crashes? Is send/stret the way to go
> here? (I think, for example, in the case of a normal C function
> returning a double it would just work out of the box...?)

It's indeed exactly the same as calling a C function that returns a
DOUBLE-FLOAT,

? (send
    (send (@class "NSDate") :date-with-time-interval-since-now 10000.0d0)
    'time-interval-since-reference-date)
1.087937955145176D+8

SEND/STRET only really applies when the method in question is declared
to return a structure (e.g., an :<NSR>ect, an :<NSR>ange, ...)

>
> Thanks in advance,
>
> Sebastian
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>



More information about the Openmcl-devel mailing list