Skip to content

Commit

Permalink
Merge pull request SynthstromAudible#40 from bobtwinkles/clang-fmt
Browse files Browse the repository at this point in the history
Tree-Wide Format, take 2
  • Loading branch information
jamiefaye authored Jun 9, 2023
2 parents 1023340 + 8cc1f81 commit f9e1ed5
Show file tree
Hide file tree
Showing 567 changed files with 45,231 additions and 44,588 deletions.
21 changes: 21 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
BasedOnStyle: LLVM
IndentWidth: 4
TabWidth: 4
UseTab: ForIndentation
BreakBeforeBraces: Custom
BraceWrapping:
BeforeElse: True
ColumnLimit: 120
ReflowComments: False
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
IndentGotoLabels: False
PointerAlignment: Left
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeTernaryOperators: True
AccessModifierOffset: -4

# Not sure about this one, it's a lot of changed lines but I also like
# alphabetic ordering
SortIncludes: Never
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8

[*.{c,cpp,h,hpp}]
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true
15 changes: 15 additions & 0 deletions .github/workflows/format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on: [push]
jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run clang-format style check for C/C++ code
uses: DoozyX/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
sourcE: './src'
extensions: 'c,cpp,h,hpp'
clangFormatVersion: 14
6 changes: 6 additions & 0 deletions contrib/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

find src \
\( -name '*.[ch]pp' -or -name '*.[ch]' \) \
-exec echo [+] Format {} \; \
-exec clang-format --style=file -i {} \;
42 changes: 25 additions & 17 deletions src/Action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
#include "ConsequenceNoteArrayChange.h"
#include "ModelStack.h"

Action::Action(int newActionType)
{
Action::Action(int newActionType) {
firstConsequence = NULL;
nextAction = NULL;
type = newActionType;
Expand All @@ -52,7 +51,6 @@ Action::Action(int newActionType)
offset = 0;
}


// Call this before the destructor!
void Action::prepareForDestruction(int whichQueueActionIn, Song* song) {

Expand All @@ -64,7 +62,7 @@ void Action::prepareForDestruction(int whichQueueActionIn, Song* song) {
void Action::deleteAllConsequences(int whichQueueActionIn, Song* song, bool destructing) {
Consequence* currentConsequence = firstConsequence;
while (currentConsequence) {
AudioEngine::routineWithClusterLoading(); // -----------------------------------
AudioEngine::routineWithClusterLoading(); // -----------------------------------
Consequence* toDelete = currentConsequence;
currentConsequence = currentConsequence->next;
toDelete->prepareForDestruction(whichQueueActionIn, song);
Expand Down Expand Up @@ -93,8 +91,6 @@ int Action::revert(int time, ModelStack* modelStack) {
time = BEFORE;
}



Consequence* newFirstConsequence = NULL;

int error = NO_ERROR;
Expand All @@ -116,7 +112,10 @@ int Action::revert(int time, ModelStack* modelStack) {
// Special case for arrangement-record. See big comment above
if (type == ACTION_ARRANGEMENT_RECORD) {
// Delete the old one
thisConsequence->prepareForDestruction(AFTER, modelStack->song); // Have to put AFTER. See the effect this will have in ConsequenceCDelete::prepareForDestruction()
thisConsequence->prepareForDestruction(
AFTER,
modelStack
->song); // Have to put AFTER. See the effect this will have in ConsequenceCDelete::prepareForDestruction()
thisConsequence->~Consequence();
generalMemoryAllocator.dealloc(thisConsequence);
}
Expand All @@ -143,13 +142,14 @@ bool Action::containsConsequenceParamChange(ParamCollection* paramCollection, in
for (Consequence* thisCons = firstConsequence; thisCons; thisCons = thisCons->next) {
if (thisCons->type == CONSEQUENCE_PARAM_CHANGE) {
ConsequenceParamChange* thisConsParamChange = (ConsequenceParamChange*)thisCons;
if (thisConsParamChange->modelStack.paramCollection == paramCollection && thisConsParamChange->modelStack.paramId == paramId) return true;
if (thisConsParamChange->modelStack.paramCollection == paramCollection
&& thisConsParamChange->modelStack.paramId == paramId)
return true;
}
}
return false;
}


void Action::recordParamChangeIfNotAlreadySnapshotted(ModelStackWithAutoParam const* modelStack, bool stealData) {

// If we already have a snapshot of this, we can get out.
Expand Down Expand Up @@ -196,33 +196,36 @@ bool Action::containsConsequenceNoteArrayChange(InstrumentClip* clip, int noteRo
return false;
}

int Action::recordNoteArrayChangeIfNotAlreadySnapshotted(InstrumentClip* clip, int noteRowId, NoteVector* noteVector, bool stealData, bool moveToFrontIfAlreadySnapshotted) {
int Action::recordNoteArrayChangeIfNotAlreadySnapshotted(InstrumentClip* clip, int noteRowId, NoteVector* noteVector,
bool stealData, bool moveToFrontIfAlreadySnapshotted) {
if (containsConsequenceNoteArrayChange(clip, noteRowId, moveToFrontIfAlreadySnapshotted)) return NO_ERROR;

// If we're still here, we need to snapshot.
return recordNoteArrayChangeDefinitely(clip, noteRowId, noteVector, stealData);
}

int Action::recordNoteArrayChangeDefinitely(InstrumentClip* clip, int noteRowId, NoteVector* noteVector, bool stealData) {
int Action::recordNoteArrayChangeDefinitely(InstrumentClip* clip, int noteRowId, NoteVector* noteVector,
bool stealData) {
void* consMemory = generalMemoryAllocator.alloc(sizeof(ConsequenceNoteArrayChange));

if (!consMemory) return ERROR_INSUFFICIENT_RAM;

ConsequenceNoteArrayChange* newCons = new (consMemory) ConsequenceNoteArrayChange(clip, noteRowId, noteVector, stealData);
ConsequenceNoteArrayChange* newCons =
new (consMemory) ConsequenceNoteArrayChange(clip, noteRowId, noteVector, stealData);
addConsequence(newCons);

return NO_ERROR; // Though we wouldn't know if there was a RAM error as ConsequenceNoteArrayChange tried to clone the data...
}


void Action::recordNoteExistenceChange(InstrumentClip* clip, int noteRowId, Note* note, int type) {

if (containsConsequenceNoteArrayChange(clip, noteRowId)) return;

void* consMemory = generalMemoryAllocator.alloc(sizeof(ConsequenceNoteExistence));

if (consMemory) {
ConsequenceNoteExistence* newConsequence = new (consMemory) ConsequenceNoteExistence(clip, noteRowId, note, type);
ConsequenceNoteExistence* newConsequence =
new (consMemory) ConsequenceNoteExistence(clip, noteRowId, note, type);
addConsequence(newConsequence);
}
}
Expand All @@ -232,7 +235,8 @@ void Action::recordClipInstanceExistenceChange(Output* output, ClipInstance* cli
void* consMemory = generalMemoryAllocator.alloc(sizeof(ConsequenceClipInstanceExistence));

if (consMemory) {
ConsequenceClipInstanceExistence* newConsequence = new (consMemory) ConsequenceClipInstanceExistence(output, clipInstance, type);
ConsequenceClipInstanceExistence* newConsequence =
new (consMemory) ConsequenceClipInstanceExistence(output, clipInstance, type);
addConsequence(newConsequence);
}
}
Expand Down Expand Up @@ -287,7 +291,8 @@ void Action::recordAudioClipSampleChange(AudioClip* clip) {
void Action::updateYScrollClipViewAfter(InstrumentClip* clip) {
if (!numClipStates) return;

if (numClipStates != currentSong->sessionClips.getNumElements() + currentSong->arrangementOnlyClips.getNumElements()) {
if (numClipStates
!= currentSong->sessionClips.getNumElements() + currentSong->arrangementOnlyClips.getNumElements()) {
numClipStates = 0;
generalMemoryAllocator.dealloc(clipStates);
clipStates = NULL;
Expand All @@ -313,5 +318,8 @@ void Action::updateYScrollClipViewAfter(InstrumentClip* clip) {

i++;
}
if (clipArray != &currentSong->arrangementOnlyClips) { clipArray = &currentSong->arrangementOnlyClips; goto traverseClips; }
if (clipArray != &currentSong->arrangementOnlyClips) {
clipArray = &currentSong->arrangementOnlyClips;
goto traverseClips;
}
}
17 changes: 8 additions & 9 deletions src/Action.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ class ModelStack;
#define ACTION_NOTEROW_LENGTH_EDIT 25
#define ACTION_NOTEROW_HORIZONTAL_SHIFT 26



class Action {
public:
Action(int newActionType);
Expand All @@ -79,11 +77,13 @@ class Action {
bool containsConsequenceParamChange(ParamCollection* paramCollection, int paramId);
void recordParamChangeIfNotAlreadySnapshotted(ModelStackWithAutoParam const* modelStack, bool stealData = false);
void recordParamChangeDefinitely(ModelStackWithAutoParam const* modelStack, bool stealData);
int recordNoteArrayChangeIfNotAlreadySnapshotted(InstrumentClip* clip, int noteRowId, NoteVector* noteVector, bool stealData, bool moveToFrontIfAlreadySnapshotted = false);
int recordNoteArrayChangeIfNotAlreadySnapshotted(InstrumentClip* clip, int noteRowId, NoteVector* noteVector,
bool stealData, bool moveToFrontIfAlreadySnapshotted = false);
int recordNoteArrayChangeDefinitely(InstrumentClip* clip, int noteRowId, NoteVector* noteVector, bool stealData);
bool containsConsequenceNoteArrayChange(InstrumentClip* clip, int noteRowId, bool moveToFrontIfFound = false);
void recordNoteExistenceChange(InstrumentClip* clip, int noteRowId, Note* note, int type);
void recordNoteChange(InstrumentClip* clip, int noteRowId, Note* note, int32_t lengthAfter, int velocityAfter, int probabilityAfter);
void recordNoteChange(InstrumentClip* clip, int noteRowId, Note* note, int32_t lengthAfter, int velocityAfter,
int probabilityAfter);
void updateYScrollClipViewAfter(InstrumentClip* clip = NULL);
void recordClipInstanceExistenceChange(Output* output, ClipInstance* clipInstance, int type);
void prepareForDestruction(int whichQueueActionIn, Song* song);
Expand Down Expand Up @@ -114,14 +114,13 @@ class Action {
bool tripletsOn;
uint32_t tripletsLevel;

//bool inKeyboardView;

//bool inKeyboardView;

UI* view;
UI* view;

Clip* currentClip; // Watch out - this might get set to NULL
Clip* currentClip; // Watch out - this might get set to NULL

int32_t posToClearArrangementFrom;
int32_t posToClearArrangementFrom;

Action* nextAction;
Consequence* firstConsequence;
Expand Down
7 changes: 2 additions & 5 deletions src/ActionClipState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@
#include "definitions.h"
#include "kit.h"

ActionClipState::ActionClipState()
{
ActionClipState::ActionClipState() {
}

ActionClipState::~ActionClipState()
{
ActionClipState::~ActionClipState() {
}


void ActionClipState::grabFromClip(Clip* thisClip) {
//modKnobMode = thisClip->modKnobMode;

Expand Down
5 changes: 2 additions & 3 deletions src/ActionClipState.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ class ActionClipState {
//uint8_t modKnobMode;
bool affectEntire;
bool wrapEditing;
uint32_t wrapEditLevel;
int selectedDrumIndex; // -1 means none

uint32_t wrapEditLevel;
int selectedDrumIndex; // -1 means none
};

#endif /* ACTIONCLIPSTATE_H_ */
Loading

0 comments on commit f9e1ed5

Please sign in to comment.