[Haskell-iPhone] General FFI Questions

Schell Scivally efsubenovex at gmail.com
Fri Jan 3 23:39:19 UTC 2014


Thanks Stephen and Carter. I think what was happening is that CGFloat is
either a float or a double depending on whether or not the target is 64bit.
This was making the alignment not what I expected. My trick is just to have
an intermediate struct that I can depend on gets fed into haskell. Now I'm
working on marshalling arrays of structs.


On Fri, Jan 3, 2014 at 3:27 PM, Stephen Blackheath [to GHC-iPhone] <
likeliest.complexions.stephen at blacksapphire.com> wrote:

>
> Schell,
>
> Take a look at my Storable instance for SockAddrBTH here:
>
>
> https://github.com/the-real-blackh/simple-bluetooth/blob/master/Network/Bluetooth/Device.hsc
>
> Using .hsc files gives you get the offset into the structure like this:
>
>   p `plusPtr` (#const offsetof(struct sockaddr_rc, rc_bdaddr))
>
> #include <stddef.h> to give you offsetof.
>
> Quite a useful trick.
>
>
> Steve
>
> On 04/01/14 08:41, Schell Scivally wrote:
> > I'm having a hard time unmarshalling a c struct into a haskell record.
> > Does anyone have a good link that talks about unmarshalling nested c
> > structs? Is this common or should I just forget about it?
> >
> > --
> > Schell Scivally
> > http://blog.efnx.com
> > http://github.com/schell
> > http://twitter.com/schellsan
> >
> >
> > _______________________________________________
> > iPhone mailing list
> > iPhone at haskell.org
> > http://www.haskell.org/mailman/listinfo/iphone
> >
> _______________________________________________
> iPhone mailing list
> iPhone at haskell.org
> http://www.haskell.org/mailman/listinfo/iphone
>



-- 
Schell Scivally
http://blog.efnx.com
http://github.com/schell
http://twitter.com/schellsan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/iphone/attachments/20140103/56158025/attachment.html>


More information about the iPhone mailing list