Sort imports

This commit is contained in:
Eugen Wissner 2017-10-01 19:03:42 +02:00
parent a576c36d02
commit 74b085b88d
18 changed files with 99 additions and 215 deletions

View File

@ -74,7 +74,7 @@ lambda_return_check="skip-unittest"
; Check for auto function without return statement ; Check for auto function without return statement
auto_function_check="skip-unittest" auto_function_check="skip-unittest"
; Check for sortedness of imports ; Check for sortedness of imports
imports_sortedness="disabled" imports_sortedness="skip-unittest"
; Check for explicitly annotated unittests ; Check for explicitly annotated unittests
explicitly_annotated_unittests="disabled" explicitly_annotated_unittests="disabled"
; Check for useless usage of the final attribute ; Check for useless usage of the final attribute

View File

@ -19,20 +19,20 @@ version (D_Ddoc)
} }
else version (linux): else version (linux):
import core.stdc.errno;
public import core.sys.linux.epoll; 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.event.selector;
import tanya.async.loop; import tanya.async.loop;
import tanya.async.protocol;
import tanya.async.transport; import tanya.async.transport;
import tanya.async.watcher; import tanya.async.watcher;
import tanya.container.array; import tanya.container.array;
import tanya.memory; import tanya.memory;
import tanya.memory.mmappool; import tanya.memory.mmappool;
import tanya.network.socket; import tanya.network.socket;
import core.stdc.errno;
import core.sys.posix.unistd;
import core.time;
import std.algorithm.comparison;
extern (C) nothrow @nogc extern (C) nothrow @nogc
{ {

View File

@ -19,17 +19,17 @@ version (D_Ddoc)
} }
else version (Windows): else version (Windows):
import tanya.container.buffer; import core.sys.windows.mswsock;
import core.sys.windows.winsock2;
import tanya.async.loop; import tanya.async.loop;
import tanya.async.protocol; import tanya.async.protocol;
import tanya.async.transport; import tanya.async.transport;
import tanya.async.watcher; import tanya.async.watcher;
import tanya.container.buffer;
import tanya.memory; import tanya.memory;
import tanya.memory.mmappool; import tanya.memory.mmappool;
import tanya.network.socket; import tanya.network.socket;
import tanya.sys.windows.winbase; import tanya.sys.windows.winbase;
import core.sys.windows.mswsock;
import core.sys.windows.winsock2;
/** /**
* Transport for stream sockets. * Transport for stream sockets.

View File

@ -23,8 +23,8 @@ import tanya.async.loop;
import tanya.async.protocol; import tanya.async.protocol;
import tanya.async.transport; import tanya.async.transport;
import tanya.async.watcher; import tanya.async.watcher;
import tanya.container.buffer;
import tanya.container.array; import tanya.container.array;
import tanya.container.buffer;
import tanya.memory; import tanya.memory;
import tanya.memory.mmappool; import tanya.memory.mmappool;
import tanya.network.socket; import tanya.network.socket;

View File

@ -18,8 +18,8 @@
*/ */
module tanya.async.protocol; module tanya.async.protocol;
import tanya.network.socket;
import tanya.async.transport; import tanya.async.transport;
import tanya.network.socket;
/** /**
* Common protocol interface. * Common protocol interface.

View File

@ -14,8 +14,8 @@
*/ */
module tanya.async.watcher; module tanya.async.watcher;
import std.functional;
import std.exception; import std.exception;
import std.functional;
import tanya.async.loop; import tanya.async.loop;
import tanya.async.protocol; import tanya.async.protocol;
import tanya.async.transport; import tanya.async.transport;

View File

@ -16,10 +16,10 @@ module tanya.container;
public import tanya.container.array; public import tanya.container.array;
public import tanya.container.buffer; public import tanya.container.buffer;
public import tanya.container.set;
public import tanya.container.list; public import tanya.container.list;
public import tanya.container.string;
public import tanya.container.queue; 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 * Thrown if $(D_PSYMBOL Set) cannot insert a new element because the container

View File

@ -201,7 +201,7 @@ struct Queue(T)
{ {
int result; int result;
for (size_t i = 0; !empty; ++i) for (size_t i; !empty; ++i)
{ {
auto e = dequeue(); auto e = dequeue();
if ((result = dg(i, e)) != 0) if ((result = dg(i, e)) != 0)

View File

@ -437,7 +437,7 @@ struct Set(T)
InsertStatus status = insertInUnusedBucket(value); InsertStatus status = insertInUnusedBucket(value);
for (; !status; 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, throw make!HashContainerFullException(defaultAllocator,
"Set is full"); "Set is full");

View File

@ -30,8 +30,7 @@ import core.exception;
import std.algorithm.comparison; import std.algorithm.comparison;
import std.algorithm.mutation; import std.algorithm.mutation;
import std.algorithm.searching; import std.algorithm.searching;
import std.range : isInfinite, isInputRange, ElementEncodingType, hasLength, static import std.range;
popFrontN, empty;
import tanya.memory; import tanya.memory;
import tanya.meta.trait; import tanya.meta.trait;
import tanya.meta.transform; import tanya.meta.transform;
@ -353,9 +352,9 @@ struct String
* Precondition: $(D_INLINECODE allocator is null). * Precondition: $(D_INLINECODE allocator is null).
*/ */
this(S)(const S str, shared Allocator allocator = defaultAllocator) this(S)(const S str, shared Allocator allocator = defaultAllocator)
if (!isInfinite!S if (!std.range.isInfinite!S
&& isInputRange!S && std.range.isInputRange!S
&& isSomeChar!(ElementEncodingType!S)) && isSomeChar!(std.range.ElementEncodingType!S))
{ {
this(allocator); this(allocator);
insertBack(str); insertBack(str);
@ -668,12 +667,12 @@ struct String
* Throws: $(D_PSYMBOL UTFException). * Throws: $(D_PSYMBOL UTFException).
*/ */
size_t insertBack(R)(R str) @trusted size_t insertBack(R)(R str) @trusted
if (!isInfinite!R if (!std.range.isInfinite!R
&& isInputRange!R && std.range.isInputRange!R
&& is(Unqual!(ElementEncodingType!R) == char)) && is(Unqual!(std.range.ElementEncodingType!R) == char))
{ {
size_t size; size_t size;
static if (hasLength!R || isNarrowString!R) static if (std.range.hasLength!R || isNarrowString!R)
{ {
size = str.length + length; size = str.length + length;
reserve(size); reserve(size);
@ -732,11 +731,11 @@ struct String
/// ditto /// ditto
size_t insertBack(R)(R str) @trusted size_t insertBack(R)(R str) @trusted
if (!isInfinite!R if (!std.range.isInfinite!R
&& isInputRange!R && std.range.isInputRange!R
&& is(Unqual!(ElementEncodingType!R) == wchar)) && 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); reserve(length + str.length * wchar.sizeof);
} }
@ -771,7 +770,7 @@ struct String
} }
dchar d = (range[0] - 0xd800) | ((range[1] - 0xdc00) >> 10); dchar d = (range[0] - 0xd800) | ((range[1] - 0xdc00) >> 10);
range.popFrontN(2); std.range.popFrontN(range, 2);
} }
else else
{ {
@ -798,11 +797,11 @@ struct String
/// ditto /// ditto
size_t insertBack(R)(R str) @trusted size_t insertBack(R)(R str) @trusted
if (!isInfinite!R if (!std.range.isInfinite!R
&& isInputRange!R && std.range.isInputRange!R
&& is(Unqual!(ElementEncodingType!R) == dchar)) && 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); reserve(length + str.length * 4);
} }
@ -1269,9 +1268,9 @@ struct String
* Throws: $(D_PSYMBOL UTFException). * Throws: $(D_PSYMBOL UTFException).
*/ */
ref String opAssign(S)(S that) nothrow ref String opAssign(S)(S that) nothrow
if (!isInfinite!S if (!std.range.isInfinite!S
&& isInputRange!S && std.range.isInputRange!S
&& isSomeChar!(ElementEncodingType!S)) && isSomeChar!(std.range.ElementEncodingType!S))
{ {
this.length_ = 0; this.length_ = 0;
insertBack(that); insertBack(that);
@ -1507,7 +1506,7 @@ struct String
assert(s.length == 38); assert(s.length == 38);
auto byCodePoint = s.byCodePoint(); auto byCodePoint = s.byCodePoint();
byCodePoint.popFrontN(8); std.range.popFrontN(byCodePoint, 8);
assert(s.remove(byCodePoint).count == 0); assert(s.remove(byCodePoint).count == 0);
assert(s == "Из слова"); assert(s == "Из слова");
@ -1532,9 +1531,9 @@ struct String
* Precondition: $(D_PARAM r) refers to a region of $(D_KEYWORD this). * Precondition: $(D_PARAM r) refers to a region of $(D_KEYWORD this).
*/ */
size_t insertAfter(T, R)(R r, T el) @trusted size_t insertAfter(T, R)(R r, T el) @trusted
if ((isSomeChar!T || (!isInfinite!T if ((isSomeChar!T || (!std.range.isInfinite!T
&& isInputRange!T && std.range.isInputRange!T
&& isSomeChar!(ElementEncodingType!T))) && isSomeChar!(std.range.ElementEncodingType!T)))
&& (is(R == ByCodeUnit!char) || is(R == ByCodePoint!char))) && (is(R == ByCodeUnit!char) || is(R == ByCodePoint!char)))
in in
{ {
@ -1565,9 +1564,9 @@ struct String
/// ///
size_t insertBefore(T, R)(R r, T el) @trusted size_t insertBefore(T, R)(R r, T el) @trusted
if ((isSomeChar!T || (!isInfinite!T if ((isSomeChar!T || (!std.range.isInfinite!T
&& isInputRange!T && std.range.isInputRange!T
&& isSomeChar!(ElementEncodingType!T))) && isSomeChar!(std.range.ElementEncodingType!T)))
&& (is(R == ByCodeUnit!char) || is(R == ByCodePoint!char))) && (is(R == ByCodeUnit!char) || is(R == ByCodePoint!char)))
in in
{ {

View File

@ -300,7 +300,7 @@ class Entropy
// Perform second SHA-512 on entropy // Perform second SHA-512 on entropy
output = sha512Of(output); output = sha512Of(output);
for (ubyte i = 0; i < sourceCount; ++i) for (ubyte i; i < sourceCount; ++i)
{ {
sources[i].size = 0; sources[i].size = 0;
} }

View File

@ -20,8 +20,11 @@ import tanya.memory.op;
version (Posix) version (Posix)
{ {
import core.sys.posix.sys.mman : PROT_READ, PROT_WRITE, MAP_PRIVATE, import core.sys.posix.sys.mman : MAP_ANON,
MAP_ANON, MAP_FAILED; MAP_FAILED,
MAP_PRIVATE,
PROT_READ,
PROT_WRITE;
import core.sys.posix.unistd; import core.sys.posix.unistd;
extern(C) extern(C)

View File

@ -20,8 +20,8 @@ import std.algorithm.mutation;
import std.conv; import std.conv;
public import tanya.memory.allocator; public import tanya.memory.allocator;
import tanya.memory.mmappool; import tanya.memory.mmappool;
import tanya.range.primitive;
import tanya.meta.trait; import tanya.meta.trait;
import tanya.range.primitive;
/** /**
* The mixin generates common methods for classes and structs using * The mixin generates common methods for classes and structs using

View File

@ -19,6 +19,7 @@
module tanya.meta.metafunction; module tanya.meta.metafunction;
import tanya.meta.trait; import tanya.meta.trait;
import tanya.meta.transform;
/** /**
* Finds the minimum value in $(D_PARAM Args) according to $(D_PARAM pred). * 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)); 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). * Creates an alias for $(D_PARAM T).
* *

View File

@ -360,70 +360,6 @@ pure nothrow @safe @nogc unittest
static assert(hasStaticMember!(S, "member5")); 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. * 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!(int, 8, Object));
static assert(!isTypeTuple!(5, 8, 2)); static assert(!isTypeTuple!(5, 8, 2));
class C; class C
enum E : bool; {
union U; }
struct T(); enum E : bool
{
t,
f,
}
union U
{
}
struct T()
{
}
static assert(isTypeTuple!C); static assert(isTypeTuple!C);
static assert(isTypeTuple!E); static assert(isTypeTuple!E);
@ -2392,7 +2338,7 @@ if (isCallable!F)
{ {
static if (is(FunctionTypeOf!F Params == __parameters)) static if (is(FunctionTypeOf!F Params == __parameters))
{ {
enum string[] Impl() string[] Impl()
{ {
string[] tuple; string[] tuple;
@ -2463,7 +2409,7 @@ enum FunctionAttribute : uint
template functionAttributes(F...) template functionAttributes(F...)
if (isCallable!F) if (isCallable!F)
{ {
enum uint Impl() uint Impl()
{ {
uint attrs = FunctionAttribute.none; uint attrs = FunctionAttribute.none;
foreach (a; __traits(getFunctionAttributes, F[0])) foreach (a; __traits(getFunctionAttributes, F[0]))

View File

@ -18,28 +18,6 @@
*/ */
module tanya.meta.transform; 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; import tanya.meta.trait;
/** /**

View File

@ -17,7 +17,7 @@ module tanya.network.socket;
import core.stdc.errno; import core.stdc.errno;
import core.time; import core.time;
import std.algorithm.comparison; import std.algorithm.comparison;
public import std.socket : SocketOptionLevel, SocketOption; public import std.socket : SocketOption, SocketOptionLevel;
import std.traits; import std.traits;
import std.typecons; import std.typecons;
import tanya.memory; import tanya.memory;
@ -44,50 +44,50 @@ version (Posix)
} }
else version (Windows) else version (Windows)
{ {
import core.sys.windows.winbase : GetModuleHandle, import core.sys.windows.winbase : ERROR_IO_INCOMPLETE,
GetProcAddress,
ERROR_IO_PENDING, ERROR_IO_PENDING,
ERROR_IO_INCOMPLETE; GetModuleHandle,
import core.sys.windows.winsock2 : sockaddr, GetProcAddress;
import core.sys.windows.winsock2 : accept,
addrinfo,
bind,
closesocket,
FIONBIO,
freeaddrinfo, freeaddrinfo,
getaddrinfo, getaddrinfo,
SD_RECEIVE, getsockopt,
SD_SEND, ioctlsocket,
SD_BOTH, listen,
MSG_DONTROUTE,
MSG_OOB, MSG_OOB,
MSG_PEEK, MSG_PEEK,
MSG_DONTROUTE, recv,
socklen_t, SD_BOTH,
SD_RECEIVE,
SD_SEND,
send,
setsockopt,
shutdown,
SOCKADDR, SOCKADDR,
SOCKADDR_STORAGE, sockaddr,
addrinfo,
sockaddr_in, sockaddr_in,
sockaddr_in6, sockaddr_in6,
shutdown, SOCKADDR_STORAGE,
closesocket,
listen,
socket, socket,
bind, socklen_t,
accept,
WSAGetLastError,
recv,
send,
getsockopt,
setsockopt,
ioctlsocket,
FIONBIO,
SOL_SOCKET, SOL_SOCKET,
SO_TYPE; SO_TYPE,
WSAGetLastError;
import tanya.async.iocp; import tanya.async.iocp;
import tanya.sys.windows.error : EWOULDBLOCK = WSAEWOULDBLOCK, import tanya.sys.windows.def;
ECONNABORTED = WSAECONNABORTED, import tanya.sys.windows.error : ECONNABORTED = WSAECONNABORTED,
ENOBUFS = WSAENOBUFS, ENOBUFS = WSAENOBUFS,
EOPNOTSUPP = WSAEOPNOTSUPP, EOPNOTSUPP = WSAEOPNOTSUPP,
EPROTONOSUPPORT = WSAEPROTONOSUPPORT, EPROTONOSUPPORT = WSAEPROTONOSUPPORT,
EPROTOTYPE = WSAEPROTOTYPE, EPROTOTYPE = WSAEPROTOTYPE,
ESOCKTNOSUPPORT = WSAESOCKTNOSUPPORT,
ETIMEDOUT = WSAETIMEDOUT, ETIMEDOUT = WSAETIMEDOUT,
ESOCKTNOSUPPORT = WSAESOCKTNOSUPPORT; EWOULDBLOCK = WSAEWOULDBLOCK;
import tanya.sys.windows.def;
public import tanya.sys.windows.winbase; public import tanya.sys.windows.winbase;
public import tanya.sys.windows.winsock2; public import tanya.sys.windows.winsock2;

View File

@ -15,6 +15,7 @@
module tanya.range.primitive; module tanya.range.primitive;
import tanya.meta.trait; import tanya.meta.trait;
import tanya.meta.transform;
/** /**
* Returns the element type of the range $(D_PARAM R). * Returns the element type of the range $(D_PARAM R).
@ -287,18 +288,6 @@ pure nothrow @safe @nogc unittest
static assert(hasSlicing!D); static assert(hasSlicing!D);
} }
version (TanyaPhobos)
{
public import std.range.primitives : isInputRange,
isForwardRange,
isBidirectionalRange,
isRandomAccessRange,
isInfinite;
}
else:
import tanya.meta.transform;
version (unittest) version (unittest)
{ {
mixin template InputRangeStub() mixin template InputRangeStub()