Rework for git.tesses.org, GC* is std::shared_ptr maybe will fix crash during exit
Some checks failed
Build and Deploy on Tag / update-tap (push) Has been cancelled
Build and Deploy on Tag / build-arch (push) Has been cancelled

This commit is contained in:
2026-04-30 16:00:00 -05:00
parent fca18e63a6
commit 991f2a217d
78 changed files with 1243 additions and 849 deletions

View File

@@ -308,7 +308,7 @@ namespace Tesses::CrossLang
{
}
Parser::Parser(std::vector<LexToken> tokens, GC* gc, TRootEnvironment* env)
Parser::Parser(std::vector<LexToken> tokens, std::shared_ptr<GC> gc, TRootEnvironment* env)
{
this->i = 0;
this->tokens = tokens;

View File

@@ -212,15 +212,15 @@ int main(int argc, char** argv)
}
GC* gc=nullptr;
GCList* ls=nullptr;
std::shared_ptr<GC> gc;
std::shared_ptr<GCList> ls;
TRootEnvironment* env=nullptr;
if(comptime != "none")
{
gc = new GC();
gc = std::make_shared<GC>();
gc->Start();
ls = new GCList(gc);
env = TRootEnvironment::Create(ls,TDictionary::Create(ls));
ls = std::make_shared<GCList>(gc);
env = TRootEnvironment::Create(*ls,TDictionary::Create(*ls));
if(comptime == "secure")
{
@@ -281,10 +281,5 @@ int main(int argc, char** argv)
gen.Save(strm);
}
if(gc != nullptr)
{
delete ls;
delete gc;
}
return 0;
}

View File

@@ -2,7 +2,7 @@
namespace Tesses::CrossLang
{
SharedPtrTObject::SharedPtrTObject(GC* gc, TObject o)
SharedPtrTObject::SharedPtrTObject(std::shared_ptr<GC> gc, TObject o)
{
this->ls = new GCList(gc);
this->ls->Add(o);
@@ -17,18 +17,15 @@ namespace Tesses::CrossLang
if(this->ls)
delete this->ls;
}
GC* SharedPtrTObject::GetGC()
std::shared_ptr<GC> SharedPtrTObject::GetGC()
{
return this->ls->GetGC();
}
MarkedTObject CreateMarkedTObject(GC* gc, TObject o)
MarkedTObject CreateMarkedTObject(std::shared_ptr<GC> gc, TObject o)
{
return std::make_shared<SharedPtrTObject>(gc,o);
}
MarkedTObject CreateMarkedTObject(GC& gc, TObject o)
{
return CreateMarkedTObject(&gc,o);
}
MarkedTObject CreateMarkedTObject(GCList* gc, TObject o)
{
return CreateMarkedTObject(gc->GetGC(),o);

View File

@@ -15,7 +15,8 @@ static bool Download(Tesses::Framework::Filesystem::VFSPath filename,std::shared
if(inContainer && (*inContainer=="1" || *inContainer=="y" || *inContainer=="Y"))
{
HttpRequest req;
req.url = "https://downloads.tesses.net/ShellPackage.crvm";
req.followRedirects=true;
req.url = "https://redirect.tesses.net/crosslang-shell";
req.method = "GET";
HttpResponse resp(req);
if(resp.statusCode == StatusCode::OK)
@@ -34,13 +35,14 @@ static bool Download(Tesses::Framework::Filesystem::VFSPath filename,std::shared
while(true)
{
std::cout << "File " << filename.ToString() << " not found, do you want to download the installer from: https://downloads.tesses.net/ShellPackage.crvm (this may install other stuff as well) (Y/n)? ";
std::cout << "File " << filename.ToString() << " not found, do you want to download the installer from: https://redirect.tesses.net/crosslang-shell (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://downloads.tesses.net/ShellPackage.crvm";
req.followRedirects = true;
req.url = "https://redirect.tesses.net/crosslang-shell";
req.method = "GET";
HttpResponse resp(req);
if(resp.statusCode == StatusCode::OK)
@@ -89,7 +91,8 @@ TObject CrossLangShell(GCList& ls, std::vector<std::string>& argv)
auto subdir = std::make_shared<Tesses::Framework::Filesystem::SubdirFilesystem>(Tesses::Framework::Filesystem::LocalFS,dir);
HttpRequest req;
req.url = "https://downloads.tesses.net/ShellPackage.crvm";
req.followRedirects=true;
req.url = "https://redirect.tesses.net/crosslang-shell";
req.method = "GET";
HttpResponse resp(req);
if(resp.statusCode == StatusCode::OK)

View File

@@ -212,15 +212,15 @@ void CrossLangCompiler(std::vector<std::string>& argv)
}
GC* gc=nullptr;
GCList* ls=nullptr;
std::shared_ptr<GC> gc;
std::shared_ptr<GCList> ls;
TRootEnvironment* env=nullptr;
if(comptime != "none")
{
gc = new GC();
std::shared_ptr<GC> gc= std::make_shared<GC>();
gc->Start();
ls = new GCList(gc);
env = TRootEnvironment::Create(ls,TDictionary::Create(ls));
ls = std::make_shared<GCList>(gc);
env = TRootEnvironment::Create(*ls,TDictionary::Create(*ls));
if(comptime == "secure")
{
@@ -281,10 +281,5 @@ void CrossLangCompiler(std::vector<std::string>& argv)
gen.Save(strm);
}
if(gc != nullptr)
{
delete ls;
delete gc;
}
}
}

View File

@@ -9,7 +9,7 @@ using namespace Tesses::Framework::Filesystem;
namespace Tesses::CrossLang::Programs {
TObject CrossLangInterperter(GCList& ls,TRootEnvironment* env,std::vector<std::string>& argv)
{
GC* gc = ls.GetGC();
std::shared_ptr<GC> gc = ls.GetGC();
if(argv.size() > 1)
{
std::ifstream strm(argv[1],std::ios_base::in|std::ios_base::binary);

View File

@@ -8,8 +8,8 @@ int main(int argc, char** argv)
TF_InitWithConsole();
if(argc > 0)
TF_AllowPortable(argv[0]);
GC gc;
gc.Start();
std::shared_ptr<GC> gc= std::make_shared<GC>();
gc->Start();
GCList ls(gc);

View File

@@ -6,16 +6,17 @@
using namespace Tesses::Framework;
using namespace Tesses::CrossLang;
using namespace Tesses::Framework::Filesystem;
static GC gc;
int main(int argc, char** argv)
{
TF_InitWithConsole();
if(argc > 0)
TF_AllowPortable(argv[0]);
gc.Start();
std::shared_ptr<GC> gc= std::make_shared<GC>();
gc->Start();
GCList ls(gc);
TRootEnvironment* env = TRootEnvironment::Create(ls, TDictionary::Create(ls));
TStd::RegisterStd(&gc,env);
TStd::RegisterStd(gc,env);
std::vector<std::string> args(argc);
for(int i = 0; i < argc; i++)

View File

@@ -6,17 +6,17 @@
using namespace Tesses::Framework;
using namespace Tesses::CrossLang;
using namespace Tesses::Framework::Filesystem;
static GC gc;
int main(int argc, char** argv)
{
TF_InitWithConsole();
if(argc > 0)
TF_AllowPortable(argv[0]);
gc.Start();
std::shared_ptr<GC> gc= std::make_shared<GC>();
gc->Start();
GCList ls(gc);
TRootEnvironment* env = TRootEnvironment::Create(ls, TDictionary::Create(ls));
TStd::RegisterStd(&gc,env);
TStd::RegisterStd(gc,env);
std::vector<std::string> args(argc);
for(int i = 0; i < argc; i++)

View File

@@ -26,18 +26,19 @@ int main(int argc, char** argv)
args[i] = argv[i];
if(programName == "crossint")
{
GC gc;
gc.Start();
int64_t myi64=0;
{
std::shared_ptr<GC> gc= std::make_shared<GC>();
gc->Start();
GCList ls(gc);
TRootEnvironment* env = TRootEnvironment::Create(ls, TDictionary::Create(ls));
TStd::RegisterStd(&gc,env);
TStd::RegisterStd(gc,env);
auto res= Programs::CrossLangInterperter(ls, env, args);
GetObject(res,myi64);
}
return (int)myi64;
}
else if(programName == "crossc")
@@ -74,17 +75,17 @@ int main(int argc, char** argv)
}
else if(programName == "crossvm")
{
GC gc;
gc.Start();
std::shared_ptr<GC> gc= std::make_shared<GC>();
gc->Start();
int64_t myi64=0;
{
GCList ls(gc);
TRootEnvironment* env = TRootEnvironment::Create(ls, TDictionary::Create(ls));
TStd::RegisterStd(&gc,env);
TStd::RegisterStd(gc,env);
auto res= Programs::CrossLangVM(ls, env, args);
GetObject(res,myi64);
}
return (int)myi64;
}
@@ -95,16 +96,15 @@ int main(int argc, char** argv)
{
int64_t myi64=0;
args.erase(args.begin());
GC gc;
gc.Start();
{
std::shared_ptr<GC> gc= std::make_shared<GC>();
gc->Start();
GCList ls(gc);
TRootEnvironment* env = TRootEnvironment::Create(ls, TDictionary::Create(ls));
TStd::RegisterStd(&gc,env);
TStd::RegisterStd(gc,env);
auto res= Programs::CrossLangInterperter(ls, env, args);
GetObject(res,myi64);
}
return (int)myi64;
}
@@ -148,33 +148,29 @@ int main(int argc, char** argv)
int64_t myi64=0;
args.erase(args.begin());
GC gc;
gc.Start();
{
std::shared_ptr<GC> gc= std::make_shared<GC>();
gc->Start();
GCList ls(gc);
TRootEnvironment* env = TRootEnvironment::Create(ls, TDictionary::Create(ls));
TStd::RegisterStd(&gc,env);
TStd::RegisterStd(gc,env);
auto res= Programs::CrossLangVM(ls, env, args);
GetObject(res,myi64);
}
return (int)myi64;
}
}
{
int64_t myi64=0;
GC gc;
gc.Start();
{
std::shared_ptr<GC> gc= std::make_shared<GC>();
gc->Start();
GCList ls(gc);
auto res= Programs::CrossLangShell(ls, args);
GetObject(res,myi64);
}
return (int)myi64;
}
}

View File

@@ -226,7 +226,7 @@ namespace Tesses::CrossLang
return nullptr;
}
void TStd::RegisterClass(GC* gc, TRootEnvironment* env)
void TStd::RegisterClass(std::shared_ptr<GC> gc, TRootEnvironment* env)
{
GCList ls(gc);
env->permissions.canRegisterClass=true;

View File

@@ -280,7 +280,7 @@ namespace Tesses::CrossLang {
return dict;
}
void TStd::RegisterConsole(GC* gc,TRootEnvironment* env)
void TStd::RegisterConsole(std::shared_ptr<GC> gc,TRootEnvironment* env)
{
env->permissions.canRegisterConsole=true;
if(env->permissions.customConsole != nullptr)

View File

@@ -99,7 +99,7 @@ namespace Tesses::CrossLang
}
return nullptr;
}
void TStd::RegisterCrypto(GC* gc,TRootEnvironment* env)
void TStd::RegisterCrypto(std::shared_ptr<GC> gc,TRootEnvironment* env)
{
env->permissions.canRegisterCrypto=true;

View File

@@ -129,7 +129,7 @@ namespace Tesses::CrossLang
}
return nullptr;
}
void TStd::RegisterDictionary(GC* gc,TRootEnvironment* env)
void TStd::RegisterDictionary(std::shared_ptr<GC> gc,TRootEnvironment* env)
{
env->permissions.canRegisterDictionary=true;

View File

@@ -136,7 +136,7 @@ namespace Tesses::CrossLang
{
return Tesses::Framework::Serialization::BitConverter::IsLittleEndian();
}
void TStd::RegisterEnv(GC* gc, TRootEnvironment* env)
void TStd::RegisterEnv(std::shared_ptr<GC> gc, TRootEnvironment* env)
{
env->permissions.canRegisterEnv=true;

View File

@@ -49,7 +49,7 @@ namespace Tesses::CrossLang {
}
return Undefined();
}
void TStd::RegisterHelpers(GC* gc, TRootEnvironment* env)
void TStd::RegisterHelpers(std::shared_ptr<GC> gc, TRootEnvironment* env)
{
auto helpers=env->EnsureDictionary(gc,"Helpers");
helpers->DeclareFunction(gc,"CopyToProgress","Copy Stream to another (but with progress event)",{"src","dest","progressCB","$precision"},Helpers_CopyToProgress);

View File

@@ -4,23 +4,6 @@
namespace Tesses::CrossLang
{
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;
}
static TObject FS_CreateArchive(GCList& ls, std::vector<TObject> args)
{
std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs;
@@ -160,17 +143,7 @@ namespace Tesses::CrossLang
return nullptr;
}
static TObject FS_getCurrentPath(GCList& ls, std::vector<TObject> args)
{
return Tesses::Framework::Filesystem::VFSPath::GetAbsoluteCurrentDirectory();
}
static TObject FS_setCurrentPath(GCList& ls, std::vector<TObject> args)
{
Tesses::Framework::Filesystem::VFSPath path;
if(GetArgumentAsPath(args,0,path))
Tesses::Framework::Filesystem::VFSPath::SetAbsoluteCurrentDirectory(path);
return nullptr;
}
@@ -287,12 +260,22 @@ namespace Tesses::CrossLang
}
return nullptr;
}
void TStd::RegisterIO(GC* gc,TRootEnvironment* env,bool enableLocalFilesystem)
void TStd::RegisterIO(std::shared_ptr<GC> gc,TRootEnvironment* env, bool enable)
{
if(enable)
{
RegisterIO(gc,env,std::make_shared<RelativeFilesystem>(Tesses::Framework::Filesystem::LocalFS, Tesses::Framework::Filesystem::VFSPath::GetAbsoluteCurrentDirectory()));
}
else
{
RegisterIO(gc,env,nullptr);
}
}
void TStd::RegisterIO(std::shared_ptr<GC> gc,TRootEnvironment* env,std::shared_ptr<RelativeFilesystem> fs)
{
env->permissions.canRegisterIO=true;
env->permissions.canRegisterLocalFS = enableLocalFilesystem;
env->permissions.localfs = fs;
GCList ls(gc);
gc->BarrierBegin();
@@ -323,14 +306,36 @@ namespace Tesses::CrossLang
}
));
if(enableLocalFilesystem)
if(fs)
{
dict->SetValue("Local", Tesses::Framework::Filesystem::LocalFS);
dict->DeclareFunction(gc, "MakeFull", "Make absolute path from relative path",{"path"},FS_MakeFull);
dict->DeclareFunction(gc,"getCurrentPath","Get current path",{},FS_getCurrentPath);
dict->DeclareFunction(gc,"setCurrentPath","Set the current path",{"path"},FS_setCurrentPath);
dict->SetValue("Local", fs);
dict->DeclareFunction(gc, "MakeFull", "Make absolute path from relative path",{"path"},[fs](GCList& ls, std::vector<TObject> args)->TObject{
Tesses::Framework::Filesystem::VFSPath path;
if(GetArgumentAsPath(args,0,path))
{
if(path.relative)
{
auto myPath = fs->GetWorking() / path;
myPath = myPath.CollapseRelativeParents();
return myPath;
}
return path.CollapseRelativeParents();
}
return nullptr;
});
dict->DeclareFunction(gc,"getCurrentPath","Get current path",{},[fs](GCList& ls, std::vector<TObject> args)->TObject{
return fs->GetWorking();
});
dict->DeclareFunction(gc,"setCurrentPath","Set the current path",{"path"}, [fs](GCList& ls, std::vector<TObject> args)->TObject {
Tesses::Framework::Filesystem::VFSPath path;
if(GetArgumentAsPath(args,0,path))
{
fs->SetWorking(path);
}
return path;
});
}
dict->DeclareFunction(gc, "ReadAllText","Read all text from file", {"fs","filename"},FS_ReadAllText);

View File

@@ -186,7 +186,7 @@ namespace Tesses::CrossLang
{
return JsonDeserialize(ls,Json::DocDecode(str));
}
void TStd::RegisterJson(GC* gc,TRootEnvironment* env)
void TStd::RegisterJson(std::shared_ptr<GC> gc,TRootEnvironment* env)
{
env->permissions.canRegisterJSON=true;

View File

@@ -379,6 +379,56 @@ namespace Tesses::CrossLang
ctx->WithLastModified(*da);
return this;
}
else if(key == "WithDebug")
{
bool debug=true;
GetArgument(args,0,debug);
ctx->WithDebug(debug);
return this;
}
else if(key == "getDebug")
{
return ctx->Debug();
}
else if(key == "SendServerSentEvents")
{
if(!args.empty() && std::holds_alternative<std::shared_ptr<Tesses::Framework::Http::ServerSentEvents>>(args[0]))
{
ctx->SendServerSentEvents(std::get<std::shared_ptr<Tesses::Framework::Http::ServerSentEvents>>(args[0]));
}
}
else if(key == "WithHeaderIntercepter")
{
TCallable* callable;
if(GetArgumentHeap(args, 0, callable))
{
auto marked = CreateMarkedTObject(ls.GetGC(),callable);
ctx->WithHeaderIntercepter([marked](ServerContext& ctx)->bool {
auto obj = marked->GetObject();
TCallable* callable;
if(GetObjectHeap(obj, callable))
{
GCList ls(marked->GetGC());
auto ptr=TNativeObject::Create<TServerContext>(ls, &ctx);
auto res = callable->Call(ls, {ptr});
ptr->Finish();
bool r0;
if(GetObject(res, r0)) return r0;
}
return false;
});
}
return this;
}
else if(key == "WithContentDisposition")
{
std::string filename;
@@ -589,7 +639,7 @@ namespace Tesses::CrossLang
}
};
TObjectHttpServer::TObjectHttpServer(GC* gc,TObject obj)
TObjectHttpServer::TObjectHttpServer(std::shared_ptr<GC> gc,TObject obj)
{
this->ls=new GCList(gc);
this->ls->Add(obj);
@@ -598,10 +648,10 @@ namespace Tesses::CrossLang
class TDictionaryHttpRequestBody : public HttpRequestBody
{
GC* gc;
std::shared_ptr<GC> gc;
TDictionary* req;
public:
TDictionaryHttpRequestBody(GC* gc,TDictionary* req)
TDictionaryHttpRequestBody(std::shared_ptr<GC> gc,TDictionary* req)
{
this->gc = gc;
this->req = req;
@@ -790,7 +840,7 @@ namespace Tesses::CrossLang
}
if(GetArgument(args,1,pathStr) && env->permissions.canRegisterLocalFS)
if(GetArgument(args,1,pathStr) && env->permissions.localfs)
{
std::shared_ptr<IHttpServer> httpSvr = ToHttpServer(ls.GetGC(),args[0]);
@@ -979,7 +1029,7 @@ namespace Tesses::CrossLang
GetObject(_obj,req.followRedirects);
_obj = options->GetValue("TrustedRootCertBundle");
GetObject(_obj,req.trusted_root_cert_bundle);
if(env->permissions.canRegisterLocalFS)
if(env->permissions.localfs)
{
_obj = options->GetValue("UnixSocket");
GetObject(_obj,req.unixSocket);
@@ -1403,7 +1453,7 @@ namespace Tesses::CrossLang
return false;
}
std::shared_ptr<IHttpServer> ToHttpServer(GC* gc, TObject obj)
std::shared_ptr<IHttpServer> ToHttpServer(std::shared_ptr<GC> gc, TObject obj)
{
if(std::holds_alternative<std::shared_ptr<IHttpServer>>(obj)) return std::get<std::shared_ptr<IHttpServer>>(obj);
TDictionary* dict;
@@ -1522,8 +1572,13 @@ namespace Tesses::CrossLang
return nullptr;
}
static TObject New_ServerSentEvents(GCList& ls, std::vector<TObject> args)
{
return std::make_shared<Tesses::Framework::Http::ServerSentEvents>();
}
void TStd::RegisterNet(GC* gc, TRootEnvironment* env)
void TStd::RegisterNet(std::shared_ptr<GC> gc, TRootEnvironment* env)
{
env->permissions.canRegisterNet=true;
@@ -1545,6 +1600,7 @@ namespace Tesses::CrossLang
_new->DeclareFunction(gc, "MountableServer","Create a server you can mount to, must mount parents before child",{"root"}, New_MountableServer);
_new->DeclareFunction(gc, "NetworkStream","Create a network stream",{"ipv6","datagram"},New_NetworkStream);
_new->DeclareFunction(gc, "ServerSentEvents", "Create server sent events object",{""},New_ServerSentEvents);
TDictionary* http = TDictionary::Create(ls);
@@ -1617,7 +1673,7 @@ namespace Tesses::CrossLang
gc->BarrierEnd();
}
Tesses::Framework::Http::ServerRequestHandler TCallable::ToRouteServerRequestHandler(GC* gc)
Tesses::Framework::Http::ServerRequestHandler TCallable::ToRouteServerRequestHandler(std::shared_ptr<GC> gc)
{
auto value = CreateMarkedTObject(gc,this);
return [value,this](ServerContext& ctx)->bool {

View File

@@ -46,7 +46,7 @@ namespace Tesses::CrossLang
}
#endif
#endif
void TStd::RegisterOGC(GC* gc, TRootEnvironment* env)
void TStd::RegisterOGC(std::shared_ptr<GC> gc, TRootEnvironment* env)
{
GCList ls(gc);
#if defined(GEKKO)

View File

@@ -65,7 +65,7 @@ namespace Tesses::CrossLang
return nullptr;
}
void TStd::RegisterPath(GC* gc,TRootEnvironment* env)
void TStd::RegisterPath(std::shared_ptr<GC> gc,TRootEnvironment* env)
{
env->permissions.canRegisterPath=true;

View File

@@ -184,7 +184,7 @@ namespace Tesses::CrossLang
return Undefined();
}
};
static TObject Process_Start(GCList& ls, std::vector<TObject> args)
static TObject Process_Start(GCList& ls, std::vector<TObject> args, TRootEnvironment* env)
{
//Process.Start({
@@ -220,7 +220,11 @@ namespace Tesses::CrossLang
GetObject(name,process->process.name);
Tesses::Framework::Filesystem::VFSPath wdPath;
if(env->permissions.localfs)
{
process->process.workingDirectory = env->permissions.localfs->GetWorking().ToString();
}
if(GetObject(workingDirectory,wdPath))
{
process->process.workingDirectory= wdPath.MakeAbsolute().ToString();
@@ -274,23 +278,36 @@ namespace Tesses::CrossLang
return nullptr;
}
static TObject New_Process(GCList& ls, std::vector<TObject> args)
{
return TNativeObject::Create<ProcessObject>(ls,ls);
}
void TStd::RegisterProcess(GC* gc,TRootEnvironment* env)
void TStd::RegisterProcess(std::shared_ptr<GC> gc,TRootEnvironment* env)
{
env->permissions.canRegisterProcess=true;
GCList ls(gc);
TDictionary* dict = TDictionary::Create(ls);
dict->DeclareFunction(gc,"Start","Start a process",{"process_object"},Process_Start);
gc->BarrierBegin();
auto processStart = TExternalMethod::Create(ls,"Start a process",{"process_object"},[env](GCList& ls, std::vector<TObject> args)->TObject{
return Process_Start(ls,args,env);
});
processStart->watch.push_back(env);
dict->SetValue("Start",processStart);
env->SetVariable("Process",dict);
auto process = env->EnsureDictionary(gc,"New");
process->DeclareFunction(gc, "Process", "Create process",{},New_Process);
auto newProcess = TExternalMethod::Create(ls, "Create process",{},[env](GCList& ls, std::vector<TObject> args)->TObject {
auto obj= TNativeObject::Create<ProcessObject>(ls,ls);
if(env->permissions.localfs)
{
obj->process.workingDirectory = env->permissions.localfs->GetWorking().ToString();
}
return obj;
});
newProcess->watch.push_back(env);
process->SetValue("Process",newProcess);
//process->DeclareFunction(gc, "Process", "Create process",{},New_Process);
process->DeclareFunction(gc, "CGIServer", "Create a CGI Server",{"path"},[](GCList& ls, std::vector<TObject> args)->TObject{
Tesses::Framework::Filesystem::VFSPath path;
if(GetArgumentAsPath(args,0,path))

View File

@@ -150,7 +150,7 @@ namespace Tesses::CrossLang {
}
#endif
void TStd::RegisterSqlite(GC* gc,TRootEnvironment* env)
void TStd::RegisterSqlite(std::shared_ptr<GC> gc,TRootEnvironment* env)
{
env->permissions.canRegisterSqlite=true;

View File

@@ -376,7 +376,7 @@ namespace Tesses::CrossLang
void RegisterFFI(GC* gc, TDictionary* dict)
void RegisterFFI(std::shared_ptr<GC> gc, TDictionary* dict)
{
dict->SetValue("SizeOfChar",(int64_t)sizeof(char));
dict->SetValue("SizeOfShort",(int64_t)sizeof(short));
@@ -485,14 +485,14 @@ namespace Tesses::CrossLang
}
void LoadPlugin(GC* gc, TRootEnvironment* env, Tesses::Framework::Filesystem::VFSPath sharedObjectPath)
void LoadPlugin(std::shared_ptr<GC> gc, TRootEnvironment* env, Tesses::Framework::Filesystem::VFSPath sharedObjectPath)
{
#if defined(CROSSLANG_ENABLE_SHARED)
auto ptr = std::make_shared<DL>(GetPluginPath(sharedObjectPath));
auto cb = ptr->Resolve<PluginFunction>("CrossLangPluginInit");
if(cb == nullptr) return;
gc->RegisterEverythingCallback([ptr,cb](GC* gc, TRootEnvironment* env)-> void{
gc->RegisterEverythingCallback([ptr,cb](std::shared_ptr<GC> gc, TRootEnvironment* env)-> void{
cb(gc,env);
});
cb(gc,env);
@@ -747,6 +747,9 @@ namespace Tesses::CrossLang
std::string GetObjectTypeString(TObject _obj)
{
if(std::holds_alternative<std::shared_ptr<Tesses::Framework::TF_Timer_Handle>>(_obj)) return "Timer";
if(std::holds_alternative<std::shared_ptr<Tesses::Framework::Http::ServerSentEvents>>(_obj)) return "ServerSentEvents";
if(std::holds_alternative<std::regex>(_obj)) return "Regex";
if(std::holds_alternative<Undefined>(_obj)) return "Undefined";
if(std::holds_alternative<std::nullptr_t>(_obj)) return "Null";
@@ -861,11 +864,20 @@ namespace Tesses::CrossLang
auto vfs = std::get<std::shared_ptr<Tesses::Framework::Filesystem::VFS>>(_obj);
if(vfs != nullptr)
{
auto rfs = std::dynamic_pointer_cast<RelativeFilesystem>(vfs);
auto localVFS = std::dynamic_pointer_cast<Tesses::Framework::Filesystem::LocalFilesystem>(vfs);
auto mountableVFS = std::dynamic_pointer_cast<Tesses::Framework::Filesystem::MountableFilesystem>(vfs);
auto subFS = std::dynamic_pointer_cast<Tesses::Framework::Filesystem::SubdirFilesystem>(vfs);
auto tempFS = std::dynamic_pointer_cast<Tesses::Framework::Filesystem::TempFS>(vfs);
if(rfs)
{
auto fs=rfs->GetVFS();
if(fs)
{
return GetObjectTypeString(fs);
}
return "RelativeFilesystem";
}
if(localVFS != nullptr) return "LocalFilesystem";
if(subFS != nullptr) return "SubdirFilesystem";
if(mountableVFS != nullptr) return "MountableFilesystem";
@@ -897,6 +909,7 @@ namespace Tesses::CrossLang
auto natObj = dynamic_cast<TNativeObject*>(obj);
auto cobj = dynamic_cast<TClassObject*>(obj);
auto aarray = dynamic_cast<TAssociativeArray*>(obj);
auto file = dynamic_cast<TFile*>(obj);
if(rootEnv != nullptr) return "RootEnvironment";
if(subEnv != nullptr) return "SubEnvironment";
@@ -917,6 +930,7 @@ namespace Tesses::CrossLang
if(byteArray != nullptr) return "ByteArray";
if(native != nullptr) return "Native";
if(any != nullptr) return "Any";
if(file != nullptr) return "File";
return "HeapObject";
}
@@ -1013,7 +1027,6 @@ namespace Tesses::CrossLang
this->canRegisterEnv=false;
this->canRegisterIO=false;
this->canRegisterJSON=false;
this->canRegisterLocalFS=false;
this->canRegisterNet=false;
this->canRegisterOGC=false;
this->canRegisterPath=false;
@@ -1261,8 +1274,34 @@ namespace Tesses::CrossLang
return std::make_shared<Tesses::Framework::Streams::ByteWriter>(strm);
return nullptr;
}
static void empty(){}
static TObject New_Timer(GCList& ls, std::vector<TObject> args)
{
TCallable* callable;
if(GetArgumentHeap(args, 0, callable))
{
int64_t interval = 1000;
bool enabled=true;
GetArgument(args,1, interval);
GetArgument(args,2,enabled);
void TStd::RegisterRoot(GC* gc, TRootEnvironment* env)
auto obj = CreateMarkedTObject(ls.GetGC(), callable);
return Tesses::Framework::TF_Timer([obj]()->void {
TCallable* callable;
if(GetObjectHeap(obj->GetObject(), callable))
{
GCList ls(obj->GetGC());
callable->Call(ls,{});
}
}, interval , enabled);
}
return Tesses::Framework::TF_Timer(empty, 1000L, false);
}
void TStd::RegisterRoot(std::shared_ptr<GC> gc, TRootEnvironment* env)
{
GCList ls(gc);
@@ -1325,8 +1364,9 @@ namespace Tesses::CrossLang
newTypes->DeclareFunction(gc, "MemoryStream","Create a memory stream",{"writable"}, New_MemoryStream);
newTypes->DeclareFunction(gc, "Filesystem","Create filesystem", {"fs"},New_Filesystem);
newTypes->DeclareFunction(gc, "TempFS","Create a temp directory",{"",""}, New_TempFS);
newTypes->DeclareFunction(gc, "Timer", "Create a timer",{"$cb","$interval","$enabled"}, New_Timer);
newTypes->DeclareFunction(gc, "Stream","Create stream", {"strm"},New_Stream);
newTypes->DeclareFunction(gc,"Version","Create a version object",{"$major","$minor","$patch","$build","$stage"},[](GCList& ls, std::vector<TObject> args)->TObject{
int64_t major=1;
@@ -1477,14 +1517,18 @@ namespace Tesses::CrossLang
gc->BarrierEnd();
}
void TStd::RegisterStd(GC* gc, TRootEnvironment* env)
void TStd::RegisterStd(std::shared_ptr<GC> gc, TRootEnvironment* env)
{
RegisterStd(gc, env, std::make_shared<RelativeFilesystem>(Tesses::Framework::Filesystem::LocalFS, Tesses::Framework::Filesystem::VFSPath::GetAbsoluteCurrentDirectory()));
}
void TStd::RegisterStd(std::shared_ptr<GC> gc, TRootEnvironment* env,std::shared_ptr<RelativeFilesystem> localfs)
{
env->permissions.canRegisterEverything=true;
RegisterEnv(gc, env);
RegisterRoot(gc,env);
RegisterPath(gc,env);
RegisterConsole(gc, env);
RegisterIO(gc, env);
RegisterIO(gc, env, localfs);
RegisterNet(gc, env);
RegisterSqlite(gc, env);
RegisterVM(gc, env);

View File

@@ -27,7 +27,7 @@ namespace Tesses::CrossLang {
return nullptr;
}
void TStd::RegisterUuid(GC* gc, TRootEnvironment* env)
void TStd::RegisterUuid(std::shared_ptr<GC> gc, TRootEnvironment* env)
{
gc->BarrierBegin();
TDictionary* guid = env->EnsureDictionary(gc, "Uuid");

View File

@@ -317,7 +317,7 @@ namespace Tesses::CrossLang
}
return nullptr;
}
void TStd::RegisterVM(GC* gc,TRootEnvironment* env)
void TStd::RegisterVM(std::shared_ptr<GC> gc,TRootEnvironment* env)
{
env->permissions.canRegisterVM=true;
GCList ls(gc);

View File

@@ -5,7 +5,7 @@ namespace Tesses::CrossLang {
{
TAny* anyObj = new TAny();
GC* gc = ls.GetGC();
std::shared_ptr<GC> gc = ls.GetGC();
ls.Add(anyObj);
gc->Watch(anyObj);
return anyObj;
@@ -14,7 +14,7 @@ namespace Tesses::CrossLang {
{
TAny* anyObj = new TAny();
GC* gc = ls->GetGC();
std::shared_ptr<GC> gc = ls->GetGC();
ls->Add(anyObj);
gc->Watch(anyObj);
return anyObj;

View File

@@ -6,7 +6,7 @@ namespace Tesses::CrossLang
TAssociativeArray* TAssociativeArray::Create(GCList& ls)
{
TAssociativeArray* list=new TAssociativeArray();
GC* _gc = ls.GetGC();
std::shared_ptr<GC> _gc = ls.GetGC();
ls.Add(list);
_gc->Watch(list);
return list;
@@ -14,12 +14,12 @@ namespace Tesses::CrossLang
TAssociativeArray* TAssociativeArray::Create(GCList* ls)
{
TAssociativeArray* list=new TAssociativeArray();
GC* _gc = ls->GetGC();
std::shared_ptr<GC> _gc = ls->GetGC();
ls->Add(list);
_gc->Watch(list);
return list;
}
void TAssociativeArray::Set(GC* gc, TObject key, TObject value)
void TAssociativeArray::Set(std::shared_ptr<GC> gc, TObject key, TObject value)
{
if(std::holds_alternative<Undefined>(key)) return;
gc->BarrierBegin();
@@ -46,7 +46,7 @@ namespace Tesses::CrossLang
this->items.push_back(std::pair<TObject,TObject>(key,value));
gc->BarrierEnd();
}
TObject TAssociativeArray::Get(GC* gc, TObject key)
TObject TAssociativeArray::Get(std::shared_ptr<GC> gc, TObject key)
{
if(std::holds_alternative<Undefined>(key)) return Undefined();
gc->BarrierBegin();

View File

@@ -1,7 +1,7 @@
#include "CrossLang.hpp"
//THANKS TO https://www.youtube.com/watch?v=R-z2Hv-7nxk
namespace Tesses::CrossLang {
TTask::TTask(GC* gc)
TTask::TTask(std::shared_ptr<GC> gc)
{
this->gc = gc;
}
@@ -172,10 +172,10 @@ namespace Tesses::CrossLang {
}
class TTaskCseObj {
GC* gc;
std::shared_ptr<GC> gc;
TTask* task;
public:
TTaskCseObj(GC* gc, TTask* task)
TTaskCseObj(std::shared_ptr<GC> gc, TTask* task)
{
this->gc = gc;
this->task = task;
@@ -230,7 +230,7 @@ namespace Tesses::CrossLang {
//try {
GCList ls2(ls.GetGC());
GC* gc = ls.GetGC();
std::shared_ptr<GC> gc = ls.GetGC();
std::shared_ptr<TTaskCseObj> obj = std::make_shared<TTaskCseObj>(gc,task);

View File

@@ -43,6 +43,9 @@ namespace Tesses::CrossLang
return nullptr;
}
break;
default:
//DO NOTHING
break;
}
return &item;

View File

@@ -13,7 +13,7 @@ namespace Tesses::CrossLang {
TClassEnvironment* env2=new TClassEnvironment(env,obj);
GC* _gc = gc->GetGC();
std::shared_ptr<GC> _gc = gc->GetGC();
gc->Add(env2);
_gc->Watch(env2);
return env2;
@@ -23,7 +23,7 @@ namespace Tesses::CrossLang {
TClassEnvironment* env2=new TClassEnvironment(env,obj);
GC* _gc = gc.GetGC();
std::shared_ptr<GC> _gc = gc.GetGC();
gc.Add(env2);
_gc->Watch(env2);
return env2;

View File

@@ -4,7 +4,7 @@ namespace Tesses::CrossLang {
{
TArgWrapper* argWrapper = new TArgWrapper();
argWrapper->callable = callable;
GC* gc = ls.GetGC();
std::shared_ptr<GC> gc = ls.GetGC();
ls.Add(argWrapper);
gc->Watch(argWrapper);
return argWrapper;
@@ -13,7 +13,7 @@ namespace Tesses::CrossLang {
{
TArgWrapper* argWrapper = new TArgWrapper();
argWrapper->callable = callable;
GC* gc = ls->GetGC();
std::shared_ptr<GC> gc = ls->GetGC();
ls->Add(argWrapper);
gc->Watch(argWrapper);
return argWrapper;
@@ -54,7 +54,7 @@ namespace Tesses::CrossLang {
TClosure* closure = new TClosure();
closure->className="";
closure->ownScope=ownScope;
GC* _gc = ls.GetGC();
std::shared_ptr<GC> _gc = ls.GetGC();
ls.Add(closure);
_gc->Watch(closure);
closure->chunkId = chunkId;
@@ -71,7 +71,7 @@ namespace Tesses::CrossLang {
TClosure* closure = new TClosure();
closure->className="";
closure->ownScope=ownScope;
GC* _gc = ls->GetGC();
std::shared_ptr<GC> _gc = ls->GetGC();
ls->Add(closure);
_gc->Watch(closure);
closure->chunkId = chunkId;

View File

@@ -6,7 +6,7 @@ namespace Tesses::CrossLang {
TDynamicDictionary* dict=new TDynamicDictionary();
dict->cb = callable;
GC* _gc = ls.GetGC();
std::shared_ptr<GC> _gc = ls.GetGC();
ls.Add(dict);
_gc->Watch(dict);
return dict;
@@ -15,7 +15,7 @@ namespace Tesses::CrossLang {
{
TDynamicDictionary* dict=new TDynamicDictionary();
dict->cb = callable;
GC* _gc = ls->GetGC();
std::shared_ptr<GC> _gc = ls->GetGC();
ls->Add(dict);
_gc->Watch(dict);
return dict;
@@ -153,34 +153,22 @@ namespace Tesses::CrossLang {
return Undefined();
}
void TDictionary::DeclareFunction(GC* gc,std::string key,std::string documentation, std::vector<std::string> argNames, std::function<TObject(GCList& ls, std::vector<TObject> args)> cb)
void TDictionary::DeclareFunction(std::shared_ptr<GC> gc,std::string key,std::string documentation, std::vector<std::string> argNames, std::function<TObject(GCList& ls, std::vector<TObject> args)> cb)
{
gc->BarrierBegin();
GCList ls(gc);
this->SetValue(key, TExternalMethod::Create(ls,documentation,argNames,cb));
gc->BarrierEnd();
}
void TDictionary::DeclareFunction(GC& gc,std::string key,std::string documentation, std::vector<std::string> argNames, std::function<TObject(GCList& ls, std::vector<TObject> args)> cb)
{
gc.BarrierBegin();
GCList ls(gc);
this->SetValue(key, TExternalMethod::Create(ls,documentation,argNames,cb));
gc.BarrierEnd();
}
void TDictionary::DeclareFunction(GC* gc,std::string key,std::string documentation, std::vector<std::string> argNames, std::function<TObject(GCList& ls, std::vector<TObject> args)> cb,std::function<void()> destroy)
void TDictionary::DeclareFunction(std::shared_ptr<GC> gc,std::string key,std::string documentation, std::vector<std::string> argNames, std::function<TObject(GCList& ls, std::vector<TObject> args)> cb,std::function<void()> destroy)
{
gc->BarrierBegin();
GCList ls(gc);
this->SetValue(key, TExternalMethod::Create(ls,documentation,argNames,cb,destroy));
gc->BarrierEnd();
}
void TDictionary::DeclareFunction(GC& gc,std::string key,std::string documentation, std::vector<std::string> argNames, std::function<TObject(GCList& ls, std::vector<TObject> args)> cb,std::function<void()> destroy)
{
gc.BarrierBegin();
GCList ls(gc);
this->SetValue(key, TExternalMethod::Create(ls,documentation,argNames,cb,destroy));
gc.BarrierEnd();
}
TObject TDictionary::GetValue(std::string key)
{
if(this->items.empty()) return Undefined();
@@ -216,7 +204,7 @@ namespace Tesses::CrossLang {
TDictionary* TDictionary::Create(GCList* gc)
{
TDictionary* dict=new TDictionary();
GC* _gc = gc->GetGC();
std::shared_ptr<GC> _gc = gc->GetGC();
gc->Add(dict);
_gc->Watch(dict);
return dict;
@@ -224,7 +212,7 @@ namespace Tesses::CrossLang {
TDictionary* TDictionary::Create(GCList& gc)
{
TDictionary* dict=new TDictionary();
GC* _gc = gc.GetGC();
std::shared_ptr<GC> _gc = gc.GetGC();
gc.Add(dict);
_gc->Watch(dict);
return dict;

View File

@@ -2,7 +2,7 @@
namespace Tesses::CrossLang {
EmbedStream::EmbedStream(GC* gc, TFile* file, uint32_t resource)
EmbedStream::EmbedStream(std::shared_ptr<GC> gc, TFile* file, uint32_t resource)
{
this->offset = 0;
this->resource = resource;
@@ -124,17 +124,58 @@ namespace Tesses::CrossLang {
}
return nullptr;
}
bool EmbedDirectory::RegularFileExists(Tesses::Framework::Filesystem::VFSPath path)
{
auto ent = getEntry(path);
TCallable* call;
return GetObjectHeap(ent,call);
}
bool EmbedDirectory::DirectoryExists(Tesses::Framework::Filesystem::VFSPath path)
bool EmbedDirectory::Stat(Tesses::Framework::Filesystem::VFSPath path, Tesses::Framework::Filesystem::StatData& data)
{
auto ent = getEntry(path);
TDictionary* dict;
return GetObjectHeap(ent,dict);
if(GetObjectHeap(ent,dict))
{
data.Size = 0;
data.Mode = Tesses::Framework::Filesystem::MODE_DIRECTORY | 0755;
data.BlockCount = 0;
data.BlockSize = 0;
data.Device = 0;
data.DeviceId = 0;
data.GroupId = 0;
data.HardLinks = 1;
data.Inode = 0;
data.LastAccess = Tesses::Framework::Date::DateTime(0);
data.LastModified = Tesses::Framework::Date::DateTime(0);
data.LastStatus = Tesses::Framework::Date::DateTime(0);
data.UserId = 0;
return true;
}
TCallable* cal;
if(GetObjectHeap(ent, cal))
{
GCList ls(this->dir->GetGC());
auto fileO= cal->Call(ls, {});
std::shared_ptr<Tesses::Framework::Streams::Stream> strm;
if(GetObject(fileO,strm)) {
data.Size = (uint64_t)strm->GetLength();
data.Mode = Tesses::Framework::Filesystem::MODE_REGULAR | 0755;
data.BlockSize = 512;
data.BlockCount = data.Size / data.BlockSize;
data.Device = 0;
data.DeviceId = 0;
data.GroupId = 0;
data.HardLinks = 1;
data.Inode = 0;
data.LastAccess = Tesses::Framework::Date::DateTime(0);
data.LastModified = Tesses::Framework::Date::DateTime(0);
data.LastStatus = Tesses::Framework::Date::DateTime(0);
data.UserId = 0;
return true;
}
}
return false;
}
class DICT_DIRENUM
@@ -148,7 +189,7 @@ namespace Tesses::CrossLang {
{
return this->current->first;
}
DICT_DIRENUM(GC* gc, TDictionary* dict) : ls(gc), dict(dict)
DICT_DIRENUM(std::shared_ptr<GC> gc, TDictionary* dict) : ls(gc), dict(dict)
{
ls.Add(dict);
}
@@ -197,26 +238,11 @@ namespace Tesses::CrossLang {
return Tesses::Framework::Filesystem::VFSPathEnumerator();
}
EmbedDirectory::EmbedDirectory(GC* gc, TDictionary* dict)
EmbedDirectory::EmbedDirectory(std::shared_ptr<GC> gc, TDictionary* dict)
{
this->dir = CreateMarkedTObject(gc, dict);
}
void EmbedDirectory::CreateDirectory(Tesses::Framework::Filesystem::VFSPath path)
{
//DO NOTHING
}
void EmbedDirectory::DeleteDirectory(Tesses::Framework::Filesystem::VFSPath path)
{
}
void EmbedDirectory::DeleteFile(Tesses::Framework::Filesystem::VFSPath path)
{
}
void EmbedDirectory::MoveFile(Tesses::Framework::Filesystem::VFSPath src, Tesses::Framework::Filesystem::VFSPath dest)
{
}
std::string EmbedDirectory::VFSPathToSystem(Tesses::Framework::Filesystem::VFSPath path)
{
return path.ToString();

View File

@@ -2,7 +2,7 @@
namespace Tesses::CrossLang
{
bool TYieldEnumerator::MoveNext(GC* ls)
bool TYieldEnumerator::MoveNext(std::shared_ptr<GC> ls)
{
CallStackEntry* ent;
GCList ls2(ls);
@@ -56,7 +56,7 @@ namespace Tesses::CrossLang
yieldEnum->hasStarted=false;
yieldEnum->enumerator = v;
GC* _gc = ls.GetGC();
std::shared_ptr<GC> _gc = ls.GetGC();
ls.Add(yieldEnum);
_gc->Watch(yieldEnum);
return yieldEnum;
@@ -69,13 +69,13 @@ namespace Tesses::CrossLang
yieldEnum->hasStarted=false;
yieldEnum->enumerator = v;
GC* _gc = ls->GetGC();
std::shared_ptr<GC> _gc = ls->GetGC();
ls->Add(yieldEnum);
_gc->Watch(yieldEnum);
return yieldEnum;
}
bool TCustomEnumerator::MoveNext(GC* ls)
bool TCustomEnumerator::MoveNext(std::shared_ptr<GC> ls)
{
GCList ls2(ls);
auto res = this->dict->CallMethod(ls2,"MoveNext",{});
@@ -110,7 +110,7 @@ namespace Tesses::CrossLang
{
TCustomEnumerator* customEnum = new TCustomEnumerator();
customEnum->dict = dict;
GC* _gc = ls->GetGC();
std::shared_ptr<GC> _gc = ls->GetGC();
ls->Add(customEnum);
_gc->Watch(customEnum);
return customEnum;
@@ -119,7 +119,7 @@ namespace Tesses::CrossLang
{
TCustomEnumerator* customEnum = new TCustomEnumerator();
customEnum->dict = dict;
GC* _gc = ls.GetGC();
std::shared_ptr<GC> _gc = ls.GetGC();
ls.Add(customEnum);
_gc->Watch(customEnum);
return customEnum;
@@ -162,7 +162,7 @@ namespace Tesses::CrossLang
{
TVFSPathEnumerator* vfspathe = new TVFSPathEnumerator();
vfspathe->enumerator = enumerator;
GC* _gc = ls.GetGC();
std::shared_ptr<GC> _gc = ls.GetGC();
ls.Add(vfspathe);
_gc->Watch(vfspathe);
return vfspathe;
@@ -171,12 +171,12 @@ namespace Tesses::CrossLang
{
TVFSPathEnumerator* vfspathe = new TVFSPathEnumerator();
vfspathe->enumerator = enumerator;
GC* _gc = ls->GetGC();
std::shared_ptr<GC> _gc = ls->GetGC();
ls->Add(vfspathe);
_gc->Watch(vfspathe);
return vfspathe;
}
bool TVFSPathEnumerator::MoveNext(GC* ls)
bool TVFSPathEnumerator::MoveNext(std::shared_ptr<GC> ls)
{
return enumerator.MoveNext();
}
@@ -189,7 +189,7 @@ namespace Tesses::CrossLang
TDictionaryEnumerator* dicte=new TDictionaryEnumerator();
dicte->dict = dict;
dicte->hasStarted=false;
GC* _gc = ls.GetGC();
std::shared_ptr<GC> _gc = ls.GetGC();
ls.Add(dicte);
_gc->Watch(dicte);
return dicte;
@@ -199,13 +199,13 @@ namespace Tesses::CrossLang
TDictionaryEnumerator* dicte=new TDictionaryEnumerator();
dicte->dict = dict;
dicte->hasStarted=false;
GC* _gc = ls->GetGC();
std::shared_ptr<GC> _gc = ls->GetGC();
ls->Add(dicte);
_gc->Watch(dicte);
return dicte;
}
bool TDictionaryEnumerator::MoveNext(GC* ls)
bool TDictionaryEnumerator::MoveNext(std::shared_ptr<GC> ls)
{
if(!this->hasStarted)
{
@@ -248,7 +248,7 @@ namespace Tesses::CrossLang
TListEnumerator* liste=new TListEnumerator();
liste->ls = list;
liste->index = -1;
GC* _gc = ls.GetGC();
std::shared_ptr<GC> _gc = ls.GetGC();
ls.Add(liste);
_gc->Watch(liste);
return liste;
@@ -258,12 +258,12 @@ namespace Tesses::CrossLang
TListEnumerator* liste=new TListEnumerator();
liste->ls = list;
liste->index = -1;
GC* _gc = ls->GetGC();
std::shared_ptr<GC> _gc = ls->GetGC();
ls->Add(liste);
_gc->Watch(liste);
return liste;
}
bool TListEnumerator::MoveNext(GC* ls)
bool TListEnumerator::MoveNext(std::shared_ptr<GC> ls)
{
this->index++;
return this->index >= 0 && this->index < this->ls->Count();
@@ -291,7 +291,7 @@ namespace Tesses::CrossLang
TAssociativeArrayEnumerator* liste=new TAssociativeArrayEnumerator();
liste->ls = list;
liste->index = -1;
GC* _gc = ls.GetGC();
std::shared_ptr<GC> _gc = ls.GetGC();
ls.Add(liste);
_gc->Watch(liste);
return liste;
@@ -301,12 +301,12 @@ namespace Tesses::CrossLang
TAssociativeArrayEnumerator* liste=new TAssociativeArrayEnumerator();
liste->ls = list;
liste->index = -1;
GC* _gc = ls->GetGC();
std::shared_ptr<GC> _gc = ls->GetGC();
ls->Add(liste);
_gc->Watch(liste);
return liste;
}
bool TAssociativeArrayEnumerator::MoveNext(GC* ls)
bool TAssociativeArrayEnumerator::MoveNext(std::shared_ptr<GC> ls)
{
this->index++;
return this->index >= 0 && this->index < this->ls->Count();
@@ -338,7 +338,7 @@ namespace Tesses::CrossLang
TDynamicListEnumerator* liste=new TDynamicListEnumerator();
liste->ls = list;
liste->index = -1;
GC* _gc = ls.GetGC();
std::shared_ptr<GC> _gc = ls.GetGC();
ls.Add(liste);
_gc->Watch(liste);
return liste;
@@ -348,12 +348,12 @@ namespace Tesses::CrossLang
TDynamicListEnumerator* liste=new TDynamicListEnumerator();
liste->ls = list;
liste->index = -1;
GC* _gc = ls->GetGC();
std::shared_ptr<GC> _gc = ls->GetGC();
ls->Add(liste);
_gc->Watch(liste);
return liste;
}
bool TDynamicListEnumerator::MoveNext(GC* ls)
bool TDynamicListEnumerator::MoveNext(std::shared_ptr<GC> ls)
{
this->index++;
GCList ls2(ls);
@@ -384,7 +384,7 @@ namespace Tesses::CrossLang
TStringEnumerator* stre=new TStringEnumerator();
stre->str = str;
stre->hasStarted=false;
GC* _gc = ls.GetGC();
std::shared_ptr<GC> _gc = ls.GetGC();
ls.Add(stre);
_gc->Watch(stre);
return stre;
@@ -394,12 +394,12 @@ namespace Tesses::CrossLang
TStringEnumerator* stre=new TStringEnumerator();
stre->str = str;
stre->hasStarted=false;
GC* _gc = ls->GetGC();
std::shared_ptr<GC> _gc = ls->GetGC();
ls->Add(stre);
_gc->Watch(stre);
return stre;
}
bool TStringEnumerator::MoveNext(GC* ls)
bool TStringEnumerator::MoveNext(std::shared_ptr<GC> ls)
{
if(!this->hasStarted)
{

View File

@@ -4,7 +4,7 @@ namespace Tesses::CrossLang {
{
TDynamicList* list=new TDynamicList();
list->cb = callable;
GC* _gc = ls.GetGC();
std::shared_ptr<GC> _gc = ls.GetGC();
ls.Add(list);
_gc->Watch(list);
return list;
@@ -13,7 +13,7 @@ namespace Tesses::CrossLang {
{
TDynamicList* list=new TDynamicList();
list->cb = callable;
GC* _gc = ls->GetGC();
std::shared_ptr<GC> _gc = ls->GetGC();
ls->Add(list);
_gc->Watch(list);
return list;
@@ -140,7 +140,7 @@ namespace Tesses::CrossLang {
TByteArray* TByteArray::Create(GCList& ls)
{
TByteArray* arr=new TByteArray();
GC* _gc = ls.GetGC();
std::shared_ptr<GC> _gc = ls.GetGC();
ls.Add(arr);
_gc->Watch(arr);
return arr;
@@ -149,7 +149,7 @@ namespace Tesses::CrossLang {
TByteArray* TByteArray::Create(GCList* ls)
{
TByteArray* arr=new TByteArray();
GC* _gc = ls->GetGC();
std::shared_ptr<GC> _gc = ls->GetGC();
ls->Add(arr);
_gc->Watch(arr);
return arr;
@@ -157,7 +157,7 @@ namespace Tesses::CrossLang {
TList* TList::Create(GCList* gc)
{
TList* list=new TList();
GC* _gc = gc->GetGC();
std::shared_ptr<GC> _gc = gc->GetGC();
gc->Add(list);
_gc->Watch(list);
return list;
@@ -165,7 +165,7 @@ namespace Tesses::CrossLang {
TList* TList::Create(GCList& gc)
{
TList* list=new TList();
GC* _gc = gc.GetGC();
std::shared_ptr<GC> _gc = gc.GetGC();
gc.Add(list);
_gc->Watch(list);
return list;

View File

@@ -43,7 +43,7 @@ namespace Tesses::CrossLang
{
return true;
}
bool TNativeObject::Equals(GC* gc, TObject right)
bool TNativeObject::Equals(std::shared_ptr<GC> gc, TObject right)
{
if(std::holds_alternative<THeapObjectHolder>(right))
{
@@ -54,7 +54,7 @@ namespace Tesses::CrossLang
TNative* TNative::Create(GCList& ls, void* ptr,std::function<void(void*)> destroy)
{
TNative* native = new TNative(ptr,destroy);
GC* gc = ls.GetGC();
std::shared_ptr<GC> gc = ls.GetGC();
ls.Add(native);
gc->Watch(native);
return native;
@@ -62,7 +62,7 @@ namespace Tesses::CrossLang
TNative* TNative::Create(GCList* ls, void* ptr,std::function<void(void*)> destroy)
{
TNative* native = new TNative(ptr,destroy);
GC* gc = ls->GetGC();
std::shared_ptr<GC> gc = ls->GetGC();
ls->Add(native);
gc->Watch(native);
return native;

275
src/types/relativefs.cpp Normal file
View File

@@ -0,0 +1,275 @@
#include "CrossLang.hpp"
namespace Tesses::CrossLang
{
RelativeFilesystem::RelativeFilesystem(std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs, Tesses::Framework::Filesystem::VFSPath working)
{
this->vfs = vfs;
this->path = working;
}
std::shared_ptr<Tesses::Framework::Streams::Stream> RelativeFilesystem::OpenFile(Tesses::Framework::Filesystem::VFSPath path, std::string mode)
{
if(path.relative)
{
return this->vfs->OpenFile(path.MakeAbsolute(GetWorking()), mode);
}
else
{
return this->vfs->OpenFile(path,mode);
}
}
void RelativeFilesystem::CreateDirectory(Tesses::Framework::Filesystem::VFSPath path)
{
if(path.relative)
{
this->vfs->CreateDirectory(path.MakeAbsolute(GetWorking()));
}
else
{
this->vfs->CreateDirectory(path);
}
}
void RelativeFilesystem::DeleteDirectory(Tesses::Framework::Filesystem::VFSPath path)
{
if(path.relative)
{
this->vfs->DeleteDirectory(path.MakeAbsolute(GetWorking()));
}
else
{
this->vfs->DeleteDirectory(path);
}
}
void RelativeFilesystem::DeleteFile(Tesses::Framework::Filesystem::VFSPath path)
{
if(path.relative)
{
this->vfs->DeleteFile(path.MakeAbsolute(GetWorking()));
}
else
{
this->vfs->DeleteFile(path);
}
}
void RelativeFilesystem::CreateSymlink(Tesses::Framework::Filesystem::VFSPath existingFile, Tesses::Framework::Filesystem::VFSPath symlinkFile)
{
if(symlinkFile.relative)
{
this->vfs->CreateSymlink(existingFile,symlinkFile.MakeAbsolute(GetWorking()));
}
else
{
this->vfs->CreateSymlink(existingFile, symlinkFile);
}
}
Tesses::Framework::Filesystem::VFSPathEnumerator RelativeFilesystem::EnumeratePaths(Tesses::Framework::Filesystem::VFSPath path)
{
if(path.relative)
{
return this->vfs->EnumeratePaths(path.MakeAbsolute(GetWorking()));
}
else
{
return this->vfs->EnumeratePaths(path);
}
}
void RelativeFilesystem::CreateHardlink(Tesses::Framework::Filesystem::VFSPath existingFile, Tesses::Framework::Filesystem::VFSPath newName)
{
auto working = GetWorking();
if(existingFile.relative)
{
existingFile = existingFile.MakeAbsolute(working);
existingFile = existingFile.CollapseRelativeParents();
}
if(newName.relative)
{
newName = newName.MakeAbsolute(working);
newName = newName.CollapseRelativeParents();
}
this->vfs->CreateHardlink(existingFile, newName);
}
void RelativeFilesystem::MoveFile(Tesses::Framework::Filesystem::VFSPath src, Tesses::Framework::Filesystem::VFSPath dest)
{
auto working = GetWorking();
if(src.relative)
{
src = src.MakeAbsolute(working);
src = src.CollapseRelativeParents();
}
if(dest.relative)
{
dest = dest.MakeAbsolute(working);
dest = dest.CollapseRelativeParents();
}
this->vfs->MoveFile(src, dest);
}
void RelativeFilesystem::MoveDirectory(Tesses::Framework::Filesystem::VFSPath src, Tesses::Framework::Filesystem::VFSPath dest)
{
auto working = GetWorking();
if(src.relative)
{
src = src.MakeAbsolute(working);
src = src.CollapseRelativeParents();
}
if(dest.relative)
{
dest = dest.MakeAbsolute(working);
dest = dest.CollapseRelativeParents();
}
this->vfs->MoveFile(src, dest);
}
Tesses::Framework::Filesystem::VFSPath RelativeFilesystem::ReadLink(Tesses::Framework::Filesystem::VFSPath path)
{
if(path.relative)
{
return this->vfs->ReadLink(path.MakeAbsolute(GetWorking()));
}
else
{
return this->vfs->ReadLink(path);
}
}
std::string RelativeFilesystem::VFSPathToSystem(Tesses::Framework::Filesystem::VFSPath path)
{
return this->vfs->VFSPathToSystem(path);
}
Tesses::Framework::Filesystem::VFSPath RelativeFilesystem::SystemToVFSPath(std::string path)
{
return this->vfs->SystemToVFSPath(path);
}
void RelativeFilesystem::SetDate(Tesses::Framework::Filesystem::VFSPath path, Tesses::Framework::Date::DateTime lastWrite, Tesses::Framework::Date::DateTime lastAccess)
{
if(path.relative)
{
this->vfs->SetDate(path.MakeAbsolute(GetWorking()), lastWrite,lastAccess);
}
else
{
this->vfs->SetDate(path,lastWrite,lastAccess);
}
}
bool RelativeFilesystem::Stat(Tesses::Framework::Filesystem::VFSPath path, Tesses::Framework::Filesystem::StatData& stat)
{
if(path.relative)
{
return this->vfs->Stat(path.MakeAbsolute(GetWorking()), stat);
}
else
{
return this->vfs->Stat(path,stat);
}
}
bool RelativeFilesystem::StatVFS(Tesses::Framework::Filesystem::VFSPath path, Tesses::Framework::Filesystem::StatVFSData& vfsData)
{
if(path.relative)
{
return this->vfs->StatVFS(path.MakeAbsolute(GetWorking()), vfsData);
}
else
{
return this->vfs->StatVFS(path,vfsData);
}
}
void RelativeFilesystem::Chmod(Tesses::Framework::Filesystem::VFSPath path, uint32_t mode)
{
if(path.relative)
{
this->vfs->Chmod(path.MakeAbsolute(GetWorking()), mode);
}
else
{
this->vfs->Chmod(path,mode);
}
}
void RelativeFilesystem::Chown(Tesses::Framework::Filesystem::VFSPath path, uint32_t uid, uint32_t gid)
{
if(path.relative)
{
this->vfs->Chown(path.MakeAbsolute(GetWorking()), uid, gid);
}
else
{
this->vfs->Chown(path,uid,gid);
}
}
void RelativeFilesystem::Lock(Tesses::Framework::Filesystem::VFSPath path)
{
if(path.relative)
{
this->vfs->Lock(path.MakeAbsolute(GetWorking()));
}
else
{
this->vfs->Lock(path);
}
}
void RelativeFilesystem::Unlock(Tesses::Framework::Filesystem::VFSPath path)
{
if(path.relative)
{
this->vfs->Unlock(path.MakeAbsolute(GetWorking()));
}
else
{
this->vfs->Unlock(path);
}
}
Tesses::Framework::Filesystem::FIFOCreationResult RelativeFilesystem::CreateFIFO(Tesses::Framework::Filesystem::VFSPath path, uint32_t mod)
{
if(path.relative)
{
return this->vfs->CreateFIFO(path.MakeAbsolute(GetWorking()), mod);
}
else
{
return this->vfs->CreateFIFO(path, mod);
}
}
Tesses::Framework::Filesystem::VFSPath RelativeFilesystem::GetWorking()
{
mtx.Lock();
auto path = this->path;
mtx.Unlock();
return path;
}
void RelativeFilesystem::SetWorking(Tesses::Framework::Filesystem::VFSPath working)
{
mtx.Lock();
this->path = working;
mtx.Unlock();
}
std::shared_ptr<Tesses::Framework::Filesystem::VFS> RelativeFilesystem::GetVFS()
{
return this->vfs;
}
std::shared_ptr<Tesses::Framework::Filesystem::FSWatcher> RelativeFilesystem::CreateWatcher(std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs, Tesses::Framework::Filesystem::VFSPath path)
{
if(path.relative)
{
return Tesses::Framework::Filesystem::FSWatcher::Create(vfs, path.MakeAbsolute(GetWorking()));
}
else
{
return Tesses::Framework::Filesystem::FSWatcher::Create(vfs,path);
}
}
}

View File

@@ -86,7 +86,7 @@ namespace Tesses::CrossLang {
return value;
}
void TRootEnvironment::LoadDependency(GC* gc,std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs, std::pair<std::string,TVMVersion> dep)
void TRootEnvironment::LoadDependency(std::shared_ptr<GC> gc,std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs, std::pair<std::string,TVMVersion> dep)
{
for(auto item : this->dependencies)
if(item.first == dep.first && item.second.CompareTo(dep.second) >= 0) return;
@@ -129,7 +129,7 @@ namespace Tesses::CrossLang {
f->Load(ls.GetGC(),ms);
return this->LoadFile(ls.GetGC(), f);
}
TDictionary* TEnvironment::EnsureDictionary(GC* gc, std::string key)
TDictionary* TEnvironment::EnsureDictionary(std::shared_ptr<GC> gc, std::string key)
{
TObject item = this->GetVariable(key);
TDictionary* dict;
@@ -139,7 +139,7 @@ namespace Tesses::CrossLang {
this->DeclareVariable(key, dict);
return dict;
}
void TEnvironment::DeclareVariable(GC* gc, std::vector<std::string> name, TObject o)
void TEnvironment::DeclareVariable(std::shared_ptr<GC> gc, std::vector<std::string> name, TObject o)
{
if(name.size() == 0)
throw VMException("name can't be empty.");
@@ -209,7 +209,7 @@ namespace Tesses::CrossLang {
}
}
TObject TEnvironment::LoadFile(GC* gc, TFile* file)
TObject TEnvironment::LoadFile(std::shared_ptr<GC> gc, TFile* file)
{
file->EnsureCanRunInCrossLang();
for(size_t i = 0; i < file->classes.size(); i++)
@@ -266,7 +266,7 @@ namespace Tesses::CrossLang {
}
return nullptr;
}
void TRootEnvironment::LoadFileWithDependencies(GC* gc,std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs, TFile* file)
void TRootEnvironment::LoadFileWithDependencies(std::shared_ptr<GC> gc,std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs, TFile* file)
{
this->dependencies.push_back(std::pair<std::string,TVMVersion>(file->name,file->version));
for(auto item : file->dependencies)
@@ -276,7 +276,7 @@ namespace Tesses::CrossLang {
LoadFile(gc, file);
}
void TRootEnvironment::LoadFileWithDependencies(GC* gc,std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs, Tesses::Framework::Filesystem::VFSPath path)
void TRootEnvironment::LoadFileWithDependencies(std::shared_ptr<GC> gc,std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs, Tesses::Framework::Filesystem::VFSPath path)
{
@@ -344,7 +344,7 @@ namespace Tesses::CrossLang {
TRootEnvironment* TRootEnvironment::Create(GCList* gc,TDictionary* dict)
{
TRootEnvironment* env=new TRootEnvironment(dict);
GC* _gc = gc->GetGC();
std::shared_ptr<GC> _gc = gc->GetGC();
gc->Add(env);
_gc->Watch(env);
return env;
@@ -352,13 +352,13 @@ namespace Tesses::CrossLang {
TRootEnvironment* TRootEnvironment::Create(GCList& gc,TDictionary* dict)
{
TRootEnvironment* env=new TRootEnvironment(dict);
GC* _gc = gc.GetGC();
std::shared_ptr<GC> _gc = gc.GetGC();
gc.Add(env);
_gc->Watch(env);
return env;
}
bool TRootEnvironment::HandleException(GC* gc,TEnvironment* env, TObject err)
bool TRootEnvironment::HandleException(std::shared_ptr<GC> gc,TEnvironment* env, TObject err)
{
if(error != nullptr)
{
@@ -373,7 +373,7 @@ namespace Tesses::CrossLang {
}
return false;
}
bool TRootEnvironment::HandleBreakpoint(GC* gc,TEnvironment* env, TObject err)
bool TRootEnvironment::HandleBreakpoint(std::shared_ptr<GC> gc,TEnvironment* env, TObject err)
{
if(error != nullptr)
{

View File

@@ -6,7 +6,7 @@ namespace Tesses::CrossLang
{
return Tesses::Framework::Streams::Stream::GetLength();
}
TObjectStream::TObjectStream(GC* gc, TObject obj)
TObjectStream::TObjectStream(std::shared_ptr<GC> gc, TObject obj)
{
this->ls = new GCList(gc);
this->ls->Add(obj);

View File

@@ -180,7 +180,7 @@ namespace Tesses::CrossLang {
{
auto dict=TDictionary::Create(gc);
TSubEnvironment* sEnv = this->GetSubEnvironment(dict);
GC* _gc = gc->GetGC();
std::shared_ptr<GC> _gc = gc->GetGC();
gc->Add(sEnv);
_gc->Watch(sEnv);
return sEnv;
@@ -189,7 +189,7 @@ namespace Tesses::CrossLang {
{
auto dict=TDictionary::Create(gc);
TSubEnvironment* sEnv = this->GetSubEnvironment(dict);
GC* _gc = gc.GetGC();
std::shared_ptr<GC> _gc = gc.GetGC();
gc.Add(sEnv);
_gc->Watch(sEnv);
return sEnv;
@@ -197,7 +197,7 @@ namespace Tesses::CrossLang {
TSubEnvironment* TSubEnvironment::Create(GCList* gc, TEnvironment* env, TDictionary* dict)
{
TSubEnvironment* senv = new TSubEnvironment(env,dict);
GC* _gc = gc->GetGC();
std::shared_ptr<GC> _gc = gc->GetGC();
gc->Add(senv);
_gc->Watch(senv);
return senv;
@@ -205,7 +205,7 @@ namespace Tesses::CrossLang {
TSubEnvironment* TSubEnvironment::Create(GCList& gc, TEnvironment* env, TDictionary* dict)
{
TSubEnvironment* senv = new TSubEnvironment(env,dict);
GC* _gc = gc.GetGC();
std::shared_ptr<GC> _gc = gc.GetGC();
gc.Add(senv);
_gc->Watch(senv);
return senv;
@@ -227,32 +227,20 @@ namespace Tesses::CrossLang {
this->env->Mark();
for(auto defer : defers) defer->Mark();
}
void TEnvironment::DeclareFunction(GC* gc,std::string key,std::string documentation, std::vector<std::string> argNames, std::function<TObject(GCList& ls, std::vector<TObject> args)> cb)
void TEnvironment::DeclareFunction(std::shared_ptr<GC> gc,std::string key,std::string documentation, std::vector<std::string> argNames, std::function<TObject(GCList& ls, std::vector<TObject> args)> cb)
{
gc->BarrierBegin();
GCList ls(gc);
this->DeclareVariable(key, TExternalMethod::Create(ls,documentation,argNames,cb));
gc->BarrierEnd();
}
void TEnvironment::DeclareFunction(GC& gc,std::string key,std::string documentation, std::vector<std::string> argNames, std::function<TObject(GCList& ls, std::vector<TObject> args)> cb)
{
gc.BarrierBegin();
GCList ls(gc);
this->DeclareVariable(key, TExternalMethod::Create(ls,documentation,argNames,cb));
gc.BarrierEnd();
}
void TEnvironment::DeclareFunction(GC* gc,std::string key,std::string documentation, std::vector<std::string> argNames, std::function<TObject(GCList& ls, std::vector<TObject> args)> cb,std::function<void()> destroy)
void TEnvironment::DeclareFunction(std::shared_ptr<GC> gc,std::string key,std::string documentation, std::vector<std::string> argNames, std::function<TObject(GCList& ls, std::vector<TObject> args)> cb,std::function<void()> destroy)
{
gc->BarrierBegin();
GCList ls(gc);
this->DeclareVariable(key, TExternalMethod::Create(ls,documentation,argNames,cb,destroy));
gc->BarrierEnd();
}
void TEnvironment::DeclareFunction(GC& gc,std::string key,std::string documentation, std::vector<std::string> argNames, std::function<TObject(GCList& ls, std::vector<TObject> args)> cb,std::function<void()> destroy)
{
gc.BarrierBegin();
GCList ls(gc);
this->DeclareVariable(key, TExternalMethod::Create(ls,documentation,argNames,cb,destroy));
gc.BarrierEnd();
}
};

View File

@@ -2,7 +2,7 @@
namespace Tesses::CrossLang {
TObjectVFS::TObjectVFS(GC* gc, TObject obj)
TObjectVFS::TObjectVFS(std::shared_ptr<GC> gc, TObject obj)
{
this->ls = new GCList(gc);
this->ls->Add(obj);

View File

@@ -10,7 +10,7 @@
#include <sstream>
#include <variant>
namespace Tesses::CrossLang {
bool InterperterThread::Add(GC* gc)
bool InterperterThread::Add(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);

View File

@@ -13,7 +13,7 @@
namespace Tesses::CrossLang {
bool Equals(GC* gc, TObject left, TObject right)
bool Equals(std::shared_ptr<GC> gc, TObject left, TObject right)
{
GCList ls(gc);
if(std::holds_alternative<std::nullptr_t>(left) && std::holds_alternative<std::nullptr_t>(right))

View File

@@ -14,7 +14,7 @@
namespace Tesses::CrossLang {
extern bool IHttpServer_Handle(std::shared_ptr<Tesses::Framework::Http::IHttpServer> svr,std::vector<TObject>& args);
bool InterperterThread::ExecuteMethod2(GC* gc, TObject instance, std::string key, std::vector<TObject> args)
bool InterperterThread::ExecuteMethod2(std::shared_ptr<GC> gc, TObject instance, std::string key, std::vector<TObject> args)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
if(!cse.empty())
@@ -395,7 +395,7 @@ namespace Tesses::CrossLang {
cse.back()->Push(gc, path.GetExtension());
return false;
}
if(cse.back()->env->GetRootEnvironment()->permissions.canRegisterLocalFS && key == "MakeAbsolute")
if(cse.back()->env->GetRootEnvironment()->permissions.localfs && key == "MakeAbsolute")
{
Tesses::Framework::Filesystem::VFSPath p;
if(GetArgumentAsPath(args,0,p))
@@ -405,11 +405,11 @@ namespace Tesses::CrossLang {
}
else
{
cse.back()->Push(gc,path.MakeAbsolute());
cse.back()->Push(gc,path.MakeAbsolute(cse.back()->env->GetRootEnvironment()->permissions.localfs->GetWorking()));
return false;
}
}
if(cse.back()->env->GetRootEnvironment()->permissions.canRegisterLocalFS && key == "MakeRelative")
if(cse.back()->env->GetRootEnvironment()->permissions.localfs && key == "MakeRelative")
{
Tesses::Framework::Filesystem::VFSPath p;
if(GetArgumentAsPath(args,0,p))
@@ -419,7 +419,7 @@ namespace Tesses::CrossLang {
}
else
{
cse.back()->Push(gc,path.MakeRelative());
cse.back()->Push(gc,path.MakeRelative(cse.back()->env->GetRootEnvironment()->permissions.localfs->GetWorking()));
return false;
}
}
@@ -1199,6 +1199,48 @@ namespace Tesses::CrossLang {
cse.back()->Push(gc,Undefined());
return false;
}
else if(std::holds_alternative<std::shared_ptr<Tesses::Framework::Http::ServerSentEvents>>(instance))
{
auto& sse = std::get<std::shared_ptr<Tesses::Framework::Http::ServerSentEvents>>(instance);
if(sse != nullptr)
{
std::string text;
std::string text2;
if(key == "SendComment" && GetArgument(args, 0, text))
{
sse->SendComment(text);
}
else if(key == "SendCustomEvent" && GetArgument(args, 0, text) && GetArgument(args,1,text2)) {
sse->SendCustomEvent(text,text2);
}
else if(key == "SendCustomEvent" && GetArgument(args, 0, text)) {
if(GetArgument(args,1,text2))
sse->SendData(text,text2);
else
sse->SendData(text);
}
else if(key == "SendId" && GetArgument(args, 0, text))
{
sse->SendId(text);
}
else if(key == "SendRetry")
{
std::shared_ptr<Tesses::Framework::Date::TimeSpan> ts;
int64_t num;
if(GetArgument(args,0,ts) && ts)
{
sse->SendRetry(*ts);
}
else if(GetArgument(args,0,num))
{
sse->SendRetry((uint32_t)num);
}
}
}
cse.back()->Push(gc, Undefined());
return false;
}
else if(std::holds_alternative<std::shared_ptr<Tesses::Framework::Streams::Stream>>(instance))
{
auto& strm = std::get<std::shared_ptr<Tesses::Framework::Streams::Stream>>(instance);
@@ -1234,6 +1276,18 @@ namespace Tesses::CrossLang {
}
if(netStrm != nullptr)
{
if(key == "SetMulticastMembership")
{
std::string ma;
std::string ifaceIP = "0.0.0.0";
if(GetArgument(args,0,ma))
{
GetArgument(args,1,ifaceIP);
netStrm->SetMulticastMembership(ma,ifaceIP);
}
cse.back()->Push(gc, Undefined());
return false;
}
if(key == "GetPort")
{
cse.back()->Push(gc, (int64_t)netStrm->GetPort());
@@ -2230,9 +2284,10 @@ namespace Tesses::CrossLang {
}
if(key == "RegisterEverything")
{
if(myEnv->permissions.canRegisterEverything)
if(myEnv->permissions.canRegisterEverything && myEnv->permissions.localfs)
{
TStd::RegisterStd(gc, rootEnv);
TStd::RegisterStd(gc, rootEnv, std::make_shared<RelativeFilesystem>(myEnv->permissions.localfs->GetVFS(),myEnv->permissions.localfs->GetWorking()));
}
else
{
@@ -2250,7 +2305,15 @@ namespace Tesses::CrossLang {
if(myEnv->permissions.canRegisterIO && !rootEnv->permissions.locked)
TStd::RegisterIO(gc, rootEnv, myEnv->permissions.canRegisterLocalFS);
{
if(myEnv->permissions.localfs)
{
TStd::RegisterIO(gc, rootEnv, std::make_shared<RelativeFilesystem>(myEnv->permissions.localfs->GetVFS(),myEnv->permissions.localfs->GetWorking()));
}
else {
TStd::RegisterIO(gc, rootEnv, nullptr);
}
}
if(myEnv->permissions.canRegisterJSON && !rootEnv->permissions.locked)
TStd::RegisterJson(gc, rootEnv);
@@ -2329,7 +2392,15 @@ namespace Tesses::CrossLang {
if(GetArgument(args,0,r))
{
if((myEnv->permissions.canRegisterEverything || myEnv->permissions.canRegisterIO) && !rootEnv->permissions.locked)
TStd::RegisterIO(gc, rootEnv, myEnv->permissions.canRegisterLocalFS ? r : false);
{
if(myEnv->permissions.localfs)
{
TStd::RegisterIO(gc, rootEnv, std::make_shared<RelativeFilesystem>(myEnv->permissions.localfs->GetVFS(),myEnv->permissions.localfs->GetWorking()));
}
else {
TStd::RegisterIO(gc, rootEnv, nullptr);
}
}
}
cse.back()->Push(gc,nullptr);
return false;

View File

@@ -10,7 +10,7 @@
#include <sstream>
#include <variant>
namespace Tesses::CrossLang {
bool InterperterThread::GetField(GC* gc)
bool InterperterThread::GetField(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -47,6 +47,25 @@ namespace Tesses::CrossLang {
cse.back()->Push(gc, Undefined());
return false;
}
if(std::holds_alternative<std::shared_ptr<Tesses::Framework::TF_Timer_Handle>>(instance))
{
auto timer = std::get<std::shared_ptr<Tesses::Framework::TF_Timer_Handle>>(instance);
if(timer)
{
if(key == "Interval")
{
cse.back()->Push(gc, timer->GetIntervalMilliseconds());
return false;
}
if(key == "Enabled")
{
cse.back()->Push(gc, timer->GetEnabled());
return false;
}
}
cse.back()->Push(gc, Undefined());
return false;
}
if(std::holds_alternative<std::shared_ptr<Tesses::Framework::Filesystem::VFS>>(instance))
{
auto vfs = std::get<std::shared_ptr<Tesses::Framework::Filesystem::VFS>>(instance);

View File

@@ -11,7 +11,11 @@
#include <variant>
namespace Tesses::CrossLang {
bool InterperterThread::SetField(GC* gc)
static void empty()
{
}
bool InterperterThread::SetField(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -30,7 +34,61 @@ namespace Tesses::CrossLang {
}
std::string key = std::get<std::string>(_key);
if(std::holds_alternative<std::shared_ptr<Tesses::Framework::TextStreams::TextWriter>>(instance))
if(std::holds_alternative<std::shared_ptr<Tesses::Framework::TF_Timer_Handle>>(instance))
{
auto handle = std::get<std::shared_ptr<Tesses::Framework::TF_Timer_Handle>>(instance);
if(handle)
{
int64_t ms;
bool b;
if(key == "Enabled" && GetObject(value,b))
{
handle->SetEnabled(b);
cse.back()->Push(gc,b);
return false;
}
if(key == "Interval" && GetObject(value, ms))
{
handle->SetIntervalFromMilliseconds(ms);
cse.back()->Push(gc,ms);
return false;
}
if(key == "Callback")
{
TCallable* callable;
if(GetObjectHeap(value,callable))
{
auto obj = CreateMarkedTObject(ls.GetGC(), callable);
handle->SetCallback([obj]()->void {
TCallable* callable;
if(GetObjectHeap(obj->GetObject(), callable))
{
GCList ls(obj->GetGC());
callable->Call(ls,{});
}
});
cse.back()->Push(gc, callable);
return false;
}
else
{
handle->SetCallback(empty);
cse.back()->Push(gc, nullptr);
return false;
}
}
}
cse.back()->Push(gc, Undefined());
return false;
}
if(std::holds_alternative<std::shared_ptr<Tesses::Framework::TextStreams::TextWriter>>(instance))
{
auto writer = std::get<std::shared_ptr<Tesses::Framework::TextStreams::TextWriter>>(instance);
auto stringWriter = std::dynamic_pointer_cast<Tesses::Framework::TextStreams::StringWriter>(writer);
@@ -177,11 +235,19 @@ namespace Tesses::CrossLang {
auto netStrm = std::dynamic_pointer_cast<Tesses::Framework::Streams::NetworkStream>(strm);
if(netStrm != nullptr)
{
int64_t n0;
bool bc;
if(key == "Broadcast" && GetObject(value,bc))
netStrm->SetBroadcast(bc);
if(key == "NoDelay" && GetObject(value,bc))
netStrm->SetNoDelay(bc);
if(key == "ReuseAddress" && GetObject(value,bc))
netStrm->SetReuseAddress(bc);
if(key == "ReusePort" && GetObject(value,bc))
netStrm->SetReusePort(bc);
if(key == "MulticastTTL" && GetObject(value,n0))
netStrm->SetMulticastTTL((uint8_t)n0);
}
stk->Push(gc, Undefined());
return false;

View File

@@ -10,7 +10,7 @@
#include <sstream>
#include <variant>
namespace Tesses::CrossLang {
bool InterperterThread::Sub(GC* gc)
bool InterperterThread::Sub(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);

View File

@@ -10,7 +10,7 @@
#include <sstream>
#include <variant>
namespace Tesses::CrossLang {
std::string ToString(GC* gc, TObject o)
std::string ToString(std::shared_ptr<GC> gc, TObject o)
{
if(std::holds_alternative<Tesses::Framework::Filesystem::VFSPath>(o))
{

View File

@@ -11,7 +11,7 @@ namespace Tesses::CrossLang
{
TFile* f = new TFile();
f->icon = -1;
GC* _gc = ls.GetGC();
std::shared_ptr<GC> _gc = ls.GetGC();
ls.Add(f);
_gc->Watch(f);
return f;
@@ -20,7 +20,7 @@ namespace Tesses::CrossLang
{
TFile* f = new TFile();
f->icon=-1;
GC* _gc = ls->GetGC();
std::shared_ptr<GC> _gc = ls->GetGC();
ls->Add(f);
_gc->Watch(f);
return f;
@@ -35,7 +35,7 @@ namespace Tesses::CrossLang
TFileChunk* TFileChunk::Create(GCList& ls)
{
TFileChunk* chk = new TFileChunk();
GC* _gc = ls.GetGC();
std::shared_ptr<GC> _gc = ls.GetGC();
ls.Add(chk);
_gc->Watch(chk);
return chk;
@@ -43,7 +43,7 @@ namespace Tesses::CrossLang
TFileChunk* TFileChunk::Create(GCList* ls)
{
TFileChunk* chk = new TFileChunk();
GC* _gc = ls->GetGC();
std::shared_ptr<GC> _gc = ls->GetGC();
ls->Add(chk);
_gc->Watch(chk);
return chk;
@@ -280,7 +280,7 @@ namespace Tesses::CrossLang
return nullptr;
}
void TFile::Load(GC* gc, std::shared_ptr<Tesses::Framework::Streams::Stream> stream)
void TFile::Load(std::shared_ptr<GC> gc, std::shared_ptr<Tesses::Framework::Streams::Stream> stream)
{
uint8_t main_header[18];

View File

@@ -71,7 +71,7 @@ namespace Tesses::CrossLang
ls.GetGC()->BarrierEnd();
th->thrd =new Thread([th]()->void {
GC* gc=th->gc;
std::shared_ptr<GC> gc=th->gc;
GCList ls(gc);
ls.Add(th);
th->hasInit=true;
@@ -241,14 +241,14 @@ namespace Tesses::CrossLang
delete this->mtx;
}
void GC::RegisterEverythingCallback(std::function<void(GC* gc, TRootEnvironment* env)> cb)
void GC::RegisterEverythingCallback(std::function<void(std::shared_ptr<GC> gc, TRootEnvironment* env)> cb)
{
this->register_everything.push_back(cb);
}
void GC::RegisterEverything(TRootEnvironment* env)
{
for(auto item : this->register_everything)
item(this,env);
item(this->shared_from_this(),env);
}
void GC::Collect()
{

View File

@@ -2,21 +2,15 @@
namespace Tesses::CrossLang
{
GCList::GCList(GC* gc)
GCList::GCList(std::shared_ptr<GC> gc)
{
gc->BarrierBegin();
this->gc = gc;
gc->SetRoot(this);
gc->BarrierEnd();
}
GCList::GCList(GC& gc)
{
gc.BarrierBegin();
this->gc = &gc;
gc.SetRoot(this);
gc.BarrierEnd();
}
GC* GCList::GetGC()
std::shared_ptr<GC> GCList::GetGC()
{
return this->gc;
}

View File

@@ -36,9 +36,9 @@ namespace Tesses::CrossLang {
#define TVM_HANDLER(hndl) if(hndl(gc)) goto execute
typedef bool (InterperterThread::*opcode)(GC* gc);
typedef bool (InterperterThread::*opcode)(std::shared_ptr<GC> gc);
bool InterperterThread::InterperterThread::Breakpoint(GC* gc)
bool InterperterThread::InterperterThread::Breakpoint(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -53,7 +53,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::Times(GC* gc)
bool InterperterThread::Times(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -138,7 +138,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::Divide(GC* gc)
bool InterperterThread::Divide(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -253,7 +253,7 @@ namespace Tesses::CrossLang {
}
return false;
}
bool InterperterThread::Mod(GC* gc)
bool InterperterThread::Mod(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -340,7 +340,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::Neg(GC* gc)
bool InterperterThread::Neg(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -414,7 +414,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::LNot(GC* gc)
bool InterperterThread::LNot(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -499,7 +499,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::BNot(GC* gc)
bool InterperterThread::BNot(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -571,7 +571,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::Lt(GC* gc)
bool InterperterThread::Lt(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -691,7 +691,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::Gt(GC* gc)
bool InterperterThread::Gt(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -812,7 +812,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::Lte(GC* gc)
bool InterperterThread::Lte(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -933,7 +933,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::Gte(GC* gc)
bool InterperterThread::Gte(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -1056,7 +1056,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::Eq(GC* gc)
bool InterperterThread::Eq(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -1242,7 +1242,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::NEq(GC* gc)
bool InterperterThread::NEq(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -1420,7 +1420,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::LShift(GC* gc)
bool InterperterThread::LShift(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -1491,7 +1491,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::RShift(GC* gc)
bool InterperterThread::RShift(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -1563,7 +1563,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::BOr(GC* gc)
bool InterperterThread::BOr(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -1635,7 +1635,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::XOr(GC* gc)
bool InterperterThread::XOr(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -1707,7 +1707,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::BAnd(GC* gc)
bool InterperterThread::BAnd(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -1812,7 +1812,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::ExecuteFunction(GC* gc)
bool InterperterThread::ExecuteFunction(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
if(!cse.empty())
@@ -1889,7 +1889,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::Yield(GC* gc)
bool InterperterThread::Yield(std::shared_ptr<GC> gc)
{
GCList ls(gc);
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -1902,7 +1902,7 @@ namespace Tesses::CrossLang {
}
return false;
}
bool InterperterThread::ExecuteMethod(GC* gc)
bool InterperterThread::ExecuteMethod(std::shared_ptr<GC> gc)
{
GCList ls(gc);
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -1939,7 +1939,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::GetVariable(GC* gc)
bool InterperterThread::GetVariable(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
if(!cse.empty())
@@ -1961,7 +1961,7 @@ namespace Tesses::CrossLang {
}
return false;
}
bool InterperterThread::SetVariable(GC* gc)
bool InterperterThread::SetVariable(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
if(!cse.empty())
@@ -2120,7 +2120,7 @@ namespace Tesses::CrossLang {
}
return false;
}
bool InterperterThread::DeclareVariable(GC* gc)
bool InterperterThread::DeclareVariable(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
if(!cse.empty())
@@ -2279,7 +2279,7 @@ namespace Tesses::CrossLang {
}
bool InterperterThread::DeclareConstVariable(GC* gc)
bool InterperterThread::DeclareConstVariable(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
if(!cse.empty())
@@ -2436,7 +2436,7 @@ namespace Tesses::CrossLang {
}
return false;
}
bool InterperterThread::PushResourceStream(GC* gc)
bool InterperterThread::PushResourceStream(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
if(!cse.empty())
@@ -2466,7 +2466,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::PushResource(GC* gc)
bool InterperterThread::PushResource(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
if(!cse.empty())
@@ -2495,7 +2495,7 @@ namespace Tesses::CrossLang {
}
return false;
}
bool InterperterThread::Throw(GC* gc)
bool InterperterThread::Throw(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -2509,7 +2509,7 @@ namespace Tesses::CrossLang {
}
return false;
}
bool InterperterThread::PushResourceDirectory(GC* gc)
bool InterperterThread::PushResourceDirectory(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
GCList ls(gc);
@@ -2524,7 +2524,7 @@ namespace Tesses::CrossLang {
}
return false;
}
bool InterperterThread::JumpIfDefined(GC* gc)
bool InterperterThread::JumpIfDefined(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2550,7 +2550,7 @@ namespace Tesses::CrossLang {
throw VMException("Can't read jmpifdefined pc.");
return false;
}
bool InterperterThread::JumpIfBreak(GC* gc)
bool InterperterThread::JumpIfBreak(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2576,7 +2576,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::JumpIfContinue(GC* gc)
bool InterperterThread::JumpIfContinue(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2601,7 +2601,7 @@ namespace Tesses::CrossLang {
throw VMException("Can't read jmpifcontinue pc.");
return false;
}
bool InterperterThread::JumpUndefined(GC* gc)
bool InterperterThread::JumpUndefined(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2626,7 +2626,7 @@ namespace Tesses::CrossLang {
throw VMException("Can't read jmpundefined pc.");
return false;
}
bool InterperterThread::Jump(GC* gc)
bool InterperterThread::Jump(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2641,7 +2641,7 @@ namespace Tesses::CrossLang {
throw VMException("Can't read jmp pc.");
return false;
}
bool InterperterThread::PushNull(GC* gc)
bool InterperterThread::PushNull(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2650,7 +2650,7 @@ namespace Tesses::CrossLang {
stk->Push(gc,nullptr);
return false;
}
bool InterperterThread::PushBreak(GC* gc)
bool InterperterThread::PushBreak(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2659,7 +2659,7 @@ namespace Tesses::CrossLang {
stk->Push(gc,TBreak());
return false;
}
bool InterperterThread::PushContinue(GC* gc)
bool InterperterThread::PushContinue(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2668,7 +2668,7 @@ namespace Tesses::CrossLang {
stk->Push(gc,TContinue());
return false;
}
bool InterperterThread::PushUndefined(GC* gc)
bool InterperterThread::PushUndefined(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2677,7 +2677,7 @@ namespace Tesses::CrossLang {
stk->Push(gc,Undefined());
return false;
}
bool InterperterThread::LineInfo(GC* gc)
bool InterperterThread::LineInfo(std::shared_ptr<GC> gc)
{
GCList ls(gc);
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2695,7 +2695,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::PushFalse(GC* gc)
bool InterperterThread::PushFalse(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2704,7 +2704,7 @@ namespace Tesses::CrossLang {
stk->Push(gc,false);
return false;
}
bool InterperterThread::PushTrue(GC* gc)
bool InterperterThread::PushTrue(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2713,7 +2713,7 @@ namespace Tesses::CrossLang {
stk->Push(gc,true);
return false;
}
bool InterperterThread::CreateDictionary(GC* gc)
bool InterperterThread::CreateDictionary(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2723,11 +2723,11 @@ namespace Tesses::CrossLang {
stk->Push(gc,dict);
return false;
}
bool InterperterThread::Nop(GC* gc)
bool InterperterThread::Nop(std::shared_ptr<GC> gc)
{
return false;
}
bool InterperterThread::AppendList(GC* gc)
bool InterperterThread::AppendList(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2760,7 +2760,7 @@ namespace Tesses::CrossLang {
gc->BarrierEnd();
return false;
}
bool InterperterThread::AppendDictionary(GC* gc)
bool InterperterThread::AppendDictionary(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2800,7 +2800,7 @@ namespace Tesses::CrossLang {
gc->BarrierEnd();
return false;
}
bool InterperterThread::CreateArray(GC* gc)
bool InterperterThread::CreateArray(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2810,7 +2810,7 @@ namespace Tesses::CrossLang {
stk->Push(gc,dict);
return false;
}
bool InterperterThread::Pop(GC* gc)
bool InterperterThread::Pop(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2819,7 +2819,7 @@ namespace Tesses::CrossLang {
stk->Pop(ls);
return false;
}
bool InterperterThread::TryCatch(GC* gc)
bool InterperterThread::TryCatch(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2861,7 +2861,7 @@ namespace Tesses::CrossLang {
}
return false;
}
bool InterperterThread::JumpConditional(GC* gc)
bool InterperterThread::JumpConditional(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2884,7 +2884,7 @@ namespace Tesses::CrossLang {
throw VMException("Can't read jmpc pc.");
return false;
}
bool InterperterThread::PushClosure(GC* gc)
bool InterperterThread::PushClosure(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
if(!cse.empty())
@@ -2912,7 +2912,7 @@ namespace Tesses::CrossLang {
}
return false;
}
bool InterperterThread::PushScopelessClosure(GC* gc)
bool InterperterThread::PushScopelessClosure(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
if(!cse.empty())
@@ -2941,7 +2941,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::PushString(GC* gc)
bool InterperterThread::PushString(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -2962,7 +2962,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::PushLong(GC* gc)
bool InterperterThread::PushLong(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
if(!cse.empty())
@@ -2978,7 +2978,7 @@ namespace Tesses::CrossLang {
}
return false;
}
bool InterperterThread::PushChar(GC* gc)
bool InterperterThread::PushChar(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
if(!cse.empty())
@@ -2994,7 +2994,7 @@ namespace Tesses::CrossLang {
}
return false;
}
bool InterperterThread::PushDouble(GC* gc)
bool InterperterThread::PushDouble(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
if(!cse.empty())
@@ -3010,7 +3010,7 @@ namespace Tesses::CrossLang {
}
return false;
}
bool InterperterThread::Return(GC* gc)
bool InterperterThread::Return(std::shared_ptr<GC> gc)
{
@@ -3020,7 +3020,7 @@ namespace Tesses::CrossLang {
stk->ip = (uint32_t)stk->callable->closure->code.size();
return false;
}
bool InterperterThread::ScopeBegin(GC* gc)
bool InterperterThread::ScopeBegin(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -3034,7 +3034,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::Defer(GC* gc)
bool InterperterThread::Defer(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -3050,7 +3050,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::Dup(GC* gc)
bool InterperterThread::Dup(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -3062,7 +3062,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::ScopeEndTimes(GC* gc)
bool InterperterThread::ScopeEndTimes(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -3097,7 +3097,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::ScopeEnd(GC* gc)
bool InterperterThread::ScopeEnd(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -3127,7 +3127,7 @@ namespace Tesses::CrossLang {
return false;
}
bool InterperterThread::PushRelativePath(GC* gc)
bool InterperterThread::PushRelativePath(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -3138,7 +3138,7 @@ namespace Tesses::CrossLang {
stk->Push(gc, p);
return false;
}
bool InterperterThread::PushRootPath(GC* gc)
bool InterperterThread::PushRootPath(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -3149,7 +3149,7 @@ namespace Tesses::CrossLang {
stk->Push(gc, p);
return false;
}
bool InterperterThread::Illegal(GC* gc)
bool InterperterThread::Illegal(std::shared_ptr<GC> gc)
{
@@ -3162,7 +3162,7 @@ namespace Tesses::CrossLang {
}
void InterperterThread::Execute(GC* gc)
void InterperterThread::Execute(std::shared_ptr<GC> gc)
{
std::vector<CallStackEntry*>& cse=this->call_stack_entries;
@@ -3342,7 +3342,7 @@ namespace Tesses::CrossLang {
this->callable->Mark();
for(auto item : this->stack) GC::Mark(item);
}
void CallStackEntry::Push(GC* gc,TObject o)
void CallStackEntry::Push(std::shared_ptr<GC> gc,TObject o)
{
gc->BarrierBegin();
this->stack.push_back(o);
@@ -3376,7 +3376,7 @@ namespace Tesses::CrossLang {
InterperterThread* InterperterThread::Create(GCList& ls)
{
InterperterThread* it = new InterperterThread();
GC* _gc = ls.GetGC();
std::shared_ptr<GC> _gc = ls.GetGC();
ls.Add(it);
_gc->Watch(it);
return it;
@@ -3384,7 +3384,7 @@ namespace Tesses::CrossLang {
InterperterThread* InterperterThread::Create(GCList* ls)
{
InterperterThread* it = new InterperterThread();
GC* _gc = ls->GetGC();
std::shared_ptr<GC> _gc = ls->GetGC();
ls->Add(it);
_gc->Watch(it);
return it;
@@ -3396,7 +3396,7 @@ namespace Tesses::CrossLang {
cse->srcline = -1;
cse->srcfile = "";
cse->thread=nullptr;
GC* _gc = ls.GetGC();
std::shared_ptr<GC> _gc = ls.GetGC();
ls.Add(cse);
_gc->Watch(cse);
return cse;
@@ -3409,7 +3409,7 @@ namespace Tesses::CrossLang {
cse->srcline = -1;
cse->srcfile = "";
cse->thread=nullptr;
GC* _gc = ls->GetGC();
std::shared_ptr<GC> _gc = ls->GetGC();
ls->Add(cse);
_gc->Watch(cse);
return cse;