+ Add method to get typeid of property via Python

This commit is contained in:
wmayer 2014-03-05 15:10:37 +01:00
parent 5fdb762236
commit 4699856799
2 changed files with 27 additions and 1 deletions

View File

@ -23,6 +23,11 @@
<UserDocu>Return the type of a named property. This can be (Hidden,ReadOnly,Output) or any combination. </UserDocu>
</Documentation>
</Methode>
<Methode Name="getTypeIdOfProperty">
<Documentation>
<UserDocu>Returns the C++ class name of a named property.</UserDocu>
</Documentation>
</Methode>
<Methode Name="setEditorMode">
<Documentation>
<UserDocu>Set the behaviour of the property in the property editor.

View File

@ -64,8 +64,13 @@ PyObject* PropertyContainerPy::getTypeOfProperty(PyObject *args)
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
return NULL; // NULL triggers exception
short Type = getPropertyContainerPtr()->getPropertyType(pstr);
Property* prop = getPropertyContainerPtr()->getPropertyByName(pstr);
if (!prop) {
PyErr_Format(PyExc_AttributeError, "Property container has no property '%s'", pstr);
return 0;
}
short Type = prop->getType();
if (Type & Prop_Hidden)
ret.append(Py::String("Hidden"));
if (Type & Prop_ReadOnly)
@ -78,6 +83,22 @@ PyObject* PropertyContainerPy::getTypeOfProperty(PyObject *args)
return Py::new_reference_to(ret);
}
PyObject* PropertyContainerPy::getTypeIdOfProperty(PyObject *args)
{
char *pstr;
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
return NULL; // NULL triggers exception
Property* prop = getPropertyContainerPtr()->getPropertyByName(pstr);
if (!prop) {
PyErr_Format(PyExc_AttributeError, "Property container has no property '%s'", pstr);
return 0;
}
Py::String str(prop->getTypeId().getName());
return Py::new_reference_to(str);
}
PyObject* PropertyContainerPy::setEditorMode(PyObject *args)
{
char* name;