Revert "style fixes"

This reverts commit 15d47d0aae.
This commit is contained in:
tildearrow 2024-08-19 02:49:14 -05:00
parent 73c61d9ac7
commit f1de0bf2b7
3 changed files with 42 additions and 42 deletions

View file

@ -365,19 +365,19 @@ void DivInstrument::writeFeatureFM(SafeWriter* w, bool fui) {
} }
void MemPatch::clear() { void MemPatch::clear() {
data = NULL; data = nullptr;
offset=0; offset = 0;
size=0; size = 0;
} }
bool MemPatch::calcDiff(const void* pre, const void* post, size_t inputSize) { bool MemPatch::calcDiff(const void* pre, const void* post, size_t inputSize) {
bool diffValid=false; bool diffValid = false;
size_t firstDiff=0; size_t firstDiff = 0;
size_t lastDiff=0; size_t lastDiff = 0;
const unsigned char* preBytes=(const unsigned char*)pre; const uint8_t* preBytes = (const uint8_t*)pre;
const unsigned char* postBytes=(const unsigned char*)post; const uint8_t* postBytes = (const uint8_t*)post;
for (size_t ii=0; ii<inputSize; ++ii) { for (size_t ii = 0; ii < inputSize; ++ii) {
if (preBytes[ii] != postBytes[ii]) { if (preBytes[ii] != postBytes[ii]) {
lastDiff=ii; lastDiff=ii;
firstDiff=diffValid ? firstDiff : ii; firstDiff=diffValid ? firstDiff : ii;
@ -386,27 +386,27 @@ bool MemPatch::calcDiff(const void* pre, const void* post, size_t inputSize) {
} }
if (diffValid) { if (diffValid) {
offset=firstDiff; offset = firstDiff;
size=lastDiff - firstDiff + 1; size = lastDiff - firstDiff + 1;
data=new unsigned char[size]; data = new uint8_t[size];
// the diff is to make pre into post (MemPatch is general, not specific to // the diff is to make pre into post (MemPatch is general, not specific to
// undo), so copy from postBytes // undo), so copy from postBytes
memcpy(data, postBytes+offset, size); memcpy(data, postBytes + offset, size);
} }
return diffValid; return diffValid;
} }
void MemPatch::applyAndReverse(void* target, size_t targetSize) { void MemPatch::applyAndReverse(void* target, size_t targetSize) {
if (size==0) return; if (size == 0) { return; }
assert(offset+size<=targetSize); assert(offset + size <= targetSize);
unsigned char* targetBytes=(unsigned char*)target; uint8_t* targetBytes = (uint8_t*)target;
// swap this->data and its segment on target // swap this->data and its segment on target
for (size_t ii=0; ii<size; ++ii) { for (size_t ii = 0; ii < size; ++ii) {
unsigned char tmp=targetBytes[offset+ii]; uint8_t tmp = targetBytes[offset + ii];
targetBytes[offset+ii] = data[ii]; targetBytes[offset + ii] = data[ii];
data[ii] = tmp; data[ii] = tmp;
} }
} }
@ -424,13 +424,13 @@ void DivInstrumentUndoStep::applyAndReverse(DivInstrument* target) {
} }
bool DivInstrumentUndoStep::makeUndoPatch(size_t processTime_, const DivInstrument* pre, const DivInstrument* post) { bool DivInstrumentUndoStep::makeUndoPatch(size_t processTime_, const DivInstrument* pre, const DivInstrument* post) {
processTime=processTime_; processTime = processTime_;
// create the patch that will make post into pre // create the patch that will make post into pre
podPatch.calcDiff((const DivInstrumentPOD*)post, (const DivInstrumentPOD*)pre, sizeof(DivInstrumentPOD)); podPatch.calcDiff((const DivInstrumentPOD*)post, (const DivInstrumentPOD*)pre, sizeof(DivInstrumentPOD));
if (pre->name!=post->name != 0) { if (pre->name.compare(post->name) != 0) {
nameValid=true; nameValid = true;
name=pre->name; name = pre->name;
} }
return nameValid || podPatch.isValid(); return nameValid || podPatch.isValid();
@ -443,7 +443,7 @@ void DivInstrument::recordUndoStepIfChanged(size_t processTime, const DivInstrum
if (step.makeUndoPatch(processTime, old, this)) { if (step.makeUndoPatch(processTime, old, this)) {
// make room // make room
if (undoHist.size()>=undoHist.capacity()) { if (undoHist.size() >= undoHist.capacity()) {
DivInstrumentUndoStep* step = undoHist.front(); DivInstrumentUndoStep* step = undoHist.front();
delete step; delete step;
undoHist.pop_front(); undoHist.pop_front();
@ -455,8 +455,8 @@ void DivInstrument::recordUndoStepIfChanged(size_t processTime, const DivInstrum
redoHist.pop_back(); redoHist.pop_back();
} }
DivInstrumentUndoStep* stepPtr=new DivInstrumentUndoStep; DivInstrumentUndoStep* stepPtr = new DivInstrumentUndoStep;
*stepPtr=step; *stepPtr = step;
step.clear(); // don't let it delete the data ptr that's been copied! step.clear(); // don't let it delete the data ptr that's been copied!
undoHist.push_back(stepPtr); undoHist.push_back(stepPtr);
@ -465,16 +465,16 @@ void DivInstrument::recordUndoStepIfChanged(size_t processTime, const DivInstrum
} }
int DivInstrument::undo() { int DivInstrument::undo() {
if (undoHist.empty()) return 0; if (undoHist.empty()) { return 0; }
DivInstrumentUndoStep* step=undoHist.back(); DivInstrumentUndoStep* step = undoHist.back();
undoHist.pop_back(); undoHist.pop_back();
logI("DivInstrument::undo (%u off, %u size)", step->podPatch.offset, step->podPatch.size); logI("DivInstrument::undo (%u off, %u size)", step->podPatch.offset, step->podPatch.size);
step->applyAndReverse(this); step->applyAndReverse(this);
// make room // make room
if (redoHist.size()>=redoHist.capacity()) { if (redoHist.size() >= redoHist.capacity()) {
DivInstrumentUndoStep* step=redoHist.front(); DivInstrumentUndoStep* step = redoHist.front();
delete step; delete step;
redoHist.pop_front(); redoHist.pop_front();
} }
@ -484,7 +484,7 @@ int DivInstrument::undo() {
} }
int DivInstrument::redo() { int DivInstrument::redo() {
if (redoHist.empty()) return 0; if (redoHist.empty()) { return 0; }
DivInstrumentUndoStep* step = redoHist.back(); DivInstrumentUndoStep* step = redoHist.back();
redoHist.pop_back(); redoHist.pop_back();
@ -492,8 +492,8 @@ int DivInstrument::redo() {
step->applyAndReverse(this); step->applyAndReverse(this);
// make room // make room
if (undoHist.size()>=undoHist.capacity()) { if (undoHist.size() >= undoHist.capacity()) {
DivInstrumentUndoStep* step=undoHist.front(); DivInstrumentUndoStep* step = undoHist.front();
delete step; delete step;
undoHist.pop_front(); undoHist.pop_front();
} }

View file

@ -888,7 +888,7 @@ struct DivInstrumentPOD {
struct MemPatch { struct MemPatch {
MemPatch() : MemPatch() :
data(NULL) data(nullptr)
, offset(0) , offset(0)
, size(0) { , size(0) {
} }
@ -902,9 +902,9 @@ struct MemPatch {
void clear(); void clear();
bool calcDiff(const void* pre, const void* post, size_t size); bool calcDiff(const void* pre, const void* post, size_t size);
void applyAndReverse(void* target, size_t inputSize); void applyAndReverse(void* target, size_t inputSize);
bool isValid() const { return size>0; } bool isValid() const { return size > 0; }
unsigned char* data; uint8_t* data;
size_t offset; size_t offset;
size_t size; size_t size;
}; };

View file

@ -5250,7 +5250,7 @@ void FurnaceGUI::drawInsEdit() {
ImGui::SetNextWindowSizeConstraints(ImVec2(440.0f*dpiScale,400.0f*dpiScale),ImVec2(canvasW,canvasH)); ImGui::SetNextWindowSizeConstraints(ImVec2(440.0f*dpiScale,400.0f*dpiScale),ImVec2(canvasW,canvasH));
} }
if (ImGui::Begin("Instrument Editor",&insEditOpen,globalWinFlags|(settings.allowEditDocking?0:ImGuiWindowFlags_NoDocking),_("Instrument Editor"))) { if (ImGui::Begin("Instrument Editor",&insEditOpen,globalWinFlags|(settings.allowEditDocking?0:ImGuiWindowFlags_NoDocking),_("Instrument Editor"))) {
DivInstrument* ins=NULL; DivInstrument* ins=nullptr;
if (curIns==-2) { if (curIns==-2) {
ImGui::SetCursorPosY(ImGui::GetCursorPosY()+(ImGui::GetContentRegionAvail().y-ImGui::GetFrameHeightWithSpacing()+ImGui::GetStyle().ItemSpacing.y)*0.5f); ImGui::SetCursorPosY(ImGui::GetCursorPosY()+(ImGui::GetContentRegionAvail().y-ImGui::GetFrameHeightWithSpacing()+ImGui::GetStyle().ItemSpacing.y)*0.5f);
CENTER_TEXT(_("waiting...")); CENTER_TEXT(_("waiting..."));
@ -7742,8 +7742,8 @@ void FurnaceGUI::drawInsEdit() {
} }
if (ins) { if (ins) {
bool insChanged=ins!=cachedCurInsPtr; bool insChanged = ins != cachedCurInsPtr;
bool delayDiff=ImGui::IsMouseDown(ImGuiMouseButton_Left) || ImGui::IsMouseDown(ImGuiMouseButton_Right) || ImGui::GetIO().WantCaptureKeyboard; bool delayDiff = ImGui::IsMouseDown(ImGuiMouseButton_Left) || ImGui::IsMouseDown(ImGuiMouseButton_Right) || ImGui::GetIO().WantCaptureKeyboard;
// check against the last cached to see if diff -- note that modifications to instruments happen outside // check against the last cached to see if diff -- note that modifications to instruments happen outside
// drawInsEdit (e.g. cursor inputs are processed and can directly modify macro data) // drawInsEdit (e.g. cursor inputs are processed and can directly modify macro data)
@ -7752,12 +7752,12 @@ void FurnaceGUI::drawInsEdit() {
} }
if (insChanged || !delayDiff) { if (insChanged || !delayDiff) {
cachedCurIns=*ins; cachedCurIns = *ins;
} }
cachedCurInsPtr=ins; cachedCurInsPtr = ins;
} else { } else {
cachedCurInsPtr=NULL; cachedCurInsPtr = nullptr;
} }
} }