Rename MiniYaml MergeLiberal -> MergePartial, MergeStrict -> Merge.

This commit is contained in:
Paul Chote
2015-05-10 15:45:33 +01:00
committed by Oliver Brakmann
parent abed25d293
commit a074bb1d4b
14 changed files with 21 additions and 21 deletions

View File

@@ -98,7 +98,7 @@ namespace OpenRA
throw new YamlException( throw new YamlException(
"Bogus inheritance -- duplicate inheritance of {0}.".F(kv.Key)); "Bogus inheritance -- duplicate inheritance of {0}.".F(kv.Key));
node = MiniYaml.MergeStrict(node, MergeWithParents(kv.Value, allUnits, allParents)); node = MiniYaml.Merge(node, MergeWithParents(kv.Value, allUnits, allParents));
} }
return node; return node;

View File

@@ -101,7 +101,7 @@ namespace OpenRA
var mergedNodes = files var mergedNodes = files
.Select(s => MiniYaml.FromFile(s)) .Select(s => MiniYaml.FromFile(s))
.Aggregate(nodes, MiniYaml.MergeLiberal); .Aggregate(nodes, MiniYaml.MergePartial);
Func<MiniYamlNode, Dictionary<string, MiniYaml>, T> wrap = (wkv, wyy) => Func<MiniYamlNode, Dictionary<string, MiniYaml>, T> wrap = (wkv, wyy) =>
{ {

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Graphics
cachedSheets = new Dictionary<string, Sheet>(); cachedSheets = new Dictionary<string, Sheet>();
cachedSprites = new Dictionary<string, Dictionary<string, Sprite>>(); cachedSprites = new Dictionary<string, Dictionary<string, Sprite>>();
var chrome = chromeFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal); var chrome = chromeFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergePartial);
foreach (var c in chrome) foreach (var c in chrome)
LoadCollection(c.Key, c.Value); LoadCollection(c.Key, c.Value);

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Graphics
public CursorProvider(ModData modData) public CursorProvider(ModData modData)
{ {
var sequenceFiles = modData.Manifest.Cursors; var sequenceFiles = modData.Manifest.Cursors;
var sequences = new MiniYaml(null, sequenceFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal)); var sequences = new MiniYaml(null, sequenceFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergePartial));
var shadowIndex = new int[] { }; var shadowIndex = new int[] { };
var nodesDict = sequences.ToDictionary(); var nodesDict = sequences.ToDictionary();

View File

@@ -129,7 +129,7 @@ namespace OpenRA.Graphics
var nodes = sequenceFiles var nodes = sequenceFiles
.Select(s => MiniYaml.FromFile(s)) .Select(s => MiniYaml.FromFile(s))
.Aggregate(sequenceNodes, MiniYaml.MergeLiberal); .Aggregate(sequenceNodes, MiniYaml.MergePartial);
var items = new Dictionary<string, UnitSequences>(); var items = new Dictionary<string, UnitSequences>();
foreach (var n in nodes) foreach (var n in nodes)

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Graphics
var sequences = voxelFiles var sequences = voxelFiles
.Select(s => MiniYaml.FromFile(s)) .Select(s => MiniYaml.FromFile(s))
.Aggregate(voxelNodes, MiniYaml.MergeLiberal); .Aggregate(voxelNodes, MiniYaml.MergePartial);
foreach (var s in sequences) foreach (var s in sequences)
LoadVoxelsForUnit(s.Key, s.Value); LoadVoxelsForUnit(s.Key, s.Value);

View File

@@ -262,12 +262,12 @@ namespace OpenRA
return FromLines(text.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries), fileName); return FromLines(text.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries), fileName);
} }
public static List<MiniYamlNode> MergeStrict(List<MiniYamlNode> a, List<MiniYamlNode> b) public static List<MiniYamlNode> Merge(List<MiniYamlNode> a, List<MiniYamlNode> b)
{ {
return Merge(a, b, false); return Merge(a, b, false);
} }
public static List<MiniYamlNode> MergeLiberal(List<MiniYamlNode> a, List<MiniYamlNode> b) public static List<MiniYamlNode> MergePartial(List<MiniYamlNode> a, List<MiniYamlNode> b)
{ {
return Merge(a, b, true); return Merge(a, b, true);
} }
@@ -327,12 +327,12 @@ namespace OpenRA
return ret; return ret;
} }
public static MiniYaml MergeLiberal(MiniYaml a, MiniYaml b) public static MiniYaml MergePartial(MiniYaml a, MiniYaml b)
{ {
return Merge(a, b, true); return Merge(a, b, true);
} }
public static MiniYaml MergeStrict(MiniYaml a, MiniYaml b) public static MiniYaml Merge(MiniYaml a, MiniYaml b)
{ {
return Merge(a, b, false); return Merge(a, b, false);
} }

View File

@@ -119,10 +119,10 @@ namespace OpenRA
return; return;
} }
var yaml = Manifest.Translations.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergeLiberal); var yaml = Manifest.Translations.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergePartial);
Languages = yaml.Select(t => t.Key).ToArray(); Languages = yaml.Select(t => t.Key).ToArray();
yaml = MiniYaml.MergeLiberal(map.TranslationDefinitions, yaml); yaml = MiniYaml.MergePartial(map.TranslationDefinitions, yaml);
foreach (var y in yaml) foreach (var y in yaml)
{ {

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Widgets
{ {
data = new Dictionary<string, string>(); data = new Dictionary<string, string>();
var metrics = yaml.Select(y => MiniYaml.FromFile(y)) var metrics = yaml.Select(y => MiniYaml.FromFile(y))
.Aggregate(MiniYaml.MergeLiberal); .Aggregate(MiniYaml.MergePartial);
foreach (var m in metrics) foreach (var m in metrics)
foreach (var n in m.Value.Nodes) foreach (var n in m.Value.Nodes)

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Graphics
if (nodes.TryGetValue("Defaults", out defaults)) if (nodes.TryGetValue("Defaults", out defaults))
{ {
nodes.Remove("Defaults"); nodes.Remove("Defaults");
nodes = nodes.ToDictionary(kv => kv.Key, kv => MiniYaml.MergeStrict(kv.Value, defaults)); nodes = nodes.ToDictionary(kv => kv.Key, kv => MiniYaml.Merge(kv.Value, defaults));
// Merge 'Defaults' animation image value. An example follows. // Merge 'Defaults' animation image value. An example follows.
// //

View File

@@ -32,8 +32,8 @@ namespace OpenRA.Mods.Common.Lint
this.emitError = emitError; this.emitError = emitError;
var sequenceSource = map != null ? map.SequenceDefinitions : new List<MiniYamlNode>(); var sequenceSource = map != null ? map.SequenceDefinitions : new List<MiniYamlNode>();
sequenceDefinitions = MiniYaml.MergeLiberal(sequenceSource, sequenceDefinitions = MiniYaml.MergePartial(sequenceSource,
Game.ModData.Manifest.Sequences.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergeLiberal)); Game.ModData.Manifest.Sequences.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergePartial));
var rules = map == null ? Game.ModData.DefaultRules : map.Rules; var rules = map == null ? Game.ModData.DefaultRules : map.Rules;
var factions = rules.Actors["world"].TraitInfos<FactionInfo>().Select(f => f.InternalName).ToArray(); var factions = rules.Actors["world"].TraitInfos<FactionInfo>().Select(f => f.InternalName).ToArray();

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
var nodes = sequenceFiles var nodes = sequenceFiles
.Select(s => MiniYaml.FromFile(s)) .Select(s => MiniYaml.FromFile(s))
.Aggregate(MiniYaml.MergeLiberal); .Aggregate(MiniYaml.MergePartial);
foreach (var n in nodes) foreach (var n in nodes)
Game.ModData.SpriteSequenceLoader.ParseSequences(Game.ModData, ts, sc, n); Game.ModData.SpriteSequenceLoader.ParseSequences(Game.ModData, ts, sc, n);

View File

@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
// Add a group for each campaign // Add a group for each campaign
if (Game.ModData.Manifest.Missions.Any()) if (Game.ModData.Manifest.Missions.Any())
{ {
var yaml = Game.ModData.Manifest.Missions.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergeLiberal); var yaml = Game.ModData.Manifest.Missions.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergePartial);
foreach (var kv in yaml) foreach (var kv in yaml)
{ {

View File

@@ -73,9 +73,9 @@ Root2:
// Merge order should not matter // Merge order should not matter
// Note: All the Merge* variants are different plumbing over the same // Note: All the Merge* variants are different plumbing over the same
// internal logic. Testing only MergeStrict is sufficient. // Internal logic. Testing only Merge is sufficient.
TestMixedMerge(MiniYaml.MergeStrict(a, b).First().Value); TestMixedMerge(MiniYaml.Merge(a, b).First().Value);
TestMixedMerge(MiniYaml.MergeStrict(b, a).First().Value); TestMixedMerge(MiniYaml.Merge(b, a).First().Value);
} }
void TestMixedMerge(MiniYaml result) void TestMixedMerge(MiniYaml result)