@@ -66,7 +66,7 @@ inline PyTypeObject *make_static_property_type() {
66
66
issue no Python C API calls which could potentially invoke the
67
67
garbage collector (the GC will call type_traverse(), which will in
68
68
turn find the newly constructed type in an invalid state) */
69
- auto heap_type = (PyHeapTypeObject *) PyType_Type.tp_alloc (&PyType_Type, 0 );
69
+ auto * heap_type = (PyHeapTypeObject *) PyType_Type.tp_alloc (&PyType_Type, 0 );
70
70
if (!heap_type)
71
71
pybind11_fail (" make_static_property_type(): error allocating type!" );
72
72
@@ -75,7 +75,7 @@ inline PyTypeObject *make_static_property_type() {
75
75
heap_type->ht_qualname = name_obj.inc_ref ().ptr ();
76
76
# endif
77
77
78
- auto type = &heap_type->ht_type ;
78
+ auto * type = &heap_type->ht_type ;
79
79
type->tp_name = name;
80
80
type->tp_base = type_incref (&PyProperty_Type);
81
81
type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
@@ -131,7 +131,7 @@ extern "C" inline int pybind11_meta_setattro(PyObject *obj, PyObject *name, PyOb
131
131
// 1. `Type.static_prop = value` --> descr_set: `Type.static_prop.__set__(value)`
132
132
// 2. `Type.static_prop = other_static_prop` --> setattro: replace existing `static_prop`
133
133
// 3. `Type.regular_attribute = value` --> setattro: regular attribute assignment
134
- const auto static_prop = (PyObject *) get_internals ().static_property_type ;
134
+ auto * const static_prop = (PyObject *) get_internals ().static_property_type ;
135
135
const auto call_descr_set = (descr != nullptr ) && (value != nullptr )
136
136
&& (PyObject_IsInstance (descr, static_prop) != 0 )
137
137
&& (PyObject_IsInstance (value, static_prop) == 0 );
@@ -180,7 +180,7 @@ extern "C" inline PyObject *pybind11_meta_call(PyObject *type, PyObject *args, P
180
180
}
181
181
182
182
// This must be a pybind11 instance
183
- auto instance = reinterpret_cast <detail::instance *>(self);
183
+ auto * instance = reinterpret_cast <detail::instance *>(self);
184
184
185
185
// Ensure that the base __init__ function(s) were called
186
186
for (const auto &vh : values_and_holders (instance)) {
@@ -244,7 +244,7 @@ inline PyTypeObject *make_default_metaclass() {
244
244
issue no Python C API calls which could potentially invoke the
245
245
garbage collector (the GC will call type_traverse(), which will in
246
246
turn find the newly constructed type in an invalid state) */
247
- auto heap_type = (PyHeapTypeObject *) PyType_Type.tp_alloc (&PyType_Type, 0 );
247
+ auto * heap_type = (PyHeapTypeObject *) PyType_Type.tp_alloc (&PyType_Type, 0 );
248
248
if (!heap_type)
249
249
pybind11_fail (" make_default_metaclass(): error allocating metaclass!" );
250
250
@@ -253,7 +253,7 @@ inline PyTypeObject *make_default_metaclass() {
253
253
heap_type->ht_qualname = name_obj.inc_ref ().ptr ();
254
254
#endif
255
255
256
- auto type = &heap_type->ht_type ;
256
+ auto * type = &heap_type->ht_type ;
257
257
type->tp_name = name;
258
258
type->tp_base = type_incref (&PyType_Type);
259
259
type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
@@ -285,7 +285,7 @@ inline void traverse_offset_bases(void *valueptr,
285
285
instance *self,
286
286
bool (*f)(void * /* parentptr*/ , instance * /* self*/ )) {
287
287
for (handle h : reinterpret_borrow<tuple>(tinfo->type ->tp_bases )) {
288
- if (auto parent_tinfo = get_type_info ((PyTypeObject *) h.ptr ())) {
288
+ if (auto * parent_tinfo = get_type_info ((PyTypeObject *) h.ptr ())) {
289
289
for (auto &c : parent_tinfo->implicit_casts ) {
290
290
if (c.first == tinfo->cpptype ) {
291
291
auto *parentptr = c.second (valueptr);
@@ -341,7 +341,7 @@ inline PyObject *make_new_instance(PyTypeObject *type) {
341
341
}
342
342
#endif
343
343
PyObject *self = type->tp_alloc (type, 0 );
344
- auto inst = reinterpret_cast <instance *>(self);
344
+ auto * inst = reinterpret_cast <instance *>(self);
345
345
// Allocate the value/holder internals:
346
346
inst->allocate_layout ();
347
347
@@ -366,14 +366,14 @@ extern "C" inline int pybind11_object_init(PyObject *self, PyObject *, PyObject
366
366
367
367
inline void add_patient (PyObject *nurse, PyObject *patient) {
368
368
auto &internals = get_internals ();
369
- auto instance = reinterpret_cast <detail::instance *>(nurse);
369
+ auto * instance = reinterpret_cast <detail::instance *>(nurse);
370
370
instance->has_patients = true ;
371
371
Py_INCREF (patient);
372
372
internals.patients [nurse].push_back (patient);
373
373
}
374
374
375
375
inline void clear_patients (PyObject *self) {
376
- auto instance = reinterpret_cast <detail::instance *>(self);
376
+ auto * instance = reinterpret_cast <detail::instance *>(self);
377
377
auto &internals = get_internals ();
378
378
auto pos = internals.patients .find (self);
379
379
assert (pos != internals.patients .end ());
@@ -390,7 +390,7 @@ inline void clear_patients(PyObject *self) {
390
390
// / Clears all internal data from the instance and removes it from registered instances in
391
391
// / preparation for deallocation.
392
392
inline void clear_instance (PyObject *self) {
393
- auto instance = reinterpret_cast <detail::instance *>(self);
393
+ auto * instance = reinterpret_cast <detail::instance *>(self);
394
394
395
395
// Deallocate any values/holders, if present:
396
396
for (auto &v_h : values_and_holders (instance)) {
@@ -426,7 +426,7 @@ inline void clear_instance(PyObject *self) {
426
426
extern " C" inline void pybind11_object_dealloc (PyObject *self) {
427
427
clear_instance (self);
428
428
429
- auto type = Py_TYPE (self);
429
+ auto * type = Py_TYPE (self);
430
430
type->tp_free (self);
431
431
432
432
#if PY_VERSION_HEX < 0x03080000
@@ -455,7 +455,7 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass) {
455
455
issue no Python C API calls which could potentially invoke the
456
456
garbage collector (the GC will call type_traverse(), which will in
457
457
turn find the newly constructed type in an invalid state) */
458
- auto heap_type = (PyHeapTypeObject *) metaclass->tp_alloc (metaclass, 0 );
458
+ auto * heap_type = (PyHeapTypeObject *) metaclass->tp_alloc (metaclass, 0 );
459
459
if (!heap_type)
460
460
pybind11_fail (" make_object_base_type(): error allocating type!" );
461
461
@@ -464,7 +464,7 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass) {
464
464
heap_type->ht_qualname = name_obj.inc_ref ().ptr ();
465
465
#endif
466
466
467
- auto type = &heap_type->ht_type ;
467
+ auto * type = &heap_type->ht_type ;
468
468
type->tp_name = name;
469
469
type->tp_base = type_incref (&PyBaseObject_Type);
470
470
type->tp_basicsize = static_cast <ssize_t >(sizeof (instance));
@@ -527,7 +527,7 @@ extern "C" inline int pybind11_clear(PyObject *self) {
527
527
528
528
// / Give instances of this type a `__dict__` and opt into garbage collection.
529
529
inline void enable_dynamic_attributes (PyHeapTypeObject *heap_type) {
530
- auto type = &heap_type->ht_type ;
530
+ auto * type = &heap_type->ht_type ;
531
531
type->tp_flags |= Py_TPFLAGS_HAVE_GC;
532
532
type->tp_dictoffset = type->tp_basicsize ; // place dict at the end
533
533
type->tp_basicsize += (ssize_t ) sizeof (PyObject *); // and allocate enough space for it
@@ -622,7 +622,7 @@ inline PyObject *make_new_python_type(const type_record &rec) {
622
622
module_ = rec.scope .attr (" __name__" );
623
623
}
624
624
625
- auto full_name = c_str (
625
+ const auto * full_name = c_str (
626
626
#if !defined(PYPY_VERSION)
627
627
module_ ? str (module_).cast <std::string>() + " ." + rec.name :
628
628
#endif
@@ -639,16 +639,16 @@ inline PyObject *make_new_python_type(const type_record &rec) {
639
639
640
640
auto &internals = get_internals ();
641
641
auto bases = tuple (rec.bases );
642
- auto base = (bases.empty ()) ? internals.instance_base : bases[0 ].ptr ();
642
+ auto * base = (bases.empty ()) ? internals.instance_base : bases[0 ].ptr ();
643
643
644
644
/* Danger zone: from now (and until PyType_Ready), make sure to
645
645
issue no Python C API calls which could potentially invoke the
646
646
garbage collector (the GC will call type_traverse(), which will in
647
647
turn find the newly constructed type in an invalid state) */
648
- auto metaclass
648
+ auto * metaclass
649
649
= rec.metaclass .ptr () ? (PyTypeObject *) rec.metaclass .ptr () : internals.default_metaclass ;
650
650
651
- auto heap_type = (PyHeapTypeObject *) metaclass->tp_alloc (metaclass, 0 );
651
+ auto * heap_type = (PyHeapTypeObject *) metaclass->tp_alloc (metaclass, 0 );
652
652
if (!heap_type)
653
653
pybind11_fail (std::string (rec.name ) + " : Unable to create type object!" );
654
654
@@ -657,7 +657,7 @@ inline PyObject *make_new_python_type(const type_record &rec) {
657
657
heap_type->ht_qualname = qualname.inc_ref ().ptr ();
658
658
#endif
659
659
660
- auto type = &heap_type->ht_type ;
660
+ auto * type = &heap_type->ht_type ;
661
661
type->tp_name = full_name;
662
662
type->tp_doc = tp_doc;
663
663
type->tp_base = type_incref ((PyTypeObject *) base);
0 commit comments