forked from bloomberg/pystack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject.h
More file actions
219 lines (207 loc) Β· 6.27 KB
/
object.h
File metadata and controls
219 lines (207 loc) Β· 6.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#pragma once
#include <cstdint>
#include <sys/types.h>
static_assert(sizeof(void*) == sizeof(intptr_t));
#if INTPTR_MAX == INT64_MAX
# define ENVIRONMENT64
#else
# define ENVIRONMENT32
#endif
namespace pystack {
#define PyObject_HEAD PyObject ob_base;
#define PyObject_VAR_HEAD PyVarObject ob_base;
typedef ssize_t Py_ssize_t;
struct _typeobject;
typedef struct object
{
ssize_t ob_refcnt;
_typeobject* ob_type;
} PyObject;
typedef struct
{
PyObject ob_base;
Py_ssize_t ob_size; /* Number of items in variable part */
} PyVarObject;
typedef PyObject* (*ternaryfunc)(PyObject*, PyObject*, PyObject*);
typedef int (*inquiry)(PyObject*);
typedef void (*freefunc)(void*);
typedef void (*destructor)(PyObject*);
typedef int (*printfunc)(PyObject*, void*, int);
typedef PyObject* (*getattrfunc)(PyObject*, char*);
typedef PyObject* (*getattrofunc)(PyObject*, PyObject*);
typedef int (*setattrfunc)(PyObject*, char*, PyObject*);
typedef int (*setattrofunc)(PyObject*, PyObject*, PyObject*);
typedef int (*cmpfunc)(PyObject*, PyObject*);
typedef PyObject* (*reprfunc)(PyObject*);
typedef long (*hashfunc)(PyObject*);
typedef PyObject* (*richcmpfunc)(PyObject*, PyObject*, int);
typedef PyObject* (*getiterfunc)(PyObject*);
typedef PyObject* (*iternextfunc)(PyObject*);
typedef PyObject* (*descrgetfunc)(PyObject*, PyObject*, PyObject*);
typedef int (*descrsetfunc)(PyObject*, PyObject*, PyObject*);
typedef int (*initproc)(PyObject*, PyObject*, PyObject*);
typedef PyObject* (*newfunc)(_typeobject*, PyObject*, PyObject*);
typedef PyObject* (*allocfunc)(_typeobject*, Py_ssize_t);
typedef int (*visitproc)(PyObject*, void*);
typedef int (*traverseproc)(PyObject*, visitproc, void*);
namespace Python2 {
typedef struct _typeobject
{
PyObject_VAR_HEAD const char* tp_name;
Py_ssize_t tp_basicsize, tp_itemsize;
destructor tp_dealloc;
printfunc tp_print;
getattrfunc tp_getattr;
setattrfunc tp_setattr;
cmpfunc tp_compare;
reprfunc tp_repr;
void* tp_as_number;
void* tp_as_sequence;
void* tp_as_mapping;
hashfunc tp_hash;
ternaryfunc tp_call;
reprfunc tp_str;
getattrofunc tp_getattro;
setattrofunc tp_setattro;
void* tp_as_buffer;
long tp_flags;
const char* tp_doc;
traverseproc tp_traverse;
inquiry tp_clear;
richcmpfunc tp_richcompare;
Py_ssize_t tp_weaklistoffset;
getiterfunc tp_iter;
iternextfunc tp_iternext;
struct PyMethodDef* tp_methods;
struct PyMemberDef* tp_members;
struct PyGetSetDef* tp_getset;
struct _typeobject* tp_base;
PyObject* tp_dict;
descrgetfunc tp_descr_get;
descrsetfunc tp_descr_set;
Py_ssize_t tp_dictoffset;
initproc tp_init;
allocfunc tp_alloc;
newfunc tp_new;
freefunc tp_free;
inquiry tp_is_gc;
PyObject* tp_bases;
PyObject* tp_mro;
PyObject* tp_cache;
PyObject* tp_subclasses;
PyObject* tp_weaklist;
destructor tp_del;
unsigned int tp_version_tag;
} PyTypeObject;
} // namespace Python2
namespace Python3_3 {
typedef struct _typeobject
{
PyObject_VAR_HEAD const char* tp_name; /* For printing, in format "<module>.<name>" */
Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */
destructor tp_dealloc;
printfunc tp_print;
getattrfunc tp_getattr;
setattrfunc tp_setattr;
void* tp_as_async;
reprfunc tp_repr;
void* tp_as_number;
void* tp_as_sequence;
void* tp_as_mapping;
hashfunc tp_hash;
ternaryfunc tp_call;
reprfunc tp_str;
getattrofunc tp_getattro;
setattrofunc tp_setattro;
void* tp_as_buffer;
unsigned long tp_flags;
const char* tp_doc;
traverseproc tp_traverse;
inquiry tp_clear;
richcmpfunc tp_richcompare;
Py_ssize_t tp_weaklistoffset;
getiterfunc tp_iter;
iternextfunc tp_iternext;
struct PyMethodDef* tp_methods;
struct PyMemberDef* tp_members;
struct PyGetSetDef* tp_getset;
struct _typeobject* tp_base;
PyObject* tp_dict;
descrgetfunc tp_descr_get;
descrsetfunc tp_descr_set;
Py_ssize_t tp_dictoffset;
initproc tp_init;
allocfunc tp_alloc;
newfunc tp_new;
freefunc tp_free;
inquiry tp_is_gc;
PyObject* tp_bases;
PyObject* tp_mro;
PyObject* tp_cache;
PyObject* tp_subclasses;
PyObject* tp_weaklist;
destructor tp_del;
unsigned int tp_version_tag;
} PyTypeObject;
} // namespace Python3_3
namespace Python3_8 {
typedef struct _typeobject
{
PyObject_VAR_HEAD const char* tp_name;
Py_ssize_t tp_basicsize, tp_itemsize;
destructor tp_dealloc;
Py_ssize_t tp_vectorcall_offset;
getattrfunc tp_getattr;
setattrfunc tp_setattr;
void* tp_as_async;
reprfunc tp_repr;
void* tp_as_number;
void* tp_as_sequence;
void* tp_as_mapping;
hashfunc tp_hash;
ternaryfunc tp_call;
reprfunc tp_str;
getattrofunc tp_getattro;
setattrofunc tp_setattro;
void* tp_as_buffer;
unsigned long tp_flags;
const char* tp_doc; /* Documentation string */
traverseproc tp_traverse;
inquiry tp_clear;
richcmpfunc tp_richcompare;
Py_ssize_t tp_weaklistoffset;
getiterfunc tp_iter;
iternextfunc tp_iternext;
struct PyMethodDef* tp_methods;
struct PyMemberDef* tp_members;
struct PyGetSetDef* tp_getset;
struct _typeobject* tp_base;
PyObject* tp_dict;
descrgetfunc tp_descr_get;
descrsetfunc tp_descr_set;
Py_ssize_t tp_dictoffset;
initproc tp_init;
allocfunc tp_alloc;
newfunc tp_new;
freefunc tp_free;
inquiry tp_is_gc;
PyObject* tp_bases;
PyObject* tp_mro;
PyObject* tp_cache;
PyObject* tp_subclasses;
PyObject* tp_weaklist;
destructor tp_del;
unsigned int tp_version_tag;
} PyTypeObject;
} // namespace Python3_8
/* These flags are used to determine if a type is a subclass. */
constexpr long Pystack_TPFLAGS_INT_SUBCLASS = 1ul << 23u;
constexpr long Pystack_TPFLAGS_LONG_SUBCLASS = 1ul << 24u;
constexpr long Pystack_TPFLAGS_LIST_SUBCLASS = 1ul << 25u;
constexpr long Pystack_TPFLAGS_TUPLE_SUBCLASS = 1uL << 26u;
constexpr long Pystack_TPFLAGS_BYTES_SUBCLASS = 1uL << 27u;
constexpr long Pystack_TPFLAGS_UNICODE_SUBCLASS = 1uL << 28u;
constexpr long Pystack_TPFLAGS_DICT_SUBCLASS = 1uL << 29u;
constexpr long Pystack_TPFLAGS_BASE_EXC_SUBCLASS = 1uL << 30u;
constexpr long Pystack_TPFLAGS_TYPE_SUBCLASS = 1uL << 31u;
} // namespace pystack