Skip to content

Commit

Permalink
chore: 一些没啥用的参数重命名
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Oct 23, 2023
1 parent 023412d commit 90243bd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion include/MaaFramework/Task/MaaCustomRecognizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extern "C"
MaaBool (*analyze)(MaaSyncContextHandle sync_context, const MaaImageBufferHandle image, MaaStringView task_name,
MaaStringView custom_recognition_param, MaaTransparentArg recognizer_arg,
/*out*/ MaaRectHandle out_box,
/*out*/ MaaStringBufferHandle detail_buff);
/*out*/ MaaStringBufferHandle out_detail);
};

#ifdef __cplusplus
Expand Down
10 changes: 5 additions & 5 deletions include/MaaFramework/Task/MaaSyncContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ extern "C"
/* SyncContext */

MaaBool MAA_FRAMEWORK_API MaaSyncContextRunTask(MaaSyncContextHandle sync_context, MaaStringView task,
MaaBool MAA_FRAMEWORK_API MaaSyncContextRunTask(MaaSyncContextHandle sync_context, MaaStringView task_name,
MaaStringView param);
MaaBool MAA_FRAMEWORK_API MaaSyncContextRunRecognizer(MaaSyncContextHandle sync_context, MaaImageBufferHandle image,
MaaStringView task, MaaStringView task_param,
MaaStringView task_name, MaaStringView task_param,
/* out */ MaaRectHandle out_box,
/* out */ MaaStringBufferHandle detail_buff);
MaaBool MAA_FRAMEWORK_API MaaSyncContextRunAction(MaaSyncContextHandle sync_context, MaaStringView task,
/* out */ MaaStringBufferHandle out_detail);
MaaBool MAA_FRAMEWORK_API MaaSyncContextRunAction(MaaSyncContextHandle sync_context, MaaStringView task_name,
MaaStringView task_param, MaaRectHandle cur_box,
MaaStringView cur_rec_detail);
MaaBool MAA_FRAMEWORK_API MaaSyncContextClick(MaaSyncContextHandle sync_context, int32_t x, int32_t y);
Expand All @@ -32,7 +32,7 @@ extern "C"

MaaBool MAA_FRAMEWORK_API MaaSyncContextScreencap(MaaSyncContextHandle sync_context,
/* out */ MaaImageBufferHandle buffer);
MaaBool MAA_FRAMEWORK_API MaaSyncContextGetTaskResult(MaaSyncContextHandle sync_context, MaaStringView task,
MaaBool MAA_FRAMEWORK_API MaaSyncContextGetTaskResult(MaaSyncContextHandle sync_context, MaaStringView task_name,
/* out */ MaaStringBufferHandle buffer);

#ifdef __cplusplus
Expand Down
4 changes: 2 additions & 2 deletions sample/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int main([[maybe_unused]] int argc, char** argv)
MaaBool my_analyze(MaaSyncContextHandle sync_context, const MaaImageBufferHandle image, MaaStringView task_name,
MaaStringView custom_recognition_param, MaaTransparentArg arg,
/*out*/ MaaRectHandle out_box,
/*out*/ MaaStringBufferHandle detail_buff)
/*out*/ MaaStringBufferHandle out_detail)
{
/* Get image */

Expand Down Expand Up @@ -101,7 +101,7 @@ MaaBool my_analyze(MaaSyncContextHandle sync_context, const MaaImageBufferHandle
out_box->height = my_box[3];

// Step 2: output anything you want
MaaSetString(detail_buff,
MaaSetString(out_detail,
"Balabala, this string will be used by MaaCustomActionAPI and MaaSyncContextGetTaskResult. "
"And for compatibility, I recommend you use json.");

Expand Down
32 changes: 16 additions & 16 deletions source/MaaFramework/API/MaaSyncContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
#include "Buffer/StringBuffer.hpp"
#include "Utils/Logger.h"

MaaBool MaaSyncContextRunTask(MaaSyncContextHandle sync_context, MaaStringView task, MaaStringView param)
MaaBool MaaSyncContextRunTask(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView param)
{
LogFunc << VAR_VOIDP(sync_context) << VAR(task) << VAR(param);
LogFunc << VAR_VOIDP(sync_context) << VAR(task_name) << VAR(param);

if (!sync_context) {
LogError << "handle is null";
return false;
}

return sync_context->run_task(task, param);
return sync_context->run_task(task_name, param);
}

MaaBool MaaSyncContextRunRecognizer(MaaSyncContextHandle sync_context, MaaImageBufferHandle image, MaaStringView task,
MaaStringView task_param, MaaRectHandle out_box, MaaStringBufferHandle detail_buff)
MaaBool MaaSyncContextRunRecognizer(MaaSyncContextHandle sync_context, MaaImageBufferHandle image, MaaStringView task_name,
MaaStringView task_param, MaaRectHandle out_box, MaaStringBufferHandle out_detail)
{
LogFunc << VAR_VOIDP(sync_context) << VAR(image) << VAR(task) << VAR(task_param) << VAR(out_box)
<< VAR(detail_buff);
LogFunc << VAR_VOIDP(sync_context) << VAR(image) << VAR(task_name) << VAR(task_param) << VAR(out_box)
<< VAR(out_detail);

if (!sync_context || !image) {
LogError << "handle is null";
Expand All @@ -30,25 +30,25 @@ MaaBool MaaSyncContextRunRecognizer(MaaSyncContextHandle sync_context, MaaImageB
cv::Rect cvbox {};
std::string detail;

bool ret = sync_context->run_recognizer(image->get(), task, task_param, cvbox, detail);
bool ret = sync_context->run_recognizer(image->get(), task_name, task_param, cvbox, detail);

if (out_box) {
out_box->x = cvbox.x;
out_box->y = cvbox.y;
out_box->width = cvbox.width;
out_box->height = cvbox.height;
}
if (detail_buff) {
detail_buff->set(std::move(detail));
if (out_detail) {
out_detail->set(std::move(detail));
}

return ret;
}

MaaBool MaaSyncContextRunAction(MaaSyncContextHandle sync_context, MaaStringView task, MaaStringView task_param,
MaaBool MaaSyncContextRunAction(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView task_param,
MaaRectHandle cur_box, MaaStringView cur_rec_detail)
{
LogFunc << VAR_VOIDP(sync_context) << VAR(task) << VAR(task_param) << VAR(cur_box) << VAR(cur_rec_detail);
LogFunc << VAR_VOIDP(sync_context) << VAR(task_name) << VAR(task_param) << VAR(cur_box) << VAR(cur_rec_detail);

if (!sync_context) {
LogError << "handle is null";
Expand All @@ -63,7 +63,7 @@ MaaBool MaaSyncContextRunAction(MaaSyncContextHandle sync_context, MaaStringView
cvbox.height = cur_box->height;
}

bool ret = sync_context->run_action(task, task_param, cvbox, cur_rec_detail);
bool ret = sync_context->run_action(task_name, task_param, cvbox, cur_rec_detail);
return ret;
}

Expand Down Expand Up @@ -161,16 +161,16 @@ MaaBool MaaSyncContextScreencap(MaaSyncContextHandle sync_context, MaaImageBuffe
return true;
}

MaaBool MaaSyncContextGetTaskResult(MaaSyncContextHandle sync_context, MaaStringView task, MaaStringBufferHandle buffer)
MaaBool MaaSyncContextGetTaskResult(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringBufferHandle buffer)
{
LogFunc << VAR_VOIDP(sync_context) << VAR(task) << VAR(buffer);
LogFunc << VAR_VOIDP(sync_context) << VAR(task_name) << VAR(buffer);

if (!sync_context || !buffer) {
LogError << "handle is null";
return false;
}

auto res = sync_context->task_result(task);
auto res = sync_context->task_result(task_name);
if (res.empty()) {
LogError << "res is empty";
return false;
Expand Down

0 comments on commit 90243bd

Please sign in to comment.