patterns: Move builtin functions to namespace. Add string functions

This commit is contained in:
WerWolv
2021-08-27 09:56:20 +02:00
parent b7003d499c
commit d0aec62997
4 changed files with 171 additions and 133 deletions

View File

@@ -151,8 +151,15 @@ namespace hex {
/* Pattern Language Functions */
void ContentRegistry::PatternLanguageFunctions::add(std::string_view name, u32 parameterCount, const std::function<hex::lang::ASTNode*(hex::lang::Evaluator&, std::vector<hex::lang::ASTNode*>&)> &func) {
getEntries()[name.data()] = Function{ parameterCount, func };
void ContentRegistry::PatternLanguageFunctions::add(const Namespace &ns, const std::string &name, u32 parameterCount, const std::function<hex::lang::ASTNode*(hex::lang::Evaluator&, std::vector<hex::lang::ASTNode*>&)> &func) {
std::string functionName;
for (auto &scope : ns)
functionName += scope + "::";
functionName += name;
getEntries()[functionName] = Function { parameterCount, func };
}
std::map<std::string, ContentRegistry::PatternLanguageFunctions::Function>& ContentRegistry::PatternLanguageFunctions::getEntries() {