| Directory: | ./ |
|---|---|
| File: | include/pinocchio/bindings/python/utils/address.hpp |
| Date: | 2025-02-12 21:03:38 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 4 | 6 | 66.7% |
| Branches: | 1 | 2 | 50.0% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2022 INRIA | ||
| 3 | // | ||
| 4 | |||
| 5 | #ifndef __pinocchio_python_utils_address_hpp__ | ||
| 6 | #define __pinocchio_python_utils_address_hpp__ | ||
| 7 | |||
| 8 | #include <eigenpy/eigenpy.hpp> | ||
| 9 | |||
| 10 | namespace pinocchio | ||
| 11 | { | ||
| 12 | namespace python | ||
| 13 | { | ||
| 14 | |||
| 15 | namespace bp = boost::python; | ||
| 16 | |||
| 17 | /// | ||
| 18 | /// \brief Add the Python method to extract the address of the underlying C++ object. | ||
| 19 | /// | ||
| 20 | template<class C> | ||
| 21 | struct AddressVisitor : public bp::def_visitor<AddressVisitor<C>> | ||
| 22 | { | ||
| 23 | |||
| 24 | template<class PyClass> | ||
| 25 | 390 | void visit(PyClass & cl) const | |
| 26 | { | ||
| 27 |
1/2✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
|
390 | cl.def( |
| 28 | "__address__", | ||
| 29 | ✗ | +[](const C & self) -> size_t { | |
| 30 | ✗ | return reinterpret_cast<size_t>(static_cast<const void *>(&self)); | |
| 31 | }, | ||
| 32 | 780 | bp::arg("self"), "Returns the address of the underlying C++ object."); | |
| 33 | 390 | } | |
| 34 | }; | ||
| 35 | |||
| 36 | } // namespace python | ||
| 37 | } // namespace pinocchio | ||
| 38 | |||
| 39 | #endif // ifndef __pinocchio_python_utils_address_hpp__ | ||
| 40 |