Skip to content

[RGen] Generate the aux BlockLiteral pointer variable for the trampolines. #23078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 18, 2025

Conversation

mandel-macaque
Copy link
Member

Generates the creation of a BlockLiteral pointer aux variable that will be used to pass a block callback to the invoker.

mandel-macaque and others added 3 commits June 18, 2025 10:36
We are not yet fully doing the convesions needed for a block callback in
the native invoker call. We need the following:

```csharp
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
unsafe global::AudioUnit.AudioUnitStatus Invoke (ref global::AudioUnit.AudioUnitRenderActionFlags actionFlags, ref global::AudioToolbox.AudioTimeStamp timestamp, uint frameCount, nint outputBusNumber, global::AudioToolbox.AudioBuffers outputData, [BlockProxy (typeof (ObjCRuntime.Trampolines.NIDAURenderPullInputBlock))]global::AudioUnit.AURenderPullInputBlock? pullInputBlock)
{
  var outputData__handle__ = outputData.GetHandle ();
  using var block_pullInputBlock = Trampolines.SDAURenderPullInputBlock.CreateNullableBlock (pullInputBlock);
  BlockLiteral *block_ptr_pullInputBlock = null;
  if (pullInputBlock is not null)
    block_ptr_pullInputBlock = &block_pullInputBlock;
  var ret = (AudioUnitStatus) invoker (BlockPointer, (AudioUnitRenderActionFlags*) global::System.Runtime.CompilerServices.Unsafe.AsPointer<AudioUnitRenderActionFlags> (ref actionFlags), (global::AudioToolbox.AudioTimeStamp*) global::System.Runtime.CompilerServices.Unsafe.AsPointer<global::AudioToolbox.AudioTimeStamp> (ref timestamp), frameCount, outputBusNumber, outputData__handle__, (IntPtr) block_ptr_pullInputBlock);
  GC.KeepAlive (outputData);
  return ret!;
}
```

This change adds the declaration of the 'block_pullInputBlock', we will
add the assigment in comming PRs to make the reviews easier.
…ines.

Generates the creation of a BlockLiteral pointer aux variable that will
be used to pass a block callback to the invoker.
Base automatically changed from dev/mandel/rgen-trampoline-block-param to main June 18, 2025 19:07
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@mandel-macaque mandel-macaque requested a review from Copilot June 18, 2025 20:00
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds functionality to generate an auxiliary BlockLiteral pointer variable for trampolines, enabling the proper handling of block callbacks in the generated code. Key changes include:

  • Modifying trampoline test cases to include the BlockLiteral pointer variable.
  • Introducing a new test for BlockLiteral auxiliary variable generation in ObjCRuntime.
  • Updating generator logic to produce both the nullable block and its corresponding pointer variable.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/rgen/Microsoft.Macios.Generator.Tests/Emitters/BindingSyntaxFactoryTrampolineTests.cs Updates test expecting the new block pointer variable.
tests/rgen/Microsoft.Macios.Generator.Tests/Emitters/BindingSyntaxFactoryObjCRuntimeTests.cs Adds a test for the generated BlockLiteral auxiliary variable.
tests/rgen/Microsoft.Macios.Generator.Tests/Classes/Data/ExpectedTrampolinePropertyTestsTrampolines.cs Updates expected declarations to verify pointer variable generation.
src/rgen/Microsoft.Macios.Generator/Emitters/BindingSyntaxFactory.Trampoline.cs Modifies trampoline generation logic to include the BlockLiteral auxiliary variable.
src/rgen/Microsoft.Macios.Generator/Emitters/BindingSyntaxFactory.ObjCRuntime.cs Introduces a helper to generate a BlockLiteral pointer variable with proper documentation.

SyntaxKind.NullLiteralExpression)))),
PrefixUnaryExpression (
SyntaxKind.AddressOfExpression,
IdentifierName (blockVariableName!)),
Copy link
Preview

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using the null-forgiving operator '!' when accessing blockVariableName in this context. Ensure that blockVariableName is non-null before usage or adjust the logic so that the '!' operator is not needed.

Suggested change
IdentifierName (blockVariableName!)),
IdentifierName (blockVariableName)),

Copilot uses AI. Check for mistakes.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [PR Build #c94d900] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: c94d9003ce20993b2a397ecf038ebec53efa074e [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #817d581] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 817d5818094cf72ed744c68e32d369e3ca305669 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

.NET ( No breaking changes )

✅ API diff vs stable

.NET ( No breaking changes )

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: c94d9003ce20993b2a397ecf038ebec53efa074e [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #817d581] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 817d5818094cf72ed744c68e32d369e3ca305669 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #817d581] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: 817d5818094cf72ed744c68e32d369e3ca305669 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #817d581] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: 817d5818094cf72ed744c68e32d369e3ca305669 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #817d581] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: 817d5818094cf72ed744c68e32d369e3ca305669 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #817d581] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: 817d5818094cf72ed744c68e32d369e3ca305669 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build #c94d900] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 119 tests passed 🎉

Tests counts

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 10 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 10 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: c94d9003ce20993b2a397ecf038ebec53efa074e [PR build]

@mandel-macaque
Copy link
Member Author

Failing tests are unrelated to code changes.

@mandel-macaque mandel-macaque merged commit 56d7587 into main Jun 18, 2025
38 of 40 checks passed
@mandel-macaque mandel-macaque deleted the dev/mandel/create-blockliteral-pointer branch June 18, 2025 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants