[swift-users] Passing a pointer to self to C function
john_brownie at sil.org
Fri Sep 30 05:10:09 CDT 2016
Still working on the expat wrapper. The thing I need to do is to pass a
pointer to self to be stored in the userData that will be passed to
callbacks, allowing me to get at the local instance. I did this in Swift
The migrator turned this into:
XML_SetUserData(parser, unsafeBitCast(self, to:
but it doesn't work. I don't get an appropriate pointer back in the
callback that I can turn into what I need.
From reading the migration documentation, I don't want to use
unsafeBitCast if at all possible, but I'm not clear what the alternative is.
Also, getting the userData back is something I will need. I currently use:
let theParser = userData!.bindMemory(to: ExpatSwift.self, capacity: 1)
I think that's correct, but I'm not getting a valid object reference.
Any insight is greatly appreciated!
In Finland on furlough from SIL Papua New Guinea
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-users