From 07b1bbfe7f088fc11f16db628337ce987792801e Mon Sep 17 00:00:00 2001 From: Duy-Nguyen Ta Date: Sat, 18 Mar 2017 18:29:53 -0400 Subject: [PATCH] remove namespace requirement for cython wrapper Only for unittesting wrap geometry.h, not yet tested in real python/cython --- wrap/Class.cpp | 7 +++++-- wrap/Qualified.h | 18 ++++++------------ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/wrap/Class.cpp b/wrap/Class.cpp index 9191a380f..97d57616f 100644 --- a/wrap/Class.cpp +++ b/wrap/Class.cpp @@ -730,8 +730,11 @@ void Class::python_wrapper(FileWriter& wrapperFile) const { /* ************************************************************************* */ void Class::emit_cython_pxd(FileWriter& pxdFile) const { - pxdFile.oss << "cdef extern from \"" << includeFile << "\" namespace \"" - << qualifiedNamespaces("::") << "\":" << endl; + pxdFile.oss << "cdef extern from \"" << includeFile << "\""; + string ns = qualifiedNamespaces("::"); + if (!ns.empty()) + pxdFile.oss << " namespace \"" << ns << "\""; + pxdFile.oss << ":" << endl; pxdFile.oss << " cdef cppclass " << pxdClassName() << " \"" << qualifiedName("::") << "\""; if (templateArgs.size()>0) { pxdFile.oss << "["; diff --git a/wrap/Qualified.h b/wrap/Qualified.h index b2df6f7b8..03095eb89 100644 --- a/wrap/Qualified.h +++ b/wrap/Qualified.h @@ -227,18 +227,12 @@ public: /// return the Cython class in pxd corresponding to a Python class in pyx std::string pxd_class_in_pyx() const { - if (isNonBasicType()) { - if (namespaces_.size() > 0) - return pxdClassName(); - else { - std::cerr << "Class without namespace: " << pxdClassName() << std::endl; - throw std::runtime_error("Error: User type without namespace!!"); - } - } - else if (isEigen()) { - return name_ + "Xd"; - } else // basic types and not Eigen - return name_; + if (isNonBasicType()) { + return pxdClassName(); + } else if (isEigen()) { + return name_ + "Xd"; + } else // basic types and not Eigen + return name_; } /// the internal Cython shared obj in a Python class wrappper