standardize names for classes with inner namespace
parent
0d68f42700
commit
c13b964777
|
@ -145,7 +145,7 @@ void Constructor::emit_cython_pxd(FileWriter& pxdFile, Str className) const {
|
||||||
void Constructor::emit_cython_pyx(FileWriter& pyxFile, const Class& cls) const {
|
void Constructor::emit_cython_pyx(FileWriter& pyxFile, const Class& cls) const {
|
||||||
for (size_t i = 0; i < nrOverloads(); i++) {
|
for (size_t i = 0; i < nrOverloads(); i++) {
|
||||||
ArgumentList args = argumentList(i);
|
ArgumentList args = argumentList(i);
|
||||||
pyxFile.oss << "\tdef " + name_ + "_" + to_string(i) +
|
pyxFile.oss << "\tdef " + cls.pyxClassName() + "_" + to_string(i) +
|
||||||
"(self, *args, **kwargs):\n";
|
"(self, *args, **kwargs):\n";
|
||||||
pyxFile.oss << pyx_resolveOverloadParams(args, true);
|
pyxFile.oss << pyx_resolveOverloadParams(args, true);
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ void GlobalFunction::emit_cython_pyx_no_overload(FileWriter& file) const {
|
||||||
file.oss << "def " << funcName;
|
file.oss << "def " << funcName;
|
||||||
// modify name of function instantiation as python doesn't allow overloads
|
// modify name of function instantiation as python doesn't allow overloads
|
||||||
// e.g. template<T={A,B,C}> funcName(...) --> funcNameA, funcNameB, funcNameC
|
// e.g. template<T={A,B,C}> funcName(...) --> funcNameA, funcNameB, funcNameC
|
||||||
if (templateArgValue_) file.oss << templateArgValue_->name();
|
if (templateArgValue_) file.oss << templateArgValue_->pyxClassName();
|
||||||
// funtion arguments
|
// funtion arguments
|
||||||
file.oss << "(";
|
file.oss << "(";
|
||||||
argumentList(0).emit_cython_pyx(file);
|
argumentList(0).emit_cython_pyx(file);
|
||||||
|
|
|
@ -106,7 +106,7 @@ void Method::emit_cython_pyx_no_overload(FileWriter& file,
|
||||||
file.oss << "\tdef " << funcName;
|
file.oss << "\tdef " << funcName;
|
||||||
// modify name of function instantiation as python doesn't allow overloads
|
// modify name of function instantiation as python doesn't allow overloads
|
||||||
// e.g. template<T={A,B,C}> funcName(...) --> funcNameA, funcNameB, funcNameC
|
// e.g. template<T={A,B,C}> funcName(...) --> funcNameA, funcNameB, funcNameC
|
||||||
if (templateArgValue_) file.oss << templateArgValue_->name();
|
if (templateArgValue_) file.oss << templateArgValue_->pyxClassName();
|
||||||
// funtion arguments
|
// funtion arguments
|
||||||
file.oss << "(self";
|
file.oss << "(self";
|
||||||
if (argumentList(0).size() > 0) file.oss << ", ";
|
if (argumentList(0).size() > 0) file.oss << ", ";
|
||||||
|
@ -132,7 +132,7 @@ void Method::emit_cython_pyx(FileWriter& file, const Class& cls) const {
|
||||||
// doesn't allow overloads
|
// doesn't allow overloads
|
||||||
// e.g. template<T={A,B,C}> funcName(...) --> funcNameA, funcNameB, funcNameC
|
// e.g. template<T={A,B,C}> funcName(...) --> funcNameA, funcNameB, funcNameC
|
||||||
string instantiatedName =
|
string instantiatedName =
|
||||||
(templateArgValue_) ? funcName + templateArgValue_->name() : funcName;
|
(templateArgValue_) ? funcName + templateArgValue_->pyxClassName() : funcName;
|
||||||
|
|
||||||
size_t N = nrOverloads();
|
size_t N = nrOverloads();
|
||||||
// It's easy if there's no overload
|
// It's easy if there's no overload
|
||||||
|
|
|
@ -201,7 +201,10 @@ public:
|
||||||
/// To refer to a Cython class in pyx, we need to add "pxd.", e.g. pxd.noiseModel_Gaussian
|
/// To refer to a Cython class in pyx, we need to add "pxd.", e.g. pxd.noiseModel_Gaussian
|
||||||
/// see the other function pxd_class_in_pyx for that purpose.
|
/// see the other function pxd_class_in_pyx for that purpose.
|
||||||
std::string pyxClassName() const {
|
std::string pyxClassName() const {
|
||||||
return pxdClassName();
|
if (isEigen())
|
||||||
|
return name_;
|
||||||
|
else
|
||||||
|
return qualifiedName("_", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Python type of function arguments in pyx to interface with normal python scripts
|
/// Python type of function arguments in pyx to interface with normal python scripts
|
||||||
|
|
Loading…
Reference in New Issue