@@ -21,7 +21,8 @@ PYBIND11_MODULE(PyCGraph, m) {
2121 .def (py::init<int , const std::string&>())
2222 .def (" getCode" , &CStatus::getCode)
2323 .def (" getInfo" , &CStatus::getInfo)
24- .def (" isOK" , &CStatus::isOK);
24+ .def (" isOK" , &CStatus::isOK)
25+ .def (" isErr" , &CStatus::isErr);
2526
2627 py::enum_<GMultiConditionType>(m, " GMultiConditionType" )
2728 .value (" SERIAL" , GMultiConditionType::SERIAL)
@@ -37,7 +38,8 @@ PYBIND11_MODULE(PyCGraph, m) {
3738 py::class_<PyGPipeline, std::unique_ptr<PyGPipeline, py::nodelete> >(m, " GPipeline" )
3839 .def (py::init<>())
3940 .def (" init" , &PyGPipeline::init)
40- .def (" createGParam" , &PyGPipeline::__createGParam_4py)
41+ .def (" createGParam" , &PyGPipeline::__createGParam_4py,
42+ py::keep_alive<1 , 2 >())
4143 .def (" getGParam" , &PyGPipeline::__getGParam_4py)
4244 .def (" run" , &PyGPipeline::run, py::call_guard<py::gil_scoped_release>())
4345 .def (" process" , &PyGPipeline::process, py::call_guard<py::gil_scoped_release>(),
@@ -48,15 +50,17 @@ PYBIND11_MODULE(PyCGraph, m) {
4850 py::arg (" depends" ) = GElementPtrSet{},
4951 py::arg (" name" ) = CGRAPH_EMPTY,
5052 py::arg (" loop" ) = CGRAPH_DEFAULT_LOOP_TIMES,
51- " register a GElement with dependencies, name, and loop count. " );
53+ py::keep_alive< 1 , 2 >() );
5254
5355 py::class_<GElement, PywGElement, std::unique_ptr<GElement, py::nodelete> >(m, " GElement" )
5456 .def (py::init<>())
57+ .def (" createGParam" , &GElement::__createGParam_4py,
58+ py::keep_alive<1 , 2 >())
5559 .def (" getGParam" , &GElement::__getGParam_4py)
5660 .def (" getName" , &GElement::getName)
5761 .def (" setName" , &GElement::setName)
5862 .def (" addDependGElements" , &GElement::addDependGElements,
59- py::arg (" elements" ))
63+ py::arg (" elements" ))
6064 .def (" setLoop" , &GElement::setLoop);
6165
6266 py::class_<GNode, PywGNode, GElement, std::unique_ptr<GNode, py::nodelete> >(m, " GNode" )
@@ -70,32 +74,42 @@ PYBIND11_MODULE(PyCGraph, m) {
7074
7175 py::class_<PyGCluster, GElement, std::unique_ptr<PyGCluster, py::nodelete> >(m, " GCluster" )
7276 .def (py::init<const CGraph::GElementPtrArr&>(),
73- py::arg (" elements" ) = GElementPtrArr{})
77+ py::arg (" elements" ) = GElementPtrArr{},
78+ py::keep_alive<1 , 2 >())
7479 .def (" addGElements" , &PyGCluster::addGElements,
75- py::arg (" elements" ));
80+ py::arg (" elements" ),
81+ py::keep_alive<1 , 2 >());
7682
7783 py::class_<PyGRegion, GElement, std::unique_ptr<PyGRegion, py::nodelete> >(m, " GRegion" )
7884 .def (py::init<const CGraph::GElementPtrArr&>(),
79- py::arg (" elements" ) = GElementPtrArr{})
85+ py::arg (" elements" ) = GElementPtrArr{},
86+ py::keep_alive<1 , 2 >())
8087 .def (" addGElements" , &PyGRegion::addGElements,
81- py::arg (" elements" ));
88+ py::arg (" elements" ),
89+ py::keep_alive<1 , 2 >());
8290
8391 py::class_<PywGCondition, GElement, std::unique_ptr<PywGCondition, py::nodelete> >(m, " GCondition" )
8492 .def (py::init<const CGraph::GElementPtrArr&>(),
85- py::arg (" elements" ) = GElementPtrArr{})
93+ py::arg (" elements" ) = GElementPtrArr{},
94+ py::keep_alive<1 , 2 >())
8695 .def (" getRange" , &PywGCondition::__getRange_4py)
8796 .def (" addGElements" , &PywGCondition::addGElements,
88- py::arg (" elements" ));
97+ py::arg (" elements" ),
98+ py::keep_alive<1 , 2 >());
8999
90100 py::class_<PyGMultiCondition<CGraph::GMultiConditionType::SERIAL>, GElement>(m, " GSerialMultiCondition" )
91101 .def (py::init<const CGraph::GElementPtrArr&>(),
92- py::arg (" elements" ) = GElementPtrArr{})
102+ py::arg (" elements" ) = GElementPtrArr{},
103+ py::keep_alive<1 , 2 >())
93104 .def (" addGElements" , &PyGMultiCondition<CGraph::GMultiConditionType::SERIAL>::addGElements,
94- py::arg (" elements" ));
105+ py::arg (" elements" ),
106+ py::keep_alive<1 , 2 >());
95107
96108 py::class_<PyGMultiCondition<CGraph::GMultiConditionType::PARALLEL>, GElement>(m, " GParallelMultiCondition" )
97109 .def (py::init<const CGraph::GElementPtrArr&>(),
98- py::arg (" elements" ) = GElementPtrArr{})
110+ py::arg (" elements" ) = GElementPtrArr{},
111+ py::keep_alive<1 , 2 >())
99112 .def (" addGElements" , &PyGMultiCondition<CGraph::GMultiConditionType::PARALLEL>::addGElements,
100- py::arg (" elements" ));
113+ py::arg (" elements" ),
114+ py::keep_alive<1 , 2 >());
101115}
0 commit comments