diff --git a/pytriqs/gf/local/gf_desc.py b/pytriqs/gf/local/gf_desc.py index 2981ea55..f849a230 100644 --- a/pytriqs/gf/local/gf_desc.py +++ b/pytriqs/gf/local/gf_desc.py @@ -95,11 +95,11 @@ module.add_class(t) ######################## module.add_enum(c_name = "statistic_enum", - c_name_absolute = "triqs::gfs::statistic_enum", + c_namespace = "triqs::gfs", values = ["Fermion","Boson"]) module.add_enum(c_name = "mesh_kind", - c_name_absolute = "triqs::gfs::mesh_kind", + c_namespace = "triqs::gfs", values = ["half_bins","full_bins","without_last"]) ######################## diff --git a/pytriqs/wrap_generator/py_converter_wrapper.mako.hpp b/pytriqs/wrap_generator/py_converter_wrapper.mako.hpp index 0b63d8ea..c7d3ab28 100644 --- a/pytriqs/wrap_generator/py_converter_wrapper.mako.hpp +++ b/pytriqs/wrap_generator/py_converter_wrapper.mako.hpp @@ -74,16 +74,16 @@ template<> struct py_converter<${c.c_type_absolute}> { template <> struct py_converter<${en.c_name_absolute}> { static PyObject * c2py(${en.c_name_absolute} x) { %for n,val in enumerate(en.values[:-1]) : - if (x == ${val}) return PyString_FromString("${val}"); + if (x == ${en.c_namespace}${val}) return PyString_FromString("${val}"); %endfor return PyString_FromString("${en.values[-1]}"); // last case separate to avoid no return warning of compiler } static ${en.c_name_absolute} py2c(PyObject * ob){ std::string s=PyString_AsString(ob); %for n,val in enumerate(en.values[:-1]) : - if (s == "${val}") return ${val}; + if (s == "${val}") return ${en.c_namespace}${val}; %endfor - return ${en.values[-1]}; + return ${en.c_namespace}${en.values[-1]}; } static bool is_convertible(PyObject *ob, bool raise_exception) { if (!PyString_Check(ob)) { diff --git a/pytriqs/wrap_generator/wrap_generator.py b/pytriqs/wrap_generator/wrap_generator.py index 6923e6c5..3b7e4ff8 100644 --- a/pytriqs/wrap_generator/wrap_generator.py +++ b/pytriqs/wrap_generator/wrap_generator.py @@ -277,6 +277,7 @@ class class_ : # expect a tuple : "algebra", "scalar1", "scalar2", etc... self.number_protocol = {} if arithmetic : + if not isinstance(arithmetic, tuple) : arithmetic = (arithmetic,) add = arithmetic[0] in ("algebra", "abelian_group", "vector_space", "only_add") abelian_group = arithmetic[0] in ("algebra", "abelian_group", "vector_space") vector_space = arithmetic[0] in ("algebra", "vector_space") @@ -435,9 +436,10 @@ class enum_ : - values : list of string representing the enumerated - doc : the doc string. """ - def __init__(self, c_name, values, c_name_absolute = None, doc = '') : - self.c_name, self.c_name_absolute, self.values, self.doc = c_name, c_name_absolute or c_name, values, doc - + def __init__(self, c_name, values, c_namespace ="", doc = '') : + self.c_name, self.c_namespace, self.values, self.doc = c_name, c_namespace + "::", values, doc + self.c_name_absolute = self.c_namespace + self.c_name + class module_ : """ Representation of a module