Make FeaturePython Python binding a template class to avoid code duplication
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
#include <Base/Reader.h>
|
||||
|
||||
#include "FeaturePython.h"
|
||||
#include "FeaturePythonPy.h"
|
||||
#include "FeaturePythonPyImp.h"
|
||||
|
||||
using namespace App;
|
||||
|
||||
@@ -109,13 +109,26 @@ void FeaturePythonImp::onChanged(const Property* prop)
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *FeaturePythonImp::getPyObject(void)
|
||||
{
|
||||
// ref counter is set to 1
|
||||
return new FeaturePythonPyT<DocumentObjectPy>(object);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
|
||||
namespace App {
|
||||
PROPERTY_SOURCE_TEMPLATE(App::FeaturePython, App::DocumentObject)
|
||||
template<> const char* App::FeaturePython::getViewProviderName(void) const {
|
||||
return "Gui::ViewProviderPythonFeature";
|
||||
}
|
||||
template<> PyObject* App::FeaturePython::getPyObject(void) {
|
||||
if (PythonObject.is(Py::_None())) {
|
||||
// ref counter is set to 1
|
||||
PythonObject = Py::Object(new FeaturePythonPyT<DocumentObjectPy>(this),true);
|
||||
}
|
||||
return Py::new_reference_to(PythonObject);
|
||||
}
|
||||
// explicit template instantiation
|
||||
template class AppExport FeaturePythonT<DocumentObject>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user