Skip to content

Commit

Permalink
Merge pull request #471 from ManifoldFR/topic/fix-register-symbolic-link
Browse files Browse the repository at this point in the history
Add unit test multiple_registration, fix register_symbolic_link_to_registered_type() for multiple successive registrations
  • Loading branch information
ManifoldFR committed May 22, 2024
2 parents 3b7cdb7 + 7b27e7a commit 3ab149b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added
- Added a deprecation call policy shortcut ([#466](https://github.com/stack-of-tasks/eigenpy/pull/466))

### Fixed
- Fix register_symbolic_link_to_registered_type() for multiple successive registrations ([#471](https://github.com/stack-of-tasks/eigenpy/pull/471))

## [3.5.1] - 2024-04-25

### Fixed
Expand Down
2 changes: 2 additions & 0 deletions include/eigenpy/registration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ inline bool register_symbolic_link_to_registered_type() {
const bp::converter::registration* reg =
bp::converter::registry::query(info);
bp::handle<> class_obj(reg->get_class_object());
bp::incref(class_obj.get());
bp::scope().attr(reg->get_class_object()->tp_name) = bp::object(class_obj);
return true;
}
Expand All @@ -61,6 +62,7 @@ inline bool register_symbolic_link_to_registered_type(const Visitor& visitor) {
const bp::converter::registration* reg =
bp::converter::registry::query(info);
bp::handle<> class_obj(reg->get_class_object());
bp::incref(class_obj.get());
bp::object object(class_obj);
bp::scope().attr(reg->get_class_object()->tp_name) = object;
registration_class<T> cl(object);
Expand Down
3 changes: 3 additions & 0 deletions unittest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ endmacro(ADD_LIB_UNIT_TEST)

add_dependencies(build_tests ${PYWRAP})
add_lib_unit_test(matrix)
add_lib_unit_test(multiple_registration)
if(BUILD_TESTING_SCIPY)
find_scipy()
add_lib_unit_test(sparse_matrix)
Expand Down Expand Up @@ -101,6 +102,8 @@ endif()
add_lib_unit_test(bind_virtual_factory)

add_python_lib_unit_test("py-matrix" "unittest/python/test_matrix.py")
add_python_lib_unit_test("py-multiple-registration"
"unittest/python/test_multiple_registration.py")

add_python_lib_unit_test("py-tensor" "unittest/python/test_tensor.py")
add_python_lib_unit_test("py-geometry" "unittest/python/test_geometry.py")
Expand Down
28 changes: 28 additions & 0 deletions unittest/multiple_registration.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "eigenpy/registration.hpp"
#include <cstdio>

namespace bp = boost::python;

class X {
public:
X() {}
void operator()() { printf("DOOT\n"); }
};

class X_wrapper : public X, bp::wrapper<X> {
public:
static void expose() {
if (!eigenpy::register_symbolic_link_to_registered_type<X>()) {
bp::class_<X>("X", bp::init<>()).def("__call__", &X::operator());
}
}
};

BOOST_PYTHON_MODULE(multiple_registration) {
X_wrapper::expose();
X_wrapper::expose();
X_wrapper::expose();
X_wrapper::expose();
X_wrapper::expose();
X_wrapper::expose();
}
1 change: 1 addition & 0 deletions unittest/python/test_multiple_registration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import multiple_registration # noqa

0 comments on commit 3ab149b

Please sign in to comment.