@@ -118,16 +118,11 @@ static ManagedDataOffsets()
118118 size = fields . Length * IntPtr . Size ;
119119 }
120120
121- public static int GetSlotOffset ( string name )
122- {
123- return NameMapping [ name ] ;
124- }
125-
126121 private static int BaseOffset ( IntPtr type )
127122 {
128123 Debug . Assert ( type != IntPtr . Zero ) ;
129124 int typeSize = Marshal . ReadInt32 ( type , TypeOffset . tp_basicsize ) ;
130- Debug . Assert ( typeSize > 0 ) ;
125+ Debug . Assert ( typeSize > 0 && typeSize <= ExceptionOffset . Size ( ) ) ;
131126 return typeSize ;
132127 }
133128 public static int DataOffset ( IntPtr type )
@@ -358,38 +353,39 @@ public static void FreeModuleDef(IntPtr ptr)
358353 /// Note that the two values reserved for stackless have been put
359354 /// to good use as PythonNet specific flags (Managed and Subclass)
360355 /// </summary>
361- internal class TypeFlags
356+ [ Flags ]
357+ internal enum TypeFlags
362358 {
363- public const int HeapType = ( 1 << 9 ) ;
364- public const int BaseType = ( 1 << 10 ) ;
365- public const int Ready = ( 1 << 12 ) ;
366- public const int Readying = ( 1 << 13 ) ;
367- public const int HaveGC = ( 1 << 14 ) ;
359+ HeapType = ( 1 << 9 ) ,
360+ BaseType = ( 1 << 10 ) ,
361+ Ready = ( 1 << 12 ) ,
362+ Readying = ( 1 << 13 ) ,
363+ HaveGC = ( 1 << 14 ) ,
368364 // 15 and 16 are reserved for stackless
369- public const int HaveStacklessExtension = 0 ;
365+ HaveStacklessExtension = 0 ,
370366 /* XXX Reusing reserved constants */
371- public const int Managed = ( 1 << 15 ) ; // PythonNet specific
372- public const int Subclass = ( 1 << 16 ) ; // PythonNet specific
373- public const int HaveIndex = ( 1 << 17 ) ;
367+ Managed = ( 1 << 15 ) , // PythonNet specific
368+ Subclass = ( 1 << 16 ) , // PythonNet specific
369+ HaveIndex = ( 1 << 17 ) ,
374370 /* Objects support nb_index in PyNumberMethods */
375- public const int HaveVersionTag = ( 1 << 18 ) ;
376- public const int ValidVersionTag = ( 1 << 19 ) ;
377- public const int IsAbstract = ( 1 << 20 ) ;
378- public const int HaveNewBuffer = ( 1 << 21 ) ;
371+ HaveVersionTag = ( 1 << 18 ) ,
372+ ValidVersionTag = ( 1 << 19 ) ,
373+ IsAbstract = ( 1 << 20 ) ,
374+ HaveNewBuffer = ( 1 << 21 ) ,
379375 // TODO: Implement FastSubclass functions
380- public const int IntSubclass = ( 1 << 23 ) ;
381- public const int LongSubclass = ( 1 << 24 ) ;
382- public const int ListSubclass = ( 1 << 25 ) ;
383- public const int TupleSubclass = ( 1 << 26 ) ;
384- public const int StringSubclass = ( 1 << 27 ) ;
385- public const int UnicodeSubclass = ( 1 << 28 ) ;
386- public const int DictSubclass = ( 1 << 29 ) ;
387- public const int BaseExceptionSubclass = ( 1 << 30 ) ;
388- public const int TypeSubclass = ( 1 << 31 ) ;
389-
390- public const int Default = (
376+ IntSubclass = ( 1 << 23 ) ,
377+ LongSubclass = ( 1 << 24 ) ,
378+ ListSubclass = ( 1 << 25 ) ,
379+ TupleSubclass = ( 1 << 26 ) ,
380+ StringSubclass = ( 1 << 27 ) ,
381+ UnicodeSubclass = ( 1 << 28 ) ,
382+ DictSubclass = ( 1 << 29 ) ,
383+ BaseExceptionSubclass = ( 1 << 30 ) ,
384+ TypeSubclass = ( 1 << 31 ) ,
385+
386+ Default = (
391387 HaveStacklessExtension |
392- HaveVersionTag ) ;
388+ HaveVersionTag )
393389 }
394390
395391
0 commit comments