Merge pull request #17 from wiiu-env/clang_format

Format the code via clang-format [no-ci]
This commit is contained in:
Maschell 2022-02-03 17:11:27 +01:00 committed by GitHub
commit 807f7ea68b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 448 additions and 381 deletions

67
.clang-format Normal file
View File

@ -0,0 +1,67 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignOperands: Align
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 0
CompactNamespaces: false
ContinuationIndentWidth: 8
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Right
ReflowComments: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Never

View File

@ -6,8 +6,16 @@ on:
- master
jobs:
clang-format:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src
build-binary:
runs-on: ubuntu-18.04
needs: clang-format
steps:
- uses: actions/checkout@v2
- name: build binary

View File

@ -3,8 +3,16 @@ name: CI-PR
on: [pull_request]
jobs:
clang-format:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src
build-binary:
runs-on: ubuntu-18.04
needs: clang-format
steps:
- uses: actions/checkout@v2
- name: build binary

View File

@ -14,21 +14,21 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "Application.h"
#include "common/common.h"
#include "resources/Resources.h"
#include "utils/AsyncExecutor.h"
#include "utils/logger.h"
#include <coreinit/core.h>
#include <coreinit/foreground.h>
#include <coreinit/title.h>
#include <proc_ui/procui.h>
#include <sysapp/launch.h>
#include "Application.h"
#include "common/common.h"
#include <gui/FreeTypeGX.h>
#include <gui/VPadController.h>
#include <gui/WPadController.h>
#include "resources/Resources.h"
#include <gui/sounds/SoundHandler.hpp>
#include <gui/memory.h>
#include "utils/logger.h"
#include "utils/AsyncExecutor.h"
#include <gui/sounds/SoundHandler.hpp>
#include <proc_ui/procui.h>
#include <sysapp/launch.h>
#include <thread>
Application *Application::applicationInstance = nullptr;
@ -94,9 +94,7 @@ void Application::quit(int32_t code) {
}
void Application::fadeOut() {
GuiImage fadeOut(video->getTvWidth(), video->getTvHeight(), (GX2Color) {
0, 0, 0, 255
});
GuiImage fadeOut(video->getTvWidth(), video->getTvHeight(), (GX2Color){0, 0, 0, 255});
for (int32_t i = 0; i < 255; i += 10) {
if (i > 255)
@ -185,7 +183,6 @@ bool Application::procUI() {
DEBUG_FUNCTION_LINE("Initialize main window");
mainWindow = new MainWindow(video->getTvWidth(), video->getTvHeight());
}
}
executeProcess = true;
}

View File

@ -18,8 +18,8 @@
#define _APPLICATION_H
#include "menu/MainWindow.h"
#include <gui/video/CVideo.h>
#include "system/CThread.h"
#include <gui/video/CVideo.h>
// forward declaration
class FreeTypeGX;
@ -77,7 +77,6 @@ private:
GuiController *controller[5]{};
int exitCode;
BOOL sFromHBL = FALSE;
};
#endif //_APPLICATION_H

View File

@ -13,4 +13,3 @@ extern "C" {
#endif
#endif /* COMMON_H */

View File

@ -1,9 +1,9 @@
#include "common/common.h"
#include <whb/log_cafe.h>
#include <whb/log_udp.h>
#include <whb/log_module.h>
#include "utils/logger.h"
#include "Application.h"
#include "common/common.h"
#include "utils/logger.h"
#include <whb/log_cafe.h>
#include <whb/log_module.h>
#include <whb/log_udp.h>
int32_t main(int32_t argc, char **argv) {
bool moduleInit;

View File

@ -1,9 +1,9 @@
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#include <fs/CFile.hpp>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
CFile::CFile() {
iFd = -1;
@ -171,5 +171,3 @@ int32_t CFile::fwrite(const char *format, ...) {
return result;
}

View File

@ -1,10 +1,10 @@
#ifndef CFILE_HPP_
#define CFILE_HPP_
#include <stdio.h>
#include <string>
#include <string.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <unistd.h>
#include <wut_types.h>

View File

@ -24,14 +24,14 @@
* DirList Class
* for WiiXplorer 2010
***************************************************************************/
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <strings.h>
#include <algorithm>
#include <sys/stat.h>
#include <sys/dirent.h>
#include <sys/stat.h>
#include <fs/DirList.h>
#include <utils/StringTools.h>

View File

@ -27,8 +27,8 @@
#ifndef ___DIRLIST_H_
#define ___DIRLIST_H_
#include <vector>
#include <string>
#include <vector>
#include <wut_types.h>
typedef struct {
@ -97,6 +97,7 @@ public:
Dirs = 0x02,
CheckSubfolders = 0x08,
};
protected:
// Internal parser
BOOL InternalLoadPath(std::string &path);

View File

@ -1,11 +1,11 @@
#include <malloc.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include "fs/FSUtils.h"
#include "fs/CFile.hpp"
#include "utils/logger.h"
#include <fcntl.h>
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_t *size) {
//! always initialze input
@ -139,4 +139,3 @@ int32_t FSUtils::saveBufferToFile(const char *path, void *buffer, uint32_t size)
file.close();
return written;
}

View File

@ -1,14 +1,14 @@
#include <algorithm>
#include <string>
#include <string.h>
#include <coreinit/cache.h>
#include <coreinit/mcp.h>
#include <nn/acp/nn_acp_types.h>
#include <nn/acp/title.h>
#include <coreinit/cache.h>
#include <string.h>
#include <string>
#include "utils/AsyncExecutor.h"
#include "GameList.h"
#include "common/common.h"
#include "utils/AsyncExecutor.h"
#include "fs/FSUtils.h"
#include "utils/logger.h"

View File

@ -1,13 +1,13 @@
#ifndef GAME_LIST_H_
#define GAME_LIST_H_
#include <vector>
#include <coreinit/cache.h>
#include <coreinit/mcp.h>
#include <gui/GuiImageData.h>
#include <gui/sigslot.h>
#include <mutex>
#include <stdint.h>
#include <coreinit/mcp.h>
#include <coreinit/cache.h>
#include <gui/sigslot.h>
#include <gui/GuiImageData.h>
#include <vector>
typedef struct _gameInfo {
uint64_t titleId;

View File

@ -1,11 +1,11 @@
#include "GameIcon.h"
#include "GameIconModel.h"
#include "Application.h"
#include "GameIconModel.h"
#include "utils/logger.h"
#include "utils/utils.h"
#include <gui/video/CVideo.h>
#include <gui/video/shaders/Shader3D.h>
#include <gui/video/shaders/ShaderFractalColor.h>
#include "utils/utils.h"
#include "utils/logger.h"
static const float cfIconMirrorScale = 1.15f;
static const float cfIconMirrorAlpha = 0.45f;

View File

@ -1,6 +1,7 @@
#ifndef ICON_MODEL_H_
#define ICON_MODEL_H_
// clang-format off
static const float cfGameIconPosVtxs[] = {
-0.844501f, -0.861263f, 0.050154f, -0.802664f, -0.8797f, 0.054004f, -0.809968f, -0.828995f, 0.061777f, -0.864233f, -0.822169f, 0.054004f,
-0.802664f, -0.8797f, 0.054004f, -0.726455f, -0.89991f, 0.058224f, -0.730326f, -0.842312f, 0.067487f, -0.809968f, -0.828995f, 0.061777f,

View File

@ -14,16 +14,16 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <map>
#include <algorithm>
#include <gui/GuiIconGrid.h>
#include <gui/GuiController.h>
#include <coreinit/cache.h>
#include "common/common.h"
#include "Application.h"
#include <gui/video/CVideo.h>
#include "utils/logger.h"
#include "common/common.h"
#include "gui/GameIcon.h"
#include "utils/logger.h"
#include <algorithm>
#include <coreinit/cache.h>
#include <gui/GuiController.h>
#include <gui/GuiIconGrid.h>
#include <gui/video/CVideo.h>
#include <map>
GuiIconGrid::GuiIconGrid(int32_t w, int32_t h, uint64_t GameIndex, bool sortByName)
: GuiTitleBrowser(w, h, GameIndex),
@ -268,7 +268,6 @@ void GuiIconGrid::OnLeftClick(GuiButton *button, const GuiController *controller
setSelectedGame(newTitleId);
gameSelectionChanged(this, selectedGame);
}
}
void GuiIconGrid::OnRightClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) {
@ -395,11 +394,9 @@ void GuiIconGrid::OnGameButtonHeld(GuiButton *button, const GuiController *contr
}
void GuiIconGrid::OnGameButtonPointedOn(GuiButton *button, const GuiController *controller) {
}
void GuiIconGrid::OnGameButtonPointedOff(GuiButton *button, const GuiController *controller) {
}
void GuiIconGrid::OnDrag(GuiDragListener *element, const GuiController *controller, GuiTrigger *trigger, int32_t dx, int32_t dy) {

View File

@ -16,13 +16,13 @@
****************************************************************************/
#pragma once
#include <map>
#include "gui/GuiTitleBrowser.h"
#include "gui/GameIcon.h"
#include "gui/GuiDragListener.h"
#include <gui/GuiParticleImage.h>
#include "gui/GuiTitleBrowser.h"
#include "utils/AsyncExecutor.h"
#include "utils/logger.h"
#include <gui/GuiParticleImage.h>
#include <map>
class GuiIconGrid : public GuiTitleBrowser, public sigslot::has_slots<> {
public:
@ -173,6 +173,4 @@ private:
std::vector<GuiImage *> emptyIcons;
std::vector<GuiButton *> emptyButtons;
};

View File

@ -1,8 +1,8 @@
#pragma once
#include "game/GameList.h"
#include <gui/Gui.h>
#include <gui/sigslot.h>
#include "game/GameList.h"
class GuiTitleBrowser : public GuiFrame {
public:

View File

@ -1,25 +1,23 @@
#include "GameSplashScreen.h"
#include "utils/logger.h"
#include "common/common.h"
#include "fs/FSUtils.h"
#include "utils/AsyncExecutor.h"
#include "utils/logger.h"
GameSplashScreen::GameSplashScreen(int32_t w, int32_t h, gameInfo *info, bool onTV) : GuiFrame(w, h),
bgImageColor(w, h, (GX2Color) {
0, 0, 0, 0
}) {
bgImageColor(w, h, (GX2Color){0, 0, 0, 0}) {
bgImageColor.setImageColor((GX2Color){
79, 153, 239, 255
}, 0);
79, 153, 239, 255},
0);
bgImageColor.setImageColor((GX2Color){
79, 153, 239, 255
}, 1);
79, 153, 239, 255},
1);
bgImageColor.setImageColor((GX2Color){
59, 159, 223, 255
}, 2);
59, 159, 223, 255},
2);
bgImageColor.setImageColor((GX2Color){
59, 159, 223, 255
}, 3);
59, 159, 223, 255},
3);
append(&bgImageColor);
this->onTV = onTV;
this->info = info;

View File

@ -1,8 +1,8 @@
#pragma once
#include "game/GameList.h"
#include <gui/GuiImage.h>
#include <gui/GuiFrame.h>
#include <gui/GuiImage.h>
class GameSplashScreen : public GuiFrame, public sigslot::has_slots<> {
public:
@ -15,6 +15,7 @@ public:
virtual void draw(CVideo *v);
sigslot::signal3<GuiElement *, gameInfo *, bool> gameGameSplashScreenFinished;
private:
GuiImage bgImageColor;
GuiImageData *splashScreenData = nullptr;

View File

@ -1,7 +1,7 @@
#include <nn/swkbd.h>
#include "KeyboardHelper.h"
#include "utils/logger.h"
#include <coreinit/memdefaultheap.h>
#include <nn/swkbd.h>
KeyboardHelper::KeyboardHelper() {
auto *_fsClient = (FSClient *) MEMAllocFromDefaultHeap(sizeof(FSClient));

View File

@ -1,7 +1,7 @@
#pragma once
#include <string>
#include <coreinit/filesystem.h>
#include <string>
class KeyboardHelper {
public:
@ -24,7 +24,6 @@ public:
std::string getResult();
private:
void *workMemory = nullptr;
FSClient *fsClient = nullptr;
bool keyboardOpen = false;

View File

@ -69,6 +69,7 @@ public:
sigslot::signal1<GuiElement *> settingsButtonClicked;
sigslot::signal1<GuiElement *> layoutSwitchClicked;
sigslot::signal1<GuiElement *> gameListFilterClicked;
private:
void OnSettingsButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *) {
settingsButtonClicked(this);

View File

@ -16,18 +16,18 @@
****************************************************************************/
#include "MainWindow.h"
#include "Application.h"
#include "utils/logger.h"
#include "utils/StringTools.h"
#include "utils/logger.h"
#include "resources/Resources.h"
#include "gui/GuiTitleBrowser.h"
#include "gui/GuiIconGrid.h"
#include <sysapp/launch.h>
#include <future>
#include <coreinit/title.h>
#include <nn/acp/title.h>
#include "utils/AsyncExecutor.h"
#include "GameSplashScreen.h"
#include "gui/GuiIconGrid.h"
#include "gui/GuiTitleBrowser.h"
#include "resources/Resources.h"
#include "utils/AsyncExecutor.h"
#include <coreinit/title.h>
#include <future>
#include <nn/acp/title.h>
#include <sysapp/launch.h>
MainWindow::MainWindow(int32_t w, int32_t h)
: width(w), height(h), gameClickSound(Resources::GetSound("game_click.mp3")), mainSwitchButtonFrame(nullptr), currentTvFrame(nullptr), currentDrcFrame(nullptr) {
@ -43,7 +43,6 @@ MainWindow::MainWindow(int32_t w, int32_t h)
gameList.titleUpdated.connect(this, &MainWindow::OnGameTitleUpdated);
gameList.titleAdded.connect(this, &MainWindow::OnGameTitleAdded);
AsyncExecutor::execute([&] { gameList.load(); });
}
MainWindow::~MainWindow() {
@ -354,7 +353,6 @@ void MainWindow::OnCloseEffectFinish(GuiElement *element) {
}
void MainWindow::OnSettingsButtonClicked(GuiElement *element) {
}
void MainWindow::OnGameSelectionChange(GuiTitleBrowser *element, uint64_t selectedIdx) {

View File

@ -17,13 +17,13 @@
#ifndef _MAIN_WINDOW_H_
#define _MAIN_WINDOW_H_
#include <vector>
#include <queue>
#include <gui/Gui.h>
#include "game/GameList.h"
#include "KeyboardHelper.h"
#include "gui/GuiTitleBrowser.h"
#include "MainDrcButtonsFrame.h"
#include "game/GameList.h"
#include "gui/GuiTitleBrowser.h"
#include <gui/Gui.h>
#include <queue>
#include <vector>
class CVideo;

View File

@ -1,18 +1,18 @@
#include "Resources.h"
#include "filelist.h"
#include "fs/FSUtils.h"
#include "utils/AsyncExecutor.h"
#include <gui/GuiImageData.h>
#include <gui/GuiSound.h>
#include <malloc.h>
#include <string.h>
#include <string>
#include "Resources.h"
#include "filelist.h"
#include <gui/GuiSound.h>
#include <gui/GuiImageData.h>
#include "fs/FSUtils.h"
#include "utils/AsyncExecutor.h"
#include <chrono>
#include <future>
#include <iostream>
#include <thread>
#include <strings.h>
#include <thread>
Resources *Resources::instance = nullptr;

View File

@ -2,6 +2,7 @@
#include <map>
#include <stdint.h>
#include <string>
//! forward declaration
class GuiImageData;

View File

@ -17,9 +17,9 @@
#ifndef CTHREAD_H_
#define CTHREAD_H_
#include <coreinit/thread.h>
#include <malloc.h>
#include <unistd.h>
#include <coreinit/thread.h>
class CThread {
public:
@ -27,10 +27,7 @@ public:
//! constructor
CThread(int32_t iAttr, int32_t iPriority = 16, int32_t iStackSize = 0x8000, CThread::Callback callback = nullptr, void *callbackArg = nullptr)
: pThread(nullptr)
, pThreadStack(nullptr)
, pCallback(callback)
, pCallbackArg(callbackArg) {
: pThread(nullptr), pThreadStack(nullptr), pCallback(callback), pCallbackArg(callbackArg) {
//! save attribute assignment
iAttributes = iAttr;
//! allocate the thread
@ -122,6 +119,7 @@ public:
eAttributeDetach = 0x08,
eAttributePinnedAff = 0x10
};
private:
static int32_t threadCallback(int32_t argc, const char **argv) {
//! After call to start() continue with the internal function

View File

@ -1,12 +1,12 @@
#pragma once
#include <vector>
#include <future>
#include <thread>
#include <queue>
#include <gui/GuiElement.h>
#include <coreinit/cache.h>
#include "utils/logger.h"
#include <coreinit/cache.h>
#include <future>
#include <gui/GuiElement.h>
#include <queue>
#include <thread>
#include <vector>
class AsyncExecutor {
public:

View File

@ -23,17 +23,16 @@
*
* for WiiXplorer 2010
***************************************************************************/
#include <vector>
#include <string>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include <string.h>
#include <string>
#include <strings.h>
#include <wut_types.h>
#include <stdio.h>
#include <utils/StringTools.h>
#include <vector>
#include <wchar.h>
#include <wut_types.h>
BOOL StringTools::EndsWith(const std::string &a, const std::string &b) {
@ -214,7 +213,6 @@ bool StringTools::findStringIC(const std::string &strHaystack, const std::string
auto it = std::search(
strHaystack.begin(), strHaystack.end(),
strNeedle.begin(), strNeedle.end(),
[](char ch1, char ch2) { return std::toupper(ch1) == std::toupper(ch2); }
);
[](char ch1, char ch2) { return std::toupper(ch1) == std::toupper(ch2); });
return (it != strHaystack.end());
}

View File

@ -26,11 +26,11 @@
#ifndef __STRING_TOOLS_H
#define __STRING_TOOLS_H
#include <vector>
#include <string>
#include <wut_types.h>
#include <algorithm>
#include <cctype>
#include <string>
#include <vector>
#include <wut_types.h>
class StringTools {
public:
@ -91,4 +91,3 @@ public:
};
#endif /* __STRING_TOOLS_H */

View File

@ -1,7 +1,7 @@
#pragma once
#include <whb/log.h>
#include <string.h>
#include <whb/log.h>
#ifdef __cplusplus
extern "C" {
@ -10,15 +10,16 @@ extern "C" {
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) \
do { \
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0)
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) \
do { \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0)
#ifdef __cplusplus
}
#endif

View File

@ -1,9 +1,9 @@
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <string.h>
#include <utils/logger.h>
// https://gist.github.com/ccbrown/9722406

View File

@ -12,7 +12,8 @@ extern "C" {
typeof(x) _x = x; \
typeof(min) _min = min; \
typeof(max) _max = max; \
( ( ( _x ) < ( _min ) ) ? ( _min ) : ( ( _x ) > ( _max ) ) ? ( _max) : ( _x ) ); \
(((_x) < (_min)) ? (_min) : ((_x) > (_max)) ? (_max) \
: (_x)); \
})
#define DegToRad(a) ((a) *0.01745329252f)