mirror of
https://onedev.site.tesses.net/crosslang
synced 2026-04-18 12:27:03 +00:00
Add custom console and allow runtimes to set the config dir
This commit is contained in:
@@ -1813,6 +1813,7 @@ class GC {
|
|||||||
bool canRegisterClass;
|
bool canRegisterClass;
|
||||||
bool sqlite3Scoped;
|
bool sqlite3Scoped;
|
||||||
bool locked;
|
bool locked;
|
||||||
|
TDictionary* customConsole =nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TRootEnvironment : public TEnvironment
|
class TRootEnvironment : public TEnvironment
|
||||||
@@ -2565,4 +2566,6 @@ class GC {
|
|||||||
MarkedTObject CreateMarkedTObject(GCList& gc, TObject o);
|
MarkedTObject CreateMarkedTObject(GCList& gc, TObject o);
|
||||||
std::string JoinPeriod(std::vector<std::string>& p);
|
std::string JoinPeriod(std::vector<std::string>& p);
|
||||||
TObject GetClassInfo(GCList& ls,TFile* f, uint32_t index);
|
TObject GetClassInfo(GCList& ls,TFile* f, uint32_t index);
|
||||||
|
|
||||||
|
extern Tesses::Framework::Filesystem::VFSPath CrossLangConfigPath;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -266,7 +266,8 @@ namespace Tesses::CrossLang
|
|||||||
TClassObject* co;
|
TClassObject* co;
|
||||||
if(GetArgumentHeap(args, 0, co))
|
if(GetArgumentHeap(args, 0, co))
|
||||||
{
|
{
|
||||||
return TDictionary::Create(ls,
|
ls.GetGC()->BarrierBegin();
|
||||||
|
auto res= TDictionary::Create(ls,
|
||||||
{
|
{
|
||||||
TDItem("Name", co->name),
|
TDItem("Name", co->name),
|
||||||
TDItem("File", co->file),
|
TDItem("File", co->file),
|
||||||
@@ -275,6 +276,8 @@ namespace Tesses::CrossLang
|
|||||||
TDItem("Entries", ClassInstanceToList(ls,co))
|
TDItem("Entries", ClassInstanceToList(ls,co))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
ls.GetGC()->BarrierEnd();
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -196,6 +196,14 @@ namespace Tesses::CrossLang {
|
|||||||
void TStd::RegisterConsole(GC* gc,TRootEnvironment* env)
|
void TStd::RegisterConsole(GC* gc,TRootEnvironment* env)
|
||||||
{
|
{
|
||||||
env->permissions.canRegisterConsole=true;
|
env->permissions.canRegisterConsole=true;
|
||||||
|
if(env->permissions.customConsole != nullptr)
|
||||||
|
{
|
||||||
|
gc->BarrierBegin();
|
||||||
|
env->DeclareVariable("Console", env->permissions.customConsole );
|
||||||
|
gc->BarrierEnd();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CROSSLANG_ENABLE_TERMIOS
|
#ifdef CROSSLANG_ENABLE_TERMIOS
|
||||||
tcgetattr(0, &orig_termios);
|
tcgetattr(0, &orig_termios);
|
||||||
atexit(disableRawMode);
|
atexit(disableRawMode);
|
||||||
|
|||||||
@@ -13,9 +13,13 @@ namespace Tesses::CrossLang
|
|||||||
static char EnvPathSeperator=':';
|
static char EnvPathSeperator=':';
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Tesses::Framework::Filesystem::VFSPath CrossLangConfigPath("");
|
||||||
|
|
||||||
|
|
||||||
Tesses::Framework::Filesystem::VFSPath GetCrossLangConfigDir()
|
Tesses::Framework::Filesystem::VFSPath GetCrossLangConfigDir()
|
||||||
{
|
{
|
||||||
|
if(!CrossLangConfigPath.path.empty())
|
||||||
|
return CrossLangConfigPath;
|
||||||
|
|
||||||
return SpecialFolders::GetConfig() / "Tesses" / "CrossLang";
|
return SpecialFolders::GetConfig() / "Tesses" / "CrossLang";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -480,7 +480,9 @@ namespace Tesses::CrossLang
|
|||||||
GCList ls2(this->ls->GetGC());
|
GCList ls2(this->ls->GetGC());
|
||||||
auto res = CreateDictionaryFromServerContext(ls2,&ctx);
|
auto res = CreateDictionaryFromServerContext(ls2,&ctx);
|
||||||
bool result;
|
bool result;
|
||||||
|
this->ls->GetGC()->BarrierBegin();
|
||||||
auto callableO = clsObj->GetValue("","Handle");
|
auto callableO = clsObj->GetValue("","Handle");
|
||||||
|
this->ls->GetGC()->BarrierEnd();
|
||||||
TCallable* callable;
|
TCallable* callable;
|
||||||
if(GetObjectHeap(callableO, callable))
|
if(GetObjectHeap(callableO, callable))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace Tesses::CrossLang
|
|||||||
if(value == "true") {
|
if(value == "true") {
|
||||||
items.push_back(std::pair<std::string,TObject>(key,true));
|
items.push_back(std::pair<std::string,TObject>(key,true));
|
||||||
} else if(value == "false") {
|
} else if(value == "false") {
|
||||||
items.push_back(std::pair<std::string,TObject>(key,true));
|
items.push_back(std::pair<std::string,TObject>(key,false));
|
||||||
} else if(value == "null") {
|
} else if(value == "null") {
|
||||||
items.push_back(std::pair<std::string,TObject>(key,nullptr));
|
items.push_back(std::pair<std::string,TObject>(key,nullptr));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -387,15 +387,19 @@ namespace Tesses::CrossLang
|
|||||||
});
|
});
|
||||||
dict->DeclareFunction(gc, "getRootEnvironment","Get root environment, for reflection purposes",{},[env](GCList& ls2,std::vector<TObject> args)->TObject {return env;});
|
dict->DeclareFunction(gc, "getRootEnvironment","Get root environment, for reflection purposes",{},[env](GCList& ls2,std::vector<TObject> args)->TObject {return env;});
|
||||||
dict->DeclareFunction(gc, "getCurrentEnvironment","Get current environment, for reflection purposes",{},VM_getCurrentEnvironment);
|
dict->DeclareFunction(gc, "getCurrentEnvironment","Get current environment, for reflection purposes",{},VM_getCurrentEnvironment);
|
||||||
dict->DeclareFunction(gc, "CreateEnvironment","Create root environment",{"$dict"},[](GCList& ls,std::vector<TObject> args)->TObject{
|
dict->DeclareFunction(gc, "CreateEnvironment","Create root environment",{"$dict"},[env](GCList& ls,std::vector<TObject> args)->TObject{
|
||||||
TDictionary* dict;
|
TDictionary* dict;
|
||||||
if(GetArgumentHeap(args,0,dict))
|
if(GetArgumentHeap(args,0,dict))
|
||||||
{
|
{
|
||||||
return TRootEnvironment::Create(ls,dict);
|
auto renv = TRootEnvironment::Create(ls,dict);
|
||||||
|
renv->permissions.customConsole = env->permissions.customConsole;
|
||||||
|
return renv;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return TRootEnvironment::Create(ls,TDictionary::Create(ls));
|
auto renv = TRootEnvironment::Create(ls,TDictionary::Create(ls));
|
||||||
|
renv->permissions.customConsole = env->permissions.customConsole;
|
||||||
|
return renv;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dict->DeclareFunction(gc, "LoadExecutable", "Load a crossvm executable",{"stream"},[](GCList& ls,std::vector<TObject> args)->TObject{
|
dict->DeclareFunction(gc, "LoadExecutable", "Load a crossvm executable",{"stream"},[](GCList& ls,std::vector<TObject> args)->TObject{
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ namespace Tesses::CrossLang
|
|||||||
}
|
}
|
||||||
void TAssociativeArray::Mark()
|
void TAssociativeArray::Mark()
|
||||||
{
|
{
|
||||||
|
if(this->marked) return;
|
||||||
|
this->marked=true;
|
||||||
for(auto& item : this->items)
|
for(auto& item : this->items)
|
||||||
{
|
{
|
||||||
GC::Mark(item.first);
|
GC::Mark(item.first);
|
||||||
|
|||||||
@@ -311,6 +311,7 @@ namespace Tesses::CrossLang {
|
|||||||
if(this->marked) return;
|
if(this->marked) return;
|
||||||
this->marked = true;
|
this->marked = true;
|
||||||
this->dict->Mark();
|
this->dict->Mark();
|
||||||
|
if(this->permissions.customConsole != nullptr) this->permissions.customConsole->Mark();
|
||||||
for(auto defer : this->defers) defer->Mark();
|
for(auto defer : this->defers) defer->Mark();
|
||||||
if(this->error != nullptr) this->error->Mark();
|
if(this->error != nullptr) this->error->Mark();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3311,6 +3311,22 @@ namespace Tesses::CrossLang {
|
|||||||
gc->BarrierEnd();
|
gc->BarrierEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(key == "SetCustomConsole")
|
||||||
|
{
|
||||||
|
TDictionary* dict;
|
||||||
|
if(!rootEnv->permissions.locked && GetArgumentHeap(args,0, dict))
|
||||||
|
{
|
||||||
|
gc->BarrierBegin();
|
||||||
|
rootEnv->permissions.customConsole = dict;
|
||||||
|
gc->BarrierEnd();
|
||||||
|
}
|
||||||
|
else if(!rootEnv->permissions.locked && myEnv->permissions.customConsole == nullptr)
|
||||||
|
{
|
||||||
|
gc->BarrierBegin();
|
||||||
|
rootEnv->permissions.customConsole=nullptr;
|
||||||
|
gc->BarrierEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
if(key == "RegisterEverything")
|
if(key == "RegisterEverything")
|
||||||
{
|
{
|
||||||
if(myEnv->permissions.canRegisterEverything)
|
if(myEnv->permissions.canRegisterEverything)
|
||||||
|
|||||||
Reference in New Issue
Block a user