From 1f556fdb70da2dcae3c7bb7c2fea04c582a4473f Mon Sep 17 00:00:00 2001 From: Cameron Ross Date: Wed, 13 Jun 2018 05:17:20 -0300 Subject: [PATCH] clean up aliases --- source/dyaml/constructor.d | 6 ++---- source/dyaml/emitter.d | 2 -- source/dyaml/exception.d | 4 +--- source/dyaml/node.d | 27 +++++++++------------------ source/dyaml/test/common.d | 2 +- source/dyaml/test/inputoutput.d | 3 --- source/dyaml/token.d | 22 +++++++++++----------- 7 files changed, 24 insertions(+), 42 deletions(-) diff --git a/source/dyaml/constructor.d b/source/dyaml/constructor.d index 48131c6..f7ea296 100644 --- a/source/dyaml/constructor.d +++ b/source/dyaml/constructor.d @@ -769,14 +769,12 @@ Node.Pair[] constructOrderedMap(ref Node node) @safe } @safe unittest { - alias Node.Pair Pair; - Node[] alternateTypes(uint length) @safe { Node[] pairs; foreach(long i; 0 .. length) { - auto pair = (i % 2) ? Pair(i.to!string, i) : Pair(i, i.to!string); + auto pair = (i % 2) ? Node.Pair(i.to!string, i) : Node.Pair(i, i.to!string); pairs ~= Node([pair]); } return pairs; @@ -787,7 +785,7 @@ Node.Pair[] constructOrderedMap(ref Node node) @safe Node[] pairs; foreach(long i; 0 .. length) { - auto pair = Pair(i.to!string, i); + auto pair = Node.Pair(i.to!string, i); pairs ~= Node([pair]); } return pairs; diff --git a/source/dyaml/emitter.d b/source/dyaml/emitter.d index 4e9eda7..10e739d 100644 --- a/source/dyaml/emitter.d +++ b/source/dyaml/emitter.d @@ -72,8 +72,6 @@ private alias isSpace = among!('\0', '\n', '\r', '\u0085', '\u2028', '\u2029', ' struct Emitter { private: - alias dyaml.tagdirective.TagDirective TagDirective; - ///Default tag handle shortcuts and replacements. static TagDirective[] defaultTagDirectives_ = [TagDirective("!", "!"), TagDirective("!!", "tag:yaml.org,2002:")]; diff --git a/source/dyaml/exception.d b/source/dyaml/exception.d index d7710e9..f214726 100644 --- a/source/dyaml/exception.d +++ b/source/dyaml/exception.d @@ -13,8 +13,6 @@ import std.array; import std.string; import std.conv; -alias to!string str; - /// Base class for all exceptions thrown by D:YAML. class YAMLException : Exception @@ -53,7 +51,7 @@ struct Mark // Line/column numbers start at zero internally, make them start at 1. static string clamped(ushort v) @safe pure nothrow { - return str(v + 1) ~ (v == ushort.max ? " or higher" : ""); + return text(v + 1, v == ushort.max ? " or higher" : ""); } return "line " ~ clamped(line_) ~ ",column " ~ clamped(column_); } diff --git a/source/dyaml/node.d b/source/dyaml/node.d index 565cdb6..191afb5 100644 --- a/source/dyaml/node.d +++ b/source/dyaml/node.d @@ -165,8 +165,8 @@ struct Node package: // YAML value type. - alias Algebraic!(YAMLNull, YAMLMerge, bool, long, real, ubyte[], SysTime, string, - Node.Pair[], Node[], YAMLObject) Value; + alias Value = Algebraic!(YAMLNull, YAMLMerge, bool, long, real, ubyte[], SysTime, string, + Node.Pair[], Node[], YAMLObject); // Can Value hold this type without wrapping it in a YAMLObject? enum allowed(T) = isIntegral!T || @@ -522,7 +522,7 @@ struct Node } /// Shortcut for get(). - alias get as; + alias as = get; /** Get the value of the node as specified type. * @@ -722,9 +722,6 @@ struct Node /// @safe unittest { - alias Node.Value Value; - alias Node.Pair Pair; - Node narray = Node([11, 12, 13, 14]); Node nmap = Node(["11", "12", "13", "14"], [11, 12, 13, 14]); @@ -735,9 +732,6 @@ struct Node } @safe unittest { - alias Node.Value Value; - alias Node.Pair Pair; - Node narray = Node([11, 12, 13, 14]); Node nmap = Node(["11", "12", "13", "14"], [11, 12, 13, 14]); @@ -1432,9 +1426,6 @@ struct Node } @safe unittest { - alias Node.Value Value; - alias Node.Pair Pair; - Node n1 = Node(cast(long)11); Node n2 = Node(cast(long)12); Node n3 = Node(cast(long)13); @@ -1954,22 +1945,22 @@ struct Node } // Is the value a bool? - alias isType!bool isBool; + alias isBool = isType!bool; // Is the value a raw binary buffer? - alias isType!(ubyte[]) isBinary; + alias isBinary = isType!(ubyte[]); // Is the value an integer? - alias isType!long isInt; + alias isInt = isType!long; // Is the value a floating point number? - alias isType!real isFloat; + alias isFloat = isType!real; // Is the value a string? - alias isType!string isString; + alias isString = isType!string; // Is the value a timestamp? - alias isType!SysTime isTime; + alias isTime = isType!SysTime; // Does given node have the same type as this node? bool hasEqualType(const ref Node node) const @safe diff --git a/source/dyaml/test/common.d b/source/dyaml/test/common.d index ca17b33..486fc46 100644 --- a/source/dyaml/test/common.d +++ b/source/dyaml/test/common.d @@ -104,7 +104,7 @@ enum TestStatus } ///Unittest result. -alias Tuple!(string, "name", string[], "filenames", TestStatus, "kind", string, "info") Result; +alias Result = Tuple!(string, "name", string[], "filenames", TestStatus, "kind", string, "info"); /** * Find unittest input filenames. diff --git a/source/dyaml/test/inputoutput.d b/source/dyaml/test/inputoutput.d index c4b3a8c..4853008 100644 --- a/source/dyaml/test/inputoutput.d +++ b/source/dyaml/test/inputoutput.d @@ -17,9 +17,6 @@ import std.system; import dyaml.test.common; import dyaml.stream; - -alias std.system.endian endian; - /// Get an UTF-16 byte order mark. /// /// Params: wrong = Get the incorrect BOM for this system. diff --git a/source/dyaml/token.d b/source/dyaml/token.d index 03654af..656b02b 100644 --- a/source/dyaml/token.d +++ b/source/dyaml/token.d @@ -132,14 +132,14 @@ Token streamStartToken(const Mark start, const Mark end, const Encoding encoding } /// Aliases for construction of simple token types. -alias simpleToken!(TokenID.StreamEnd) streamEndToken; -alias simpleToken!(TokenID.BlockSequenceStart) blockSequenceStartToken; -alias simpleToken!(TokenID.BlockMappingStart) blockMappingStartToken; -alias simpleToken!(TokenID.BlockEnd) blockEndToken; -alias simpleToken!(TokenID.Key) keyToken; -alias simpleToken!(TokenID.Value) valueToken; -alias simpleToken!(TokenID.BlockEntry) blockEntryToken; -alias simpleToken!(TokenID.FlowEntry) flowEntryToken; +alias streamEndToken = simpleToken!(TokenID.StreamEnd); +alias blockSequenceStartToken = simpleToken!(TokenID.BlockSequenceStart); +alias blockMappingStartToken = simpleToken!(TokenID.BlockMappingStart); +alias blockEndToken = simpleToken!(TokenID.BlockEnd); +alias keyToken = simpleToken!(TokenID.Key); +alias valueToken = simpleToken!(TokenID.Value); +alias blockEntryToken = simpleToken!(TokenID.BlockEntry); +alias flowEntryToken = simpleToken!(TokenID.FlowEntry); /// Construct a simple token with value with specified type. /// @@ -157,9 +157,9 @@ Token simpleValueToken(TokenID id)(const Mark start, const Mark end, char[] valu } /// Alias for construction of tag token. -alias simpleValueToken!(TokenID.Tag) tagToken; -alias simpleValueToken!(TokenID.Alias) aliasToken; -alias simpleValueToken!(TokenID.Anchor) anchorToken; +alias tagToken = simpleValueToken!(TokenID.Tag); +alias aliasToken = simpleValueToken!(TokenID.Alias); +alias anchorToken = simpleValueToken!(TokenID.Anchor); /// Construct a scalar token. ///