Update to version 1.0.0 #3
10 changed files with 525 additions and 77 deletions
|
@ -2,4 +2,5 @@ FileVersion = 1
|
||||||
|
|
||||||
[Project]
|
[Project]
|
||||||
Name = "Bofa"
|
Name = "Bofa"
|
||||||
|
TargetType = "BeefLib"
|
||||||
StartupObject = "Bofa.Program"
|
StartupObject = "Bofa.Program"
|
||||||
|
|
10
src/Bofa.bf
10
src/Bofa.bf
|
@ -6,7 +6,7 @@ using System.Collections;
|
||||||
class Bofa
|
class Bofa
|
||||||
{
|
{
|
||||||
|
|
||||||
private String _line = null ~ if(_ != null) delete _; //The actual line
|
private String _line = null ~ delete _; //The actual line
|
||||||
private Bofa _lastObject = null; //If we are a container we keep track of the last container inside of us
|
private Bofa _lastObject = null; //If we are a container we keep track of the last container inside of us
|
||||||
|
|
||||||
public StringView Name;
|
public StringView Name;
|
||||||
|
@ -29,13 +29,13 @@ class Bofa
|
||||||
if(target.Type == .Array)
|
if(target.Type == .Array)
|
||||||
{
|
{
|
||||||
depth++;
|
depth++;
|
||||||
for(var i in Value.Array.Reversed)
|
for(var i in target.Value.Array.Reversed)
|
||||||
toProcess.Add((depth, i));
|
toProcess.Add((depth, i));
|
||||||
}
|
}
|
||||||
else if(target.Type == .Object)
|
else if(target.Type == .Object)
|
||||||
{
|
{
|
||||||
depth++;
|
depth++;
|
||||||
for(var i in Value.Object)
|
for(var i in target.Value.Object)
|
||||||
toProcess.Add((depth, i.value));
|
toProcess.Add((depth, i.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +60,8 @@ class Bofa
|
||||||
strBuffer.Append(scope $"a {Name}");
|
strBuffer.Append(scope $"a {Name}");
|
||||||
case .BigInteger:
|
case .BigInteger:
|
||||||
strBuffer.Append(scope $"bi {Name} {Value.BigInteger}");
|
strBuffer.Append(scope $"bi {Name} {Value.BigInteger}");
|
||||||
|
case .BigUnsignedInteger:
|
||||||
|
strBuffer.Append(scope $"bui {Name} {Value.BigUnsignedInteger}");
|
||||||
case .BigNumber:
|
case .BigNumber:
|
||||||
strBuffer.Append(scope $"bn {Name} {Value.BigNumber:R}");
|
strBuffer.Append(scope $"bn {Name} {Value.BigNumber:R}");
|
||||||
case .Boolean:
|
case .Boolean:
|
||||||
|
@ -68,6 +70,8 @@ class Bofa
|
||||||
strBuffer.Append(scope $"c {Typename} {Name} {Value.Custom}");
|
strBuffer.Append(scope $"c {Typename} {Name} {Value.Custom}");
|
||||||
case .Integer:
|
case .Integer:
|
||||||
strBuffer.Append(scope $"i {Name} {Value.Integer}");
|
strBuffer.Append(scope $"i {Name} {Value.Integer}");
|
||||||
|
case .UnsignedInteger:
|
||||||
|
strBuffer.Append(scope $"ui {Name} {Value.UnsignedInteger}");
|
||||||
case .Line:
|
case .Line:
|
||||||
strBuffer.Append(scope $"l {Name} {Value.Line}");
|
strBuffer.Append(scope $"l {Name} {Value.Line}");
|
||||||
case .Number:
|
case .Number:
|
||||||
|
|
|
@ -50,7 +50,7 @@ class BofaParser
|
||||||
}
|
}
|
||||||
if (entry.Type == .Error)
|
if (entry.Type == .Error)
|
||||||
{
|
{
|
||||||
if(entry.Data.Bofa != null)
|
if (entry.Data.Bofa != null)
|
||||||
delete entry.Data.Bofa;
|
delete entry.Data.Bofa;
|
||||||
pErrors.Add(line);
|
pErrors.Add(line);
|
||||||
continue;
|
continue;
|
||||||
|
@ -168,6 +168,10 @@ class BofaParser
|
||||||
typeName = "Integer";
|
typeName = "Integer";
|
||||||
case "bi":
|
case "bi":
|
||||||
typeName = "BigInteger";
|
typeName = "BigInteger";
|
||||||
|
case "ui":
|
||||||
|
typeName = "UnsignedInteger";
|
||||||
|
case "bui":
|
||||||
|
typeName = "BigUnsignedInteger";
|
||||||
case "t":
|
case "t":
|
||||||
typeName = "Text";
|
typeName = "Text";
|
||||||
case "a":
|
case "a":
|
||||||
|
@ -278,7 +282,24 @@ class BofaParser
|
||||||
toReturn.Type = .Error;
|
toReturn.Type = .Error;
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
bofaRes.Value.BigInteger = result.Value;
|
case "ui":
|
||||||
|
bofaRes.Type = .UnsignedInteger;
|
||||||
|
var result = uint32.Parse(line);
|
||||||
|
if (result case .Err)
|
||||||
|
{
|
||||||
|
toReturn.Type = .Error;
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
bofaRes.Value.UnsignedInteger = result.Value;
|
||||||
|
case "bui":
|
||||||
|
bofaRes.Type = .BigUnsignedInteger;
|
||||||
|
var result = uint64.Parse(line);
|
||||||
|
if (result case .Err)
|
||||||
|
{
|
||||||
|
toReturn.Type = .Error;
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
bofaRes.Value.BigUnsignedInteger = result.Value;
|
||||||
case "t":
|
case "t":
|
||||||
bofaRes.Value.Text = new String(line);
|
bofaRes.Value.Text = new String(line);
|
||||||
bofaRes.Type = .Text;
|
bofaRes.Type = .Text;
|
||||||
|
|
|
@ -12,6 +12,8 @@ struct BofaValue
|
||||||
public double BigNumber;
|
public double BigNumber;
|
||||||
public int32 Integer;
|
public int32 Integer;
|
||||||
public int64 BigInteger;
|
public int64 BigInteger;
|
||||||
|
public uint32 UnsignedInteger;
|
||||||
|
public uint64 BigUnsignedInteger;
|
||||||
public bool Boolean;
|
public bool Boolean;
|
||||||
public StringView Custom;
|
public StringView Custom;
|
||||||
public Dictionary<StringView, Bofa> Object;
|
public Dictionary<StringView, Bofa> Object;
|
||||||
|
|
482
src/Extension.bf
482
src/Extension.bf
|
@ -1,4 +1,8 @@
|
||||||
using Bofa.Serialization;
|
using Bofa.Serialization;
|
||||||
|
using Bofa;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
|
||||||
namespace System
|
namespace System
|
||||||
{
|
{
|
||||||
|
@ -11,6 +15,63 @@ namespace System
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Int : IBofaParseable
|
extension Int : IBofaParseable
|
||||||
|
{
|
||||||
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
|
{
|
||||||
|
pTarget.Type = .Integer;
|
||||||
|
pTarget.Typename = "Integer";
|
||||||
|
pTarget.Value.Integer = (.)Math.Clamp(this, int32.MinValue, int32.MaxValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deserialize(Bofa.Bofa pInput) mut
|
||||||
|
{
|
||||||
|
if(pInput.Type != .Integer)
|
||||||
|
return false;
|
||||||
|
this = Math.Clamp(pInput.Value.Integer, int.MaxValue, int.MinValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Int8 : IBofaParseable
|
||||||
|
{
|
||||||
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
|
{
|
||||||
|
pTarget.Type = .Integer;
|
||||||
|
pTarget.Typename = "Integer";
|
||||||
|
pTarget.Value.Integer = (.)Math.Clamp(this, int8.MinValue, int8.MaxValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deserialize(Bofa.Bofa pInput) mut
|
||||||
|
{
|
||||||
|
if(pInput.Type != .Integer)
|
||||||
|
return false;
|
||||||
|
this = (.)Math.Clamp(pInput.Value.Integer, int8.MaxValue, int8.MinValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Int16 : IBofaParseable
|
||||||
|
{
|
||||||
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
|
{
|
||||||
|
pTarget.Type = .Integer;
|
||||||
|
pTarget.Typename = "Integer";
|
||||||
|
pTarget.Value.Integer = (.)Math.Clamp(this, int16.MinValue, int16.MaxValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deserialize(Bofa.Bofa pInput) mut
|
||||||
|
{
|
||||||
|
if(pInput.Type != .Integer)
|
||||||
|
return false;
|
||||||
|
this = (.)Math.Clamp(pInput.Value.Integer, int16.MaxValue, int16.MinValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Int32 : IBofaParseable
|
||||||
{
|
{
|
||||||
public bool Serialize(Bofa.Bofa pTarget)
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
{
|
{
|
||||||
|
@ -28,4 +89,425 @@ namespace System
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension Int64 : IBofaParseable
|
||||||
|
{
|
||||||
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
|
{
|
||||||
|
pTarget.Type = .BigInteger;
|
||||||
|
pTarget.Typename = "BigInteger";
|
||||||
|
pTarget.Value.BigInteger = (.)this;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deserialize(Bofa.Bofa pInput) mut
|
||||||
|
{
|
||||||
|
if(pInput.Type != .BigInteger)
|
||||||
|
return false;
|
||||||
|
this = (.)pInput.Value.BigInteger;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension UInt : IBofaParseable
|
||||||
|
{
|
||||||
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
|
{
|
||||||
|
pTarget.Type = .UnsignedInteger;
|
||||||
|
pTarget.Typename = "UnsignedInteger";
|
||||||
|
pTarget.Value.UnsignedInteger = (.)Math.Clamp(this, uint32.MinValue, uint32.MaxValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deserialize(Bofa.Bofa pInput) mut
|
||||||
|
{
|
||||||
|
if(pInput.Type != .UnsignedInteger)
|
||||||
|
return false;
|
||||||
|
this = (.)Math.Clamp(pInput.Value.UnsignedInteger, uint.MaxValue, uint.MinValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension UInt8 : IBofaParseable
|
||||||
|
{
|
||||||
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
|
{
|
||||||
|
pTarget.Type = .UnsignedInteger;
|
||||||
|
pTarget.Typename = "UnsignedInteger";
|
||||||
|
pTarget.Value.UnsignedInteger = (.)Math.Clamp(this, uint8.MinValue, uint8.MaxValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deserialize(Bofa.Bofa pInput) mut
|
||||||
|
{
|
||||||
|
if(pInput.Type != .UnsignedInteger)
|
||||||
|
return false;
|
||||||
|
this = (.)Math.Clamp(pInput.Value.UnsignedInteger, uint8.MaxValue, uint8.MinValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension UInt16 : IBofaParseable
|
||||||
|
{
|
||||||
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
|
{
|
||||||
|
pTarget.Type = .UnsignedInteger;
|
||||||
|
pTarget.Typename = "UnsignedInteger";
|
||||||
|
pTarget.Value.UnsignedInteger = (.)Math.Clamp(this, uint16.MinValue, uint16.MaxValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deserialize(Bofa.Bofa pInput) mut
|
||||||
|
{
|
||||||
|
if(pInput.Type != .UnsignedInteger)
|
||||||
|
return false;
|
||||||
|
this = (.)Math.Clamp(pInput.Value.UnsignedInteger, uint16.MaxValue, uint16.MinValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension UInt32 : IBofaParseable
|
||||||
|
{
|
||||||
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
|
{
|
||||||
|
pTarget.Type = .UnsignedInteger;
|
||||||
|
pTarget.Typename = "UnsignedInteger";
|
||||||
|
pTarget.Value.UnsignedInteger = (.)Math.Clamp(this, uint32.MinValue, uint32.MaxValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deserialize(Bofa.Bofa pInput) mut
|
||||||
|
{
|
||||||
|
if(pInput.Type != .UnsignedInteger)
|
||||||
|
return false;
|
||||||
|
this = (.)Math.Clamp(pInput.Value.UnsignedInteger, uint32.MaxValue, uint32.MinValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension UInt64 : IBofaParseable
|
||||||
|
{
|
||||||
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
|
{
|
||||||
|
pTarget.Type = .BigUnsignedInteger;
|
||||||
|
pTarget.Typename = "BigUnsignedInteger";
|
||||||
|
pTarget.Value.BigUnsignedInteger = (.)Math.Clamp(this, uint64.MinValue, uint64.MaxValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deserialize(Bofa.Bofa pInput) mut
|
||||||
|
{
|
||||||
|
if(pInput.Type != .BigUnsignedInteger)
|
||||||
|
return false;
|
||||||
|
this = (.)Math.Clamp(pInput.Value.BigUnsignedInteger, uint64.MaxValue, uint64.MinValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Char8 : IBofaParseable
|
||||||
|
{
|
||||||
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
|
{
|
||||||
|
pTarget.Type = .Text;
|
||||||
|
pTarget.Typename = "Text";
|
||||||
|
pTarget.Value.Text = new String()..Append(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deserialize(Bofa.Bofa pInput) mut
|
||||||
|
{
|
||||||
|
if(pInput.Type == .Text)
|
||||||
|
this = pInput.Value.Text[0];
|
||||||
|
else if(pInput.Type == .Line)
|
||||||
|
this = pInput.Value.Line[0];
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Char16 : IBofaParseable
|
||||||
|
{
|
||||||
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
|
{
|
||||||
|
pTarget.Type = .Text;
|
||||||
|
pTarget.Typename = "Text";
|
||||||
|
pTarget.Value.Text = new String()..Append(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deserialize(Bofa.Bofa pInput) mut
|
||||||
|
{
|
||||||
|
if(pInput.Type == .Text)
|
||||||
|
this = pInput.Value.Text[0];
|
||||||
|
else if(pInput.Type == .Line)
|
||||||
|
this = pInput.Value.Line[0];
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Char32 : IBofaParseable
|
||||||
|
{
|
||||||
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
|
{
|
||||||
|
pTarget.Type = .Text;
|
||||||
|
pTarget.Typename = "Text";
|
||||||
|
pTarget.Value.Text = new String()..Append(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deserialize(Bofa.Bofa pInput) mut
|
||||||
|
{
|
||||||
|
if(pInput.Type == .Text)
|
||||||
|
this = pInput.Value.Text[0];
|
||||||
|
else if(pInput.Type == .Line)
|
||||||
|
this = pInput.Value.Line[0];
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Float : IBofaParseable
|
||||||
|
{
|
||||||
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
|
{
|
||||||
|
pTarget.Type = .Number;
|
||||||
|
pTarget.Typename = "Number";
|
||||||
|
pTarget.Value.Number = (.)this;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deserialize(Bofa.Bofa pInput) mut
|
||||||
|
{
|
||||||
|
if(pInput.Type != .Number)
|
||||||
|
return false;
|
||||||
|
this = (.)pInput.Value.Number;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Double : IBofaParseable
|
||||||
|
{
|
||||||
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
|
{
|
||||||
|
pTarget.Type = .BigNumber;
|
||||||
|
pTarget.Typename = "BigNumber";
|
||||||
|
pTarget.Value.BigNumber = (.)this;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deserialize(Bofa.Bofa pInput) mut
|
||||||
|
{
|
||||||
|
if(pInput.Type != .BigNumber)
|
||||||
|
return false;
|
||||||
|
this = (.)pInput.Value.BigNumber;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension String : IBofaParseable
|
||||||
|
{
|
||||||
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
|
{
|
||||||
|
if(this.Contains('\n'))
|
||||||
|
{
|
||||||
|
pTarget.Type = .Text;
|
||||||
|
pTarget.Typename = "Text";
|
||||||
|
pTarget.Value.Text = new .(this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pTarget.Type = .Line;
|
||||||
|
pTarget.Typename = "Line";
|
||||||
|
pTarget.Value.Line = this;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deserialize(Bofa.Bofa pInput)
|
||||||
|
{
|
||||||
|
this.Clear();
|
||||||
|
if(pInput.Type == .Line)
|
||||||
|
this.Append(pInput.Value.Line);
|
||||||
|
else if(pInput.Type == .Text)
|
||||||
|
this.Append(pInput.Value.Text);
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace System.Collections
|
||||||
|
{
|
||||||
|
extension List<T> : IBofaParseable where T : IBofaParseable where T : new where T : delete where T : class
|
||||||
|
{
|
||||||
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
|
{
|
||||||
|
pTarget.Type = .Array;
|
||||||
|
pTarget.Typename = "Array";
|
||||||
|
pTarget.Value.Array = new .(this.Count);
|
||||||
|
for(var i in this)
|
||||||
|
{
|
||||||
|
Bofa toAdd = new .();
|
||||||
|
toAdd.[Friend]_line = new .(@i.Index);
|
||||||
|
toAdd.Name = toAdd.[Friend]_line;
|
||||||
|
if(!i.Serialize(toAdd))
|
||||||
|
{
|
||||||
|
delete toAdd;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pTarget.Value.Array.Add(toAdd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deserialize(Bofa.Bofa pInput)
|
||||||
|
{
|
||||||
|
if(pInput.Type != .Array)
|
||||||
|
return false;
|
||||||
|
for(var i in pInput.Value.Array)
|
||||||
|
{
|
||||||
|
var toParse = new T();
|
||||||
|
if(!toParse.Deserialize(i))
|
||||||
|
delete toParse;
|
||||||
|
else
|
||||||
|
this.Add((.)toParse);
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension List<T> : IBofaParseable where T : IBofaParseable where T : struct where T : new
|
||||||
|
{
|
||||||
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
|
{
|
||||||
|
pTarget.Type = .Array;
|
||||||
|
pTarget.Typename = "Array";
|
||||||
|
pTarget.Value.Array = new .(this.Count);
|
||||||
|
for(var i in this)
|
||||||
|
{
|
||||||
|
Bofa toAdd = new .();
|
||||||
|
toAdd.[Friend]_line = new .(@i.Index);
|
||||||
|
toAdd.Name = toAdd.[Friend]_line;
|
||||||
|
if(!i.Serialize(toAdd))
|
||||||
|
{
|
||||||
|
delete toAdd;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pTarget.Value.Array.Add(toAdd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deserialize(Bofa.Bofa pInput)
|
||||||
|
{
|
||||||
|
if(pInput.Type != .Array)
|
||||||
|
return false;
|
||||||
|
for(var i in pInput.Value.Array)
|
||||||
|
{
|
||||||
|
var toParse = T();
|
||||||
|
if(toParse.Deserialize(i))
|
||||||
|
this.Add((.)toParse);
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Dictionary<TKey, TValue> : IBofaParseable where TKey : String where TValue : IBofaParseable where TValue : new where TValue : delete where TValue : class
|
||||||
|
{
|
||||||
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
|
{
|
||||||
|
pTarget.Type = .Object;
|
||||||
|
pTarget.Typename = "Object";
|
||||||
|
pTarget.Value.Object = new .();
|
||||||
|
for(var i in this)
|
||||||
|
{
|
||||||
|
Bofa toAdd = new .();
|
||||||
|
toAdd.[Friend]_line = new .(@i.Key);
|
||||||
|
toAdd.Name = toAdd.[Friend]_line;
|
||||||
|
if(!i.value.Serialize(toAdd))
|
||||||
|
{
|
||||||
|
delete toAdd;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pTarget.Value.Array.Add(toAdd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deserialize(Bofa.Bofa pInput)
|
||||||
|
{
|
||||||
|
if(pInput.Type != .Object)
|
||||||
|
return false;
|
||||||
|
for(var i in pInput.Value.Object)
|
||||||
|
{
|
||||||
|
var toParse = new TValue();
|
||||||
|
if(toParse.Deserialize(i.value))
|
||||||
|
this.Add(new .(i.key), toParse);
|
||||||
|
else
|
||||||
|
delete toParse;
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Dictionary<TKey, TValue> : IBofaParseable where TKey : String where TValue : IBofaParseable where TValue : new where TValue : struct
|
||||||
|
{
|
||||||
|
public bool Serialize(Bofa.Bofa pTarget)
|
||||||
|
{
|
||||||
|
pTarget.Type = .Object;
|
||||||
|
pTarget.Typename = "Object";
|
||||||
|
pTarget.Value.Object = new .();
|
||||||
|
for(var i in this)
|
||||||
|
{
|
||||||
|
Bofa toAdd = new .();
|
||||||
|
toAdd.[Friend]_line = new .(@i.Key);
|
||||||
|
toAdd.Name = toAdd.[Friend]_line;
|
||||||
|
if(!i.value.Serialize(toAdd))
|
||||||
|
{
|
||||||
|
delete toAdd;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pTarget.Value.Array.Add(toAdd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deserialize(Bofa.Bofa pInput)
|
||||||
|
{
|
||||||
|
if(pInput.Type != .Object)
|
||||||
|
return false;
|
||||||
|
for(var i in pInput.Value.Object)
|
||||||
|
{
|
||||||
|
var toParse = TValue();
|
||||||
|
if(toParse.Deserialize(i.value))
|
||||||
|
this.Add(new .(i.key), toParse);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,21 +0,0 @@
|
||||||
namespace Bofa;
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
|
|
||||||
class Program
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void Main()
|
|
||||||
{
|
|
||||||
Bofa.Testing.Profiling.Profiling_Depth_Testing();
|
|
||||||
Bofa.Testing.Profiling.Profiling_Depth_Testing_Medium();
|
|
||||||
Bofa.Testing.Profiling.Profiling_Normal();
|
|
||||||
Bofa.Testing.Profiling.Profiling_Normal_Medium();
|
|
||||||
Bofa.Testing.Profiling.Profiling_Normal_Large();
|
|
||||||
Bofa.Testing.Profiling.Profiling_Texts();
|
|
||||||
Bofa.Testing.Profiling.Profiling_Texts_Large();
|
|
||||||
|
|
||||||
Console.Read();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
namespace Bofa.Testing;
|
|
||||||
|
|
||||||
using Bofa;
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
|
|
||||||
class Consistency
|
|
||||||
{
|
|
||||||
[Test(Name="Reverse simple")]
|
|
||||||
public static void Standart()
|
|
||||||
{
|
|
||||||
String content = """
|
|
||||||
l one line of text
|
|
||||||
b bool true
|
|
||||||
t textgoes here
|
|
||||||
- Text addendum
|
|
||||||
n tone 12.5
|
|
||||||
bn biggie 65645654535.553001
|
|
||||||
i int 234345
|
|
||||||
bi bint 38432847329847329
|
|
||||||
o object
|
|
||||||
b content true
|
|
||||||
a array
|
|
||||||
b content true
|
|
||||||
b content true
|
|
||||||
""";
|
|
||||||
Dictionary<StringView, Bofa> output = new .();
|
|
||||||
List<int64> errors = new .();
|
|
||||||
BofaParser.Parse(content, output, errors);
|
|
||||||
|
|
||||||
String s = scope .();
|
|
||||||
for(var i in output)
|
|
||||||
{
|
|
||||||
i.value.ToString(s);
|
|
||||||
s.Append('\n');
|
|
||||||
}
|
|
||||||
s.RemoveFromEnd(1);
|
|
||||||
|
|
||||||
Test.Assert(content == s);
|
|
||||||
|
|
||||||
DeleteDictionaryAndValues!(output);
|
|
||||||
delete errors;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,7 +7,7 @@ using System.Collections;
|
||||||
|
|
||||||
class Fuzzing
|
class Fuzzing
|
||||||
{
|
{
|
||||||
//[Test(Name = "Fuzzing - 10 * 1000000 random characters")]
|
[Test(Name = "Fuzzing - 10 * 1000000 random characters")]
|
||||||
public static void Fuzzin_Random()
|
public static void Fuzzin_Random()
|
||||||
{
|
{
|
||||||
for (int i < 10)
|
for (int i < 10)
|
||||||
|
@ -25,7 +25,7 @@ class Fuzzing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//[Test(Name = "Fuzzing - 10 * 10000000 random characters")]
|
[Test(Name = "Fuzzing - 10 * 10000000 random characters")]
|
||||||
public static void Fuzzin_Random_Large()
|
public static void Fuzzin_Random_Large()
|
||||||
{
|
{
|
||||||
for (int i < 10)
|
for (int i < 10)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
namespace Bofa.Testing;
|
namespace Bofa.Testing;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
using Bofa;
|
using Bofa;
|
||||||
using Bofa.Serialization;
|
using Bofa.Serialization;
|
||||||
|
@ -8,18 +9,19 @@ using Bofa.Serialization;
|
||||||
[BofaSerialize]
|
[BofaSerialize]
|
||||||
class Serialization
|
class Serialization
|
||||||
{
|
{
|
||||||
public int anInteger = (.)1;
|
public int anInteger = 1;
|
||||||
|
public String aString = "Value";
|
||||||
|
public List<String> listOfStrings = new .() ~ DeleteContainerAndItems!(_);
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public static void Test()
|
public static void Test()
|
||||||
{
|
{
|
||||||
Serialization s = scope .();
|
Serialization s = scope .();
|
||||||
|
s.listOfStrings.Add(new .("dfdsfdsfdsf"));
|
||||||
Bofa b = scope .();
|
Bofa b = scope .();
|
||||||
b.Name = "s";
|
b.Name = "s";
|
||||||
s.Serialize(b);
|
s.Serialize(b);
|
||||||
|
|
||||||
Console.WriteLine(b.ToString(.. scope .()));
|
|
||||||
//Console.Read();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -8,6 +8,8 @@ enum EBofaType
|
||||||
BigNumber, //64bit floating point number
|
BigNumber, //64bit floating point number
|
||||||
Integer, //32bit signed integer
|
Integer, //32bit signed integer
|
||||||
BigInteger, //64bit signed integer
|
BigInteger, //64bit signed integer
|
||||||
|
UnsignedInteger, //32bit unsigned integer
|
||||||
|
BigUnsignedInteger, //64bit unsigned integer
|
||||||
Boolean, //8bit true or false
|
Boolean, //8bit true or false
|
||||||
Object, // Key-Value container
|
Object, // Key-Value container
|
||||||
Array, //Numeric container
|
Array, //Numeric container
|
||||||
|
|
Loading…
Add table
Reference in a new issue