Added support for calling script functions from extern C hooks
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
a747c60f32
commit
f143e526ab
|
@ -1,4 +1,6 @@
|
||||||
#include "EvalValue.hpp"
|
#include "EvalValue.hpp"
|
||||||
|
#include "NumericEvalValue.hpp"
|
||||||
|
#include "StringEvalValue.hpp"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -26,6 +28,21 @@ extern "C" {
|
||||||
return v->EvaluateString() -> c_str();
|
return v->EvaluateString() -> c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EvalValue* CreateIntegerEvalValue(long l){
|
||||||
|
return new IntegerEvalValue(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
EvalValue* CreateFloatEvalValue(double d){
|
||||||
|
return new FloatEvalValue(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
EvalValue* CreateBoolEvalValue(bool b){
|
||||||
|
return new BooleanEvalValue(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
EvalValue* CreateStringEvalValue(const char* s){
|
||||||
|
return new StringEvalValue(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TESTS_BUILD
|
#ifdef TESTS_BUILD
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
#include <utility>
|
#include <iterator>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include "Script.hpp"
|
#include "Script.hpp"
|
||||||
#include "Parser/Lexer.hpp"
|
#include "Parser/Lexer.hpp"
|
||||||
|
@ -97,6 +97,15 @@ extern "C" {
|
||||||
EvalValue* GetVariable(Script* script, const char* key){
|
EvalValue* GetVariable(Script* script, const char* key){
|
||||||
return script->GetVariable(key);
|
return script->GetVariable(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HasFunction(Script* script, const char* key){
|
||||||
|
return script->HasFunction(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
EvalValue* CallFunction(Script* script, const char* key, EvalValue* parameters[], int parameterCount){
|
||||||
|
std::vector<EvalValue*> v(parameters, parameters + parameterCount);
|
||||||
|
return script->CallFunction(key, v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue