22// The .NET Foundation licenses this file to you under the Apache 2.0 License.
33// See the LICENSE file in the project root for more information.
44
5+ #nullable enable
6+
57using System ;
68using System . Runtime . InteropServices ;
79using System . Runtime . Versioning ;
1315namespace IronPython . Modules {
1416 public static partial class PythonSignal {
1517 [ SupportedOSPlatform ( "windows" ) ]
16- internal class NtSignalState : PythonSignalState {
17- //We use a single Windows event handler to process all signals. This handler simply
18- //delegates the work out to PySignalToPyHandler.
19- public NativeSignal . WinSignalsHandler WinAllSignalsHandlerDelegate ;
18+ private class NtSignalState : PythonSignalState {
19+ // We use a single Windows event handler to process all signals. This handler simply
20+ // delegates the work out to PySignalToPyHandler.
21+ public NativeWindowsSignal . WinSignalsHandler WinAllSignalsHandlerDelegate ;
22+
2023
2124 public NtSignalState ( PythonContext pc ) : base ( pc ) {
22- WinAllSignalsHandlerDelegate = new NativeSignal . WinSignalsHandler ( WindowsEventHandler ) ;
23- NativeSignal . SetConsoleCtrlHandler ( this . WinAllSignalsHandlerDelegate , true ) ;
25+ WinAllSignalsHandlerDelegate = new NativeWindowsSignal . WinSignalsHandler ( WindowsEventHandler ) ;
26+ NativeWindowsSignal . SetConsoleCtrlHandler ( this . WinAllSignalsHandlerDelegate , true ) ;
2427 }
2528
26- //Our implementation of WinSignalsHandler
29+
30+ // Our implementation of WinSignalsHandler
2731 private bool WindowsEventHandler ( uint winSignal ) {
2832 bool retVal ;
2933 int pySignal ;
@@ -53,27 +57,27 @@ private bool WindowsEventHandler(uint winSignal) {
5357 int tempId = ( int ) PySignalToPyHandler [ pySignal ] ;
5458
5559 if ( tempId == SIG_DFL ) {
56- //SIG_DFL - we let Windows do whatever it normally would
60+ // SIG_DFL - we let Windows do whatever it normally would
5761 retVal = false ;
5862 } else if ( tempId == SIG_IGN ) {
59- //SIG_IGN - we do nothing, but tell Windows we handled the signal
63+ // SIG_IGN - we do nothing, but tell Windows we handled the signal
6064 retVal = true ;
6165 } else {
6266 throw new Exception ( "unreachable" ) ;
6367 }
6468 } else if ( PySignalToPyHandler [ pySignal ] == default_int_handler ) {
6569 if ( pySignal != SIGINT ) {
66- //We're dealing with the default_int_handlerImpl which we
67- //know doesn't care about the frame parameter
70+ // We're dealing with the default_int_handlerImpl which we
71+ // know doesn't care about the frame parameter
6872 retVal = true ;
6973 default_int_handlerImpl ( pySignal , null ) ;
7074 } else {
71- //Let the real interrupt handler throw a KeyboardInterrupt for SIGINT.
72- //It handles this far more gracefully than we can
75+ // Let the real interrupt handler throw a KeyboardInterrupt for SIGINT.
76+ // It handles this far more gracefully than we can
7377 retVal = false ;
7478 }
7579 } else {
76- //We're dealing with a callable matching PySignalHandler's signature
80+ // We're dealing with a callable matching PySignalHandler's signature
7781 retVal = true ;
7882 PySignalHandler temp = ( PySignalHandler ) Converter . ConvertToDelegate ( PySignalToPyHandler [ pySignal ] ,
7983 typeof ( PySignalHandler ) ) ;
@@ -96,7 +100,9 @@ private bool WindowsEventHandler(uint winSignal) {
96100 }
97101 }
98102
99- internal static class NativeSignal {
103+
104+ [ SupportedOSPlatform ( "windows" ) ]
105+ internal static class NativeWindowsSignal {
100106 // Windows API expects to be given a function pointer like this to handle signals
101107 internal delegate bool WinSignalsHandler ( uint winSignal ) ;
102108
0 commit comments