Rename BooleanExpression => ConditionExpression
This commit is contained in:
@@ -398,13 +398,13 @@ namespace OpenRA
|
|||||||
|
|
||||||
return InvalidValueAction(value, fieldType, fieldName);
|
return InvalidValueAction(value, fieldType, fieldName);
|
||||||
}
|
}
|
||||||
else if (fieldType == typeof(BooleanExpression))
|
else if (fieldType == typeof(ConditionExpression))
|
||||||
{
|
{
|
||||||
if (value != null)
|
if (value != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return new BooleanExpression(value);
|
return new ConditionExpression(value);
|
||||||
}
|
}
|
||||||
catch (InvalidDataException e)
|
catch (InvalidDataException e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -241,7 +241,7 @@
|
|||||||
<Compile Include="Primitives\float3.cs" />
|
<Compile Include="Primitives\float3.cs" />
|
||||||
<Compile Include="InstalledMods.cs" />
|
<Compile Include="InstalledMods.cs" />
|
||||||
<Compile Include="CryptoUtil.cs" />
|
<Compile Include="CryptoUtil.cs" />
|
||||||
<Compile Include="Support\BooleanExpression.cs" />
|
<Compile Include="Support\ConditionExpression.cs" />
|
||||||
<Compile Include="ExternalMods.cs" />
|
<Compile Include="ExternalMods.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace OpenRA.Support
|
namespace OpenRA.Support
|
||||||
{
|
{
|
||||||
public class BooleanExpression
|
public class ConditionExpression
|
||||||
{
|
{
|
||||||
public readonly string Expression;
|
public readonly string Expression;
|
||||||
readonly HashSet<string> variables = new HashSet<string>();
|
readonly HashSet<string> variables = new HashSet<string>();
|
||||||
@@ -67,7 +67,7 @@ namespace OpenRA.Support
|
|||||||
class NotEqualsToken : BinaryOperationToken { public NotEqualsToken(int index) : base("!=", index) { } }
|
class NotEqualsToken : BinaryOperationToken { public NotEqualsToken(int index) : base("!=", index) { } }
|
||||||
class NotToken : UnaryOperationToken { public NotToken(int index) : base("!", index) { } }
|
class NotToken : UnaryOperationToken { public NotToken(int index) : base("!", index) { } }
|
||||||
|
|
||||||
public BooleanExpression(string expression)
|
public ConditionExpression(string expression)
|
||||||
{
|
{
|
||||||
Expression = expression;
|
Expression = expression;
|
||||||
var openParens = 0;
|
var openParens = 0;
|
||||||
@@ -29,9 +29,9 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
if (typeof(IEnumerable<string>).IsAssignableFrom(type))
|
if (typeof(IEnumerable<string>).IsAssignableFrom(type))
|
||||||
return fieldInfo.GetValue(ruleInfo) as IEnumerable<string>;
|
return fieldInfo.GetValue(ruleInfo) as IEnumerable<string>;
|
||||||
|
|
||||||
if (type == typeof(BooleanExpression))
|
if (type == typeof(ConditionExpression))
|
||||||
{
|
{
|
||||||
var expr = (BooleanExpression)fieldInfo.GetValue(ruleInfo);
|
var expr = (ConditionExpression)fieldInfo.GetValue(ruleInfo);
|
||||||
return expr != null ? expr.Variables : Enumerable.Empty<string>();
|
return expr != null ? expr.Variables : Enumerable.Empty<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,9 +48,9 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
if (typeof(IEnumerable).IsAssignableFrom(type))
|
if (typeof(IEnumerable).IsAssignableFrom(type))
|
||||||
return (IEnumerable<string>)propertyInfo.GetValue(ruleInfo);
|
return (IEnumerable<string>)propertyInfo.GetValue(ruleInfo);
|
||||||
|
|
||||||
if (type == typeof(BooleanExpression))
|
if (type == typeof(ConditionExpression))
|
||||||
{
|
{
|
||||||
var expr = (BooleanExpression)propertyInfo.GetValue(ruleInfo);
|
var expr = (ConditionExpression)propertyInfo.GetValue(ruleInfo);
|
||||||
return expr != null ? expr.Variables : Enumerable.Empty<string>();
|
return expr != null ? expr.Variables : Enumerable.Empty<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
[ConsumedConditionReference]
|
[ConsumedConditionReference]
|
||||||
[Desc("Boolean expression defining the condition to enable this trait.")]
|
[Desc("Boolean expression defining the condition to enable this trait.")]
|
||||||
public readonly BooleanExpression RequiresCondition = null;
|
public readonly ConditionExpression RequiresCondition = null;
|
||||||
|
|
||||||
public abstract object Create(ActorInitializer init);
|
public abstract object Create(ActorInitializer init);
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ using OpenRA.Support;
|
|||||||
namespace OpenRA.Test
|
namespace OpenRA.Test
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class BooleanExpressionTest
|
public class ConditionExpressionTest
|
||||||
{
|
{
|
||||||
IReadOnlyDictionary<string, bool> testValues = new ReadOnlyDictionary<string, bool>(new Dictionary<string, bool>()
|
IReadOnlyDictionary<string, bool> testValues = new ReadOnlyDictionary<string, bool>(new Dictionary<string, bool>()
|
||||||
{
|
{
|
||||||
@@ -29,17 +29,17 @@ namespace OpenRA.Test
|
|||||||
|
|
||||||
void AssertFalse(string expression)
|
void AssertFalse(string expression)
|
||||||
{
|
{
|
||||||
Assert.False(new BooleanExpression(expression).Evaluate(testValues), expression);
|
Assert.False(new ConditionExpression(expression).Evaluate(testValues), expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssertTrue(string expression)
|
void AssertTrue(string expression)
|
||||||
{
|
{
|
||||||
Assert.True(new BooleanExpression(expression).Evaluate(testValues), expression);
|
Assert.True(new ConditionExpression(expression).Evaluate(testValues), expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssertParseFailure(string expression)
|
void AssertParseFailure(string expression)
|
||||||
{
|
{
|
||||||
Assert.Throws(typeof(InvalidDataException), () => new BooleanExpression(expression).Evaluate(testValues), expression);
|
Assert.Throws(typeof(InvalidDataException), () => new ConditionExpression(expression).Evaluate(testValues), expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase(TestName = "AND operation")]
|
[TestCase(TestName = "AND operation")]
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
<Compile Include="OpenRA.Mods.Common\ShapeTest.cs" />
|
<Compile Include="OpenRA.Mods.Common\ShapeTest.cs" />
|
||||||
<Compile Include="OpenRA.Game\OrderTest.cs" />
|
<Compile Include="OpenRA.Game\OrderTest.cs" />
|
||||||
<Compile Include="OpenRA.Game\PlatformTest.cs" />
|
<Compile Include="OpenRA.Game\PlatformTest.cs" />
|
||||||
<Compile Include="OpenRA.Game\BooleanExpressionTest.cs" />
|
<Compile Include="OpenRA.Game\ConditionExpressionTest.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
||||||
|
|||||||
Reference in New Issue
Block a user