Make FeaturePython Python binding a template class to avoid code duplication
This commit is contained in:
@@ -31,13 +31,11 @@
|
||||
#include <App/DynamicProperty.h>
|
||||
#include <App/PropertyPythonObject.h>
|
||||
#include <App/PropertyGeo.h>
|
||||
#include <App/FeaturePythonPy.h>
|
||||
|
||||
namespace App
|
||||
{
|
||||
|
||||
class Property;
|
||||
class FeaturePythonPy;
|
||||
|
||||
// Helper class to hide implementation details
|
||||
class AppExport FeaturePythonImp
|
||||
@@ -48,6 +46,7 @@ public:
|
||||
|
||||
DocumentObjectExecReturn *execute();
|
||||
void onChanged(const Property* prop);
|
||||
PyObject *getPyObject(void);
|
||||
|
||||
private:
|
||||
App::DocumentObject* object;
|
||||
@@ -188,7 +187,7 @@ public:
|
||||
PyObject *getPyObject(void) {
|
||||
if (FeatureT::PythonObject.is(Py::_None())) {
|
||||
// ref counter is set to 1
|
||||
FeatureT::PythonObject = Py::Object(new FeaturePythonPy(this),true);
|
||||
FeatureT::PythonObject = Py::Object(imp->getPyObject(),true);
|
||||
}
|
||||
return Py::new_reference_to(FeatureT::PythonObject);
|
||||
}
|
||||
@@ -199,8 +198,6 @@ public:
|
||||
FeatureT::PythonObject = Py::None();
|
||||
}
|
||||
|
||||
friend class FeaturePythonPy;
|
||||
|
||||
protected:
|
||||
virtual void onChanged(const Property* prop) {
|
||||
imp->onChanged(prop);
|
||||
|
||||
Reference in New Issue
Block a user