Changed the parameter vectors to uint16
This commit is contained in:
parent
a393ff6615
commit
a17f6b9169
3 changed files with 6 additions and 8 deletions
|
|
@ -26,8 +26,6 @@ sfz::Opcode::Opcode(absl::string_view inputOpcode, absl::string_view inputValue)
|
||||||
uint32_t returnedValue;
|
uint32_t returnedValue;
|
||||||
const auto numDigits = (nextCharIndex == opcode.npos) ? opcode.npos : nextCharIndex - nextNumIndex;
|
const auto numDigits = (nextCharIndex == opcode.npos) ? opcode.npos : nextCharIndex - nextNumIndex;
|
||||||
if (absl::SimpleAtoi(opcode.substr(nextNumIndex, numDigits), &returnedValue)) {
|
if (absl::SimpleAtoi(opcode.substr(nextNumIndex, numDigits), &returnedValue)) {
|
||||||
// ASSERT(returnedValue < std::numeric_limits<uint8_t>::max());
|
|
||||||
// parameterPositions.push_back(parameterPosition);
|
|
||||||
lettersOnlyHash = hash("&", lettersOnlyHash);
|
lettersOnlyHash = hash("&", lettersOnlyHash);
|
||||||
parameters.push_back(returnedValue);
|
parameters.push_back(returnedValue);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ struct Opcode {
|
||||||
absl::string_view value {};
|
absl::string_view value {};
|
||||||
uint64_t lettersOnlyHash { Fnv1aBasis };
|
uint64_t lettersOnlyHash { Fnv1aBasis };
|
||||||
// This is to handle the integer parameters of some opcodes
|
// This is to handle the integer parameters of some opcodes
|
||||||
std::vector<uint8_t> parameters;
|
std::vector<uint16_t> parameters;
|
||||||
LEAK_DETECTOR(Opcode);
|
LEAK_DETECTOR(Opcode);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ TEST_CASE("[Opcode] Construction")
|
||||||
REQUIRE(opcode.lettersOnlyHash == hash("sample&"));
|
REQUIRE(opcode.lettersOnlyHash == hash("sample&"));
|
||||||
REQUIRE(opcode.value == "dummy");
|
REQUIRE(opcode.value == "dummy");
|
||||||
REQUIRE(opcode.parameters.size() == 1);
|
REQUIRE(opcode.parameters.size() == 1);
|
||||||
REQUIRE(opcode.parameters == std::vector<uint8_t>({ 123 }));
|
REQUIRE(opcode.parameters == std::vector<uint16_t>({ 123 }));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Parameterized opcode with underscore")
|
SECTION("Parameterized opcode with underscore")
|
||||||
|
|
@ -44,7 +44,7 @@ TEST_CASE("[Opcode] Construction")
|
||||||
REQUIRE(opcode.opcode == "sample_underscore123");
|
REQUIRE(opcode.opcode == "sample_underscore123");
|
||||||
REQUIRE(opcode.lettersOnlyHash == hash("sample_underscore&"));
|
REQUIRE(opcode.lettersOnlyHash == hash("sample_underscore&"));
|
||||||
REQUIRE(opcode.value == "dummy");
|
REQUIRE(opcode.value == "dummy");
|
||||||
REQUIRE(opcode.parameters == std::vector<uint8_t>({ 123 }));
|
REQUIRE(opcode.parameters == std::vector<uint16_t>({ 123 }));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Parameterized opcode within the opcode")
|
SECTION("Parameterized opcode within the opcode")
|
||||||
|
|
@ -53,7 +53,7 @@ TEST_CASE("[Opcode] Construction")
|
||||||
REQUIRE(opcode.opcode == "sample1_underscore");
|
REQUIRE(opcode.opcode == "sample1_underscore");
|
||||||
REQUIRE(opcode.lettersOnlyHash == hash("sample&_underscore"));
|
REQUIRE(opcode.lettersOnlyHash == hash("sample&_underscore"));
|
||||||
REQUIRE(opcode.value == "dummy");
|
REQUIRE(opcode.value == "dummy");
|
||||||
REQUIRE(opcode.parameters == std::vector<uint8_t>({ 1 }));
|
REQUIRE(opcode.parameters == std::vector<uint16_t>({ 1 }));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Parameterized opcode within the opcode")
|
SECTION("Parameterized opcode within the opcode")
|
||||||
|
|
@ -75,7 +75,7 @@ TEST_CASE("[Opcode] Construction")
|
||||||
REQUIRE(opcode.parameters.size() == 2);
|
REQUIRE(opcode.parameters.size() == 2);
|
||||||
REQUIRE(opcode.parameters[0] == 123);
|
REQUIRE(opcode.parameters[0] == 123);
|
||||||
REQUIRE(opcode.parameters[1] == 44);
|
REQUIRE(opcode.parameters[1] == 44);
|
||||||
REQUIRE(opcode.parameters == std::vector<uint8_t>({ 123, 44 }));
|
REQUIRE(opcode.parameters == std::vector<uint16_t>({ 123, 44 }));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Parameterized opcode within the opcode twice, with a back parameter")
|
SECTION("Parameterized opcode within the opcode twice, with a back parameter")
|
||||||
|
|
@ -85,7 +85,7 @@ TEST_CASE("[Opcode] Construction")
|
||||||
REQUIRE(opcode.lettersOnlyHash == hash("sample&_double&_underscore&"));
|
REQUIRE(opcode.lettersOnlyHash == hash("sample&_double&_underscore&"));
|
||||||
REQUIRE(opcode.value == "dummy");
|
REQUIRE(opcode.value == "dummy");
|
||||||
REQUIRE(opcode.parameters.size() == 3);
|
REQUIRE(opcode.parameters.size() == 3);
|
||||||
REQUIRE(opcode.parameters == std::vector<uint8_t>({ 123, 44, 23 }));
|
REQUIRE(opcode.parameters == std::vector<uint16_t>({ 123, 44, 23 }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue