Add RouteServer, TextReader/TextWriter and file locks
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
#include "CrossLang.hpp"
|
||||
|
||||
namespace Tesses::CrossLang
|
||||
{
|
||||
TRandom::TRandom() : random()
|
||||
{
|
||||
|
||||
}
|
||||
TRandom::TRandom(uint64_t seed) : random(seed)
|
||||
{
|
||||
|
||||
}
|
||||
std::string TRandom::TypeName()
|
||||
{
|
||||
return "Random";
|
||||
}
|
||||
TObject TRandom::CallMethod(GCList& ls,std::string name, std::vector<TObject> args)
|
||||
{
|
||||
if(name == "Next")
|
||||
{
|
||||
int64_t first;
|
||||
int64_t second;
|
||||
if(GetArgument(args,0,first))
|
||||
{
|
||||
if(GetArgument(args,1,second))
|
||||
{
|
||||
return (int64_t)random.Next((int32_t)first,(int32_t)second);
|
||||
}
|
||||
|
||||
return (int64_t)random.Next((uint32_t)first);
|
||||
}
|
||||
|
||||
return random.Next();
|
||||
|
||||
}
|
||||
|
||||
if(name == "NextByte")
|
||||
{
|
||||
return (int64_t)random.NextByte();
|
||||
}
|
||||
|
||||
if(name == "ToString") {
|
||||
return "";
|
||||
}
|
||||
return Undefined();
|
||||
}
|
||||
}
|
||||
@@ -210,7 +210,11 @@ namespace Tesses::CrossLang
|
||||
}
|
||||
TObjectStream::~TObjectStream()
|
||||
{
|
||||
Close();
|
||||
TDictionary* dict;
|
||||
if(GetObjectHeap(this->obj, dict))
|
||||
{
|
||||
dict->CallMethod(*ls,"Close",{});
|
||||
}
|
||||
delete this->ls;
|
||||
}
|
||||
|
||||
|
||||
@@ -169,6 +169,26 @@ namespace Tesses::CrossLang {
|
||||
|
||||
}
|
||||
}
|
||||
void TObjectVFS::Lock(Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
TDictionary* dict;
|
||||
if(GetObjectHeap(this->obj, dict))
|
||||
{
|
||||
GCList ls(this->ls->GetGC());
|
||||
dict->CallMethod(ls, "Lock",{path});
|
||||
|
||||
}
|
||||
}
|
||||
void TObjectVFS::Unlock(Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
TDictionary* dict;
|
||||
if(GetObjectHeap(this->obj, dict))
|
||||
{
|
||||
GCList ls(this->ls->GetGC());
|
||||
dict->CallMethod(ls, "Unlock",{path});
|
||||
|
||||
}
|
||||
}
|
||||
bool TObjectVFS::RegularFileExists(Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
|
||||
@@ -573,8 +593,12 @@ namespace Tesses::CrossLang {
|
||||
}
|
||||
TObjectVFS::~TObjectVFS()
|
||||
{
|
||||
|
||||
Close();
|
||||
TDictionary* dict;
|
||||
if(GetObjectHeap(this->obj, dict))
|
||||
{
|
||||
GCList ls(this->ls->GetGC());
|
||||
dict->CallMethod(ls,"Close",{});
|
||||
}
|
||||
delete this->ls;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user