Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-07-30 09:03:47 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-07-30 09:03:47 +0300
commita2b8dad469a0f7fa16d73cccfdbd37c9d5d5c10d (patch)
treeebb41643bd1df2bb33664b89e42f17526a31c5af /source/blender/python
parentddcb6b1023bf3089cd6d2db3012b68b9ec2b980f (diff)
PyAPI: support accessing the original value for RNA enum parsing
Needed in siturations when the input argument is needed for exception messages.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/intern/bpy_rna.c3
-rw-r--r--source/blender/python/intern/bpy_rna.h7
2 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index e45cd02a5bf..759630b73ac 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -832,6 +832,8 @@ int pyrna_enum_value_parse_string(PyObject *o, void *p)
parse_data->items, identifier, &parse_data->value, "enum identifier") == -1) {
return 0;
}
+
+ parse_data->value_orig = o;
parse_data->is_set = true;
return 1;
}
@@ -851,6 +853,7 @@ int pyrna_enum_bitfield_parse_set(PyObject *o, void *p)
parse_data->items, o, &parse_data->value, "enum identifier set") == -1) {
return 0;
}
+ parse_data->value_orig = o;
parse_data->is_set = true;
return 1;
}
diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h
index 23a6b19c22c..24dbad53eb3 100644
--- a/source/blender/python/intern/bpy_rna.h
+++ b/source/blender/python/intern/bpy_rna.h
@@ -219,6 +219,13 @@ int pyrna_set_to_enum_bitfield(const struct EnumPropertyItem *items,
*/
struct BPy_EnumProperty_Parse {
const EnumPropertyItem *items;
+ /**
+ * Set when the value was successfully parsed.
+ * Useful if the input ever needs to be included in an error message.
+ * (if the value is not supported under certain conditions).
+ */
+ PyObject *value_orig;
+
int value;
bool is_set;
};