mirror of
https://github.com/yokemura/Magical8bitPlug2.git
synced 2025-05-24 23:00:21 -04:00
Merge pull request #24 from yokemura/feature/ParseWarning
Added new parse warning message
This commit is contained in:
commit
47cefdd0e8
@ -153,6 +153,10 @@ void CustomEnvelopeComponent::textEditorTextChanged (TextEditor& editor)
|
|||||||
|
|
||||||
ParseError err = kParseErrorNone;
|
ParseError err = kParseErrorNone;
|
||||||
processor.settingRefs.setSequenceWithString (paramType, txt, &err);
|
processor.settingRefs.setSequenceWithString (paramType, txt, &err);
|
||||||
|
|
||||||
|
ColorScheme cs = ColorScheme (processor.settingRefs.colorSchemeType());
|
||||||
|
Colour c = (err < kParseErrorLevelFatal) ? cs.main : cs.warning;
|
||||||
|
label->setColour (juce::Label::textColourId, c);
|
||||||
|
|
||||||
if (err == kParseErrorValueOutOfRange)
|
if (err == kParseErrorValueOutOfRange)
|
||||||
{
|
{
|
||||||
|
@ -320,5 +320,35 @@ public:
|
|||||||
FrameSequence result29 = parser.parse(input29, 0, 2, &error);
|
FrameSequence result29 = parser.parse(input29, 0, 2, &error);
|
||||||
expect(error = kParseErrorValueOutOfRange);
|
expect(error = kParseErrorValueOutOfRange);
|
||||||
|
|
||||||
|
beginTest ("Empty segment warning(pre-repeat)");
|
||||||
|
error = kParseErrorNone;
|
||||||
|
String input30 = "[1]|2";
|
||||||
|
FrameSequence result30 = parser.parse(input30, 0, 2, &error);
|
||||||
|
expect(result30.valueAt(0) == 1);
|
||||||
|
expect(result30.valueAt(1) == 2);
|
||||||
|
expect(result30.loopStartIndex == 0);
|
||||||
|
expect(result30.releaseSequenceStartIndex == 1);
|
||||||
|
expect(error = kParseWarningPreRepeatSegmentEmpty);
|
||||||
|
|
||||||
|
beginTest ("Empty segment warning(in-repeat)");
|
||||||
|
error = kParseErrorNone;
|
||||||
|
String input31 = "1[]|2";
|
||||||
|
FrameSequence result31 = parser.parse(input31, 0, 2, &error);
|
||||||
|
expect(result31.valueAt(0) == 1);
|
||||||
|
expect(result31.valueAt(1) == 2);
|
||||||
|
expect(result31.loopStartIndex == 1);
|
||||||
|
expect(result31.releaseSequenceStartIndex == 1);
|
||||||
|
expect(error = kParseWarningRepeatSegmentEmpty);
|
||||||
|
|
||||||
|
beginTest ("Empty segment warning(after release)");
|
||||||
|
error = kParseErrorNone;
|
||||||
|
String input32 = "1[2]|";
|
||||||
|
FrameSequence result32 = parser.parse(input32, 0, 2, &error);
|
||||||
|
expect(result32.valueAt(0) == 1);
|
||||||
|
expect(result32.valueAt(1) == 2);
|
||||||
|
expect(result32.loopStartIndex == 1);
|
||||||
|
expect(result32.releaseSequenceStartIndex == 2);
|
||||||
|
expect(error = kParseWarningReleaseSegmentEmpty);
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -14,6 +14,18 @@ String getParseErrorString (ParseError err, int minValue, int maxValue)
|
|||||||
{
|
{
|
||||||
switch (err)
|
switch (err)
|
||||||
{
|
{
|
||||||
|
case kParseWarningPreRepeatSegmentEmpty:
|
||||||
|
return TRANS ("Main body of the sequence is empty");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kParseWarningRepeatSegmentEmpty:
|
||||||
|
return TRANS ("Repeat section is empty");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kParseWarningReleaseSegmentEmpty:
|
||||||
|
return TRANS ("Release section is empty");
|
||||||
|
break;
|
||||||
|
|
||||||
case kParseErrorDuplicatedReleaseDelimiter:
|
case kParseErrorDuplicatedReleaseDelimiter:
|
||||||
return TRANS ("You cannot use \"|\" more than once");
|
return TRANS ("You cannot use \"|\" more than once");
|
||||||
break;
|
break;
|
||||||
|
@ -15,6 +15,9 @@ enum ParseError
|
|||||||
{
|
{
|
||||||
kParseErrorNone = 0,
|
kParseErrorNone = 0,
|
||||||
kParseErrorLevelWarning,
|
kParseErrorLevelWarning,
|
||||||
|
kParseWarningPreRepeatSegmentEmpty,
|
||||||
|
kParseWarningRepeatSegmentEmpty,
|
||||||
|
kParseWarningReleaseSegmentEmpty,
|
||||||
kParseErrorLevelFatal,
|
kParseErrorLevelFatal,
|
||||||
kParseErrorDuplicatedReleaseDelimiter,
|
kParseErrorDuplicatedReleaseDelimiter,
|
||||||
kParseErrorDuplicatedOpenBracket,
|
kParseErrorDuplicatedOpenBracket,
|
||||||
|
@ -438,6 +438,9 @@ FrameSequence FrameSequenceParser::parse (const String& input,
|
|||||||
{
|
{
|
||||||
return fs;
|
return fs;
|
||||||
}
|
}
|
||||||
|
if (sequence.size() == 0) {
|
||||||
|
*error = kParseWarningPreRepeatSegmentEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
fs.sequence = sequence;
|
fs.sequence = sequence;
|
||||||
fs.sequence.reserve (1000);
|
fs.sequence.reserve (1000);
|
||||||
@ -456,6 +459,10 @@ FrameSequence FrameSequenceParser::parse (const String& input,
|
|||||||
{
|
{
|
||||||
return fs;
|
return fs;
|
||||||
}
|
}
|
||||||
|
if (repeatSeq.size() == 0) {
|
||||||
|
// Repeat section is defined but content is empty
|
||||||
|
*error = kParseWarningRepeatSegmentEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
// Add the result to working frameSequence
|
// Add the result to working frameSequence
|
||||||
fs.sequence.insert (fs.sequence.end(), repeatSeq.begin(), repeatSeq.end());
|
fs.sequence.insert (fs.sequence.end(), repeatSeq.begin(), repeatSeq.end());
|
||||||
@ -477,6 +484,10 @@ FrameSequence FrameSequenceParser::parse (const String& input,
|
|||||||
{
|
{
|
||||||
return fs;
|
return fs;
|
||||||
}
|
}
|
||||||
|
if (releaseSeq.size() == 0) {
|
||||||
|
// Release section is defined but content is empty
|
||||||
|
*error = kParseWarningRepeatSegmentEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
// Add the result to working frameSequence
|
// Add the result to working frameSequence
|
||||||
fs.sequence.insert (fs.sequence.end(), releaseSeq.begin(), releaseSeq.end());
|
fs.sequence.insert (fs.sequence.end(), releaseSeq.begin(), releaseSeq.end());
|
||||||
|
Loading…
Reference in New Issue
Block a user