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 2.2 as:

XML_SetUserData(parser, unsafeBitCast(self, UnsafeMutablePointer<Void>.self))

The migrator turned this into:

XML_SetUserData(parser, unsafeBitCast(self, to: UnsafeMutableRawPointer.self))

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!
--
John Brownie
In Finland on furlough from SIL Papua New Guinea
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to