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

Skip to content

Commit e4d10d6

Browse files
committed
Use long instead of int in all places that use Py_ssize_t
1 parent f121c44 commit e4d10d6

12 files changed

+94
-94
lines changed

src/runtime/arrayobject.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public static IntPtr mp_subscript(IntPtr ob, IntPtr idx)
9393
return IntPtr.Zero;
9494
}
9595

96-
int count = Runtime.PyTuple_Size(idx);
96+
var count = Runtime.PyTuple_Size(idx);
9797

9898
var args = new int[count];
9999

@@ -186,7 +186,7 @@ public static int mp_ass_subscript(IntPtr ob, IntPtr idx, IntPtr v)
186186
return -1;
187187
}
188188

189-
int count = Runtime.PyTuple_Size(idx);
189+
var count = Runtime.PyTuple_Size(idx);
190190
var args = new int[count];
191191

192192
for (var i = 0; i < count; i++)

src/runtime/assemblymanager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ private static Assembly ResolveHandler(object ob, ResolveEventArgs args)
140140
internal static void UpdatePath()
141141
{
142142
IntPtr list = Runtime.PySys_GetObject("path");
143-
int count = Runtime.PyList_Size(list);
143+
var count = Runtime.PyList_Size(list);
144144
if (count != pypath.Count)
145145
{
146146
pypath.Clear();

src/runtime/classobject.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ public static int mp_ass_subscript(IntPtr ob, IntPtr idx, IntPtr v)
230230
}
231231

232232
// Get the args passed in.
233-
int i = Runtime.PyTuple_Size(args);
233+
var i = Runtime.PyTuple_Size(args);
234234
IntPtr defaultArgs = cls.indexer.GetDefaultArgs(args);
235-
int numOfDefaultArgs = Runtime.PyTuple_Size(defaultArgs);
236-
int temp = i + numOfDefaultArgs;
235+
var numOfDefaultArgs = Runtime.PyTuple_Size(defaultArgs);
236+
var temp = i + numOfDefaultArgs;
237237
IntPtr real = Runtime.PyTuple_New(temp + 1);
238238
for (var n = 0; n < i; n++)
239239
{

src/runtime/converter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ private static void SetConversionError(IntPtr value, Type target)
842842
private static bool ToArray(IntPtr value, Type obType, out object result, bool setError)
843843
{
844844
Type elementType = obType.GetElementType();
845-
int size = Runtime.PySequence_Size(value);
845+
var size = Runtime.PySequence_Size(value);
846846
result = null;
847847

848848
if (size < 0)

src/runtime/importhook.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw)
155155
// hook is saved as this.py_import. This version handles CLR
156156
// import and defers to the normal builtin for everything else.
157157

158-
int num_args = Runtime.PyTuple_Size(args);
158+
var num_args = Runtime.PyTuple_Size(args);
159159
if (num_args < 1)
160160
{
161161
return Exceptions.RaiseTypeError("__import__() takes at least 1 argument (0 given)");

src/runtime/indexer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ internal void SetItem(IntPtr inst, IntPtr args)
5656

5757
internal bool NeedsDefaultArgs(IntPtr args)
5858
{
59-
int pynargs = Runtime.PyTuple_Size(args);
59+
var pynargs = Runtime.PyTuple_Size(args);
6060
MethodBase[] methods = SetterBinder.GetMethods();
6161
if (methods.Length == 0)
6262
{
@@ -72,7 +72,7 @@ internal bool NeedsDefaultArgs(IntPtr args)
7272
return false;
7373
}
7474

75-
for (int v = pynargs; v < clrnargs; v++)
75+
for (var v = pynargs; v < clrnargs; v++)
7676
{
7777
if (pi[v].DefaultValue == DBNull.Value)
7878
{
@@ -95,7 +95,7 @@ internal IntPtr GetDefaultArgs(IntPtr args)
9595
{
9696
return Runtime.PyTuple_New(0);
9797
}
98-
int pynargs = Runtime.PyTuple_Size(args);
98+
var pynargs = Runtime.PyTuple_Size(args);
9999

100100
// Get the default arg tuple
101101
MethodBase[] methods = SetterBinder.GetMethods();

src/runtime/interfaceobject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static InterfaceObject()
3636
public static IntPtr tp_new(IntPtr tp, IntPtr args, IntPtr kw)
3737
{
3838
var self = (InterfaceObject)GetManagedObject(tp);
39-
int nargs = Runtime.PyTuple_Size(args);
39+
var nargs = Runtime.PyTuple_Size(args);
4040
Type type = self.type;
4141
object obj;
4242

src/runtime/metatype.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static IntPtr Initialize()
2929
/// </summary>
3030
public static IntPtr tp_new(IntPtr tp, IntPtr args, IntPtr kw)
3131
{
32-
int len = Runtime.PyTuple_Size(args);
32+
var len = Runtime.PyTuple_Size(args);
3333
if (len < 3)
3434
{
3535
return Exceptions.RaiseTypeError("invalid argument list");

src/runtime/methodbinder.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw, MethodBase info, Meth
279279
{
280280
// loop to find match, return invoker w/ or /wo error
281281
MethodBase[] _methods = null;
282-
int pynargs = Runtime.PyTuple_Size(args);
282+
var pynargs = (int)Runtime.PyTuple_Size(args);
283283
object arg;
284284
var isGeneric = false;
285285
ArrayList defaultArgList = null;
@@ -301,9 +301,9 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw, MethodBase info, Meth
301301
isGeneric = true;
302302
}
303303
ParameterInfo[] pi = mi.GetParameters();
304-
int clrnargs = pi.Length;
304+
var clrnargs = pi.Length;
305305
var match = false;
306-
int arrayStart = -1;
306+
var arrayStart = -1;
307307
var outs = 0;
308308

309309
if (pynargs == clrnargs)
@@ -314,7 +314,7 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw, MethodBase info, Meth
314314
{
315315
match = true;
316316
defaultArgList = new ArrayList();
317-
for (int v = pynargs; v < clrnargs; v++)
317+
for (var v = pynargs; v < clrnargs; v++)
318318
{
319319
if (pi[v].DefaultValue == DBNull.Value)
320320
{
@@ -338,7 +338,7 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw, MethodBase info, Meth
338338
{
339339
var margs = new object[clrnargs];
340340

341-
for (var n = 0; n < clrnargs; n++)
341+
for (int n = 0; n < clrnargs; n++)
342342
{
343343
IntPtr op;
344344
if (n < pynargs)

src/runtime/methodbinding.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public static IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw)
104104
{
105105
if (self.info.IsGenericMethod)
106106
{
107-
int len = Runtime.PyTuple_Size(args); //FIXME: Never used
107+
var len = Runtime.PyTuple_Size(args); //FIXME: Never used
108108
Type[] sigTp = Runtime.PythonArgsToTypeArray(args, true);
109109
if (sigTp != null)
110110
{
@@ -129,7 +129,7 @@ public static IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw)
129129

130130
if (target == IntPtr.Zero && !self.m.IsStatic())
131131
{
132-
int len = Runtime.PyTuple_Size(args);
132+
var len = Runtime.PyTuple_Size(args);
133133
if (len < 1)
134134
{
135135
Exceptions.SetError(Exceptions.TypeError, "not enough arguments");

src/runtime/pyobject.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,9 @@ public virtual void DelItem(int index)
519519
/// Returns the length for objects that support the Python sequence
520520
/// protocol, or 0 if the object does not support the protocol.
521521
/// </remarks>
522-
public virtual int Length()
522+
public virtual long Length()
523523
{
524-
int s = Runtime.PyObject_Size(obj);
524+
var s = Runtime.PyObject_Size(obj);
525525
if (s < 0)
526526
{
527527
Runtime.PyErr_Clear();

0 commit comments

Comments
 (0)