Skip to content

Commit d54951c

Browse files
committed
implement IHandle
1 parent 1b20646 commit d54951c

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Silk.NET.Core;
5+
6+
public interface IHandle
7+
{
8+
public bool IsNull { get; }
9+
}

sources/Core/Core/PublicAPI/net10.0/PublicAPI.Unshipped.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ Silk.NET.Core.IGLContext.VSync.get -> bool
125125
Silk.NET.Core.IGLContext.VSync.set -> void
126126
Silk.NET.Core.IGLContextSource
127127
Silk.NET.Core.IGLContextSource.GLContext.get -> Silk.NET.Core.IGLContext?
128+
Silk.NET.Core.IHandle
129+
Silk.NET.Core.IHandle.IsNull.get -> bool
128130
Silk.NET.Core.INativeWindow
129131
Silk.NET.Core.INativeWindow.TryGetPlatformInfo<TPlatformInfo>(out TPlatformInfo? info) -> bool
130132
Silk.NET.Core.Loader.DefaultNativeContext

sources/SilkTouch/SilkTouch/Mods/TransformHandles.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,11 @@ public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax node)
513513
Token(SyntaxKind.UnsafeKeyword),
514514
Token(SyntaxKind.PartialKeyword)
515515
)
516+
)
517+
.WithBaseList(
518+
BaseList(
519+
[SimpleBaseType(ParseTypeName("IHandle"))]
520+
)
516521
);
517522
}
518523

@@ -700,6 +705,23 @@ private static IEnumerable<MemberDeclarationSyntax> GetDefaultHandleMembers(stri
700705
)
701706
)
702707
.WithSemicolonToken(Token(SyntaxKind.SemicolonToken));
708+
709+
// IHandle.IsNull
710+
yield return PropertyDeclaration(
711+
PredefinedType(Token(SyntaxKind.BoolKeyword)),
712+
Identifier("IsNull")
713+
)
714+
.WithModifiers(TokenList(Token(SyntaxKind.PublicKeyword)))
715+
.WithExpressionBody(
716+
ArrowExpressionClause(
717+
BinaryExpression(
718+
SyntaxKind.EqualsExpression,
719+
CastExpression(IdentifierName("IntPtr"), IdentifierName("Handle")),
720+
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0))
721+
)
722+
)
723+
)
724+
.WithSemicolonToken(Token(SyntaxKind.SemicolonToken));
703725
}
704726

705727
private static IEnumerable<MemberDeclarationSyntax> GetDSLHandleMembers(string structName)

0 commit comments

Comments
 (0)