Skip to content

Commit d1abd9a

Browse files
committed
switched interfaceobject.cs to the new style references
1 parent 5ad09e4 commit d1abd9a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/runtime/interfaceobject.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Python.Runtime
1313
[Serializable]
1414
internal class InterfaceObject : ClassBase
1515
{
16-
internal ConstructorInfo ctor;
16+
internal ConstructorInfo? ctor;
1717

1818
internal InterfaceObject(Type tp) : base(tp)
1919
{
@@ -34,9 +34,9 @@ static InterfaceObject()
3434
/// <summary>
3535
/// Implements __new__ for reflected interface types.
3636
/// </summary>
37-
public static IntPtr tp_new(IntPtr tp, IntPtr args, IntPtr kw)
37+
public static NewReference tp_new(BorrowedReference tp, BorrowedReference args, BorrowedReference kw)
3838
{
39-
var self = (InterfaceObject)GetManagedObject(tp);
39+
var self = (InterfaceObject)GetManagedObject(tp)!;
4040
if (!self.type.Valid)
4141
{
4242
return Exceptions.RaiseTypeError(self.type.DeletedMessage);
@@ -47,13 +47,13 @@ public static IntPtr tp_new(IntPtr tp, IntPtr args, IntPtr kw)
4747

4848
if (nargs == 1)
4949
{
50-
IntPtr inst = Runtime.PyTuple_GetItem(args, 0);
50+
BorrowedReference inst = Runtime.PyTuple_GetItem(args, 0);
5151
var co = GetManagedObject(inst) as CLRObject;
5252

5353
if (co == null || !type.IsInstanceOfType(co.inst))
5454
{
5555
Exceptions.SetError(Exceptions.TypeError, $"object does not implement {type.Name}");
56-
return IntPtr.Zero;
56+
return default;
5757
}
5858

5959
obj = co.inst;
@@ -66,14 +66,14 @@ public static IntPtr tp_new(IntPtr tp, IntPtr args, IntPtr kw)
6666
if (obj == null || !type.IsInstanceOfType(obj))
6767
{
6868
Exceptions.SetError(Exceptions.TypeError, "CoClass default constructor failed");
69-
return IntPtr.Zero;
69+
return default;
7070
}
7171
}
7272

7373
else
7474
{
7575
Exceptions.SetError(Exceptions.TypeError, "interface takes exactly one argument");
76-
return IntPtr.Zero;
76+
return default;
7777
}
7878

7979
return self.WrapObject(obj);
@@ -89,23 +89,23 @@ public static IntPtr tp_new(IntPtr tp, IntPtr args, IntPtr kw)
8989
/// Expose the wrapped implementation through attributes in both
9090
/// converted/encoded (__implementation__) and raw (__raw_implementation__) form.
9191
/// </summary>
92-
public static IntPtr tp_getattro(IntPtr ob, IntPtr key)
92+
public static NewReference tp_getattro(BorrowedReference ob, BorrowedReference key)
9393
{
94-
var clrObj = (CLRObject)GetManagedObject(ob);
94+
var clrObj = (CLRObject)GetManagedObject(ob)!;
9595

9696
if (!Runtime.PyString_Check(key))
9797
{
9898
return Exceptions.RaiseTypeError("string expected");
9999
}
100100

101-
string name = Runtime.GetManagedString(key);
101+
string? name = Runtime.GetManagedString(key);
102102
if (name == "__implementation__")
103103
{
104104
return Converter.ToPython(clrObj.inst);
105105
}
106106
else if (name == "__raw_implementation__")
107107
{
108-
return CLRObject.GetInstHandle(clrObj.inst);
108+
return CLRObject.GetReference(clrObj.inst);
109109
}
110110

111111
return Runtime.PyObject_GenericGetAttr(ob, key);

0 commit comments

Comments
 (0)