@@ -76,7 +76,6 @@ internal static partial class TypeOffset
76
76
internal static class ManagedDataOffsets
77
77
{
78
78
public static int Magic { get ; internal set ; }
79
- public static readonly Dictionary < string , int > NameMapping = new Dictionary < string , int > ( ) ;
80
79
81
80
static class DataOffsets
82
81
{
@@ -95,17 +94,10 @@ static DataOffsets()
95
94
96
95
static ManagedDataOffsets ( )
97
96
{
98
- NameMapping = TypeOffset . GetOffsets ( ) ;
99
-
100
97
FieldInfo [ ] fields = typeof ( DataOffsets ) . GetFields ( BindingFlags . Static | BindingFlags . Public ) ;
101
98
size = fields . Length * IntPtr . Size ;
102
99
}
103
100
104
- public static int GetSlotOffset ( string name )
105
- {
106
- return NameMapping [ name ] ;
107
- }
108
-
109
101
private static int BaseOffset ( IntPtr type )
110
102
{
111
103
Debug . Assert ( type != IntPtr . Zero ) ;
@@ -135,30 +127,15 @@ internal static class OriginalObjectOffsets
135
127
{
136
128
static OriginalObjectOffsets ( )
137
129
{
138
- int size = IntPtr . Size ;
139
- var n = 0 ; // Py_TRACE_REFS add two pointers to PyObject_HEAD
140
- #if PYTHON_WITH_PYDEBUG
141
- _ob_next = 0 ;
142
- _ob_prev = 1 * size ;
143
- n = 2 ;
144
- #endif
145
- ob_refcnt = ( n + 0 ) * size ;
146
- ob_type = ( n + 1 ) * size ;
130
+ ob_refcnt = Native . ABI . ObjectHeadOffset ;
131
+ ob_type = ob_refcnt + IntPtr . Size ;
132
+ size = ob_type + IntPtr . Size ;
147
133
}
148
134
149
135
public static int Size { get { return size ; } }
150
136
151
- private static readonly int size =
152
- #if PYTHON_WITH_PYDEBUG
153
- 4 * IntPtr . Size ;
154
- #else
155
- 2 * IntPtr . Size ;
156
- #endif
157
-
158
- #if PYTHON_WITH_PYDEBUG
159
- public static int _ob_next ;
160
- public static int _ob_prev ;
161
- #endif
137
+ private static readonly int size ;
138
+
162
139
public static int ob_refcnt ;
163
140
public static int ob_type ;
164
141
}
@@ -168,10 +145,6 @@ internal class ObjectOffset
168
145
{
169
146
static ObjectOffset ( )
170
147
{
171
- #if PYTHON_WITH_PYDEBUG
172
- _ob_next = OriginalObjectOffsets . _ob_next ;
173
- _ob_prev = OriginalObjectOffsets . _ob_prev ;
174
- #endif
175
148
ob_refcnt = OriginalObjectOffsets . ob_refcnt ;
176
149
ob_type = OriginalObjectOffsets . ob_type ;
177
150
@@ -198,10 +171,6 @@ public static int Size(IntPtr pyType)
198
171
return size ;
199
172
}
200
173
201
- #if PYTHON_WITH_PYDEBUG
202
- public static int _ob_next ;
203
- public static int _ob_prev ;
204
- #endif
205
174
public static int ob_refcnt ;
206
175
public static int ob_type ;
207
176
private static readonly int size ;
@@ -256,17 +225,12 @@ static BytesOffset()
256
225
int size = IntPtr . Size ;
257
226
for ( int i = 0 ; i < fi . Length ; i ++ )
258
227
{
259
- fi [ i ] . SetValue ( null , i * size ) ;
228
+ fi [ i ] . SetValue ( null , i * size + Native . ABI . ObjectHeadOffset ) ;
260
229
}
261
230
}
262
231
263
232
/* The *real* layout of a type object when allocated on the heap */
264
233
//typedef struct _heaptypeobject {
265
- #if PYTHON_WITH_PYDEBUG
266
- /* _PyObject_HEAD_EXTRA defines pointers to support a doubly-linked list of all live heap objects. */
267
- public static int _ob_next = 0 ;
268
- public static int _ob_prev = 0 ;
269
- #endif
270
234
// PyObject_VAR_HEAD {
271
235
// PyObject_HEAD {
272
236
public static int ob_refcnt = 0 ;
0 commit comments