Atlas-Launcher/source/script/module/debug/_load.cpp

35 lines
866 B
C++

#include "_load.hpp"
#include <stdexcept>
#include <string>
#include "log.hpp"
namespace atlas::script::module::debug {
void load(const engine::Engine* atlasEngine) {
asIScriptEngine* asEngine = atlasEngine->getAsEngine();
int error;
// start namespace
error = asEngine->SetDefaultNamespace("atlas::debug");
if (error < 0)
throw std::runtime_error("Could not enter the \"atlas::debug\" namespace.");
// functions
error = asEngine->RegisterGlobalFunction(
"void log(const string& in, const string& in)",
asFUNCTION(log),
asCALL_CDECL
);
if (error < 0)
throw std::runtime_error("Could not register the \"load\" function.");
// end namespace
error = asEngine->SetDefaultNamespace("");
if (error < 0)
throw std::runtime_error("Could not reset the namespace.");
}
}