artifacts from looking at situations with owned = false

parent c8e37b58
......@@ -392,7 +392,7 @@ PYBIND11_NOINLINE inline void instance::allocate_layout() {
#endif
nonsimple.status = reinterpret_cast<uint8_t *>(&nonsimple.values_and_holders[flags_at]);
}
aaa_owned = true;
aaa_owned = true; // (ALMOST?) ALWAYS USED.
}
PYBIND11_NOINLINE inline void instance::deallocate_layout() {
......@@ -518,7 +518,7 @@ public:
auto inst = reinterpret_steal<object>(make_new_instance(tinfo->type));
auto wrapper = reinterpret_cast<instance *>(inst.ptr());
wrapper->aaa_owned = false;
// wrapper->aaa_owned = false; NOT NEEDED
void *&valueptr = values_and_holders(wrapper).begin()->xxx_value_ptr<void>(); // holder_type not available here.
switch (policy) {
......@@ -526,12 +526,14 @@ public:
case return_value_policy::take_ownership:
valueptr = src;
wrapper->aaa_owned = true;
// to_cout("aaa_owned = true switch policy return_value_policy::automatic,take_ownership");
break;
case return_value_policy::automatic_reference:
case return_value_policy::reference:
valueptr = src;
wrapper->aaa_owned = false;
// to_cout("aaa_owned = false switch policy return_value_policy::automatic_reference,reference");
break;
case return_value_policy::copy:
......@@ -549,6 +551,7 @@ public:
#endif
}
wrapper->aaa_owned = true;
// to_cout("aaa_owned = true switch policy return_value_policy::copy");
break;
case return_value_policy::move:
......@@ -569,11 +572,13 @@ public:
#endif
}
wrapper->aaa_owned = true;
// to_cout("aaa_owned = true switch policy return_value_policy::move");
break;
case return_value_policy::reference_internal:
valueptr = src;
wrapper->aaa_owned = false;
// to_cout("aaa_owned = false switch policy return_value_policy::reference_internal");
keep_alive_impl(inst, parent);
break;
......
......@@ -340,7 +340,7 @@ inline PyObject *make_new_instance(PyTypeObject *type) {
// Allocate the value/holder internals:
inst->allocate_layout();
inst->aaa_owned = true;
inst->aaa_owned = true; // (ALMOST?) ALWAYS USED.
return self;
}
......
......@@ -163,6 +163,8 @@
#include <typeindex>
#include <type_traits>
#include <iostream>
#if PY_MAJOR_VERSION >= 3 /// Compatibility macros for various Python versions
#define PYBIND11_INSTANCE_METHOD_NEW(ptr, class_) PyInstanceMethod_New(ptr)
#define PYBIND11_INSTANCE_METHOD_CHECK PyInstanceMethod_Check
......@@ -389,6 +391,10 @@ enum class return_value_policy : uint8_t {
PYBIND11_NAMESPACE_BEGIN(detail)
inline void to_cout(std::string msg) {
std::cout << std::endl << msg << std::endl;
}
inline static constexpr int log2(size_t n, int k = 0) { return (n <= 1) ? k : log2(n >> 1, k + 1); }
// Returns the size as a multiple of sizeof(void *), rounded up.
......
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