Show dynamically added methods in calltips list
This commit is contained in:
parent
295f6c3058
commit
24f559be9a
|
@ -383,11 +383,18 @@ PyObject *FeaturePythonPyT<FeaturePyT>::getCustomAttributes(const char* attr) co
|
||||||
{
|
{
|
||||||
PY_TRY{
|
PY_TRY{
|
||||||
if (Base::streq(attr, "__dict__")){
|
if (Base::streq(attr, "__dict__")){
|
||||||
PyObject* dict = FeaturePyT::getCustomAttributes(attr);
|
// Return the default dict
|
||||||
if (dict){
|
PyTypeObject *tp = this->ob_type;
|
||||||
std::vector<std::string> Props = FeaturePyT::getDocumentObjectPtr()->getDynamicPropertyNames();
|
PyObject* dict = PyDict_Copy(tp->tp_dict);
|
||||||
for (std::vector<std::string>::const_iterator it = Props.begin(); it != Props.end(); ++it)
|
std::map<std::string,App::Property*> Map;
|
||||||
PyDict_SetItem(dict, PyString_FromString(it->c_str()), PyString_FromString(""));
|
FeaturePyT::getPropertyContainerPtr()->getPropertyMap(Map);
|
||||||
|
for (std::map<std::string,App::Property*>::iterator it = Map.begin(); it != Map.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)
|
||||||
|
PyDict_SetItem(dict, PyString_FromString(it->first.c_str()), PyString_FromString(""));
|
||||||
|
if (PyErr_Occurred()) {
|
||||||
|
Py_DECREF(dict);
|
||||||
|
dict = 0;
|
||||||
}
|
}
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include <App/Document.h>
|
#include <App/Document.h>
|
||||||
#include <App/DocumentObject.h>
|
#include <App/DocumentObject.h>
|
||||||
#include <App/DocumentPy.h>
|
#include <App/DocumentPy.h>
|
||||||
|
#include <App/DocumentObjectPy.h>
|
||||||
#include <Gui/BitmapFactory.h>
|
#include <Gui/BitmapFactory.h>
|
||||||
#include <Gui/Document.h>
|
#include <Gui/Document.h>
|
||||||
#include <Gui/DocumentPy.h>
|
#include <Gui/DocumentPy.h>
|
||||||
|
@ -232,8 +233,19 @@ QMap<QString, CallTip> CallTipsList::extractTips(const QString& context) const
|
||||||
Py::Object type(PyObject_Type(obj.ptr()), true);
|
Py::Object type(PyObject_Type(obj.ptr()), true);
|
||||||
Py::Object inst = obj; // the object instance
|
Py::Object inst = obj; // the object instance
|
||||||
union PyType_Object typeobj = {&Base::PyObjectBase::Type};
|
union PyType_Object typeobj = {&Base::PyObjectBase::Type};
|
||||||
bool subclass = (PyObject_IsSubclass(type.ptr(), typeobj.o) == 1);
|
union PyType_Object typedoc = {&App::DocumentObjectPy::Type};
|
||||||
if (subclass) obj = type;
|
if (PyObject_IsSubclass(type.ptr(), typedoc.o) == 1) {
|
||||||
|
// From the template Python object we don't query its type object because there we keep
|
||||||
|
// a list of additional methods that we won't see otherwise. But to get the correct doc
|
||||||
|
// strings we query the type's dict in the class itself.
|
||||||
|
// To see if we have a template Python object we check for the existence of supportedProperties
|
||||||
|
if (!type.hasAttr("supportedProperties")) {
|
||||||
|
obj = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (PyObject_IsSubclass(type.ptr(), typeobj.o) == 1) {
|
||||||
|
obj = type;
|
||||||
|
}
|
||||||
|
|
||||||
// If we have an instance of PyObjectBase then determine whether it's valid or not
|
// If we have an instance of PyObjectBase then determine whether it's valid or not
|
||||||
if (PyObject_IsInstance(inst.ptr(), typeobj.o) == 1) {
|
if (PyObject_IsInstance(inst.ptr(), typeobj.o) == 1) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user