@@ -65,7 +65,7 @@ inline PyTypeObject *make_static_property_type() {
65
65
issue no Python C API calls which could potentially invoke the
66
66
garbage collector (the GC will call type_traverse(), which will in
67
67
turn find the newly constructed type in an invalid state) */
68
- auto heap_type = (PyHeapTypeObject *) PyType_Type.tp_alloc (&PyType_Type, 0 );
68
+ auto * heap_type = (PyHeapTypeObject *) PyType_Type.tp_alloc (&PyType_Type, 0 );
69
69
if (!heap_type) {
70
70
pybind11_fail (" make_static_property_type(): error allocating type!" );
71
71
}
@@ -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;
@@ -130,7 +130,7 @@ extern "C" inline int pybind11_meta_setattro(PyObject* obj, PyObject* name, PyOb
130
130
// 1. `Type.static_prop = value` --> descr_set: `Type.static_prop.__set__(value)`
131
131
// 2. `Type.static_prop = other_static_prop` --> setattro: replace existing `static_prop`
132
132
// 3. `Type.regular_attribute = value` --> setattro: regular attribute assignment
133
- const auto static_prop = (PyObject *) get_internals ().static_property_type ;
133
+ auto * const static_prop = (PyObject *) get_internals ().static_property_type ;
134
134
const auto call_descr_set = (descr != nullptr ) && (value != nullptr )
135
135
&& (PyObject_IsInstance (descr, static_prop) != 0 )
136
136
&& (PyObject_IsInstance (value, static_prop) == 0 );
@@ -179,7 +179,7 @@ extern "C" inline PyObject *pybind11_meta_call(PyObject *type, PyObject *args, P
179
179
}
180
180
181
181
// This must be a pybind11 instance
182
- auto instance = reinterpret_cast <detail::instance *>(self);
182
+ auto * instance = reinterpret_cast <detail::instance *>(self);
183
183
184
184
// Ensure that the base __init__ function(s) were called
185
185
for (const auto &vh : values_and_holders (instance)) {
@@ -245,7 +245,7 @@ inline PyTypeObject* make_default_metaclass() {
245
245
issue no Python C API calls which could potentially invoke the
246
246
garbage collector (the GC will call type_traverse(), which will in
247
247
turn find the newly constructed type in an invalid state) */
248
- auto heap_type = (PyHeapTypeObject *) PyType_Type.tp_alloc (&PyType_Type, 0 );
248
+ auto * heap_type = (PyHeapTypeObject *) PyType_Type.tp_alloc (&PyType_Type, 0 );
249
249
if (!heap_type) {
250
250
pybind11_fail (" make_default_metaclass(): error allocating metaclass!" );
251
251
}
@@ -255,7 +255,7 @@ inline PyTypeObject* make_default_metaclass() {
255
255
heap_type->ht_qualname = name_obj.inc_ref ().ptr ();
256
256
#endif
257
257
258
- auto type = &heap_type->ht_type ;
258
+ auto * type = &heap_type->ht_type ;
259
259
type->tp_name = name;
260
260
type->tp_base = type_incref (&PyType_Type);
261
261
type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
@@ -285,7 +285,7 @@ inline PyTypeObject* make_default_metaclass() {
285
285
inline void traverse_offset_bases (void *valueptr, const detail::type_info *tinfo, 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);
@@ -344,7 +344,7 @@ inline PyObject *make_new_instance(PyTypeObject *type) {
344
344
}
345
345
#endif
346
346
PyObject *self = type->tp_alloc (type, 0 );
347
- auto inst = reinterpret_cast <instance *>(self);
347
+ auto * inst = reinterpret_cast <instance *>(self);
348
348
// Allocate the value/holder internals:
349
349
inst->allocate_layout ();
350
350
@@ -369,14 +369,14 @@ extern "C" inline int pybind11_object_init(PyObject *self, PyObject *, PyObject
369
369
370
370
inline void add_patient (PyObject *nurse, PyObject *patient) {
371
371
auto &internals = get_internals ();
372
- auto instance = reinterpret_cast <detail::instance *>(nurse);
372
+ auto * instance = reinterpret_cast <detail::instance *>(nurse);
373
373
instance->has_patients = true ;
374
374
Py_INCREF (patient);
375
375
internals.patients [nurse].push_back (patient);
376
376
}
377
377
378
378
inline void clear_patients (PyObject *self) {
379
- auto instance = reinterpret_cast <detail::instance *>(self);
379
+ auto * instance = reinterpret_cast <detail::instance *>(self);
380
380
auto &internals = get_internals ();
381
381
auto pos = internals.patients .find (self);
382
382
assert (pos != internals.patients .end ());
@@ -394,7 +394,7 @@ inline void clear_patients(PyObject *self) {
394
394
// / Clears all internal data from the instance and removes it from registered instances in
395
395
// / preparation for deallocation.
396
396
inline void clear_instance (PyObject *self) {
397
- auto instance = reinterpret_cast <detail::instance *>(self);
397
+ auto * instance = reinterpret_cast <detail::instance *>(self);
398
398
399
399
// Deallocate any values/holders, if present:
400
400
for (auto &v_h : values_and_holders (instance)) {
@@ -435,7 +435,7 @@ inline void clear_instance(PyObject *self) {
435
435
extern " C" inline void pybind11_object_dealloc (PyObject *self) {
436
436
clear_instance (self);
437
437
438
- auto type = Py_TYPE (self);
438
+ auto * type = Py_TYPE (self);
439
439
type->tp_free (self);
440
440
441
441
#if PY_VERSION_HEX < 0x03080000
@@ -464,7 +464,7 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass) {
464
464
issue no Python C API calls which could potentially invoke the
465
465
garbage collector (the GC will call type_traverse(), which will in
466
466
turn find the newly constructed type in an invalid state) */
467
- auto heap_type = (PyHeapTypeObject *) metaclass->tp_alloc (metaclass, 0 );
467
+ auto * heap_type = (PyHeapTypeObject *) metaclass->tp_alloc (metaclass, 0 );
468
468
if (!heap_type) {
469
469
pybind11_fail (" make_object_base_type(): error allocating type!" );
470
470
}
@@ -474,7 +474,7 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass) {
474
474
heap_type->ht_qualname = name_obj.inc_ref ().ptr ();
475
475
#endif
476
476
477
- auto type = &heap_type->ht_type ;
477
+ auto * type = &heap_type->ht_type ;
478
478
type->tp_name = name;
479
479
type->tp_base = type_incref (&PyBaseObject_Type);
480
480
type->tp_basicsize = static_cast <ssize_t >(sizeof (instance));
@@ -538,7 +538,7 @@ extern "C" inline int pybind11_clear(PyObject *self) {
538
538
539
539
// / Give instances of this type a `__dict__` and opt into garbage collection.
540
540
inline void enable_dynamic_attributes (PyHeapTypeObject *heap_type) {
541
- auto type = &heap_type->ht_type ;
541
+ auto * type = &heap_type->ht_type ;
542
542
type->tp_flags |= Py_TPFLAGS_HAVE_GC;
543
543
type->tp_dictoffset = type->tp_basicsize ; // place dict at the end
544
544
type->tp_basicsize += (ssize_t )sizeof (PyObject *); // and allocate enough space for it
@@ -639,11 +639,11 @@ inline PyObject* make_new_python_type(const type_record &rec) {
639
639
}
640
640
}
641
641
642
- auto full_name = c_str (
642
+ const auto * full_name = c_str (
643
643
#if !defined(PYPY_VERSION)
644
644
module_ ? str (module_).cast <std::string>() + " ." + rec.name :
645
645
#endif
646
- rec.name );
646
+ rec.name );
647
647
648
648
char *tp_doc = nullptr ;
649
649
if (rec.doc && options::show_user_defined_docstrings ()) {
@@ -656,17 +656,16 @@ inline PyObject* make_new_python_type(const type_record &rec) {
656
656
657
657
auto &internals = get_internals ();
658
658
auto bases = tuple (rec.bases );
659
- auto base = (bases.empty ()) ? internals.instance_base
660
- : bases[0 ].ptr ();
659
+ auto *base = (bases.empty ()) ? internals.instance_base : bases[0 ].ptr ();
661
660
662
661
/* Danger zone: from now (and until PyType_Ready), make sure to
663
662
issue no Python C API calls which could potentially invoke the
664
663
garbage collector (the GC will call type_traverse(), which will in
665
664
turn find the newly constructed type in an invalid state) */
666
- auto metaclass = rec. metaclass . ptr () ? (PyTypeObject *) rec. metaclass . ptr ()
667
- : internals.default_metaclass ;
665
+ auto * metaclass
666
+ = rec. metaclass . ptr () ? (PyTypeObject *) rec. metaclass . ptr () : internals.default_metaclass ;
668
667
669
- auto heap_type = (PyHeapTypeObject *) metaclass->tp_alloc (metaclass, 0 );
668
+ auto * heap_type = (PyHeapTypeObject *) metaclass->tp_alloc (metaclass, 0 );
670
669
if (!heap_type) {
671
670
pybind11_fail (std::string (rec.name ) + " : Unable to create type object!" );
672
671
}
@@ -676,7 +675,7 @@ inline PyObject* make_new_python_type(const type_record &rec) {
676
675
heap_type->ht_qualname = qualname.inc_ref ().ptr ();
677
676
#endif
678
677
679
- auto type = &heap_type->ht_type ;
678
+ auto * type = &heap_type->ht_type ;
680
679
type->tp_name = full_name;
681
680
type->tp_doc = tp_doc;
682
681
type->tp_base = type_incref ((PyTypeObject *)base);
0 commit comments