python: add wrapper on twa_graph::edges()
* spot/twa/twagraph.hh (edges): Do not hide from SWIG. * spot/graph/graph.hh: Hide stuff that SWIG do not understand. * python/spot/impl.i: Add some typemaps and fragment to iterate over the result of twa_graph::edges().
This commit is contained in:
parent
cd661801df
commit
1eee12b8b4
3 changed files with 31 additions and 4 deletions
|
|
@ -389,6 +389,7 @@ namespace std {
|
|||
%include <spot/graph/graph.hh>
|
||||
%nodefaultctor spot::digraph;
|
||||
%nodefaultctor spot::internal::state_out;
|
||||
%nodefaultctor spot::internal::all_trans;
|
||||
%traits_swigtype(spot::internal::edge_storage<unsigned int, unsigned int, unsigned int, spot::internal::boxed_label<spot::twa_graph_edge_data, false> >);
|
||||
%fragment(SWIG_Traits_frag(spot::internal::edge_storage<unsigned int, unsigned int, unsigned int, spot::internal::boxed_label<spot::twa_graph_edge_data, false> >));
|
||||
|
||||
|
|
@ -397,10 +398,17 @@ namespace std {
|
|||
SWIG_POINTER_OWN);
|
||||
}
|
||||
|
||||
%typemap(edges, optimal="1") spot::internal::all_trans<spot::digraph<spot::twa_graph_state, spot::twa_graph_edge_data>> {
|
||||
$result = SWIG_NewPointerObj(new $1_ltype($1), $&1_descriptor,
|
||||
SWIG_POINTER_OWN);
|
||||
}
|
||||
|
||||
%noexception spot::twa_graph::out;
|
||||
%noexception spot::twa_graph::edges;
|
||||
%include <spot/twa/twagraph.hh>
|
||||
|
||||
%template(twa_graph_state_out) spot::internal::state_out<spot::digraph<spot::twa_graph_state, spot::twa_graph_edge_data>>;
|
||||
%template(twa_graph_all_trans) spot::internal::all_trans<spot::digraph<spot::twa_graph_state, spot::twa_graph_edge_data>>;
|
||||
%template(twa_graph_edge_boxed_data) spot::internal::boxed_label<spot::twa_graph_edge_data, false>;
|
||||
%template(twa_graph_edge_storage) spot::internal::edge_storage<unsigned int, unsigned int, unsigned int, spot::internal::boxed_label<spot::twa_graph_edge_data, false> >;
|
||||
|
||||
|
|
@ -582,6 +590,14 @@ namespace std {
|
|||
}
|
||||
}
|
||||
|
||||
%extend spot::internal::all_trans<spot::digraph<spot::twa_graph_state, spot::twa_graph_edge_data>> {
|
||||
swig::SwigPyIterator* __iter__(PyObject **PYTHON_SELF)
|
||||
{
|
||||
return swig::make_forward_iterator(self->begin(), self->begin(),
|
||||
self->end(), *PYTHON_SELF);
|
||||
}
|
||||
}
|
||||
|
||||
%extend spot::acc_cond::acc_code {
|
||||
std::string __repr__()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -527,11 +527,13 @@ namespace spot
|
|||
template <typename Graph>
|
||||
class SPOT_API all_trans
|
||||
{
|
||||
public:
|
||||
typedef typename std::conditional<std::is_const<Graph>::value,
|
||||
const typename Graph::edge_vector_t,
|
||||
typename Graph::edge_vector_t>::type
|
||||
tv_t;
|
||||
typedef all_edge_iterator<Graph> iter_t;
|
||||
private:
|
||||
tv_t& tv_;
|
||||
public:
|
||||
|
||||
|
|
|
|||
|
|
@ -408,11 +408,20 @@ namespace spot
|
|||
auto states()
|
||||
SPOT_RETURN(g_.states());
|
||||
|
||||
auto edges() const
|
||||
SPOT_RETURN(g_.edges());
|
||||
auto edges()
|
||||
SPOT_RETURN(g_.edges());
|
||||
internal::all_trans<const graph_t>
|
||||
edges() const
|
||||
{
|
||||
return g_.edges();
|
||||
}
|
||||
#endif
|
||||
|
||||
internal::all_trans<graph_t>
|
||||
edges()
|
||||
{
|
||||
return g_.edges();
|
||||
}
|
||||
|
||||
#ifndef SWIG
|
||||
auto edge_vector() const
|
||||
SPOT_RETURN(g_.edge_vector());
|
||||
auto edge_vector()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue