[Bf-blender-cvs] [11d7619e22d] refactor-idprop-ui-data: Revert "Use pyrna_enum_value_parse_string"
Hans Goudey
noreply at git.blender.org
Thu Aug 5 21:01:50 CEST 2021
Commit: 11d7619e22d73429bd966d87f42f52e6f6d138c9
Author: Hans Goudey
Date: Thu Aug 5 11:23:51 2021 -0500
Branches: refactor-idprop-ui-data
https://developer.blender.org/rB11d7619e22d73429bd966d87f42f52e6f6d138c9
Revert "Use pyrna_enum_value_parse_string"
This reverts commit 1cf574dc39b9f10ba7cd43625c28d86d3cdbe0dc.
===================================================================
M source/blender/python/generic/idprop_py_ui_api.c
===================================================================
diff --git a/source/blender/python/generic/idprop_py_ui_api.c b/source/blender/python/generic/idprop_py_ui_api.c
index 98452457115..4563abd5daa 100644
--- a/source/blender/python/generic/idprop_py_ui_api.c
+++ b/source/blender/python/generic/idprop_py_ui_api.c
@@ -34,8 +34,6 @@
#include "RNA_access.h"
#include "RNA_enum_types.h"
-#include "../intern/bpy_rna.h"
-
#define USE_STRING_COERCE
#ifdef USE_STRING_COERCE
@@ -60,11 +58,16 @@ static bool args_contain_key(PyObject *kwargs, const char *name)
* \return False when parsing fails, in which case caller should return NULL.
*/
static bool idprop_ui_data_update_base(IDProperty *idprop,
- const struct BPy_EnumProperty_Parse *rna_subtype,
+ const char *rna_subtype,
const char *description)
{
- if (rna_subtype->is_set) {
- idprop->ui_data->rna_subtype = rna_subtype->value;
+ if (rna_subtype != NULL) {
+ int result = PROP_NONE;
+ if (!RNA_enum_value_from_id(rna_enum_property_subtype_items, rna_subtype, &result)) {
+ PyErr_SetString(PyExc_KeyError, "RNA subtype not found");
+ return false;
+ }
+ idprop->ui_data->rna_subtype = result;
}
if (description != NULL) {
@@ -79,8 +82,7 @@ static bool idprop_ui_data_update_base(IDProperty *idprop,
*/
static bool idprop_ui_data_update_int(IDProperty *idprop, PyObject *args, PyObject *kwargs)
{
- struct BPy_EnumProperty_Parse rna_subtype = {.items = rna_enum_property_subtype_items,
- .value = PROP_NONE};
+ const char *rna_subtype = NULL;
const char *description = NULL;
int min, max, soft_min, soft_max, step;
PyObject *default_value = NULL;
@@ -88,7 +90,7 @@ static bool idprop_ui_data_update_int(IDProperty *idprop, PyObject *args, PyObje
"min", "max", "soft_min", "soft_max", "step", "default", "subtype", "description", NULL};
if (!PyArg_ParseTupleAndKeywords(args,
kwargs,
- "|$iiiiiOO&z:update",
+ "|$iiiiiOzz:update",
(char **)kwlist,
&min,
&max,
@@ -96,13 +98,12 @@ static bool idprop_ui_data_update_int(IDProperty *idprop, PyObject *args, PyObje
&soft_max,
&step,
&default_value,
- pyrna_enum_value_parse_string,
&rna_subtype,
&description)) {
return false;
}
- if (!idprop_ui_data_update_base(idprop, &rna_subtype, description)) {
+ if (!idprop_ui_data_update_base(idprop, rna_subtype, description)) {
return false;
}
@@ -175,8 +176,7 @@ static bool idprop_ui_data_update_int(IDProperty *idprop, PyObject *args, PyObje
*/
static bool idprop_ui_data_update_float(IDProperty *idprop, PyObject *args, PyObject *kwargs)
{
- struct BPy_EnumProperty_Parse rna_subtype = {.items = rna_enum_property_subtype_items,
- .value = PROP_NONE};
+ const char *rna_subtype = NULL;
const char *description = NULL;
int precision;
double min, max, soft_min, soft_max, step;
@@ -193,7 +193,7 @@ static bool idprop_ui_data_update_float(IDProperty *idprop, PyObject *args, PyOb
NULL};
if (!PyArg_ParseTupleAndKeywords(args,
kwargs,
- "|$dddddiOO&z:update",
+ "|$dddddiOzz:update",
(char **)kwlist,
&min,
&max,
@@ -202,13 +202,12 @@ static bool idprop_ui_data_update_float(IDProperty *idprop, PyObject *args, PyOb
&step,
&precision,
&default_value,
- pyrna_enum_value_parse_string,
&rna_subtype,
&description)) {
return false;
}
- if (!idprop_ui_data_update_base(idprop, &rna_subtype, description)) {
+ if (!idprop_ui_data_update_base(idprop, rna_subtype, description)) {
return false;
}
@@ -284,23 +283,21 @@ static bool idprop_ui_data_update_float(IDProperty *idprop, PyObject *args, PyOb
*/
static bool idprop_ui_data_update_string(IDProperty *idprop, PyObject *args, PyObject *kwargs)
{
- struct BPy_EnumProperty_Parse rna_subtype = {.items = rna_enum_property_subtype_items,
- .value = PROP_NONE};
+ const char *rna_subtype = NULL;
const char *description = NULL;
const char *default_value;
const char *kwlist[] = {"default", "subtype", "description", NULL};
if (!PyArg_ParseTupleAndKeywords(args,
kwargs,
- "|$zO&z:update",
+ "|$zzz:update",
(char **)kwlist,
&default_value,
- pyrna_enum_value_parse_string,
&rna_subtype,
&description)) {
return false;
}
- if (!idprop_ui_data_update_base(idprop, &rna_subtype, description)) {
+ if (!idprop_ui_data_update_base(idprop, rna_subtype, description)) {
return false;
}
@@ -319,21 +316,15 @@ static bool idprop_ui_data_update_string(IDProperty *idprop, PyObject *args, PyO
*/
static bool idprop_ui_data_update_id(IDProperty *idprop, PyObject *args, PyObject *kwargs)
{
- struct BPy_EnumProperty_Parse rna_subtype = {.items = rna_enum_property_subtype_items,
- .value = PROP_NONE};
+ const char *rna_subtype = NULL;
const char *description = NULL;
const char *kwlist[] = {"subtype", "description", NULL};
- if (!PyArg_ParseTupleAndKeywords(args,
- kwargs,
- "|$O&z:update",
- (char **)kwlist,
- pyrna_enum_value_parse_string,
- &rna_subtype,
- &description)) {
+ if (!PyArg_ParseTupleAndKeywords(
+ args, kwargs, "|$zz:update", (char **)kwlist, &rna_subtype, &description)) {
return false;
}
- if (!idprop_ui_data_update_base(idprop, &rna_subtype, description)) {
+ if (!idprop_ui_data_update_base(idprop, rna_subtype, description)) {
return false;
}
More information about the Bf-blender-cvs
mailing list