ClassGeneric.GetClass now returns BorrowedReference to indicate that the value should not be disposed
This commit is contained in:
Родитель
cf8823fa94
Коммит
f48d7a96f7
|
@ -133,7 +133,7 @@ namespace Python.Runtime
|
|||
/// Return the ClassBase-derived instance that implements a particular
|
||||
/// reflected managed type, creating it if it doesn't yet exist.
|
||||
/// </summary>
|
||||
internal static ReflectedClrType GetClass(Type type) => ReflectedClrType.GetOrCreate(type);
|
||||
internal static BorrowedReference GetClass(Type type) => ReflectedClrType.GetOrCreate(type);
|
||||
|
||||
internal static ClassBase GetClassImpl(Type type)
|
||||
{
|
||||
|
|
|
@ -236,7 +236,7 @@ namespace Python.Runtime
|
|||
return Exceptions.RaiseTypeError("type expected");
|
||||
}
|
||||
Type a = t.MakeArrayType();
|
||||
PyType o = ClassManager.GetClass(a);
|
||||
BorrowedReference o = ClassManager.GetClass(a);
|
||||
return new NewReference(o);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,13 +43,13 @@ namespace Python.Runtime
|
|||
|
||||
internal static NewReference GetReference(object ob, Type type)
|
||||
{
|
||||
PyType cc = ClassManager.GetClass(type);
|
||||
BorrowedReference cc = ClassManager.GetClass(type);
|
||||
return Create(ob, cc);
|
||||
}
|
||||
|
||||
internal static NewReference GetReference(object ob)
|
||||
{
|
||||
PyType cc = ClassManager.GetClass(ob.GetType());
|
||||
BorrowedReference cc = ClassManager.GetClass(ob.GetType());
|
||||
return Create(ob, cc);
|
||||
}
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ namespace Python.Runtime
|
|||
&& obj.inst is IPythonDerivedType
|
||||
&& self.type.Value.IsInstanceOfType(obj.inst))
|
||||
{
|
||||
var basecls = ClassManager.GetClass(self.type.Value);
|
||||
var basecls = ReflectedClrType.GetOrCreate(self.type.Value);
|
||||
return new MethodBinding(self, new PyObject(ob), basecls).Alloc();
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ internal sealed class ReflectedClrType : PyType
|
|||
{
|
||||
private ReflectedClrType(StolenReference reference) : base(reference, prevalidated: true) { }
|
||||
internal ReflectedClrType(ReflectedClrType original) : base(original, prevalidated: true) { }
|
||||
internal ReflectedClrType(BorrowedReference original) : base(original) { }
|
||||
ReflectedClrType(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
|
||||
internal ClassBase Impl => (ClassBase)ManagedType.GetManagedObject(this)!;
|
||||
|
|
Загрузка…
Ссылка в новой задаче