Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
09db57a3
Commit
09db57a3
authored
Dec 07, 2020
by
Ralf W. Grosse-Kunstleve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
artifacts from looking at situations with owned = false
parent
c8e37b58
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
3 deletions
+14
-3
include/pybind11/cast.h
+7
-2
include/pybind11/detail/class.h
+1
-1
include/pybind11/detail/common.h
+6
-0
No files found.
include/pybind11/cast.h
View file @
09db57a3
...
@@ -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
;
...
...
include/pybind11/detail/class.h
View file @
09db57a3
...
@@ -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
;
}
}
...
...
include/pybind11/detail/common.h
View file @
09db57a3
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment