Finally change cmake file to be like TessesFramework
This commit is contained in:
@ -17,8 +17,9 @@ int main(int argc, char** argv)
|
||||
Tesses::Framework::Filesystem::LocalFilesystem fs;
|
||||
GC gc;
|
||||
gc.Start();
|
||||
GCList ls(gc);
|
||||
|
||||
tryAgain:
|
||||
GCList ls(gc);
|
||||
TRootEnvironment* env = TRootEnvironment::Create(ls, TDictionary::Create(ls));
|
||||
|
||||
|
||||
@ -29,13 +30,13 @@ int main(int argc, char** argv)
|
||||
else
|
||||
{
|
||||
tryAgainFast:
|
||||
std::cout << "File " << filename.ToString() << " not found, do you want to download the installer from: https://crosslang.tesseslanguage.com/crosslang-shell-install.tcross (this will install other stuff as well) (Y/n)? ";
|
||||
std::cout << "File " << filename.ToString() << " not found, do you want to download the installer from: https://gitea.site.tesses.net/tesses50/crosslang-libs/raw/branch/master/crosslang-shell-install.tcross (this may install other stuff as well) (Y/n)? ";
|
||||
std::string line;
|
||||
std::getline(std::cin,line);
|
||||
if(line == "Y" || line == "y")
|
||||
{
|
||||
HttpRequest req;
|
||||
req.url = "https://crosslang.tesseslanguage.com/crosslang-shell-install.tcross";
|
||||
req.url = "https://gitea.site.tesses.net/tesses50/crosslang-libs/raw/branch/master/crosslang-shell-install.tcross";
|
||||
req.method = "GET";
|
||||
HttpResponse resp(req);
|
||||
if(resp.statusCode == StatusCode::OK)
|
||||
@ -74,4 +75,4 @@ int main(int argc, char** argv)
|
||||
if(GetObject(res,iresult))
|
||||
return (int)iresult;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,6 +54,23 @@ namespace Tesses::CrossLang
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
static TObject FS_MakeFull(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
Tesses::Framework::Filesystem::VFSPath path;
|
||||
if(GetArgumentAsPath(args,0,path))
|
||||
{
|
||||
if(path.relative)
|
||||
{
|
||||
Tesses::Framework::Filesystem::LocalFilesystem lfs;
|
||||
auto curDir = std::filesystem::current_path();
|
||||
auto myPath = lfs.SystemToVFSPath(curDir.string()) / path;
|
||||
myPath = myPath.CollapseRelativeParents();
|
||||
return myPath;
|
||||
}
|
||||
return path.CollapseRelativeParents();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
void TStd::RegisterIO(GC* gc,TRootEnvironment* env,bool enableLocalFilesystem)
|
||||
{
|
||||
|
||||
@ -68,6 +85,7 @@ namespace Tesses::CrossLang
|
||||
TVFSHeapObject* vfs = TVFSHeapObject::Create(ls, new Tesses::Framework::Filesystem::LocalFilesystem());
|
||||
|
||||
dict->SetValue("Local", vfs);
|
||||
dict->DeclareFunction(gc, "MakeFull", "Make absolute path from relative path",{"path"},FS_MakeFull);
|
||||
}
|
||||
|
||||
dict->DeclareFunction(gc, "MountableFilesystem","Create a mountable filesystem",{"root"}, FS_MountableFilesystem);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#include "CrossLang.hpp"
|
||||
|
||||
#include <iostream>
|
||||
namespace Tesses::CrossLang {
|
||||
void TRootEnvironment::LoadDependency(GC* gc,Tesses::Framework::Filesystem::VFS* vfs, std::pair<std::string,TVMVersion> dep)
|
||||
{
|
||||
@ -14,7 +14,6 @@ namespace Tesses::CrossLang {
|
||||
|
||||
|
||||
Tesses::Framework::Streams::Stream* file;
|
||||
|
||||
if(vfs->RegularFileExists(filename) && (file = vfs->OpenFile(filename,"rb")) != nullptr)
|
||||
{
|
||||
|
||||
@ -159,7 +158,7 @@ namespace Tesses::CrossLang {
|
||||
TFile* f = TFile::Create(ls);
|
||||
f->Load(gc, file);
|
||||
Tesses::Framework::Filesystem::SubdirFilesystem dir(vfs,path.GetParent(),false);
|
||||
LoadFileWithDependencies(gc,vfs,f);
|
||||
LoadFileWithDependencies(gc,&dir,f);
|
||||
}
|
||||
else throw VMException("Could not open file: \"" + path.GetFileName() + "\".");
|
||||
|
||||
|
||||
@ -201,7 +201,9 @@ namespace Tesses::CrossLang {
|
||||
return out;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TObjectVFS::SymlinkExists(Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
TVFSHeapObject* vfs;
|
||||
@ -220,6 +222,7 @@ namespace Tesses::CrossLang {
|
||||
return out;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool TObjectVFS::CharacterDeviceExists(Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
@ -239,6 +242,7 @@ namespace Tesses::CrossLang {
|
||||
return out;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool TObjectVFS::BlockDeviceExists(Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
@ -258,6 +262,7 @@ namespace Tesses::CrossLang {
|
||||
return out;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool TObjectVFS::SocketFileExists(Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
@ -277,6 +282,7 @@ namespace Tesses::CrossLang {
|
||||
return out;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool TObjectVFS::FIFOFileExists(Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
@ -296,6 +302,7 @@ namespace Tesses::CrossLang {
|
||||
return out;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool TObjectVFS::FileExists(Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
@ -315,6 +322,7 @@ namespace Tesses::CrossLang {
|
||||
return out;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool TObjectVFS::SpecialFileExists(Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
@ -334,6 +342,7 @@ namespace Tesses::CrossLang {
|
||||
return out;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void TObjectVFS::CreateSymlink(Tesses::Framework::Filesystem::VFSPath existingFile, Tesses::Framework::Filesystem::VFSPath symlinkFile)
|
||||
{
|
||||
@ -383,6 +392,7 @@ namespace Tesses::CrossLang {
|
||||
return out;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void TObjectVFS::DeleteFile(Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
@ -450,6 +460,7 @@ namespace Tesses::CrossLang {
|
||||
delete ls;
|
||||
});
|
||||
}
|
||||
return Tesses::Framework::Filesystem::VFSPathEnumerator();
|
||||
}
|
||||
void TObjectVFS::MoveFile(Tesses::Framework::Filesystem::VFSPath src, Tesses::Framework::Filesystem::VFSPath dest)
|
||||
{
|
||||
|
||||
@ -1535,6 +1535,42 @@ namespace Tesses::CrossLang {
|
||||
else if(std::holds_alternative<std::string>(instance))
|
||||
{
|
||||
std::string str = std::get<std::string>(instance);
|
||||
if(key == "IndexOf")
|
||||
{
|
||||
char c;
|
||||
if(GetArgument<char>(args,0,c))
|
||||
{
|
||||
int64_t index = 0;
|
||||
GetArgument(args,1,index);
|
||||
|
||||
auto res = str.find_first_of(c,(std::size_t)index);
|
||||
if(res == std::string::npos)
|
||||
cse.back()->Push(gc, (int64_t)-1);
|
||||
else
|
||||
cse.back()->Push(gc, (int64_t)res);
|
||||
return false;
|
||||
}
|
||||
cse.back()->Push(gc,nullptr);
|
||||
return false;
|
||||
}
|
||||
if(key == "LastIndexOf")
|
||||
{
|
||||
char c;
|
||||
if(GetArgument<char>(args,0,c))
|
||||
{
|
||||
int64_t index = str.size();
|
||||
GetArgument(args,1,index);
|
||||
|
||||
auto res = str.find_last_of(c,(std::size_t)index);
|
||||
if(res == std::string::npos)
|
||||
cse.back()->Push(gc, (int64_t)-1);
|
||||
else
|
||||
cse.back()->Push(gc, (int64_t)res);
|
||||
return false;
|
||||
}
|
||||
cse.back()->Push(gc,nullptr);
|
||||
return false;
|
||||
}
|
||||
if(key == "GetEnumerator")
|
||||
{
|
||||
cse.back()->Push(gc, TStringEnumerator::Create(ls,str));
|
||||
@ -1721,7 +1757,51 @@ namespace Tesses::CrossLang {
|
||||
//TStd::RegisterSqlite
|
||||
//TStd::RegisterVM
|
||||
auto myEnv = cse.back()->env->GetRootEnvironment();
|
||||
if(key == "RegisterEverything")
|
||||
{
|
||||
if(myEnv->permissions.canRegisterConsole && !rootEnv->permissions.locked)
|
||||
TStd::RegisterConsole(gc, rootEnv);
|
||||
|
||||
if(myEnv->permissions.canRegisterCrypto && !rootEnv->permissions.locked)
|
||||
TStd::RegisterCrypto(gc, rootEnv);
|
||||
|
||||
if(myEnv->permissions.canRegisterDictionary && !rootEnv->permissions.locked)
|
||||
TStd::RegisterDictionary(gc, rootEnv);
|
||||
|
||||
if(myEnv->permissions.canRegisterEnv && !rootEnv->permissions.locked)
|
||||
TStd::RegisterDictionary(gc, rootEnv);
|
||||
|
||||
|
||||
if(myEnv->permissions.canRegisterIO && !rootEnv->permissions.locked)
|
||||
TStd::RegisterIO(gc, rootEnv, myEnv->permissions.canRegisterLocalFS);
|
||||
|
||||
if(myEnv->permissions.canRegisterJSON && !rootEnv->permissions.locked)
|
||||
TStd::RegisterJson(gc, rootEnv);
|
||||
|
||||
if(myEnv->permissions.canRegisterNet && !rootEnv->permissions.locked)
|
||||
TStd::RegisterNet(gc, rootEnv);
|
||||
|
||||
if(myEnv->permissions.canRegisterOGC && !rootEnv->permissions.locked)
|
||||
TStd::RegisterOGC(gc, rootEnv);
|
||||
|
||||
if(myEnv->permissions.canRegisterPath && !rootEnv->permissions.locked)
|
||||
TStd::RegisterPath(gc, rootEnv);
|
||||
|
||||
if(myEnv->permissions.canRegisterRoot && !rootEnv->permissions.locked)
|
||||
TStd::RegisterRoot(gc, rootEnv);
|
||||
|
||||
if(myEnv->permissions.canRegisterSDL2 && !rootEnv->permissions.locked)
|
||||
TStd::RegisterSDL2(gc, rootEnv);
|
||||
|
||||
if(myEnv->permissions.canRegisterSqlite && !rootEnv->permissions.locked)
|
||||
TStd::RegisterSqlite(gc, rootEnv);
|
||||
|
||||
if(myEnv->permissions.canRegisterVM && !rootEnv->permissions.locked)
|
||||
TStd::RegisterVM(gc, rootEnv);
|
||||
|
||||
cse.back()->Push(gc,nullptr);
|
||||
return false;
|
||||
}
|
||||
if(key == "RegisterConsole")
|
||||
{
|
||||
if(myEnv->permissions.canRegisterConsole && !rootEnv->permissions.locked)
|
||||
@ -1779,7 +1859,7 @@ namespace Tesses::CrossLang {
|
||||
if(key == "RegisterOGC")
|
||||
{
|
||||
if(myEnv->permissions.canRegisterOGC && !rootEnv->permissions.locked)
|
||||
TStd::RegisterNet(gc, rootEnv);
|
||||
TStd::RegisterOGC(gc, rootEnv);
|
||||
cse.back()->Push(gc,nullptr);
|
||||
return false;
|
||||
}
|
||||
@ -2623,7 +2703,7 @@ namespace Tesses::CrossLang {
|
||||
|
||||
}
|
||||
|
||||
if(key == "GetAt")
|
||||
if(key == "SetAt")
|
||||
{
|
||||
if(args.size() != 2)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user