File tree Expand file tree Collapse file tree 2 files changed +35
-2
lines changed
Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,24 @@ namespace Python.Runtime
1515{
1616
1717 [ StructLayout ( LayoutKind . Sequential ) ]
18- internal static partial class TypeOffset
18+ internal static class TypeOffset
1919 {
20+ static TypeOffset ( )
21+ {
22+ Type type = typeof ( TypeOffset ) ;
23+ FieldInfo [ ] fi = type . GetFields ( ) ;
24+ int size = IntPtr . Size ;
25+ for ( int i = 0 ; i < fi . Length ; i ++ )
26+ {
27+ fi [ i ] . SetValue ( null , i * size ) ;
28+ }
29+ }
30+
31+ public static int magic ( )
32+ {
33+ return ob_size ;
34+ }
35+
2036 // Auto-generated from PyHeapTypeObject in Python.h
2137 public static int ob_refcnt = 0 ;
2238 public static int ob_type = 0 ;
@@ -225,3 +241,4 @@ internal static partial class SlotTypes
225241
226242}
227243#endif
244+
Original file line number Diff line number Diff line change @@ -289,8 +289,24 @@ def gen_heap_type_members(parser, writer):
289289 members = parser .get_struct_members ("PyHeapTypeObject" )
290290 class_definition = """
291291 [StructLayout(LayoutKind.Sequential)]
292- internal static partial class TypeOffset
292+ internal static class TypeOffset
293293 {
294+ static TypeOffset()
295+ {
296+ Type type = typeof(TypeOffset);
297+ FieldInfo[] fi = type.GetFields();
298+ int size = IntPtr.Size;
299+ for (int i = 0; i < fi.Length; i++)
300+ {
301+ fi[i].SetValue(null, i * size);
302+ }
303+ }
304+
305+ public static int magic()
306+ {
307+ return ob_size;
308+ }
309+
294310 // Auto-generated from PyHeapTypeObject in Python.h
295311"""
296312
You can’t perform that action at this time.
0 commit comments