Commit 010afe9b authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Export Vector_size_t and std::type_info to Python

parent bd96105e
......@@ -128,9 +128,12 @@ struct export_vector_types
template <class ValueType>
void operator()(ValueType) const
{
string type_name = get_type_name<>()(typeid(ValueType));
if (type_name == "long double")
type_name = "long_double";
string type_name;
if (std::is_same<ValueType, size_t>::value)
type_name = "size_t";
else
type_name = get_type_name<>()(typeid(ValueType));
std::replace(type_name.begin(), type_name.end(), ' ', '_');
string name = "Vector_" + type_name;
class_<vector<ValueType> > vc(name.c_str());
vc.def(vector_indexing_suite<vector<ValueType> >())
......@@ -424,12 +427,19 @@ BOOST_PYTHON_MODULE(libgraph_tool_core)
def("raise_error", &raise_error);
def("get_property_types", &get_property_types);
class_<boost::any>("any")
.def("empty", &boost::any::empty);
.def("empty", &boost::any::empty)
.def("type", &boost::any::type,
return_value_policy<reference_existing_object>());
class_<std::type_info, boost::noncopyable>("type_info", no_init)
.def("name", &std::type_info::name)
.def("hash_code", &std::type_info::hash_code);
def("gcc_demangle", &python::detail::gcc_demangle);
def("graph_filtering_enabled", &graph_filtering_enabled);
export_openmp();
boost::mpl::for_each<boost::mpl::push_back<scalar_types,string>::type>(export_vector_types());
boost::mpl::for_each<boost::mpl::vector<uint64_t>>(export_vector_types());
class_<GraphInterface>("GraphInterface", init<>())
.def(init<GraphInterface,bool,boost::python::object,
......
......@@ -123,11 +123,11 @@ __all__ = ["Graph", "GraphView", "Vertex", "Edge", "Vector_bool",
"Vector_double", "Vector_long_double", "Vector_string",
"Vector_size_t", "value_types", "load_graph", "PropertyMap",
"group_vector_property", "ungroup_vector_property",
"infect_vertex_property", "edge_endpoint_property", "perfect_prop_hash",
"seed_rng", "show_config", "PropertyArray", "openmp_enabled",
"openmp_get_num_threads", "openmp_set_num_threads", "openmp_get_schedule",
"openmp_set_schedule", "__author__", "__copyright__", "__URL__",
"__version__"]
"infect_vertex_property", "edge_endpoint_property",
"perfect_prop_hash", "seed_rng", "show_config", "PropertyArray",
"openmp_enabled", "openmp_get_num_threads", "openmp_set_num_threads",
"openmp_get_schedule", "openmp_set_schedule", "__author__",
"__copyright__", "__URL__", "__version__"]
# this is rather pointless, but it works around a sphinx bug
graph_tool = sys.modules[__name__]
......@@ -1124,7 +1124,8 @@ class PropertyDict(dict):
from .libgraph_tool_core import Vertex, EdgeBase, Vector_bool, Vector_int16_t, \
Vector_int32_t, Vector_int64_t, Vector_double, Vector_long_double, \
Vector_string, new_vertex_property, new_edge_property, new_graph_property
Vector_string, Vector_size_t, new_vertex_property, new_edge_property, \
new_graph_property
class Graph(object):
......
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