Skip to content

Commit ff17809

Browse files
knoepfeljcpunk
authored andcommitted
Migrate to newer syntax.
1 parent 3e644c6 commit ff17809

File tree

2 files changed

+29
-187
lines changed

2 files changed

+29
-187
lines changed

src/object/class.cpp

+22-141
Original file line numberDiff line numberDiff line change
@@ -143,54 +143,13 @@ extern "C"
143143

144144
static PyTypeObject static_data_object = {
145145
PyVarObject_HEAD_INIT(NULL, 0)
146-
const_cast<char*>("Boost.Python.StaticProperty"),
147-
sizeof(propertyobject),
148-
0,
149-
0, /* tp_dealloc */
150-
0, /* tp_print */
151-
0, /* tp_getattr */
152-
0, /* tp_setattr */
153-
0, /* tp_compare */
154-
0, /* tp_repr */
155-
0, /* tp_as_number */
156-
0, /* tp_as_sequence */
157-
0, /* tp_as_mapping */
158-
0, /* tp_hash */
159-
0, /* tp_call */
160-
0, /* tp_str */
161-
0, /* tp_getattro */
162-
0, /* tp_setattro */
163-
0, /* tp_as_buffer */
164-
Py_TPFLAGS_DEFAULT // | Py_TPFLAGS_HAVE_GC
146+
.tp_name = const_cast<char*>("Boost.Python.StaticProperty"),
147+
.tp_basicsize = sizeof(propertyobject),
148+
.tp_flags = Py_TPFLAGS_DEFAULT // | Py_TPFLAGS_HAVE_GC
165149
| Py_TPFLAGS_BASETYPE, /* tp_flags */
166-
0, /* tp_doc */
167-
0, /* tp_traverse */
168-
0, /* tp_clear */
169-
0, /* tp_richcompare */
170-
0, /* tp_weaklistoffset */
171-
0, /* tp_iter */
172-
0, /* tp_iternext */
173-
0, /* tp_methods */
174-
0, /* tp_members */
175-
0, /* tp_getset */
176-
0, //&PyProperty_Type, /* tp_base */
177-
0, /* tp_dict */
178-
static_data_descr_get, /* tp_descr_get */
179-
static_data_descr_set, /* tp_descr_set */
180-
0, /* tp_dictoffset */
181-
property_init, /* tp_init */
182-
0, /* tp_alloc */
183-
0, // filled in with type_new /* tp_new */
184-
0, // filled in with __PyObject_GC_Del /* tp_free */
185-
0, /* tp_is_gc */
186-
0, /* tp_bases */
187-
0, /* tp_mro */
188-
0, /* tp_cache */
189-
0, /* tp_subclasses */
190-
0, /* tp_weaklist */
191-
#if PYTHON_API_VERSION >= 1012
192-
0 /* tp_del */
193-
#endif
150+
.tp_descr_get = static_data_descr_get,
151+
.tp_descr_set = static_data_descr_set,
152+
.tp_init = property_init,
194153
};
195154

196155
namespace objects
@@ -249,54 +208,12 @@ extern "C"
249208

250209
static PyTypeObject class_metatype_object = {
251210
PyVarObject_HEAD_INIT(NULL, 0)
252-
const_cast<char*>("Boost.Python.class"),
253-
PyType_Type.tp_basicsize,
254-
0,
255-
0, /* tp_dealloc */
256-
0, /* tp_print */
257-
0, /* tp_getattr */
258-
0, /* tp_setattr */
259-
0, /* tp_compare */
260-
0, /* tp_repr */
261-
0, /* tp_as_number */
262-
0, /* tp_as_sequence */
263-
0, /* tp_as_mapping */
264-
0, /* tp_hash */
265-
0, /* tp_call */
266-
0, /* tp_str */
267-
0, /* tp_getattro */
268-
class_setattro, /* tp_setattro */
269-
0, /* tp_as_buffer */
270-
Py_TPFLAGS_DEFAULT // | Py_TPFLAGS_HAVE_GC
211+
.tp_name = const_cast<char*>("Boost.Python.class"),
212+
.tp_basicsize = PyType_Type.tp_basicsize,
213+
.tp_setattro = class_setattro,
214+
.tp_flags = Py_TPFLAGS_DEFAULT // | Py_TPFLAGS_HAVE_GC
271215
| Py_TPFLAGS_BASETYPE, /* tp_flags */
272-
0, /* tp_doc */
273-
0, /* tp_traverse */
274-
0, /* tp_clear */
275-
0, /* tp_richcompare */
276-
0, /* tp_weaklistoffset */
277-
0, /* tp_iter */
278-
0, /* tp_iternext */
279-
0, /* tp_methods */
280-
0, /* tp_members */
281-
0, /* tp_getset */
282-
0, //&PyType_Type, /* tp_base */
283-
0, /* tp_dict */
284-
0, /* tp_descr_get */
285-
0, /* tp_descr_set */
286-
0, /* tp_dictoffset */
287-
0, /* tp_init */
288-
0, /* tp_alloc */
289-
0, // filled in with type_new /* tp_new */
290-
0, // filled in with __PyObject_GC_Del /* tp_free */
291-
(inquiry)type_is_gc, /* tp_is_gc */
292-
0, /* tp_bases */
293-
0, /* tp_mro */
294-
0, /* tp_cache */
295-
0, /* tp_subclasses */
296-
0, /* tp_weaklist */
297-
#if PYTHON_API_VERSION >= 1012
298-
0 /* tp_del */
299-
#endif
216+
.tp_is_gc = (inquiry)type_is_gc,
300217
};
301218

302219
// Install the instance data for a C++ object into a Python instance
@@ -416,54 +333,18 @@ namespace objects
416333

417334
static PyTypeObject class_type_object = {
418335
PyVarObject_HEAD_INIT(NULL, 0)
419-
const_cast<char*>("Boost.Python.instance"),
420-
offsetof(instance<>,storage), /* tp_basicsize */
421-
1, /* tp_itemsize */
422-
instance_dealloc, /* tp_dealloc */
423-
0, /* tp_print */
424-
0, /* tp_getattr */
425-
0, /* tp_setattr */
426-
0, /* tp_compare */
427-
0, /* tp_repr */
428-
0, /* tp_as_number */
429-
0, /* tp_as_sequence */
430-
0, /* tp_as_mapping */
431-
0, /* tp_hash */
432-
0, /* tp_call */
433-
0, /* tp_str */
434-
0, /* tp_getattro */
435-
0, /* tp_setattro */
436-
0, /* tp_as_buffer */
437-
Py_TPFLAGS_DEFAULT // | Py_TPFLAGS_HAVE_GC
336+
.tp_name = const_cast<char*>("Boost.Python.instance"),
337+
.tp_basicsize =offsetof(instance<>,storage),
338+
.tp_itemsize = 1,
339+
.tp_dealloc = instance_dealloc,
340+
.tp_flags = Py_TPFLAGS_DEFAULT // | Py_TPFLAGS_HAVE_GC
438341
| Py_TPFLAGS_BASETYPE, /* tp_flags */
439-
0, /* tp_doc */
440-
0, /* tp_traverse */
441-
0, /* tp_clear */
442-
0, /* tp_richcompare */
443-
offsetof(instance<>,weakrefs), /* tp_weaklistoffset */
444-
0, /* tp_iter */
445-
0, /* tp_iternext */
446-
0, /* tp_methods */
447-
instance_members, /* tp_members */
448-
instance_getsets, /* tp_getset */
449-
0, //&PyBaseObject_Type, /* tp_base */
450-
0, /* tp_dict */
451-
0, /* tp_descr_get */
452-
0, /* tp_descr_set */
453-
offsetof(instance<>,dict), /* tp_dictoffset */
454-
0, /* tp_init */
455-
PyType_GenericAlloc, /* tp_alloc */
456-
instance_new, /* tp_new */
457-
0, /* tp_free */
458-
0, /* tp_is_gc */
459-
0, /* tp_bases */
460-
0, /* tp_mro */
461-
0, /* tp_cache */
462-
0, /* tp_subclasses */
463-
0, /* tp_weaklist */
464-
#if PYTHON_API_VERSION >= 1012
465-
0 /* tp_del */
466-
#endif
342+
.tp_weaklistoffset =offsetof(instance<>,weakrefs),
343+
.tp_members = instance_members,
344+
.tp_getset = instance_getsets,
345+
.tp_dictoffset = offsetof(instance<>,dict),
346+
.tp_alloc = PyType_GenericAlloc,
347+
.tp_new = instance_new,
467348
};
468349

469350
BOOST_PYTHON_DECL type_handle class_type()

src/object/enum.cpp

+7-46
Original file line numberDiff line numberDiff line change
@@ -91,58 +91,19 @@ extern "C"
9191

9292
static PyTypeObject enum_type_object = {
9393
PyVarObject_HEAD_INIT(NULL, 0) // &PyType_Type
94-
const_cast<char*>("Boost.Python.enum"),
95-
sizeof(enum_object), /* tp_basicsize */
96-
0, /* tp_itemsize */
97-
(destructor) enum_dealloc, /* tp_dealloc */
98-
0, /* tp_print */
99-
0, /* tp_getattr */
100-
0, /* tp_setattr */
101-
0, /* tp_compare */
102-
enum_repr, /* tp_repr */
103-
0, /* tp_as_number */
104-
0, /* tp_as_sequence */
105-
0, /* tp_as_mapping */
106-
0, /* tp_hash */
107-
0, /* tp_call */
108-
enum_str, /* tp_str */
109-
0, /* tp_getattro */
110-
0, /* tp_setattro */
111-
0, /* tp_as_buffer */
94+
.tp_name = const_cast<char*>("Boost.Python.enum"),
95+
.tp_basicsize = sizeof(enum_object),
96+
.tp_dealloc = (destructor) enum_dealloc,
97+
.tp_repr = enum_repr,
98+
.tp_str = enum_str,
99+
.tp_flags =
112100
Py_TPFLAGS_DEFAULT
113101
#if PY_VERSION_HEX < 0x03000000
114102
| Py_TPFLAGS_CHECKTYPES
115103
#endif
116104
| Py_TPFLAGS_HAVE_GC
117105
| Py_TPFLAGS_BASETYPE, /* tp_flags */
118-
0, /* tp_doc */
119-
0, /* tp_traverse */
120-
0, /* tp_clear */
121-
0, /* tp_richcompare */
122-
0, /* tp_weaklistoffset */
123-
0, /* tp_iter */
124-
0, /* tp_iternext */
125-
0, /* tp_methods */
126-
enum_members, /* tp_members */
127-
0, /* tp_getset */
128-
0, //&PyInt_Type, /* tp_base */
129-
0, /* tp_dict */
130-
0, /* tp_descr_get */
131-
0, /* tp_descr_set */
132-
0, /* tp_dictoffset */
133-
0, /* tp_init */
134-
0, /* tp_alloc */
135-
0, /* tp_new */
136-
0, /* tp_free */
137-
0, /* tp_is_gc */
138-
0, /* tp_bases */
139-
0, /* tp_mro */
140-
0, /* tp_cache */
141-
0, /* tp_subclasses */
142-
0, /* tp_weaklist */
143-
#if PYTHON_API_VERSION >= 1012
144-
0 /* tp_del */
145-
#endif
106+
.tp_members = enum_members,
146107
};
147108

148109
object module_prefix();

0 commit comments

Comments
 (0)