renaming instance::owned to aaa_owned, to pin-point where it is used

parent e639c3a7
...@@ -392,7 +392,7 @@ PYBIND11_NOINLINE inline void instance::allocate_layout() { ...@@ -392,7 +392,7 @@ PYBIND11_NOINLINE inline void instance::allocate_layout() {
#endif #endif
nonsimple.status = reinterpret_cast<uint8_t *>(&nonsimple.values_and_holders[flags_at]); nonsimple.status = reinterpret_cast<uint8_t *>(&nonsimple.values_and_holders[flags_at]);
} }
owned = true; aaa_owned = true;
} }
PYBIND11_NOINLINE inline void instance::deallocate_layout() { PYBIND11_NOINLINE inline void instance::deallocate_layout() {
...@@ -518,20 +518,20 @@ public: ...@@ -518,20 +518,20 @@ public:
auto inst = reinterpret_steal<object>(make_new_instance(tinfo->type)); auto inst = reinterpret_steal<object>(make_new_instance(tinfo->type));
auto wrapper = reinterpret_cast<instance *>(inst.ptr()); auto wrapper = reinterpret_cast<instance *>(inst.ptr());
wrapper->owned = false; wrapper->aaa_owned = false;
void *&valueptr = values_and_holders(wrapper).begin()->xxx_value_ptr<void>(); // holder_type not available here. void *&valueptr = values_and_holders(wrapper).begin()->xxx_value_ptr<void>(); // holder_type not available here.
switch (policy) { switch (policy) {
case return_value_policy::automatic: case return_value_policy::automatic:
case return_value_policy::take_ownership: case return_value_policy::take_ownership:
valueptr = src; valueptr = src;
wrapper->owned = true; wrapper->aaa_owned = true;
break; break;
case return_value_policy::automatic_reference: case return_value_policy::automatic_reference:
case return_value_policy::reference: case return_value_policy::reference:
valueptr = src; valueptr = src;
wrapper->owned = false; wrapper->aaa_owned = false;
break; break;
case return_value_policy::copy: case return_value_policy::copy:
...@@ -548,7 +548,7 @@ public: ...@@ -548,7 +548,7 @@ public:
type_name + " is non-copyable!"); type_name + " is non-copyable!");
#endif #endif
} }
wrapper->owned = true; wrapper->aaa_owned = true;
break; break;
case return_value_policy::move: case return_value_policy::move:
...@@ -568,12 +568,12 @@ public: ...@@ -568,12 +568,12 @@ public:
type_name + " is neither movable nor copyable!"); type_name + " is neither movable nor copyable!");
#endif #endif
} }
wrapper->owned = true; wrapper->aaa_owned = true;
break; break;
case return_value_policy::reference_internal: case return_value_policy::reference_internal:
valueptr = src; valueptr = src;
wrapper->owned = false; wrapper->aaa_owned = false;
keep_alive_impl(inst, parent); keep_alive_impl(inst, parent);
break; break;
......
...@@ -340,7 +340,7 @@ inline PyObject *make_new_instance(PyTypeObject *type) { ...@@ -340,7 +340,7 @@ inline PyObject *make_new_instance(PyTypeObject *type) {
// Allocate the value/holder internals: // Allocate the value/holder internals:
inst->allocate_layout(); inst->allocate_layout();
inst->owned = true; inst->aaa_owned = true;
return self; return self;
} }
...@@ -398,7 +398,7 @@ inline void clear_instance(PyObject *self) { ...@@ -398,7 +398,7 @@ inline void clear_instance(PyObject *self) {
if (v_h.instance_registered() && !deregister_instance(instance, v_h.xxx_value_ptr<void>(), v_h.type)) if (v_h.instance_registered() && !deregister_instance(instance, v_h.xxx_value_ptr<void>(), v_h.type))
pybind11_fail("pybind11_object_dealloc(): Tried to deallocate unregistered instance!"); pybind11_fail("pybind11_object_dealloc(): Tried to deallocate unregistered instance!");
if (instance->owned || v_h.holder_constructed()) if (instance->aaa_owned || v_h.holder_constructed())
v_h.type->dealloc(v_h); v_h.type->dealloc(v_h);
} }
} }
......
...@@ -426,7 +426,7 @@ struct instance { ...@@ -426,7 +426,7 @@ struct instance {
/// Weak references /// Weak references
PyObject *weakrefs; PyObject *weakrefs;
/// If true, the pointer is owned which means we're free to manage it with a holder. /// If true, the pointer is owned which means we're free to manage it with a holder.
bool owned : 1; bool aaa_owned : 1;
/** /**
* An instance has two possible value/holder layouts. * An instance has two possible value/holder layouts.
* *
......
...@@ -1464,7 +1464,7 @@ private: ...@@ -1464,7 +1464,7 @@ private:
} }
} catch (const std::bad_weak_ptr &) {} } catch (const std::bad_weak_ptr &) {}
if (!v_h.holder_constructed() && inst->owned) { if (!v_h.holder_constructed() && inst->aaa_owned) {
new (std::addressof(v_h.xxx_holder<holder_type>())) holder_type(v_h.xxx_value_ptr<type>()); // init_holder new (std::addressof(v_h.xxx_holder<holder_type>())) holder_type(v_h.xxx_value_ptr<type>()); // init_holder
v_h.set_holder_constructed(); v_h.set_holder_constructed();
} }
...@@ -1486,7 +1486,7 @@ private: ...@@ -1486,7 +1486,7 @@ private:
if (holder_ptr) { if (holder_ptr) {
init_holder_from_existing(v_h, holder_ptr, std::is_copy_constructible<holder_type>()); init_holder_from_existing(v_h, holder_ptr, std::is_copy_constructible<holder_type>());
v_h.set_holder_constructed(); v_h.set_holder_constructed();
} else if (inst->owned || detail::always_construct_holder<holder_type>::value) { } else if (inst->aaa_owned || detail::always_construct_holder<holder_type>::value) {
new (std::addressof(v_h.xxx_holder<holder_type>())) holder_type(v_h.xxx_value_ptr<type>()); // init_holder new (std::addressof(v_h.xxx_holder<holder_type>())) holder_type(v_h.xxx_value_ptr<type>()); // init_holder
v_h.set_holder_constructed(); v_h.set_holder_constructed();
} }
...@@ -1495,7 +1495,7 @@ private: ...@@ -1495,7 +1495,7 @@ private:
/// Performs instance initialization including constructing a holder and registering the known /// Performs instance initialization including constructing a holder and registering the known
/// instance. Should be called as soon as the `type` value_ptr is set for an instance. Takes an /// instance. Should be called as soon as the `type` value_ptr is set for an instance. Takes an
/// optional pointer to an existing holder to use; if not specified and the instance is /// optional pointer to an existing holder to use; if not specified and the instance is
/// `.owned`, a new holder will be constructed to manage the value pointer. /// `.aaa_owned`, a new holder will be constructed to manage the value pointer.
static void init_instance(detail::instance *inst, const void *holder_ptr) { static void init_instance(detail::instance *inst, const void *holder_ptr) {
auto v_h = inst->get_value_and_holder(detail::get_type_info(typeid(type))); auto v_h = inst->get_value_and_holder(detail::get_type_info(typeid(type)));
if (!v_h.instance_registered()) { if (!v_h.instance_registered()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment