diff --git a/sources/Core/Core/Abstractions/IHandle.cs b/sources/Core/Core/Abstractions/IHandle.cs new file mode 100644 index 0000000000..2bbfce1735 --- /dev/null +++ b/sources/Core/Core/Abstractions/IHandle.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Silk.NET.Core; + +public interface IHandle +{ + public bool IsNull { get; } +} diff --git a/sources/Core/Core/PublicAPI/net10.0/PublicAPI.Unshipped.txt b/sources/Core/Core/PublicAPI/net10.0/PublicAPI.Unshipped.txt index d6847290ae..c5306ce6c7 100644 --- a/sources/Core/Core/PublicAPI/net10.0/PublicAPI.Unshipped.txt +++ b/sources/Core/Core/PublicAPI/net10.0/PublicAPI.Unshipped.txt @@ -125,6 +125,8 @@ Silk.NET.Core.IGLContext.VSync.get -> bool Silk.NET.Core.IGLContext.VSync.set -> void Silk.NET.Core.IGLContextSource Silk.NET.Core.IGLContextSource.GLContext.get -> Silk.NET.Core.IGLContext? +Silk.NET.Core.IHandle +Silk.NET.Core.IHandle.IsNull.get -> bool Silk.NET.Core.INativeWindow Silk.NET.Core.INativeWindow.TryGetPlatformInfo(out TPlatformInfo? info) -> bool Silk.NET.Core.Loader.DefaultNativeContext diff --git a/sources/SilkTouch/SilkTouch/Mods/TransformHandles.cs b/sources/SilkTouch/SilkTouch/Mods/TransformHandles.cs index 0387459f74..6609d40a20 100644 --- a/sources/SilkTouch/SilkTouch/Mods/TransformHandles.cs +++ b/sources/SilkTouch/SilkTouch/Mods/TransformHandles.cs @@ -513,6 +513,11 @@ public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax node) Token(SyntaxKind.UnsafeKeyword), Token(SyntaxKind.PartialKeyword) ) + ) + .WithBaseList( + BaseList( + [SimpleBaseType(ParseTypeName("IHandle"))] + ) ); } @@ -700,6 +705,23 @@ private static IEnumerable GetDefaultHandleMembers(stri ) ) .WithSemicolonToken(Token(SyntaxKind.SemicolonToken)); + + // IHandle.IsNull + yield return PropertyDeclaration( + PredefinedType(Token(SyntaxKind.BoolKeyword)), + Identifier("IsNull") + ) + .WithModifiers(TokenList(Token(SyntaxKind.PublicKeyword))) + .WithExpressionBody( + ArrowExpressionClause( + BinaryExpression( + SyntaxKind.EqualsExpression, + CastExpression(IdentifierName("IntPtr"), IdentifierName("Handle")), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)) + ) + ) + ) + .WithSemicolonToken(Token(SyntaxKind.SemicolonToken)); } private static IEnumerable GetDSLHandleMembers(string structName)