Skip to content

Commit

Permalink
styles: 超级格式化
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Mar 6, 2024
1 parent 8d5edbb commit 3e5f699
Show file tree
Hide file tree
Showing 145 changed files with 1,429 additions and 963 deletions.
18 changes: 12 additions & 6 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros:
- __pragma
- _Pragma
- __attribute__
- __declspec
# AttributeMacros:
# - __pragma
# - _Pragma
# - __attribute__
# - __declspec
BinPackArguments: false
BinPackParameters: false
BitFieldColonSpacing: After
Expand Down Expand Up @@ -136,7 +136,13 @@ PackConstructorInitializers: Never
# PenaltyIndentedWhitespace:
# PenaltyReturnTypeOnItsOwnLine:
PointerAlignment: Left
QualifierAlignment: Leave
QualifierAlignment: Custom
QualifierOrder:
- inline
- static
- const
- constexpr
- type
ReferenceAlignment: Left
ReflowComments: true
RemoveBracesLLVM: false
Expand Down
69 changes: 45 additions & 24 deletions include/MaaFramework/Instance/MaaController.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ extern "C"
* @param callback_arg The callback arg that will be passed to the callback function.
* @return MaaControllerHandle The handle of the created controller instance.
*/
MaaControllerHandle MAA_FRAMEWORK_API MaaAdbControllerCreate( //
MaaStringView adb_path, MaaStringView address, MaaAdbControllerType type, MaaStringView config,
MaaControllerCallback callback, MaaCallbackTransparentArg callback_arg);
MaaControllerHandle MAA_FRAMEWORK_API MaaAdbControllerCreate(
MaaStringView adb_path,
MaaStringView address,
MaaAdbControllerType type,
MaaStringView config,
MaaControllerCallback callback,
MaaCallbackTransparentArg callback_arg);

/**
* @brief Create a win32 controller instance.
Expand All @@ -45,8 +49,10 @@ extern "C"
* @param callback_arg The callback arg that will be passed to the callback function.
* @return MaaControllerHandle The handle of the created controller instance.
*/
MaaControllerHandle MAA_FRAMEWORK_API MaaWin32ControllerCreate( //
MaaWin32Hwnd hWnd, MaaWin32ControllerType type, MaaControllerCallback callback,
MaaControllerHandle MAA_FRAMEWORK_API MaaWin32ControllerCreate(
MaaWin32Hwnd hWnd,
MaaWin32ControllerType type,
MaaControllerCallback callback,
MaaCallbackTransparentArg callback_arg);

/**
Expand All @@ -61,9 +67,14 @@ extern "C"
* @param callback_arg The callback arg that will be passed to the callback function.
* @return MaaControllerHandle The handle of the created controller instance.
*/
MaaControllerHandle MAA_FRAMEWORK_API MaaAdbControllerCreateV2( //
MaaStringView adb_path, MaaStringView address, MaaAdbControllerType type, MaaStringView config,
MaaStringView agent_path, MaaControllerCallback callback, MaaCallbackTransparentArg callback_arg);
MaaControllerHandle MAA_FRAMEWORK_API MaaAdbControllerCreateV2(
MaaStringView adb_path,
MaaStringView address,
MaaAdbControllerType type,
MaaStringView config,
MaaStringView agent_path,
MaaControllerCallback callback,
MaaCallbackTransparentArg callback_arg);

/**
* @brief Create a custom controller instance.
Expand All @@ -74,17 +85,27 @@ extern "C"
* @param callback_arg The callback arg that will be passed to the callback function.
* @return MaaControllerHandle The handle of the created controller instance.
*/
MaaControllerHandle MAA_FRAMEWORK_API MaaCustomControllerCreate( //
MaaCustomControllerHandle handle, MaaTransparentArg handle_arg, MaaControllerCallback callback,
MaaControllerHandle MAA_FRAMEWORK_API MaaCustomControllerCreate(
MaaCustomControllerHandle handle,
MaaTransparentArg handle_arg,
MaaControllerCallback callback,
MaaCallbackTransparentArg callback_arg);

MaaControllerHandle MAA_FRAMEWORK_API MaaThriftControllerCreate( //
MaaThriftControllerType type, MaaStringView host, int32_t port, MaaStringView config,
MaaControllerCallback callback, MaaCallbackTransparentArg callback_arg);
MaaControllerHandle MAA_FRAMEWORK_API MaaThriftControllerCreate(
MaaThriftControllerType type,
MaaStringView host,
int32_t port,
MaaStringView config,
MaaControllerCallback callback,
MaaCallbackTransparentArg callback_arg);

MaaControllerHandle MAA_FRAMEWORK_API MaaDbgControllerCreate( //
MaaStringView read_path, MaaStringView write_path, MaaDbgControllerType type, MaaStringView config,
MaaControllerCallback callback, MaaCallbackTransparentArg callback_arg);
MaaControllerHandle MAA_FRAMEWORK_API MaaDbgControllerCreate(
MaaStringView read_path,
MaaStringView write_path,
MaaDbgControllerType type,
MaaStringView config,
MaaControllerCallback callback,
MaaCallbackTransparentArg callback_arg);

/**
* @brief Free the controller instance.
Expand All @@ -105,8 +126,8 @@ extern "C"
* @param val_size The size of the option value.
* @return MaaBool Whether the option is set successfully.
*/
MaaBool MAA_FRAMEWORK_API MaaControllerSetOption(MaaControllerHandle ctrl, MaaCtrlOption key, MaaOptionValue value,
MaaOptionValueSize val_size);
MaaBool MAA_FRAMEWORK_API MaaControllerSetOption(
MaaControllerHandle ctrl, MaaCtrlOption key, MaaOptionValue value, MaaOptionValueSize val_size);

/**
* @defgroup MaaControllerPostRequest Controller Requests
Expand All @@ -119,17 +140,17 @@ extern "C"

MaaCtrlId MAA_FRAMEWORK_API MaaControllerPostClick(MaaControllerHandle ctrl, int32_t x, int32_t y);

MaaCtrlId MAA_FRAMEWORK_API MaaControllerPostSwipe(MaaControllerHandle ctrl, int32_t x1, int32_t y1, int32_t x2,
int32_t y2, int32_t duration);
MaaCtrlId MAA_FRAMEWORK_API MaaControllerPostSwipe(
MaaControllerHandle ctrl, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t duration);

MaaCtrlId MAA_FRAMEWORK_API MaaControllerPostPressKey(MaaControllerHandle ctrl, int32_t keycode);

MaaCtrlId MAA_FRAMEWORK_API MaaControllerPostInputText(MaaControllerHandle ctrl, MaaStringView text);

MaaCtrlId MAA_FRAMEWORK_API MaaControllerPostTouchDown(MaaControllerHandle ctrl, int32_t contact, int32_t x,
int32_t y, int32_t pressure);
MaaCtrlId MAA_FRAMEWORK_API MaaControllerPostTouchMove(MaaControllerHandle ctrl, int32_t contact, int32_t x,
int32_t y, int32_t pressure);
MaaCtrlId MAA_FRAMEWORK_API
MaaControllerPostTouchDown(MaaControllerHandle ctrl, int32_t contact, int32_t x, int32_t y, int32_t pressure);
MaaCtrlId MAA_FRAMEWORK_API
MaaControllerPostTouchMove(MaaControllerHandle ctrl, int32_t contact, int32_t x, int32_t y, int32_t pressure);

MaaCtrlId MAA_FRAMEWORK_API MaaControllerPostTouchUp(MaaControllerHandle ctrl, int32_t contact);

Expand Down
13 changes: 7 additions & 6 deletions include/MaaFramework/Instance/MaaCustomController.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ extern "C"
* You do not have to implement all the functions in this API. Instead, just implement the functions you need.
* Do note that if an unimplemented function is called, the framework will likely crash.
*/
struct MaaCustomControllerAPI
{
struct MaaCustomControllerAPI {
MaaBool (*connect)(MaaTransparentArg handle_arg);

/// Write result to buffer.
MaaBool (*request_uuid)(MaaTransparentArg handle_arg, /* out */ MaaStringBufferHandle buffer);

/// Write result to width and height.
MaaBool (*request_resolution)(MaaTransparentArg handle_arg, /* out */ int32_t* width,
/* out */ int32_t* height);
MaaBool (*request_resolution)(
MaaTransparentArg handle_arg,
/* out */ int32_t* width,
/* out */ int32_t* height);

MaaBool (*start_app)(MaaStringView intent, MaaTransparentArg handle_arg);
MaaBool (*stop_app)(MaaStringView intent, MaaTransparentArg handle_arg);
Expand All @@ -43,8 +44,8 @@ extern "C"
MaaBool (*screencap)(MaaTransparentArg handle_arg, /* out */ MaaImageBufferHandle buffer);

MaaBool (*click)(int32_t x, int32_t y, MaaTransparentArg handle_arg);
MaaBool (*swipe)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t duration,
MaaTransparentArg handle_arg);
MaaBool (*swipe)(
int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t duration, MaaTransparentArg handle_arg);
MaaBool (*touch_down)(int32_t contact, int32_t x, int32_t y, int32_t pressure, MaaTransparentArg handle_arg);
MaaBool (*touch_move)(int32_t contact, int32_t x, int32_t y, int32_t pressure, MaaTransparentArg handle_arg);
MaaBool (*touch_up)(int32_t contact, MaaTransparentArg handle_arg);
Expand Down
16 changes: 9 additions & 7 deletions include/MaaFramework/Instance/MaaInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ extern "C"
* @param val_size The size of the option value.
* @return MaaBool Whether the option is set successfully.
*/
MaaBool MAA_FRAMEWORK_API MaaSetOption(MaaInstanceHandle inst, MaaInstOption key, MaaOptionValue value,
MaaOptionValueSize val_size);
MaaBool MAA_FRAMEWORK_API
MaaSetOption(MaaInstanceHandle inst, MaaInstOption key, MaaOptionValue value, MaaOptionValueSize val_size);

/**
* @brief Bind the instance to an initialized resource.
Expand Down Expand Up @@ -89,9 +89,11 @@ extern "C"
* @param recognizer_arg
* @return MaaBool
*/
MaaBool MAA_FRAMEWORK_API MaaRegisterCustomRecognizer(MaaInstanceHandle inst, MaaStringView name,
MaaCustomRecognizerHandle recognizer,
MaaTransparentArg recognizer_arg);
MaaBool MAA_FRAMEWORK_API MaaRegisterCustomRecognizer(
MaaInstanceHandle inst,
MaaStringView name,
MaaCustomRecognizerHandle recognizer,
MaaTransparentArg recognizer_arg);

/**
* @brief Unregister a custom recognizer from the instance.
Expand Down Expand Up @@ -121,8 +123,8 @@ extern "C"
* @param action_arg
* @return MaaBool
*/
MaaBool MAA_FRAMEWORK_API MaaRegisterCustomAction(MaaInstanceHandle inst, MaaStringView name,
MaaCustomActionHandle action, MaaTransparentArg action_arg);
MaaBool MAA_FRAMEWORK_API MaaRegisterCustomAction(
MaaInstanceHandle inst, MaaStringView name, MaaCustomActionHandle action, MaaTransparentArg action_arg);

/**
* @brief Unregister a custom action from the instance.
Expand Down
8 changes: 4 additions & 4 deletions include/MaaFramework/Instance/MaaResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ extern "C"
* @param callback_arg
* @return MaaResourceHandle
*/
MaaResourceHandle MAA_FRAMEWORK_API MaaResourceCreate(MaaResourceCallback callback,
MaaCallbackTransparentArg callback_arg);
MaaResourceHandle MAA_FRAMEWORK_API
MaaResourceCreate(MaaResourceCallback callback, MaaCallbackTransparentArg callback_arg);

/**
* @brief Free the resource.
Expand Down Expand Up @@ -81,8 +81,8 @@ extern "C"
* @param val_size The size of the option value.
* @return MaaBool Whether the option is set successfully.
*/
MaaBool MAA_FRAMEWORK_API MaaResourceSetOption(MaaResourceHandle res, MaaResOption key, MaaOptionValue value,
MaaOptionValueSize val_size);
MaaBool MAA_FRAMEWORK_API MaaResourceSetOption(
MaaResourceHandle res, MaaResOption key, MaaOptionValue value, MaaOptionValueSize val_size);

/**
* @brief Get the hash of the resource.
Expand Down
3 changes: 1 addition & 2 deletions include/MaaFramework/MaaDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ extern "C"
{
#endif

typedef struct MaaRect
{
typedef struct MaaRect {
int32_t x;
int32_t y;
int32_t width;
Expand Down
12 changes: 8 additions & 4 deletions include/MaaFramework/Task/MaaCustomAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ extern "C"
* You do not have to implement all the functions in this API. Instead, just implement the functions you need.
* Do note that if an unimplemented function is called, the framework will likely crash.
*/
struct MaaCustomActionAPI
{
MaaBool (*run)(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView custom_action_param,
MaaRectHandle cur_box, MaaStringView cur_rec_detail, MaaTransparentArg action_arg);
struct MaaCustomActionAPI {
MaaBool (*run)(
MaaSyncContextHandle sync_context,
MaaStringView task_name,
MaaStringView custom_action_param,
MaaRectHandle cur_box,
MaaStringView cur_rec_detail,
MaaTransparentArg action_arg);

void (*stop)(MaaTransparentArg action_arg);
};
Expand Down
15 changes: 9 additions & 6 deletions include/MaaFramework/Task/MaaCustomRecognizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@ extern "C"
* You do not have to implement all the functions in this API. Instead, just implement the functions you need.
* Do note that if an unimplemented function is called, the framework will likely crash.
*/
struct MaaCustomRecognizerAPI
{
struct MaaCustomRecognizerAPI {
/// Write the recognition result to the out_box and return true if the recognition is successful.
/// If the recognition fails, return false.
/// You can also write details to the out_detail buffer.
MaaBool (*analyze)(MaaSyncContextHandle sync_context, const MaaImageBufferHandle image, MaaStringView task_name,
MaaStringView custom_recognition_param, MaaTransparentArg recognizer_arg,
/*out*/ MaaRectHandle out_box,
/*out*/ MaaStringBufferHandle out_detail);
MaaBool (*analyze)(
MaaSyncContextHandle sync_context,
const MaaImageBufferHandle image,
MaaStringView task_name,
MaaStringView custom_recognition_param,
MaaTransparentArg recognizer_arg,
/*out*/ MaaRectHandle out_box,
/*out*/ MaaStringBufferHandle out_detail);
};

#ifdef __cplusplus
Expand Down
46 changes: 27 additions & 19 deletions include/MaaFramework/Task/MaaSyncContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,39 @@ extern "C"
{
#endif

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_name, MaaStringView task_param,
MaaRectHandle out_box /**< [out] */,
MaaStringBufferHandle out_detail /**< [out] */);
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
MaaSyncContextRunTask(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView param);
MaaBool MAA_FRAMEWORK_API MaaSyncContextRunRecognizer(
MaaSyncContextHandle sync_context,
MaaImageBufferHandle image,
MaaStringView task_name,
MaaStringView task_param,
MaaRectHandle out_box /**< [out] */,
MaaStringBufferHandle out_detail /**< [out] */);
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);
MaaBool MAA_FRAMEWORK_API MaaSyncContextSwipe(MaaSyncContextHandle sync_context, int32_t x1, int32_t y1, int32_t x2,
int32_t y2, int32_t duration);
MaaBool MAA_FRAMEWORK_API MaaSyncContextSwipe(
MaaSyncContextHandle sync_context, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t duration);
MaaBool MAA_FRAMEWORK_API MaaSyncContextPressKey(MaaSyncContextHandle sync_context, int32_t keycode);
MaaBool MAA_FRAMEWORK_API MaaSyncContextInputText(MaaSyncContextHandle sync_context, MaaStringView text);

MaaBool MAA_FRAMEWORK_API MaaSyncContextTouchDown(MaaSyncContextHandle sync_context, int32_t contact, int32_t x,
int32_t y, int32_t pressure);
MaaBool MAA_FRAMEWORK_API MaaSyncContextTouchMove(MaaSyncContextHandle sync_context, int32_t contact, int32_t x,
int32_t y, int32_t pressure);
MaaBool MAA_FRAMEWORK_API MaaSyncContextTouchDown(
MaaSyncContextHandle sync_context, int32_t contact, int32_t x, int32_t y, int32_t pressure);
MaaBool MAA_FRAMEWORK_API MaaSyncContextTouchMove(
MaaSyncContextHandle sync_context, int32_t contact, int32_t x, int32_t y, int32_t pressure);
MaaBool MAA_FRAMEWORK_API MaaSyncContextTouchUp(MaaSyncContextHandle sync_context, int32_t contact);

MaaBool MAA_FRAMEWORK_API MaaSyncContextScreencap(MaaSyncContextHandle sync_context,
MaaImageBufferHandle out_image /**< [out] */);
MaaBool MAA_FRAMEWORK_API MaaSyncContextGetTaskResult(MaaSyncContextHandle sync_context, MaaStringView task_name,
MaaStringBufferHandle out_task_result /**< [out] */);
MaaBool MAA_FRAMEWORK_API
MaaSyncContextScreencap(MaaSyncContextHandle sync_context, MaaImageBufferHandle out_image /**< [out] */);
MaaBool MAA_FRAMEWORK_API MaaSyncContextGetTaskResult(
MaaSyncContextHandle sync_context,
MaaStringView task_name,
MaaStringBufferHandle out_task_result /**< [out] */);

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions include/MaaFramework/Utility/MaaBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ extern "C"
int32_t MAA_FRAMEWORK_API MaaGetImageWidth(MaaImageBufferHandle handle);
int32_t MAA_FRAMEWORK_API MaaGetImageHeight(MaaImageBufferHandle handle);
int32_t MAA_FRAMEWORK_API MaaGetImageType(MaaImageBufferHandle handle);
MaaBool MAA_FRAMEWORK_API MaaSetImageRawData(MaaImageBufferHandle handle, MaaImageRawData data, int32_t width,
int32_t height, int32_t type);
MaaBool MAA_FRAMEWORK_API MaaSetImageRawData(
MaaImageBufferHandle handle, MaaImageRawData data, int32_t width, int32_t height, int32_t type);

typedef uint8_t* MaaImageEncodedData;
MaaImageEncodedData MAA_FRAMEWORK_API MaaGetImageEncoded(MaaImageBufferHandle handle);
Expand Down
4 changes: 2 additions & 2 deletions include/MaaFramework/Utility/MaaUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ extern "C"
* @param val_size The size of the option value.
* @return MaaBool Whether the option is set successfully.
*/
MaaBool MAA_FRAMEWORK_API MaaSetGlobalOption(MaaGlobalOption key, MaaOptionValue value,
MaaOptionValueSize val_size);
MaaBool MAA_FRAMEWORK_API
MaaSetGlobalOption(MaaGlobalOption key, MaaOptionValue value, MaaOptionValueSize val_size);

#ifdef __cplusplus
}
Expand Down
Loading

0 comments on commit 3e5f699

Please sign in to comment.