Re: [Pharo-dev] FFI BoxedFloat64 bug?

2016-02-18 Thread Esteban Lorenzano
Floats and doubles in C have different size, regardless the size of floats in pharo who are always 64bits. But a call to a function(float a) expects a 32bits float and not a 64bit so a cast needs to be done (automatically in FFI), now if you are calling a function(float *a) and you have a float

Re: [Pharo-dev] FFI BoxedFloat64 bug?

2016-02-18 Thread Henrik Sperre Johansen
I must admit, I don't get it either... When you have a signature with a pointer to a primitive type, it's usually because a) The method replaces the value b) The method expects a pointer to an array with items of the primitive type. In neither case is automatic marshalling from Smalltalk type very

Re: [Pharo-dev] FFI BoxedFloat64 bug?

2016-02-18 Thread Clément Bera
OK nevermind I got it now. I talked with Esteban. I had misunderstood. 2016-02-18 14:57 GMT+01:00 Clément Bera : > I don't understand. > > In 32 bits in C, there are 32 bits float called "float" or "single > precision float" but its usage is very uncommon. People always use "double" > as every 32

Re: [Pharo-dev] FFI BoxedFloat64 bug?

2016-02-18 Thread Clément Bera
I don't understand. In 32 bits in C, there are 32 bits float called "float" or "single precision float" but its usage is very uncommon. People always use "double" as every 32 bits processors supports 64 bits float nowadays. When I look at the Cairo reference manual, only double are used, so I don'

Re: [Pharo-dev] FFI BoxedFloat64 bug?

2016-02-18 Thread Alexandre Bergel
Thanks Esteban! Alexandre > On Feb 18, 2016, at 8:11 AM, Esteban Lorenzano wrote: > > >> On 17 Feb 2016, at 19:35, Alexandre Bergel wrote: >> >>> I don't understand. All BoxedFloat have 8 bytes, that's why they are called >>> BoxedFloat64. There are no 4-bytes floats in Pharo. Even in 32 b

Re: [Pharo-dev] FFI BoxedFloat64 bug?

2016-02-18 Thread Esteban Lorenzano
> On 17 Feb 2016, at 19:35, Alexandre Bergel wrote: > >> I don't understand. All BoxedFloat have 8 bytes, that's why they are called >> BoxedFloat64. There are no 4-bytes floats in Pharo. Even in 32 bits. > > I have some code that involve FFI and floats that was working before Spur. > I got t

Re: [Pharo-dev] FFI BoxedFloat64 bug?

2016-02-18 Thread Esteban Lorenzano
but in C (32bits) floats are 4 bytes, so when you do: ByteArray new floatAt: 1 put: somePharoFloat; it will cast it to 4 bytes (if it fits which is most of the cases). but as I said… it is an error I need to fix :) Esteban > On 12 Feb 2016, at 20:50, Clément Bera wrote: > > I don't

Re: [Pharo-dev] FFI BoxedFloat64 bug?

2016-02-17 Thread Alexandre Bergel
> I don't understand. All BoxedFloat have 8 bytes, that's why they are called > BoxedFloat64. There are no 4-bytes floats in Pharo. Even in 32 bits. I have some code that involve FFI and floats that was working before Spur. I got the error mentioned by Alex. Defining this pointer method gives a

Re: [Pharo-dev] FFI BoxedFloat64 bug?

2016-02-12 Thread Clément Bera
I don't understand. All BoxedFloat have 8 bytes, that's why they are called BoxedFloat64. There are no 4-bytes floats in Pharo. Even in 32 bits. 2016-02-12 18:06 GMT+01:00 Esteban Lorenzano : > > On 12 Feb 2016, at 17:50, Aliaksei Syrel wrote: > > On Fri, Feb 12, 2016 at 5:45 PM, Esteban Lorenza

Re: [Pharo-dev] FFI BoxedFloat64 bug?

2016-02-12 Thread Esteban Lorenzano
> On 12 Feb 2016, at 17:50, Aliaksei Syrel wrote: > > On Fri, Feb 12, 2016 at 5:45 PM, Esteban Lorenzano > wrote: > Float>>#pointer > ^ (ByteArray new: FFIExternalType pointerSize) > floatAt: 1 put: self; > yourself > > Yes it does

Re: [Pharo-dev] FFI BoxedFloat64 bug?

2016-02-12 Thread Aliaksei Syrel
> > (and you can commit it to Pharo/NB-FFI repo… I’m taking a plane now and I > do not have the time until thursday :( ) done Cheers, Alex On Fri, Feb 12, 2016 at 5:50 PM, Aliaksei Syrel wrote: > On Fri, Feb 12, 2016 at 5:45 PM, Esteban Lorenzano > wrote: > >> Float>>#pointer >> ^ (ByteArray

Re: [Pharo-dev] FFI BoxedFloat64 bug?

2016-02-12 Thread Aliaksei Syrel
On Fri, Feb 12, 2016 at 5:45 PM, Esteban Lorenzano wrote: > Float>>#pointer > ^ (ByteArray new: FFIExternalType pointerSize) > floatAt: 1 put: self; > yourself > Yes it does the trick :) Thanks!

Re: [Pharo-dev] FFI BoxedFloat64 bug?

2016-02-12 Thread Esteban Lorenzano
Oops… I didn’t implemented #pointer for floats… it should be something like this: Float>>#pointer ^ (ByteArray new: FFIExternalType pointerSize) floatAt: 1 put: self; yourself can you test it? (and you can commit it to Pharo/NB-FFI repo… I’m taking a plan