Skip to content

Commit

Permalink
+ Add method to get typeid of property via Python
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Mar 5, 2014
1 parent 5fdb762 commit 4699856
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/App/PropertyContainerPy.xml
Expand Up @@ -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.
Expand Down
23 changes: 22 additions & 1 deletion src/App/PropertyContainerPyImp.cpp
Expand Up @@ -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)
Expand All @@ -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;
Expand Down

0 comments on commit 4699856

Please sign in to comment.