Skip to content

Commit

Permalink
ArrayType.cs fixes and optimizations.
Browse files Browse the repository at this point in the history
  • Loading branch information
tnunnink committed Aug 1, 2023
1 parent d74c99b commit 6464cba
Show file tree
Hide file tree
Showing 22 changed files with 446 additions and 398 deletions.
86 changes: 33 additions & 53 deletions src/.idea/.idea.L5Sharp/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/Components/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ public int ParentPortId
{
// ReSharper disable once ExplicitCallerInfoArgument I don't like the L5X name...
get => GetValue<int>(L5XName.ParentModPortId);
set => SetValue(value);
// ReSharper disable once ExplicitCallerInfoArgument I don't like the L5X name...
set => SetValue(value, L5XName.ParentModPortId);
}

/// <summary>
Expand Down
8 changes: 1 addition & 7 deletions src/Enums/Radix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,10 @@ private Radix(string name, string value) : base(name, value)
/// </returns>
public static Radix Default(LogixType type)
{
if (type is ArrayType arrayType)
type = arrayType.First();

if (type is not AtomicType atomicType)
return Null;

return atomicType is REAL ? Float : Decimal;
return atomicType is REAL or LREAL ? Float : Decimal;
}

/// <summary>
Expand All @@ -103,9 +100,6 @@ public static Radix Default(LogixType type)
/// <returns>true if the current radix value is valid for the given data type instance; otherwise, false.</returns>
public bool SupportsType(LogixType type)
{
if (type is ArrayType arrayType)
type = arrayType.First();

if (type is not AtomicType atomicType)
return Equals(Null);

Expand Down
12 changes: 6 additions & 6 deletions src/Enums/Scope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private Scope(string name, string value) : base(name, value)
/// <summary>
/// Gets the corresponding L5XName for the current <see cref="Scope"/>.
/// </summary>
public abstract XName XName { get; }
public abstract string L5XName { get; }

/// <summary>
/// Represents a Null <see cref="Scope"/> value.
Expand Down Expand Up @@ -48,7 +48,7 @@ public NullScope() : base(nameof(Null), "NullScope")
{
}

public override XName XName => string.Empty;
public override string L5XName => string.Empty;
}

private class ControllerScope : Scope
Expand All @@ -57,7 +57,7 @@ public ControllerScope() : base(nameof(Controller), "ControllerScope")
{
}

public override XName XName => L5XName.Controller;
public override string L5XName => L5Sharp.L5XName.Controller;
}

private class ProgramScope : Scope
Expand All @@ -66,7 +66,7 @@ public ProgramScope() : base(nameof(Program), "ProgramScope")
{
}

public override XName XName => L5XName.Program;
public override string L5XName => L5Sharp.L5XName.Program;
}

private class RoutineScope : Scope
Expand All @@ -75,7 +75,7 @@ public RoutineScope() : base(nameof(Routine), "RoutineScope")
{
}

public override XName XName => L5XName.Routine;
public override string L5XName => L5Sharp.L5XName.Routine;
}

private class InstructionScope : Scope
Expand All @@ -84,6 +84,6 @@ public InstructionScope() : base(nameof(Instruction), "InstructionScope")
{
}

public override XName XName => L5XName.AddOnInstructionDefinition;
public override string L5XName => L5Sharp.L5XName.AddOnInstructionDefinition;
}
}
Loading

0 comments on commit 6464cba

Please sign in to comment.