-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CoreGraphics] Adjust CGPDFOperatorTable to not use a generic Action …
…delegate. * CoreCLR doesn't support generic Action delegates in reverse (P/Invokes), so we need to find a different solution. * The native CGPDFOperatorTable callback API is not very friendly to us, because we can't pass it callback-specific data, which means that the managed caller must conform to the FullAOT requirement of the managed callback (must be a static function; must have a MonoPInvokeCallback attribute). * We can leverage the new function pointer syntax in C# 9 to make these requirements enforced by the C# compiler (unmanaged function pointer + UnmanagedCallersOnly attribute). The resulting API is still clunky to use, but I don't see any way around that. Fixes this monotouch-test failure with CoreCLR: [FAIL] Tamarin : System.Runtime.InteropServices.MarshalDirectiveException : Cannot marshal 'parameter #3': Non-blittable generic types cannot be marshaled. at CoreGraphics.CGPDFOperatorTable.CGPDFOperatorTableSetCallback(IntPtr table, String name, Action`2 callback) at CoreGraphics.CGPDFOperatorTable.SetCallback(String name, Action`2 callback) at MonoTouchFixtures.CoreGraphics.PDFScannerTest.Tamarin() in xamarin-macios/tests/monotouch-test/CoreGraphics/PDFScannerTest.cs:line 102 Ref: dotnet/runtime#32963
- Loading branch information
1 parent
c1981b0
commit 74d2220
Showing
2 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters