Add DIP25 compatibility. Fix #83

This commit is contained in:
Eugen Wissner 2019-03-23 06:41:51 +01:00
parent ad46afb10b
commit 76f2cd7080
11 changed files with 24 additions and 82 deletions

View File

@ -8,7 +8,7 @@ language: d
d: d:
- dmd-2.085.0 - dmd-2.085.0
- dmd-2.082.1 - dmd-2.081.2
env: env:
global: global:

View File

@ -10,10 +10,10 @@ environment:
DVersion: 2.085.0 DVersion: 2.085.0
arch: x86 arch: x86
- DC: dmd - DC: dmd
DVersion: 2.082.1 DVersion: 2.081.2
arch: x64 arch: x64
- DC: dmd - DC: dmd
DVersion: 2.082.1 DVersion: 2.081.2
arch: x86 arch: x86
skip_tags: true skip_tags: true

View File

@ -53,6 +53,7 @@
{ {
"name": "unittest", "name": "unittest",
"versions": ["TanyaPhobos"], "versions": ["TanyaPhobos"],
"dflags": ["-dip25"],
"importPaths": [ "importPaths": [
"./source", "./source",
"./tests" "./tests"

View File

@ -67,11 +67,7 @@ final class StreamTransport : SocketWatcher, DuplexTransport, SocketTransport
* Postcondition: $(D_INLINECODE socket !is null) * Postcondition: $(D_INLINECODE socket !is null)
*/ */
override @property OverlappedConnectedSocket socket() pure nothrow @safe @nogc override @property OverlappedConnectedSocket socket() pure nothrow @safe @nogc
out (socket) out (socket; socket !is null)
{
assert(socket !is null);
}
do
{ {
return cast(OverlappedConnectedSocket) socket_; return cast(OverlappedConnectedSocket) socket_;
} }
@ -124,11 +120,7 @@ final class StreamTransport : SocketWatcher, DuplexTransport, SocketTransport
* Precondition: $(D_INLINECODE protocol !is null) * Precondition: $(D_INLINECODE protocol !is null)
*/ */
@property void protocol(Protocol protocol) pure nothrow @safe @nogc @property void protocol(Protocol protocol) pure nothrow @safe @nogc
in in (protocol !is null)
{
assert(protocol !is null);
}
do
{ {
protocol_ = protocol; protocol_ = protocol;
} }
@ -264,11 +256,7 @@ final class IOCPLoop : Loop
private void kill(StreamTransport transport, private void kill(StreamTransport transport,
SocketException exception = null) @nogc SocketException exception = null) @nogc
in in (transport !is null)
{
assert(transport !is null);
}
do
{ {
transport.socket.shutdown(); transport.socket.shutdown();
defaultAllocator.dispose(transport.socket); defaultAllocator.dispose(transport.socket);

View File

@ -75,22 +75,14 @@ package class StreamTransport : SocketWatcher, DuplexTransport, SocketTransport
* Postcondition: $(D_INLINECODE socket !is null) * Postcondition: $(D_INLINECODE socket !is null)
*/ */
override @property ConnectedSocket socket() pure nothrow @safe @nogc override @property ConnectedSocket socket() pure nothrow @safe @nogc
out (socket) out (socket; socket !is null)
{
assert(socket !is null);
}
do
{ {
return cast(ConnectedSocket) socket_; return cast(ConnectedSocket) socket_;
} }
private @property void socket(ConnectedSocket socket) private @property void socket(ConnectedSocket socket)
pure nothrow @safe @nogc pure nothrow @safe @nogc
in in (socket !is null)
{
assert(socket !is null);
}
do
{ {
socket_ = socket; socket_ = socket;
} }
@ -114,11 +106,7 @@ package class StreamTransport : SocketWatcher, DuplexTransport, SocketTransport
* Precondition: $(D_INLINECODE protocol !is null) * Precondition: $(D_INLINECODE protocol !is null)
*/ */
@property void protocol(Protocol protocol) pure nothrow @safe @nogc @property void protocol(Protocol protocol) pure nothrow @safe @nogc
in in (protocol !is null)
{
assert(protocol !is null);
}
do
{ {
protocol_ = protocol; protocol_ = protocol;
} }
@ -257,11 +245,7 @@ abstract class SelectorLoop : Loop
*/ */
protected void kill(StreamTransport transport, protected void kill(StreamTransport transport,
SocketException exception = null) @nogc SocketException exception = null) @nogc
in in (transport !is null)
{
assert(transport !is null);
}
do
{ {
transport.socket.shutdown(); transport.socket.shutdown();
defaultAllocator.dispose(transport.socket); defaultAllocator.dispose(transport.socket);
@ -283,11 +267,7 @@ abstract class SelectorLoop : Loop
*/ */
protected bool feed(StreamTransport transport, protected bool feed(StreamTransport transport,
SocketException exception = null) @nogc SocketException exception = null) @nogc
in in (transport !is null)
{
assert(transport !is null);
}
do
{ {
while (transport.input.length && transport.writeReady) while (transport.input.length && transport.writeReady)
{ {
@ -350,11 +330,7 @@ abstract class SelectorLoop : Loop
* connection = Connection watcher ready to accept. * connection = Connection watcher ready to accept.
*/ */
package void acceptConnections(ConnectionWatcher connection) @nogc package void acceptConnections(ConnectionWatcher connection) @nogc
in in (connection !is null)
{
assert(connection !is null);
}
do
{ {
while (true) while (true)
{ {

View File

@ -262,12 +262,8 @@ abstract class Loop
* $(D_PSYMBOL maxBlockTime). * $(D_PSYMBOL maxBlockTime).
*/ */
protected @property void blockTime(in Duration blockTime) @safe pure nothrow @nogc protected @property void blockTime(in Duration blockTime) @safe pure nothrow @nogc
in in (blockTime <= 1.dur!"hours", "Too long to wait.")
{ in (!blockTime.isNegative)
assert(blockTime <= 1.dur!"hours", "Too long to wait.");
assert(!blockTime.isNegative);
}
do
{ {
blockTime_ = blockTime; blockTime_ = blockTime;
} }
@ -340,11 +336,7 @@ class BadLoopException : Exception
* loop = The event loop. * loop = The event loop.
*/ */
@property void defaultLoop(Loop loop) @nogc @property void defaultLoop(Loop loop) @nogc
in in (loop !is null)
{
assert(loop !is null);
}
do
{ {
defaultLoop_ = loop; defaultLoop_ = loop;
} }

View File

@ -57,10 +57,7 @@ interface DuplexTransport : ReadTransport, WriteTransport
* Postcondition: $(D_INLINECODE protocol !is null) * Postcondition: $(D_INLINECODE protocol !is null)
*/ */
@property Protocol protocol() pure nothrow @safe @nogc @property Protocol protocol() pure nothrow @safe @nogc
out (protocol) out (protocol; protocol !is null);
{
assert(protocol !is null);
}
/** /**
* Switches the protocol. * Switches the protocol.
@ -73,10 +70,7 @@ interface DuplexTransport : ReadTransport, WriteTransport
* Precondition: $(D_INLINECODE protocol !is null) * Precondition: $(D_INLINECODE protocol !is null)
*/ */
@property void protocol(Protocol protocol) pure nothrow @safe @nogc @property void protocol(Protocol protocol) pure nothrow @safe @nogc
in in (protocol !is null);
{
assert(protocol !is null);
}
/** /**

View File

@ -52,11 +52,7 @@ abstract class SocketWatcher : Watcher
* Precondition: $(D_INLINECODE socket !is null) * Precondition: $(D_INLINECODE socket !is null)
*/ */
this(Socket socket) pure nothrow @safe @nogc this(Socket socket) pure nothrow @safe @nogc
in in (socket !is null)
{
assert(socket !is null);
}
do
{ {
socket_ = socket; socket_ = socket;
} }
@ -102,11 +98,7 @@ class ConnectionWatcher : SocketWatcher
* Invokes new connection callback. * Invokes new connection callback.
*/ */
override void invoke() @nogc override void invoke() @nogc
in in (protocolFactory !is null, "Protocol isn't set.")
{
assert(protocolFactory !is null, "Protocol isn't set.");
}
do
{ {
for (; !this.incoming.empty; this.incoming.removeFront()) for (; !this.incoming.empty; this.incoming.removeFront())
{ {

View File

@ -1928,7 +1928,7 @@ private char[] errol3(double value,
* $(D_PARAM sign). * $(D_PARAM sign).
*/ */
private const(char)[] real2String(double value, private const(char)[] real2String(double value,
ref char[512] buffer, return ref char[512] buffer,
out int exponent, out int exponent,
out bool sign) @nogc nothrow pure @trusted out bool sign) @nogc nothrow pure @trusted
{ {

View File

@ -57,10 +57,9 @@ struct Address4
* Params: * Params:
* address = The address as an unsigned integer in host byte order. * address = The address as an unsigned integer in host byte order.
*/ */
this(uint address) @nogc nothrow pure @safe this(uint address) @nogc nothrow pure @trusted
{ {
copy(NetworkOrder!4(address), copy(NetworkOrder!4(address), (cast(ubyte*) &this.address)[0 .. 4]);
(() @trusted => (cast(ubyte*) &this.address)[0 .. 4])());
} }
/// ///

View File

@ -608,7 +608,7 @@ if (isTypeTuple!Specs && NoDuplicates!Specs.length == Specs.length)
return this; return this;
} }
private ref typeof(this) copyAssign(T)(ref T that) private ref typeof(this) copyAssign(T)(ref T that) return
{ {
this.tag = staticIndexOf!(T, Types); this.tag = staticIndexOf!(T, Types);