Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions sources/Core/Core/Abstractions/IHandle.cs
Original file line number Diff line number Diff line change
@@ -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

Check failure on line 6 in sources/Core/Core/Abstractions/IHandle.cs

View workflow job for this annotation

GitHub Actions / Test (osx-arm64, macos-latest, osx-arm64)

Missing XML comment for publicly visible type or member 'IHandle'

Check failure on line 6 in sources/Core/Core/Abstractions/IHandle.cs

View workflow job for this annotation

GitHub Actions / Test (win-x64, windows-latest, win-x64)

Missing XML comment for publicly visible type or member 'IHandle'

Check failure on line 6 in sources/Core/Core/Abstractions/IHandle.cs

View workflow job for this annotation

GitHub Actions / Test (linux-x64, ubuntu-22.04, linux-x64)

Missing XML comment for publicly visible type or member 'IHandle'
Copy link
Member

Choose a reason for hiding this comment

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

Missing docs comments are resulting in compilation failure.

Copy link
Member

Choose a reason for hiding this comment

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

Hmmm on second thought, maybe we could do IHandle<TSelf> : IEquatable<TSelf>, IEqualityOperators<TSelf, TSelf, bool>? At this point we totally negate the need for IsNull as users generalising over T: IHandle<T>>? Could maybe keep this non-generic interface and DIM it in the generic one if we want (is that a thing?) If we go that route no changes will be required to TransformHandles other than the base list.

{
public bool IsNull { get; }

Check failure on line 8 in sources/Core/Core/Abstractions/IHandle.cs

View workflow job for this annotation

GitHub Actions / Test (osx-arm64, macos-latest, osx-arm64)

Missing XML comment for publicly visible type or member 'IHandle.IsNull'

Check failure on line 8 in sources/Core/Core/Abstractions/IHandle.cs

View workflow job for this annotation

GitHub Actions / Test (win-x64, windows-latest, win-x64)

Missing XML comment for publicly visible type or member 'IHandle.IsNull'

Check failure on line 8 in sources/Core/Core/Abstractions/IHandle.cs

View workflow job for this annotation

GitHub Actions / Test (linux-x64, ubuntu-22.04, linux-x64)

Missing XML comment for publicly visible type or member 'IHandle.IsNull'
}
2 changes: 2 additions & 0 deletions sources/Core/Core/PublicAPI/net10.0/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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<TPlatformInfo>(out TPlatformInfo? info) -> bool
Silk.NET.Core.Loader.DefaultNativeContext
Expand Down
22 changes: 22 additions & 0 deletions sources/SilkTouch/SilkTouch/Mods/TransformHandles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,11 @@ public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax node)
Token(SyntaxKind.UnsafeKeyword),
Token(SyntaxKind.PartialKeyword)
)
)
.WithBaseList(
BaseList(
[SimpleBaseType(ParseTypeName("IHandle"))]
)
);
}

Expand Down Expand Up @@ -700,6 +705,23 @@ private static IEnumerable<MemberDeclarationSyntax> 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))
Comment on lines +719 to +720
Copy link
Member

Choose a reason for hiding this comment

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

Could we do this == default to make it agnostic to non-pointer-sized handles?

)
)
)
.WithSemicolonToken(Token(SyntaxKind.SemicolonToken));
}

private static IEnumerable<MemberDeclarationSyntax> GetDSLHandleMembers(string structName)
Expand Down
Loading