Make FeaturePython Python binding a template class to avoid code duplication

This commit is contained in:
wmayer
2013-03-22 00:34:18 +01:00
parent e6de57649b
commit 605e85b952
30 changed files with 508 additions and 506 deletions

View File

@@ -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>;
}