diff --git a/python/spot/impl.i b/python/spot/impl.i index 43bf8966e..a279d5d96 100644 --- a/python/spot/impl.i +++ b/python/spot/impl.i @@ -389,6 +389,7 @@ namespace std { %include %nodefaultctor spot::digraph; %nodefaultctor spot::internal::state_out; +%nodefaultctor spot::internal::all_trans; %traits_swigtype(spot::internal::edge_storage >); %fragment(SWIG_Traits_frag(spot::internal::edge_storage >)); @@ -397,10 +398,17 @@ namespace std { SWIG_POINTER_OWN); } +%typemap(edges, optimal="1") spot::internal::all_trans> { + $result = SWIG_NewPointerObj(new $1_ltype($1), $&1_descriptor, + SWIG_POINTER_OWN); +} + %noexception spot::twa_graph::out; +%noexception spot::twa_graph::edges; %include %template(twa_graph_state_out) spot::internal::state_out>; +%template(twa_graph_all_trans) spot::internal::all_trans>; %template(twa_graph_edge_boxed_data) spot::internal::boxed_label; %template(twa_graph_edge_storage) spot::internal::edge_storage >; @@ -582,6 +590,14 @@ namespace std { } } +%extend spot::internal::all_trans> { + 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__() { diff --git a/spot/graph/graph.hh b/spot/graph/graph.hh index 2e948e8b6..6d9127c04 100644 --- a/spot/graph/graph.hh +++ b/spot/graph/graph.hh @@ -527,11 +527,13 @@ namespace spot template class SPOT_API all_trans { + public: typedef typename std::conditional::value, const typename Graph::edge_vector_t, typename Graph::edge_vector_t>::type tv_t; typedef all_edge_iterator iter_t; + private: tv_t& tv_; public: diff --git a/spot/twa/twagraph.hh b/spot/twa/twagraph.hh index 40d029491..bec6ff5e9 100644 --- a/spot/twa/twagraph.hh +++ b/spot/twa/twagraph.hh @@ -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 + edges() const + { + return g_.edges(); + } +#endif + internal::all_trans + edges() + { + return g_.edges(); + } + +#ifndef SWIG auto edge_vector() const SPOT_RETURN(g_.edge_vector()); auto edge_vector()