Skip to content

Commit

Permalink
Fixed issues with SAFE in Parse and HttpRequest blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
openbullet committed Apr 28, 2022
1 parent 9c44c4a commit 308bd7c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
11 changes: 11 additions & 0 deletions RuriLib/Models/Blocks/Custom/HttpRequestBlockInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public override string ToLC(bool printDefaultParams = false)

using var writer = new LoliCodeWriter(base.ToLC(printDefaultParams));

if (Safe)
{
writer.AppendLine("SAFE", 2);
}

switch (RequestParams)
{
case StandardRequestParams x:
Expand Down Expand Up @@ -154,6 +159,12 @@ public override void FromLC(ref string script, ref int lineNumber)
if (string.IsNullOrWhiteSpace(line))
continue;

if (line.StartsWith("SAFE"))
{
Safe = true;
continue;
}

if (line.StartsWith("TYPE:"))
{
try
Expand Down
18 changes: 13 additions & 5 deletions RuriLib/Models/Blocks/Custom/ParseBlockInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ public override string ToLC(bool printDefaultParams = false)
*/

using var writer = new LoliCodeWriter(base.ToLC(printDefaultParams));


if (Safe)
{
writer.AppendLine("SAFE", 2);
}

if (Recursive)
writer.AppendLine("RECURSIVE", 2);

Expand Down Expand Up @@ -84,6 +89,12 @@ public override void FromLC(ref string script, ref int lineNumber)
if (string.IsNullOrWhiteSpace(line))
continue;

if (line.StartsWith("SAFE"))
{
Safe = true;
continue;
}

if (line.StartsWith("RECURSIVE"))
Recursive = true;

Expand Down Expand Up @@ -148,10 +159,7 @@ public override string ToCSharp(List<string> definedVariables, ConfigSettings se
writer.WriteLine("try {");

// Here we already know the variable exists so we just do the assignment
if (Descriptor.ReturnType.HasValue)
{
writer.Write($"{OutputVariable} = ");
}
writer.Write($"{OutputVariable} = ");

WriteParseMethod(writer);

Expand Down

0 comments on commit 308bd7c

Please sign in to comment.