Cleanup: use variable names based on term gizmo
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
|
||||
|
||||
static bool bpy_gizmotype_target_property_def(
|
||||
wmGizmoType *wt, PyObject *item)
|
||||
wmGizmoType *gzt, PyObject *item)
|
||||
{
|
||||
/* Note: names based on 'rna_rna.c' */
|
||||
PyObject *empty_tuple = PyTuple_New(0);
|
||||
@@ -102,7 +102,7 @@ static bool bpy_gizmotype_target_property_def(
|
||||
goto fail;
|
||||
}
|
||||
|
||||
WM_gizmotype_target_property_def(wt, params.id, params.type, params.array_length);
|
||||
WM_gizmotype_target_property_def(gzt, params.id, params.type, params.array_length);
|
||||
Py_DECREF(empty_tuple);
|
||||
return true;
|
||||
|
||||
@@ -111,17 +111,17 @@ fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
static void gizmo_properties_init(wmGizmoType *wt)
|
||||
static void gizmo_properties_init(wmGizmoType *gzt)
|
||||
{
|
||||
PyTypeObject *py_class = wt->ext.data;
|
||||
RNA_struct_blender_type_set(wt->ext.srna, wt);
|
||||
PyTypeObject *py_class = gzt->ext.data;
|
||||
RNA_struct_blender_type_set(gzt->ext.srna, gzt);
|
||||
|
||||
/* only call this so pyrna_deferred_register_class gives a useful error
|
||||
* WM_operatortype_append_ptr will call RNA_def_struct_identifier
|
||||
* later */
|
||||
RNA_def_struct_identifier_no_struct_map(wt->srna, wt->idname);
|
||||
RNA_def_struct_identifier_no_struct_map(gzt->srna, gzt->idname);
|
||||
|
||||
if (pyrna_deferred_register_class(wt->srna, py_class) != 0) {
|
||||
if (pyrna_deferred_register_class(gzt->srna, py_class) != 0) {
|
||||
PyErr_Print(); /* failed to register operator props */
|
||||
PyErr_Clear();
|
||||
}
|
||||
@@ -149,7 +149,7 @@ static void gizmo_properties_init(wmGizmoType *wt)
|
||||
PyObject **items = PySequence_Fast_ITEMS(bl_target_properties_fast);
|
||||
|
||||
for (uint i = 0; i < items_len; i++) {
|
||||
if (!bpy_gizmotype_target_property_def(wt, items[i])) {
|
||||
if (!bpy_gizmotype_target_property_def(gzt, items[i])) {
|
||||
PyErr_Print();
|
||||
PyErr_Clear();
|
||||
break;
|
||||
@@ -161,25 +161,25 @@ static void gizmo_properties_init(wmGizmoType *wt)
|
||||
}
|
||||
}
|
||||
|
||||
void BPY_RNA_gizmo_wrapper(wmGizmoType *wt, void *userdata)
|
||||
void BPY_RNA_gizmo_wrapper(wmGizmoType *gzt, void *userdata)
|
||||
{
|
||||
/* take care not to overwrite anything set in
|
||||
* WM_gizmomaptype_group_link_ptr before opfunc() is called */
|
||||
StructRNA *srna = wt->srna;
|
||||
*wt = *((wmGizmoType *)userdata);
|
||||
wt->srna = srna; /* restore */
|
||||
StructRNA *srna = gzt->srna;
|
||||
*gzt = *((wmGizmoType *)userdata);
|
||||
gzt->srna = srna; /* restore */
|
||||
|
||||
/* don't do translations here yet */
|
||||
#if 0
|
||||
/* Use i18n context from ext.srna if possible (py gizmogroups). */
|
||||
if (wt->ext.srna) {
|
||||
RNA_def_struct_translation_context(wt->srna, RNA_struct_translation_context(wt->ext.srna));
|
||||
if (gt->ext.srna) {
|
||||
RNA_def_struct_translation_context(gt->srna, RNA_struct_translation_context(gt->ext.srna));
|
||||
}
|
||||
#endif
|
||||
|
||||
wt->struct_size = sizeof(wmGizmo);
|
||||
gzt->struct_size = sizeof(wmGizmo);
|
||||
|
||||
gizmo_properties_init(wt);
|
||||
gizmo_properties_init(gzt);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -190,46 +190,46 @@ void BPY_RNA_gizmo_wrapper(wmGizmoType *wt, void *userdata)
|
||||
/** \name Gizmo Group
|
||||
* \{ */
|
||||
|
||||
static void gizmogroup_properties_init(wmGizmoGroupType *wgt)
|
||||
static void gizmogroup_properties_init(wmGizmoGroupType *gzgt)
|
||||
{
|
||||
#ifdef USE_SRNA
|
||||
PyTypeObject *py_class = wgt->ext.data;
|
||||
PyTypeObject *py_class = gzgt->ext.data;
|
||||
#endif
|
||||
RNA_struct_blender_type_set(wgt->ext.srna, wgt);
|
||||
RNA_struct_blender_type_set(gzgt->ext.srna, gzgt);
|
||||
|
||||
#ifdef USE_SRNA
|
||||
/* only call this so pyrna_deferred_register_class gives a useful error
|
||||
* WM_operatortype_append_ptr will call RNA_def_struct_identifier
|
||||
* later */
|
||||
RNA_def_struct_identifier(wgt->srna, wgt->idname);
|
||||
RNA_def_struct_identifier(gzgt->srna, gzgt->idname);
|
||||
|
||||
if (pyrna_deferred_register_class(wgt->srna, py_class) != 0) {
|
||||
if (pyrna_deferred_register_class(gzgt->srna, py_class) != 0) {
|
||||
PyErr_Print(); /* failed to register operator props */
|
||||
PyErr_Clear();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *wgt, void *userdata)
|
||||
void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *gzgt, void *userdata)
|
||||
{
|
||||
/* take care not to overwrite anything set in
|
||||
* WM_gizmomaptype_group_link_ptr before opfunc() is called */
|
||||
#ifdef USE_SRNA
|
||||
StructRNA *srna = wgt->srna;
|
||||
StructRNA *srna = gzgt->srna;
|
||||
#endif
|
||||
*wgt = *((wmGizmoGroupType *)userdata);
|
||||
*gzgt = *((wmGizmoGroupType *)userdata);
|
||||
#ifdef USE_SRNA
|
||||
wgt->srna = srna; /* restore */
|
||||
gzgt->srna = srna; /* restore */
|
||||
#endif
|
||||
|
||||
#ifdef USE_SRNA
|
||||
/* Use i18n context from ext.srna if possible (py gizmogroups). */
|
||||
if (wgt->ext.srna) {
|
||||
RNA_def_struct_translation_context(wgt->srna, RNA_struct_translation_context(wgt->ext.srna));
|
||||
if (gzgt->ext.srna) {
|
||||
RNA_def_struct_translation_context(gzgt->srna, RNA_struct_translation_context(gzgt->ext.srna));
|
||||
}
|
||||
#endif
|
||||
|
||||
gizmogroup_properties_init(wgt);
|
||||
gizmogroup_properties_init(gzgt);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -29,7 +29,7 @@ struct wmGizmoType;
|
||||
struct wmGizmoGroupType;
|
||||
|
||||
/* exposed to rna/wm api */
|
||||
void BPY_RNA_gizmo_wrapper(struct wmGizmoType *wt, void *userdata);
|
||||
void BPY_RNA_gizmogroup_wrapper(struct wmGizmoGroupType *wgt, void *userdata);
|
||||
void BPY_RNA_gizmo_wrapper(struct wmGizmoType *gzt, void *userdata);
|
||||
void BPY_RNA_gizmogroup_wrapper(struct wmGizmoGroupType *gzgt, void *userdata);
|
||||
|
||||
#endif /* __BPY_GIZMO_WRAP_H__ */
|
||||
|
||||
@@ -67,26 +67,26 @@ struct BPyGizmoHandlerUserData {
|
||||
};
|
||||
|
||||
static void py_rna_gizmo_handler_get_cb(
|
||||
const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop,
|
||||
const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop,
|
||||
void *value_p)
|
||||
{
|
||||
PyGILState_STATE gilstate = PyGILState_Ensure();
|
||||
|
||||
struct BPyGizmoHandlerUserData *data = mpr_prop->custom_func.user_data;
|
||||
struct BPyGizmoHandlerUserData *data = gz_prop->custom_func.user_data;
|
||||
PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_GIZMO_FN_SLOT_GET], NULL);
|
||||
if (ret == NULL) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (mpr_prop->type->data_type == PROP_FLOAT) {
|
||||
if (gz_prop->type->data_type == PROP_FLOAT) {
|
||||
float *value = value_p;
|
||||
if (mpr_prop->type->array_length == 1) {
|
||||
if (gz_prop->type->array_length == 1) {
|
||||
if ((*value = PyFloat_AsDouble(ret)) == -1.0f && PyErr_Occurred()) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (PyC_AsArray(value, ret, mpr_prop->type->array_length, &PyFloat_Type, false,
|
||||
if (PyC_AsArray(value, ret, gz_prop->type->array_length, &PyFloat_Type, false,
|
||||
"Gizmo get callback: ") == -1)
|
||||
{
|
||||
goto fail;
|
||||
@@ -111,23 +111,23 @@ fail:
|
||||
}
|
||||
|
||||
static void py_rna_gizmo_handler_set_cb(
|
||||
const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop,
|
||||
const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop,
|
||||
const void *value_p)
|
||||
{
|
||||
PyGILState_STATE gilstate = PyGILState_Ensure();
|
||||
|
||||
struct BPyGizmoHandlerUserData *data = mpr_prop->custom_func.user_data;
|
||||
struct BPyGizmoHandlerUserData *data = gz_prop->custom_func.user_data;
|
||||
|
||||
PyObject *args = PyTuple_New(1);
|
||||
|
||||
if (mpr_prop->type->data_type == PROP_FLOAT) {
|
||||
if (gz_prop->type->data_type == PROP_FLOAT) {
|
||||
const float *value = value_p;
|
||||
PyObject *py_value;
|
||||
if (mpr_prop->type->array_length == 1) {
|
||||
if (gz_prop->type->array_length == 1) {
|
||||
py_value = PyFloat_FromDouble(*value);
|
||||
}
|
||||
else {
|
||||
py_value = PyC_Tuple_PackArray_F32(value, mpr_prop->type->array_length);
|
||||
py_value = PyC_Tuple_PackArray_F32(value, gz_prop->type->array_length);
|
||||
}
|
||||
if (py_value == NULL) {
|
||||
goto fail;
|
||||
@@ -158,10 +158,10 @@ fail:
|
||||
}
|
||||
|
||||
static void py_rna_gizmo_handler_range_get_cb(
|
||||
const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop,
|
||||
const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop,
|
||||
void *value_p)
|
||||
{
|
||||
struct BPyGizmoHandlerUserData *data = mpr_prop->custom_func.user_data;
|
||||
struct BPyGizmoHandlerUserData *data = gz_prop->custom_func.user_data;
|
||||
|
||||
PyGILState_STATE gilstate = PyGILState_Ensure();
|
||||
|
||||
@@ -184,7 +184,7 @@ static void py_rna_gizmo_handler_range_get_cb(
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (mpr_prop->type->data_type == PROP_FLOAT) {
|
||||
if (gz_prop->type->data_type == PROP_FLOAT) {
|
||||
float range[2];
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (((range[i] = PyFloat_AsDouble(PyTuple_GET_ITEM(ret, i))) == -1.0f && PyErr_Occurred()) == 0) {
|
||||
@@ -215,9 +215,9 @@ fail:
|
||||
}
|
||||
|
||||
static void py_rna_gizmo_handler_free_cb(
|
||||
const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop)
|
||||
const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop)
|
||||
{
|
||||
struct BPyGizmoHandlerUserData *data = mpr_prop->custom_func.user_data;
|
||||
struct BPyGizmoHandlerUserData *data = gz_prop->custom_func.user_data;
|
||||
|
||||
PyGILState_STATE gilstate = PyGILState_Ensure();
|
||||
for (int i = 0; i < BPY_GIZMO_FN_SLOT_LEN; i++) {
|
||||
@@ -271,14 +271,14 @@ static PyObject *bpy_gizmo_target_set_handler(PyObject *UNUSED(self), PyObject *
|
||||
goto fail;
|
||||
}
|
||||
|
||||
wmGizmo *mpr = ((BPy_StructRNA *)params.self)->ptr.data;
|
||||
wmGizmo *gz = ((BPy_StructRNA *)params.self)->ptr.data;
|
||||
|
||||
const wmGizmoPropertyType *mpr_prop_type =
|
||||
WM_gizmotype_target_property_find(mpr->type, params.target);
|
||||
if (mpr_prop_type == NULL) {
|
||||
const wmGizmoPropertyType *gz_prop_type =
|
||||
WM_gizmotype_target_property_find(gz->type, params.target);
|
||||
if (gz_prop_type == NULL) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"Gizmo target property '%s.%s' not found",
|
||||
mpr->type->idname, params.target);
|
||||
gz->type->idname, params.target);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ static PyObject *bpy_gizmo_target_set_handler(PyObject *UNUSED(self), PyObject *
|
||||
}
|
||||
|
||||
WM_gizmo_target_property_def_func_ptr(
|
||||
mpr, mpr_prop_type,
|
||||
gz, gz_prop_type,
|
||||
&(const struct wmGizmoPropertyFnParams) {
|
||||
.value_get_fn = py_rna_gizmo_handler_get_cb,
|
||||
.value_set_fn = py_rna_gizmo_handler_set_cb,
|
||||
@@ -361,28 +361,28 @@ static PyObject *bpy_gizmo_target_get_value(PyObject *UNUSED(self), PyObject *ar
|
||||
goto fail;
|
||||
}
|
||||
|
||||
wmGizmo *mpr = ((BPy_StructRNA *)params.self)->ptr.data;
|
||||
wmGizmo *gz = ((BPy_StructRNA *)params.self)->ptr.data;
|
||||
|
||||
wmGizmoProperty *mpr_prop =
|
||||
WM_gizmo_target_property_find(mpr, params.target);
|
||||
if (mpr_prop == NULL) {
|
||||
wmGizmoProperty *gz_prop =
|
||||
WM_gizmo_target_property_find(gz, params.target);
|
||||
if (gz_prop == NULL) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"Gizmo target property '%s.%s' not found",
|
||||
mpr->type->idname, params.target);
|
||||
gz->type->idname, params.target);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
const int array_len = WM_gizmo_target_property_array_length(mpr, mpr_prop);
|
||||
switch (mpr_prop->type->data_type) {
|
||||
const int array_len = WM_gizmo_target_property_array_length(gz, gz_prop);
|
||||
switch (gz_prop->type->data_type) {
|
||||
case PROP_FLOAT:
|
||||
{
|
||||
if (array_len != 0) {
|
||||
float *value = BLI_array_alloca(value, array_len);
|
||||
WM_gizmo_target_property_value_get_array(mpr, mpr_prop, value);
|
||||
WM_gizmo_target_property_value_get_array(gz, gz_prop, value);
|
||||
return PyC_Tuple_PackArray_F32(value, array_len);
|
||||
}
|
||||
else {
|
||||
float value = WM_gizmo_target_property_value_get(mpr, mpr_prop);
|
||||
float value = WM_gizmo_target_property_value_get(gz, gz_prop);
|
||||
return PyFloat_FromDouble(value);
|
||||
}
|
||||
break;
|
||||
@@ -429,36 +429,36 @@ static PyObject *bpy_gizmo_target_set_value(PyObject *UNUSED(self), PyObject *ar
|
||||
goto fail;
|
||||
}
|
||||
|
||||
wmGizmo *mpr = ((BPy_StructRNA *)params.self)->ptr.data;
|
||||
wmGizmo *gz = ((BPy_StructRNA *)params.self)->ptr.data;
|
||||
|
||||
wmGizmoProperty *mpr_prop =
|
||||
WM_gizmo_target_property_find(mpr, params.target);
|
||||
if (mpr_prop == NULL) {
|
||||
wmGizmoProperty *gz_prop =
|
||||
WM_gizmo_target_property_find(gz, params.target);
|
||||
if (gz_prop == NULL) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"Gizmo target property '%s.%s' not found",
|
||||
mpr->type->idname, params.target);
|
||||
gz->type->idname, params.target);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
const int array_len = WM_gizmo_target_property_array_length(mpr, mpr_prop);
|
||||
switch (mpr_prop->type->data_type) {
|
||||
const int array_len = WM_gizmo_target_property_array_length(gz, gz_prop);
|
||||
switch (gz_prop->type->data_type) {
|
||||
case PROP_FLOAT:
|
||||
{
|
||||
if (array_len != 0) {
|
||||
float *value = BLI_array_alloca(value, array_len);
|
||||
if (PyC_AsArray(value, params.value, mpr_prop->type->array_length, &PyFloat_Type, false,
|
||||
if (PyC_AsArray(value, params.value, gz_prop->type->array_length, &PyFloat_Type, false,
|
||||
"Gizmo target property array") == -1)
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
WM_gizmo_target_property_value_set_array(BPy_GetContext(), mpr, mpr_prop, value);
|
||||
WM_gizmo_target_property_value_set_array(BPy_GetContext(), gz, gz_prop, value);
|
||||
}
|
||||
else {
|
||||
float value;
|
||||
if ((value = PyFloat_AsDouble(params.value)) == -1.0f && PyErr_Occurred()) {
|
||||
goto fail;
|
||||
}
|
||||
WM_gizmo_target_property_value_set(BPy_GetContext(), mpr, mpr_prop, value);
|
||||
WM_gizmo_target_property_value_set(BPy_GetContext(), gz, gz_prop, value);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
@@ -504,22 +504,22 @@ static PyObject *bpy_gizmo_target_get_range(PyObject *UNUSED(self), PyObject *ar
|
||||
goto fail;
|
||||
}
|
||||
|
||||
wmGizmo *mpr = ((BPy_StructRNA *)params.self)->ptr.data;
|
||||
wmGizmo *gz = ((BPy_StructRNA *)params.self)->ptr.data;
|
||||
|
||||
wmGizmoProperty *mpr_prop =
|
||||
WM_gizmo_target_property_find(mpr, params.target);
|
||||
if (mpr_prop == NULL) {
|
||||
wmGizmoProperty *gz_prop =
|
||||
WM_gizmo_target_property_find(gz, params.target);
|
||||
if (gz_prop == NULL) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"Gizmo target property '%s.%s' not found",
|
||||
mpr->type->idname, params.target);
|
||||
gz->type->idname, params.target);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
switch (mpr_prop->type->data_type) {
|
||||
switch (gz_prop->type->data_type) {
|
||||
case PROP_FLOAT:
|
||||
{
|
||||
float range[2];
|
||||
WM_gizmo_target_property_range_get(mpr, mpr_prop, range);
|
||||
WM_gizmo_target_property_range_get(gz, gz_prop, range);
|
||||
return PyC_Tuple_PackArray_F32(range, 2);
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user