@@ -93,7 +93,6 @@ internal static void RestoreRuntimeData(TypeManagerState storage)
9393 Debug . Assert ( type == _slotsImpls [ type ] ) ;
9494 InitializeSlots ( entry . Value , _slotsImpls [ type ] , holder ) ;
9595 Runtime . PyType_Modified ( entry . Value ) ;
96- // FIXME: mp_length_slot.CanAssgin(clrType)
9796 }
9897 }
9998
@@ -290,31 +289,7 @@ internal static void InitializeClass(PyType type, ClassBase impl, Type clrType)
290289 SlotsHolder slotsHolder = CreateSlotsHolder ( type ) ;
291290 InitializeSlots ( type , impl . GetType ( ) , slotsHolder ) ;
292291
293- if ( ! slotsHolder . IsHolding ( TypeOffset . mp_length ) && mp_length_slot . CanAssign ( clrType ) )
294- {
295- InitializeSlot ( type , TypeOffset . mp_length , mp_length_slot . Method , slotsHolder ) ;
296- }
297-
298- if ( ! typeof ( IEnumerable ) . IsAssignableFrom ( clrType ) &&
299- ! typeof ( IEnumerator ) . IsAssignableFrom ( clrType ) )
300- {
301- // The tp_iter slot should only be set for enumerable types.
302- Util . WriteIntPtr ( type , TypeOffset . tp_iter , IntPtr . Zero ) ;
303- }
304-
305-
306- // Only set mp_subscript and mp_ass_subscript for types with indexers
307- if ( ! ( impl is ArrayObject ) )
308- {
309- if ( impl . indexer == null || ! impl . indexer . CanGet )
310- {
311- Util . WriteIntPtr ( type , TypeOffset . mp_subscript , IntPtr . Zero ) ;
312- }
313- if ( impl . indexer == null || ! impl . indexer . CanSet )
314- {
315- Util . WriteIntPtr ( type , TypeOffset . mp_ass_subscript , IntPtr . Zero ) ;
316- }
317- }
292+ impl . InitializeSlots ( type , slotsHolder ) ;
318293
319294 OperatorMethod . FixupSlots ( type , clrType ) ;
320295 // Leverage followup initialization from the Python runtime. Note
@@ -331,8 +306,6 @@ internal static void InitializeClass(PyType type, ClassBase impl, Type clrType)
331306 using ( var mod = Runtime . PyString_FromString ( mn ) )
332307 Runtime . PyDict_SetItem ( dict , PyIdentifier . __module__ , mod . Borrow ( ) ) ;
333308
334- impl . InitializeSlots ( type , slotsHolder ) ;
335-
336309 Runtime . PyType_Modified ( type . Reference ) ;
337310
338311#if DEBUG
@@ -716,6 +689,12 @@ internal static void InitializeSlot(BorrowedReference type, int slotOffset, Dele
716689 InitializeSlot ( type , slotOffset , thunk , slotsHolder ) ;
717690 }
718691
692+ internal static void InitializeSlotIfEmpty ( BorrowedReference type , int slotOffset , Delegate impl , SlotsHolder slotsHolder )
693+ {
694+ if ( slotsHolder . IsHolding ( slotOffset ) ) return ;
695+ InitializeSlot ( type , slotOffset , impl , slotsHolder ) ;
696+ }
697+
719698 static void InitializeSlot ( BorrowedReference type , int slotOffset , ThunkInfo thunk , SlotsHolder slotsHolder )
720699 {
721700 Util . WriteIntPtr ( type , slotOffset , thunk . Address ) ;
0 commit comments