mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
At the cost of adding an unsafe bitcast implementation detail, simplified the code involved to register a new FunctionTest when adding one. Also simplifies how Swift native `FunctionTest`s are registered with the C++ registry. Now, the to-be-executed thin closure for native Swift `FunctionTest`s is stored under within the swift::test::FunctionTest instance corresponding to it. Because its type isn't representable in C++, `void *` is used instead. When the FunctionTest is invoked, a thunk is called which takes the actual test function and bridged versions of the arguments. That thunk unwraps the arguments, casts the stored function to the appropriate type, and invokes it. Thanks to Andrew Trick for the idea.
3.5 KiB
3.5 KiB