make FeaturePythonPyT more flexible
This commit is contained in:
parent
fc2bbf52f9
commit
10bb1d6fea
|
@ -26,7 +26,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <Base/Console.h>
|
#include <Base/Console.h>
|
||||||
#include <App/PropertyContainerPy.h>
|
#include <Base/BaseClass.h>
|
||||||
|
|
||||||
namespace App
|
namespace App
|
||||||
{
|
{
|
||||||
|
@ -41,7 +41,7 @@ public:
|
||||||
static PyTypeObject Type;
|
static PyTypeObject Type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FeaturePythonPyT(PropertyContainer *pcObject, PyTypeObject *T = &Type);
|
FeaturePythonPyT(Base::BaseClass *pcObject, PyTypeObject *T = &Type);
|
||||||
virtual ~FeaturePythonPyT();
|
virtual ~FeaturePythonPyT();
|
||||||
|
|
||||||
/** @name callbacks and implementers for the python object methods */
|
/** @name callbacks and implementers for the python object methods */
|
||||||
|
|
|
@ -81,7 +81,7 @@ PyTypeObject FeaturePythonPyT<FeaturePyT>::Type = {
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class FeaturePyT>
|
template<class FeaturePyT>
|
||||||
FeaturePythonPyT<FeaturePyT>::FeaturePythonPyT(PropertyContainer *pcObject, PyTypeObject *T)
|
FeaturePythonPyT<FeaturePyT>::FeaturePythonPyT(Base::BaseClass *pcObject, PyTypeObject *T)
|
||||||
: FeaturePyT(reinterpret_cast<typename FeaturePyT::PointerType>(pcObject), T)
|
: FeaturePyT(reinterpret_cast<typename FeaturePyT::PointerType>(pcObject), T)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -156,16 +156,18 @@ PyObject *FeaturePythonPyT<FeaturePyT>::_getattr(char *attr)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject* dict = PyDict_Copy(tp->tp_dict);
|
PyObject* dict = FeaturePyT::_getattr(attr);
|
||||||
std::map<std::string,App::Property*> Map;
|
if (dict && PyDict_CheckExact(dict)) {
|
||||||
FeaturePyT::getPropertyContainerPtr()->getPropertyMap(Map);
|
PyObject* dict_old = dict;
|
||||||
for (std::map<std::string,App::Property*>::iterator it = Map.begin(); it != Map.end(); ++it)
|
dict = PyDict_Copy(dict_old);
|
||||||
PyDict_SetItem(dict, PyString_FromString(it->first.c_str()), PyString_FromString(""));
|
Py_DECREF(dict_old); // delete old dict
|
||||||
for (std::map<std::string, PyObject*>::const_iterator it = dyn_methods.begin(); it != dyn_methods.end(); ++it)
|
|
||||||
PyDict_SetItem(dict, PyString_FromString(it->first.c_str()), PyString_FromString(""));
|
for (std::map<std::string, PyObject*>::const_iterator it = dyn_methods.begin(); it != dyn_methods.end(); ++it)
|
||||||
if (PyErr_Occurred()) {
|
PyDict_SetItem(dict, PyString_FromString(it->first.c_str()), PyString_FromString(""));
|
||||||
Py_DECREF(dict);
|
if (PyErr_Occurred()) {
|
||||||
dict = 0;
|
Py_DECREF(dict);
|
||||||
|
dict = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user