dart-lang / native

Dart packages related to FFI and native assets bundling.
BSD 3-Clause "New" or "Revised" License
155 stars 43 forks source link

Should we separate user facing code from boilerplate? #210

Open liamappelbe opened 2 years ago

liamappelbe commented 2 years ago

The generated code would be easier to read if we move all the boilerplate that the user doesn't care about to a separate file.

dcharkes commented 2 years ago

We could, but apart from the generated comments there is not much useful info in the file anyway.

What would you propose as split? Having the Dart function name/types + comments copied from C as members of a class and then delegate the implementation to another class in another file? (In that case the implementation class is going to be basically what we now have but without the comments.)

liamappelbe commented 2 years ago

I think the C bindings are pretty much fine. We might be able to move the 2 late final fields associated with each function to a private class in another file, but mainly I'm thinking about the ObjC boilerplate. There's the objc_getClass result for every interface, the selectors for every method, all the objc_msgSend wrappers, and a bunch of private util functions and classes.