mirror of
https://github.com/pybind/pybind11.git
synced 2026-06-30 03:17:02 +00:00
Revert "Redesigned virtual call mechanism and user-facing syntax (breaking change!)"
This reverts commit 86d825f330.
This commit is contained in:
@@ -82,11 +82,15 @@ void runExample12Virtual(Example12 *ex) {
|
||||
}
|
||||
|
||||
void init_ex12(py::module &m) {
|
||||
/* Important: indicate the trampoline class PyExample12 using the third
|
||||
argument to py::class_. The second argument with the unique pointer
|
||||
is simply the default holder type used by pybind11. */
|
||||
py::class_<Example12, std::unique_ptr<Example12>, PyExample12>(m, "Example12")
|
||||
/* Important: use the wrapper type as a template
|
||||
argument to class_<>, but use the original name
|
||||
to denote the type */
|
||||
py::class_<PyExample12>(m, "Example12")
|
||||
/* Declare that 'PyExample12' is really an alias for the original type 'Example12' */
|
||||
.alias<Example12>()
|
||||
.def(py::init<int>())
|
||||
/* Copy constructor (not needed in this case, but should generally be declared in this way) */
|
||||
.def(py::init<const PyExample12 &>())
|
||||
/* Reference original class in function definitions */
|
||||
.def("run", &Example12::run)
|
||||
.def("run_bool", &Example12::run_bool)
|
||||
|
||||
Reference in New Issue
Block a user