event.cc (12334:e0ab29a34764) | event.cc (13621:ae14904aa87b) |
---|---|
1/* 2 * Copyright (c) 2017 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 121 unchanged lines hidden (view full) --- 130 // TODO: Ownership of global exit events has always been a bit 131 // questionable. We currently assume they are owned by the C++ 132 // world. This is what the old SWIG code did, but that will result 133 // in memory leaks. 134 py::class_<GlobalSimLoopExitEvent, 135 std::unique_ptr<GlobalSimLoopExitEvent, py::nodelete>>( 136 m, "GlobalSimLoopExitEvent") 137 .def("getCause", &GlobalSimLoopExitEvent::getCause) | 1/* 2 * Copyright (c) 2017 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 121 unchanged lines hidden (view full) --- 130 // TODO: Ownership of global exit events has always been a bit 131 // questionable. We currently assume they are owned by the C++ 132 // world. This is what the old SWIG code did, but that will result 133 // in memory leaks. 134 py::class_<GlobalSimLoopExitEvent, 135 std::unique_ptr<GlobalSimLoopExitEvent, py::nodelete>>( 136 m, "GlobalSimLoopExitEvent") 137 .def("getCause", &GlobalSimLoopExitEvent::getCause) |
138#if PY_MAJOR_VERSION >= 3 139 .def("getCode", &GlobalSimLoopExitEvent::getCode) 140#else 141 // Workaround for an issue where PyBind11 converts the exit 142 // code to a long. This is normally fine, but sys.exit treats 143 // any non-int type as an error and exits with status 1 if it 144 // is passed a long. |
|
138 .def("getCode", [](GlobalSimLoopExitEvent *e) { 139 return py::reinterpret_steal<py::object>( 140 PyInt_FromLong(e->getCode())); 141 }) | 145 .def("getCode", [](GlobalSimLoopExitEvent *e) { 146 return py::reinterpret_steal<py::object>( 147 PyInt_FromLong(e->getCode())); 148 }) |
149#endif |
|
142 ; 143 144 // Event base class. These should never be returned directly to 145 // Python since they don't have a well-defined life cycle. Python 146 // events should be derived from PyEvent instead. 147 py::class_<Event> c_event( 148 m, "Event"); 149 c_event --- 31 unchanged lines hidden --- | 150 ; 151 152 // Event base class. These should never be returned directly to 153 // Python since they don't have a well-defined life cycle. Python 154 // events should be derived from PyEvent instead. 155 py::class_<Event> c_event( 156 m, "Event"); 157 c_event --- 31 unchanged lines hidden --- |