Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 445531d

Browse files
committed
Style clean-up runtime.cs
1 parent 044edfe commit 445531d

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

src/runtime/runtime.cs

+18-19
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public class Runtime
115115
#elif PYTHON36
116116
public const string pyversion = "3.6";
117117
public const string pyver = "36";
118-
#elif PYTHON37 // TODO: Add interop37 after Python3.7 is released
118+
#elif PYTHON37 // TODO: Add `interop37.cs` after PY37 is released
119119
public const string pyversion = "3.7";
120120
public const string pyver = "37";
121121
#else
@@ -154,7 +154,7 @@ public class Runtime
154154

155155
// set to true when python is finalizing
156156
internal static object IsFinalizingLock = new object();
157-
internal static bool IsFinalizing = false;
157+
internal static bool IsFinalizing;
158158

159159
internal static bool Is32Bit;
160160
internal static bool IsPython2;
@@ -401,7 +401,7 @@ internal static IntPtr GetBoundArgTuple(IntPtr obj, IntPtr args)
401401
PyTuple_SetItem(items, 0, obj);
402402
XIncref(obj);
403403

404-
for (int i = 0; i < size; i++)
404+
for (var i = 0; i < size; i++)
405405
{
406406
IntPtr item = PyTuple_GetItem(args, i);
407407
XIncref(item);
@@ -419,14 +419,14 @@ internal static IntPtr ExtendTuple(IntPtr t, params IntPtr[] args)
419419
IntPtr item;
420420

421421
IntPtr items = PyTuple_New(size + add);
422-
for (int i = 0; i < size; i++)
422+
for (var i = 0; i < size; i++)
423423
{
424424
item = PyTuple_GetItem(t, i);
425425
XIncref(item);
426426
PyTuple_SetItem(items, i, item);
427427
}
428428

429-
for (int n = 0; n < add; n++)
429+
for (var n = 0; n < add; n++)
430430
{
431431
item = args[n];
432432
XIncref(item);
@@ -447,7 +447,7 @@ internal static Type[] PythonArgsToTypeArray(IntPtr arg, bool mangleObjects)
447447
// tuple of (managed or unmanaged) type objects, return a Type[]
448448
// containing the CLR Type objects that map to those types.
449449
IntPtr args = arg;
450-
bool free = false;
450+
var free = false;
451451

452452
if (!PyTuple_Check(arg))
453453
{
@@ -458,10 +458,10 @@ internal static Type[] PythonArgsToTypeArray(IntPtr arg, bool mangleObjects)
458458
}
459459

460460
int n = PyTuple_Size(args);
461-
Type[] types = new Type[n];
461+
var types = new Type[n];
462462
Type t = null;
463463

464-
for (int i = 0; i < n; i++)
464+
for (var i = 0; i < n; i++)
465465
{
466466
IntPtr op = PyTuple_GetItem(args, i);
467467
if (mangleObjects && (!PyType_Check(op)))
@@ -513,7 +513,7 @@ internal static unsafe void XIncref(IntPtr op)
513513
Py_IncRef(op);
514514
return;
515515
#else
516-
void* p = (void*)op;
516+
var p = (void*)op;
517517
if ((void*)0 != p)
518518
{
519519
if (Is32Bit)
@@ -536,7 +536,7 @@ internal static unsafe void XDecref(IntPtr op)
536536
Py_DecRef(op);
537537
return;
538538
#else
539-
void* p = (void*)op;
539+
var p = (void*)op;
540540
if ((void*)0 != p)
541541
{
542542
if (Is32Bit)
@@ -562,15 +562,14 @@ internal static unsafe void XDecref(IntPtr op)
562562
return;
563563
}
564564
NativeCall.Impl.Void_Call_1(new IntPtr(f), op);
565-
return;
566565
}
567566
}
568567
#endif
569568
}
570569

571570
internal static unsafe long Refcount(IntPtr op)
572571
{
573-
void* p = (void*)op;
572+
var p = (void*)op;
574573
if ((void*)0 != p)
575574
{
576575
if (Is32Bit)
@@ -786,15 +785,15 @@ internal static extern void Py_SetPath(
786785
/// </summary>
787786
internal static unsafe IntPtr PyObject_TYPE(IntPtr op)
788787
{
789-
void* p = (void*)op;
788+
var p = (void*)op;
790789
if ((void*)0 == p)
791790
{
792791
return IntPtr.Zero;
793792
}
794793
#if Py_DEBUG
795-
int n = 3;
794+
var n = 3;
796795
#else
797-
int n = 1;
796+
var n = 1;
798797
#endif
799798
if (Is32Bit)
800799
{
@@ -966,13 +965,13 @@ internal static bool PyBool_Check(IntPtr ob)
966965

967966
internal static IntPtr PyInt_FromInt32(int value)
968967
{
969-
IntPtr v = new IntPtr(value);
968+
var v = new IntPtr(value);
970969
return PyInt_FromLong(v);
971970
}
972971

973972
internal static IntPtr PyInt_FromInt64(long value)
974973
{
975-
IntPtr v = new IntPtr(value);
974+
var v = new IntPtr(value);
976975
return PyInt_FromLong(v);
977976
}
978977

@@ -1285,7 +1284,7 @@ int size
12851284

12861285
internal static IntPtr PyUnicode_FromString(string s)
12871286
{
1288-
return PyUnicode_FromUnicode(s, (s.Length));
1287+
return PyUnicode_FromUnicode(s, s.Length);
12891288
}
12901289

12911290
/// <summary>
@@ -1463,7 +1462,7 @@ internal static bool PyTuple_Check(IntPtr ob)
14631462
#elif PYTHON3
14641463
internal static bool PyIter_Check(IntPtr pointer)
14651464
{
1466-
IntPtr ob_type = (IntPtr)Marshal.PtrToStructure(pointer + ObjectOffset.ob_type, typeof(IntPtr));
1465+
var ob_type = (IntPtr)Marshal.PtrToStructure(pointer + ObjectOffset.ob_type, typeof(IntPtr));
14671466
IntPtr tp_iternext = ob_type + TypeOffset.tp_iternext;
14681467
return tp_iternext != null && tp_iternext != _PyObject_NextNotImplemented;
14691468
}

0 commit comments

Comments
 (0)