Skip to content

Commit

Permalink
styles: 格式化
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Sep 21, 2024
1 parent ddd2eab commit 39b7663
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 43 deletions.
6 changes: 3 additions & 3 deletions include/MaaFramework/MaaDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ typedef struct MaaRect
/*
* See MaaMsg.h
*/
typedef void (MAA_CALL *MaaNotificationCallback)(const char* message, const char* details_json, void* notify_trans_arg);
typedef void(MAA_CALL* MaaNotificationCallback)(const char* message, const char* details_json, void* notify_trans_arg);

typedef MaaBool (MAA_CALL *MaaCustomRecognitionCallback)(
typedef MaaBool(MAA_CALL* MaaCustomRecognitionCallback)(
MaaContext* context,
MaaTaskId task_id,
const char* current_task_name,
Expand All @@ -237,7 +237,7 @@ typedef MaaBool (MAA_CALL *MaaCustomRecognitionCallback)(
/* out */ MaaRect* out_box,
/* out */ MaaStringBuffer* out_detail);

typedef MaaBool (MAA_CALL *MaaCustomActionCallback)(
typedef MaaBool(MAA_CALL* MaaCustomActionCallback)(
MaaContext* context,
MaaTaskId task_id,
const char* current_task_name,
Expand Down
1 change: 0 additions & 1 deletion include/MaaFramework/MaaMsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
#define MaaMsg_Task_Recognition_Failed ("Task.Recognition.Failed")
/// @}


/**
* @{
* @brief Message for the task action.
Expand Down
3 changes: 2 additions & 1 deletion include/MaaFramework/Utility/MaaUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ extern "C"
/**
* @param[in] value
*/
MAA_FRAMEWORK_API MaaBool MaaSetGlobalOption(MaaGlobalOption key, MaaOptionValue value /**< byte array, int*, char*, bool* */, MaaOptionValueSize val_size);
MAA_FRAMEWORK_API MaaBool
MaaSetGlobalOption(MaaGlobalOption key, MaaOptionValue value /**< byte array, int*, char*, bool* */, MaaOptionValueSize val_size);

#ifdef __cplusplus
}
Expand Down
10 changes: 7 additions & 3 deletions include/MaaToolkit/ProjectInterface/MaaToolkitProjectInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ extern "C"
{
#endif

MAA_TOOLKIT_API void MaaToolkitProjectInterfaceRegisterCustomRecognition(
uint64_t inst_id,
const char* name,
MaaCustomRecognitionCallback recognition,
void* trans_arg);
MAA_TOOLKIT_API void
MaaToolkitProjectInterfaceRegisterCustomRecognition(uint64_t inst_id, const char* name, MaaCustomRecognitionCallback recognition, void* trans_arg);
MAA_TOOLKIT_API void MaaToolkitProjectInterfaceRegisterCustomAction(uint64_t inst_id, const char* name, MaaCustomActionCallback action, void* trans_arg);
MaaToolkitProjectInterfaceRegisterCustomAction(uint64_t inst_id, const char* name, MaaCustomActionCallback action, void* trans_arg);

MAA_TOOLKIT_API MaaBool MaaToolkitProjectInterfaceRunCli(
uint64_t inst_id,
uint64_t inst_id,
const char* resource_path,
const char* user_path,
MaaBool directly,
Expand Down
7 changes: 5 additions & 2 deletions source/MaaFramework/API/MaaController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ MaaController* MaaWin32ControllerCreate(
#endif
}

MaaController*
MaaCustomControllerCreate(MaaCustomControllerCallbacks* controller, void* controller_arg, MaaNotificationCallback notify, void* notify_trans_arg)
MaaController* MaaCustomControllerCreate(
MaaCustomControllerCallbacks* controller,
void* controller_arg,
MaaNotificationCallback notify,
void* notify_trans_arg)
{
LogFunc << VAR(controller) << VAR(controller_arg) << VAR_VOIDP(notify) << VAR_VOIDP(notify_trans_arg);

Expand Down
7 changes: 4 additions & 3 deletions source/MaaFramework/Controller/CustomControllerAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ CustomControllerAgent::CustomControllerAgent(
, controller_(controller)
, controller_arg_(controller_arg)
{
LogDebug << VAR_VOIDP(controller_) << VAR_VOIDP(controller_arg_) << VAR_VOIDP(controller->connect) << VAR_VOIDP(controller->request_uuid)
<< VAR_VOIDP(controller->start_app) << VAR_VOIDP(controller->stop_app) << VAR_VOIDP(controller->screencap) << VAR_VOIDP(controller->click)
<< VAR_VOIDP(controller->swipe) << VAR_VOIDP(controller->touch_down) << VAR_VOIDP(controller->touch_move) << VAR_VOIDP(controller->touch_up)
LogDebug << VAR_VOIDP(controller_) << VAR_VOIDP(controller_arg_) << VAR_VOIDP(controller->connect)
<< VAR_VOIDP(controller->request_uuid) << VAR_VOIDP(controller->start_app) << VAR_VOIDP(controller->stop_app)
<< VAR_VOIDP(controller->screencap) << VAR_VOIDP(controller->click) << VAR_VOIDP(controller->swipe)
<< VAR_VOIDP(controller->touch_down) << VAR_VOIDP(controller->touch_move) << VAR_VOIDP(controller->touch_up)
<< VAR_VOIDP(controller->press_key) << VAR_VOIDP(controller->input_text);
}

Expand Down
6 changes: 5 additions & 1 deletion source/MaaFramework/Controller/CustomControllerAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ MAA_CTRL_NS_BEGIN
class CustomControllerAgent : public ControllerAgent
{
public:
CustomControllerAgent(MaaCustomControllerCallbacks* controller, void* controller_arg, MaaNotificationCallback notify, void* notify_trans_arg);
CustomControllerAgent(
MaaCustomControllerCallbacks* controller,
void* controller_arg,
MaaNotificationCallback notify,
void* notify_trans_arg);
virtual ~CustomControllerAgent() override = default;

protected:
Expand Down
2 changes: 1 addition & 1 deletion source/MaaFramework/Resource/PipelineResMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ bool PipelineResMgr::parse_wait_freezes_param(
return false;
}
output.rate_limit = std::chrono::milliseconds(rate_limit);

auto timeout = default_value.timeout.count();
if (!get_and_check_value(field, "timeout", timeout, timeout)) {
LogError << "failed to parse_wait_freezes_param timeout" << VAR(field);
Expand Down
3 changes: 2 additions & 1 deletion source/MaaFramework/Resource/PipelineResMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class PipelineResMgr : public NonCopyable
static bool parse_target_offset(const json::value& input_target, Action::Target& output);
static bool
parse_action_target(const json::value& input, const std::string& key, Action::Target& output, const Action::Target& default_value);

static bool check_all_next_list(const PipelineDataMap& data_map);

private:
Expand All @@ -117,6 +117,7 @@ class PipelineResMgr : public NonCopyable
bool parse_config(const json::value& input, std::set<std::string>& existing_keys, const DefaultPipelineMgr& default_mg);

static bool check_next_list(const PipelineData::NextList& next_list, const PipelineDataMap& data_map);

private:
std::vector<std::filesystem::path> paths_;
PipelineDataMap pipeline_data_map_;
Expand Down
4 changes: 2 additions & 2 deletions source/MaaFramework/Task/Component/CustomAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ bool CustomAction::run(
std::string task_name,
MAA_RES_NS::CustomActionSession session,
const MAA_RES_NS::Action::CustomParam& param,
MaaRecoId reco_id,
MaaRecoId reco_id,
const cv::Rect& rect)
{
LogFunc << VAR(context.task_id()) << VAR(task_name) << VAR_VOIDP(session.action) << VAR_VOIDP(session.trans_arg)
<< VAR(param.custom_param)<< VAR(reco_id) << VAR(rect) ;
<< VAR(param.custom_param) << VAR(reco_id) << VAR(rect);

if (!session.action) {
LogError << "Action is null" << VAR(task_name) << VAR(param.name);
Expand Down
1 change: 0 additions & 1 deletion source/MaaFramework/Task/TaskBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ NodeDetail TaskBase::run_action(const RecoResult& reco)
};
notify(MaaMsg_Task_Action_Starting, cb_detail);
}


Actuator actuator(tasker_, *context_);
bool ret = actuator.run(*reco.box, reco.reco_id, pipeline_data);
Expand Down
2 changes: 1 addition & 1 deletion source/MaaFramework/Task/TaskBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class TaskBase
std::string cur_task_;

std::shared_ptr<Context> context_ = nullptr;

private:
void init();
bool debug_mode() const;
Expand Down
6 changes: 4 additions & 2 deletions source/MaaToolkit/ProjectInterface/ProjectInterfaceMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ class ProjectInterfaceMgr : public SingletonHolder<ProjectInterfaceMgr>
friend class SingletonHolder<ProjectInterfaceMgr>;

public:
void
register_custom_recognition(uint64_t inst_id, const std::string& name, MAA_PROJECT_INTERFACE_NS::CustomRecognitionSession recognition);
void register_custom_recognition(
uint64_t inst_id,
const std::string& name,
MAA_PROJECT_INTERFACE_NS::CustomRecognitionSession recognition);
void register_custom_action(uint64_t inst_id, const std::string& name, MAA_PROJECT_INTERFACE_NS::CustomActionSession action);

bool run_cli(
Expand Down
13 changes: 4 additions & 9 deletions source/MaaUtils/Codec/Codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ static constexpr inline void char32_to_utf8(std::string& out, char32_t ch)
}
}

static constexpr inline bool
utf8_to_char32(std::string_view::iterator& cur, std::string_view::iterator end, char32_t& ch)
static constexpr inline bool utf8_to_char32(std::string_view::iterator& cur, std::string_view::iterator end, char32_t& ch)
{
char leading = *cur++;
if ((leading & 0b10000000) == 0) {
Expand Down Expand Up @@ -57,8 +56,7 @@ static constexpr inline bool
char next1 = *cur++;
char next2 = *cur++;
char next3 = *cur++;
ch = ((leading & 0b00001111) << 18) | ((next1 & 0b00111111) << 12)
| ((next2 & 0b00111111) << 6) | (next3 & 0b00111111);
ch = ((leading & 0b00001111) << 18) | ((next1 & 0b00111111) << 12) | ((next2 & 0b00111111) << 6) | (next3 & 0b00111111);
}
else {
// mainly for 0b10xxxxxx, skip corrupted data
Expand All @@ -84,8 +82,7 @@ static constexpr inline void char32_to_wchar(std::wstring& out, char32_t ch)
}
}

static constexpr inline bool
wchar_to_char32(std::wstring_view::iterator& cur, std::wstring_view::iterator end, char32_t& ch)
static constexpr inline bool wchar_to_char32(std::wstring_view::iterator& cur, std::wstring_view::iterator end, char32_t& ch)
{
if constexpr (sizeof(wchar_t) == 2) {
auto leading = static_cast<uint32_t>(static_cast<uint16_t>(*cur++));
Expand All @@ -97,9 +94,7 @@ static constexpr inline bool
if ((next & 0b1111'1100'0000'0000) != 0xDC00) {
return false;
}
ch = static_cast<char32_t>(
(((leading & 0b0000'0011'1111'1111) << 10) | (next & 0b0000'0011'1111'1111))
+ 0x10000);
ch = static_cast<char32_t>((((leading & 0b0000'0011'1111'1111) << 10) | (next & 0b0000'0011'1111'1111)) + 0x10000);
}
else if ((leading & 0b1111'1100'0000'0000) == 0xDC00) {
return false;
Expand Down
2 changes: 0 additions & 2 deletions source/include/Utils/JsonExt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

namespace json::ext
{

template <>
class jsonization<std::filesystem::path>
{
Expand Down Expand Up @@ -58,5 +57,4 @@ class jsonization<cv::Rect>
return true;
}
};

} // namespace json::ext
10 changes: 5 additions & 5 deletions source/include/Utils/Time.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ MAA_NS_BEGIN
inline std::string format_now()
{
#ifndef MAA_USE_POSIX_TIME
return std::format("{}", std::chrono::current_zone()->to_local(
std::chrono::floor<std::chrono::milliseconds>(std::chrono::system_clock::now())));
return std::format(
"{}",
std::chrono::current_zone()->to_local(std::chrono::floor<std::chrono::milliseconds>(std::chrono::system_clock::now())));
#else
timeval tv = {};
gettimeofday(&tv, nullptr);
Expand All @@ -45,8 +46,7 @@ inline std::string format_now()
inline std::string format_now_for_filename()
{
#ifndef MAA_USE_POSIX_TIME
return std::format("{:%Y.%m.%d-%H.%M.%S}",
std::chrono::current_zone()->to_local(std::chrono::system_clock::now()));
return std::format("{:%Y.%m.%d-%H.%M.%S}", std::chrono::current_zone()->to_local(std::chrono::system_clock::now()));
#else
timeval tv = {};
gettimeofday(&tv, nullptr);
Expand All @@ -70,4 +70,4 @@ inline duration_t duration_since(const std::chrono::steady_clock::time_point& st
return std::chrono::duration_cast<duration_t>(std::chrono::steady_clock::now() - start_time);
}

MAA_NS_END
MAA_NS_END
7 changes: 2 additions & 5 deletions test/pipeline/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ int main([[maybe_unused]] int argc, char** argv)
}

std::string logging_dir = (cur_dir / "debug").string();
MaaSetGlobalOption(
MaaGlobalOption_LogDir,
static_cast<void*>(logging_dir.data()),
logging_dir.size());
MaaSetGlobalOption(MaaGlobalOption_LogDir, static_cast<void*>(logging_dir.data()), logging_dir.size());
bool on = true;
MaaSetGlobalOption(MaaGlobalOption_SaveDraw, &on, sizeof(on));
MaaLoggingLevel lv = MaaLoggingLevel_Info;
Expand All @@ -31,4 +28,4 @@ int main([[maybe_unused]] int argc, char** argv)
}

return 0;
}
}

0 comments on commit 39b7663

Please sign in to comment.