Add executables list to plugin API#179
Conversation
|
I'm okay with the idea but I don't really like the list interface:
A bit more complicated but I really don't like that |
Do you mean like how
I think we could change |
I think the best way is to return a
You would have to handle quoted arguments, etc., so that's not that simple. I think for now we can keep it as a single |
That would be a problem if it was the other way around (splitting on spaces), but |
I think at some point I tried to make that change and stumble upon something annoying but maybe I'm misremembering... Feel free to try to modify it this way. |
|
I think I just found what you're probably referring to: |
|
Unfortunately, I can't use I could do something similar to what I did with |
It's not about |
|
You're right, that fixed it. However, I have another issue in py::class_<IExecutablesList>(m, "IExecutablesList")
.def("executables",
[](IExecutablesList* executablesList) {
return make_generator(executablesList->executables());
})I get build errors: 'MOBase::IExecutable': cannot instantiate abstract class. How should I deal with that? |
Did you include the |
|
Yes, in |
What type did you use with |
|
|
|
You can try to replace the lambda with: .def("__next__", [](state& s) {
if (s.it != s.g.end()) -> decltype(auto) {
decltype(auto) v = *s.it;
s.it++;
return v;
}
else {
throw py::stop_iteration();
}
});...but that would need some testing. |
|
This gives me error code C2440 'return': cannot convert from '_Rty' to '_Rty &&' at the |
Can you push the uibase and plugin python changes to Github? I'll try to have a look when I can. |
|
Alright, thanks |
Replace the |
I don't think the other use needs that because they return // create a Python generator from a C++ generator
//
template <typename T, typename... Args>
auto make_generator(std::generator<T> g, Args&&... args)
{
using state = detail::generator_state<T>;
namespace py = pybind11;
if (!py::detail::get_type_info(typeid(state), false)) {
py::class_<state>(py::handle(), "iterator", pybind11::module_local())
.def("__iter__",
[](state& s) -> state& {
return s;
})
.def(
"__next__",
[](state& s) -> T {
if (s.it != s.g.end()) {
decltype(auto) v = *s.it;
s.it++;
return v;
}
else {
throw py::stop_iteration();
}
},
std::forward<Args>(args)...);
}
return py::cast(state{std::move(g)});
}And then you pass |
|
The changes in |
Maybe try replacing the |

This adds the
IExecutableandIExecutablesListinterfaces and theIOrganizer::executablesListmethod to expand the plugin API.