Open liamappelbe opened 2 weeks ago
Fixed in https://github.com/dart-lang/native/pull/1668.
The main problem was that we're indicating errors by throwing exceptions. So if, for example, a method returned an enum, which we don't support yet, parseDeclaration
would throw. Then since the method parser wasn't catching that exception, it also propagated up through _parseCompoundDeclaration
, effectively removing that declaration. The fix is to catch the error in _parseCompoundDeclaration
and just omit that method. I added tryParseDeclaration
that wraps parseDeclaration
, logs the exception and returns null.
More generally, any time we're calling parseDeclaration
, if we want to gracefully handle a problem with the declaration, we should instead call tryParseDeclaration
and handle the nullable result. I had a quick look at all the call sites and I don't think there are any other cases like this at the moment.
I'm running https://github.com/dart-lang/native/pull/1367 (with https://github.com/dart-lang/native/pull/1668 patched) on the
AVFAudio
module to try to see if I can migrate the ffigen objc example to swift. That'll be a good milestone to demonstrate binding a simple, but realistic, Apple API.The most important class for this example is
AVAudioPlayer
, but currently it's flaky whether that class even exists in the list of declarations returned byparseAst
.