11using System ;
22using System . Runtime . InteropServices ;
33using System . Security ;
4- #if ( UCS4 )
4+ #if UCS4
55using System . Text ;
66using Mono . Unix ;
7-
8- #endif
9-
10- #if ( UCS2 && PYTHON3 )
7+ #elif UCS2 && PYTHON3
118using System . Text ;
129#endif
1310
@@ -16,7 +13,7 @@ namespace Python.Runtime
1613 [ SuppressUnmanagedCodeSecurityAttribute ( ) ]
1714 static class NativeMethods
1815 {
19- #if ( MONO_LINUX || MONO_OSX )
16+ #if MONO_LINUX || MONO_OSX
2017 static public IntPtr LoadLibrary ( string fileName ) {
2118 return dlopen ( fileName , RTLD_NOW | RTLD_SHARED ) ;
2219 }
@@ -40,7 +37,7 @@ static public IntPtr GetProcAddress(IntPtr dllHandle, string name) {
4037 return res ;
4138 }
4239
43- #if ( MONO_OSX )
40+ #if MONO_OSX
4441 static int RTLD_NOW = 0x2 ;
4542 static int RTLD_SHARED = 0x20 ;
4643 static IntPtr RTLD_DEFAULT = new IntPtr ( - 2 ) ;
@@ -56,7 +53,7 @@ static public IntPtr GetProcAddress(IntPtr dllHandle, string name) {
5653
5754 [ DllImport ( "__Internal" ) ]
5855 private static extern IntPtr dlerror ( ) ;
59- #else
56+ #elif MONO_LINUX
6057 static int RTLD_NOW = 0x2 ;
6158 static int RTLD_SHARED = 0x20 ;
6259 static IntPtr RTLD_DEFAULT = IntPtr . Zero ;
@@ -74,7 +71,7 @@ static public IntPtr GetProcAddress(IntPtr dllHandle, string name) {
7471 private static extern IntPtr dlerror ( ) ;
7572#endif
7673
77- #else
74+ #else // Windows
7875 [ DllImport ( "kernel32.dll" ) ]
7976 public static extern IntPtr LoadLibrary ( string dllToLoad ) ;
8077
@@ -93,13 +90,11 @@ public class Runtime
9390 /// the responsibility of the caller to have acquired the GIL
9491 /// before calling any of these methods.
9592 /// </summary>
96- #if ( UCS4 )
93+ #if UCS4
9794 public const int UCS = 4 ;
98- #endif
99- #if ( UCS2 )
95+ #elif UCS2
10096 public const int UCS = 2 ;
101- #endif
102- #if ! ( UCS2 || UCS4 )
97+ #else
10398#error You must define either UCS2 or UCS4!
10499#endif
105100
@@ -156,23 +151,23 @@ public class Runtime
156151#endif
157152#endif
158153
159- #if ( PYTHON_WITH_PYDEBUG )
154+ #if PYTHON_WITH_PYDEBUG
160155 internal const string dllWithPyDebug = "d" ;
161156#else
162157 internal const string dllWithPyDebug = "" ;
163158#endif
164- #if ( PYTHON_WITH_PYMALLOC )
159+ #if PYTHON_WITH_PYMALLOC
165160 internal const string dllWithPyMalloc = "m" ;
166161#else
167162 internal const string dllWithPyMalloc = "" ;
168163#endif
169- #if ( PYTHON_WITH_WIDE_UNICODE )
164+ #if PYTHON_WITH_WIDE_UNICODE
170165 internal const string dllWithWideUnicode = "u" ;
171166#else
172167 internal const string dllWithWideUnicode = "" ;
173168#endif
174169
175- #if ( PYTHON_WITHOUT_ENABLE_SHARED )
170+ #if PYTHON_WITHOUT_ENABLE_SHARED
176171 public const string dll = "__Internal" ;
177172#else
178173 public const string dll = dllBase + dllWithPyDebug + dllWithPyMalloc + dllWithWideUnicode ;
@@ -504,7 +499,7 @@ internal static Type[] PythonArgsToTypeArray(IntPtr arg, bool mangleObjects)
504499
505500 internal unsafe static void XIncref ( IntPtr op )
506501 {
507- #if ( Py_DEBUG )
502+ #if Py_DEBUG
508503 // according to Python doc, Py_IncRef() is Py_XINCREF()
509504 Py_IncRef ( op ) ;
510505 return ;
@@ -526,7 +521,7 @@ internal unsafe static void XIncref(IntPtr op)
526521
527522 internal static unsafe void XDecref ( IntPtr op )
528523 {
529- #if ( Py_DEBUG )
524+ #if Py_DEBUG
530525 // Py_DecRef calls Python's Py_DECREF
531526 // according to Python doc, Py_DecRef() is Py_XDECREF()
532527 Py_DecRef ( op ) ;
@@ -581,7 +576,7 @@ internal unsafe static long Refcount(IntPtr op)
581576 return 0 ;
582577 }
583578
584- #if ( Py_DEBUG )
579+ #if Py_DEBUG
585580 // Py_IncRef and Py_DecRef are taking care of the extra payload
586581 // in Py_DEBUG builds of Python like _Py_RefTotal
587582 [ DllImport ( Runtime . dll , CallingConvention = CallingConvention . Cdecl ,
@@ -892,7 +887,7 @@ internal unsafe static IntPtr
892887 {
893888 return IntPtr . Zero ;
894889 }
895- #if ( Py_DEBUG )
890+ #if Py_DEBUG
896891 int n = 3 ;
897892#else
898893 int n = 1 ;
0 commit comments