Allow non-local script functions to be called from outside the script
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#include <utility>
|
||||
|
||||
#include <utility>
|
||||
#include <unordered_map>
|
||||
#include "Script.hpp"
|
||||
@@ -65,6 +67,16 @@ EvalValue *Script::GetLastValue() {
|
||||
return _evaluator->GetLastValue();
|
||||
}
|
||||
|
||||
bool Script::HasFunction(const string &key) {
|
||||
auto f = _scriptVariables->find(HashedString(key).GetHash());
|
||||
return f != _scriptVariables->end() && f.operator->()->second->GetType()->GetClass() == TypeClass ::Function;
|
||||
}
|
||||
|
||||
EvalValue *Script::CallFunction(const string &key, vector<EvalValue *> variables) {
|
||||
auto var = (ScriptFunctionEvalValue*)GetVariable(key);
|
||||
return this->_evaluator->EvaluateFunction(var, std::move(variables));
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
Script* CreateScript(char * s){
|
||||
return Script::Create(s);
|
||||
|
||||
Reference in New Issue
Block a user