diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-11-04 10:06:34 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-11-04 10:06:34 +0300 |
commit | d3bcbe10c20e8b418659d8fdca98fd6b4bfecdfe (patch) | |
tree | 82f75ce25312385146ece0970844da2ebc711d77 /source | |
parent | d3b85af6ca4b0d1cbddec99b5c53b6aa081af230 (diff) |
PyAPI: add Struct.is_property_set(..., ghost) option
This exposes the use_ghost argument to RNA_property_is_set_ex.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index d6ab76dac60..cd0ec44e2ad 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -3604,20 +3604,30 @@ static PyObject *pyrna_struct_values(BPy_PropertyRNA *self) } PyDoc_STRVAR(pyrna_struct_is_property_set_doc, - ".. method:: is_property_set(property)\n" + ".. method:: is_property_set(property, ghost=True)\n" "\n" " Check if a property is set, use for testing operator properties.\n" "\n" + " :arg ghost: Used for operators that re-run with previous settings.\n" + " In this case the property is not marked as set,\n" + " yet the value from the previous execution is used.\n" + "\n" + " In rare cases you may want to set this option to false.\n" + "\n" + " :type ghost: boolean\n" " :return: True when the property has been set.\n" " :rtype: boolean\n"); -static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *args) +static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *args, PyObject *kw) { PropertyRNA *prop; const char *name; + bool use_ghost = false; PYRNA_STRUCT_CHECK_OBJ(self); - if (!PyArg_ParseTuple(args, "s:is_property_set", &name)) { + static const char *_keywords[] = {"", "ghost", NULL}; + static _PyArg_Parser _parser = {"s|$O&:is_property_set", _keywords, 0}; + if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &name, PyC_ParseBool, &use_ghost)) { return NULL; } @@ -3629,7 +3639,7 @@ static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *arg return NULL; } - return PyBool_FromLong(RNA_property_is_set(&self->ptr, prop)); + return PyBool_FromLong(RNA_property_is_set_ex(&self->ptr, prop, use_ghost)); } PyDoc_STRVAR(pyrna_struct_property_unset_doc, @@ -5654,7 +5664,7 @@ static struct PyMethodDef pyrna_struct_methods[] = { {"is_property_set", (PyCFunction)pyrna_struct_is_property_set, - METH_VARARGS, + METH_VARARGS | METH_KEYWORDS, pyrna_struct_is_property_set_doc}, {"property_unset", (PyCFunction)pyrna_struct_property_unset, |