mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-07 17:32:00 +00:00
Move classh
into pybind11/pybind11.h and update test_classh_mock.cpp accordingly.
This commit is contained in:
parent
9f9a698ee9
commit
d0003f5660
@ -2308,6 +2308,18 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT
|
||||||
|
|
||||||
|
// Supports easier switching between py::class_<T> and py::class_<T, py::smart_holder>:
|
||||||
|
// users can simply replace the `_` in `class_` with `h` or vice versa.
|
||||||
|
template <typename type_, typename... options>
|
||||||
|
class classh : public class_<type_, smart_holder, options...> {
|
||||||
|
public:
|
||||||
|
using class_<type_, smart_holder, options...>::class_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Binds an existing constructor taking arguments Args...
|
/// Binds an existing constructor taking arguments Args...
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
detail::initimpl::constructor<Args...> init() {
|
detail::initimpl::constructor<Args...> init() {
|
||||||
|
@ -6,23 +6,9 @@
|
|||||||
|
|
||||||
#include "pybind11.h"
|
#include "pybind11.h"
|
||||||
|
|
||||||
|
// Legacy macros introduced with smart_holder_type_casters implementation in 2021.
|
||||||
|
// Deprecated.
|
||||||
#define PYBIND11_TYPE_CASTER_BASE_HOLDER(...)
|
#define PYBIND11_TYPE_CASTER_BASE_HOLDER(...)
|
||||||
#define PYBIND11_SMART_HOLDER_TYPE_CASTERS(...)
|
#define PYBIND11_SMART_HOLDER_TYPE_CASTERS(...)
|
||||||
#define PYBIND11_SH_AVL(...) // "Smart_Holder if AVaiLable"
|
#define PYBIND11_SH_AVL(...) // "Smart_Holder if AVaiLable"
|
||||||
#define PYBIND11_SH_DEF(...) // "Smart_Holder if DEFault"
|
#define PYBIND11_SH_DEF(...) // "Smart_Holder if DEFault"
|
||||||
|
|
||||||
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
|
||||||
|
|
||||||
#ifdef PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT
|
|
||||||
|
|
||||||
// Supports easier switching between py::class_<T> and py::class_<T, py::smart_holder>:
|
|
||||||
// users can simply replace the `_` in `class_` with `h` or vice versa.
|
|
||||||
template <typename type_, typename... options>
|
|
||||||
class classh : public class_<type_, smart_holder, options...> {
|
|
||||||
public:
|
|
||||||
using class_<type_, smart_holder, options...>::class_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
|
||||||
|
@ -1,18 +1,20 @@
|
|||||||
#include "pybind11_tests.h"
|
#include "pybind11_tests.h"
|
||||||
|
|
||||||
// The main purpose of this test is to ensure the suggested BOILERPLATE code block below is
|
// The main purpose of this test was to ensure that the suggested
|
||||||
// correct.
|
// BOILERPLATE code block (NOW DEPRECATED!) block below is correct.
|
||||||
|
|
||||||
// Copy this block of code into your project.
|
// Copy this block of code into your project.
|
||||||
// Replace FOOEXT with the name of your project.
|
// Replace FOOEXT with the name of your project.
|
||||||
// BOILERPLATE BEGIN
|
// BOILERPLATE BEGIN DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED
|
||||||
#ifdef FOOEXT_USING_PYBIND11_SMART_HOLDER
|
#ifdef FOOEXT_USING_PYBIND11_SMART_HOLDER
|
||||||
# include <pybind11/smart_holder.h>
|
# include <pybind11/smart_holder.h>
|
||||||
#else
|
#else
|
||||||
# include <pybind11/pybind11.h>
|
# include <pybind11/pybind11.h>
|
||||||
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
||||||
|
# ifndef PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT
|
||||||
template <typename type_, typename... options>
|
template <typename type_, typename... options>
|
||||||
using classh = class_<type_, options...>;
|
using classh = class_<type_, options...>;
|
||||||
|
# endif
|
||||||
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
||||||
# ifndef PYBIND11_SH_AVL
|
# ifndef PYBIND11_SH_AVL
|
||||||
# define PYBIND11_SH_AVL(...) std::shared_ptr<__VA_ARGS__> // "Smart_Holder if AVaiLable"
|
# define PYBIND11_SH_AVL(...) std::shared_ptr<__VA_ARGS__> // "Smart_Holder if AVaiLable"
|
||||||
@ -27,7 +29,7 @@ PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
|||||||
# define PYBIND11_TYPE_CASTER_BASE_HOLDER(...)
|
# define PYBIND11_TYPE_CASTER_BASE_HOLDER(...)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
// BOILERPLATE END
|
// BOILERPLATE END DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct FooUc {};
|
struct FooUc {};
|
||||||
@ -37,8 +39,8 @@ struct FooSc {};
|
|||||||
struct FooSp {};
|
struct FooSp {};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(FooUp)
|
PYBIND11_SMART_HOLDER_TYPE_CASTERS(FooUp) // DEPRECATED
|
||||||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(FooSp)
|
PYBIND11_SMART_HOLDER_TYPE_CASTERS(FooSp) // DEPRECATED
|
||||||
|
|
||||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(FooSa, std::shared_ptr<FooSa>)
|
PYBIND11_TYPE_CASTER_BASE_HOLDER(FooSa, std::shared_ptr<FooSa>)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user