Skip to content

Commit

Permalink
Merge branch 'develop/3.0' into dependabot/nuget/develop/3.0/multi-62…
Browse files Browse the repository at this point in the history
…30e5459e
  • Loading branch information
Perksey authored Dec 7, 2024
2 parents 568011f + eae19f5 commit 8e1ad80
Show file tree
Hide file tree
Showing 212 changed files with 62,701 additions and 28,460 deletions.
Binary file added .silktouch/0afb5dc84012c2fa.stout
Binary file not shown.
Binary file modified .silktouch/c8c046b328b09d23.stout
Binary file not shown.
Binary file removed .silktouch/f634eee0bf239a81.stout
Binary file not shown.
2 changes: 2 additions & 0 deletions eng/silktouch/sdl/SDL3/generate.rsp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ SDL_SIZE_MAX
SDL_memcpy
SDL_memmove
SDL_memset
SDL_BeginThreadFunction
SDL_EndThreadFunction
--file
sdl-SDL.h
--methodClassName
Expand Down
2 changes: 1 addition & 1 deletion eng/submodules/sdl
Submodule sdl updated 1514 files
16 changes: 11 additions & 5 deletions generator.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"ExtractNestedTyping",
"TransformHandles",
"TransformFunctions",
"TransformProperties",
"PrettifyNames",
"AddVTables"
],
Expand Down Expand Up @@ -71,6 +72,7 @@
"AddIncludes",
"ClangScraper",
"AddApiProfiles",
"BakeSourceSets",
"MixKhronosData",
"AddOpaqueStructs",
"TransformFunctions",
Expand All @@ -88,29 +90,33 @@
"Profiles": [
{
"Profile": "gl",
"SourceSubdirectory": "glcompat",
"BakedOutputSubdirectory": "gl"
"SourceSubdirectory": "glcompat"
},
{
"Profile": "glcore",
"SourceSubdirectory": "glcore",
"BakedOutputSubdirectory": "gl",
"MinVersion": "3.2"
},
{
"Profile": "gles1",
"SourceSubdirectory": "gles1",
"BakedOutputSubdirectory": "gl",
"MaxVersion": "2.0"
},
{
"Profile": "gles2",
"SourceSubdirectory": "gles2",
"BakedOutputSubdirectory": "gl",
"MinVersion": "2.0"
}
]
},
"BakeSourceSets": {
"SourceSets": {
"glcompat": "gl",
"glcore": "gl",
"gles1": "gl",
"gles2": "gl"
}
},
"AddOpaqueStructs": {
"Names": [
"GLsync"
Expand Down
81 changes: 81 additions & 0 deletions sources/Core/Core/Abstractions/Utf8String.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.InteropServices;

namespace Silk.NET.Core;

/// <summary>
/// Represents a target type for UTF-8 string literals.
/// </summary>
/// <param name="bytes">The UTF-8 bytes.</param>
public readonly ref struct Utf8String(ReadOnlySpan<byte> bytes)
{
/// <summary>
/// Gets the UTF-8 byte representation of this string.
/// </summary>
public ReadOnlySpan<byte> Bytes { get; } = bytes;

/// <summary>
/// Converts this string to a <see cref="Ref{T}"/>.
/// </summary>
/// <param name="str">The string.</param>
/// <returns>The ref.</returns>
public static implicit operator Ref<byte>(Utf8String str) => str.Bytes;

/// <summary>
/// Converts this string to a <see cref="Ref{T}"/>.
/// </summary>
/// <param name="str">The string.</param>
/// <returns>The ref.</returns>
public static implicit operator Ref<sbyte>(Utf8String str) => (ReadOnlySpan<sbyte>)str;

/// <summary>
/// Converts this string to a <see cref="ReadOnlySpan{T}"/>.
/// </summary>
/// <param name="str">The string.</param>
/// <returns>The span.</returns>
public static implicit operator ReadOnlySpan<byte>(Utf8String str) => str.Bytes;

/// <summary>
/// Converts this string to a <see cref="Ref{T}"/>.
/// </summary>
/// <param name="str">The string.</param>
/// <returns>The span.</returns>
public static implicit operator ReadOnlySpan<sbyte>(Utf8String str) =>
MemoryMarshal.Cast<byte, sbyte>(str);

// TODO add ptr casts once we have an analyzer for e.g. [KnownImmovable]

/// <summary>
/// Converts this string to a <see cref="Ref"/>.
/// </summary>
/// <param name="str">The string.</param>
/// <returns>The ref.</returns>
public static implicit operator Ref(Utf8String str) => (Ref<byte>)str.Bytes;

/// <summary>
/// Converts this string to a <see cref="string"/>.
/// </summary>
/// <param name="str">The string.</param>
/// <returns>The string.</returns>
public static implicit operator string(Utf8String str) => str.ToString();

/// <summary>
/// Converts the given UTF-8 bytes to a <see cref="Utf8String"/>.
/// </summary>
/// <param name="bytes">The bytes.</param>
/// <returns>The string.</returns>
public static implicit operator Utf8String(ReadOnlySpan<byte> bytes) => new(bytes);

/// <summary>
/// Converts the given UTF-8 bytes to a <see cref="Utf8String"/>.
/// </summary>
/// <param name="bytes">The bytes.</param>
/// <returns>The string.</returns>
public static implicit operator Utf8String(ReadOnlySpan<sbyte> bytes) =>
MemoryMarshal.Cast<sbyte, byte>(bytes);

/// <inheritdoc />
public override string ToString() => (string)(Ref<byte>)this;
}
13 changes: 11 additions & 2 deletions sources/Core/Core/Pointers/Ref.generic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,21 @@ public ref T this[nuint index]
public static bool operator !=(NullPtr lh, Ref<T> rh) => (Ref<T>)lh != rh;

/// <summary>
/// Creates a <see cref="Ref{T}"/> from a span
/// Creates a <see cref="Ref{T}"/> from a span.
/// </summary>
/// <param name="span"></param>
/// <param name="span">The span to create the ref from.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
public static implicit operator Ref<T>(Span<T> span) => new(ref span.GetPinnableReference());

/// <summary>
/// Creates a <see cref="Ref{T}"/> from a readonly span.
/// </summary>
/// <param name="span">The span to create the ref from.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
// TODO const correctness analyzers
public static implicit operator Ref<T>(ReadOnlySpan<T> span) =>
new(ref Unsafe.AsRef(in span.GetPinnableReference()));

/// <summary>
/// Creates a <see cref="Ref{T}"/> from a byte reference
/// </summary>
Expand Down
Loading

0 comments on commit 8e1ad80

Please sign in to comment.