Skip to content

Commit 2b6f815

Browse files
committed
Clarify MashalAs on runtime.cs
- Shorten MarshalAsAttribute name - Put MashalAs'ed argument on own-line - Flip IF comparison
1 parent e8c2294 commit 2b6f815

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/runtime/runtime.cs

+10-7
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,13 @@ internal static void Initialize()
290290

291291
#if PYTHON3
292292
IntPtr dll = IntPtr.Zero;
293-
if ("__Internal" != Runtime.dll)
293+
if (Runtime.dll != "__Internal")
294294
{
295295
NativeMethods.LoadLibrary(Runtime.dll);
296296
}
297297
_PyObject_NextNotImplemented = NativeMethods.GetProcAddress(dll, "_PyObject_NextNotImplemented");
298298
#if !(MONO_LINUX || MONO_OSX)
299-
if (IntPtr.Zero != dll)
299+
if (dll != IntPtr.Zero)
300300
{
301301
NativeMethods.FreeLibrary(dll);
302302
}
@@ -665,7 +665,10 @@ internal unsafe static extern IntPtr
665665
[DllImport(Runtime.dll, CallingConvention = CallingConvention.Cdecl,
666666
ExactSpelling = true, CharSet = CharSet.Ansi)]
667667
public unsafe static extern int
668-
Py_Main(int argc, [MarshalAsAttribute(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)] string[] argv);
668+
Py_Main(
669+
int argc,
670+
[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)] string[] argv
671+
);
669672
#elif PYTHON2
670673
[DllImport(Runtime.dll, CallingConvention = CallingConvention.Cdecl,
671674
ExactSpelling = true, CharSet = CharSet.Ansi)]
@@ -739,7 +742,7 @@ internal unsafe static extern string
739742
[DllImport(Runtime.dll, CallingConvention = CallingConvention.Cdecl,
740743
ExactSpelling = true, CharSet = CharSet.Ansi)]
741744
internal unsafe static extern void
742-
Py_SetProgramName([MarshalAsAttribute(UnmanagedType.LPWStr)] string name);
745+
Py_SetProgramName([MarshalAs(UnmanagedType.LPWStr)] string name);
743746

744747
[DllImport(Runtime.dll, CallingConvention = CallingConvention.Cdecl,
745748
ExactSpelling = true, CharSet = CharSet.Ansi)]
@@ -750,7 +753,7 @@ internal unsafe static extern string
750753
[DllImport(Runtime.dll, CallingConvention = CallingConvention.Cdecl,
751754
ExactSpelling = true, CharSet = CharSet.Ansi)]
752755
internal unsafe static extern void
753-
Py_SetPythonHome([MarshalAsAttribute(UnmanagedType.LPWStr)] string home);
756+
Py_SetPythonHome([MarshalAs(UnmanagedType.LPWStr)] string home);
754757

755758
[DllImport(Runtime.dll, CallingConvention = CallingConvention.Cdecl,
756759
ExactSpelling = true, CharSet = CharSet.Ansi)]
@@ -761,7 +764,7 @@ internal unsafe static extern string
761764
[DllImport(Runtime.dll, CallingConvention = CallingConvention.Cdecl,
762765
ExactSpelling = true, CharSet = CharSet.Ansi)]
763766
internal unsafe static extern void
764-
Py_SetPath([MarshalAsAttribute(UnmanagedType.LPWStr)] string home);
767+
Py_SetPath([MarshalAs(UnmanagedType.LPWStr)] string home);
765768
#elif PYTHON2
766769
[DllImport(Runtime.dll, CallingConvention = CallingConvention.Cdecl,
767770
ExactSpelling = true, CharSet = CharSet.Ansi)]
@@ -2081,7 +2084,7 @@ internal unsafe static extern IntPtr
20812084
internal unsafe static extern void
20822085
PySys_SetArgvEx(
20832086
int argc,
2084-
[MarshalAsAttribute(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)] string[] argv,
2087+
[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)] string[] argv,
20852088
int updatepath
20862089
);
20872090
#elif PYTHON2

0 commit comments

Comments
 (0)