Added extern C support for registering static variables
This commit is contained in:
parent
e939920e5c
commit
184ef8ec9a
|
@ -1,3 +1,11 @@
|
|||
#include "StaticScope.hpp"
|
||||
|
||||
Porygon::StandardLibraries::StaticScope::InternalScope* Porygon::StandardLibraries::StaticScope::_internal = nullptr;
|
||||
namespace Porygon::StandardLibraries{
|
||||
StaticScope::InternalScope* StaticScope::_internal = nullptr;
|
||||
|
||||
extern "C"{
|
||||
void RegisterStaticVariable(uint32_t identifier, ScriptType* type, Evaluation::EvalValue* value){
|
||||
StaticScope::RegisterVariableRaw(identifier, type, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,6 +62,12 @@ namespace Porygon::StandardLibraries{
|
|||
GetScope()->_variables.insert({identifier, value});
|
||||
}
|
||||
|
||||
static void RegisterVariableRaw(uint32_t identifier, ScriptType* type, Evaluation::EvalValue* value){
|
||||
auto hash = Utilities::HashedString::CreateLookup(identifier);
|
||||
GetScope()->_boundVariables.insert({hash, new Binder::BoundVariable(shared_ptr<ScriptType>(type))});
|
||||
GetScope()->_variables.insert({hash, value});
|
||||
}
|
||||
|
||||
static Binder::BoundVariable* GetBoundVariable(const Utilities::HashedString &identifier){
|
||||
auto found = GetScope()->_boundVariables.find(identifier);
|
||||
if (found != GetScope()->_boundVariables.end()) {
|
||||
|
|
Loading…
Reference in New Issue