-
-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial group codegen * Fix some trimming oddities * Fix HintTargetPGI and others similarly situated * Base typing and namespacing * Cast enum members, fix stray semicolons, Silk.NET.OpenGL builds again * Group and bool transformations * Fix erroneous cast order * Add Delete(singular) overloads (ArrayParameterOverloader) * Add SAL object model & Khronos length metadata parsing * ArrayParameterTransformer w/ tests * Integrate ArrayParameterTransformer * Support SupportedApiProfileAttribute generation with metadata * PrettifyNames conflict resolution now actually works * Fix casting transformation ambiguity bugs * Fix metadata retrieval for reserved identifiers * Fix unit tests * Fixup for all caps names * Fix naive trimming bug * More self-review comments
- Loading branch information
Showing
366 changed files
with
518,108 additions
and
117,125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Numerics; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Silk.NET.Core; | ||
|
||
/// <summary> | ||
/// Represents a boolean marshalling scheme for the given underlying type. | ||
/// </summary> | ||
public interface IBoolScheme | ||
{ | ||
/// <summary> | ||
/// The <c>true</c> value. | ||
/// </summary> | ||
static abstract T True<T>() | ||
where T : unmanaged, IEquatable<T>, IIncrementOperators<T>, IDecrementOperators<T>; | ||
|
||
/// <summary> | ||
/// The <c>false</c> value. | ||
/// </summary> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] | ||
static virtual T False<T>() | ||
where T : unmanaged, IEquatable<T>, IIncrementOperators<T>, IDecrementOperators<T> => | ||
default!; | ||
|
||
/// <summary> | ||
/// Determines whether the given value represents a true value. | ||
/// </summary> | ||
/// <param name="value">The underlying value.</param> | ||
/// <typeparam name="T">The type of the underlying value.</typeparam> | ||
/// <returns>True or false.</returns> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] | ||
static virtual bool IsTrue<T>(T value) | ||
where T : unmanaged, IEquatable<T>, IIncrementOperators<T>, IDecrementOperators<T> => | ||
!value.Equals(default); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Numerics; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Silk.NET.Core; | ||
|
||
/// <summary> | ||
/// The "default" option for variance of DSL types using type parameters. For example, use this in place of a | ||
/// <see cref="IBoolScheme"/> type parameter to use the default boolean scheme (as implemented by | ||
/// <see cref="MaybeBool{T}"/>) | ||
/// </summary> | ||
public class Default : IBoolScheme | ||
{ | ||
/// <inheritdoc /> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] | ||
public static T True<T>() | ||
where T : unmanaged, IEquatable<T>, IIncrementOperators<T>, IDecrementOperators<T> | ||
{ | ||
var ret = default(T); | ||
ret++; | ||
return ret; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Numerics; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Silk.NET.Core; | ||
|
||
/// <summary> | ||
/// A boolean represented as an underlying value. | ||
/// </summary> | ||
/// <param name="Value">The underlying value/</param> | ||
/// <typeparam name="T">The underlying type.</typeparam> | ||
public readonly record struct MaybeBool<T>(T Value) | ||
where T : unmanaged, IEquatable<T>, IIncrementOperators<T> | ||
{ | ||
/// <summary> | ||
/// Creates a <see cref="MaybeBool{T}"/> from a <typeparamref name="T"/>. | ||
/// </summary> | ||
/// <param name="Value">The underlying value.</param> | ||
/// <returns>The wrapped value.</returns> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] | ||
public static implicit operator MaybeBool<T>(T Value) => new(Value); | ||
|
||
/// <summary> | ||
/// Gets the underlying value. | ||
/// </summary> | ||
/// <param name="value">The wrapped value.</param> | ||
/// <returns>The underlying value.</returns> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] | ||
public static implicit operator T(MaybeBool<T> value) => value.Value; | ||
|
||
/// <summary> | ||
/// Creates a boolean wrapper of the specified type representing the given value. | ||
/// </summary> | ||
/// <param name="value">The boolean value.</param> | ||
/// <returns>The wrapped underlying value.</returns> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] | ||
public static implicit operator MaybeBool<T>(bool value) | ||
{ | ||
var val = default(T); | ||
if (value) | ||
{ | ||
val++; | ||
} | ||
|
||
return val; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the boolean value of this wrapped value. | ||
/// </summary> | ||
/// <param name="value">The wrapped underlying value.</param> | ||
/// <returns>The boolean value.</returns> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] | ||
public static implicit operator bool(MaybeBool<T> value) => !value.Value.Equals(default); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Numerics; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Silk.NET.Core; | ||
|
||
/// <summary> | ||
/// A boolean represented as an underlying value expressed using a specific scheme. | ||
/// </summary> | ||
/// <param name="Value">The underlying value/</param> | ||
/// <typeparam name="T">The underlying type.</typeparam> | ||
/// <typeparam name="TScheme">The scheme used to determine the underlying value.</typeparam> | ||
public readonly record struct MaybeBool<T, TScheme>(T Value) | ||
where T : unmanaged, IEquatable<T>, IIncrementOperators<T>, IDecrementOperators<T> | ||
where TScheme : IBoolScheme | ||
{ | ||
/// <summary> | ||
/// Creates a <see cref="MaybeBool{T,TScheme}"/> from a <typeparamref name="T"/>. | ||
/// </summary> | ||
/// <param name="Value">The underlying value.</param> | ||
/// <returns>The wrapped value.</returns> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] | ||
public static implicit operator MaybeBool<T, TScheme>(T Value) => new(Value); | ||
|
||
/// <summary> | ||
/// Gets the underlying value. | ||
/// </summary> | ||
/// <param name="value">The wrapped value.</param> | ||
/// <returns>The underlying value.</returns> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] | ||
public static implicit operator T(MaybeBool<T, TScheme> value) => value.Value; | ||
|
||
/// <summary> | ||
/// Creates a boolean wrapper of the specified type representing the given value. | ||
/// </summary> | ||
/// <param name="value">The boolean value.</param> | ||
/// <returns>The wrapped underlying value.</returns> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] | ||
public static implicit operator MaybeBool<T, TScheme>(bool value) => | ||
value ? TScheme.True<T>() : TScheme.False<T>(); | ||
|
||
/// <summary> | ||
/// Gets the boolean value of this wrapped value. | ||
/// </summary> | ||
/// <param name="value">The wrapped underlying value.</param> | ||
/// <returns>The boolean value.</returns> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] | ||
public static implicit operator bool(MaybeBool<T, TScheme> value) => | ||
TScheme.IsTrue(value.Value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Numerics; | ||
|
||
namespace Silk.NET.Core; | ||
|
||
/// <summary> | ||
/// The bool scheme for the Win32 <c>VARIANT_BOOL</c> type. | ||
/// </summary> | ||
public class VariantBool : IBoolScheme | ||
{ | ||
/// <inheritdoc /> | ||
public static T True<T>() | ||
where T : unmanaged, IEquatable<T>, IIncrementOperators<T>, IDecrementOperators<T> | ||
{ | ||
// True is -1/all bits set | ||
var ret = default(T); | ||
unchecked | ||
{ | ||
ret--; | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public static bool IsTrue<T>(T value) | ||
where T : unmanaged, IEquatable<T>, IIncrementOperators<T>, IDecrementOperators<T> => | ||
value.Equals(True<T>()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.