mirror of https://github.com/ppy/SDL3-CS.git
Add [MustDisposeResource] annoations to array helpers
This commit is contained in:
parent
bb9834d0a9
commit
3edde48072
|
|
@ -12,4 +12,8 @@
|
|||
<ProjectReference Include="..\SDL3-CS.SourceGeneration\SDL3-CS.SourceGeneration.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace SDL
|
||||
{
|
||||
|
|
@ -59,6 +60,7 @@ namespace SDL
|
|||
[Macro]
|
||||
public static int SDL_AUDIO_FRAMESIZE(SDL_AudioSpec x) => SDL_AUDIO_BYTESIZE((x).format) * (x).channels;
|
||||
|
||||
[MustDisposeResource]
|
||||
public static unsafe SDLArray<SDL_AudioDeviceID>? SDL_GetAudioOutputDevices()
|
||||
{
|
||||
int count;
|
||||
|
|
@ -66,6 +68,7 @@ namespace SDL
|
|||
return SDLArray.Create(array, count);
|
||||
}
|
||||
|
||||
[MustDisposeResource]
|
||||
public static unsafe SDLArray<SDL_AudioDeviceID>? SDL_GetAudioCaptureDevices()
|
||||
{
|
||||
int count;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace SDL
|
||||
{
|
||||
|
|
@ -11,6 +12,7 @@ namespace SDL
|
|||
/// <returns>
|
||||
/// An array of <see cref="nint"/> that can be passed to <see cref="Marshal.PtrToStringUTF8(System.IntPtr)"/>.
|
||||
/// </returns>
|
||||
[MustDisposeResource]
|
||||
public static unsafe SDLArray<IntPtr>? SDL_GetGamepadMappings()
|
||||
{
|
||||
int count;
|
||||
|
|
@ -18,6 +20,7 @@ namespace SDL
|
|||
return SDLArray.Create(array, count);
|
||||
}
|
||||
|
||||
[MustDisposeResource]
|
||||
public static unsafe SDLArray<SDL_JoystickID>? SDL_GetGamepads()
|
||||
{
|
||||
int count;
|
||||
|
|
@ -25,6 +28,7 @@ namespace SDL
|
|||
return SDLArray.Create(array, count);
|
||||
}
|
||||
|
||||
[MustDisposeResource]
|
||||
public static unsafe SDLPointerArray<SDL_GamepadBinding>? SDL_GetGamepadBindings(SDL_Gamepad* gamepad)
|
||||
{
|
||||
int count;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace SDL
|
||||
{
|
||||
|
|
@ -10,6 +11,7 @@ namespace SDL
|
|||
|
||||
public static partial class SDL3
|
||||
{
|
||||
[MustDisposeResource]
|
||||
public static unsafe SDLArray<SDL_HapticID>? SDL_GetHaptics()
|
||||
{
|
||||
int count;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace SDL
|
||||
{
|
||||
|
|
@ -10,6 +11,7 @@ namespace SDL
|
|||
|
||||
public static partial class SDL3
|
||||
{
|
||||
[MustDisposeResource]
|
||||
public static unsafe SDLArray<SDL_JoystickID>? SDL_GetJoysticks()
|
||||
{
|
||||
int count;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace SDL
|
||||
{
|
||||
|
|
@ -15,6 +16,7 @@ namespace SDL
|
|||
|
||||
public static partial class SDL3
|
||||
{
|
||||
[MustDisposeResource]
|
||||
public static unsafe SDLArray<SDL_KeyboardID>? SDL_GetKeyboards()
|
||||
{
|
||||
int count;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace SDL
|
||||
{
|
||||
|
|
@ -32,6 +33,7 @@ namespace SDL
|
|||
[Macro]
|
||||
public static SDLButtonMask SDL_BUTTON(SDLButton button) => (SDLButtonMask)(1 << ((int)button - 1));
|
||||
|
||||
[MustDisposeResource]
|
||||
public static unsafe SDLArray<SDL_MouseID>? SDL_GetMice()
|
||||
{
|
||||
int count;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace SDL
|
||||
{
|
||||
|
|
@ -34,6 +35,7 @@ namespace SDL
|
|||
[Macro]
|
||||
public static SDL_PEN_CAPABILITIES SDL_PEN_AXIS_CAPABILITY(SDL_PenAxis axis) => SDL_PEN_CAPABILITY((int)axis + SDL_PEN_FLAG_AXIS_BIT_OFFSET);
|
||||
|
||||
[MustDisposeResource]
|
||||
public static unsafe SDLArray<SDL_PenID>? SDL_GetPens()
|
||||
{
|
||||
int count;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace SDL
|
||||
{
|
||||
|
|
@ -10,6 +11,7 @@ namespace SDL
|
|||
|
||||
public static partial class SDL3
|
||||
{
|
||||
[MustDisposeResource]
|
||||
public static unsafe SDLArray<SDL_SensorID>? SDL_GetSensors()
|
||||
{
|
||||
int count;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace SDL
|
||||
{
|
||||
|
|
@ -19,6 +20,7 @@ namespace SDL
|
|||
[Constant]
|
||||
public const SDL_TouchID SDL_MOUSE_TOUCHID = unchecked((SDL_TouchID)(-1));
|
||||
|
||||
[MustDisposeResource]
|
||||
public static unsafe SDLArray<SDL_TouchID>? SDL_GetTouchDevices()
|
||||
{
|
||||
int count;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace SDL
|
||||
{
|
||||
|
|
@ -54,6 +55,7 @@ namespace SDL
|
|||
[Macro]
|
||||
public static bool SDL_WINDOWPOS_ISCENTERED(int X) => (((X) & 0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK);
|
||||
|
||||
[MustDisposeResource]
|
||||
public static unsafe SDLArray<SDL_DisplayID>? SDL_GetDisplays()
|
||||
{
|
||||
int count;
|
||||
|
|
@ -61,6 +63,7 @@ namespace SDL
|
|||
return SDLArray.Create(array, count);
|
||||
}
|
||||
|
||||
[MustDisposeResource]
|
||||
public static unsafe SDLPointerArray<SDL_DisplayMode>? SDL_GetFullscreenDisplayModes(SDL_DisplayID displayID)
|
||||
{
|
||||
int count;
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@
|
|||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace SDL
|
||||
{
|
||||
[MustDisposeResource]
|
||||
public sealed unsafe class SDLArray<T> : IDisposable
|
||||
where T : unmanaged
|
||||
{
|
||||
|
|
@ -41,6 +43,7 @@ namespace SDL
|
|||
|
||||
internal static unsafe class SDLArray
|
||||
{
|
||||
[MustDisposeResource]
|
||||
internal static SDLArray<T>? Create<T>(T* array, int count)
|
||||
where T : unmanaged
|
||||
{
|
||||
|
|
@ -50,6 +53,7 @@ namespace SDL
|
|||
return new SDLArray<T>(array, count);
|
||||
}
|
||||
|
||||
[MustDisposeResource]
|
||||
internal static SDLPointerArray<T>? Create<T>(T** array, int count)
|
||||
where T : unmanaged
|
||||
{
|
||||
|
|
@ -58,6 +62,5 @@ namespace SDL
|
|||
|
||||
return new SDLPointerArray<T>(array, count);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@
|
|||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace SDL
|
||||
{
|
||||
// T* can't be used as a type parameter, so this has to be a separate class
|
||||
[MustDisposeResource]
|
||||
public sealed unsafe class SDLPointerArray<T> : IDisposable
|
||||
where T : unmanaged
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue