diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-02-12 06:39:56 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-02-12 06:39:56 +0300 |
commit | b96180ec1763b29bdda4acd6cf79275058bcbde3 (patch) | |
tree | 74782072278e53659f1b1c3e66eaaed6d11e9ced /source/blender/python | |
parent | 12811a096c8ec23477bdc29a02d5d9492d13e94d (diff) |
* Added description string to operator types, should be set along with ot->idname when defining ops.
* User interface uses this as a tooltip when NULL or "" is given.
* Python doc generation includes this description
* Python defined ops take the description as an argument.
* NULL check to image_ops.c, was crashing on exit when there was an image open.
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/epy_doc_gen.py | 1 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_opwrapper.c | 10 |
2 files changed, 8 insertions, 3 deletions
diff --git a/source/blender/python/epy_doc_gen.py b/source/blender/python/epy_doc_gen.py index afe5468070b..afe9acff36d 100644 --- a/source/blender/python/epy_doc_gen.py +++ b/source/blender/python/epy_doc_gen.py @@ -265,6 +265,7 @@ def op2epy(target_path): out.write('def %s(%s):\n' % (op, ', '.join(kw_args))) out.write('\t"""\n') + out.write('\t%s\n' % rna_struct.description) for desc in kw_arg_attrs: out.write('\t%s\n' % desc) out.write('\t@rtype: None\n') diff --git a/source/blender/python/intern/bpy_opwrapper.c b/source/blender/python/intern/bpy_opwrapper.c index 8a644f51b24..ca6104d087f 100644 --- a/source/blender/python/intern/bpy_opwrapper.c +++ b/source/blender/python/intern/bpy_opwrapper.c @@ -44,6 +44,7 @@ typedef struct PyOperatorType { void *next, *prev; char idname[OP_MAX_TYPENAME]; char name[OP_MAX_TYPENAME]; + char description[OP_MAX_TYPENAME]; // XXX should be longer? PyObject *py_invoke; PyObject *py_exec; } PyOperatorType; @@ -276,6 +277,7 @@ void PYTHON_OT_wrapper(wmOperatorType *ot, void *userdata) /* identifiers */ ot->name= pyot->name; ot->idname= pyot->idname; + ot->description= pyot->description; /* api callbacks */ if (pyot->py_invoke != Py_None) @@ -342,10 +344,11 @@ PyObject *PYOP_wrap_add(PyObject *self, PyObject *args) char *idname= NULL; char *name= NULL; + char *description= NULL; PyObject *invoke= NULL; PyObject *exec= NULL; - if (!PyArg_ParseTuple(args, "ssOO", &idname, &name, &invoke, &exec)) { + if (!PyArg_ParseTuple(args, "sssOO", &idname, &name, &description, &invoke, &exec)) { PyErr_SetString( PyExc_AttributeError, "expected 2 strings and 2 function objects"); return NULL; } @@ -362,8 +365,9 @@ PyObject *PYOP_wrap_add(PyObject *self, PyObject *args) pyot= MEM_callocN(sizeof(PyOperatorType), "PyOperatorType"); - strcpy(pyot->idname, idname); - strcpy(pyot->name, name); + strncpy(pyot->idname, idname, sizeof(pyot->idname)); + strncpy(pyot->name, name, sizeof(pyot->name)); + strncpy(pyot->description, description, sizeof(pyot->description)); pyot->py_invoke= invoke; pyot->py_exec= exec; Py_INCREF(invoke); |