Commit 919ade0c authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Improve run_action module

Use tr1::tuple instead of boost::tuple to get around maximum tuple size
limit (this requires GCC 4.3). Introduce get_prop<> template function to
facilitate access of property maps from inline C++ code.
parent 149c5c94
......@@ -63,8 +63,8 @@ def inline(g, code, arg_names=[], local_dict=None,
# each term on the expansion will properly unwrap a tuple pointer value
# to a reference with the appropriate name and type
exp_term = """typename boost::remove_pointer<typename element<%d,Args>::type>::type& %s =
*get<%d>(_args);"""
exp_term = """typename boost::remove_pointer<typename tr1::tuple_element<%d,Args>::type>::type& %s =
*tr1::get<%d>(_args);"""
arg_expansion = "\n".join([ exp_term % (i,arg_names[i],i) for i in \
xrange(0, len(arg_names))])
......
......@@ -18,9 +18,7 @@
#include <list>
#include <tr1/unordered_set>
#include <tr1/unordered_map>
#include <boost/tuple/tuple.hpp>
#include <boost/type_traits.hpp>
#include <boost/python.hpp>
#include <tr1/tuple>
#include "graph.hh"
#include "graph_filtering.hh"
#include "graph_properties.hh"
......@@ -29,7 +27,6 @@
#include <boost/lambda/bind.hpp>
using namespace boost;
using namespace boost::tuples;
using namespace std;
using namespace graph_tool;
......@@ -57,6 +54,22 @@ struct prop_bind_t
};
};
// utility template function to extract the correct property map
template <class PropertyMap>
PropertyMap get_prop(py::object& map)
{
try
{
python::object pmap =
python::object(map).attr("_PropertyMap__map").attr("get_map")();
return any_cast<PropertyMap>(python::extract<boost::any>(pmap)());
}
catch (bad_any_cast&)
{
throw GraphException("could not convert property map as requested");
}
}
// the action function object
template <class Args>
struct action_${code_hash}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment