-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: merge code, move macro (#178)
- Loading branch information
Showing
8 changed files
with
280 additions
and
709 deletions.
There are no files selected for viewing
Submodule LHG
updated
19 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
MacroBlockBegin: '^LHG.*Begin' | ||
MacroBlockEnd: '^LHG.*End' | ||
StatementMacros: | ||
- 'LHGArgToJsonMiddle' | ||
- 'LHGArgFromJsonMiddle' |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,22 @@ | ||
#pragma once | ||
|
||
#include "./utils.hpp" | ||
|
||
#include "utils/phony.hpp" | ||
|
||
#include "../info.hpp" | ||
|
||
namespace lhg::call | ||
{ | ||
|
||
__CALL_DECLARE_OUTER_STATE(maa::func_type_MaaSetImageEncoded::_1_data, std::string) | ||
|
||
__CALL_DECLARE_OUTER_STATE(maa::func_type_MaaResourceGetTaskList::_1_buffer, MaaStringBufferHandle) | ||
__CALL_DECLARE_OUTER_STATE(maa::func_type_MaaResourceGetHash::_1_buffer, MaaStringBufferHandle) | ||
__CALL_DECLARE_OUTER_STATE(maa::func_type_MaaControllerGetUUID::_1_buffer, MaaStringBufferHandle) | ||
__CALL_DECLARE_OUTER_STATE( | ||
maa::func_type_MaaSyncContextGetTaskResult::_2_out_task_result, | ||
MaaStringBufferHandle) | ||
__CALL_DECLARE_OUTER_STATE( | ||
maa::func_type_MaaSyncContextRunRecognizer::_5_out_detail, | ||
MaaStringBufferHandle) | ||
|
||
__CALL_DECLARE_OUTER_STATE(maa::func_type_MaaSyncContextRunAction::_3_cur_box, MaaRect); | ||
__CALL_DECLARE_OUTER_STATE(maa::func_type_MaaSyncContextRunRecognizer::_4_out_box, MaaRect); | ||
|
||
}; // namespace lhg::call | ||
LHGArgOuterState(maa::func_type_MaaSetImageEncoded::_1_data, std::string); | ||
|
||
LHGArgOuterState(maa::func_type_MaaResourceGetTaskList::_1_buffer, | ||
MaaStringBufferHandle); | ||
LHGArgOuterState(maa::func_type_MaaResourceGetHash::_1_buffer, | ||
MaaStringBufferHandle); | ||
LHGArgOuterState(maa::func_type_MaaControllerGetUUID::_1_buffer, | ||
MaaStringBufferHandle); | ||
LHGArgOuterState(maa::func_type_MaaSyncContextGetTaskResult::_2_out_task_result, | ||
MaaStringBufferHandle); | ||
LHGArgOuterState(maa::func_type_MaaSyncContextRunRecognizer::_5_out_detail, | ||
MaaStringBufferHandle); | ||
|
||
LHGArgOuterState(maa::func_type_MaaSyncContextRunAction::_3_cur_box, MaaRect); | ||
LHGArgOuterState(maa::func_type_MaaSyncContextRunRecognizer::_4_out_box, | ||
MaaRect); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,49 @@ | ||
#pragma once | ||
|
||
#include "./type.hpp" | ||
#include "./utils.hpp" | ||
|
||
#include "MaaFramework/Utility/MaaBuffer.h" | ||
#include "utils/phony.hpp" | ||
|
||
#include "../info.hpp" | ||
|
||
namespace lhg::callback | ||
{ | ||
|
||
__CALLBACK_DECLARE_HANDLE_OPER(maa::func_type_CustomActionRun::_0_sync_context, scope) | ||
__CALLBACK_DECLARE_ARG_TO_JSON_BEGIN(maa::func_type_CustomActionRun, _3_cur_box) | ||
auto rec = std::get<maa::func_type_CustomActionRun::_3_cur_box::index>(arg); | ||
req[name] = { | ||
{ "x", rec->x }, | ||
{ "y", rec->y }, | ||
{ "width", rec->width }, | ||
{ "height", rec->height }, | ||
}; | ||
__CALLBACK_DECLARE_ARG_TO_JSON_END() | ||
|
||
__CALLBACK_DECLARE_HANDLE_OPER(maa::func_type_CustomRecognizerAnalyze::_0_sync_context, scope) | ||
__CALLBACK_DECLARE_HANDLE_OPER(maa::func_type_CustomRecognizerAnalyze::_1_image, scope) | ||
__CALLBACK_DECLARE_INPUT(maa::func_type_CustomRecognizerAnalyze::_5_out_box, false) | ||
__CALLBACK_DECLARE_INPUT(maa::func_type_CustomRecognizerAnalyze::_6_out_detail, false) | ||
__CALLBACK_DECLARE_OUTPUT(maa::func_type_CustomRecognizerAnalyze::_5_out_box, true) | ||
__CALLBACK_DECLARE_OUTPUT(maa::func_type_CustomRecognizerAnalyze::_6_out_detail, true) | ||
|
||
__CALLBACK_DECLARE_JSON_TO_ARG_BEGIN(maa::func_type_CustomRecognizerAnalyze, _5_out_box) | ||
auto rec = std::get<maa::func_type_CustomRecognizerAnalyze::_5_out_box::index>(arg); | ||
rec->x = value.at("x").as_integer(); | ||
rec->y = value.at("y").as_integer(); | ||
rec->width = value.at("width").as_integer(); | ||
rec->height = value.at("height").as_integer(); | ||
return true; | ||
__CALLBACK_DECLARE_ARG_TO_JSON_END() | ||
|
||
__CALLBACK_DECLARE_JSON_TO_ARG_BEGIN(maa::func_type_CustomRecognizerAnalyze, _6_out_detail) | ||
auto det = std::get<maa::func_type_CustomRecognizerAnalyze::_6_out_detail::index>(arg); | ||
std::string detail = value.as_string(); | ||
MaaSetStringEx(det, detail.c_str(), detail.size()); | ||
return true; | ||
__CALLBACK_DECLARE_ARG_TO_JSON_END() | ||
|
||
template <> | ||
struct get_context<maa::callback_CustomActionRun, true> | ||
{ | ||
using callback_tag = maa::callback_CustomActionRun; | ||
using func_type = typename callback_tag::type; | ||
using arg_tuple = typename func_type::args; | ||
using call_arg_tuple = convert_arg_type<arg_tuple>; | ||
static context_info* get(const call_arg_tuple& arg) | ||
{ | ||
auto ptr = | ||
reinterpret_cast<pri_maa::custom_action_context*>(std::get<callback_tag::context>(arg)); | ||
return ptr->run.get(); | ||
} | ||
}; | ||
|
||
template <> | ||
struct get_context<maa::callback_CustomActionStop, true> | ||
{ | ||
using callback_tag = maa::callback_CustomActionStop; | ||
using func_type = typename callback_tag::type; | ||
using arg_tuple = typename func_type::args; | ||
using call_arg_tuple = convert_arg_type<arg_tuple>; | ||
static context_info* get(const call_arg_tuple& arg) | ||
{ | ||
auto ptr = | ||
reinterpret_cast<pri_maa::custom_action_context*>(std::get<callback_tag::context>(arg)); | ||
return ptr->stop.get(); | ||
} | ||
}; | ||
|
||
__CALLBACK_DECLARE_JSON_TO_ARG_SCHEMA_BEGIN(maa::func_type_CustomRecognizerAnalyze, _5_out_box) | ||
b.type("object").prop({ { "x", schema::Builder().type("number").obj }, | ||
{ "y", schema::Builder().type("number").obj }, | ||
{ "width", schema::Builder().type("number").obj }, | ||
{ "height", schema::Builder().type("number").obj } }); | ||
__CALLBACK_DECLARE_JSON_TO_ARG_SCHEMA_END() | ||
__CALLBACK_DECLARE_JSON_TO_ARG_SCHEMA_TYPE( | ||
maa::func_type_CustomRecognizerAnalyze, | ||
_6_out_detail, | ||
"string") | ||
|
||
__CALLBACK_DECLARE_ARG_TO_JSON_SCHEMA_BEGIN(maa::func_type_CustomActionRun, _3_cur_box) | ||
b.type("object").prop({ { "x", schema::Builder().type("number").obj }, | ||
{ "y", schema::Builder().type("number").obj }, | ||
{ "width", schema::Builder().type("number").obj }, | ||
{ "height", schema::Builder().type("number").obj } }); | ||
__CALLBACK_DECLARE_ARG_TO_JSON_SCHEMA_END() | ||
|
||
}; // namespace lhg::callback | ||
LHGArgHandle(maa::func_type_CustomActionRun::_0_sync_context, scope); | ||
LHGArgHandle(maa::func_type_CustomRecognizerAnalyze::_0_sync_context, scope); | ||
LHGArgHandle(maa::func_type_CustomRecognizerAnalyze::_1_image, scope); | ||
|
||
LHGArgToJsonBegin(maa::func_type_CustomActionRun, _3_cur_box, false) | ||
auto rec = std::get<index>(arg); | ||
value = pri_maa::from_rect(rec); | ||
LHGArgToJsonMiddle() | ||
pri_maa::schema_rect(b); | ||
LHGArgToJsonEnd() | ||
|
||
LHGArgOutput(maa::func_type_CustomRecognizerAnalyze::_5_out_box); | ||
LHGArgOutput(maa::func_type_CustomRecognizerAnalyze::_6_out_detail); | ||
|
||
LHGArgFromJsonBegin(maa::func_type_CustomRecognizerAnalyze, _5_out_box, false) | ||
auto rec = std::get<index>(arg); | ||
pri_maa::to_rect(value, rec); | ||
LHGArgFromJsonMiddle() | ||
pri_maa::schema_rect(b); | ||
LHGArgFromJsonEnd() | ||
|
||
LHGArgFromJsonBegin(maa::func_type_CustomRecognizerAnalyze, _6_out_detail, | ||
false) | ||
auto det = std::get<index>(arg); | ||
std::string detail = value.as_string(); | ||
MaaSetStringEx(det, detail.c_str(), detail.size()); | ||
LHGArgFromJsonMiddle() | ||
b.type("string"); | ||
LHGArgFromJsonEnd() | ||
|
||
LHGArgGetContextBegin(maa::callback_CustomActionRun) | ||
auto ptr = reinterpret_cast<pri_maa::custom_action_context *>( | ||
std::get<callback_tag::context>(arg)); | ||
return ptr->run.get(); | ||
LHGArgGetContextEnd() | ||
|
||
LHGArgGetContextBegin(maa::callback_CustomActionStop) | ||
auto ptr = reinterpret_cast<pri_maa::custom_action_context *>( | ||
std::get<callback_tag::context>(arg)); | ||
return ptr->stop.get(); | ||
LHGArgGetContextEnd() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,15 @@ | ||
#pragma once | ||
|
||
#include "./utils.hpp" | ||
|
||
#include "MaaFramework/MaaDef.h" | ||
#include "utils/phony.hpp" | ||
|
||
#include "../info.hpp" | ||
|
||
namespace lhg::callback | ||
{ | ||
|
||
__CALLBACK_DECLARE_OUTER_STATE( | ||
LHGArgOuterState( | ||
maa::func_type_CustomActionRun::_0_sync_context, | ||
HandleManager<MaaSyncContextHandle>::ScopedHandle) | ||
|
||
__CALLBACK_DECLARE_OUTER_STATE( | ||
HandleManager<MaaSyncContextHandle>::ScopedHandle); | ||
LHGArgOuterState( | ||
maa::func_type_CustomRecognizerAnalyze::_0_sync_context, | ||
HandleManager<MaaSyncContextHandle>::ScopedHandle) | ||
|
||
__CALLBACK_DECLARE_OUTER_STATE( | ||
HandleManager<MaaSyncContextHandle>::ScopedHandle); | ||
LHGArgOuterState( | ||
maa::func_type_CustomRecognizerAnalyze::_1_image, | ||
HandleManager<MaaImageBufferHandle>::ScopedHandle) | ||
|
||
}; // namespace lhg::callback | ||
HandleManager<MaaImageBufferHandle>::ScopedHandle); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.