Format the code via clang-format

This commit is contained in:
Maschell 2022-07-24 17:07:42 +02:00
parent 0c8f5afbb1
commit d9f6b0a237
33 changed files with 341 additions and 242 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,9 +6,16 @@ on:
- main
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 ./source
build-binary:
runs-on: ubuntu-18.04
needs: clang-format
steps:
- uses: actions/checkout@v2
- name: Checkout submodules using a PAT
@ -63,4 +70,4 @@ jobs:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip
asset_name: ${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip
asset_content_type: application/unknown
asset_content_type: application/zip

View File

@ -3,8 +3,34 @@ 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 ./source
check-build-with-logging:
runs-on: ubuntu-18.04
needs: clang-format
steps:
- uses: actions/checkout@v2
- name: Checkout submodules using a PAT
run: |
git config --file .gitmodules --get-regexp url | while read url; do
git config --file=.gitmodules $(echo "$url" | sed -E "s/git@github.com:|https:\/\/github.com\//https:\/\/${{ secrets.CI_PAT }}:${{ secrets.CI_PAT }}@github.com\//")
done
git submodule sync
git submodule update --init --recursive
- name: build binary with logging
run: |
docker build . -t builder
docker run --rm -v ${PWD}:/project builder make DEBUG=VERBOSE
docker run --rm -v ${PWD}:/project builder make clean
docker run --rm -v ${PWD}:/project builder make DEBUG=1
build-binary:
runs-on: ubuntu-18.04
needs: clang-format
steps:
- uses: actions/checkout@v2
- name: Checkout submodules using a PAT

View File

@ -1,10 +1,10 @@
#include "ApplicationState.h"
#include "utils/WiiUScreen.h"
#include "../build/safe_payload.h"
#include "utils/ScreenUtils.h"
#include "utils/StringTools.h"
#include "../build/safe_payload.h"
#include <sysapp/launch.h>
#include "utils/WiiUScreen.h"
#include <iosuhax.h>
#include <sysapp/launch.h>
extern "C" void OSShutdown();
@ -132,8 +132,7 @@ void ApplicationState::changeState(eGameState newState) {
} else if (this->state == STATE_BOOT_MENU) {
menu.addText("System is currently booting into: ");
std::string titleId = StringTools::strfmt("%ll016X", this->coldbootTitleId);
std::string titleName = this->coldbootTitle ?
std::string(this->coldbootTitle->name) : "Unknown title";
std::string titleName = this->coldbootTitle ? std::string(this->coldbootTitle->name) : "Unknown title";
menu.addText(titleId + " (" + titleName + ")");
menu.addText();
if (this->systemXMLRestorePossible && this->systemXMLAlreadyPatched) {
@ -209,8 +208,7 @@ void ApplicationState::update(Input *input) {
changeState(STATE_INSTALL_FST);
}
} else if (this->state == STATE_INSTALL_FST) {
auto result = (this->fstAlreadyPatched) ? InstallerService::SUCCESS :
InstallerService::patchFST(this->appInfo->path, this->appInfo->fstHash);
auto result = (this->fstAlreadyPatched) ? InstallerService::SUCCESS : InstallerService::patchFST(this->appInfo->path, this->appInfo->fstHash);
if (result != InstallerService::SUCCESS) {
this->installerError = result;
setError(ERROR_INSTALLER_ERROR);
@ -218,8 +216,7 @@ void ApplicationState::update(Input *input) {
changeState(STATE_INSTALL_COS);
}
} else if (this->state == STATE_INSTALL_COS) {
auto result = (this->cosAlreadyPatched) ? InstallerService::SUCCESS :
InstallerService::patchCOS(this->appInfo->path, this->appInfo->cosHash);
auto result = (this->cosAlreadyPatched) ? InstallerService::SUCCESS : InstallerService::patchCOS(this->appInfo->path, this->appInfo->cosHash);
if (result != InstallerService::SUCCESS) {
this->installerError = result;
setError(ERROR_INSTALLER_ERROR);

View File

@ -1,15 +1,14 @@
#pragma once
#include <string>
#include <optional>
#include <input/Input.h>
#include "common/common.h"
#include "InstallerService.h"
#include "Menu.h"
#include "common/common.h"
#include <input/Input.h>
#include <optional>
#include <string>
class ApplicationState {
public:
enum eErrorState {
ERROR_NONE,
ERROR_IOSUHAX_FAILED,

View File

@ -1,19 +1,19 @@
#include "common/common.h"
#include "utils/logger.h"
#include "utils/WiiUScreen.h"
#include "utils/StringTools.h"
#include "fs/FSUtils.h"
#include "common/fst_structs.h"
#include "InstallerService.h"
#include "utils/utils.h"
#include "common/common.h"
#include "common/fst_structs.h"
#include "fs/FSUtils.h"
#include "utils/StringTools.h"
#include "utils/WiiUScreen.h"
#include "utils/logger.h"
#include "utils/pugixml.hpp"
#include "utils/utils.h"
#include <coreinit/mcp.h>
#include <string>
#include <memory>
#include <cstdlib>
#include <malloc.h>
#include <sstream>
#include <iosuhax.h>
#include <malloc.h>
#include <memory>
#include <sstream>
#include <string>
InstallerService::eResults InstallerService::checkCOS(const std::string &path, char *hash) {
std::string cosFilePath = path + "/code/cos.xml";
@ -343,7 +343,6 @@ std::string InstallerService::ErrorMessage(InstallerService::eResults error) {
} else {
return "UNKNOWN ERROR";
}
}
bool InstallerService::isBackupAvailable(const std::string &path) {
@ -789,4 +788,3 @@ InstallerService::eResults InstallerService::setBootTitle(uint64_t titleId) {
return SUCCESS;
}

View File

@ -1,9 +1,9 @@
#pragma once
#include "utils/pugixml.hpp"
#include "common/common.h"
#include <optional>
#include "utils/pugixml.hpp"
#include <coreinit/memorymap.h>
#include <optional>
class InstallerService {
public:

View File

@ -1,11 +1,12 @@
#pragma once
#include <string>
#include <functional>
#include <utility>
#include <list>
#include "utils/WiiUScreen.h"
#include "input/Input.h"
#include "utils/ScreenUtils.h"
#include "utils/WiiUScreen.h"
#include <functional>
#include <list>
#include <string>
#include <utility>
template<typename T>
class Menu {

View File

@ -1,3 +1,4 @@
// clang-format off
#include "common.h"
systemXMLInformation systemXMLHashInformation[] = {

View File

@ -1,7 +1,7 @@
#pragma once
#include <cstdint>
#include <coreinit/mcp.h>
#include <cstdint>
#ifdef __cplusplus
extern "C" {

View File

@ -59,4 +59,3 @@ WUT_CHECK_OFFSET(FSTNodeEntry, 0x08, file.size);
WUT_CHECK_OFFSET(FSTNodeEntry, 0x0C, permission);
WUT_CHECK_OFFSET(FSTNodeEntry, 0x0E, sectionNumber);
WUT_CHECK_SIZE(FSTNodeEntry, 0x10);

View File

@ -1,7 +1,7 @@
#include "CFile.hpp"
#include <stdarg.h>
#include <stdio.h>
#include <strings.h>
#include "CFile.hpp"
CFile::CFile() {
iFd = -1;
@ -169,5 +169,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

@ -1,11 +1,11 @@
#include <malloc.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include "FSUtils.h"
#include "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
@ -171,4 +171,3 @@ int32_t FSUtils::saveBufferToFile(const char *path, const void *buffer, uint32_t
file.close();
return written;
}

View File

@ -1,7 +1,7 @@
#pragma once
#include <wut_types.h>
#include <string>
#include <wut_types.h>
class FSUtils {
public:

View File

@ -1,4 +1,5 @@
#pragma once
#include "Input.h"
class CombinedInput : public Input {
public:

View File

@ -1,7 +1,7 @@
#pragma once
#include <cstring>
#include <cstdint>
#include <cstring>
class Input {
public:
@ -57,5 +57,4 @@ public:
PadData data{};
PadData lastData{};
};

View File

@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <vpad/input.h>
#include "Input.h"
#include <vpad/input.h>
class VPadInput : public Input {
public:

View File

@ -16,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "Input.h"
#include <padscore/kpad.h>
#include <padscore/wpad.h>
#include "Input.h"
class WPADInput : public Input {
public:

View File

@ -1,20 +1,20 @@
#include <coreinit/debug.h>
#include <whb/proc.h>
#include <whb/log.h>
#include <whb/log_udp.h>
#include <whb/proc.h>
#include "InstallerService.h"
#include "utils/WiiUScreen.h"
#include <input/CombinedInput.h>
#include <input/VPADInput.h>
#include <input/WPADInput.h>
#include <iosuhax.h>
#include <iosuhax_devoptab.h>
#include <string_view>
#include <input/WPADInput.h>
#include <input/VPADInput.h>
#include <input/CombinedInput.h>
#include "utils/WiiUScreen.h"
#include "InstallerService.h"
#include "ApplicationState.h"
#include "../build/safe_payload.h"
#include "ApplicationState.h"
constexpr bool strings_equal(char const *a, char const *b) {
return std::string_view(a) == b;
@ -38,8 +38,7 @@ int main_loop() {
WPAD_CHAN_0,
WPAD_CHAN_1,
WPAD_CHAN_2,
WPAD_CHAN_3
};
WPAD_CHAN_3};
if (sFSAFd < 0 || !sIosuhaxMount) {
state.setError(ApplicationState::eErrorState::ERROR_IOSUHAX_FAILED);

View File

@ -14,8 +14,9 @@
* 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 <coreinit/screen.h>
#include "ScreenUtils.h"
#include <coreinit/screen.h>
#include <stdint.h>
void ScreenUtils::printTextOnScreen(ConsoleScreenID screen, int x, int y, const char *msg) {
if (!msg) {

View File

@ -15,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#pragma once
#include <stdint.h>
//! Defines the ID of a display usable with OSScreen.
typedef enum ConsoleScreenID {

View File

@ -23,17 +23,16 @@
*
* for WiiXplorer 2010
***************************************************************************/
#include <vector>
#include <string>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include <strings.h>
#include <wut_types.h>
#include <stdio.h>
#include "StringTools.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <strings.h>
#include <vector>
#include <wchar.h>
#include <wut_types.h>
BOOL StringTools::EndsWith(const std::string &a, const std::string &b) {
@ -214,8 +213,7 @@ 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

@ -25,11 +25,11 @@
***************************************************************************/
#pragma once
#include <vector>
#include <string>
#include <wut_types.h>
#include <algorithm>
#include <cctype>
#include <string>
#include <vector>
#include <wut_types.h>
class StringTools {
public:

View File

@ -1,3 +1,4 @@
// clang-format off
/*
*
* TinySHA1 - a header only implementation of the SHA1 algorithm in C++. Based

View File

@ -3,21 +3,22 @@
#include <whb/log.h>
#include <whb/log_console.h>
#include <coreinit/memheap.h>
#include "logger.h"
#include <coreinit/cache.h>
#include <coreinit/memfrmheap.h>
#include <coreinit/memheap.h>
#include <coreinit/memory.h>
#include <coreinit/screen.h>
#include <proc_ui/procui.h>
#include <cstring>
#include "logger.h"
#include <proc_ui/procui.h>
#define NUM_LINES (16)
#define LINE_LENGTH (128)
#define CONSOLE_FRAME_HEAP_TAG (0x000DECAF)
#define PRINTF_BUFFER_LENGTH 2048
#define DEBUG_CONSOLE_LOG(FMT, ARGS...)do { \
#define DEBUG_CONSOLE_LOG(FMT, ARGS...) \
do { \
DEBUG_FUNCTION_LINE(FMT, ##ARGS); \
WiiUScreen::drawLinef(FMT, ##ARGS); \
} while (0)

View File

@ -10,11 +10,13 @@ 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);

View File

@ -1,3 +1,4 @@
// clang-format off
/**
* pugixml parser - version 1.10
* --------------------------------------------------------

View File

@ -1,3 +1,4 @@
// clang-format off
/**
* pugixml parser - version 1.10
* --------------------------------------------------------

View File

@ -1,3 +1,4 @@
// clang-format off
/**
* pugixml parser - version 1.10
* --------------------------------------------------------

View File

@ -1,10 +1,10 @@
#include <string.h>
#include <stddef.h>
#include <whb/log.h>
#include <fs/FSUtils.h>
#include "logger.h"
#include "utils.h"
#include "TinySHA1.hpp"
#include "logger.h"
#include <fs/FSUtils.h>
#include <stddef.h>
#include <string.h>
#include <whb/log.h>
// https://gist.github.com/ccbrown/9722406
void Utils::dumpHex(const void *data, size_t size) {

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)