mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 05:05:11 +00:00
ae951ca085
* Fix warning that not including a cmake source or build dir will be a fatal error (it is now on newest CMakes) * Fixes appveyor * Travis uses CMake 3.9 for more than a year now * Travis dropped sudo: false in December * Dropping Sphinx 2 - clang7: Suppress self-assign warnings; fix missing virtual dtors - pypy: - Keep old version (newer stuff breaks) - Pin packages to extra index for speed - travis: - Make docker explicit; remove docker if not needed - Make commands more verbose (for debugging / repro) - Make Ubuntu dist explicit per job - Fix Windows - Add names to travis
45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
/*
|
|
tests/test_gil_scoped.cpp -- acquire and release gil
|
|
|
|
Copyright (c) 2017 Borja Zarco (Google LLC) <bzarco@google.com>
|
|
|
|
All rights reserved. Use of this source code is governed by a
|
|
BSD-style license that can be found in the LICENSE file.
|
|
*/
|
|
|
|
#include "pybind11_tests.h"
|
|
#include <pybind11/functional.h>
|
|
|
|
|
|
class VirtClass {
|
|
public:
|
|
virtual ~VirtClass() {}
|
|
virtual void virtual_func() {}
|
|
virtual void pure_virtual_func() = 0;
|
|
};
|
|
|
|
class PyVirtClass : public VirtClass {
|
|
void virtual_func() override {
|
|
PYBIND11_OVERLOAD(void, VirtClass, virtual_func,);
|
|
}
|
|
void pure_virtual_func() override {
|
|
PYBIND11_OVERLOAD_PURE(void, VirtClass, pure_virtual_func,);
|
|
}
|
|
};
|
|
|
|
TEST_SUBMODULE(gil_scoped, m) {
|
|
py::class_<VirtClass, PyVirtClass>(m, "VirtClass")
|
|
.def(py::init<>())
|
|
.def("virtual_func", &VirtClass::virtual_func)
|
|
.def("pure_virtual_func", &VirtClass::pure_virtual_func);
|
|
|
|
m.def("test_callback_py_obj",
|
|
[](py::object func) { func(); });
|
|
m.def("test_callback_std_func",
|
|
[](const std::function<void()> &func) { func(); });
|
|
m.def("test_callback_virtual_func",
|
|
[](VirtClass &virt) { virt.virtual_func(); });
|
|
m.def("test_callback_pure_virtual_func",
|
|
[](VirtClass &virt) { virt.pure_virtual_func(); });
|
|
}
|