38 lines
1.4 KiB
C++
38 lines
1.4 KiB
C++
#include "_load.hpp"
|
|
|
|
#include <stdexcept>
|
|
|
|
#include "Path.hpp"
|
|
|
|
|
|
namespace atlas::script::module::filesystem {
|
|
|
|
Path* pathFactory(const engine::Engine* atlasEngine, const std::string& virtualPath) {
|
|
return new Path(atlasEngine, virtualPath);
|
|
};
|
|
|
|
void load(const engine::Engine* atlasEngine) {
|
|
asIScriptEngine* asEngine = atlasEngine->getAsEngine();
|
|
auto fileSystem = atlasEngine->getFileSystem();
|
|
int error;
|
|
|
|
// start namespace
|
|
error = asEngine->SetDefaultNamespace("atlas::filesystem");
|
|
if (error < 0)
|
|
throw std::runtime_error("Could not enter the \"atlas::filesystem\" namespace.");
|
|
|
|
// TODO(Faraphel): register the Path and File types
|
|
error = asEngine->RegisterGlobalProperty("int Path::FileSystem", fileSystem.get());
|
|
|
|
// error = asEngine->RegisterObjectType("Path", 0, asOBJ_REF);
|
|
// error = asEngine->RegisterObjectBehaviour("Path", asBEHAVE_FACTORY, "Path@ f(const string& in)", asFUNCTION(pathFactory), asCALL_CDECL);
|
|
// error = asEngine->RegisterObjectMethod("Path", "Path@ getParent() const", asMETHOD(Path, getParent), asCALL_THISCALL);
|
|
// error = asEngine->RegisterObjectMethod("Path", "bool exists() const", asMETHOD(Path, exists), asCALL_THISCALL);
|
|
|
|
// end namespace
|
|
error = asEngine->SetDefaultNamespace("");
|
|
if (error < 0)
|
|
throw std::runtime_error("Could not reset the namespace.");
|
|
}
|
|
|
|
}
|