45 lines
2.3 KiB
C++
45 lines
2.3 KiB
C++
#include "_load.hpp"
|
|
|
|
#include <cassert>
|
|
|
|
#include "Path.hpp"
|
|
#include "FileSystem.hpp"
|
|
|
|
|
|
namespace atlas::script::module::filesystem {
|
|
|
|
void load(const engine::Engine* atlasEngine) {
|
|
asIScriptEngine* asEngine = atlasEngine->getAsEngine();
|
|
auto* fileSystem = new FileSystem(atlasEngine->getFileSystem());
|
|
|
|
int error;
|
|
|
|
// start namespace
|
|
error = asEngine->SetDefaultNamespace("atlas::filesystem"); assert(error >= 0);
|
|
|
|
// file type
|
|
error = asEngine->RegisterObjectType("File", 0, asOBJ_REF); assert(error >= 0);
|
|
error = asEngine->RegisterObjectBehaviour("File", asBEHAVE_ADDREF, "void f()", asMETHOD(File, asAddReference), asCALL_THISCALL); assert(error >= 0);
|
|
error = asEngine->RegisterObjectBehaviour("File", asBEHAVE_RELEASE, "void f()", asMETHOD(File, asRelease), asCALL_THISCALL); assert(error >= 0);
|
|
|
|
// path type
|
|
error = asEngine->RegisterObjectType("Path", 0, asOBJ_REF); assert(error >= 0);
|
|
error = asEngine->RegisterObjectBehaviour("Path", asBEHAVE_ADDREF, "void f()", asMETHOD(Path, asAddReference), asCALL_THISCALL); assert(error >= 0);
|
|
error = asEngine->RegisterObjectBehaviour("Path", asBEHAVE_RELEASE, "void f()", asMETHOD(Path, asRelease), asCALL_THISCALL); assert(error >= 0);
|
|
error = asEngine->RegisterObjectMethod("Path", "Path@ getParent() const", asMETHOD(Path, getParent), asCALL_THISCALL); assert(error >= 0);
|
|
error = asEngine->RegisterObjectMethod("Path", "bool exists() const", asMETHOD(Path, exists), asCALL_THISCALL); assert(error >= 0);
|
|
|
|
// file system type
|
|
error = asEngine->RegisterObjectType("FileSystem", 0, asOBJ_REF); assert(error >= 0);
|
|
error = asEngine->RegisterObjectBehaviour("FileSystem", asBEHAVE_ADDREF, "void f()", asMETHOD(FileSystem, asAddReference), asCALL_THISCALL); assert(error >= 0);
|
|
error = asEngine->RegisterObjectBehaviour("FileSystem", asBEHAVE_RELEASE, "void f()", asMETHOD(FileSystem, asRelease), asCALL_THISCALL); assert(error >= 0);
|
|
error = asEngine->RegisterObjectMethod("FileSystem", "Path@ getPath(const string& in) const", asMETHOD(FileSystem, getPath), asCALL_THISCALL); assert(error >= 0);
|
|
|
|
// file system singleton
|
|
error = asEngine->RegisterGlobalProperty("const FileSystem fileSystem", fileSystem); assert(error >= 0);
|
|
|
|
// end namespace
|
|
error = asEngine->SetDefaultNamespace(""); assert(error >= 0);
|
|
}
|
|
|
|
}
|