Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stack Of Tasks
dynamic-graph-python
Commits
516eb712
Commit
516eb712
authored
Mar 16, 2012
by
Florent Lamiraux
Committed by
Florent Lamiraux florent@laas.fr
Mar 16, 2012
Browse files
Document entity class types with the output of C++ getDocString method.
parent
4b88b840
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/dynamic-graph-py.cc
View file @
516eb712
...
...
@@ -50,6 +50,7 @@ namespace dynamicgraph {
extern
PyObject
*
executeCommand
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
listCommands
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
getCommandDocstring
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
getDocString
(
PyObject
*
self
,
PyObject
*
args
);
}
namespace
factory
{
...
...
@@ -186,6 +187,10 @@ static PyMethodDef dynamicGraphMethods[] = {
dynamicgraph
::
python
::
entity
::
getCommandDocstring
,
METH_VARARGS
,
"get the docstring of an entity command"
},
{
"entity_get_docstring"
,
dynamicgraph
::
python
::
entity
::
getDocString
,
METH_VARARGS
,
"get the doc string of an entity type"
},
{
"factory_get_entity_class_list"
,
dynamicgraph
::
python
::
factory
::
getEntityClassList
,
METH_VARARGS
,
...
...
src/dynamic_graph/entity.py
View file @
516eb712
...
...
@@ -85,6 +85,7 @@ class Entity (object) :
Entity
.
__init__
(
self
,
self
.
className
,
name
)
if
not
self
.
__class__
.
commandCreated
:
self
.
boundClassCommands
()
self
.
__class__
.
__doc__
=
wrap
.
entity_get_docstring
(
self
.
obj
)
self
.
__class__
.
commandCreated
=
True
@
property
...
...
src/entity-py.cc
View file @
516eb712
...
...
@@ -305,6 +305,32 @@ namespace dynamicgraph {
return
Py_BuildValue
(
"s"
,
docstring
.
c_str
());
}
PyObject
*
getDocString
(
PyObject
*
/*self*/
,
PyObject
*
args
)
{
PyObject
*
object
=
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
"O"
,
&
object
))
{
return
NULL
;
}
// Retrieve the entity instance
if
(
!
PyCObject_Check
(
object
))
{
PyErr_SetString
(
dgpyError
,
"first argument is not an object"
);
return
NULL
;
}
void
*
pointer
=
PyCObject_AsVoidPtr
(
object
);
Entity
*
entity
=
(
Entity
*
)
pointer
;
try
{
return
Py_BuildValue
(
"s"
,
entity
->
getDocString
().
c_str
());
}
catch
(
const
std
::
exception
&
exc
)
{
PyErr_SetString
(
dgpyError
,
exc
.
what
())
;
return
NULL
;
}
catch
(...)
{
PyErr_SetString
(
dgpyError
,
"Unknown exception"
);
return
NULL
;
}
return
NULL
;
}
PyObject
*
display
(
PyObject
*
/*self*/
,
PyObject
*
args
)
{
/* Retrieve the entity instance. */
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment