Moved wrapper class signature to Class.cpp
parent
74a33ff222
commit
6068166d2b
|
@ -764,6 +764,19 @@ void Class::emit_cython_pxd(FileWriter& pxdFile) const {
|
||||||
if (numMethods == 0)
|
if (numMethods == 0)
|
||||||
pxdFile.oss << " pass\n";
|
pxdFile.oss << " pass\n";
|
||||||
}
|
}
|
||||||
|
/* ************************************************************************* */
|
||||||
|
void Class::emit_cython_wrapper_pxd(FileWriter& pxdFile) const {
|
||||||
|
pxdFile.oss << "cdef class " << pyxClassName();
|
||||||
|
if (getParent())
|
||||||
|
pxdFile.oss << "(" << getParent()->pyxClassName() << ")";
|
||||||
|
pxdFile.oss << ":\n";
|
||||||
|
pxdFile.oss << " cdef " << shared_pxd_class_in_pyx() << " "
|
||||||
|
<< shared_pxd_obj_in_pyx() << "\n";
|
||||||
|
// cyCreateFromShared
|
||||||
|
pxdFile.oss << " @staticmethod\n";
|
||||||
|
pxdFile.oss << " cdef " << pyxClassName() << " cyCreateFromShared(const "
|
||||||
|
<< shared_pxd_class_in_pyx() << "& other)\n";
|
||||||
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void Class::pyxInitParentObj(FileWriter& pyxFile, const std::string& pyObj,
|
void Class::pyxInitParentObj(FileWriter& pyxFile, const std::string& pyObj,
|
||||||
|
|
|
@ -165,6 +165,7 @@ public:
|
||||||
|
|
||||||
// emit cython wrapper
|
// emit cython wrapper
|
||||||
void emit_cython_pxd(FileWriter& pxdFile) const;
|
void emit_cython_pxd(FileWriter& pxdFile) const;
|
||||||
|
void emit_cython_wrapper_pxd(FileWriter& pxdFile) const;
|
||||||
void emit_cython_pyx(FileWriter& pyxFile,
|
void emit_cython_pyx(FileWriter& pyxFile,
|
||||||
const std::vector<Class>& allClasses) const;
|
const std::vector<Class>& allClasses) const;
|
||||||
void pyxInitParentObj(FileWriter& pyxFile, const std::string& pyObj,
|
void pyxInitParentObj(FileWriter& pyxFile, const std::string& pyObj,
|
||||||
|
|
|
@ -357,41 +357,31 @@ void Module::emit_cython_pxd(FileWriter& pxdFile) const {
|
||||||
|
|
||||||
//... wrap all classes
|
//... wrap all classes
|
||||||
for (const Class& cls : uninstantiatedClasses) {
|
for (const Class& cls : uninstantiatedClasses) {
|
||||||
cls.emit_cython_pxd(pxdFile);
|
cls.emit_cython_pxd(pxdFile);
|
||||||
|
|
||||||
for (const Class& expCls : expandedClasses) {
|
for (const Class& expanded : expandedClasses) {
|
||||||
//... ctypedef for template instantiations
|
bool matchingNonTemplated = !expanded.templateClass
|
||||||
if (expCls.templateClass &&
|
&& expanded.pxdClassName() == cls.pxdClassName();
|
||||||
expCls.templateClass->pxdClassName() == cls.pxdClassName()) {
|
bool isTemplatedFromCls = expanded.templateClass
|
||||||
pxdFile.oss << "ctypedef " << expCls.templateClass->pxdClassName()
|
&& expanded.templateClass->pxdClassName() == cls.pxdClassName();
|
||||||
<< "[";
|
|
||||||
for (size_t i = 0; i < expCls.templateInstTypeList.size(); ++i)
|
|
||||||
pxdFile.oss << expCls.templateInstTypeList[i].pxdClassName()
|
|
||||||
<< ((i == expCls.templateInstTypeList.size() - 1)
|
|
||||||
? ""
|
|
||||||
: ", ");
|
|
||||||
pxdFile.oss << "] " << expCls.pxdClassName() << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((!expCls.templateClass &&
|
// ctypedef for template instantiations
|
||||||
expCls.pxdClassName() == cls.pxdClassName()) ||
|
if (isTemplatedFromCls) {
|
||||||
(expCls.templateClass &&
|
pxdFile.oss << "\n";
|
||||||
expCls.templateClass->pxdClassName() == cls.pxdClassName())) {
|
pxdFile.oss << "ctypedef " << expanded.templateClass->pxdClassName()
|
||||||
pxdFile.oss << "\n";
|
<< "[";
|
||||||
pxdFile.oss << "cdef class " << expCls.pyxClassName();
|
for (size_t i = 0; i < expanded.templateInstTypeList.size(); ++i)
|
||||||
if (expCls.getParent())
|
pxdFile.oss << expanded.templateInstTypeList[i].pxdClassName()
|
||||||
pxdFile.oss << "(" << expCls.getParent()->pyxClassName() << ")";
|
<< ((i == expanded.templateInstTypeList.size() - 1) ? "" : ", ");
|
||||||
pxdFile.oss << ":\n";
|
pxdFile.oss << "] " << expanded.pxdClassName() << "\n";
|
||||||
pxdFile.oss << " cdef " << expCls.shared_pxd_class_in_pyx()
|
|
||||||
<< " " << expCls.shared_pxd_obj_in_pyx() << "\n";
|
|
||||||
// cyCreateFromShared
|
|
||||||
pxdFile.oss << " @staticmethod\n";
|
|
||||||
pxdFile.oss << " cdef " << expCls.pyxClassName()
|
|
||||||
<< " cyCreateFromShared(const "
|
|
||||||
<< expCls.shared_pxd_class_in_pyx() << "& other)\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pxdFile.oss << "\n\n";
|
|
||||||
|
// Python wrapper class
|
||||||
|
if (isTemplatedFromCls || matchingNonTemplated) {
|
||||||
|
expanded.emit_cython_wrapper_pxd(pxdFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pxdFile.oss << "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
//... wrap global functions
|
//... wrap global functions
|
||||||
|
|
Loading…
Reference in New Issue