3 ms·
This is also what the "official" C++ API for Metal does (https://developer.apple.com/metal/cpp/ https://developer.apple.com/metal/cpp/), it's an automatically g
by flohofwoe 3y ago
This is also what the "official" C++ API for Metal does (https://developer.apple.com/metal/cpp/ https://developer.apple.com/metal/cpp/), it's an automatically generated bindings wrapper which calls into ObjC runtime functions without an ObjC shim inbetween).
Bit of a shame that this idea isn't extended to all system frameworks and not just C++ but also C bindings (official C bindings would make life a lot easier for all other programming languages).
I also dabbled a bit with this idea by parsing clang AST-dumps of macOS system headers and generate C binding functions:
https://github.com/floooh/objc-ast-experiments https://github.com/floooh/objc-ast-experiments
Unfortunately this is very brittle, and then also broke on ARM CPUs, I guess the shim code needs some ABI adjustments (famously, objc_msgSend has multiple "ABI shapes": https://www.mikeash.com/pyblog/objc_msgsends-new-prototype.html https://www.mikeash.com/pyblog/objc_msgsends-new-prototype.h...).
- pjmlp 3y agoAs mentioned on the Swift talk at CppNow 2023, most of the C bindings are actually C++ with extern "C", and Apple would rather write less of them than more of. "CppNow 2023:Introducing a Memory-Safe Successor Language in Large C++ Code Bases" https://www.youtube.com/watch?v=lgivCGdmFrw https://www.youtube.com/watch?v=lgivCGdmFrw