summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2017-01-03 10:38:32 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2017-02-12 17:01:37 +0200
commite96a0e9b7aecc5c3b3cc3fbf705a0942bf105c9e (patch)
tree3ed3ed667a53df405e41c15d517b98946166b603
parentf7198ea11d043768c27b9b0376c8810365aabe10 (diff)
Update pybind11 to v2.0
m---------ext/pybind110
-rw-r--r--py/pykms/pykms.cpp3
-rw-r--r--py/pykms/pykmsbase.cpp34
-rw-r--r--py/pykms/pykmsomap.cpp4
-rw-r--r--py/pykms/pyvid.cpp10
5 files changed, 33 insertions, 18 deletions
diff --git a/ext/pybind11 b/ext/pybind11
-Subproject e70b2abb6dee27a2889b01f245a2a28e6fcd4b0
+Subproject e33ef9c20d36fe760792c61ccc95ecf1b42cf81
diff --git a/py/pykms/pykms.cpp b/py/pykms/pykms.cpp
index 2199039..c30db1e 100644
--- a/py/pykms/pykms.cpp
+++ b/py/pykms/pykms.cpp
@@ -36,8 +36,7 @@ PYBIND11_PLUGIN(pykms) {
init_pykmsbase(m);
- py::class_<PyPageFlipHandlerBase>(m, "PageFlipHandlerBase")
- .alias<PageFlipHandlerBase>()
+ py::class_<PageFlipHandlerBase, PyPageFlipHandlerBase>(m, "PageFlipHandlerBase")
.def(py::init<>())
.def("handle_page_flip", &PageFlipHandlerBase::handle_page_flip)
;
diff --git a/py/pykms/pykmsbase.cpp b/py/pykms/pykmsbase.cpp
index 0d5bb86..090c212 100644
--- a/py/pykms/pykmsbase.cpp
+++ b/py/pykms/pykmsbase.cpp
@@ -7,6 +7,16 @@ namespace py = pybind11;
using namespace kms;
using namespace std;
+PYBIND11_DECLARE_HOLDER_TYPE(T, T*, true);
+
+typedef DrmObject* DrmObjectHolder;
+typedef DrmPropObject* DrmPropObjectHolder;
+typedef Connector* ConnectorHolder;
+typedef Crtc* CrtcHolder;
+typedef Encoder* EncoderHolder;
+typedef Plane* PlaneHolder;
+typedef Property* PropertyHolder;
+
void init_pykmsbase(py::module &m)
{
py::class_<Card>(m, "Card")
@@ -22,12 +32,12 @@ void init_pykmsbase(py::module &m)
.def("get_prop", (Property* (Card::*)(uint32_t) const)&Card::get_prop)
;
- py::class_<DrmObject, DrmObject*>(m, "DrmObject")
+ py::class_<DrmObject, DrmObjectHolder>(m, "DrmObject")
.def_property_readonly("id", &DrmObject::id)
.def_property_readonly("card", &DrmObject::card)
;
- py::class_<DrmPropObject, DrmPropObject*>(m, "DrmPropObject", py::base<DrmObject>())
+ py::class_<DrmPropObject, DrmObject, DrmPropObjectHolder>(m, "DrmPropObject")
.def("refresh_props", &DrmPropObject::refresh_props)
.def_property_readonly("prop_map", &DrmPropObject::get_prop_map)
.def("get_prop_value", (uint64_t (DrmPropObject::*)(const string&) const)&DrmPropObject::get_prop_value)
@@ -35,7 +45,7 @@ void init_pykmsbase(py::module &m)
.def("get_prop_value_as_blob", &DrmPropObject::get_prop_value_as_blob)
;
- py::class_<Connector, Connector*>(m, "Connector", py::base<DrmPropObject>())
+ py::class_<Connector, DrmPropObject, ConnectorHolder>(m, "Connector")
.def_property_readonly("fullname", &Connector::fullname)
.def("get_default_mode", &Connector::get_default_mode)
.def("get_current_crtc", &Connector::get_current_crtc)
@@ -47,7 +57,7 @@ void init_pykmsbase(py::module &m)
.def("refresh", &Connector::refresh)
;
- py::class_<Crtc, Crtc*>(m, "Crtc", py::base<DrmPropObject>())
+ py::class_<Crtc, DrmPropObject, CrtcHolder>(m, "Crtc")
.def("set_mode", &Crtc::set_mode)
.def("page_flip", &Crtc::page_flip)
.def("set_plane", &Crtc::set_plane)
@@ -59,11 +69,11 @@ void init_pykmsbase(py::module &m)
.def("refresh", &Crtc::refresh)
;
- py::class_<Encoder, Encoder*>(m, "Encoder", py::base<DrmPropObject>())
+ py::class_<Encoder, DrmPropObject, EncoderHolder>(m, "Encoder")
.def("refresh", &Encoder::refresh)
;
- py::class_<Plane, Plane*>(m, "Plane", py::base<DrmPropObject>())
+ py::class_<Plane, DrmPropObject, PlaneHolder>(m, "Plane")
.def("supports_crtc", &Plane::supports_crtc)
.def_property_readonly("plane_type", &Plane::plane_type)
.def("__repr__", [](const Plane& o) { return "<pykms.Plane " + to_string(o.id()) + ">"; })
@@ -75,11 +85,11 @@ void init_pykmsbase(py::module &m)
.value("Cursor", PlaneType::Cursor)
;
- py::class_<Property, Property*>(m, "Property", py::base<DrmObject>())
+ py::class_<Property, DrmObject, PropertyHolder>(m, "Property")
.def_property_readonly("name", &Property::name)
;
- py::class_<Blob>(m, "Blob", py::base<DrmObject>())
+ py::class_<Blob, DrmObject>(m, "Blob")
.def("__init__", [](Blob& instance, Card& card, py::buffer buf) {
py::buffer_info info = buf.request();
if (info.ndim != 1)
@@ -90,15 +100,15 @@ void init_pykmsbase(py::module &m)
.def_property_readonly("data", &Blob::data)
;
- py::class_<Framebuffer>(m, "Framebuffer", py::base<DrmObject>())
+ py::class_<Framebuffer, DrmObject>(m, "Framebuffer")
;
- py::class_<MappedFramebuffer>(m, "MappedFramebuffer", py::base<Framebuffer>())
+ py::class_<MappedFramebuffer, Framebuffer>(m, "MappedFramebuffer")
.def_property_readonly("width", &MappedFramebuffer::width)
.def_property_readonly("height", &MappedFramebuffer::height)
;
- py::class_<DumbFramebuffer>(m, "DumbFramebuffer", py::base<MappedFramebuffer>())
+ py::class_<DumbFramebuffer, MappedFramebuffer>(m, "DumbFramebuffer")
.def(py::init<Card&, uint32_t, uint32_t, const string&>(),
py::keep_alive<1, 2>()) // Keep Card alive until this is destructed
.def(py::init<Card&, uint32_t, uint32_t, PixelFormat>(),
@@ -110,7 +120,7 @@ void init_pykmsbase(py::module &m)
.def("offset", &DumbFramebuffer::offset)
;
- py::class_<ExtFramebuffer>(m, "ExtFramebuffer", py::base<MappedFramebuffer>())
+ py::class_<ExtFramebuffer, MappedFramebuffer>(m, "ExtFramebuffer")
.def(py::init<Card&, uint32_t, uint32_t, PixelFormat, vector<int>, vector<uint32_t>, vector<uint32_t>>(),
py::keep_alive<1, 2>()) // Keep Card alive until this is destructed
;
diff --git a/py/pykms/pykmsomap.cpp b/py/pykms/pykmsomap.cpp
index a749f76..0cdbbc2 100644
--- a/py/pykms/pykmsomap.cpp
+++ b/py/pykms/pykmsomap.cpp
@@ -10,11 +10,11 @@ using namespace std;
void init_pykmsomap(py::module &m)
{
- py::class_<OmapCard>(m, "OmapCard", py::base<Card>())
+ py::class_<OmapCard, Card>(m, "OmapCard")
.def(py::init<>())
;
- py::class_<OmapFramebuffer>(m, "OmapFramebuffer", py::base<MappedFramebuffer>())
+ py::class_<OmapFramebuffer, MappedFramebuffer>(m, "OmapFramebuffer")
.def(py::init<OmapCard&, uint32_t, uint32_t, const string&>(),
py::keep_alive<1, 2>()) // Keep Card alive until this is destructed
.def(py::init<OmapCard&, uint32_t, uint32_t, PixelFormat>(),
diff --git a/py/pykms/pyvid.cpp b/py/pykms/pyvid.cpp
index 01177d5..c441562 100644
--- a/py/pykms/pyvid.cpp
+++ b/py/pykms/pyvid.cpp
@@ -9,9 +9,15 @@ namespace py = pybind11;
using namespace kms;
using namespace std;
+PYBIND11_DECLARE_HOLDER_TYPE(T, T*, true);
+
+// XXX I don't think these are really needed. Use return value parameters.
+typedef VideoDevice* VideoDeviceHolder;
+typedef VideoStreamer* VideoStreamerHolder;
+
void init_pyvid(py::module &m)
{
- py::class_<VideoDevice, VideoDevice*>(m, "VideoDevice")
+ py::class_<VideoDevice, VideoDeviceHolder>(m, "VideoDevice")
.def(py::init<const string&>())
.def_property_readonly("fd", &VideoDevice::fd)
.def_property_readonly("has_capture", &VideoDevice::has_capture)
@@ -24,7 +30,7 @@ void init_pyvid(py::module &m)
.def("get_capture_devices", &VideoDevice::get_capture_devices)
;
- py::class_<VideoStreamer, VideoStreamer*>(m, "VideoStreamer")
+ py::class_<VideoStreamer, VideoStreamerHolder>(m, "VideoStreamer")
.def_property_readonly("fd", &VideoStreamer::fd)
.def_property_readonly("ports", &VideoStreamer::get_ports)
.def("set_port", &VideoStreamer::set_port)