Work to add C style entry points to library that allow most functionality

This commit is contained in:
2019-06-05 17:46:46 +02:00
parent 6206fef4c5
commit 43dede9ae2
14 changed files with 169 additions and 79 deletions

View File

@@ -0,0 +1,46 @@
#import "EvalValue.hpp"
#include <cstring>
extern "C" {
TypeClass GetEvalValueTypeClass(EvalValue* v){
return v->GetType().get()->GetClass();
}
ScriptType* GetEvalValueType(EvalValue* v){
return v->GetType().get();
}
int64_t EvaluateEvalValueInteger(EvalValue* v){
return v->EvaluateInteger();
}
double EvaluateEvalValueFloat(EvalValue* v){
return v->EvaluateFloat();
}
bool EvaluateEvalValueBool(EvalValue* v){
return v->EvaluateBool();
}
const char* EvaluateEvalValueString(EvalValue* v){
return v->EvaluateString() -> c_str();
}
}
#ifdef TESTS_BUILD
#include <catch.hpp>
#include "../src/Script.hpp"
TEST_CASE( "Evaluate String", "[integration]" ) {
auto script = Script::Create("\"foo bar\"");
REQUIRE(!script->Diagnostics -> HasErrors());
script->Evaluate();
auto lastValue = script->GetLastValue();
REQUIRE(std::strcmp(EvaluateEvalValueString(lastValue), "foo bar") == 0);
delete script;
}
#endif