[Rgen] Add the needed code to make the objc_msgSend signatures. - #22029
Conversation
Add the code that will calculate the signature needed in the objc_msgSend which will be the method that calls the native objc message.
|
|
2a80edc to
6ad32da
Compare
There was a problem hiding this comment.
Copilot reviewed 5 out of 18 changed files in this pull request and generated 6 comments.
Files not reviewed (13)
- src/rgen/Microsoft.Macios.Transformer/Microsoft.Macios.Transformer.csproj: Language not supported
- src/rgen/Microsoft.Macios.Generator/Emitters/BindingSyntaxFactory.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/DataModel/TypeInfoComparer.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/Formatters/TypeInfoFormatter.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/DataModel/TypeInfo.Generator.cs: Evaluated as low risk
- tests/rgen/Microsoft.Macios.Generator.Tests/TestDataFactory.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/Emitters/BindingSyntaxFactory.Dlfcn.cs: Evaluated as low risk
- tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/TypeInfoComparerTests.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/Formatters/ParameterFormatter.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/DataModel/Property.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/DataModel/TypeInfo.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/Extensions/SpecialTypeExtensions.cs: Evaluated as low risk
- tests/rgen/Microsoft.Macios.Generator.Tests/Emitters/GetObjCMessageSendMethodNameTests.cs: Evaluated as low risk
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
jonathanpeppers
left a comment
There was a problem hiding this comment.
Just a minor issue with a comment, I think. Not a blocker. 👍
| ExportData<ObjCBindings.Property> property => property.Flags.HasFlag (ObjCBindings.Property | ||
| .CustomMarshalDirective), | ||
| ExportData<ObjCBindings.Method> method => method.Flags.HasFlag ( | ||
| ObjCBindings.Property.CustomMarshalDirective), |
There was a problem hiding this comment.
I remembered HasFlag had a performance issue, but it's ok to use now in .NET 5+:
| /// <summary> | ||
| /// Type of the parameter. | ||
| /// </summary> | ||
| public string Name { get; } | ||
| public string FullyQualifiedName { |
There was a problem hiding this comment.
nitpick: is the summary comment here wrong now?
There was a problem hiding this comment.
It is, fixing
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [PR Build] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [PR Build] Build passed (Build macOS tests) ✅Pipeline on Agent |
✅ API diff for current PR / commit.NET ( No breaking changes )❗ API diff vs stable (Breaking changes).NET ( ❗ Breaking changes ❗ )ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
💻 [CI Build] Windows Integration Tests passed 💻✅ All Windows Integration Tests passed. Pipeline on Agent |
💻 [PR Build] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [PR Build] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [PR Build] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [PR Build] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 120 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
Add the code that will calculate the signature needed in the objc_msgSend which will be the method that calls the native objc message.
Extra context
When we create a binding for a native type we need to be able to send 'messages' to the objc objects. From a C# developer perspective a message can be considered a method. So for example, the following objc code:
[object foo:bar];Can be translated to:
We can say this process is similar to reflection and the Invoke method. Our bindings provide methods around objc_msgsend which we use to send the messaged with the arguments needed by the message. For example, a property with a NSString backing fields defined as:
Results in the following generated code:
Our objc_msgSend method signatures are calculated based on the method parameters and live in the runtime. These objc_msgSend calls are generated by https://github.com/xamarin/xamarin-macios/blob/main/runtime/bindings-generator.cs#L20 For example a objc_msgSend signature for a method that takes a string and returns a string would be:
IntPtr_objc_msgSend_IntPtrBut this is a simplifications because there is a diff between sending a message to a super class (prefix super) or if it deals with a structure (stret).
More info can be found in the Apple documentation.