@@ -23,16 +23,16 @@ namespace Python.Runtime
23
23
internal class ConstructorBinding : ExtensionType
24
24
{
25
25
private MaybeType type ; // The managed Type being wrapped in a ClassObject
26
- private IntPtr pyTypeHndl ; // The python type tells GetInstHandle which Type to create.
26
+ private PyType typeToCreate ; // The python type tells GetInstHandle which Type to create.
27
27
private ConstructorBinder ctorBinder ;
28
28
29
29
[ NonSerialized ]
30
30
private IntPtr repr ;
31
31
32
- public ConstructorBinding ( Type type , IntPtr pyTypeHndl , ConstructorBinder ctorBinder )
32
+ public ConstructorBinding ( Type type , PyType typeToCreate , ConstructorBinder ctorBinder )
33
33
{
34
34
this . type = type ;
35
- this . pyTypeHndl = pyTypeHndl ; // steal a type reference
35
+ this . typeToCreate = typeToCreate ;
36
36
this . ctorBinder = ctorBinder ;
37
37
repr = IntPtr . Zero ;
38
38
}
@@ -110,7 +110,7 @@ public static IntPtr mp_subscript(IntPtr op, IntPtr key)
110
110
{
111
111
return Exceptions . RaiseTypeError ( "No match found for constructor signature" ) ;
112
112
}
113
- var boundCtor = new BoundContructor ( tp , self . pyTypeHndl , self . ctorBinder , ci ) ;
113
+ var boundCtor = new BoundContructor ( tp , self . typeToCreate , self . ctorBinder , ci ) ;
114
114
115
115
return boundCtor . pyHandle ;
116
116
}
@@ -169,7 +169,7 @@ public static int tp_clear(IntPtr ob)
169
169
public static int tp_traverse ( IntPtr ob , IntPtr visit , IntPtr arg )
170
170
{
171
171
var self = ( ConstructorBinding ) GetManagedObject ( ob ) ;
172
- int res = PyVisit ( self . pyTypeHndl , visit , arg ) ;
172
+ int res = PyVisit ( self . typeToCreate . Handle , visit , arg ) ;
173
173
if ( res != 0 ) return res ;
174
174
175
175
res = PyVisit ( self . repr , visit , arg ) ;
@@ -190,15 +190,15 @@ public static int tp_traverse(IntPtr ob, IntPtr visit, IntPtr arg)
190
190
internal class BoundContructor : ExtensionType
191
191
{
192
192
private Type type ; // The managed Type being wrapped in a ClassObject
193
- private IntPtr pyTypeHndl ; // The python type tells GetInstHandle which Type to create.
193
+ private PyType typeToCreate ; // The python type tells GetInstHandle which Type to create.
194
194
private ConstructorBinder ctorBinder ;
195
195
private ConstructorInfo ctorInfo ;
196
196
private IntPtr repr ;
197
197
198
- public BoundContructor ( Type type , IntPtr pyTypeHndl , ConstructorBinder ctorBinder , ConstructorInfo ci )
198
+ public BoundContructor ( Type type , PyType typeToCreate , ConstructorBinder ctorBinder , ConstructorInfo ci )
199
199
{
200
200
this . type = type ;
201
- this . pyTypeHndl = pyTypeHndl ; // steal a type reference
201
+ this . typeToCreate = typeToCreate ;
202
202
this . ctorBinder = ctorBinder ;
203
203
ctorInfo = ci ;
204
204
repr = IntPtr . Zero ;
@@ -229,7 +229,7 @@ public static IntPtr tp_call(IntPtr op, IntPtr args, IntPtr kw)
229
229
}
230
230
// Instantiate the python object that wraps the result of the method call
231
231
// and return the PyObject* to it.
232
- return CLRObject . GetInstHandle ( obj , self . pyTypeHndl ) ;
232
+ return CLRObject . GetInstHandle ( obj , self . typeToCreate . Reference ) . DangerousMoveToPointer ( ) ;
233
233
}
234
234
235
235
/// <summary>
@@ -272,7 +272,7 @@ public static int tp_clear(IntPtr ob)
272
272
public static int tp_traverse ( IntPtr ob , IntPtr visit , IntPtr arg )
273
273
{
274
274
var self = ( BoundContructor ) GetManagedObject ( ob ) ;
275
- int res = PyVisit ( self . pyTypeHndl , visit , arg ) ;
275
+ int res = PyVisit ( self . typeToCreate . Handle , visit , arg ) ;
276
276
if ( res != 0 ) return res ;
277
277
278
278
res = PyVisit ( self . repr , visit , arg ) ;
0 commit comments