Skip to content

Commit 2295ce6

Browse files
committed
Remove the hosting API
1 parent bd91c25 commit 2295ce6

23 files changed

+81
-1613
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
/// <summary>
7+
/// Represents a visitable chain of arbitrary types. This can be used for extensible configuration structures.
8+
/// </summary>
9+
public interface ITypeChain
10+
{
11+
/// <summary>
12+
/// Represents a type that visits a type chain.
13+
/// </summary>
14+
public interface Visitor
15+
{
16+
/// <summary>
17+
/// Visits the given type. If a recursive visit is desired (i.e. to visit the whole chain), check whether
18+
/// <typeparamref name="TType"/> is a <see cref="ITypeChain"/> and do this manually.
19+
/// </summary>
20+
/// <param name="value">The value.</param>
21+
/// <typeparam name="TType">The type within the chain.</typeparam>
22+
/// <returns>A value indicating whether to continue with the visitation.</returns>
23+
bool Visit<TType>(TType value);
24+
}
25+
26+
/// <summary>
27+
/// Visit all types at this level within the type chain until <see cref="Visitor.Visit{TType}"/> returns
28+
/// <c>false</c>.
29+
/// </summary>
30+
/// <param name="visitor">The visitor.</param>
31+
/// <typeparam name="TVisitor">The visitor type.</typeparam>
32+
/// <returns>A value indicating whether to continue with the visitation.</returns>
33+
bool Accept<TVisitor>(TVisitor visitor)
34+
where TVisitor : Visitor;
35+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
/// <summary>
7+
/// A chain type containing two types. This can be used to construct a full multilevel type chain by using this type for
8+
/// one of the type parameters of this type.
9+
/// </summary>
10+
/// <param name="Item1">The first value in the chain.</param>
11+
/// <param name="Item2">The second value in the chain.</param>
12+
/// <typeparam name="T1">The type of the first value in the chain.</typeparam>
13+
/// <typeparam name="T2">The type of the second value in the chain.</typeparam>
14+
public readonly record struct TypeChain<T1, T2>(T1 Item1, T2 Item2) : ITypeChain
15+
{
16+
/// <inheritdoc />
17+
public bool Accept<TVisitor>(TVisitor visitor)
18+
where TVisitor : ITypeChain.Visitor => visitor.Visit(Item1) && visitor.Visit(Item2);
19+
}

sources/Windowing/Common/Components/ISurface.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System.Diagnostics.CodeAnalysis;
55
using System.Numerics;
6-
using Silk.NET.Windowing.Hosting;
76

87
namespace Silk.NET.Windowing;
98

@@ -25,7 +24,15 @@ public interface ISurface : IDisposable
2524
/// <summary>
2625
/// Gets a unique handle representing this surface. This may be null if <see cref="Launch{T}"/> is not called.
2726
/// </summary>
28-
SurfaceHandle Handle { get; }
27+
nint Handle { get; }
28+
29+
/// <summary>
30+
/// Gets an implementation of the given component type if implemented by this surface.
31+
/// </summary>
32+
/// <param name="component">The component implementation.</param>
33+
/// <typeparam name="T">The component type.</typeparam>
34+
/// <returns>The </returns>
35+
bool TryGetComponent<T>([NotNullWhen(true)] out T? component);
2936

3037
/// <summary>
3138
/// Runs the window's event loop, dispatching events to the given actor. This may be blocking, but won't always be

sources/Windowing/Common/Configuration/IConfigureHost.cs

Lines changed: 0 additions & 57 deletions
This file was deleted.
Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using Silk.NET.Windowing.Hosting;
5-
64
namespace Silk.NET.Windowing;
75

86
/// <summary>
9-
/// Configures the <see cref="MultiThreadedSurfaceHost{TUnderlying}"/> (or a <see cref="ISurfaceHost"/> with similar
10-
/// threading rules implemented in terms of this configuration) with the given threading configuration. This must be
11-
/// applied to the root surface.
7+
/// Configures the surface with the given threading configuration. This must be applied to the root surface.
128
/// </summary>
139
/// <param name="UseSeparateEventThread">
1410
/// Whether a separate event thread should be used for the root surface. If <c>false</c>, the root surface will be
@@ -32,28 +28,4 @@ namespace Silk.NET.Windowing;
3228
public readonly record struct ThreadConfiguration(
3329
bool UseSeparateEventThread = false,
3430
bool UseBufferedEventLoop = false
35-
) : IConfigureHost
36-
{
37-
/// <inheritdoc />
38-
public void ConfigureHost<THandle, THost>(THandle handle)
39-
where THandle : ISurfaceOrRequestHandle
40-
where THost : ISurfaceHost
41-
{
42-
THost.SetSurfaceProperty(
43-
handle,
44-
new SurfaceProperty
45-
{
46-
PropertyName = SurfacePropertyName.UseSeparateEventThreadBoolean,
47-
Boolean = UseSeparateEventThread
48-
}
49-
);
50-
THost.SetSurfaceProperty(
51-
handle,
52-
new SurfaceProperty
53-
{
54-
PropertyName = SurfacePropertyName.UseBufferedEventLoopBoolean,
55-
Boolean = UseBufferedEventLoop
56-
}
57-
);
58-
}
59-
}
31+
);

sources/Windowing/Common/Hosting/HostEventKind.cs

Lines changed: 0 additions & 55 deletions
This file was deleted.

sources/Windowing/Common/Hosting/HostStatus.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.

sources/Windowing/Common/Hosting/IHostActor.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)