Skip to content

Commit

Permalink
v1.6.1 release
Browse files Browse the repository at this point in the history
wjakob committed Oct 2, 2023
1 parent 85d7582 commit 3ba3522
Showing 5 changed files with 38 additions and 28 deletions.
7 changes: 7 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -15,6 +15,13 @@ case, both modules must use the same nanobind ABI version, or they will be
isolated from each other. Releases that don't explicitly mention an ABI version
below inherit that of the preceding release.

Version 1.6.1 (Oct 2, 2023)
-------------------

* Added missing namespace declaration to the :cpp:class:`ref` intrusive
reference counting RAII helper class added in version 1.6.0. (commit `1a4df2
<https://github.com/wjakob/nanobind/commit/1a4df20265bb2a301f831c00e52c9ac8099c8675>`__).

Version 1.6.0 (Oct 2, 2023)
-------------------

47 changes: 25 additions & 22 deletions include/nanobind/intrusive/ref.h
Original file line number Diff line number Diff line change
@@ -16,6 +16,8 @@

#include "counter.h"

NAMESPACE_BEGIN(nanobind)

/**
* \brief RAII scoped reference counting helper class
*
@@ -110,27 +112,28 @@ template <typename T> class ref {

// Registar a type caster for ``ref<T>`` if nanobind was previously #included
#if defined(NB_VERSION_MAJOR)
namespace nanobind::detail {
template <typename T> struct type_caster<ref<T>> {
using Caster = make_caster<T>;
static constexpr bool IsClass = true;
NB_TYPE_CASTER(ref<T>, Caster::Name);

bool from_python(handle src, uint8_t flags,
cleanup_list *cleanup) noexcept {
Caster caster;
if (!caster.from_python(src, flags, cleanup))
return false;

value = Value(caster.operator T *());
return true;
}

static handle from_cpp(const ref<T> &value, rv_policy policy,
cleanup_list *cleanup) noexcept {
return Caster::from_cpp(value.get(), policy, cleanup);
}
};
};
NAMESPACE_BEGIN(detail)
template <typename T> struct type_caster<nanobind::ref<T>> {
using Caster = make_caster<T>;
static constexpr bool IsClass = true;
NB_TYPE_CASTER(ref<T>, Caster::Name);

bool from_python(handle src, uint8_t flags,
cleanup_list *cleanup) noexcept {
Caster caster;
if (!caster.from_python(src, flags, cleanup))
return false;

value = Value(caster.operator T *());
return true;
}

static handle from_cpp(const ref<T> &value, rv_policy policy,
cleanup_list *cleanup) noexcept {
return Caster::from_cpp(value.get(), policy, cleanup);
}
};
NAMESPACE_END(detail)
#endif

NAMESPACE_END(nanobind)
2 changes: 1 addition & 1 deletion include/nanobind/nanobind.h
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@

#define NB_VERSION_MAJOR 1
#define NB_VERSION_MINOR 6
#define NB_VERSION_PATCH 0
#define NB_VERSION_PATCH 1

// Core C++ headers that nanobind depends on
#include <cstdint>
2 changes: 1 addition & 1 deletion src/__init__.py
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ def cmake_dir() -> str:
"Return the path to the nanobind CMake module directory."
return os.path.join(os.path.abspath(os.path.dirname(__file__)), "cmake")

__version__ = "1.6.0"
__version__ = "1.6.1"

__all__ = (
"__version__",
8 changes: 4 additions & 4 deletions tests/test_intrusive.cpp
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ class Test : public nb::intrusive_base {
virtual int value(int i) const { return 123 + i; }

static Test *create_raw() { return new Test(); }
static ref<Test> create_ref() { return new Test(); }
static nb::ref<Test> create_ref() { return new Test(); }
};

class PyTest : Test {
@@ -60,7 +60,7 @@ NB_MODULE(test_intrusive_ext, m) {
return { test_constructed, test_destructed };
});

m.def("get_value_1", [](Test *o) { ref<Test> x(o); return x->value(1); });
m.def("get_value_2", [](ref<Test> x) { return x->value(2); });
m.def("get_value_3", [](const ref<Test> &x) { return x->value(3); });
m.def("get_value_1", [](Test *o) { nb::ref<Test> x(o); return x->value(1); });
m.def("get_value_2", [](nb::ref<Test> x) { return x->value(2); });
m.def("get_value_3", [](const nb::ref<Test> &x) { return x->value(3); });
}

0 comments on commit 3ba3522

Please sign in to comment.