Added missing documentation

このコミットが含まれているのは:
Sergio Pedri committed 2019-08-11 01:46:23 +02:00
1 親 d084d7bc24
コミット ef6f153f38
1ファイル変更
+17 -15
+17 -15
ファイルの表示
@@ -3,31 +3,33 @@ using System.Runtime.CompilerServices;
namespace DirectX12GameEngine.Core
{
/// <summary>
/// A <see langword="class"/> with some helper methods to copy data between memory areas
/// </summary>
public static class MemoryHelper
{
public static unsafe void Copy(IntPtr source, IntPtr destination, int sizeInBytesToCopy)
{
Copy(new Span<byte>(source.ToPointer(), sizeInBytesToCopy), destination);
}
/// <summary>
/// Copies the content of a <see cref="Span{T}"/> to the area pointed by an input <see cref="IntPtr"/> value
/// </summary>
/// <typeparam name="T">The type of values in the input <see cref="Span{T}"/></typeparam>
/// <param name="source">The source <see cref="Span{T}"/> to read</param>
/// <param name="destination">The <see cref="IntPtr"/> for the destination memory area</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void Copy<T>(Span<T> source, IntPtr destination) where T : unmanaged
{
source.CopyTo(new Span<T>(destination.ToPointer(), source.Length));
}
/// <summary>
/// Copies a memory area pointed by an <see cref="IntPtr"/> value to a target <see cref="Span{T}"/>
/// </summary>
/// <typeparam name="T">The type of values to read</typeparam>
/// <param name="source">The <see cref="IntPtr"/> that indicates the memory area to read from</param>
/// <param name="destination">The destination <see cref="Span{T}"/> to write</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void Copy<T>(IntPtr source, Span<T> destination) where T : unmanaged
{
new Span<T>(source.ToPointer(), destination.Length).CopyTo(destination);
}
public static unsafe void Copy<T>(in T source, IntPtr destination) where T : unmanaged
{
Unsafe.Copy(destination.ToPointer(), ref Unsafe.AsRef(source));
}
public static unsafe void Copy<T>(IntPtr source, ref T destination) where T : unmanaged
{
Unsafe.Copy(ref destination, source.ToPointer());
}
}
}