@@ -312,7 +312,7 @@ static BorrowedReference InitializeBases(PyType pyType, PyTuple baseTuple)
312
312
313
313
if ( baseTuple . Length ( ) > 1 )
314
314
{
315
- Marshal . WriteIntPtr ( pyType . Handle , TypeOffset . tp_bases , baseTuple . NewReferenceOrNull ( ) . DangerousMoveToPointer ( ) ) ;
315
+ Util . WriteIntPtr ( pyType , TypeOffset . tp_bases , baseTuple . NewReferenceOrNull ( ) . DangerousMoveToPointer ( ) ) ;
316
316
}
317
317
return primaryBase ;
318
318
}
@@ -323,7 +323,7 @@ static void InitializeCoreFields(PyType type)
323
323
324
324
if ( ManagedType . IsManagedType ( type . BaseReference ) )
325
325
{
326
- int baseClrInstOffset = Marshal . ReadInt32 ( type . BaseReference . DangerousGetAddress ( ) , ManagedType . Offsets . tp_clr_inst_offset ) ;
326
+ int baseClrInstOffset = Util . ReadInt32 ( type . BaseReference , ManagedType . Offsets . tp_clr_inst_offset ) ;
327
327
Util . WriteInt32 ( type , ManagedType . Offsets . tp_clr_inst_offset , baseClrInstOffset ) ;
328
328
}
329
329
else
@@ -344,7 +344,7 @@ static void InitializeClass(PyType type, ClassBase impl, Type clrType)
344
344
SlotsHolder slotsHolder = CreateSolotsHolder ( type ) ;
345
345
InitializeSlots ( type , impl . GetType ( ) , slotsHolder ) ;
346
346
347
- if ( Marshal . ReadIntPtr ( type , TypeOffset . mp_length ) == IntPtr . Zero
347
+ if ( Util . ReadIntPtr ( type , TypeOffset . mp_length ) == IntPtr . Zero
348
348
&& mp_length_slot . CanAssign ( clrType ) )
349
349
{
350
350
InitializeSlot ( type , TypeOffset . mp_length , mp_length_slot . Method , slotsHolder ) ;
@@ -381,7 +381,7 @@ static void InitializeClass(PyType type, ClassBase impl, Type clrType)
381
381
throw PythonException . ThrowLastAsClrException ( ) ;
382
382
}
383
383
384
- var dict = new BorrowedReference ( Marshal . ReadIntPtr ( type , TypeOffset . tp_dict ) ) ;
384
+ var dict = Util . ReadRef ( type , TypeOffset . tp_dict ) ;
385
385
string mn = clrType . Namespace ?? "" ;
386
386
using ( var mod = Runtime . PyString_FromString ( mn ) )
387
387
Runtime . PyDict_SetItem ( dict , PyIdentifier . __module__ , mod . Borrow ( ) ) ;
@@ -410,7 +410,7 @@ static int InheritOrAllocateStandardFields(BorrowedReference typeRef, BorrowedRe
410
410
{
411
411
IntPtr baseAddress = @base . DangerousGetAddress ( ) ;
412
412
IntPtr type = typeRef . DangerousGetAddress ( ) ;
413
- int baseSize = Marshal . ReadInt32 ( baseAddress , TypeOffset . tp_basicsize ) ;
413
+ int baseSize = Util . ReadInt32 ( @base , TypeOffset . tp_basicsize ) ;
414
414
int newFieldOffset = baseSize ;
415
415
416
416
void InheritOrAllocate ( int typeField )
@@ -538,7 +538,7 @@ internal static IntPtr WriteMethodDef(IntPtr mdef, IntPtr name, IntPtr func, int
538
538
}
539
539
540
540
internal static IntPtr WriteMethodDef ( IntPtr mdef , string name , IntPtr func , int flags = 0x0001 ,
541
- string doc = null )
541
+ string ? doc = null )
542
542
{
543
543
IntPtr namePtr = Marshal . StringToHGlobalAnsi ( name ) ;
544
544
IntPtr docPtr = doc != null ? Marshal . StringToHGlobalAnsi ( doc ) : IntPtr . Zero ;
@@ -581,7 +581,7 @@ internal static PyType CreateMetaType(Type impl, out SlotsHolder slotsHolder)
581
581
PyType py_type = Runtime . PyTypeType ;
582
582
Util . WriteRef ( type , TypeOffset . tp_base , new NewReference ( py_type ) . Steal ( ) ) ;
583
583
584
- int size = Marshal . ReadInt32 ( Runtime . PyTypeType , TypeOffset . tp_basicsize )
584
+ int size = Util . ReadInt32 ( Runtime . PyTypeType , TypeOffset . tp_basicsize )
585
585
+ IntPtr . Size // tp_clr_inst_offset
586
586
+ IntPtr . Size // tp_clr_inst
587
587
;
@@ -641,7 +641,7 @@ internal static SlotsHolder SetupMetaSlots(Type impl, PyType type)
641
641
{
642
642
slotsHolder . Set ( TypeOffset . tp_methods , ( t , offset ) =>
643
643
{
644
- var p = Marshal . ReadIntPtr ( t , offset ) ;
644
+ var p = Util . ReadIntPtr ( t , offset ) ;
645
645
Runtime . PyMem_Free ( p ) ;
646
646
Util . WriteIntPtr ( t , offset , IntPtr . Zero ) ;
647
647
} ) ;
0 commit comments