Skip to content

Commit

Permalink
[RGen] Teach bgen to ignore bgen types.
Browse files Browse the repository at this point in the history
Teach bgen to ignore the types that have been marked by the
BindingTypeAttribute.
  • Loading branch information
mandel-macaque committed Oct 15, 2024
1 parent 0f35909 commit 7a90a3f
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/AVFoundation/AVCaptureReactionType.rgen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#pragma warning disable APL0003
using System;
using System.Runtime.Versioning;

using Foundation;
using ObjCRuntime;
using ObjCBindings;

#nullable enable

namespace AVFoundation {

[BindingTypeAttribute]
[SupportedOSPlatform ("ios17.0")]
[SupportedOSPlatform ("tvos17.0")]
[SupportedOSPlatform ("maccatalyst17.0")]
[SupportedOSPlatform ("macos14.0")]
public enum AVCaptureReactionType {
[Field ("AVCaptureReactionTypeThumbsUp")]
ThumbsUp,

[Field ("AVCaptureReactionTypeThumbsDown")]
ThumbsDown,

[Field ("AVCaptureReactionTypeBalloons")]
Balloons,

[Field ("AVCaptureReactionTypeHeart")]
Heart,

[Field ("AVCaptureReactionTypeFireworks")]
Fireworks,

[Field ("AVCaptureReactionTypeRain")]
Rain,

[Field ("AVCaptureReactionTypeConfetti")]
Confetti,

[Field ("AVCaptureReactionTypeLasers")]
Lasers,
}
}
#pragma warning restore APL0003
8 changes: 8 additions & 0 deletions src/bgen/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
using System.Text;
using System.ComponentModel;
using System.Reflection;
using ObjCBindings;
using ObjCRuntime;
using Foundation;
using Xamarin.Utils;
Expand Down Expand Up @@ -5630,6 +5631,13 @@ string GetAssemblyName ()

public void Generate (Type type)
{

// check if the type has been marked as a type that will be generated by the new code generator, if that
// is the case, bgen will ignore it allowing the rgen code generator add the type to the final assembly
bool is_rgen_type = AttributeManager.HasAttribute<BindingTypeAttribute> (type);
if (is_rgen_type)
return;

if (ZeroCopyStrings) {
ErrorHelper.Warning (1027);
ZeroCopyStrings = false;
Expand Down
4 changes: 4 additions & 0 deletions src/bgen/bgen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<DefineConstants Condition="'$(XAMMACIOS_DEBUGGER)' != ''">$(DefineConstants);XAMMACIOS_DEBUGGER</DefineConstants>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<Nullable>enable</Nullable>
<NoWarn>APL0003</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand All @@ -26,6 +27,9 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="..\ObjCBindings\BindingTypeAttribute.cs">
<Link>BindingTypeAttribute.cs</Link>
</Compile>
<None Include="$(RepositoryPath)\docs\website\generator-errors.md">
<Link>generator-errors.md</Link>
</None>
Expand Down
1 change: 1 addition & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ AVFOUNDATION_SOURCES = \
AVFoundation/Events.cs \
AVFoundation/AVPlayerLooper.cs \
AVFoundation/AudioRendererWasFlushedAutomaticallyEventArgs.cs \
AVFoundation/AVCaptureReactionType.rgen.cs \

# AVKit

Expand Down

0 comments on commit 7a90a3f

Please sign in to comment.