8000 Refcounting Smart Pointers by insertinterestingnamehere · Pull Request #702 · libdynd/dynd-python · GitHub
[go: up one dir, main page]

Skip to content

Refcounting Smart Pointers #702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
d7ac59e
Add smart pointer classes for managing pyobject pointers.
insertinterestingnamehere May 24, 2016
844d532
Update dynd-python codebase to use new py_ref class.
insertinterestingnamehere May 24, 2016
3658354
Fix MSVC compilation error.
insertinterestingnamehere Jun 3, 2016
acca45b
Rewrite smart pointers that encapsulate Python references.
insertinterestingnamehere Jun 4, 2016
ecc96d3
Add RAII class to release the GIL.
insertinterestingnamehere Jun 6, 2016
fb7d0eb
Add explicit syntax for borrowing a reference from a wrapped PyObject*.
insertinterestingnamehere Jun 9, 2016
791696a
Add convenience function for null-checking a smart pointer wrapping a
insertinterestingnamehere Jun 9, 2016
24d4a32
Add a convenience function to aid in casting from a possibly null
insertinterestingnamehere Jun 9, 2016
4d0d38e
Add a series of assert statements to ensure that wrapped references
insertinterestingnamehere Jun 9, 2016
ebeb883
Make release method for py_ref return an owned or borrowed reference
insertinterestingnamehere Jun 9, 2016
059e012
Move the release method of pydynd::py_ref_tmpl to be a function that …
insertinterestingnamehere Jun 9, 2016
7f2eaba
Rename py_ref_tmpl to py_ref_t.
insertinterestingnamehere Jun 9, 2016
495faf4
Add a method to get an owned reference from a given reference.
insertinterestingnamehere Jun 9, 2016
a1aa405
Add method to py_ref_t to create a new owned reference from a given
insertinterestingnamehere Jun 9, 2016
7962d97
Add method to py_ref_t to copy the current reference.
insertinterestingnamehere Jun 9, 2016
fc522f4
Fix typo in disallow_null where release was not correctly used.
insertinterestingnamehere Jun 10, 2016
9e8bf42
Close a reference leak in smart pointers for managing PyObject pointers.
insertinterestingnamehere Jun 22, 2016
4d9ec89
Add more commenting to the new py_ref classes.
insertinterestingnamehere Aug 3, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix MSVC compilation error.
The order of the conditions in enable_if_t matters since,
in some cases, the compiler uses short circuit evaluation
of the compile-time constant expressions to simplify
the enable_if condition so that it no longer depends on
the inputs and only depends on the template parameters
of the class being constructed, which, then, causes
an error since that isn't allowed.
  • Loading branch information
insertinterestingnamehere committed Jul 1, 2016
commit 365835470389f8af771a8e8ba8b3e3fe9ea99022
8 changes: 4 additions & 4 deletions dynd/include/utility_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class py_ref_tmpl {
* Then:
* Require that conversions from the other py_ref_tmpl type to this type be explcit.
*/
template <bool other_owns, bool other_not_null, typename std::enable_if_t<not_null && !other_not_null> * = nullptr>
template <bool other_owns, bool other_not_null, typename std::enable_if_t<!other_not_null && not_null> * = nullptr>
explicit py_ref_tmpl(const py_ref_tmpl<other_owns, other_not_null> &other) noexcept
{
o = other.o;
Expand All @@ -161,7 +161,7 @@ class py_ref_tmpl {
* Then:
* a move operation can be implicitly performed.
*/
template <bool other_not_null, typename std::enable_if_t<owns_ref && (other_not_null || !not_null)> * = nullptr>
template <bool other_not_null, typename std::enable_if_t<(other_not_null || !not_null) && owns_ref> * = nullptr>
py_ref_tmpl(py_ref_tmpl<true, other_not_null> &&other) noexcept
{
o = other.o;
Expand All @@ -173,7 +173,7 @@ class py_ref_tmpl {
* Then:
* only an explicit move operation can be performed.
*/
template <bool other_not_null, typename std::enable_if_t<owns_ref && !other_not_null && not_null> * = nullptr>
template <bool other_not_null, typename std::enable_if_t<!other_not_null && not_null && owns_ref> * = nullptr>
explicit py_ref_tmpl(py_ref_tmpl<true, other_not_null> &&other) noexcept
{
o = other.o;
Expand Down Expand Up @@ -216,7 +216,7 @@ class py_ref_tmpl {
* Allow assignment from the other py_ref_tmpl type to this type.
*/
template <bool other_owns, bool other_not_null,
typename std::enable_if_t<!not_null || (not_null && other_not_null)> * = nullptr>
typename std::enable_if_t<(other_not_null && not_null) || !not_null> * = nullptr>
py_ref_tmpl<owns_ref, not_null> operator=(const py_ref_tmpl<other_owns, other_not_null> &other) noexcept
{
decref_if_owned<owns_ref, not_null>(o);
Expand Down
0