Cleanup: BPY prop: Move get/set... py callbacks into own scope.

Moving the python call itself into a dedicated sub-scope allows to
ensure local variables (arguments) do not risk leaking into the
rest of the code after being released.

Also use helper macro `PyTuple_SET_ITEMS`.

Pull Request: https://projects.blender.org/blender/blender/pulls/144798
This commit is contained in:
Bastien Montagne
2025-08-19 17:16:31 +02:00
committed by Bastien Montagne
parent 8b7a0b307b
commit 134d66201a

View File

@@ -39,6 +39,7 @@
#include "../generic/py_capi_rna.hh"
#include "../generic/py_capi_utils.hh"
#include "../generic/python_compat.hh" /* IWYU pragma: keep. */
#include "../generic/python_utildefines.hh"
using blender::Array;
@@ -603,24 +604,22 @@ static void bpy_prop_update_fn(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func;
PyObject *args;
PyObject *self;
PyObject *ret;
BLI_assert(prop_store != nullptr);
py_func = prop_store->py_data.update_fn;
args = PyTuple_New(2);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(2);
PyObject *self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEMS(args, self, reinterpret_cast<PyObject *>(bpy_context_module));
Py_INCREF(bpy_context_module);
PyTuple_SET_ITEM(args, 1, (PyObject *)bpy_context_module);
Py_INCREF(bpy_context_module);
ret = PyObject_CallObject(py_func, args);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
Py_DECREF(args);
}
if (ret == nullptr) {
PyC_Err_PrintWithFunc(py_func);
@@ -653,8 +652,6 @@ static bool bpy_prop_boolean_get_fn(PointerRNA *ptr, PropertyRNA *prop)
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func;
PyObject *args;
PyObject *self;
PyObject *ret;
bool value;
@@ -662,13 +659,15 @@ static bool bpy_prop_boolean_get_fn(PointerRNA *ptr, PropertyRNA *prop)
py_func = prop_store->py_data.get_fn;
args = PyTuple_New(1);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(1);
PyObject *self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEMS(args, self);
ret = PyObject_CallObject(py_func, args);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
Py_DECREF(args);
}
if (ret == nullptr) {
PyC_Err_PrintWithFunc(py_func);
@@ -699,23 +698,21 @@ static void bpy_prop_boolean_set_fn(PointerRNA *ptr, PropertyRNA *prop, bool val
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func;
PyObject *args;
PyObject *self;
PyObject *ret;
BLI_assert(prop_store != nullptr);
py_func = prop_store->py_data.set_fn;
args = PyTuple_New(2);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(2);
PyObject *self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEMS(args, self, PyBool_FromLong(value));
PyTuple_SET_ITEM(args, 1, PyBool_FromLong(value));
ret = PyObject_CallObject(py_func, args);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
Py_DECREF(args);
}
if (ret == nullptr) {
PyC_Err_PrintWithFunc(py_func);
@@ -738,8 +735,6 @@ static void bpy_prop_boolean_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, bo
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func;
PyObject *args;
PyObject *self;
PyObject *ret;
bool is_values_set = false;
@@ -752,13 +747,15 @@ static void bpy_prop_boolean_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, bo
py_func = prop_store->py_data.get_fn;
args = PyTuple_New(1);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(1);
PyObject *self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEMS(args, self);
ret = PyObject_CallObject(py_func, args);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
Py_DECREF(args);
}
if (ret != nullptr) {
if (bpy_prop_array_from_py_with_dims(values,
@@ -792,10 +789,7 @@ static void bpy_prop_boolean_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, co
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func;
PyObject *args;
PyObject *self;
PyObject *ret;
PyObject *py_values;
const int len = RNA_property_array_length(ptr, prop);
BPyPropArrayLength array_len_info{};
@@ -806,22 +800,24 @@ static void bpy_prop_boolean_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, co
py_func = prop_store->py_data.set_fn;
args = PyTuple_New(2);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(2);
PyObject *self = pyrna_struct_as_instance(ptr);
if (array_len_info.dims_len == 0) {
py_values = PyC_Tuple_PackArray_Bool(values, len);
PyObject *py_values;
if (array_len_info.dims_len == 0) {
py_values = PyC_Tuple_PackArray_Bool(values, len);
}
else {
py_values = PyC_Tuple_PackArray_Multi_Bool(
values, array_len_info.dims, array_len_info.dims_len);
}
PyTuple_SET_ITEMS(args, self, py_values);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
}
else {
py_values = PyC_Tuple_PackArray_Multi_Bool(
values, array_len_info.dims, array_len_info.dims_len);
}
PyTuple_SET_ITEM(args, 1, py_values);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
if (ret == nullptr) {
PyC_Err_PrintWithFunc(py_func);
@@ -850,8 +846,6 @@ static int bpy_prop_int_get_fn(PointerRNA *ptr, PropertyRNA *prop)
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func;
PyObject *args;
PyObject *self;
PyObject *ret;
int value;
@@ -860,13 +854,15 @@ static int bpy_prop_int_get_fn(PointerRNA *ptr, PropertyRNA *prop)
py_func = prop_store->py_data.get_fn;
args = PyTuple_New(1);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(1);
PyObject *self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEMS(args, self);
ret = PyObject_CallObject(py_func, args);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
Py_DECREF(args);
}
if (ret == nullptr) {
PyC_Err_PrintWithFunc(py_func);
@@ -894,23 +890,21 @@ static void bpy_prop_int_set_fn(PointerRNA *ptr, PropertyRNA *prop, int value)
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func;
PyObject *args;
PyObject *self;
PyObject *ret;
BLI_assert(prop_store != nullptr);
py_func = prop_store->py_data.set_fn;
args = PyTuple_New(2);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(2);
PyObject *self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEMS(args, self, PyLong_FromLong(value));
PyTuple_SET_ITEM(args, 1, PyLong_FromLong(value));
ret = PyObject_CallObject(py_func, args);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
Py_DECREF(args);
}
if (ret == nullptr) {
PyC_Err_PrintWithFunc(py_func);
@@ -933,8 +927,6 @@ static void bpy_prop_int_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, int *v
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func;
PyObject *args;
PyObject *self;
PyObject *ret;
bool is_values_set = false;
@@ -947,13 +939,15 @@ static void bpy_prop_int_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, int *v
py_func = prop_store->py_data.get_fn;
args = PyTuple_New(1);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(1);
PyObject *self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEMS(args, self);
ret = PyObject_CallObject(py_func, args);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
Py_DECREF(args);
}
if (ret != nullptr) {
if (bpy_prop_array_from_py_with_dims(values,
@@ -987,10 +981,7 @@ static void bpy_prop_int_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, const
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func;
PyObject *args;
PyObject *self;
PyObject *ret;
PyObject *py_values;
const int len = RNA_property_array_length(ptr, prop);
BPyPropArrayLength array_len_info{};
@@ -1001,23 +992,24 @@ static void bpy_prop_int_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, const
py_func = prop_store->py_data.set_fn;
args = PyTuple_New(2);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(2);
PyObject *self = pyrna_struct_as_instance(ptr);
if (array_len_info.dims_len == 0) {
py_values = PyC_Tuple_PackArray_I32(values, len);
PyObject *py_values;
if (array_len_info.dims_len == 0) {
py_values = PyC_Tuple_PackArray_I32(values, len);
}
else {
py_values = PyC_Tuple_PackArray_Multi_I32(
values, array_len_info.dims, array_len_info.dims_len);
}
PyTuple_SET_ITEMS(args, self, py_values);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
}
else {
py_values = PyC_Tuple_PackArray_Multi_I32(
values, array_len_info.dims, array_len_info.dims_len);
}
PyTuple_SET_ITEM(args, 1, py_values);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
if (ret == nullptr) {
PyC_Err_PrintWithFunc(py_func);
@@ -1046,8 +1038,6 @@ static float bpy_prop_float_get_fn(PointerRNA *ptr, PropertyRNA *prop)
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func;
PyObject *args;
PyObject *self;
PyObject *ret;
float value;
@@ -1056,13 +1046,15 @@ static float bpy_prop_float_get_fn(PointerRNA *ptr, PropertyRNA *prop)
py_func = prop_store->py_data.get_fn;
args = PyTuple_New(1);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(1);
PyObject *self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEMS(args, self);
ret = PyObject_CallObject(py_func, args);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
Py_DECREF(args);
}
if (ret == nullptr) {
PyC_Err_PrintWithFunc(py_func);
@@ -1090,23 +1082,21 @@ static void bpy_prop_float_set_fn(PointerRNA *ptr, PropertyRNA *prop, float valu
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func;
PyObject *args;
PyObject *self;
PyObject *ret;
BLI_assert(prop_store != nullptr);
py_func = prop_store->py_data.set_fn;
args = PyTuple_New(2);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(2);
PyObject *self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEMS(args, self, PyFloat_FromDouble(value));
PyTuple_SET_ITEM(args, 1, PyFloat_FromDouble(value));
ret = PyObject_CallObject(py_func, args);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
Py_DECREF(args);
}
if (ret == nullptr) {
PyC_Err_PrintWithFunc(py_func);
@@ -1129,8 +1119,6 @@ static void bpy_prop_float_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, floa
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func;
PyObject *args;
PyObject *self;
PyObject *ret;
bool is_values_set = false;
@@ -1143,13 +1131,15 @@ static void bpy_prop_float_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, floa
py_func = prop_store->py_data.get_fn;
args = PyTuple_New(1);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(1);
PyObject *self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEMS(args, self);
ret = PyObject_CallObject(py_func, args);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
Py_DECREF(args);
}
if (ret != nullptr) {
if (bpy_prop_array_from_py_with_dims(values,
@@ -1187,10 +1177,7 @@ static void bpy_prop_float_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, cons
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func;
PyObject *args;
PyObject *self;
PyObject *ret;
PyObject *py_values;
const int len = RNA_property_array_length(ptr, prop);
BPyPropArrayLength array_len_info{};
@@ -1201,23 +1188,25 @@ static void bpy_prop_float_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, cons
py_func = prop_store->py_data.set_fn;
args = PyTuple_New(2);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(2);
PyObject *self = pyrna_struct_as_instance(ptr);
if (array_len_info.dims_len == 0) {
py_values = PyC_Tuple_PackArray_F32(values, len);
PyObject *py_values;
if (array_len_info.dims_len == 0) {
py_values = PyC_Tuple_PackArray_F32(values, len);
}
else {
/* No need for matrix column/row swapping here unless the matrix data is read directly. */
py_values = PyC_Tuple_PackArray_Multi_F32(
values, array_len_info.dims, array_len_info.dims_len);
}
PyTuple_SET_ITEMS(args, self, py_values);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
}
else {
/* No need for matrix column/row swapping here unless the matrix data is read directly. */
py_values = PyC_Tuple_PackArray_Multi_F32(
values, array_len_info.dims, array_len_info.dims_len);
}
PyTuple_SET_ITEM(args, 1, py_values);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
if (ret == nullptr) {
PyC_Err_PrintWithFunc(py_func);
@@ -1246,21 +1235,21 @@ static void bpy_prop_string_get_fn(PointerRNA *ptr, PropertyRNA *prop, char *val
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func;
PyObject *args;
PyObject *self;
PyObject *ret;
BLI_assert(prop_store != nullptr);
py_func = prop_store->py_data.get_fn;
args = PyTuple_New(1);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(1);
PyObject *self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEMS(args, self);
ret = PyObject_CallObject(py_func, args);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
Py_DECREF(args);
}
if (ret == nullptr) {
PyC_Err_PrintWithFunc(py_func);
@@ -1289,8 +1278,6 @@ static int bpy_prop_string_length_fn(PointerRNA *ptr, PropertyRNA *prop)
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func;
PyObject *args;
PyObject *self;
PyObject *ret;
int length;
@@ -1299,13 +1286,15 @@ static int bpy_prop_string_length_fn(PointerRNA *ptr, PropertyRNA *prop)
py_func = prop_store->py_data.get_fn;
args = PyTuple_New(1);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(1);
PyObject *self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEMS(args, self);
ret = PyObject_CallObject(py_func, args);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
Py_DECREF(args);
}
if (ret == nullptr) {
PyC_Err_PrintWithFunc(py_func);
@@ -1336,32 +1325,31 @@ static void bpy_prop_string_set_fn(PointerRNA *ptr, PropertyRNA *prop, const cha
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func;
PyObject *args;
PyObject *self;
PyObject *ret;
PyObject *py_value;
BLI_assert(prop_store != nullptr);
py_func = prop_store->py_data.set_fn;
args = PyTuple_New(2);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(2);
PyObject *self = pyrna_struct_as_instance(ptr);
py_value = PyUnicode_FromString(value);
if (!py_value) {
PyErr_SetString(PyExc_ValueError, "the return value must be a string");
PyC_Err_PrintWithFunc(py_func);
PyObject *py_value = PyUnicode_FromString(value);
if (!py_value) {
PyErr_SetString(PyExc_ValueError, "the set value must be a valid string");
PyC_Err_PrintWithFunc(py_func);
}
else {
py_value = Py_None;
Py_INCREF(py_value);
}
PyTuple_SET_ITEMS(args, self, py_value);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
}
else {
PyTuple_SET_ITEM(args, 1, py_value);
}
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
if (ret == nullptr) {
PyC_Err_PrintWithFunc(py_func);
@@ -1442,28 +1430,24 @@ static void bpy_prop_string_visit_for_search_fn(
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func;
PyObject *args;
PyObject *self;
PyObject *ret;
PyObject *py_edit_text;
BLI_assert(prop_store != nullptr);
py_func = prop_store->py_data.string_data.search_fn;
args = PyTuple_New(3);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(3);
PyObject *self = pyrna_struct_as_instance(ptr);
PyObject *py_context = reinterpret_cast<PyObject *>(bpy_context_module);
PyObject *py_edit_text = PyUnicode_FromString(edit_text);
Py_INCREF(py_context);
PyTuple_SET_ITEMS(args, self, py_context, py_edit_text);
Py_INCREF(bpy_context_module);
PyTuple_SET_ITEM(args, 1, (PyObject *)bpy_context_module);
ret = PyObject_CallObject(py_func, args);
py_edit_text = PyUnicode_FromString(edit_text);
PyTuple_SET_ITEM(args, 2, py_edit_text);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
Py_DECREF(args);
}
if (ret == nullptr) {
PyC_Err_PrintWithFunc(py_func);
@@ -1545,26 +1529,22 @@ static bool bpy_prop_pointer_poll_fn(PointerRNA *self, PointerRNA candidate, Pro
const BPyPropGIL_RNAWritable_State bpy_state = bpy_prop_gil_rna_writable_begin();
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_self;
PyObject *py_candidate;
PyObject *py_func;
PyObject *args;
PyObject *ret;
bool result;
BLI_assert(self != nullptr);
py_self = pyrna_struct_as_instance(self);
py_candidate = pyrna_struct_as_instance(&candidate);
py_func = prop_store->py_data.pointer_data.poll_fn;
{
PyObject *args = PyTuple_New(2);
PyObject *py_self = pyrna_struct_as_instance(self);
PyObject *py_candidate = pyrna_struct_as_instance(&candidate);
PyTuple_SET_ITEMS(args, py_self, py_candidate);
args = PyTuple_New(2);
PyTuple_SET_ITEM(args, 0, py_self);
PyTuple_SET_ITEM(args, 1, py_candidate);
ret = PyObject_CallObject(py_func, args);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
Py_DECREF(args);
}
if (ret == nullptr) {
PyC_Err_PrintWithFunc(py_func);
@@ -1592,8 +1572,6 @@ static int bpy_prop_enum_get_fn(PointerRNA *ptr, PropertyRNA *prop)
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func;
PyObject *args;
PyObject *self;
PyObject *ret;
int value;
@@ -1602,13 +1580,15 @@ static int bpy_prop_enum_get_fn(PointerRNA *ptr, PropertyRNA *prop)
py_func = prop_store->py_data.get_fn;
args = PyTuple_New(1);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(1);
PyObject *self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEMS(args, self);
ret = PyObject_CallObject(py_func, args);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
Py_DECREF(args);
}
if (ret == nullptr) {
PyC_Err_PrintWithFunc(py_func);
@@ -1636,23 +1616,21 @@ static void bpy_prop_enum_set_fn(PointerRNA *ptr, PropertyRNA *prop, int value)
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func;
PyObject *args;
PyObject *self;
PyObject *ret;
BLI_assert(prop_store != nullptr);
py_func = prop_store->py_data.set_fn;
args = PyTuple_New(2);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(2);
PyObject *self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEMS(args, self, PyLong_FromLong(value));
PyTuple_SET_ITEM(args, 1, PyLong_FromLong(value));
ret = PyObject_CallObject(py_func, args);
ret = PyObject_CallObject(py_func, args);
Py_DECREF(args);
Py_DECREF(args);
}
if (ret == nullptr) {
PyC_Err_PrintWithFunc(py_func);
@@ -1904,30 +1882,22 @@ static const EnumPropertyItem *bpy_prop_enum_itemf_fn(bContext *C,
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
PyObject *py_func = prop_store->py_data.enum_data.itemf_fn;
PyObject *self = nullptr;
PyObject *args;
PyObject *items; /* returned from the function call */
const EnumPropertyItem *eitems = nullptr;
int err = 0;
args = PyTuple_New(2);
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
{
PyObject *args = PyTuple_New(2);
PyObject *self = pyrna_struct_as_instance(ptr);
PyObject *py_context = C ? reinterpret_cast<PyObject *>(bpy_context_module) : Py_None;
Py_INCREF(py_context);
PyTuple_SET_ITEMS(args, self, py_context);
/* now get the context */
if (C) {
PyTuple_SET_ITEM(args, 1, (PyObject *)bpy_context_module);
Py_INCREF(bpy_context_module);
items = PyObject_CallObject(py_func, args);
Py_DECREF(args);
}
else {
PyTuple_SET_ITEM(args, 1, Py_None);
Py_INCREF(Py_None);
}
items = PyObject_CallObject(py_func, args);
Py_DECREF(args);
if (items == nullptr) {
err = -1;