From d328d314b6d763ce582b2397bc4142dd747b0b2a Mon Sep 17 00:00:00 2001 From: Thomas Stoddard Date: Mon, 24 Nov 2025 16:56:09 +0000 Subject: [PATCH] Bindings: Python: Update pybind11 Updates to 3.0.1 and switches to smart_holder & native_enum. --- bindings/python/CMakeLists.txt | 2 +- bindings/python/icsneopy/api/event.cpp | 15 +++++++++------ .../message/callback/messagecallback.cpp | 2 +- .../communication/message/canerrormessage.cpp | 8 +++++--- .../communication/message/canmessage.cpp | 2 +- .../communication/message/ethernetmessage.cpp | 2 +- .../message/ethernetstatusmessage.cpp | 2 +- .../communication/message/ethphymessage.cpp | 4 ++-- .../message/filter/messagefilter.cpp | 2 +- .../message/gptpstatusmessage.cpp | 2 +- .../communication/message/linmessage.cpp | 2 +- .../communication/message/mdiomessage.cpp | 2 +- .../icsneopy/communication/message/message.cpp | 13 ++++++++----- .../message/scriptstatusmessage.cpp | 2 +- .../communication/message/spimessage.cpp | 2 +- .../message/tc10statusmessage.cpp | 2 +- .../python/icsneopy/communication/network.cpp | 11 +++++++---- bindings/python/icsneopy/core/macseccfg.cpp | 18 +++++++++--------- bindings/python/icsneopy/device/chipid.cpp | 6 ++++-- bindings/python/icsneopy/device/device.cpp | 2 +- bindings/python/icsneopy/device/devicetype.cpp | 6 ++++-- .../device/extensions/deviceextension.cpp | 2 +- .../python/icsneopy/device/idevicesettings.cpp | 2 +- bindings/python/icsneopy/flexray/flexray.cpp | 6 +++--- 24 files changed, 66 insertions(+), 51 deletions(-) diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index 1bbdee3..93c93a9 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -9,7 +9,7 @@ else() FetchContent_Declare( pybind11 GIT_REPOSITORY https://github.com/pybind/pybind11.git - GIT_TAG v2.13.6 + GIT_TAG v3.0.1 ) FetchContent_MakeAvailable(pybind11) endif() diff --git a/bindings/python/icsneopy/api/event.cpp b/bindings/python/icsneopy/api/event.cpp index 8bc18d9..f27b451 100644 --- a/bindings/python/icsneopy/api/event.cpp +++ b/bindings/python/icsneopy/api/event.cpp @@ -1,14 +1,15 @@ #include #include #include +#include #include "icsneo/api/event.h" namespace icsneo { void init_event(pybind11::module_& m) { - pybind11::class_> apiEvent(m, "APIEvent"); - pybind11::enum_(apiEvent, "Type") + pybind11::classh apiEvent(m, "APIEvent"); + pybind11::native_enum(apiEvent, "Type", "enum.IntEnum") .value("Any", APIEvent::Type::Any) .value("InvalidNeoDevice", APIEvent::Type::InvalidNeoDevice) .value("RequiredParameterNull", APIEvent::Type::RequiredParameterNull) @@ -132,13 +133,15 @@ void init_event(pybind11::module_& m) { .value("DXXErrorArg", APIEvent::Type::DXXErrorArg) .value("NoErrorFound", APIEvent::Type::NoErrorFound) .value("TooManyEvents", APIEvent::Type::TooManyEvents) - .value("Unknown", APIEvent::Type::Unknown); + .value("Unknown", APIEvent::Type::Unknown) + .finalize(); - pybind11::enum_(apiEvent, "Severity") + pybind11::native_enum(apiEvent, "Severity", "enum.IntEnum") .value("Any", APIEvent::Severity::Any) .value("EventInfo", APIEvent::Severity::EventInfo) .value("EventWarning", APIEvent::Severity::EventWarning) - .value("Error", APIEvent::Severity::Error); + .value("Error", APIEvent::Severity::Error) + .finalize(); apiEvent .def("get_type", &APIEvent::getType) @@ -147,7 +150,7 @@ void init_event(pybind11::module_& m) { .def("describe", &APIEvent::describe) .def("__repr__", &APIEvent::describe); - pybind11::class_>(m, "EventFilter") + pybind11::classh(m, "EventFilter") .def(pybind11::init()) .def(pybind11::init()) .def(pybind11::init()) diff --git a/bindings/python/icsneopy/communication/message/callback/messagecallback.cpp b/bindings/python/icsneopy/communication/message/callback/messagecallback.cpp index 656dc39..58fd9d0 100644 --- a/bindings/python/icsneopy/communication/message/callback/messagecallback.cpp +++ b/bindings/python/icsneopy/communication/message/callback/messagecallback.cpp @@ -7,7 +7,7 @@ namespace icsneo { void init_messagecallback(pybind11::module_& m) { - pybind11::class_>(m, "MessageCallback") + pybind11::classh(m, "MessageCallback") .def(pybind11::init>()); } diff --git a/bindings/python/icsneopy/communication/message/canerrormessage.cpp b/bindings/python/icsneopy/communication/message/canerrormessage.cpp index 329da23..2b3c143 100644 --- a/bindings/python/icsneopy/communication/message/canerrormessage.cpp +++ b/bindings/python/icsneopy/communication/message/canerrormessage.cpp @@ -1,13 +1,14 @@ #include #include #include +#include #include "icsneo/communication/message/canerrormessage.h" namespace icsneo { void init_errorcodes(pybind11::module_& m) { - pybind11::enum_(m, "CANErrorCode") + pybind11::native_enum(m, "CANErrorCode", "enum.IntEnum") .value("NoError", CANErrorCode::NoError) .value("StuffError", CANErrorCode::StuffError) .value("FormError", CANErrorCode::FormError) @@ -15,12 +16,13 @@ void init_errorcodes(pybind11::module_& m) { .value("Bit1Error", CANErrorCode::Bit1Error) .value("Bit0Error", CANErrorCode::Bit0Error) .value("CRCError", CANErrorCode::CRCError) - .value("NoChange", CANErrorCode::NoChange); + .value("NoChange", CANErrorCode::NoChange) + .finalize(); } void init_canerrormessage(pybind11::module_& m) { init_errorcodes(m); - pybind11::class_, Message>(m, "CANErrorMessage") + pybind11::classh(m, "CANErrorMessage") .def_readonly("network", &CANErrorMessage::network) .def_readonly("transmitErrorCount", &CANErrorMessage::transmitErrorCount) .def_readonly("receiveErrorCount", &CANErrorMessage::receiveErrorCount) diff --git a/bindings/python/icsneopy/communication/message/canmessage.cpp b/bindings/python/icsneopy/communication/message/canmessage.cpp index 68d36ed..ece6608 100644 --- a/bindings/python/icsneopy/communication/message/canmessage.cpp +++ b/bindings/python/icsneopy/communication/message/canmessage.cpp @@ -7,7 +7,7 @@ namespace icsneo { void init_canmessage(pybind11::module_& m) { - pybind11::class_, Frame>(m, "CANMessage") + pybind11::classh(m, "CANMessage") .def(pybind11::init()) .def_readwrite("arbid", &CANMessage::arbid) .def_readwrite("dlcOnWire", &CANMessage::dlcOnWire) diff --git a/bindings/python/icsneopy/communication/message/ethernetmessage.cpp b/bindings/python/icsneopy/communication/message/ethernetmessage.cpp index 5904309..3392c8f 100644 --- a/bindings/python/icsneopy/communication/message/ethernetmessage.cpp +++ b/bindings/python/icsneopy/communication/message/ethernetmessage.cpp @@ -11,7 +11,7 @@ void init_ethernetmessage(pybind11::module_& m) { .def("to_string", &MACAddress::toString) .def("__repr__", &MACAddress::toString); - pybind11::class_, Frame>(m, "EthernetMessage") + pybind11::classh(m, "EthernetMessage") .def(pybind11::init()) .def_readwrite("preemptionEnabled", &EthernetMessage::preemptionEnabled) .def_readwrite("preemptionFlags", &EthernetMessage::preemptionFlags) diff --git a/bindings/python/icsneopy/communication/message/ethernetstatusmessage.cpp b/bindings/python/icsneopy/communication/message/ethernetstatusmessage.cpp index ee2ebca..e59a8e3 100644 --- a/bindings/python/icsneopy/communication/message/ethernetstatusmessage.cpp +++ b/bindings/python/icsneopy/communication/message/ethernetstatusmessage.cpp @@ -7,7 +7,7 @@ namespace icsneo { void init_ethernetstatusmessage(pybind11::module_& m) { - pybind11::class_, Message> ethernetStatusMessage(m, "EthernetStatusMessage"); + pybind11::classh ethernetStatusMessage(m, "EthernetStatusMessage"); pybind11::enum_(ethernetStatusMessage, "LinkSpeed") .value("LinkSpeedAuto", EthernetStatusMessage::LinkSpeed::LinkSpeedAuto) diff --git a/bindings/python/icsneopy/communication/message/ethphymessage.cpp b/bindings/python/icsneopy/communication/message/ethphymessage.cpp index 586504f..c1649d9 100644 --- a/bindings/python/icsneopy/communication/message/ethphymessage.cpp +++ b/bindings/python/icsneopy/communication/message/ethphymessage.cpp @@ -7,7 +7,7 @@ namespace icsneo { void init_ethphymessage(pybind11::module_& m) { - pybind11::class_>(m, "PhyMessage") + pybind11::classh(m, "PhyMessage") .def(pybind11::init()) .def_readwrite("Enabled", &PhyMessage::Enabled) .def_readwrite("WriteEnable", &PhyMessage::WriteEnable) @@ -28,7 +28,7 @@ void init_ethphymessage(pybind11::module_& m) { .def_readwrite("device", &Clause45Message::device) .def_readwrite("regAddr", &Clause45Message::regAddr) .def_readwrite("regVal", &Clause45Message::regVal); - pybind11::class_, Message>(m, "EthPhyMessage") + pybind11::classh(m, "EthPhyMessage") .def(pybind11::init()) .def_readwrite("messages", &EthPhyMessage::messages); } diff --git a/bindings/python/icsneopy/communication/message/filter/messagefilter.cpp b/bindings/python/icsneopy/communication/message/filter/messagefilter.cpp index 449fa0a..9f28810 100644 --- a/bindings/python/icsneopy/communication/message/filter/messagefilter.cpp +++ b/bindings/python/icsneopy/communication/message/filter/messagefilter.cpp @@ -7,7 +7,7 @@ namespace icsneo { void init_messagefilter(pybind11::module_& m) { - pybind11::class_>(m, "MessageFilter") + pybind11::classh(m, "MessageFilter") .def(pybind11::init()) .def(pybind11::init()) .def(pybind11::init()); diff --git a/bindings/python/icsneopy/communication/message/gptpstatusmessage.cpp b/bindings/python/icsneopy/communication/message/gptpstatusmessage.cpp index 27b2441..867d5f9 100644 --- a/bindings/python/icsneopy/communication/message/gptpstatusmessage.cpp +++ b/bindings/python/icsneopy/communication/message/gptpstatusmessage.cpp @@ -7,7 +7,7 @@ namespace icsneo { void init_gptpstatusmessage(pybind11::module_& m) { - pybind11::class_, Message> gptpStatus(m, "GPTPStatus"); + pybind11::classh gptpStatus(m, "GPTPStatus"); pybind11::class_(gptpStatus, "Timestamp") .def_readonly("seconds", &GPTPStatus::Timestamp::seconds) diff --git a/bindings/python/icsneopy/communication/message/linmessage.cpp b/bindings/python/icsneopy/communication/message/linmessage.cpp index cfee887..cff09e4 100644 --- a/bindings/python/icsneopy/communication/message/linmessage.cpp +++ b/bindings/python/icsneopy/communication/message/linmessage.cpp @@ -30,7 +30,7 @@ void init_linmessage(pybind11::module_& m) { .def_readwrite("BusRecovered", &LINStatusFlags::BusRecovered) .def_readwrite("BreakOnly", &LINStatusFlags::BreakOnly); - pybind11::class_, Frame> linMessage(m, "LINMessage"); + pybind11::classh linMessage(m, "LINMessage"); pybind11::enum_(linMessage, "Type") .value("NOT_SET", LINMessage::Type::NOT_SET) diff --git a/bindings/python/icsneopy/communication/message/mdiomessage.cpp b/bindings/python/icsneopy/communication/message/mdiomessage.cpp index 066ff5a..31f8056 100644 --- a/bindings/python/icsneopy/communication/message/mdiomessage.cpp +++ b/bindings/python/icsneopy/communication/message/mdiomessage.cpp @@ -7,7 +7,7 @@ namespace icsneo { void init_mdiomessage(pybind11::module_& m) { - pybind11::class_, Frame> mdioMessage(m, "MDIOMessage"); + pybind11::classh mdioMessage(m, "MDIOMessage"); pybind11::enum_(mdioMessage, "Clause") .value("Clause45", MDIOMessage::Clause::Clause45) .value("Clause22", MDIOMessage::Clause::Clause22); diff --git a/bindings/python/icsneopy/communication/message/message.cpp b/bindings/python/icsneopy/communication/message/message.cpp index 5fef94e..3be74d4 100644 --- a/bindings/python/icsneopy/communication/message/message.cpp +++ b/bindings/python/icsneopy/communication/message/message.cpp @@ -1,14 +1,16 @@ #include #include #include +#include #include "icsneo/communication/message/message.h" namespace icsneo { void init_message(pybind11::module_& m) { - pybind11::class_> message(m, "Message"); - pybind11::enum_(message, "Type") + // Using py::smart_holder for safer lifetime management + pybind11::classh message(m, "Message"); + pybind11::native_enum(message, "Type", "enum.IntEnum") .value("Frame", Message::Type::Frame) .value("CANErrorCount", Message::Type::CANErrorCount) .value("CANError", Message::Type::CANError) @@ -34,17 +36,18 @@ void init_message(pybind11::module_& m) { .value("TC10Status", Message::Type::TC10Status) .value("AppError", Message::Type::AppError) .value("GPTPStatus", Message::Type::GPTPStatus) - .value("EthernetStatus", Message::Type::EthernetStatus); + .value("EthernetStatus", Message::Type::EthernetStatus) + .finalize(); message.def(pybind11::init()); message.def_readonly("type", &Message::type); message.def_readwrite("timestamp", &Message::timestamp); - pybind11::class_, Message>(m, "RawMessage") + pybind11::classh(m, "RawMessage") .def_readwrite("network", &RawMessage::network) .def_readwrite("data", &RawMessage::data); - pybind11::class_, RawMessage>(m, "Frame") + pybind11::classh(m, "Frame") .def_readwrite("description", &Frame::description) .def_readwrite("transmitted", &Frame::transmitted) .def_readwrite("error", &Frame::error); diff --git a/bindings/python/icsneopy/communication/message/scriptstatusmessage.cpp b/bindings/python/icsneopy/communication/message/scriptstatusmessage.cpp index 358afb4..305e037 100644 --- a/bindings/python/icsneopy/communication/message/scriptstatusmessage.cpp +++ b/bindings/python/icsneopy/communication/message/scriptstatusmessage.cpp @@ -7,7 +7,7 @@ namespace icsneo { void init_scriptstatusmessage(pybind11::module_& m) { - pybind11::class_, Message>(m, "ScriptStatusMessage") + pybind11::classh(m, "ScriptStatusMessage") .def_readonly("isEncrypted", &ScriptStatusMessage::isEncrypted) .def_readonly("isCoreminiRunning", &ScriptStatusMessage::isCoreminiRunning) .def_readonly("sectorOverflows", &ScriptStatusMessage::sectorOverflows) diff --git a/bindings/python/icsneopy/communication/message/spimessage.cpp b/bindings/python/icsneopy/communication/message/spimessage.cpp index 3ff2564..a87eb16 100644 --- a/bindings/python/icsneopy/communication/message/spimessage.cpp +++ b/bindings/python/icsneopy/communication/message/spimessage.cpp @@ -7,7 +7,7 @@ namespace icsneo { void init_spimessage(pybind11::module_& m) { - pybind11::class_, Frame> spiMessage(m, "SPIMessage"); + pybind11::classh spiMessage(m, "SPIMessage"); pybind11::enum_(spiMessage, "Direction") .value("Write", SPIMessage::Direction::Write) .value("Read", SPIMessage::Direction::Read); diff --git a/bindings/python/icsneopy/communication/message/tc10statusmessage.cpp b/bindings/python/icsneopy/communication/message/tc10statusmessage.cpp index a3920b3..1796bf4 100644 --- a/bindings/python/icsneopy/communication/message/tc10statusmessage.cpp +++ b/bindings/python/icsneopy/communication/message/tc10statusmessage.cpp @@ -17,7 +17,7 @@ void init_tc10statusmessage(pybind11::module_& m) { .value("SleepFailed", TC10SleepStatus::SleepFailed) .value("SleepAborted", TC10SleepStatus::SleepAborted); - pybind11::class_, Message>(m, "TC10StatusMessage") + pybind11::classh(m, "TC10StatusMessage") .def_readonly("wakeStatus", &TC10StatusMessage::wakeStatus) .def_readonly("sleepStatus", &TC10StatusMessage::sleepStatus); } diff --git a/bindings/python/icsneopy/communication/network.cpp b/bindings/python/icsneopy/communication/network.cpp index fb2e737..7231fdf 100644 --- a/bindings/python/icsneopy/communication/network.cpp +++ b/bindings/python/icsneopy/communication/network.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "icsneo/communication/network.h" @@ -9,7 +10,7 @@ namespace icsneo { void init_network(pybind11::module_& m) { pybind11::class_ network(m, "Network"); - pybind11::enum_(network, "NetID") + pybind11::native_enum(network, "NetID", "enum.IntEnum") .value("Device", Network::NetID::Device) .value("DWCAN_01", Network::NetID::DWCAN_01) .value("DWCAN_08", Network::NetID::DWCAN_08) @@ -166,9 +167,10 @@ void init_network(pybind11::module_& m) { .value("LIN_15", Network::NetID::LIN_15) .value("LIN_16", Network::NetID::LIN_16) .value("Any", Network::NetID::Any) - .value("Invalid", Network::NetID::Invalid); + .value("Invalid", Network::NetID::Invalid) + .finalize(); - pybind11::enum_(network, "Type") + pybind11::native_enum(network, "Type", "enum.Enum") .value("Invalid", Network::Type::Invalid) .value("Internal", Network::Type::Internal) .value("CAN", Network::Type::CAN) @@ -185,7 +187,8 @@ void init_network(pybind11::module_& m) { .value("MDIO", Network::Type::MDIO) .value("AutomotiveEthernet", Network::Type::AutomotiveEthernet) .value("Any", Network::Type::Any) - .value("Other", Network::Type::Other); + .value("Other", Network::Type::Other) + .finalize(); network .def(pybind11::init()) diff --git a/bindings/python/icsneopy/core/macseccfg.cpp b/bindings/python/icsneopy/core/macseccfg.cpp index 1470d82..5fa32bc 100644 --- a/bindings/python/icsneopy/core/macseccfg.cpp +++ b/bindings/python/icsneopy/core/macseccfg.cpp @@ -35,17 +35,17 @@ void init_macsecconfig(pybind11::module_ & m) .value("GCM_AES_128_XPN", MACsecCipherSuite::GcmAes128Xpn) .value("GCM_AES_256_XPN", MACsecCipherSuite::GcmAes256Xpn); - pybind11::class_>(m, "MACsecVLANTag") + pybind11::classh(m, "MACsecVLANTag") .def(pybind11::init()) .def_readwrite("vid", &MACsecVLANTag::vid) .def_readwrite("pri_cfi", &MACsecVLANTag::priCfi); - pybind11::class_>(m, "MACsecMPLSOuter") + pybind11::classh(m, "MACsecMPLSOuter") .def(pybind11::init()) .def_readwrite("mpls_label", &MACsecMPLSOuter::mplsLabel) .def_readwrite("exp", &MACsecMPLSOuter::exp); - pybind11::class_>(m, "MACsecTci") + pybind11::classh(m, "MACsecTci") .def(pybind11::init()) .def_readwrite("es", &MACsecTci::es) .def_readwrite("sc", &MACsecTci::sc) @@ -53,7 +53,7 @@ void init_macsecconfig(pybind11::module_ & m) .def_readwrite("e", &MACsecTci::e) .def_readwrite("c", &MACsecTci::c); - pybind11::class_>(m, "MACsecRxRule") + pybind11::classh(m, "MACsecRxRule") .def(pybind11::init()) .def_readwrite("key_mac_da", &MACsecRxRule::keyMacDa) .def_readwrite("mask_mac_da", &MACsecRxRule::maskMacDa) @@ -85,7 +85,7 @@ void init_macsecconfig(pybind11::module_ & m) .def_readwrite("mask_express", &MACsecRxRule::maskExpress) .def_readwrite("is_mpls", &MACsecRxRule::isMpls); - pybind11::class_>(m, "MACsecTxSecY") + pybind11::classh(m, "MACsecTxSecY") .def(pybind11::init()) .def_readwrite("enable_control_port", &MACsecTxSecY::enableControlPort) .def_readwrite("cipher", &MACsecTxSecY::cipher) @@ -99,7 +99,7 @@ void init_macsecconfig(pybind11::module_ & m) .def_readwrite("auxiliary_policy", &MACsecTxSecY::auxiliaryPolicy) .def_readwrite("sci", &MACsecTxSecY::sci); - pybind11::class_>(m, "MACsecRxSecY") + pybind11::classh(m, "MACsecRxSecY") .def(pybind11::init()) .def_readwrite("enable_control_port", &MACsecRxSecY::enableControlPort) .def_readwrite("frame_validation", &MACsecRxSecY::frameValidation) @@ -112,7 +112,7 @@ void init_macsecconfig(pybind11::module_ & m) .def_readwrite("is_control_packet", &MACsecRxSecY::isControlPacket) .def_readwrite("sci", &MACsecRxSecY::sci); - pybind11::class_>(m, "MACsecTxSa") + pybind11::classh(m, "MACsecTxSa") .def(pybind11::init()) .def_readwrite("sak", &MACsecTxSa::sak) .def_readwrite("hash_key", &MACsecTxSa::hashKey) @@ -121,7 +121,7 @@ void init_macsecconfig(pybind11::module_ & m) .def_readwrite("next_pn", &MACsecTxSa::nextPn) .def_readwrite("an", &MACsecTxSa::an); - pybind11::class_>(m, "MACsecRxSa") + pybind11::classh(m, "MACsecRxSa") .def(pybind11::init()) .def_readwrite("sak", &MACsecRxSa::sak) .def_readwrite("hash_key", &MACsecRxSa::hashKey) @@ -129,7 +129,7 @@ void init_macsecconfig(pybind11::module_ & m) .def_readwrite("ssci", &MACsecRxSa::ssci) .def_readwrite("next_pn", &MACsecRxSa::nextPn); - pybind11::class_>(m, "MACsecConfig") + pybind11::classh(m, "MACsecConfig") .def(pybind11::init()) .def("add_rx_secy", &MACsecConfig::addRxSecY, pybind11::call_guard()) .def("add_tx_secY", &MACsecConfig::addTxSecY, pybind11::call_guard()) diff --git a/bindings/python/icsneopy/device/chipid.cpp b/bindings/python/icsneopy/device/chipid.cpp index 1c967aa..cee1db5 100644 --- a/bindings/python/icsneopy/device/chipid.cpp +++ b/bindings/python/icsneopy/device/chipid.cpp @@ -1,13 +1,14 @@ #include #include #include +#include #include "icsneo/device/chipid.h" namespace icsneo { void init_chipid(pybind11::module_& m) { - pybind11::enum_(m, "ChipID") + pybind11::native_enum(m, "ChipID", "enum.IntEnum") .value("neoVIFIRE_MCHIP", ChipID::neoVIFIRE_MCHIP) .value("neoVIFIRE_LCHIP", ChipID::neoVIFIRE_LCHIP) .value("neoVIFIRE_UCHIP", ChipID::neoVIFIRE_UCHIP) @@ -130,7 +131,8 @@ void init_chipid(pybind11::module_& m) { .value("Connect_LINUX", ChipID::Connect_LINUX) .value("RADGigastar2_ZYNQ", ChipID::RADGigastar2_ZYNQ) .value("RADGemini_MCHIP", ChipID::RADGemini_MCHIP) - .value("Invalid", ChipID::Invalid); + .value("Invalid", ChipID::Invalid) + .finalize(); } } // namespace icsneo diff --git a/bindings/python/icsneopy/device/device.cpp b/bindings/python/icsneopy/device/device.cpp index 7b7f803..472f3b4 100644 --- a/bindings/python/icsneopy/device/device.cpp +++ b/bindings/python/icsneopy/device/device.cpp @@ -11,7 +11,7 @@ namespace icsneo { void init_device(pybind11::module_& m) { - pybind11::class_>(m, "Device") + pybind11::classh(m, "Device") .def("__repr__", &Device::describe) .def("add_message_callback", &Device::addMessageCallback, pybind11::call_guard()) .def("clear_script", &Device::clearScript, pybind11::call_guard()) diff --git a/bindings/python/icsneopy/device/devicetype.cpp b/bindings/python/icsneopy/device/devicetype.cpp index f405605..f8890eb 100644 --- a/bindings/python/icsneopy/device/devicetype.cpp +++ b/bindings/python/icsneopy/device/devicetype.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "icsneo/device/devicetype.h" @@ -8,7 +9,7 @@ namespace icsneo { void init_devicetype(pybind11::module_& m) { pybind11::class_ deviceType(m, "DeviceType"); - pybind11::enum_(deviceType, "Enum") + pybind11::native_enum(deviceType, "Enum", "enum.IntEnum") .value("Unknown", DeviceType::Enum::Unknown) .value("BLUE", DeviceType::Enum::BLUE) .value("ECU_AVB", DeviceType::Enum::ECU_AVB) @@ -70,7 +71,8 @@ void init_devicetype(pybind11::module_& m) { .value("RADGalaxy", DeviceType::Enum::RADGalaxy) .value("RADStar2", DeviceType::Enum::RADStar2) .value("VividCAN", DeviceType::Enum::VividCAN) - .value("OBD2_SIM", DeviceType::Enum::OBD2_SIM); + .value("OBD2_SIM", DeviceType::Enum::OBD2_SIM) + .finalize(); deviceType.def(pybind11::init()); deviceType.def("get_device_type", &DeviceType::getDeviceType); deviceType.def("get_generic_product_name", &DeviceType::getGenericProductName); diff --git a/bindings/python/icsneopy/device/extensions/deviceextension.cpp b/bindings/python/icsneopy/device/extensions/deviceextension.cpp index 97c610a..6af08ad 100644 --- a/bindings/python/icsneopy/device/extensions/deviceextension.cpp +++ b/bindings/python/icsneopy/device/extensions/deviceextension.cpp @@ -7,7 +7,7 @@ namespace icsneo { void init_deviceextension(pybind11::module_& m) { - pybind11::class_>(m, "DeviceExtension") + pybind11::classh(m, "DeviceExtension") .def("get_name", &DeviceExtension::getName); } diff --git a/bindings/python/icsneopy/device/idevicesettings.cpp b/bindings/python/icsneopy/device/idevicesettings.cpp index ea4771e..d7b5e5b 100644 --- a/bindings/python/icsneopy/device/idevicesettings.cpp +++ b/bindings/python/icsneopy/device/idevicesettings.cpp @@ -31,7 +31,7 @@ void init_idevicesettings(pybind11::module_& m) { .value("Speed5G", DeviceSettingsNamespace::LinkSpeed::ETH_SPEED_5000) .value("Speed10G", DeviceSettingsNamespace::LinkSpeed::ETH_SPEED_10000); - pybind11::class_>(m, "IDeviceSettings") + pybind11::classh(m, "IDeviceSettings") .def("apply", &IDeviceSettings::apply, pybind11::arg("temporary") = 0, pybind11::call_guard()) .def("apply_defaults", &IDeviceSettings::applyDefaults, pybind11::arg("temporary") = 0, pybind11::call_guard()) .def("get_phy_enable", &IDeviceSettings::getPhyEnable, pybind11::call_guard()) diff --git a/bindings/python/icsneopy/flexray/flexray.cpp b/bindings/python/icsneopy/flexray/flexray.cpp index 53fe1d9..6726581 100644 --- a/bindings/python/icsneopy/flexray/flexray.cpp +++ b/bindings/python/icsneopy/flexray/flexray.cpp @@ -24,7 +24,7 @@ struct ClusterNamespace { }; void init_extension(pybind11::class_& c) { - pybind11::class_>(c, "MessageBuffer") + pybind11::classh(c, "MessageBuffer") .def(pybind11::init()) .def_readwrite("is_dynamic", &MessageBuffer::isDynamic) .def_readwrite("is_sync", &MessageBuffer::isSync) @@ -39,7 +39,7 @@ void init_extension(pybind11::class_& c) { .def_readwrite("cycle_repetition", &MessageBuffer::cycleRepetition) .def_readwrite("continuous_mode", &MessageBuffer::continuousMode); - auto controller = pybind11::class_>(c, "Controller") + auto controller = pybind11::classh(c, "Controller") .def("get_network", &Controller::getNetwork) .def("get_configuration", &Controller::getConfiguration) .def("set_configuration", &Controller::setConfiguration) @@ -143,7 +143,7 @@ void init_extension(pybind11::class_& c) { } // namespace FlexRay void init_flexraymessage(pybind11::module_& m) { - pybind11::class_, Frame>(m, "FlexRayMessage") + pybind11::classh(m, "FlexRayMessage") .def(pybind11::init()) .def_readwrite("slotid", &FlexRayMessage::slotid) .def_readwrite("tsslen", &FlexRayMessage::tsslen)