summaryrefslogtreecommitdiff
path: root/tools/seq_compiler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tools/seq_compiler.cc')
-rw-r--r--tools/seq_compiler.cc22
1 files changed, 13 insertions, 9 deletions
diff --git a/tools/seq_compiler.cc b/tools/seq_compiler.cc
index e84877b..a8a9795 100644
--- a/tools/seq_compiler.cc
+++ b/tools/seq_compiler.cc
@@ -22,14 +22,15 @@ struct SequenceEntry {
std::vector<EffectEntry> effects;
};
-std::string trim(const std::string &str) {
+std::string trim(const std::string& str) {
size_t first = str.find_first_not_of(" ");
- if (std::string::npos == first) return str;
+ if (std::string::npos == first)
+ return str;
size_t last = str.find_last_not_of(" ");
return str.substr(first, (last - first + 1));
}
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
if (argc != 3) {
std::cerr << "Usage: " << argv[0] << " <input.seq> <output.cc>\n";
std::cerr << "Example: " << argv[0]
@@ -44,14 +45,15 @@ int main(int argc, char *argv[]) {
}
std::vector<SequenceEntry> sequences;
- SequenceEntry *current_seq = nullptr;
+ SequenceEntry* current_seq = nullptr;
std::string line;
int line_num = 0;
while (std::getline(in_file, line)) {
- line_num++;
+ ++line_num;
std::string trimmed = trim(line);
- if (trimmed.empty() || trimmed[0] == '#') continue;
+ if (trimmed.empty() || trimmed[0] == '#')
+ continue;
std::stringstream ss(trimmed);
std::string command;
@@ -85,7 +87,9 @@ int main(int argc, char *argv[]) {
// Remove leading whitespace from getline if any (getline reads the space
// after priority)
extra_args = trim(extra_args);
- if (!extra_args.empty()) { extra_args = ", " + extra_args; }
+ if (!extra_args.empty()) {
+ extra_args = ", " + extra_args;
+ }
current_seq->effects.push_back(
{class_name, start, end, priority, extra_args});
@@ -108,10 +112,10 @@ int main(int argc, char *argv[]) {
out_file << "void LoadTimeline(MainSequence& main_seq, WGPUDevice device, "
"WGPUQueue queue, WGPUTextureFormat format) {\n";
- for (const auto &seq : sequences) {
+ for (const SequenceEntry& seq : sequences) {
out_file << " {\n";
out_file << " auto seq = std::make_shared<Sequence>();\n";
- for (const auto &eff : seq.effects) {
+ for (const EffectEntry& eff : seq.effects) {
out_file << " seq->add_effect(std::make_shared<" << eff.class_name
<< ">(device, queue, format" << eff.extra_args << "), "
<< eff.start << "f, " << eff.end << "f, " << eff.priority