1
1
using System ;
2
2
using System . Runtime . InteropServices ;
3
3
using System . Security ;
4
- #if ( UCS4 )
4
+ #if UCS4
5
5
using System . Text ;
6
6
using Mono . Unix ;
7
-
8
- #endif
9
-
10
- #if ( UCS2 && PYTHON3 )
7
+ #elif UCS2 && PYTHON3
11
8
using System . Text ;
12
9
#endif
13
10
@@ -16,7 +13,7 @@ namespace Python.Runtime
16
13
[ SuppressUnmanagedCodeSecurityAttribute ( ) ]
17
14
static class NativeMethods
18
15
{
19
- #if ( MONO_LINUX || MONO_OSX )
16
+ #if MONO_LINUX || MONO_OSX
20
17
static public IntPtr LoadLibrary ( string fileName ) {
21
18
return dlopen ( fileName , RTLD_NOW | RTLD_SHARED ) ;
22
19
}
@@ -40,7 +37,7 @@ static public IntPtr GetProcAddress(IntPtr dllHandle, string name) {
40
37
return res ;
41
38
}
42
39
43
- #if ( MONO_OSX )
40
+ #if MONO_OSX
44
41
static int RTLD_NOW = 0x2 ;
45
42
static int RTLD_SHARED = 0x20 ;
46
43
static IntPtr RTLD_DEFAULT = new IntPtr ( - 2 ) ;
@@ -56,7 +53,7 @@ static public IntPtr GetProcAddress(IntPtr dllHandle, string name) {
56
53
57
54
[ DllImport ( "__Internal" ) ]
58
55
private static extern IntPtr dlerror ( ) ;
59
- #else
56
+ #elif MONO_LINUX
60
57
static int RTLD_NOW = 0x2 ;
61
58
static int RTLD_SHARED = 0x20 ;
62
59
static IntPtr RTLD_DEFAULT = IntPtr . Zero ;
@@ -74,7 +71,7 @@ static public IntPtr GetProcAddress(IntPtr dllHandle, string name) {
74
71
private static extern IntPtr dlerror ( ) ;
75
72
#endif
76
73
77
- #else
74
+ #else // Windows
78
75
[ DllImport ( "kernel32.dll" ) ]
79
76
public static extern IntPtr LoadLibrary ( string dllToLoad ) ;
80
77
@@ -93,13 +90,11 @@ public class Runtime
93
90
/// the responsibility of the caller to have acquired the GIL
94
91
/// before calling any of these methods.
95
92
/// </summary>
96
- #if ( UCS4 )
93
+ #if UCS4
97
94
public const int UCS = 4 ;
98
- #endif
99
- #if ( UCS2 )
95
+ #elif UCS2
100
96
public const int UCS = 2 ;
101
- #endif
102
- #if ! ( UCS2 || UCS4 )
97
+ #else
103
98
#error You must define either UCS2 or UCS4!
104
99
#endif
105
100
@@ -156,23 +151,23 @@ public class Runtime
156
151
#endif
157
152
#endif
158
153
159
- #if ( PYTHON_WITH_PYDEBUG )
154
+ #if PYTHON_WITH_PYDEBUG
160
155
internal const string dllWithPyDebug = "d" ;
161
156
#else
162
157
internal const string dllWithPyDebug = "" ;
163
158
#endif
164
- #if ( PYTHON_WITH_PYMALLOC )
159
+ #if PYTHON_WITH_PYMALLOC
165
160
internal const string dllWithPyMalloc = "m" ;
166
161
#else
167
162
internal const string dllWithPyMalloc = "" ;
168
163
#endif
169
- #if ( PYTHON_WITH_WIDE_UNICODE )
164
+ #if PYTHON_WITH_WIDE_UNICODE
170
165
internal const string dllWithWideUnicode = "u" ;
171
166
#else
172
167
internal const string dllWithWideUnicode = "" ;
173
168
#endif
174
169
175
- #if ( PYTHON_WITHOUT_ENABLE_SHARED )
170
+ #if PYTHON_WITHOUT_ENABLE_SHARED
176
171
public const string dll = "__Internal" ;
177
172
#else
178
173
public const string dll = dllBase + dllWithPyDebug + dllWithPyMalloc + dllWithWideUnicode ;
@@ -504,7 +499,7 @@ internal static Type[] PythonArgsToTypeArray(IntPtr arg, bool mangleObjects)
504
499
505
500
internal unsafe static void XIncref ( IntPtr op )
506
501
{
507
- #if ( Py_DEBUG )
502
+ #if Py_DEBUG
508
503
// according to Python doc, Py_IncRef() is Py_XINCREF()
509
504
Py_IncRef ( op ) ;
510
505
return ;
@@ -526,7 +521,7 @@ internal unsafe static void XIncref(IntPtr op)
526
521
527
522
internal static unsafe void XDecref ( IntPtr op )
528
523
{
529
- #if ( Py_DEBUG )
524
+ #if Py_DEBUG
530
525
// Py_DecRef calls Python's Py_DECREF
531
526
// according to Python doc, Py_DecRef() is Py_XDECREF()
532
527
Py_DecRef ( op ) ;
@@ -581,7 +576,7 @@ internal unsafe static long Refcount(IntPtr op)
581
576
return 0 ;
582
577
}
583
578
584
- #if ( Py_DEBUG )
579
+ #if Py_DEBUG
585
580
// Py_IncRef and Py_DecRef are taking care of the extra payload
586
581
// in Py_DEBUG builds of Python like _Py_RefTotal
587
582
[ DllImport ( Runtime . dll , CallingConvention = CallingConvention . Cdecl ,
@@ -892,7 +887,7 @@ internal unsafe static IntPtr
892
887
{
893
888
return IntPtr . Zero ;
894
889
}
895
- #if ( Py_DEBUG )
890
+ #if Py_DEBUG
896
891
int n = 3 ;
897
892
#else
898
893
int n = 1 ;
0 commit comments