Cleanup: use actual function type instead of void* in declaration

This updates the signature of `RNA_def_property_update_runtime`
which previously just has a `const void *` input. This made it difficult
to know what function signature is expected and also does not result
in compile errors when a wrong function is provided.

There is one case which required a different signature, so now there
is a separat function for that case.
This commit is contained in:
Jacques Lucke
2023-08-09 22:40:39 +02:00
parent 19912457c6
commit 08a8825827
13 changed files with 34 additions and 23 deletions

View File

@@ -416,7 +416,7 @@ void GPENCIL_OT_bake_grease_pencil_animation(wmOperatorType *ot)
prop = RNA_def_int(
ot->srna, "frame_end", 250, 1, 100000, "End Frame", "The end frame of animation", 1, 100000);
RNA_def_property_update_runtime(prop, (void *)gpencil_bake_set_frame_end);
RNA_def_property_update_runtime(prop, gpencil_bake_set_frame_end);
prop = RNA_def_int(ot->srna, "step", 1, 1, 100, "Step", "Step between generated frames", 1, 100);

View File

@@ -1730,8 +1730,7 @@ void GPENCIL_OT_convert(wmOperatorType *ot)
"The end frame of the path control curve (if Realtime is not set)",
1,
100000);
RNA_def_property_update_runtime(prop,
reinterpret_cast<const void *>(gpencil_convert_set_end_frame));
RNA_def_property_update_runtime(prop, gpencil_convert_set_end_frame);
RNA_def_float(ot->srna,
"gap_duration",

View File

@@ -423,7 +423,7 @@ void GPENCIL_OT_bake_mesh_animation(wmOperatorType *ot)
prop = RNA_def_int(
ot->srna, "frame_end", 250, 1, 100000, "End Frame", "The end frame of animation", 1, 100000);
RNA_def_property_update_runtime(prop, (void *)gpencil_bake_set_frame_end);
RNA_def_property_update_runtime(prop, gpencil_bake_set_frame_end);
prop = RNA_def_int(ot->srna, "step", 1, 1, 100, "Step", "Step between generated frames", 1, 100);

View File

@@ -288,9 +288,9 @@ void WM_OT_obj_export(wmOperatorType *ot)
/* Object transform options. */
prop = RNA_def_enum(
ot->srna, "forward_axis", io_transform_axis, IO_AXIS_NEGATIVE_Z, "Forward Axis", "");
RNA_def_property_update_runtime(prop, (void *)io_ui_forward_axis_update);
RNA_def_property_update_runtime(prop, io_ui_forward_axis_update);
prop = RNA_def_enum(ot->srna, "up_axis", io_transform_axis, IO_AXIS_Y, "Up Axis", "");
RNA_def_property_update_runtime(prop, (void *)io_ui_up_axis_update);
RNA_def_property_update_runtime(prop, io_ui_up_axis_update);
RNA_def_float(
ot->srna,
"global_scale",
@@ -521,9 +521,9 @@ void WM_OT_obj_import(wmOperatorType *ot)
1000.0f);
prop = RNA_def_enum(
ot->srna, "forward_axis", io_transform_axis, IO_AXIS_NEGATIVE_Z, "Forward Axis", "");
RNA_def_property_update_runtime(prop, (void *)io_ui_forward_axis_update);
RNA_def_property_update_runtime(prop, io_ui_forward_axis_update);
prop = RNA_def_enum(ot->srna, "up_axis", io_transform_axis, IO_AXIS_Y, "Up Axis", "");
RNA_def_property_update_runtime(prop, (void *)io_ui_up_axis_update);
RNA_def_property_update_runtime(prop, io_ui_up_axis_update);
RNA_def_boolean(ot->srna,
"use_split_objects",
true,

View File

@@ -178,9 +178,9 @@ void WM_OT_ply_export(wmOperatorType *ot)
/* Object transform options. */
prop = RNA_def_enum(ot->srna, "forward_axis", io_transform_axis, IO_AXIS_Y, "Forward Axis", "");
RNA_def_property_update_runtime(prop, (void *)io_ui_forward_axis_update);
RNA_def_property_update_runtime(prop, io_ui_forward_axis_update);
prop = RNA_def_enum(ot->srna, "up_axis", io_transform_axis, IO_AXIS_Z, "Up Axis", "");
RNA_def_property_update_runtime(prop, (void *)io_ui_up_axis_update);
RNA_def_property_update_runtime(prop, io_ui_up_axis_update);
RNA_def_float(
ot->srna,
"global_scale",
@@ -309,9 +309,9 @@ void WM_OT_ply_import(wmOperatorType *ot)
"Scene Unit",
"Apply current scene's unit (as defined by unit scale) to imported data");
prop = RNA_def_enum(ot->srna, "forward_axis", io_transform_axis, IO_AXIS_Y, "Forward Axis", "");
RNA_def_property_update_runtime(prop, (void *)io_ui_forward_axis_update);
RNA_def_property_update_runtime(prop, io_ui_forward_axis_update);
prop = RNA_def_enum(ot->srna, "up_axis", io_transform_axis, IO_AXIS_Z, "Up Axis", "");
RNA_def_property_update_runtime(prop, (void *)io_ui_up_axis_update);
RNA_def_property_update_runtime(prop, io_ui_up_axis_update);
RNA_def_boolean(ot->srna, "merge_verts", false, "Merge Vertices", "Merges vertices by distance");
RNA_def_enum(ot->srna,
"import_colors",

View File

@@ -416,7 +416,7 @@ void ED_object_add_generic_props(wmOperatorType *ot, bool do_editmode)
/* NOTE: this property gets hidden for add-camera operator. */
prop = RNA_def_enum(
ot->srna, "align", align_options, ALIGN_WORLD, "Align", "The alignment of the new object");
RNA_def_property_update_runtime(prop, (void *)view_align_update);
RNA_def_property_update_runtime(prop, view_align_update);
prop = RNA_def_float_vector_xyz(ot->srna,
"location",

View File

@@ -1084,7 +1084,7 @@ static void node_socket_template_properties_update(bNodeType *ntype, bNodeSocket
PropertyRNA *prop = RNA_struct_type_find_property(srna, stemp->identifier);
if (prop) {
RNA_def_property_update_runtime(prop, (const void *)node_property_update_default);
RNA_def_property_update_runtime(prop, node_property_update_default);
}
}

View File

@@ -453,7 +453,14 @@ void RNA_def_property_override_funcs(PropertyRNA *prop,
const char *store,
const char *apply);
void RNA_def_property_update_runtime(PropertyRNA *prop, const void *func);
typedef void (*RNAPropertyUpdateFunc)(struct Main *, struct Scene *, struct PointerRNA *);
typedef void (*RNAPropertyUpdateFuncWithContextAndProperty)(struct bContext *C,
struct PointerRNA *ptr,
struct PropertyRNA *prop);
void RNA_def_property_update_runtime(PropertyRNA *prop, RNAPropertyUpdateFunc func);
void RNA_def_property_update_runtime_with_context_and_property(
PropertyRNA *prop, RNAPropertyUpdateFuncWithContextAndProperty func);
void RNA_def_property_update_notifier(PropertyRNA *prop, int noteflag);
void RNA_def_property_poll_runtime(PropertyRNA *prop, const void *func);

View File

@@ -2920,11 +2920,18 @@ void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
prop->update = (UpdateFunc)func;
}
void RNA_def_property_update_runtime(PropertyRNA *prop, const void *func)
void RNA_def_property_update_runtime(PropertyRNA *prop, RNAPropertyUpdateFunc func)
{
prop->update = (UpdateFunc)func;
}
void RNA_def_property_update_runtime_with_context_and_property(
PropertyRNA *prop, RNAPropertyUpdateFuncWithContextAndProperty func)
{
prop->update = (UpdateFunc)func;
RNA_def_property_flag(prop, PROP_CONTEXT_PROPERTY_UPDATE);
}
void RNA_def_property_update_notifier(PropertyRNA *prop, const int noteflag)
{
prop->noteflag = noteflag;

View File

@@ -137,7 +137,7 @@ static void node_rna(StructRNA *srna)
RNA_def_property_enum_node_storage(prop, mode);
RNA_def_property_enum_items(prop, mode_items);
RNA_def_property_ui_text(prop, "Mode", "How to specify the amount of samples");
RNA_def_property_update_runtime(prop, (void *)rna_Node_socket_update);
RNA_def_property_update_runtime(prop, rna_Node_socket_update);
RNA_def_property_update_notifier(prop, NC_NODE | NA_EDITED);
}

View File

@@ -70,7 +70,7 @@ static void node_rna(StructRNA *srna)
RNA_def_property_enum_node(prop, custom1);
RNA_def_property_enum_items(prop, rna_enum_curve_normal_modes);
RNA_def_property_ui_text(prop, "Mode", "Mode for curve normal evaluation");
RNA_def_property_update_runtime(prop, (void *)rna_Node_update);
RNA_def_property_update_runtime(prop, rna_Node_update);
RNA_def_property_update_notifier(prop, NC_NODE | NA_EDITED);
}

View File

@@ -203,7 +203,7 @@ static void node_rna(StructRNA *srna)
RNA_def_property_enum_items(prop, rna_enum_subdivision_uv_smooth_items);
RNA_def_property_enum_default(prop, SUBSURF_UV_SMOOTH_PRESERVE_BOUNDARIES);
RNA_def_property_ui_text(prop, "UV Smooth", "Controls how smoothing is applied to UVs");
RNA_def_property_update_runtime(prop, (void *)rna_Node_update);
RNA_def_property_update_runtime(prop, rna_Node_update);
RNA_def_property_update_notifier(prop, NC_NODE | NA_EDITED);
prop = RNA_def_property(srna, "boundary_smooth", PROP_ENUM, PROP_NONE);
@@ -211,7 +211,7 @@ static void node_rna(StructRNA *srna)
RNA_def_property_enum_items(prop, rna_enum_subdivision_boundary_smooth_items);
RNA_def_property_enum_default(prop, SUBSURF_BOUNDARY_SMOOTH_ALL);
RNA_def_property_ui_text(prop, "Boundary Smooth", "Controls how open boundaries are smoothed");
RNA_def_property_update_runtime(prop, (void *)rna_Node_update);
RNA_def_property_update_runtime(prop, rna_Node_update);
RNA_def_property_update_notifier(prop, NC_NODE | NA_EDITED);
}

View File

@@ -2267,10 +2267,8 @@ static void bpy_prop_callback_assign_update(PropertyRNA *prop, PyObject *update_
if (update_fn && update_fn != Py_None) {
BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
RNA_def_property_update_runtime(prop, reinterpret_cast<const void *>(bpy_prop_update_fn));
RNA_def_property_update_runtime_with_context_and_property(prop, bpy_prop_update_fn);
ASSIGN_PYOBJECT_INCREF(prop_store->py_data.update_fn, update_fn);
RNA_def_property_flag(prop, PROP_CONTEXT_PROPERTY_UPDATE);
}
}