@@ -13,7 +13,7 @@ namespace Python.Runtime
13
13
[ Serializable ]
14
14
internal class InterfaceObject : ClassBase
15
15
{
16
- internal ConstructorInfo ctor ;
16
+ internal ConstructorInfo ? ctor ;
17
17
18
18
internal InterfaceObject ( Type tp ) : base ( tp )
19
19
{
@@ -34,9 +34,9 @@ static InterfaceObject()
34
34
/// <summary>
35
35
/// Implements __new__ for reflected interface types.
36
36
/// </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 )
38
38
{
39
- var self = ( InterfaceObject ) GetManagedObject ( tp ) ;
39
+ var self = ( InterfaceObject ) GetManagedObject ( tp ) ! ;
40
40
if ( ! self . type . Valid )
41
41
{
42
42
return Exceptions . RaiseTypeError ( self . type . DeletedMessage ) ;
@@ -47,13 +47,13 @@ public static IntPtr tp_new(IntPtr tp, IntPtr args, IntPtr kw)
47
47
48
48
if ( nargs == 1 )
49
49
{
50
- IntPtr inst = Runtime . PyTuple_GetItem ( args , 0 ) ;
50
+ BorrowedReference inst = Runtime . PyTuple_GetItem ( args , 0 ) ;
51
51
var co = GetManagedObject ( inst ) as CLRObject ;
52
52
53
53
if ( co == null || ! type . IsInstanceOfType ( co . inst ) )
54
54
{
55
55
Exceptions . SetError ( Exceptions . TypeError , $ "object does not implement { type . Name } ") ;
56
- return IntPtr . Zero ;
56
+ return default ;
57
57
}
58
58
59
59
obj = co . inst ;
@@ -66,14 +66,14 @@ public static IntPtr tp_new(IntPtr tp, IntPtr args, IntPtr kw)
66
66
if ( obj == null || ! type . IsInstanceOfType ( obj ) )
67
67
{
68
68
Exceptions . SetError ( Exceptions . TypeError , "CoClass default constructor failed" ) ;
69
- return IntPtr . Zero ;
69
+ return default ;
70
70
}
71
71
}
72
72
73
73
else
74
74
{
75
75
Exceptions . SetError ( Exceptions . TypeError , "interface takes exactly one argument" ) ;
76
- return IntPtr . Zero ;
76
+ return default ;
77
77
}
78
78
79
79
return self . WrapObject ( obj ) ;
@@ -89,23 +89,23 @@ public static IntPtr tp_new(IntPtr tp, IntPtr args, IntPtr kw)
89
89
/// Expose the wrapped implementation through attributes in both
90
90
/// converted/encoded (__implementation__) and raw (__raw_implementation__) form.
91
91
/// </summary>
92
- public static IntPtr tp_getattro ( IntPtr ob , IntPtr key )
92
+ public static NewReference tp_getattro ( BorrowedReference ob , BorrowedReference key )
93
93
{
94
- var clrObj = ( CLRObject ) GetManagedObject ( ob ) ;
94
+ var clrObj = ( CLRObject ) GetManagedObject ( ob ) ! ;
95
95
96
96
if ( ! Runtime . PyString_Check ( key ) )
97
97
{
98
98
return Exceptions . RaiseTypeError ( "string expected" ) ;
99
99
}
100
100
101
- string name = Runtime . GetManagedString ( key ) ;
101
+ string ? name = Runtime . GetManagedString ( key ) ;
102
102
if ( name == "__implementation__" )
103
103
{
104
104
return Converter . ToPython ( clrObj . inst ) ;
105
105
}
106
106
else if ( name == "__raw_implementation__" )
107
107
{
108
- return CLRObject . GetInstHandle ( clrObj . inst ) ;
108
+ return CLRObject . GetReference ( clrObj . inst ) ;
109
109
}
110
110
111
111
return Runtime . PyObject_GenericGetAttr ( ob , key ) ;
0 commit comments