[Bf-blender-cvs] [a2b8dad469a] master: PyAPI: support accessing the original value for RNA enum parsing
Campbell Barton
noreply at git.blender.org
Fri Jul 30 08:17:16 CEST 2021
Commit: a2b8dad469a0f7fa16d73cccfdbd37c9d5d5c10d
Author: Campbell Barton
Date: Fri Jul 30 16:03:47 2021 +1000
Branches: master
https://developer.blender.org/rBa2b8dad469a0f7fa16d73cccfdbd37c9d5d5c10d
PyAPI: support accessing the original value for RNA enum parsing
Needed in siturations when the input argument is needed for exception messages.
===================================================================
M source/blender/python/intern/bpy_rna.c
M source/blender/python/intern/bpy_rna.h
===================================================================
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;
};
More information about the Bf-blender-cvs
mailing list