Add an alternative "make_task_noR" macro to avoid making unused references in Target.hpp

Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
Username404 2022-01-29 12:48:35 +01:00
parent f33aec687a
commit ca4e773fca
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 9 additions and 5 deletions

View File

@ -65,9 +65,11 @@ protected:
} else output << openCharacters << view << closeCharacters; } else output << openCharacters << view << closeCharacters;
} }
typedef function<void (const ParseTree& parsedTree, unsigned int& index)> task; typedef function<void (const ParseTree& parsedTree, unsigned int& index)> task;
#define make_task_base(type, captures, function_body) make_pair(type_index(typeid(type)), [captures](const ParseTree& parsedTree, unsigned int& index) { const type& parseComponent = pointerAs<type>(parsedTree[index]); function_body }) #define make_task_base(start, type, captures, function_body) make_pair(type_index(typeid(type)), [captures](const ParseTree& parsedTree, unsigned int& index) { start; function_body })
#define make_task(T, F) make_task_base(T, this, F) #define make_task_base_R(T, C, F) make_task_base(const T& parseComponent = pointerAs<T>(parsedTree[index]), T, C, F)
#define make_nonlocal_task(T, F) make_task_base(T, , F) #define make_task(T, F) make_task_base_R(T, this, F)
#define make_task_noR(T, F) make_task_base(,T, this, F)
#define make_nonlocal_task(T, F) make_task_base_R(T, , F)
typedef unordered_map<type_index, task> unordered_task_map; typedef unordered_map<type_index, task> unordered_task_map;
typedef pair<const char*, const char*> print_functions_pair; typedef pair<const char*, const char*> print_functions_pair;
virtual unordered_task_map getTaskMap() = 0; virtual unordered_task_map getTaskMap() = 0;
@ -86,11 +88,11 @@ public:
} }
} }
), ),
make_task_base(StandardComponents::Reference, &, make_task(StandardComponents::Reference,
const auto print_functions = printFunctions(); const auto print_functions = printFunctions();
output << ((parseComponent.name == "print") ? print_functions.first : (parseComponent.name == "print_line") ? print_functions.second : parseComponent.name); output << ((parseComponent.name == "print") ? print_functions.first : (parseComponent.name == "print_line") ? print_functions.second : parseComponent.name);
), ),
make_task(StandardComponents::Call, make_task_noR(StandardComponents::Call,
output << '('; output << '(';
staticMap[typeid(ParseTree)](parsedTree, index); staticMap[typeid(ParseTree)](parsedTree, index);
output << ')'; output << ')';
@ -159,7 +161,9 @@ shared_ptr<Target> Target::forName(string_view name, const bool newLines = true)
} }
#undef ADDTARGET #undef ADDTARGET
#undef make_nonlocal_task #undef make_nonlocal_task
#undef make_task_noR
#undef make_task #undef make_task
#undef make_task_base_R
#undef make_task_base #undef make_task_base
return target; return target;
} }