artifacts from looking at situations with owned = false

parent c8e37b58
...@@ -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]);
} }
aaa_owned = true; aaa_owned = true; // (ALMOST?) ALWAYS USED.
} }
PYBIND11_NOINLINE inline void instance::deallocate_layout() { PYBIND11_NOINLINE inline void instance::deallocate_layout() {
...@@ -518,7 +518,7 @@ public: ...@@ -518,7 +518,7 @@ 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->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. void *&valueptr = values_and_holders(wrapper).begin()->xxx_value_ptr<void>(); // holder_type not available here.
switch (policy) { switch (policy) {
...@@ -526,12 +526,14 @@ public: ...@@ -526,12 +526,14 @@ public:
case return_value_policy::take_ownership: case return_value_policy::take_ownership:
valueptr = src; valueptr = src;
wrapper->aaa_owned = true; wrapper->aaa_owned = true;
// to_cout("aaa_owned = true switch policy return_value_policy::automatic,take_ownership");
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->aaa_owned = false; wrapper->aaa_owned = false;
// to_cout("aaa_owned = false switch policy return_value_policy::automatic_reference,reference");
break; break;
case return_value_policy::copy: case return_value_policy::copy:
...@@ -549,6 +551,7 @@ public: ...@@ -549,6 +551,7 @@ public:
#endif #endif
} }
wrapper->aaa_owned = true; wrapper->aaa_owned = true;
// to_cout("aaa_owned = true switch policy return_value_policy::copy");
break; break;
case return_value_policy::move: case return_value_policy::move:
...@@ -569,11 +572,13 @@ public: ...@@ -569,11 +572,13 @@ public:
#endif #endif
} }
wrapper->aaa_owned = true; wrapper->aaa_owned = true;
// to_cout("aaa_owned = true switch policy return_value_policy::move");
break; break;
case return_value_policy::reference_internal: case return_value_policy::reference_internal:
valueptr = src; valueptr = src;
wrapper->aaa_owned = false; wrapper->aaa_owned = false;
// to_cout("aaa_owned = false switch policy return_value_policy::reference_internal");
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->aaa_owned = true; inst->aaa_owned = true; // (ALMOST?) ALWAYS USED.
return self; return self;
} }
......
...@@ -163,6 +163,8 @@ ...@@ -163,6 +163,8 @@
#include <typeindex> #include <typeindex>
#include <type_traits> #include <type_traits>
#include <iostream>
#if PY_MAJOR_VERSION >= 3 /// Compatibility macros for various Python versions #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_NEW(ptr, class_) PyInstanceMethod_New(ptr)
#define PYBIND11_INSTANCE_METHOD_CHECK PyInstanceMethod_Check #define PYBIND11_INSTANCE_METHOD_CHECK PyInstanceMethod_Check
...@@ -389,6 +391,10 @@ enum class return_value_policy : uint8_t { ...@@ -389,6 +391,10 @@ enum class return_value_policy : uint8_t {
PYBIND11_NAMESPACE_BEGIN(detail) 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); } 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. // 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