mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-20 07:30:40 +00:00
ifdef out classh if PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT is not defined.
This commit is contained in:
parent
e4456197c4
commit
41433f632a
@ -4,11 +4,17 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.h"
|
#include "internals.h"
|
||||||
#include "smart_holder_poc.h"
|
|
||||||
|
#ifdef PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT
|
||||||
|
|
||||||
|
# include "common.h"
|
||||||
|
# include "smart_holder_poc.h"
|
||||||
|
|
||||||
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
||||||
|
|
||||||
using pybindit::memory::smart_holder;
|
using pybindit::memory::smart_holder;
|
||||||
|
|
||||||
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2024 The Pybind Development Team.
|
// Copyright (c) 2021-2024 The Pybind Development Team.
|
||||||
// All rights reserved. Use of this source code is governed by a
|
// All rights reserved. Use of this source code is governed by a
|
||||||
// BSD-style license that can be found in the LICENSE file.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
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>:
|
// 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.
|
// users can simply replace the `_` in `class_` with `h` or vice versa.
|
||||||
template <typename type_, typename... options>
|
template <typename type_, typename... options>
|
||||||
@ -21,4 +23,6 @@ public:
|
|||||||
using class_<type_, smart_holder, options...>::class_;
|
using class_<type_, smart_holder, options...>::class_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
||||||
|
@ -63,6 +63,7 @@ int AddInCppUniquePtr(std::unique_ptr<Abase<SerNo>> obj, int other_val) {
|
|||||||
|
|
||||||
template <int SerNo>
|
template <int SerNo>
|
||||||
void wrap(py::module_ m, const char *py_class_name) {
|
void wrap(py::module_ m, const char *py_class_name) {
|
||||||
|
#ifdef PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT
|
||||||
py::classh<Abase<SerNo>, AbaseAlias<SerNo>>(m, py_class_name)
|
py::classh<Abase<SerNo>, AbaseAlias<SerNo>>(m, py_class_name)
|
||||||
.def(py::init<int>(), py::arg("val"))
|
.def(py::init<int>(), py::arg("val"))
|
||||||
.def("Get", &Abase<SerNo>::Get)
|
.def("Get", &Abase<SerNo>::Get)
|
||||||
@ -71,6 +72,7 @@ void wrap(py::module_ m, const char *py_class_name) {
|
|||||||
m.def("AddInCppRawPtr", AddInCppRawPtr<SerNo>, py::arg("obj"), py::arg("other_val"));
|
m.def("AddInCppRawPtr", AddInCppRawPtr<SerNo>, py::arg("obj"), py::arg("other_val"));
|
||||||
m.def("AddInCppSharedPtr", AddInCppSharedPtr<SerNo>, py::arg("obj"), py::arg("other_val"));
|
m.def("AddInCppSharedPtr", AddInCppSharedPtr<SerNo>, py::arg("obj"), py::arg("other_val"));
|
||||||
m.def("AddInCppUniquePtr", AddInCppUniquePtr<SerNo>, py::arg("obj"), py::arg("other_val"));
|
m.def("AddInCppUniquePtr", AddInCppUniquePtr<SerNo>, py::arg("obj"), py::arg("other_val"));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace class_sh_trampoline_basic
|
} // namespace class_sh_trampoline_basic
|
||||||
|
Loading…
Reference in New Issue
Block a user