Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
5d6e5d5
use reference types instead of IntPtr where possible in runtime.cs
lostmsu Oct 17, 2021
2d33902
switched converter.cs to the new style references
lostmsu Oct 17, 2021
f8b761a
switched most of classbase.cs to the new style references (except cro…
lostmsu Oct 17, 2021
09d8e41
switched pyobject.cs to the new style references
lostmsu Oct 17, 2021
1b58cf4
mostly switched moduleobject.cs to the new style references
lostmsu Oct 17, 2021
c05c6ec
switched methodbinder.cs to the new style references
lostmsu Oct 17, 2021
d626f7e
partially switched classderived.cs to the new reference style
lostmsu Oct 17, 2021
ff60ec4
switched arrayobject.cs to the new style references
lostmsu Oct 17, 2021
0010fa0
switched delegatemanager.cs to the new style references
lostmsu Oct 17, 2021
178a359
partially switched metatype.cs to the new style references
lostmsu Oct 18, 2021
9764b25
switched typemanager.cs to the new style references
lostmsu Oct 18, 2021
11edcc3
switched pytype.cs to the new style references
lostmsu Oct 18, 2021
2e71874
mass enable nullable types
lostmsu Oct 18, 2021
3076040
fixed nullablity in arrayobject.cs
lostmsu Oct 18, 2021
56f3bd5
fixed nullability in assemblymanager.cs
lostmsu Oct 18, 2021
58cb0e6
switched classmanager.cs to the new style references
lostmsu Oct 18, 2021
2095b46
switched classobject.cs to the new style references
lostmsu Oct 18, 2021
f6b84da
partially switched managedtype.cs to the new style references
lostmsu Oct 18, 2021
ee65632
partially switched classmanager.cs to the new style references
lostmsu Oct 18, 2021
5266dc4
PyIdentifier public members to return borrowed references
lostmsu Oct 6, 2021
0bc3670
added nullability annotations to methodbinder.cs
lostmsu Oct 18, 2021
de9a8cb
switched methodbinding.cs and methodobject.cs to the new style refere…
lostmsu Oct 18, 2021
9195c30
switched overload.cs to the new style references
lostmsu Oct 18, 2021
590de7a
switched propertyobject.cs to the new style references
lostmsu Oct 18, 2021
7fa537a
switched delegateobject.cs to the new style references
lostmsu Oct 18, 2021
49124fc
switched module.cs to the new style references
lostmsu Oct 18, 2021
9db9b0b
nullability annotations for PyObject
lostmsu Oct 18, 2021
00fd17a
switched modulefunctionobject.cs to the new style references
lostmsu Oct 18, 2021
5798b41
minor refactorings
lostmsu Oct 18, 2021
ebdf7c5
partially switched moduleobject.cs and importhook.cs to the new style…
lostmsu Oct 18, 2021
5ad09e4
switched exceptions.cs to the new style references
lostmsu Oct 18, 2021
d1abd9a
switched interfaceobject.cs to the new style references
lostmsu Oct 18, 2021
43a862a
switched pythonexception.cs to the new style references
lostmsu Oct 18, 2021
1d80162
switched pytuple.cs to the new style references
lostmsu Oct 18, 2021
0241b38
switched eventobject.cs and eventbiding.cs to the new style references
lostmsu Oct 18, 2021
2ac952a
switched all PyObject derived classes to the new style references
lostmsu Oct 18, 2021
7adf98a
implemented non-confusing PyModule_AddObject
lostmsu Oct 18, 2021
2dd3f8f
switched pythonengine.cs to the new style references
lostmsu Oct 18, 2021
3b79019
switched fieldobject.cs and constructorbinding.cs to the new style re…
lostmsu Oct 18, 2021
9b990c1
switched finalizer.cs to the new style references
lostmsu Oct 19, 2021
027e529
switched debughelper.cs to the new style references
lostmsu Oct 19, 2021
4793818
switched converter extensions and sample codecs to the new style refe…
lostmsu Oct 19, 2021
0d60500
switched collection wrappers (from sample codec) to the new style ref…
lostmsu Oct 19, 2021
cf606a2
switched iterator.cs and indexer.cs to the new style references
lostmsu Oct 19, 2021
bb84c48
getting rid of a few minor warnings and compile errors
lostmsu Oct 19, 2021
e295679
switched to new references in some tests
lostmsu Oct 19, 2021
7a9e411
switched state serialization to new reference types (untested)
lostmsu Oct 19, 2021
9a9ed3b
minor error fixes
lostmsu Oct 19, 2021
581f695
assume remaning manual refcounting is not needed, because we use smar…
lostmsu Oct 19, 2021
07f1657
fixed new reference uses, that are not allowed in C#
lostmsu Oct 19, 2021
7deebd4
renamed parameter in tp_dealloc functions for clarity
lostmsu Oct 19, 2021
8619e77
allowed untested calls to PyObject_GC_Del and XDecref (3 in total)
lostmsu Oct 19, 2021
672aef6
fixed compile errors in TypeMethod (untested)
lostmsu Oct 19, 2021
c4909d4
workaround for analyzer not permitting copying a reference as the las…
lostmsu Oct 19, 2021
6fa2004
switched tests to match the new reference changes
lostmsu Oct 19, 2021
14949fb
fixed thunk loading for slots, that use new reference types
lostmsu Oct 19, 2021
0728e21
fixed PyObject_DelAttr load from DLL failing
lostmsu Oct 19, 2021
fe4c481
fixed uses of Marshal.Read/Marshal.Write overloads with first argumen…
lostmsu Oct 19, 2021
4346d41
fixed OnSerialized and OnDeserialized in PyObject not being typed cor…
lostmsu Oct 19, 2021
62e193a
fixed bad equality comparisons
lostmsu Oct 20, 2021
2fa8b9c
improved reliability of Clean and Dealloc implementations
lostmsu Oct 20, 2021
d6607b0
bad if condition
lostmsu Oct 20, 2021
6335d97
improved GetThunk reliability
lostmsu Oct 20, 2021
d649d6c
fixed circular dependency in Runtime PyMembers and InternString initi…
lostmsu Oct 20, 2021
d1bc193
tiny refactor
lostmsu Oct 20, 2021
32c4bb6
switched generictype.cs to the new style references
lostmsu Oct 20, 2021
a1427ac
increfs in OnSave are no longer necessary with the new references
lostmsu Oct 20, 2021
cd97a46
fixed MethodBinding failing for reference types
lostmsu Oct 20, 2021
05ecbcf
nullability annotation fix in MaybeMethodBase
lostmsu Oct 20, 2021
a3591b6
minor improvements
lostmsu Oct 20, 2021
7ed0c7a
WIP
lostmsu Oct 24, 2021
d6a853f
avoid generating and handling useless SerializationException when May…
lostmsu Oct 28, 2021
b0c25c1
finalizer does not attempt to finalize objects when runtime is shut down
lostmsu Oct 28, 2021
5ca474a
PyType Dict and MRO properties to assist debugging
lostmsu Oct 28, 2021
48078b3
WIP 2
lostmsu Oct 28, 2021
a624dd8
fixed PyObject disposal crashing when runtime is still finalizing
lostmsu Oct 29, 2021
e7ab071
arrays: use 64 bit indexing, and avoid first chance .NET exceptions o…
lostmsu Oct 29, 2021
cbe1dd2
refactored conditional ClassBase slot initialization
lostmsu Oct 29, 2021
d5f1c48
removed DisposePythonWrappersForClrTypes
lostmsu Oct 29, 2021
74d87c5
simplified outdated condition in ClassBase.tp_clear
lostmsu Oct 29, 2021
82d6c33
sprinkled a few DebuggerHidden to make debugging easier
lostmsu Oct 29, 2021
eeebcd7
fixed derived classes not inheriting slots correctly
lostmsu Oct 29, 2021
8ee8d3d
remove unused TypeManager._slotImpls
lostmsu Oct 29, 2021
1a4ada7
fixed TestRuntime not building in Release mode
lostmsu Oct 30, 2021
a610aa3
can't really clear managed references to Python objects from ManagedT…
lostmsu Oct 30, 2021
03f32cb
PythonException is serializable
lostmsu Oct 30, 2021
b1c9f5b
EventObject no longer used for static events. EventBinding is constru…
lostmsu Oct 30, 2021
cb4bb9a
use a special class to stub .NET types that no longer exist after a d…
lostmsu Nov 2, 2021
652f946
make EventHandlerCollection serializable
lostmsu Nov 2, 2021
84db670
fixed MaybeMemberInfo always failing for properties
lostmsu Nov 2, 2021
56fafe3
fixed construct_removed_class domain reload test case
lostmsu Nov 2, 2021
d33dcdd
domain reload test runner can run test by index
lostmsu Nov 2, 2021
b737e10
minor docs change
lostmsu Nov 2, 2021
d3e4fba
assert check in GetUnmanagedBaseType for null base
lostmsu Nov 2, 2021
e003e12
PythonEngine .Exec and .Eval no longer work with raw pointers
lostmsu Nov 9, 2021
d0a6f44
a few annotation to ease debugging
lostmsu Nov 9, 2021
e31f7ba
ensure Python types continue to exist when registered decoders for th…
lostmsu Nov 9, 2021
48c0dfc
GC-related WIP
lostmsu Nov 9, 2021
44d65d9
merge latest master
lostmsu Nov 23, 2021
cb58147
merge latest changes from upstream
lostmsu Nov 23, 2021
2fdbf0e
added TraceAlloc solution configuration
lostmsu Nov 24, 2021
a8ef06c
fixed sending PyObject across domain boundary
lostmsu Nov 24, 2021
7167229
fixed accidental premature disposal of Runtime.PyNone
lostmsu Nov 24, 2021
ab11fa2
made freeing GCHandles more robust
lostmsu Nov 24, 2021
7a4daeb
removed bad assert in generated constructor for derived classes
lostmsu Nov 24, 2021
e422367
fixed __pyobj__ access
lostmsu Nov 24, 2021
a74ea86
minor
lostmsu Nov 24, 2021
0325a8c
fixed Python derived types trying to double-free GCHandle when collec…
lostmsu Nov 24, 2021
85fab3b
reinstate collection assert on shutdown from Python
lostmsu Nov 24, 2021
932fce2
fixed crash when Python derived class instances survive past early sh…
lostmsu Nov 24, 2021
c2e207a
delay nulling GC handles of reflected instances until the last moment…
lostmsu Nov 24, 2021
c8f0f09
fixed assert in XDecref in case _Py_IsFinalizing is not present
lostmsu Nov 24, 2021
e269cf0
when initialized from Python, reset slots implemented in CLR: CLR mig…
lostmsu Nov 25, 2021
d7d5cb7
fixed minor warnings
lostmsu Nov 25, 2021
d6edace
fixed line endings in intern_.cs
lostmsu Nov 25, 2021
a86994f
use NonCopyableAnalyzer 0.7.0-m05
lostmsu Nov 25, 2021
2e040ea
Merge pull request #2 from losttech/ManagedType-DontKeepBorrowedRefs
lostmsu Dec 9, 2021
b614dba
merge latest master
lostmsu Dec 9, 2021
f09a48b
fixed MacOS bad assembly test by using PythonDLL (which is never a .N…
lostmsu Dec 9, 2021
3794fea
Merge branch 'master' into precise-API-references
lostmsu Dec 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed thunk loading for slots, that use new reference types
  • Loading branch information
lostmsu committed Oct 19, 2021
commit 14949fbedfaf197ed8b47c0aca186eaf4f11b4cf
46 changes: 46 additions & 0 deletions src/runtime/Reflection/ParameterHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Reflection;

namespace Python.Runtime.Reflection;

[Serializable]
struct ParameterHelper : IEquatable<ParameterInfo>
{
public readonly string TypeName;
public readonly ParameterModifier Modifier;

public ParameterHelper(ParameterInfo tp)
{
TypeName = tp.ParameterType.AssemblyQualifiedName;
Modifier = ParameterModifier.None;

if (tp.IsIn && tp.ParameterType.IsByRef)
{
Modifier = ParameterModifier.In;
}
else if (tp.IsOut && tp.ParameterType.IsByRef)
{
Modifier = ParameterModifier.Out;
}
else if (tp.ParameterType.IsByRef)
{
Modifier = ParameterModifier.Ref;
}
}

public bool Equals(ParameterInfo other)
{
return this.Equals(new ParameterHelper(other));
}

public bool Matches(ParameterInfo other) => this.Equals(other);
}

enum ParameterModifier
{
None,
In,
Out,
Ref
}
41 changes: 3 additions & 38 deletions src/runtime/StateSerialization/MaybeMethodBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System.Runtime.Serialization;
using System.Linq;

using Python.Runtime.Reflection;

namespace Python.Runtime
{
[Serializable]
Expand All @@ -17,43 +19,6 @@ internal struct MaybeMethodBase<T> : ISerializable where T: MethodBase
const string SerializationIsCtor = "c";
const string SerializationMethodName = "n";

[Serializable]
struct ParameterHelper : IEquatable<ParameterInfo>
{
public enum TypeModifier
{
None,
In,
Out,
Ref
}
public readonly string Name;
public readonly TypeModifier Modifier;

public ParameterHelper(ParameterInfo tp)
{
Name = tp.ParameterType.AssemblyQualifiedName;
Modifier = TypeModifier.None;

if (tp.IsIn && tp.ParameterType.IsByRef)
{
Modifier = TypeModifier.In;
}
else if (tp.IsOut && tp.ParameterType.IsByRef)
{
Modifier = TypeModifier.Out;
}
else if (tp.ParameterType.IsByRef)
{
Modifier = TypeModifier.Ref;
}
}

public bool Equals(ParameterInfo other)
{
return this.Equals(new ParameterHelper(other));
}
}
public static implicit operator MaybeMethodBase<T> (T ob) => new MaybeMethodBase<T>(ob);

string name;
Expand Down Expand Up @@ -119,7 +84,7 @@ internal MaybeMethodBase(SerializationInfo serializationInfo, StreamingContext c
bool hasRefType = false;
for (int i = 0; i < param.Length; i++)
{
var paramTypeName = param[i].Name;
var paramTypeName = param[i].TypeName;
types[i] = Type.GetType(paramTypeName);
if (types[i] == null)
{
Expand Down
163 changes: 38 additions & 125 deletions src/runtime/interop.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using Python.Runtime.Reflection;
using System.Reflection;
using System.Text;

namespace Python.Runtime
{
Expand Down Expand Up @@ -120,110 +120,38 @@ public enum TypeFlags: int

internal class Interop
{
private static Hashtable pmap;
static readonly Dictionary<MethodInfo, Type> delegateTypes = new();

static Interop()
internal static Type GetPrototype(MethodInfo method)
{
// Here we build a mapping of PyTypeObject slot names to the
// appropriate prototype (delegate) type to use for the slot.
if (delegateTypes.TryGetValue(method, out var delegateType))
return delegateType;

Type[] items = typeof(Interop).GetNestedTypes();
Hashtable p = new Hashtable();
var parameters = method.GetParameters().Select(p => new ParameterHelper(p)).ToArray();

for (int i = 0; i < items.Length; i++)
foreach (var candidate in typeof(Interop).GetNestedTypes())
{
Type item = items[i];
p[item.Name] = item;
}
if (!typeof(Delegate).IsAssignableFrom(candidate))
continue;

pmap = new Hashtable();

pmap["tp_dealloc"] = p["DestructorFunc"];
pmap["tp_print"] = p["PrintFunc"];
pmap["tp_getattr"] = p["BinaryFunc"];
pmap["tp_setattr"] = p["ObjObjArgFunc"];
pmap["tp_compare"] = p["ObjObjFunc"];
pmap["tp_repr"] = p["UnaryFunc"];
pmap["tp_hash"] = p["UnaryFunc"];
pmap["tp_call"] = p["TernaryFunc"];
pmap["tp_str"] = p["UnaryFunc"];
pmap["tp_getattro"] = p["BinaryFunc"];
pmap["tp_setattro"] = p["ObjObjArgFunc"];
pmap["tp_traverse"] = p["ObjObjArgFunc"];
pmap["tp_clear"] = p["InquiryFunc"];
pmap["tp_richcompare"] = p["RichCmpFunc"];
pmap["tp_iter"] = p["UnaryFunc"];
pmap["tp_iternext"] = p["UnaryFunc"];
pmap["tp_descr_get"] = p["TernaryFunc"];
pmap["tp_descr_set"] = p["ObjObjArgFunc"];
pmap["tp_init"] = p["ObjObjArgFunc"];
pmap["tp_alloc"] = p["IntArgFunc"];
pmap["tp_new"] = p["TernaryFunc"];
pmap["tp_free"] = p["DestructorFunc"];
pmap["tp_is_gc"] = p["InquiryFunc"];

pmap["nb_add"] = p["BinaryFunc"];
pmap["nb_subtract"] = p["BinaryFunc"];
pmap["nb_multiply"] = p["BinaryFunc"];
pmap["nb_remainder"] = p["BinaryFunc"];
pmap["nb_divmod"] = p["BinaryFunc"];
pmap["nb_power"] = p["TernaryFunc"];
pmap["nb_negative"] = p["UnaryFunc"];
pmap["nb_positive"] = p["UnaryFunc"];
pmap["nb_absolute"] = p["UnaryFunc"];
pmap["nb_nonzero"] = p["InquiryFunc"];
pmap["nb_invert"] = p["UnaryFunc"];
pmap["nb_lshift"] = p["BinaryFunc"];
pmap["nb_rshift"] = p["BinaryFunc"];
pmap["nb_and"] = p["BinaryFunc"];
pmap["nb_xor"] = p["BinaryFunc"];
pmap["nb_or"] = p["BinaryFunc"];
pmap["nb_coerce"] = p["ObjObjFunc"];
pmap["nb_int"] = p["UnaryFunc"];
pmap["nb_long"] = p["UnaryFunc"];
pmap["nb_float"] = p["UnaryFunc"];
pmap["nb_oct"] = p["UnaryFunc"];
pmap["nb_hex"] = p["UnaryFunc"];
pmap["nb_inplace_add"] = p["BinaryFunc"];
pmap["nb_inplace_subtract"] = p["BinaryFunc"];
pmap["nb_inplace_multiply"] = p["BinaryFunc"];
pmap["nb_inplace_remainder"] = p["BinaryFunc"];
pmap["nb_inplace_power"] = p["TernaryFunc"];
pmap["nb_inplace_lshift"] = p["BinaryFunc"];
pmap["nb_inplace_rshift"] = p["BinaryFunc"];
pmap["nb_inplace_and"] = p["BinaryFunc"];
pmap["nb_inplace_xor"] = p["BinaryFunc"];
pmap["nb_inplace_or"] = p["BinaryFunc"];
pmap["nb_floor_divide"] = p["BinaryFunc"];
pmap["nb_true_divide"] = p["BinaryFunc"];
pmap["nb_inplace_floor_divide"] = p["BinaryFunc"];
pmap["nb_inplace_true_divide"] = p["BinaryFunc"];
pmap["nb_index"] = p["UnaryFunc"];

pmap["sq_length"] = p["InquiryFunc"];
pmap["sq_concat"] = p["BinaryFunc"];
pmap["sq_repeat"] = p["IntArgFunc"];
pmap["sq_item"] = p["IntArgFunc"];
pmap["sq_slice"] = p["IntIntArgFunc"];
pmap["sq_ass_item"] = p["IntObjArgFunc"];
pmap["sq_ass_slice"] = p["IntIntObjArgFunc"];
pmap["sq_contains"] = p["ObjObjFunc"];
pmap["sq_inplace_concat"] = p["BinaryFunc"];
pmap["sq_inplace_repeat"] = p["IntArgFunc"];

pmap["mp_length"] = p["InquiryFunc"];
pmap["mp_subscript"] = p["BinaryFunc"];
pmap["mp_ass_subscript"] = p["ObjObjArgFunc"];

pmap["bf_getreadbuffer"] = p["IntObjArgFunc"];
pmap["bf_getwritebuffer"] = p["IntObjArgFunc"];
pmap["bf_getsegcount"] = p["ObjObjFunc"];
pmap["bf_getcharbuffer"] = p["IntObjArgFunc"];
}
MethodInfo invoke = candidate.GetMethod("Invoke");
var candiateParameters = invoke.GetParameters();
if (candiateParameters.Length != parameters.Length)
continue;

internal static Type GetPrototype(string name)
{
return pmap[name] as Type;
var parametersMatch = parameters.Zip(candiateParameters,
(expected, actual) => expected.Matches(actual))
.All(matches => matches);

if (!parametersMatch) continue;

if (invoke.ReturnType != method.ReturnType) continue;

delegateTypes.Add(method, candidate);
return candidate;
}

throw new NotImplementedException(method.ToString());
}


Expand All @@ -235,7 +163,7 @@ internal static ThunkInfo GetThunk(MethodInfo method, string funcType = null)
if (funcType != null)
dt = typeof(Interop).GetNestedType(funcType) as Type;
else
dt = GetPrototype(method.Name);
dt = GetPrototype(method);

if (dt == null)
{
Expand All @@ -252,53 +180,38 @@ internal static ThunkInfo GetThunk(Delegate @delegate)
return info;
}


[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate IntPtr UnaryFunc(IntPtr ob);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate IntPtr BinaryFunc(IntPtr ob, IntPtr arg);
public delegate NewReference B_N(BorrowedReference ob);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate IntPtr TernaryFunc(IntPtr ob, IntPtr a1, IntPtr a2);
public delegate NewReference BB_N(BorrowedReference ob, BorrowedReference a);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate NewReference BBB_N(BorrowedReference ob, BorrowedReference a1, BorrowedReference a2);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int BBB_I32(BorrowedReference ob, BorrowedReference a1, BorrowedReference a2);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int InquiryFunc(IntPtr ob);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate IntPtr IntArgFunc(IntPtr ob, int arg);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate IntPtr IntIntArgFunc(IntPtr ob, int a1, int a2);
public delegate int B_I32(BorrowedReference ob);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int IntObjArgFunc(IntPtr ob, int a1, IntPtr a2);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int IntIntObjArgFunc(IntPtr o, int a, int b, IntPtr c);
public delegate int BBB_I32(BorrowedReference ob, BorrowedReference a1, BorrowedReference a2);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int ObjObjArgFunc(IntPtr o, IntPtr a, IntPtr b);
public delegate int BP_I32(BorrowedReference ob, IntPtr arg);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int ObjObjFunc(IntPtr ob, IntPtr arg);
public delegate IntPtr B_P(BorrowedReference ob);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int BP_I32(BorrowedReference ob, IntPtr arg);
public delegate NewReference BBI32_N(BorrowedReference ob, BorrowedReference a1, int a2);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void DestructorFunc(IntPtr ob);
public delegate NewReference BP_N(BorrowedReference ob, IntPtr arg);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int PrintFunc(IntPtr ob, IntPtr a, int b);
public delegate void N_V(NewReference ob);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate IntPtr RichCmpFunc(IntPtr ob, IntPtr a, int b);
public delegate int BPP_I32(BorrowedReference ob, IntPtr a1, IntPtr a2);
}


Expand Down
2 changes: 1 addition & 1 deletion src/runtime/metatype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public static NewReference tp_new(BorrowedReference tp, BorrowedReference args,
}


public static NewReference tp_alloc(BorrowedReference mt, int n)
public static NewReference tp_alloc(BorrowedReference mt, nint n)
=> Runtime.PyType_GenericAlloc(mt, n);


Expand Down