File tree 2 files changed +35
-2
lines changed
2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,24 @@ namespace Python.Runtime
15
15
{
16
16
17
17
[ StructLayout ( LayoutKind . Sequential ) ]
18
- internal static partial class TypeOffset
18
+ internal static class TypeOffset
19
19
{
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
+
20
36
// Auto-generated from PyHeapTypeObject in Python.h
21
37
public static int ob_refcnt = 0 ;
22
38
public static int ob_type = 0 ;
@@ -225,3 +241,4 @@ internal static partial class SlotTypes
225
241
226
242
}
227
243
#endif
244
+
Original file line number Diff line number Diff line change @@ -289,8 +289,24 @@ def gen_heap_type_members(parser, writer):
289
289
members = parser .get_struct_members ("PyHeapTypeObject" )
290
290
class_definition = """
291
291
[StructLayout(LayoutKind.Sequential)]
292
- internal static partial class TypeOffset
292
+ internal static class TypeOffset
293
293
{
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
+
294
310
// Auto-generated from PyHeapTypeObject in Python.h
295
311
"""
296
312
You can’t perform that action at this time.
0 commit comments