Cleanup: follow operator callback & argument naming

This commit is contained in:
Campbell Barton 2024-05-24 14:08:33 +10:00
parent 1831e2579a
commit 61e4d1818e
16 changed files with 63 additions and 61 deletions

@ -424,9 +424,9 @@ static int pose_clear_paths_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static std::string pose_clear_paths_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *ptr)
static std::string pose_clear_paths_get_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *ptr)
{
const bool only_selected = RNA_boolean_get(ptr, "only_selected");
if (only_selected) {
@ -444,7 +444,7 @@ void POSE_OT_paths_clear(wmOperatorType *ot)
/* api callbacks */
ot->exec = pose_clear_paths_exec;
ot->poll = ED_operator_posemode_exclusive;
ot->get_description = pose_clear_paths_description;
ot->get_description = pose_clear_paths_get_description;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;

@ -361,9 +361,9 @@ static bool asset_clear_poll(bContext *C, const Span<PointerRNA> ids)
static std::string asset_clear_get_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *values)
PointerRNA *ptr)
{
const bool set_fake_user = RNA_boolean_get(values, "set_fake_user");
const bool set_fake_user = RNA_boolean_get(ptr, "set_fake_user");
if (!set_fake_user) {
return "";
}

@ -1405,18 +1405,16 @@ static int edbm_select_mode_invoke(bContext *C, wmOperator *op, const wmEvent *e
static std::string edbm_select_mode_get_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *values)
PointerRNA *ptr)
{
const int type = RNA_enum_get(values, "type");
const int type = RNA_enum_get(ptr, "type");
/* Because the special behavior for shift and ctrl click depend on user input, they may be
* incorrect if the operator is used from a script or from a special button. So only return the
* specialized descriptions if only the "type" is set, which conveys that the operator is meant
* to be used with the logic in the `invoke` method. */
if (RNA_struct_property_is_set(values, "type") &&
!RNA_struct_property_is_set(values, "use_extend") &&
!RNA_struct_property_is_set(values, "use_expand") &&
!RNA_struct_property_is_set(values, "action"))
if (RNA_struct_property_is_set(ptr, "type") && !RNA_struct_property_is_set(ptr, "use_extend") &&
!RNA_struct_property_is_set(ptr, "use_expand") && !RNA_struct_property_is_set(ptr, "action"))
{
switch (type) {
case SCE_SELECT_VERTEX:

@ -1520,9 +1520,9 @@ static int object_clear_paths_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static std::string object_clear_paths_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *ptr)
static std::string object_clear_paths_get_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *ptr)
{
const bool only_selected = RNA_boolean_get(ptr, "only_selected");
if (only_selected) {
@ -1540,7 +1540,7 @@ void OBJECT_OT_paths_clear(wmOperatorType *ot)
/* api callbacks */
ot->exec = object_clear_paths_exec;
ot->poll = ED_operator_object_active_editable;
ot->get_description = object_clear_paths_description;
ot->get_description = object_clear_paths_get_description;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;

@ -2039,9 +2039,9 @@ static int modifier_apply_as_shapekey_invoke(bContext *C, wmOperator *op, const
static std::string modifier_apply_as_shapekey_get_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *values)
PointerRNA *ptr)
{
bool keep = RNA_boolean_get(values, "keep_modifier");
bool keep = RNA_boolean_get(ptr, "keep_modifier");
if (keep) {
return TIP_("Apply modifier as a new shapekey and keep it in the stack");
}

@ -704,11 +704,11 @@ static int shape_key_lock_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static std::string shape_key_lock_description(bContext * /*C*/,
wmOperatorType * /*op*/,
PointerRNA *params)
static std::string shape_key_lock_get_description(bContext * /*C*/,
wmOperatorType * /*op*/,
PointerRNA *ptr)
{
const int action = RNA_enum_get(params, "action");
const int action = RNA_enum_get(ptr, "action");
switch (action) {
case SHAPE_KEY_LOCK:
@ -738,7 +738,7 @@ void OBJECT_OT_shape_key_lock(wmOperatorType *ot)
/* api callbacks */
ot->poll = shape_key_exists_poll;
ot->exec = shape_key_lock_exec;
ot->get_description = shape_key_lock_description;
ot->get_description = shape_key_lock_get_description;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;

@ -2984,12 +2984,12 @@ static int vertex_group_lock_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static std::string vertex_group_lock_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *params)
static std::string vertex_group_lock_get_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *ptr)
{
int action = RNA_enum_get(params, "action");
int mask = RNA_enum_get(params, "mask");
int action = RNA_enum_get(ptr, "action");
int mask = RNA_enum_get(ptr, "mask");
/* NOTE: constructing the following string literals can be done in a less verbose way,
* however the resulting strings can't be usefully translated, (via `TIP_`). */
@ -3058,7 +3058,7 @@ void OBJECT_OT_vertex_group_lock(wmOperatorType *ot)
/* api callbacks */
ot->poll = vertex_group_poll;
ot->exec = vertex_group_lock_exec;
ot->get_description = vertex_group_lock_description;
ot->get_description = vertex_group_lock_get_description;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;

@ -1317,9 +1317,9 @@ static int screen_opengl_render_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static std::string screen_opengl_render_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *ptr)
static std::string screen_opengl_render_get_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *ptr)
{
if (!RNA_boolean_get(ptr, "animation")) {
return "";
@ -1344,7 +1344,7 @@ void RENDER_OT_opengl(wmOperatorType *ot)
ot->idname = "RENDER_OT_opengl";
/* api callbacks */
ot->get_description = screen_opengl_render_description;
ot->get_description = screen_opengl_render_get_description;
ot->invoke = screen_opengl_render_invoke;
ot->exec = screen_opengl_render_exec; /* blocking */
ot->modal = screen_opengl_render_modal;

@ -709,9 +709,9 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static std::string actkeys_paste_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *ptr)
static std::string actkeys_paste_get_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *ptr)
{
/* Custom description if the 'flipped' option is used. */
if (RNA_boolean_get(ptr, "flipped")) {
@ -735,7 +735,7 @@ void ACTION_OT_paste(wmOperatorType *ot)
/* api callbacks */
// ot->invoke = WM_operator_props_popup; /* Better wait for action redo panel. */
ot->get_description = actkeys_paste_description;
ot->get_description = actkeys_paste_get_description;
ot->exec = actkeys_paste_exec;
ot->poll = ED_operator_action_active;

@ -380,7 +380,9 @@ static int track_markers_modal(bContext *C, wmOperator * /*op*/, const wmEvent *
return OPERATOR_PASS_THROUGH;
}
static std::string track_markers_desc(bContext * /*C*/, wmOperatorType * /*ot*/, PointerRNA *ptr)
static std::string track_markers_get_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *ptr)
{
const bool backwards = RNA_boolean_get(ptr, "backwards");
const bool sequence = RNA_boolean_get(ptr, "sequence");
@ -414,7 +416,7 @@ void CLIP_OT_track_markers(wmOperatorType *ot)
ot->invoke = track_markers_invoke;
ot->modal = track_markers_modal;
ot->poll = ED_space_clip_tracking_poll;
ot->get_description = track_markers_desc;
ot->get_description = track_markers_get_description;
/* flags */
ot->flag = OPTYPE_UNDO;

@ -1848,9 +1848,9 @@ static int file_external_operation_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
static std::string file_external_operation_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *ptr)
static std::string file_external_operation_get_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *ptr)
{
const char *description = "";
RNA_enum_description(file_external_operation, RNA_enum_get(ptr, "operation"), &description);
@ -1868,7 +1868,7 @@ void FILE_OT_external_operation(wmOperatorType *ot)
/* api callbacks */
ot->exec = file_external_operation_exec;
ot->get_description = file_external_operation_description;
ot->get_description = file_external_operation_get_description;
/* flags */
ot->flag = OPTYPE_REGISTER; /* No undo! */

@ -605,9 +605,9 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static std::string graphkeys_paste_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *ptr)
static std::string graphkeys_paste_get_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *ptr)
{
/* Custom description if the 'flipped' option is used. */
if (RNA_boolean_get(ptr, "flipped")) {
@ -633,7 +633,7 @@ void GRAPH_OT_paste(wmOperatorType *ot)
/* API callbacks */
// ot->invoke = WM_operator_props_popup; /* better wait for graph redo panel */
ot->get_description = graphkeys_paste_description;
ot->get_description = graphkeys_paste_get_description;
ot->exec = graphkeys_paste_exec;
ot->poll = graphop_editable_keyframes_poll;

@ -565,7 +565,9 @@ static bool decimate_poll_property(const bContext * /*C*/, wmOperator *op, const
return true;
}
static std::string decimate_desc(bContext * /*C*/, wmOperatorType * /*ot*/, PointerRNA *ptr)
static std::string decimate_get_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *ptr)
{
if (RNA_enum_get(ptr, "mode") == DECIM_ERROR) {
@ -602,7 +604,7 @@ void GRAPH_OT_decimate(wmOperatorType *ot)
/* API callbacks */
ot->poll_property = decimate_poll_property;
ot->get_description = decimate_desc;
ot->get_description = decimate_get_description;
ot->invoke = decimate_invoke;
ot->modal = graph_slider_modal;
ot->exec = decimate_exec;

@ -473,10 +473,10 @@ static int node_add_group_asset_invoke(bContext *C, wmOperator *op, const wmEven
static std::string node_add_group_asset_get_description(bContext *C,
wmOperatorType * /*ot*/,
PointerRNA *values)
PointerRNA *ptr)
{
const asset_system::AssetRepresentation *asset =
asset::operator_asset_reference_props_get_asset_from_all_library(*C, *values, nullptr);
asset::operator_asset_reference_props_get_asset_from_all_library(*C, *ptr, nullptr);
if (!asset) {
return "";
}

@ -1489,9 +1489,9 @@ static int sequencer_add_effect_strip_invoke(bContext *C,
return sequencer_add_effect_strip_exec(C, op);
}
static std::string sequencer_add_effect_strip_desc(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *ptr)
static std::string sequencer_add_effect_strip_get_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *ptr)
{
const int type = RNA_enum_get(ptr, "type");
@ -1554,7 +1554,7 @@ void SEQUENCER_OT_effect_strip_add(wmOperatorType *ot)
ot->exec = sequencer_add_effect_strip_exec;
ot->poll = ED_operator_sequencer_active_editable;
ot->poll_property = seq_effect_add_properties_poll;
ot->get_description = sequencer_add_effect_strip_desc;
ot->get_description = sequencer_add_effect_strip_get_description;
/* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;

@ -3040,16 +3040,16 @@ static int wm_open_mainfile_exec(bContext *C, wmOperator *op)
return wm_open_mainfile__open(C, op);
}
static std::string wm_open_mainfile_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *params)
static std::string wm_open_mainfile_get_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *ptr)
{
if (!RNA_struct_property_is_set(params, "filepath")) {
if (!RNA_struct_property_is_set(ptr, "filepath")) {
return "";
}
char filepath[FILE_MAX];
RNA_string_get(params, "filepath", filepath);
RNA_string_get(ptr, "filepath", filepath);
BLI_stat_t stats;
if (BLI_stat(filepath, &stats) == -1) {
@ -3151,7 +3151,7 @@ void WM_OT_open_mainfile(wmOperatorType *ot)
ot->name = "Open";
ot->idname = "WM_OT_open_mainfile";
ot->description = "Open a Blender file";
ot->get_description = wm_open_mainfile_description;
ot->get_description = wm_open_mainfile_get_description;
ot->invoke = wm_open_mainfile_invoke;
ot->exec = wm_open_mainfile_exec;