@@ -312,7 +312,7 @@ static BorrowedReference InitializeBases(PyType pyType, PyTuple baseTuple)
312312
313313 if ( baseTuple . Length ( ) > 1 )
314314 {
315- Marshal . WriteIntPtr ( pyType . Handle , TypeOffset . tp_bases , baseTuple . NewReferenceOrNull ( ) . DangerousMoveToPointer ( ) ) ;
315+ Util . WriteIntPtr ( pyType , TypeOffset . tp_bases , baseTuple . NewReferenceOrNull ( ) . DangerousMoveToPointer ( ) ) ;
316316 }
317317 return primaryBase ;
318318 }
@@ -323,7 +323,7 @@ static void InitializeCoreFields(PyType type)
323323
324324 if ( ManagedType . IsManagedType ( type . BaseReference ) )
325325 {
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 ) ;
327327 Util . WriteInt32 ( type , ManagedType . Offsets . tp_clr_inst_offset , baseClrInstOffset ) ;
328328 }
329329 else
@@ -344,7 +344,7 @@ static void InitializeClass(PyType type, ClassBase impl, Type clrType)
344344 SlotsHolder slotsHolder = CreateSolotsHolder ( type ) ;
345345 InitializeSlots ( type , impl . GetType ( ) , slotsHolder ) ;
346346
347- if ( Marshal . ReadIntPtr ( type , TypeOffset . mp_length ) == IntPtr . Zero
347+ if ( Util . ReadIntPtr ( type , TypeOffset . mp_length ) == IntPtr . Zero
348348 && mp_length_slot . CanAssign ( clrType ) )
349349 {
350350 InitializeSlot ( type , TypeOffset . mp_length , mp_length_slot . Method , slotsHolder ) ;
@@ -381,7 +381,7 @@ static void InitializeClass(PyType type, ClassBase impl, Type clrType)
381381 throw PythonException . ThrowLastAsClrException ( ) ;
382382 }
383383
384- var dict = new BorrowedReference ( Marshal . ReadIntPtr ( type , TypeOffset . tp_dict ) ) ;
384+ var dict = Util . ReadRef ( type , TypeOffset . tp_dict ) ;
385385 string mn = clrType . Namespace ?? "" ;
386386 using ( var mod = Runtime . PyString_FromString ( mn ) )
387387 Runtime . PyDict_SetItem ( dict , PyIdentifier . __module__ , mod . Borrow ( ) ) ;
@@ -410,7 +410,7 @@ static int InheritOrAllocateStandardFields(BorrowedReference typeRef, BorrowedRe
410410 {
411411 IntPtr baseAddress = @base . DangerousGetAddress ( ) ;
412412 IntPtr type = typeRef . DangerousGetAddress ( ) ;
413- int baseSize = Marshal . ReadInt32 ( baseAddress , TypeOffset . tp_basicsize ) ;
413+ int baseSize = Util . ReadInt32 ( @base , TypeOffset . tp_basicsize ) ;
414414 int newFieldOffset = baseSize ;
415415
416416 void InheritOrAllocate ( int typeField )
@@ -538,7 +538,7 @@ internal static IntPtr WriteMethodDef(IntPtr mdef, IntPtr name, IntPtr func, int
538538 }
539539
540540 internal static IntPtr WriteMethodDef ( IntPtr mdef , string name , IntPtr func , int flags = 0x0001 ,
541- string doc = null )
541+ string ? doc = null )
542542 {
543543 IntPtr namePtr = Marshal . StringToHGlobalAnsi ( name ) ;
544544 IntPtr docPtr = doc != null ? Marshal . StringToHGlobalAnsi ( doc ) : IntPtr . Zero ;
@@ -581,7 +581,7 @@ internal static PyType CreateMetaType(Type impl, out SlotsHolder slotsHolder)
581581 PyType py_type = Runtime . PyTypeType ;
582582 Util . WriteRef ( type , TypeOffset . tp_base , new NewReference ( py_type ) . Steal ( ) ) ;
583583
584- int size = Marshal . ReadInt32 ( Runtime . PyTypeType , TypeOffset . tp_basicsize )
584+ int size = Util . ReadInt32 ( Runtime . PyTypeType , TypeOffset . tp_basicsize )
585585 + IntPtr . Size // tp_clr_inst_offset
586586 + IntPtr . Size // tp_clr_inst
587587 ;
@@ -641,7 +641,7 @@ internal static SlotsHolder SetupMetaSlots(Type impl, PyType type)
641641 {
642642 slotsHolder . Set ( TypeOffset . tp_methods , ( t , offset ) =>
643643 {
644- var p = Marshal . ReadIntPtr ( t , offset ) ;
644+ var p = Util . ReadIntPtr ( t , offset ) ;
645645 Runtime . PyMem_Free ( p ) ;
646646 Util . WriteIntPtr ( t , offset , IntPtr . Zero ) ;
647647 } ) ;
0 commit comments