From 74b085b88d4e44a6d5b175c6ef954acee8e1619d Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sun, 1 Oct 2017 19:03:42 +0200 Subject: [PATCH] Sort imports --- dscanner.ini | 2 +- source/tanya/async/event/epoll.d | 10 ++-- source/tanya/async/event/iocp.d | 8 +-- source/tanya/async/event/selector.d | 2 +- source/tanya/async/protocol.d | 2 +- source/tanya/async/watcher.d | 2 +- source/tanya/container/package.d | 4 +- source/tanya/container/queue.d | 2 +- source/tanya/container/set.d | 2 +- source/tanya/container/string.d | 55 +++++++++--------- source/tanya/math/random.d | 2 +- source/tanya/memory/mmappool.d | 7 ++- source/tanya/memory/package.d | 2 +- source/tanya/meta/metafunction.d | 33 +---------- source/tanya/meta/trait.d | 86 ++++++----------------------- source/tanya/meta/transform.d | 22 -------- source/tanya/network/socket.d | 60 ++++++++++---------- source/tanya/range/primitive.d | 13 +---- 18 files changed, 99 insertions(+), 215 deletions(-) diff --git a/dscanner.ini b/dscanner.ini index 947e482..1f0c36b 100644 --- a/dscanner.ini +++ b/dscanner.ini @@ -74,7 +74,7 @@ lambda_return_check="skip-unittest" ; Check for auto function without return statement auto_function_check="skip-unittest" ; Check for sortedness of imports -imports_sortedness="disabled" +imports_sortedness="skip-unittest" ; Check for explicitly annotated unittests explicitly_annotated_unittests="disabled" ; Check for useless usage of the final attribute diff --git a/source/tanya/async/event/epoll.d b/source/tanya/async/event/epoll.d index 3796cc1..68679f3 100644 --- a/source/tanya/async/event/epoll.d +++ b/source/tanya/async/event/epoll.d @@ -19,20 +19,20 @@ version (D_Ddoc) } else version (linux): +import core.stdc.errno; public import core.sys.linux.epoll; -import tanya.async.protocol; +import core.sys.posix.unistd; +import core.time; +import std.algorithm.comparison; import tanya.async.event.selector; import tanya.async.loop; +import tanya.async.protocol; import tanya.async.transport; import tanya.async.watcher; import tanya.container.array; import tanya.memory; import tanya.memory.mmappool; import tanya.network.socket; -import core.stdc.errno; -import core.sys.posix.unistd; -import core.time; -import std.algorithm.comparison; extern (C) nothrow @nogc { diff --git a/source/tanya/async/event/iocp.d b/source/tanya/async/event/iocp.d index 3544900..be109a8 100644 --- a/source/tanya/async/event/iocp.d +++ b/source/tanya/async/event/iocp.d @@ -19,17 +19,17 @@ version (D_Ddoc) } else version (Windows): -import tanya.container.buffer; +import core.sys.windows.mswsock; +import core.sys.windows.winsock2; import tanya.async.loop; import tanya.async.protocol; import tanya.async.transport; import tanya.async.watcher; +import tanya.container.buffer; import tanya.memory; import tanya.memory.mmappool; import tanya.network.socket; import tanya.sys.windows.winbase; -import core.sys.windows.mswsock; -import core.sys.windows.winsock2; /** * Transport for stream sockets. @@ -386,4 +386,4 @@ final class IOCPLoop : Loop assert(false, "Unknown event"); } } -} \ No newline at end of file +} diff --git a/source/tanya/async/event/selector.d b/source/tanya/async/event/selector.d index f672381..091e163 100644 --- a/source/tanya/async/event/selector.d +++ b/source/tanya/async/event/selector.d @@ -23,8 +23,8 @@ import tanya.async.loop; import tanya.async.protocol; import tanya.async.transport; import tanya.async.watcher; -import tanya.container.buffer; import tanya.container.array; +import tanya.container.buffer; import tanya.memory; import tanya.memory.mmappool; import tanya.network.socket; diff --git a/source/tanya/async/protocol.d b/source/tanya/async/protocol.d index 3cef178..728ef19 100644 --- a/source/tanya/async/protocol.d +++ b/source/tanya/async/protocol.d @@ -18,8 +18,8 @@ */ module tanya.async.protocol; -import tanya.network.socket; import tanya.async.transport; +import tanya.network.socket; /** * Common protocol interface. diff --git a/source/tanya/async/watcher.d b/source/tanya/async/watcher.d index e56235a..b698fff 100644 --- a/source/tanya/async/watcher.d +++ b/source/tanya/async/watcher.d @@ -14,8 +14,8 @@ */ module tanya.async.watcher; -import std.functional; import std.exception; +import std.functional; import tanya.async.loop; import tanya.async.protocol; import tanya.async.transport; diff --git a/source/tanya/container/package.d b/source/tanya/container/package.d index fabbfa9..50dad10 100644 --- a/source/tanya/container/package.d +++ b/source/tanya/container/package.d @@ -16,10 +16,10 @@ module tanya.container; public import tanya.container.array; public import tanya.container.buffer; -public import tanya.container.set; public import tanya.container.list; -public import tanya.container.string; public import tanya.container.queue; +public import tanya.container.set; +public import tanya.container.string; /** * Thrown if $(D_PSYMBOL Set) cannot insert a new element because the container diff --git a/source/tanya/container/queue.d b/source/tanya/container/queue.d index cce68c6..e32fdd4 100644 --- a/source/tanya/container/queue.d +++ b/source/tanya/container/queue.d @@ -201,7 +201,7 @@ struct Queue(T) { int result; - for (size_t i = 0; !empty; ++i) + for (size_t i; !empty; ++i) { auto e = dequeue(); if ((result = dg(i, e)) != 0) diff --git a/source/tanya/container/set.d b/source/tanya/container/set.d index d1bcc75..ad77ee9 100644 --- a/source/tanya/container/set.d +++ b/source/tanya/container/set.d @@ -437,7 +437,7 @@ struct Set(T) InsertStatus status = insertInUnusedBucket(value); for (; !status; status = insertInUnusedBucket(value)) { - if ((this.primes.length - 1) == this.lengthIndex) + if (this.primes.length == (this.lengthIndex + 1)) { throw make!HashContainerFullException(defaultAllocator, "Set is full"); diff --git a/source/tanya/container/string.d b/source/tanya/container/string.d index ff78f51..a89fe0c 100644 --- a/source/tanya/container/string.d +++ b/source/tanya/container/string.d @@ -30,8 +30,7 @@ import core.exception; import std.algorithm.comparison; import std.algorithm.mutation; import std.algorithm.searching; -import std.range : isInfinite, isInputRange, ElementEncodingType, hasLength, - popFrontN, empty; +static import std.range; import tanya.memory; import tanya.meta.trait; import tanya.meta.transform; @@ -353,9 +352,9 @@ struct String * Precondition: $(D_INLINECODE allocator is null). */ this(S)(const S str, shared Allocator allocator = defaultAllocator) - if (!isInfinite!S - && isInputRange!S - && isSomeChar!(ElementEncodingType!S)) + if (!std.range.isInfinite!S + && std.range.isInputRange!S + && isSomeChar!(std.range.ElementEncodingType!S)) { this(allocator); insertBack(str); @@ -668,12 +667,12 @@ struct String * Throws: $(D_PSYMBOL UTFException). */ size_t insertBack(R)(R str) @trusted - if (!isInfinite!R - && isInputRange!R - && is(Unqual!(ElementEncodingType!R) == char)) + if (!std.range.isInfinite!R + && std.range.isInputRange!R + && is(Unqual!(std.range.ElementEncodingType!R) == char)) { size_t size; - static if (hasLength!R || isNarrowString!R) + static if (std.range.hasLength!R || isNarrowString!R) { size = str.length + length; reserve(size); @@ -732,11 +731,11 @@ struct String /// ditto size_t insertBack(R)(R str) @trusted - if (!isInfinite!R - && isInputRange!R - && is(Unqual!(ElementEncodingType!R) == wchar)) + if (!std.range.isInfinite!R + && std.range.isInputRange!R + && is(Unqual!(std.range.ElementEncodingType!R) == wchar)) { - static if (hasLength!R || isNarrowString!R) + static if (std.range.hasLength!R || isNarrowString!R) { reserve(length + str.length * wchar.sizeof); } @@ -771,7 +770,7 @@ struct String } dchar d = (range[0] - 0xd800) | ((range[1] - 0xdc00) >> 10); - range.popFrontN(2); + std.range.popFrontN(range, 2); } else { @@ -798,11 +797,11 @@ struct String /// ditto size_t insertBack(R)(R str) @trusted - if (!isInfinite!R - && isInputRange!R - && is(Unqual!(ElementEncodingType!R) == dchar)) + if (!std.range.isInfinite!R + && std.range.isInputRange!R + && is(Unqual!(std.range.ElementEncodingType!R) == dchar)) { - static if (hasLength!R || isSomeString!R) + static if (std.range.hasLength!R || isSomeString!R) { reserve(length + str.length * 4); } @@ -1269,9 +1268,9 @@ struct String * Throws: $(D_PSYMBOL UTFException). */ ref String opAssign(S)(S that) nothrow - if (!isInfinite!S - && isInputRange!S - && isSomeChar!(ElementEncodingType!S)) + if (!std.range.isInfinite!S + && std.range.isInputRange!S + && isSomeChar!(std.range.ElementEncodingType!S)) { this.length_ = 0; insertBack(that); @@ -1507,7 +1506,7 @@ struct String assert(s.length == 38); auto byCodePoint = s.byCodePoint(); - byCodePoint.popFrontN(8); + std.range.popFrontN(byCodePoint, 8); assert(s.remove(byCodePoint).count == 0); assert(s == "Из слова"); @@ -1532,9 +1531,9 @@ struct String * Precondition: $(D_PARAM r) refers to a region of $(D_KEYWORD this). */ size_t insertAfter(T, R)(R r, T el) @trusted - if ((isSomeChar!T || (!isInfinite!T - && isInputRange!T - && isSomeChar!(ElementEncodingType!T))) + if ((isSomeChar!T || (!std.range.isInfinite!T + && std.range.isInputRange!T + && isSomeChar!(std.range.ElementEncodingType!T))) && (is(R == ByCodeUnit!char) || is(R == ByCodePoint!char))) in { @@ -1565,9 +1564,9 @@ struct String /// size_t insertBefore(T, R)(R r, T el) @trusted - if ((isSomeChar!T || (!isInfinite!T - && isInputRange!T - && isSomeChar!(ElementEncodingType!T))) + if ((isSomeChar!T || (!std.range.isInfinite!T + && std.range.isInputRange!T + && isSomeChar!(std.range.ElementEncodingType!T))) && (is(R == ByCodeUnit!char) || is(R == ByCodePoint!char))) in { diff --git a/source/tanya/math/random.d b/source/tanya/math/random.d index bdb2449..ccf3888 100644 --- a/source/tanya/math/random.d +++ b/source/tanya/math/random.d @@ -300,7 +300,7 @@ class Entropy // Perform second SHA-512 on entropy output = sha512Of(output); - for (ubyte i = 0; i < sourceCount; ++i) + for (ubyte i; i < sourceCount; ++i) { sources[i].size = 0; } diff --git a/source/tanya/memory/mmappool.d b/source/tanya/memory/mmappool.d index 6bfb1fe..73ec0eb 100644 --- a/source/tanya/memory/mmappool.d +++ b/source/tanya/memory/mmappool.d @@ -20,8 +20,11 @@ import tanya.memory.op; version (Posix) { - import core.sys.posix.sys.mman : PROT_READ, PROT_WRITE, MAP_PRIVATE, - MAP_ANON, MAP_FAILED; + import core.sys.posix.sys.mman : MAP_ANON, + MAP_FAILED, + MAP_PRIVATE, + PROT_READ, + PROT_WRITE; import core.sys.posix.unistd; extern(C) diff --git a/source/tanya/memory/package.d b/source/tanya/memory/package.d index 468d937..aebaec8 100644 --- a/source/tanya/memory/package.d +++ b/source/tanya/memory/package.d @@ -20,8 +20,8 @@ import std.algorithm.mutation; import std.conv; public import tanya.memory.allocator; import tanya.memory.mmappool; -import tanya.range.primitive; import tanya.meta.trait; +import tanya.range.primitive; /** * The mixin generates common methods for classes and structs using diff --git a/source/tanya/meta/metafunction.d b/source/tanya/meta/metafunction.d index 0cb2b2f..ccaa89e 100644 --- a/source/tanya/meta/metafunction.d +++ b/source/tanya/meta/metafunction.d @@ -19,6 +19,7 @@ module tanya.meta.metafunction; import tanya.meta.trait; +import tanya.meta.transform; /** * Finds the minimum value in $(D_PARAM Args) according to $(D_PARAM pred). @@ -707,38 +708,6 @@ pure nothrow @safe @nogc unittest static assert(is(Instance2 == float)); } -version (TanyaPhobos) -{ - public import std.meta : Alias, - AliasSeq, - aliasSeqOf, - Erase, - EraseAll, - Filter, - NoDuplicates, - DerivedToFront, - MostDerived, - Repeat, - Replace, - ReplaceAll, - Reverse, - Map = staticMap, - Sort = staticSort, - allSatisfy, - anySatisfy, - staticIndexOf, - templateAnd, - templateNot, - templateOr, - isSorted = staticIsSorted, - ApplyLeft, - ApplyRight; -} -else: - -import tanya.meta.trait; -import tanya.meta.transform; - /** * Creates an alias for $(D_PARAM T). * diff --git a/source/tanya/meta/trait.d b/source/tanya/meta/trait.d index d9cd781..eb48cb5 100644 --- a/source/tanya/meta/trait.d +++ b/source/tanya/meta/trait.d @@ -360,70 +360,6 @@ pure nothrow @safe @nogc unittest static assert(hasStaticMember!(S, "member5")); } -version (TanyaPhobos) -{ - public import std.traits : isFloatingPoint, - isSigned, - isUnsigned, - isIntegral, - isNumeric, - isBoolean, - isSomeChar, - isScalarType, - isBasicType, - isPointer, - isArray, - isStaticArray, - isDynamicArray, - isAssociativeArray, - isBuiltinType, - isAggregateType, - getUDAs, - isNarrowString, - isSomeString, - mostNegative, - Largest, - isCopyable, - isAbstractClass, - isFinalClass, - isAbstractFunction, - isFinalFunction, - isFunctionPointer, - isDelegate, - isFunction, - isSomeFunction, - isCallable, - hasMember, - isMutable, - isNested, - isNestedFunction, - mangledName, - isInstanceOf, - isImplicitlyConvertible, - BaseTypeTuple, - TransitiveBaseTypeTuple, - BaseClassesTuple, - InterfacesTuple, - isAssignable, - TemplateArgsOf, - Parameters, - ParameterIdentifierTuple, - functionAttributes, - ParameterDefaults, - hasElaborateDestructor, - hasElaborateCopyConstructor, - hasElaborateAssign, - EnumMembers, - classInstanceAlignment, - ifTestable, - FunctionTypeOf, - ReturnType, - TemplateOf, - isTypeTuple, - isExpressions; -} -else: - /** * Determines whether $(D_PARAM T) is a floating point type. * @@ -1269,10 +1205,20 @@ pure nothrow @safe @nogc unittest static assert(!isTypeTuple!(int, 8, Object)); static assert(!isTypeTuple!(5, 8, 2)); - class C; - enum E : bool; - union U; - struct T(); + class C + { + } + enum E : bool + { + t, + f, + } + union U + { + } + struct T() + { + } static assert(isTypeTuple!C); static assert(isTypeTuple!E); @@ -2392,7 +2338,7 @@ if (isCallable!F) { static if (is(FunctionTypeOf!F Params == __parameters)) { - enum string[] Impl() + string[] Impl() { string[] tuple; @@ -2463,7 +2409,7 @@ enum FunctionAttribute : uint template functionAttributes(F...) if (isCallable!F) { - enum uint Impl() + uint Impl() { uint attrs = FunctionAttribute.none; foreach (a; __traits(getFunctionAttributes, F[0])) diff --git a/source/tanya/meta/transform.d b/source/tanya/meta/transform.d index b00f4bf..d3f8caf 100644 --- a/source/tanya/meta/transform.d +++ b/source/tanya/meta/transform.d @@ -18,28 +18,6 @@ */ module tanya.meta.transform; -version (TanyaPhobos) -{ - public import std.traits : Unqual, - OriginalType, - CopyConstness, - CopyTypeQualifiers, - Unsigned, - Signed, - PointerTarget, - KeyType, - ValueType, - Promoted, - InoutOf, - ConstOf, - SharedOf, - SharedInoutOf, - SharedConstOf, - ImmutableOf, - QualifierOf; -} -else: - import tanya.meta.trait; /** diff --git a/source/tanya/network/socket.d b/source/tanya/network/socket.d index 114ee83..dfbffb5 100644 --- a/source/tanya/network/socket.d +++ b/source/tanya/network/socket.d @@ -17,7 +17,7 @@ module tanya.network.socket; import core.stdc.errno; import core.time; import std.algorithm.comparison; -public import std.socket : SocketOptionLevel, SocketOption; +public import std.socket : SocketOption, SocketOptionLevel; import std.traits; import std.typecons; import tanya.memory; @@ -44,50 +44,50 @@ version (Posix) } else version (Windows) { - import core.sys.windows.winbase : GetModuleHandle, - GetProcAddress, + import core.sys.windows.winbase : ERROR_IO_INCOMPLETE, ERROR_IO_PENDING, - ERROR_IO_INCOMPLETE; - import core.sys.windows.winsock2 : sockaddr, + GetModuleHandle, + GetProcAddress; + import core.sys.windows.winsock2 : accept, + addrinfo, + bind, + closesocket, + FIONBIO, freeaddrinfo, getaddrinfo, - SD_RECEIVE, - SD_SEND, - SD_BOTH, + getsockopt, + ioctlsocket, + listen, + MSG_DONTROUTE, MSG_OOB, MSG_PEEK, - MSG_DONTROUTE, - socklen_t, + recv, + SD_BOTH, + SD_RECEIVE, + SD_SEND, + send, + setsockopt, + shutdown, SOCKADDR, - SOCKADDR_STORAGE, - addrinfo, + sockaddr, sockaddr_in, sockaddr_in6, - shutdown, - closesocket, - listen, + SOCKADDR_STORAGE, socket, - bind, - accept, - WSAGetLastError, - recv, - send, - getsockopt, - setsockopt, - ioctlsocket, - FIONBIO, + socklen_t, SOL_SOCKET, - SO_TYPE; + SO_TYPE, + WSAGetLastError; import tanya.async.iocp; - import tanya.sys.windows.error : EWOULDBLOCK = WSAEWOULDBLOCK, - ECONNABORTED = WSAECONNABORTED, + import tanya.sys.windows.def; + import tanya.sys.windows.error : ECONNABORTED = WSAECONNABORTED, ENOBUFS = WSAENOBUFS, EOPNOTSUPP = WSAEOPNOTSUPP, EPROTONOSUPPORT = WSAEPROTONOSUPPORT, EPROTOTYPE = WSAEPROTOTYPE, + ESOCKTNOSUPPORT = WSAESOCKTNOSUPPORT, ETIMEDOUT = WSAETIMEDOUT, - ESOCKTNOSUPPORT = WSAESOCKTNOSUPPORT; - import tanya.sys.windows.def; + EWOULDBLOCK = WSAEWOULDBLOCK; public import tanya.sys.windows.winbase; public import tanya.sys.windows.winsock2; @@ -1461,4 +1461,4 @@ private @property int lastError() nothrow @safe @nogc { return errno; } -} \ No newline at end of file +} diff --git a/source/tanya/range/primitive.d b/source/tanya/range/primitive.d index e0f87e5..33efbce 100644 --- a/source/tanya/range/primitive.d +++ b/source/tanya/range/primitive.d @@ -15,6 +15,7 @@ module tanya.range.primitive; import tanya.meta.trait; +import tanya.meta.transform; /** * Returns the element type of the range $(D_PARAM R). @@ -287,18 +288,6 @@ pure nothrow @safe @nogc unittest static assert(hasSlicing!D); } -version (TanyaPhobos) -{ - public import std.range.primitives : isInputRange, - isForwardRange, - isBidirectionalRange, - isRandomAccessRange, - isInfinite; -} -else: - -import tanya.meta.transform; - version (unittest) { mixin template InputRangeStub()