Do more docs
This commit is contained in:
@ -158,7 +158,7 @@ namespace Tesses::CrossLang
|
||||
|
||||
}
|
||||
this->EnsureSymbol(">");
|
||||
if(tagName != "if" && tagName != "true" && tagName != "false" && tagName != "for" && tagName != "while" && tagName != "do" && tagName != "each")
|
||||
if(tagName != "if" && tagName != "true" && tagName != "false" && tagName != "for" && tagName != "while" && tagName != "do" && tagName != "each" && tagName != "null")
|
||||
{
|
||||
std::string myVal = "</";
|
||||
myVal += tagName;
|
||||
@ -290,6 +290,14 @@ namespace Tesses::CrossLang
|
||||
}
|
||||
nodes.push_back(AdvancedSyntaxNode::Create(IfStatement,false,{expr,truth,falsey}));
|
||||
}
|
||||
else if(tagName == "null")
|
||||
{
|
||||
EnsureSymbol(">");
|
||||
std::vector<SyntaxNode> _nodes;
|
||||
parseFn(_nodes,"null");
|
||||
nodes.push_back(AdvancedSyntaxNode::Create(ScopeNode,false,_nodes));
|
||||
|
||||
}
|
||||
else if(tagName == "while")
|
||||
{
|
||||
|
||||
|
||||
@ -4,60 +4,6 @@
|
||||
|
||||
namespace Tesses::CrossLang
|
||||
{
|
||||
static TObject FS_SubdirFilesystem(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
TVFSHeapObject* vfsho;
|
||||
|
||||
Tesses::Framework::Filesystem::VFSPath path;
|
||||
|
||||
if(GetArgumentHeap(args,0,vfsho) && GetArgumentAsPath(args,1,path))
|
||||
{
|
||||
return TVFSHeapObject::Create(ls,new Tesses::Framework::Filesystem::SubdirFilesystem(new TObjectVFS(ls.GetGC(),vfsho),path,true));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
static TObject FS_MountableFilesystem(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
TVFSHeapObject* vfsho;
|
||||
|
||||
if(GetArgumentHeap(args,0,vfsho))
|
||||
{
|
||||
return TVFSHeapObject::Create(ls,new Tesses::Framework::Filesystem::MountableFilesystem(new TObjectVFS(ls.GetGC(),vfsho),true));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
static TObject FS_MemoryStream(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
bool writable;
|
||||
if(GetArgument(args,0,writable))
|
||||
{
|
||||
return TStreamHeapObject::Create(ls,new Tesses::Framework::Streams::MemoryStream(writable));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
static TObject FS_CreateMemoryFilesystem(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
return TVFSHeapObject::Create(ls, new Tesses::Framework::Filesystem::MemoryFilesystem());
|
||||
}
|
||||
|
||||
static TObject FS_CreateFilesystem(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
TDictionary* dict;
|
||||
if(GetArgumentHeap(args,0,dict))
|
||||
{
|
||||
return TVFSHeapObject::Create(ls, new TObjectVFS(ls.GetGC(),dict));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
static TObject FS_CreateStream(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
TDictionary* dict;
|
||||
if(GetArgumentHeap(args,0,dict))
|
||||
{
|
||||
return TStreamHeapObject::Create(ls, new TObjectStream(ls.GetGC(),dict));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
static TObject FS_MakeFull(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
Tesses::Framework::Filesystem::VFSPath path;
|
||||
@ -126,6 +72,27 @@ namespace Tesses::CrossLang
|
||||
}
|
||||
return "";
|
||||
}
|
||||
static TObject FS_ReadAllBytes(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
Tesses::Framework::Filesystem::VFSPath path;
|
||||
TVFSHeapObject* vfs;
|
||||
if(GetArgumentHeap(args,0,vfs) && GetArgumentAsPath(args,1,path))
|
||||
{
|
||||
auto txtFile = vfs->vfs->OpenFile(path,"rb");
|
||||
if(txtFile == nullptr) return nullptr;
|
||||
auto res = TByteArray::Create(ls);
|
||||
std::array<uint8_t,1024> data;
|
||||
size_t read;
|
||||
do {
|
||||
read = txtFile->ReadBlock(data.data(),data.size());
|
||||
res->data.insert(res->data.end(),data.begin(),data.begin()+read);
|
||||
} while(read != 0);
|
||||
delete txtFile;
|
||||
return res;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
static TObject FS_WriteAllText(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
@ -143,6 +110,22 @@ namespace Tesses::CrossLang
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
static TObject FS_WriteAllBytes(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
Tesses::Framework::Filesystem::VFSPath path;
|
||||
|
||||
TVFSHeapObject* vfs;
|
||||
|
||||
TByteArray* bArray;
|
||||
if(GetArgumentHeap(args,0,vfs) && GetArgumentAsPath(args,1,path) && GetArgumentHeap(args,2,bArray))
|
||||
{
|
||||
auto txtFile = vfs->vfs->OpenFile(path,"wb");
|
||||
if(txtFile == nullptr) return nullptr;
|
||||
txtFile->WriteBlock(bArray->data.data(),bArray->data.size());
|
||||
delete txtFile;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static TObject FS_getCurrentPath(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
@ -178,13 +161,9 @@ namespace Tesses::CrossLang
|
||||
dict->DeclareFunction(gc, "ReadAllText","Read all text from file", {"fs","filename"},FS_ReadAllText);
|
||||
dict->DeclareFunction(gc, "WriteAllText","Write all text to file", {"fs","filename","content"},FS_WriteAllText);
|
||||
|
||||
dict->DeclareFunction(gc, "MountableFilesystem","Create a mountable filesystem",{"root"}, FS_MountableFilesystem);
|
||||
dict->DeclareFunction(gc, "SubdirFilesystem","Create a subdir filesystem",{"fs","subdir"}, FS_SubdirFilesystem);
|
||||
dict->DeclareFunction(gc, "MemoryStream","Create a memory stream",{"writable"}, FS_MemoryStream);
|
||||
dict->DeclareFunction(gc, "CreateStream","Create stream", {"strm"},FS_CreateStream);
|
||||
dict->DeclareFunction(gc, "CreateFilesystem","Create filesystem", {"fs"},FS_CreateFilesystem);
|
||||
|
||||
dict->DeclareFunction(gc, "CreateMemoryFilesystem","Create in memory filesystem", {},FS_CreateMemoryFilesystem);
|
||||
dict->DeclareFunction(gc, "ReadAllBytes","Read all bytes from file", {"fs","filename"},FS_ReadAllBytes);
|
||||
dict->DeclareFunction(gc, "WriteAllBytes","Write all bytes to file", {"fs","filename","content"},FS_WriteAllBytes);
|
||||
|
||||
dict->DeclareFunction(gc, "CreateArchive", "Create a crvm archive",{"fs","strm","name","version","info"},FS_CreateArchive);
|
||||
dict->DeclareFunction(gc,"ExtractArchive", "Extract a crvm archive",{"strm","vfs"},FS_ExtractArchive);
|
||||
env->DeclareVariable("FS", dict);
|
||||
|
||||
@ -118,7 +118,61 @@ namespace Tesses::CrossLang
|
||||
TVFSHeapObject* vfs;
|
||||
return GetArgumentHeap(args,0,vfs);
|
||||
}
|
||||
|
||||
static TObject New_SubdirFilesystem(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
TVFSHeapObject* vfsho;
|
||||
|
||||
Tesses::Framework::Filesystem::VFSPath path;
|
||||
|
||||
if(GetArgumentHeap(args,0,vfsho) && GetArgumentAsPath(args,1,path))
|
||||
{
|
||||
return TVFSHeapObject::Create(ls,new Tesses::Framework::Filesystem::SubdirFilesystem(new TObjectVFS(ls.GetGC(),vfsho),path,true));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
static TObject New_MountableFilesystem(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
TVFSHeapObject* vfsho;
|
||||
|
||||
if(GetArgumentHeap(args,0,vfsho))
|
||||
{
|
||||
return TVFSHeapObject::Create(ls,new Tesses::Framework::Filesystem::MountableFilesystem(new TObjectVFS(ls.GetGC(),vfsho),true));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
static TObject New_MemoryStream(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
bool writable;
|
||||
if(GetArgument(args,0,writable))
|
||||
{
|
||||
return TStreamHeapObject::Create(ls,new Tesses::Framework::Streams::MemoryStream(writable));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
static TObject New_MemoryFilesystem(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
return TVFSHeapObject::Create(ls, new Tesses::Framework::Filesystem::MemoryFilesystem());
|
||||
}
|
||||
|
||||
static TObject New_Filesystem(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
TDictionary* dict;
|
||||
if(GetArgumentHeap(args,0,dict))
|
||||
{
|
||||
return TVFSHeapObject::Create(ls, new TObjectVFS(ls.GetGC(),dict));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
static TObject New_Stream(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
TDictionary* dict;
|
||||
if(GetArgumentHeap(args,0,dict))
|
||||
{
|
||||
return TStreamHeapObject::Create(ls, new TObjectStream(ls.GetGC(),dict));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static TObject TypeOf(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
if(args.size() < 1) return "Undefined";
|
||||
@ -334,6 +388,15 @@ namespace Tesses::CrossLang
|
||||
|
||||
env->permissions.canRegisterRoot=true;
|
||||
TDictionary* newTypes = TDictionary::Create(ls);
|
||||
|
||||
newTypes->DeclareFunction(gc, "MountableFilesystem","Create a mountable filesystem",{"root"}, New_MountableFilesystem);
|
||||
newTypes->DeclareFunction(gc, "SubdirFilesystem","Create a subdir filesystem",{"fs","subdir"}, New_SubdirFilesystem);
|
||||
newTypes->DeclareFunction(gc, "MemoryStream","Create a memory stream",{"writable"}, New_MemoryStream);
|
||||
newTypes->DeclareFunction(gc, "Stream","Create stream", {"strm"},New_Stream);
|
||||
newTypes->DeclareFunction(gc, "Filesystem","Create filesystem", {"fs"},New_Filesystem);
|
||||
|
||||
newTypes->DeclareFunction(gc, "MemoryFilesystem","Create in memory filesystem", {},New_MemoryFilesystem);
|
||||
|
||||
|
||||
newTypes->DeclareFunction(gc,"Version","Create a version object",{"$major","$minor","$patch","$build","$stage"},[](GCList& ls, std::vector<TObject> args)->TObject{
|
||||
int64_t major=1;
|
||||
@ -375,7 +438,7 @@ namespace Tesses::CrossLang
|
||||
env->DeclareFunction(gc, "TypeIsVFS","Get whether object is a virtual filesystem",{"object"},TypeIsVFS);
|
||||
|
||||
|
||||
env->DeclareFunction(gc, "Regex", "Create regex object",{"regex"},[](GCList& ls,std::vector<TObject> args)->TObject {
|
||||
newTypes->DeclareFunction(gc, "Regex", "Create regex object",{"regex"},[](GCList& ls,std::vector<TObject> args)->TObject {
|
||||
std::string str;
|
||||
if(GetArgument(args,0,str))
|
||||
{
|
||||
@ -384,7 +447,7 @@ namespace Tesses::CrossLang
|
||||
}
|
||||
return nullptr;
|
||||
});
|
||||
env->DeclareFunction(gc, "Mutex", "Create mutex",{}, [](GCList& ls,std::vector<TObject> args)->TObject {
|
||||
newTypes->DeclareFunction(gc, "Mutex", "Create mutex",{}, [](GCList& ls,std::vector<TObject> args)->TObject {
|
||||
ls.GetGC()->BarrierBegin();
|
||||
auto mtx = TDictionary::Create(ls);
|
||||
auto native = TNative::Create(ls, new Tesses::Framework::Threading::Mutex(),[](void* ptr)->void{
|
||||
@ -428,7 +491,7 @@ namespace Tesses::CrossLang
|
||||
ls.GetGC()->BarrierEnd();
|
||||
return mtx;
|
||||
});
|
||||
env->DeclareFunction(gc, "Thread","Create thread",{"callback"},[](GCList& ls, std::vector<TObject> args)-> TObject
|
||||
newTypes->DeclareFunction(gc, "Thread","Create thread",{"callback"},[](GCList& ls, std::vector<TObject> args)-> TObject
|
||||
{
|
||||
if(args.size() == 1 && std::holds_alternative<THeapObjectHolder>(args[0]))
|
||||
{
|
||||
@ -440,7 +503,7 @@ namespace Tesses::CrossLang
|
||||
}
|
||||
return Undefined();
|
||||
});
|
||||
env->DeclareFunction(gc,"ByteArray","Create bytearray, with optional either size (to size it) or string argument (to fill byte array)",{"$data"},ByteArray);
|
||||
newTypes->DeclareFunction(gc,"ByteArray","Create bytearray, with optional either size (to size it) or string argument (to fill byte array)",{"$data"},ByteArray);
|
||||
gc->BarrierBegin();
|
||||
env->DeclareVariable("Version", TDictionary::Create(ls,{
|
||||
TDItem("Parse",TExternalMethod::Create(ls,"Parse version from string",{"versionStr"},[](GCList& ls, std::vector<TObject> args)->TObject{
|
||||
|
||||
Reference in New Issue
Block a user