File tree 4 files changed +54
-8
lines changed
4 files changed +54
-8
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,13 @@ public void TestBasic()
25
25
Assert . That ( exit != null , SDL_GetError ) ;
26
26
SetCallback ( exit , ( ) => running = false ) ;
27
27
28
+ var entries = SDL_GetTrayEntries ( RootMenu ) ;
29
+ Assert . That ( entries , Is . Not . Null , SDL_GetError ) ;
30
+ Assert . That ( entries ! . Count , Is . EqualTo ( 3 ) ) ;
31
+
32
+ for ( int i = 0 ; i < entries . Count ; i ++ )
33
+ Console . WriteLine ( $ "{ i } . { SDL_GetTrayEntryLabel ( entries [ i ] ) ?? "<null>" } ") ;
34
+
28
35
running = true ;
29
36
30
37
while ( running )
Original file line number Diff line number Diff line change @@ -18,13 +18,11 @@ public enum SDL_TrayEntryFlags : UInt32
18
18
19
19
public static partial class SDL3
20
20
{
21
- // The code below is currently incorrect because of https://github.com/libsdl-org/SDL/issues/11787.
22
- // [MustDisposeResource]
23
- // public static unsafe SDLOpaquePointerArray<SDL_TrayEntry>? SDL_GetTrayEntries(SDL_TrayMenu* menu)
24
- // {
25
- // int count;
26
- // var array = SDL_GetTrayEntries(menu, &count);
27
- // return SDLArray.CreateOpaque(array, count);
28
- // }
21
+ public static unsafe SDLConstOpaquePointerArray < SDL_TrayEntry > ? SDL_GetTrayEntries ( SDL_TrayMenu * menu )
22
+ {
23
+ int count ;
24
+ var array = SDL_GetTrayEntries ( menu , & count ) ;
25
+ return SDLArray . CreateConstOpaque ( array , count ) ;
26
+ }
29
27
}
30
28
}
Original file line number Diff line number Diff line change @@ -73,5 +73,14 @@ internal static unsafe class SDLArray
73
73
74
74
return new SDLOpaquePointerArray < T > ( array , count ) ;
75
75
}
76
+
77
+ internal static SDLConstOpaquePointerArray < T > ? CreateConstOpaque < T > ( T * * array , int count )
78
+ where T : unmanaged
79
+ {
80
+ if ( array == null )
81
+ return null ;
82
+
83
+ return new SDLConstOpaquePointerArray < T > ( array , count ) ;
84
+ }
76
85
}
77
86
}
Original file line number Diff line number Diff line change
1
+
// Copyright (c) ppy Pty Ltd <[email protected] >. Licensed under the MIT Licence.
2
+ // See the LICENCE file in the repository root for full licence text.
3
+
4
+ using System ;
5
+ using System . Diagnostics ;
6
+
7
+ namespace SDL
8
+ {
9
+ public sealed unsafe class SDLConstOpaquePointerArray < T >
10
+ where T : unmanaged
11
+ {
12
+ private readonly T * * array ;
13
+ public readonly int Count ;
14
+
15
+ internal SDLConstOpaquePointerArray ( T * * array , int count )
16
+ {
17
+ this . array = array ;
18
+ Count = count ;
19
+ }
20
+
21
+ public T * this [ int index ]
22
+ {
23
+ get
24
+ {
25
+ ArgumentOutOfRangeException . ThrowIfNegative ( index ) ;
26
+ ArgumentOutOfRangeException . ThrowIfGreaterThanOrEqual ( index , Count ) ;
27
+ Debug . Assert ( array [ index ] != null ) ;
28
+ return array [ index ] ;
29
+ }
30
+ }
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments