Skip to content

Commit

Permalink
refactor: rename multiple variables
Browse files Browse the repository at this point in the history
  • Loading branch information
dongwlin committed Nov 15, 2023
1 parent 3458c37 commit 9af526a
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
14 changes: 7 additions & 7 deletions source/cli/CustomAction/CustomAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ CustomAction::CustomAction(const std::string& action_name,
MaaBool (*action_run)(MaaSyncContextHandle sync_context, MaaStringView task_name,
MaaStringView custom_action_param, MaaRectHandle cur_box,
MaaStringView cur_rec_detail, MaaTransparentArg arg))
: name_(action_name)
: _name(action_name)
{
custom_action_.run = action_run;
_custom_action.run = action_run;
}

CustomAction::CustomAction(const std::string& action_name,
MaaBool (*action_run)(MaaSyncContextHandle sync_context, MaaStringView task_name,
MaaStringView custom_action_param, MaaRectHandle cur_box,
MaaStringView cur_rec_detail, MaaTransparentArg arg),
void (*action_stop)(MaaTransparentArg arg))
: name_(action_name)
: _name(action_name)
{
custom_action_.run = action_run;
custom_action_.stop = action_stop;
_custom_action.run = action_run;
_custom_action.stop = action_stop;
}

std::string CustomAction::get_name() const
{
return name_;
return _name;
}

MaaCustomActionAPI CustomAction::get_custom_action() const
{
return custom_action_;
return _custom_action;
}
4 changes: 2 additions & 2 deletions source/cli/CustomAction/CustomAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ class CustomAction
MaaCustomActionAPI get_custom_action() const;

private:
std::string name_;
MaaCustomActionAPI custom_action_;
std::string _name;
MaaCustomActionAPI _custom_action;
};
8 changes: 4 additions & 4 deletions source/cli/CustomAction/CustomActionRegistrar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ void CustomActionRegistrar::add_action(const std::string& name,
MaaStringView custom_action_param, MaaRectHandle cur_box,
MaaStringView cur_rec_detail, MaaTransparentArg arg))
{
actions_.emplace_back(name, action_run);
_actions.emplace_back(name, action_run);
}

void CustomActionRegistrar::add_action(const std::string& name,
Expand All @@ -14,15 +14,15 @@ void CustomActionRegistrar::add_action(const std::string& name,
MaaStringView cur_rec_detail, MaaTransparentArg arg),
void (*action_stop)(MaaTransparentArg arg))
{
actions_.emplace_back(name, action_run, action_stop);
_actions.emplace_back(name, action_run, action_stop);
}

void CustomActionRegistrar::register_actions(MaaInstanceHandle maa_handle)
{
for (const auto& action : actions_) {
for (const auto& action : _actions) {
std::shared_ptr<MaaCustomActionAPI> custom_action =
std::make_shared<MaaCustomActionAPI>(action.get_custom_action());
custom_actions_.push_back(custom_action);
_custom_actions.push_back(custom_action);
MaaRegisterCustomAction(maa_handle, action.get_name().c_str(), custom_action.get(), nullptr);
}
}
4 changes: 2 additions & 2 deletions source/cli/CustomAction/CustomActionRegistrar.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ class CustomActionRegistrar
void register_actions(MaaInstanceHandle maa_handle);

private:
std::vector<CustomAction> actions_;
std::vector<std::shared_ptr<MaaCustomActionAPI>> custom_actions_;
std::vector<CustomAction> _actions;
std::vector<std::shared_ptr<MaaCustomActionAPI>> _custom_actions;
};
8 changes: 4 additions & 4 deletions source/cli/CustomRecognizer/CustomRecognizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ CustomRecognizer::CustomRecognizer(
MaaStringView task_name, MaaStringView custom_recognition_param,
MaaTransparentArg recognizer_arg, MaaRectHandle out_box,
MaaStringBufferHandle detail_buff))
: name_(recognizer_name)
: _name(recognizer_name)
{
custom_recognizer_.analyze = recognizer_analyze;
_custom_recognizer.analyze = recognizer_analyze;
}

std::string CustomRecognizer::get_name() const
{
return name_;
return _name;
}

MaaCustomRecognizerAPI CustomRecognizer::get_custom_recognizer() const
{
return custom_recognizer_;
return _custom_recognizer;
}
4 changes: 2 additions & 2 deletions source/cli/CustomRecognizer/CustomRecognizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ class CustomRecognizer
MaaCustomRecognizerAPI get_custom_recognizer() const;

private:
std::string name_;
MaaCustomRecognizerAPI custom_recognizer_;
std::string _name;
MaaCustomRecognizerAPI _custom_recognizer;
};
6 changes: 3 additions & 3 deletions source/cli/CustomRecognizer/CustomRecognizerRegistrar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ void CustomRecognizerRegistrar::add_recognizer(
MaaTransparentArg recognizer_arg, MaaRectHandle out_box,
MaaStringBufferHandle detail_buff))
{
recognizers_.emplace_back(name, recognizer_analyze);
_recognizers.emplace_back(name, recognizer_analyze);
}

void CustomRecognizerRegistrar::register_recognizers(MaaInstanceHandle maa_handle)
{
for (const auto& recognizer : recognizers_) {
for (const auto& recognizer : _recognizers) {
std::shared_ptr<MaaCustomRecognizerAPI> custom_recognizer =
std::make_shared<MaaCustomRecognizerAPI>(recognizer.get_custom_recognizer());
custom_recognizers_.push_back(custom_recognizer);
_custom_recognizers.push_back(custom_recognizer);
MaaRegisterCustomRecognizer(maa_handle, recognizer.get_name().c_str(), custom_recognizer.get(), nullptr);
}
}
4 changes: 2 additions & 2 deletions source/cli/CustomRecognizer/CustomRecognizerRegistrar.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ class CustomRecognizerRegistrar
void register_recognizers(MaaInstanceHandle maa_handle);

private:
std::vector<CustomRecognizer> recognizers_;
std::vector<std::shared_ptr<MaaCustomRecognizerAPI>> custom_recognizers_;
std::vector<CustomRecognizer> _recognizers;
std::vector<std::shared_ptr<MaaCustomRecognizerAPI>> _custom_recognizers;
};

0 comments on commit 9af526a

Please sign in to comment.