From a2eeedaa21333380894b3a1c5e84ed99e3ffe683 Mon Sep 17 00:00:00 2001 From: Gavin Norman Date: Mon, 19 Mar 2018 14:48:44 +0000 Subject: [PATCH] Auto-convert to D2 --- src/dhtproto/client/DhtClient.d | 58 +++++++++---------- src/dhtproto/client/legacy/DhtConst.d | 6 +- .../client/legacy/common/NodeRecordBatcher.d | 4 +- .../legacy/internal/helper/ChannelMirror.d | 12 ++-- .../internal/helper/ExtensibleChannelMirror.d | 10 ++-- .../client/legacy/internal/helper/Mirror.d | 6 +- .../legacy/internal/helper/RetryHandshake.d | 14 ++--- .../helper/mirror/ContiguousRecordCache.d | 2 +- .../internal/registry/DhtNodeRegistry.d | 8 +-- .../registry/model/IDhtNodeRegistryInfo.d | 2 +- .../internal/request/params/RequestParams.d | 2 +- src/dhttest/DhtClient.d | 4 +- src/dhttest/cases/Basic.d | 2 +- src/dhttest/cases/BasicListen.d | 6 +- src/dhttest/util/LocalStore.d | 48 +++++++-------- src/dummydhtapp/main.d | 4 +- src/fakedht/ConnectionHandler.d | 2 +- src/fakedht/DhtNode.d | 2 +- src/fakedht/Storage.d | 22 +++---- src/turtle/env/Dht.d | 6 +- 20 files changed, 110 insertions(+), 110 deletions(-) diff --git a/src/dhtproto/client/DhtClient.d b/src/dhtproto/client/DhtClient.d index d1ef6b2b..c227de45 100644 --- a/src/dhtproto/client/DhtClient.d +++ b/src/dhtproto/client/DhtClient.d @@ -402,7 +402,7 @@ public class DhtClient : IClient ***********************************************************************/ - public void opCall ( RequestParams.GetBoolDg output, + public void opCall ( scope RequestParams.GetBoolDg output, NotifierDg user_notifier ) { this.reset(output, user_notifier); @@ -427,7 +427,7 @@ public class DhtClient : IClient ***********************************************************************/ - private void reset ( RequestParams.GetBoolDg output, + private void reset ( scope RequestParams.GetBoolDg output, NotifierDg user_notifier ) { this.output = output; @@ -685,8 +685,8 @@ public class DhtClient : IClient ***************************************************************************/ - public void nodeHandshake ( RequestParams.GetBoolDg output, - RequestNotification.Callback user_notifier ) + public void nodeHandshake ( scope RequestParams.GetBoolDg output, + scope RequestNotification.Callback user_notifier ) { this.node_handshake(output, user_notifier); } @@ -758,8 +758,8 @@ public class DhtClient : IClient mixin RequestParamsSetup; // private setup() method, used by assign() } - public Put put ( Key ) ( cstring channel, Key key, RequestParams.PutValueDg input, - RequestNotification.Callback notifier ) + public Put put ( Key ) ( cstring channel, Key key, scope RequestParams.PutValueDg input, + scope RequestNotification.Callback notifier ) { return *Put(DhtConst.Command.E.Put, notifier).channel(channel).key(key) .io(input).contextFromKey(); @@ -798,8 +798,8 @@ public class DhtClient : IClient mixin RequestParamsSetup; // private setup() method, used by assign() } - public Get get ( Key ) ( cstring channel, Key key, RequestParams.GetValueDg output, - RequestNotification.Callback notifier ) + public Get get ( Key ) ( cstring channel, Key key, scope RequestParams.GetValueDg output, + scope RequestNotification.Callback notifier ) { return *Get(DhtConst.Command.E.Get, notifier).channel(channel).key(key) .io(output).contextFromKey(); @@ -836,8 +836,8 @@ public class DhtClient : IClient mixin RequestParamsSetup; // private setup() method, used by assign() } - public Exists exists ( Key ) ( cstring channel, Key key, RequestParams.GetBoolDg output, - RequestNotification.Callback notifier ) + public Exists exists ( Key ) ( cstring channel, Key key, scope RequestParams.GetBoolDg output, + scope RequestNotification.Callback notifier ) { return *Exists(DhtConst.Command.E.Exists, notifier).channel(channel) .key(key).io(output).contextFromKey(); @@ -869,7 +869,7 @@ public class DhtClient : IClient mixin RequestParamsSetup; // private setup() method, used by assign() } - public Remove remove ( Key ) ( cstring channel, Key key, RequestNotification.Callback notifier ) + public Remove remove ( Key ) ( cstring channel, Key key, scope RequestNotification.Callback notifier ) { return *Remove(DhtConst.Command.E.Remove, notifier).channel(channel) .key(key).contextFromKey(); @@ -914,8 +914,8 @@ public class DhtClient : IClient mixin RequestParamsSetup; // private setup() method, used by assign() } - public GetAll getAll ( cstring channel, RequestParams.GetPairDg output, - RequestNotification.Callback notifier ) + public GetAll getAll ( cstring channel, scope RequestParams.GetPairDg output, + scope RequestNotification.Callback notifier ) { return *GetAll(DhtConst.Command.E.GetAll, notifier).channel(channel) .io(output); @@ -959,8 +959,8 @@ public class DhtClient : IClient mixin RequestParamsSetup; // private setup() method, used by assign() } - public GetAllKeys getAllKeys ( cstring channel, RequestParams.GetValueDg output, - RequestNotification.Callback notifier ) + public GetAllKeys getAllKeys ( cstring channel, scope RequestParams.GetValueDg output, + scope RequestNotification.Callback notifier ) { return *GetAllKeys(DhtConst.Command.E.GetAllKeys, notifier) .channel(channel).io(output); @@ -1003,8 +1003,8 @@ public class DhtClient : IClient mixin RequestParamsSetup; // private setup() method, used by assign() } - public Listen listen ( cstring channel, RequestParams.GetPairDg output, - RequestNotification.Callback notifier ) + public Listen listen ( cstring channel, scope RequestParams.GetPairDg output, + scope RequestNotification.Callback notifier ) { return *Listen(DhtConst.Command.E.Listen, notifier).channel(channel) .io(output); @@ -1046,8 +1046,8 @@ public class DhtClient : IClient mixin RequestParamsSetup; // private setup() method, used by assign() } - public GetChannels getChannels ( RequestParams.GetNodeValueDg output, - RequestNotification.Callback notifier ) + public GetChannels getChannels ( scope RequestParams.GetNodeValueDg output, + scope RequestNotification.Callback notifier ) { return *GetChannels(DhtConst.Command.E.GetChannels, notifier).io(output); } @@ -1087,7 +1087,7 @@ public class DhtClient : IClient mixin RequestParamsSetup; // private setup() method, used by assign() } - public GetSize getSize ( RequestParams.GetSizeInfoDg output, RequestNotification.Callback notifier ) + public GetSize getSize ( scope RequestParams.GetSizeInfoDg output, scope RequestNotification.Callback notifier ) { return *GetSize(DhtConst.Command.E.GetSize, notifier).io(output); } @@ -1130,7 +1130,7 @@ public class DhtClient : IClient mixin RequestParamsSetup; // private setup() method, used by assign() } - public GetChannelSize getChannelSize ( cstring channel, RequestParams.GetChannelSizeInfoDg output, RequestNotification.Callback notifier ) + public GetChannelSize getChannelSize ( cstring channel, scope RequestParams.GetChannelSizeInfoDg output, scope RequestNotification.Callback notifier ) { return *GetChannelSize(DhtConst.Command.E.GetChannelSize, notifier) .channel(channel).io(output); @@ -1164,7 +1164,7 @@ public class DhtClient : IClient mixin RequestParamsSetup; // private setup() method, used by assign() } - public RemoveChannel removeChannel ( cstring channel, RequestNotification.Callback notifier ) + public RemoveChannel removeChannel ( cstring channel, scope RequestNotification.Callback notifier ) { return *RemoveChannel(DhtConst.Command.E.RemoveChannel, notifier) .channel(channel); @@ -1205,8 +1205,8 @@ public class DhtClient : IClient mixin RequestParamsSetup; // private setup() method, used by assign() } - public GetNumConnections getNumConnections ( RequestParams.GetNumConnectionsDg output, - RequestNotification.Callback notifier ) + public GetNumConnections getNumConnections ( scope RequestParams.GetNumConnectionsDg output, + scope RequestNotification.Callback notifier ) { return *GetNumConnections(DhtConst.Command.E.GetNumConnections, notifier) .io(output); @@ -1249,8 +1249,8 @@ public class DhtClient : IClient mixin RequestParamsSetup; // private setup() method, used by assign() } - public GetVersion getVersion ( RequestParams.GetNodeValueDg output, - RequestNotification.Callback notifier ) + public GetVersion getVersion ( scope RequestParams.GetNodeValueDg output, + scope RequestNotification.Callback notifier ) { return *GetVersion(DhtConst.Command.E.GetVersion, notifier).io(output); } @@ -1291,8 +1291,8 @@ public class DhtClient : IClient mixin RequestParamsSetup; // private setup() method, used by assign() } - public GetResponsibleRange getResponsibleRange ( RequestParams.GetResponsibleRangeDg output, - RequestNotification.Callback notifier ) + public GetResponsibleRange getResponsibleRange ( scope RequestParams.GetResponsibleRangeDg output, + scope RequestNotification.Callback notifier ) { return *GetResponsibleRange(DhtConst.Command.E.GetResponsibleRange, notifier).io(output); @@ -1315,7 +1315,7 @@ public class DhtClient : IClient ***************************************************************************/ override protected void scopeRequestParams ( - void delegate ( IRequestParams params ) dg ) + scope void delegate ( IRequestParams params ) dg ) { scope params = new RequestParams; dg(params); diff --git a/src/dhtproto/client/legacy/DhtConst.d b/src/dhtproto/client/legacy/DhtConst.d index db60672b..0641a0f3 100644 --- a/src/dhtproto/client/legacy/DhtConst.d +++ b/src/dhtproto/client/legacy/DhtConst.d @@ -56,7 +56,7 @@ static: ***************************************************************************/ - public const ApiVersion = "20110401"; + public enum ApiVersion = "20110401"; /*************************************************************************** @@ -66,7 +66,7 @@ static: ***************************************************************************/ - public const RecordSizeLimit = RecordBatch.DefaultMaxBatchSize; + public enum RecordSizeLimit = RecordBatch.DefaultMaxBatchSize; /*************************************************************************** @@ -221,6 +221,6 @@ public struct NodeHashRange public equals_t opEquals ( NodeHashRange rhs ) { - return this.opCmp(rhs) == 0; + return (&this).opCmp(rhs) == 0; } } diff --git a/src/dhtproto/client/legacy/common/NodeRecordBatcher.d b/src/dhtproto/client/legacy/common/NodeRecordBatcher.d index ad793181..217d15f4 100644 --- a/src/dhtproto/client/legacy/common/NodeRecordBatcher.d +++ b/src/dhtproto/client/legacy/common/NodeRecordBatcher.d @@ -94,10 +94,10 @@ public class NodeRecordBatcher { private hash_t[] hashes; - public int opApply ( int delegate ( ref hash_t hash ) dg ) + public int opApply ( scope int delegate ( ref hash_t hash ) dg ) { int r; - foreach ( h; this.hashes ) + foreach ( h; (&this).hashes ) { r = dg(h); if ( r ) break; diff --git a/src/dhtproto/client/legacy/internal/helper/ChannelMirror.d b/src/dhtproto/client/legacy/internal/helper/ChannelMirror.d index 224c0f09..8025aae8 100644 --- a/src/dhtproto/client/legacy/internal/helper/ChannelMirror.d +++ b/src/dhtproto/client/legacy/internal/helper/ChannelMirror.d @@ -79,7 +79,7 @@ abstract public class ChannelMirror ( Dht : DhtClient ) : MirrorBase!(Dht) ***********************************************************************/ - public this ( Dht.RequestNotification.Callback notifier = null ) + public this ( scope Dht.RequestNotification.Callback notifier = null ) { super(this.outer.dht.listen(this.outer.channel_, &this.outer.listenReceiveRecord, notifier)); @@ -158,7 +158,7 @@ abstract public class ChannelMirror ( Dht : DhtClient ) : MirrorBase!(Dht) ***********************************************************************/ - public this ( Dht.RequestNotification.Callback notifier = null ) + public this ( scope Dht.RequestNotification.Callback notifier = null ) { super(this.outer.dht.getAll(this.outer.channel_, &this.outer.getAllReceiveRecord, @@ -273,7 +273,7 @@ abstract public class ChannelMirror ( Dht : DhtClient ) : MirrorBase!(Dht) public this ( Dht dht, cstring channel, uint update_time_s, uint retry_time_s, - Dht.RequestNotification.Callback notifier = null ) + scope Dht.RequestNotification.Callback notifier = null ) { super(dht, channel, update_time_s, retry_time_s); @@ -305,7 +305,7 @@ abstract public class ChannelMirror ( Dht : DhtClient ) : MirrorBase!(Dht) public this ( Dht dht, cstring channel, uint update_time_s, uint retry_time_s, lazy ListenRequest listen, lazy GetAllRequest get_all, - Dht.RequestNotification.Callback notifier = null ) + scope Dht.RequestNotification.Callback notifier = null ) { super(dht, channel, update_time_s, retry_time_s); @@ -437,8 +437,8 @@ unittest // Dummy concrete channel mirror class class Mirror : ChannelMirror!(SchedulingDhtClient) { - const UpdatePeriod = 60; // do a GetAll every 60 seconds - const RetryPeriod = 3; // retry failed requests after 3 seconds + static immutable UpdatePeriod = 60; // do a GetAll every 60 seconds + static immutable RetryPeriod = 3; // retry failed requests after 3 seconds public this ( SchedulingDhtClient dht, in char[] channel ) { diff --git a/src/dhtproto/client/legacy/internal/helper/ExtensibleChannelMirror.d b/src/dhtproto/client/legacy/internal/helper/ExtensibleChannelMirror.d index 8ed57ec0..5bf1c272 100755 --- a/src/dhtproto/client/legacy/internal/helper/ExtensibleChannelMirror.d +++ b/src/dhtproto/client/legacy/internal/helper/ExtensibleChannelMirror.d @@ -156,8 +156,8 @@ public class ExtensibleMirror public this ( Dht dht, cstring channel, uint update_time_s, uint retry_time_s, - Dht.RequestNotification.Callback request_notifier, - PluginNotifier plugin_notifier, + scope Dht.RequestNotification.Callback request_notifier, + scope PluginNotifier plugin_notifier, Plugins plugin_instances ) { super(dht, channel, update_time_s, retry_time_s, request_notifier); @@ -310,7 +310,7 @@ unittest istring toString ( ) { return format("[{}, {}, {}]", - this.update_time, this.id, this.count); + (&this).update_time, (&this).id, (&this).count); } } @@ -327,7 +327,7 @@ unittest epoll.eventLoop(); // Add some records to the channel being mirrored - const num_records = 10; + static immutable num_records = 10; for ( hash_t i = 0; i < num_records; i++ ) { mstring put_dg ( DhtClient.RequestContext c ) @@ -516,7 +516,7 @@ public class RawRecordDeserializer ( T ) ***************************************************************************/ - private const bool isVersioned = Version.Info!(T).exists; + private static immutable bool isVersioned = Version.Info!(T).exists; static if (isVersioned) { diff --git a/src/dhtproto/client/legacy/internal/helper/Mirror.d b/src/dhtproto/client/legacy/internal/helper/Mirror.d index ca4c8742..84dc82f4 100644 --- a/src/dhtproto/client/legacy/internal/helper/Mirror.d +++ b/src/dhtproto/client/legacy/internal/helper/Mirror.d @@ -338,7 +338,7 @@ abstract public class Mirror ( Dht : DhtClient ) : MirrorBase!(Dht) ***************************************************************************/ public this ( Dht dht, cstring channel, uint update_time_s, - uint retry_time_s, Dht.RequestNotification.Callback notifier = null ) + uint retry_time_s, scope Dht.RequestNotification.Callback notifier = null ) { super(dht, channel, update_time_s, retry_time_s); this.user_notifier = notifier; @@ -510,8 +510,8 @@ unittest // Dummy concrete channel mirror class class ExampleMirror : Mirror!(SchedulingDhtClient) { - const UpdatePeriod = 60; // do a GetAll every 60 seconds - const RetryPeriod = 3; // retry failed requests after 3 seconds + static immutable UpdatePeriod = 60; // do a GetAll every 60 seconds + static immutable RetryPeriod = 3; // retry failed requests after 3 seconds public this ( SchedulingDhtClient dht, cstring channel ) { diff --git a/src/dhtproto/client/legacy/internal/helper/RetryHandshake.d b/src/dhtproto/client/legacy/internal/helper/RetryHandshake.d index 67bd613a..83c76697 100644 --- a/src/dhtproto/client/legacy/internal/helper/RetryHandshake.d +++ b/src/dhtproto/client/legacy/internal/helper/RetryHandshake.d @@ -99,8 +99,8 @@ class RetryHandshake ***************************************************************************/ public this ( EpollSelectDispatcher epoll, DhtClient dht, - size_t wait_time, void delegate ( ) handshake_complete_dg = null, - void delegate ( NodeItem ) one_node_handshake_dg = null ) + size_t wait_time, scope void delegate ( ) handshake_complete_dg = null, + scope void delegate ( NodeItem ) one_node_handshake_dg = null ) { this.wait_time = wait_time; @@ -257,16 +257,16 @@ unittest // event loop running. void main ( ) { - this.epoll = new EpollSelectDispatcher; - this.dht = new DhtClient(this.epoll); + (&this).epoll = new EpollSelectDispatcher; + (&this).dht = new DhtClient((&this).epoll); // In a real app, you should call `this.dht.addNodes(...);` // Start the handshake auto retry_delay_seconds = 3; - new RetryHandshake(this.epoll, this.dht, retry_delay_seconds, - &this.handshake_complete_dg, &this.node_connected_dg); + new RetryHandshake((&this).epoll, (&this).dht, retry_delay_seconds, + &(&this).handshake_complete_dg, &(&this).node_connected_dg); - this.epoll.eventLoop(); + (&this).epoll.eventLoop(); } // Called when an individual node is initially connected. diff --git a/src/dhtproto/client/legacy/internal/helper/mirror/ContiguousRecordCache.d b/src/dhtproto/client/legacy/internal/helper/mirror/ContiguousRecordCache.d index f9b03117..69ee91dd 100644 --- a/src/dhtproto/client/legacy/internal/helper/mirror/ContiguousRecordCache.d +++ b/src/dhtproto/client/legacy/internal/helper/mirror/ContiguousRecordCache.d @@ -151,7 +151,7 @@ unittest equals_t opEquals ( S rhs ) { - return this.x == rhs.x && this.y == rhs.y && this.s == rhs.s; + return (&this).x == rhs.x && (&this).y == rhs.y && (&this).s == rhs.s; } } diff --git a/src/dhtproto/client/legacy/internal/registry/DhtNodeRegistry.d b/src/dhtproto/client/legacy/internal/registry/DhtNodeRegistry.d index 459b7eed..a60065c8 100644 --- a/src/dhtproto/client/legacy/internal/registry/DhtNodeRegistry.d +++ b/src/dhtproto/client/legacy/internal/registry/DhtNodeRegistry.d @@ -71,7 +71,7 @@ public class DhtNodeRegistry : NodeRegistry, IDhtNodeRegistryInfo ***************************************************************************/ - private const expected_nodes = 100; + private static immutable expected_nodes = 100; /*************************************************************************** @@ -401,7 +401,7 @@ public class DhtNodeRegistry : NodeRegistry, IDhtNodeRegistryInfo **************************************************************************/ - public int opApply ( int delegate ( ref IDhtNodeConnectionPoolInfo ) dg ) + public int opApply ( scope int delegate ( ref IDhtNodeConnectionPoolInfo ) dg ) { int ret; @@ -580,7 +580,7 @@ public class DhtNodeRegistry : NodeRegistry, IDhtNodeRegistryInfo ***************************************************************************/ - private int opApply ( int delegate ( ref DhtNodeConnectionPool ) dg ) + private int opApply ( scope int delegate ( ref DhtNodeConnectionPool ) dg ) { int res; foreach ( pool; this.nodes.list ) @@ -602,7 +602,7 @@ public class DhtNodeRegistry : NodeRegistry, IDhtNodeRegistryInfo ***************************************************************************/ - private int opApply ( int delegate ( ref size_t, ref DhtNodeConnectionPool ) dg ) + private int opApply ( scope int delegate ( ref size_t, ref DhtNodeConnectionPool ) dg ) { int res; size_t i; diff --git a/src/dhtproto/client/legacy/internal/registry/model/IDhtNodeRegistryInfo.d b/src/dhtproto/client/legacy/internal/registry/model/IDhtNodeRegistryInfo.d index 05c8533a..893ee971 100644 --- a/src/dhtproto/client/legacy/internal/registry/model/IDhtNodeRegistryInfo.d +++ b/src/dhtproto/client/legacy/internal/registry/model/IDhtNodeRegistryInfo.d @@ -122,7 +122,7 @@ public interface IDhtNodeRegistryInfo : INodeRegistryInfo **************************************************************************/ - public int opApply ( int delegate ( ref IDhtNodeConnectionPoolInfo ) dg ); + public int opApply ( scope int delegate ( ref IDhtNodeConnectionPoolInfo ) dg ); /*************************************************************************** diff --git a/src/dhtproto/client/legacy/internal/request/params/RequestParams.d b/src/dhtproto/client/legacy/internal/request/params/RequestParams.d index 050fbd28..0dfce0ca 100644 --- a/src/dhtproto/client/legacy/internal/request/params/RequestParams.d +++ b/src/dhtproto/client/legacy/internal/request/params/RequestParams.d @@ -163,7 +163,7 @@ public class RequestParams : IChannelRequestParams ***************************************************************************/ - override protected void notify_ ( void delegate ( IRequestNotification ) info_dg ) + override protected void notify_ ( scope void delegate ( IRequestNotification ) info_dg ) { scope info = new RequestNotification(cast(DhtConst.Command.E)this.command, this.context); diff --git a/src/dhttest/DhtClient.d b/src/dhttest/DhtClient.d index a7fd0838..9b118099 100644 --- a/src/dhttest/DhtClient.d +++ b/src/dhttest/DhtClient.d @@ -184,7 +184,7 @@ class DhtClient { this.log = Log.lookup("dhttest"); - const max_connections = 2; + static immutable max_connections = 2; this.swarm_client = new SwarmClient(theScheduler.epoll, max_connections); } @@ -550,7 +550,7 @@ class DhtClient public Listener startListen ( cstring channel ) { - const hash_t key = 0xDEAD; + static immutable hash_t key = 0xDEAD; auto listener = new Listener; diff --git a/src/dhttest/cases/Basic.d b/src/dhttest/cases/Basic.d index 322db2b8..3063199c 100644 --- a/src/dhttest/cases/Basic.d +++ b/src/dhttest/cases/Basic.d @@ -22,7 +22,7 @@ import ocean.transition; import dhttest.DhtTestCase; -const PRIORITY = 100; +static immutable PRIORITY = 100; /******************************************************************************* diff --git a/src/dhttest/cases/BasicListen.d b/src/dhttest/cases/BasicListen.d index 300f455b..9c66a499 100644 --- a/src/dhttest/cases/BasicListen.d +++ b/src/dhttest/cases/BasicListen.d @@ -26,7 +26,7 @@ import ocean.core.Test; import ocean.io.select.fiber.SelectFiber; import ocean.io.select.client.FiberTimerEvent; -const PRIORITY = 90; +static immutable PRIORITY = 90; /******************************************************************************* @@ -51,7 +51,7 @@ class ListenRemovedChannel : DhtTestCase override public void run ( ) { auto listener = this.dht.startListen(this.test_channel); - const key = 0; + static immutable key = 0; this.dht.put(this.test_channel, key, "whatever"[]); listener.waitNextEvent(); test(!listener.finished); @@ -87,7 +87,7 @@ class ListenTrigger : DhtTestCase { auto listener = this.dht.startListen(this.test_channel); - const key = 5; + static immutable key = 5; this.dht.put(this.test_channel, key, "value"[]); listener.waitNextEvent(); test!("==")(listener.data.length, 1); diff --git a/src/dhttest/util/LocalStore.d b/src/dhttest/util/LocalStore.d index 01b2e291..d0a3ea89 100644 --- a/src/dhttest/util/LocalStore.d +++ b/src/dhttest/util/LocalStore.d @@ -54,7 +54,7 @@ struct LocalStore public void put ( hash_t key, cstring val ) { - this.data[key] = val.dup; + (&this).data[key] = val.dup; } /*************************************************************************** @@ -68,7 +68,7 @@ struct LocalStore public void remove ( hash_t key ) { - this.data.remove(key); + (&this).data.remove(key); } } @@ -107,14 +107,14 @@ public struct LegacyVerifier public void verifyAgainstDht ( ref LocalStore local, DhtClient dht, cstring channel ) { - this.local = &local; - - this.verifyGetChannelSize(dht, channel); - this.verifyGetAll(dht, channel); - this.verifyGetAllFilter(dht, channel); - this.verifyGetAllKeys(dht, channel); - this.verifyExists(dht, channel); - this.verifyGet(dht, channel); + (&this).local = &local; + + (&this).verifyGetChannelSize(dht, channel); + (&this).verifyGetAll(dht, channel); + (&this).verifyGetAllFilter(dht, channel); + (&this).verifyGetAllKeys(dht, channel); + (&this).verifyExists(dht, channel); + (&this).verifyGet(dht, channel); } /*************************************************************************** @@ -136,8 +136,8 @@ public struct LegacyVerifier ulong records, bytes; dht.getChannelSize(channel, records, bytes); log.trace("\tVerifying channel with GetChannelSize: local:{}, remote:{}", - this.local.data.length, records); - test!("==")(this.local.data.length, records); + (&this).local.data.length, records); + test!("==")((&this).local.data.length, records); } /*************************************************************************** @@ -158,13 +158,13 @@ public struct LegacyVerifier { auto remote = dht.getAll(channel); log.trace("\tVerifying channel with GetAll: local:{}, remote:{}", - this.local.data.length, remote.length); - test!("==")(this.local.data.length, remote.length); + (&this).local.data.length, remote.length); + test!("==")((&this).local.data.length, remote.length); foreach ( k, v; remote ) { - test!("in")(k, this.local.data); - test!("==")(v, this.local.data[k]); + test!("in")(k, (&this).local.data); + test!("==")(v, (&this).local.data[k]); } } @@ -186,10 +186,10 @@ public struct LegacyVerifier private void verifyGetAllFilter ( DhtClient dht, cstring channel ) { - const filter = "0"; + enum filter = "0"; hash_t[] local; - foreach ( k, v; this.local.data ) + foreach ( k, v; (&this).local.data ) { if ( v.contains(filter) ) local ~= k; @@ -203,7 +203,7 @@ public struct LegacyVerifier foreach ( k, v; remote ) { test(local.contains(k)); - test!("==")(v, this.local.data[k]); + test!("==")(v, (&this).local.data[k]); } } @@ -225,12 +225,12 @@ public struct LegacyVerifier { auto remote = dht.getAllKeys(channel); log.trace("\tVerifying channel with GetAllKeys: local:{}, remote:{}", - this.local.data.length, remote.length); - test!("==")(this.local.data.length, remote.length); + (&this).local.data.length, remote.length); + test!("==")((&this).local.data.length, remote.length); foreach ( k; remote ) { - test!("in")(k, this.local.data); + test!("in")(k, (&this).local.data); } } @@ -251,7 +251,7 @@ public struct LegacyVerifier private void verifyExists ( DhtClient dht, cstring channel ) { log.trace("\tVerifying channel with Exists"); - foreach ( k, v; this.local.data ) + foreach ( k, v; (&this).local.data ) { auto exists = dht.exists(channel, k); test(exists); @@ -275,7 +275,7 @@ public struct LegacyVerifier private void verifyGet ( DhtClient dht, cstring channel ) { log.trace("\tVerifying channel with Get"); - foreach ( k, v; this.local.data ) + foreach ( k, v; (&this).local.data ) { auto remote_v = dht.get(channel, k); test!("==")(remote_v, v); diff --git a/src/dummydhtapp/main.d b/src/dummydhtapp/main.d index a4ea5acc..0f7166b2 100644 --- a/src/dummydhtapp/main.d +++ b/src/dummydhtapp/main.d @@ -106,13 +106,13 @@ void main ( istring[] args ) fiber = new SelectFiber(epoll, &handshakeAndRegister, 256 * 1024); event = new FiberSelectEvent(fiber); - void ping_handler ( cstring args, void delegate ( cstring + void ping_handler ( cstring args, scope void delegate ( cstring response ) send_response ) { send_response("pong " ~ args); } - void reset_handler ( cstring args, void delegate ( cstring + void reset_handler ( cstring args, scope void delegate ( cstring response ) send_response ) { send_response("ACK"); diff --git a/src/fakedht/ConnectionHandler.d b/src/fakedht/ConnectionHandler.d index 2185d714..7774cfcb 100644 --- a/src/fakedht/ConnectionHandler.d +++ b/src/fakedht/ConnectionHandler.d @@ -223,7 +223,7 @@ public class DhtConnectionHandler : ***************************************************************************/ - public this (void delegate(IConnectionHandler) finalize_dg, + public this (scope void delegate(IConnectionHandler) finalize_dg, ConnectionSetupParams setup ) { super(finalize_dg, setup); diff --git a/src/fakedht/DhtNode.d b/src/fakedht/DhtNode.d index fc2b0a89..4327faa6 100644 --- a/src/fakedht/DhtNode.d +++ b/src/fakedht/DhtNode.d @@ -82,7 +82,7 @@ public class DhtNode public this ( DhtConst.NodeItem node_item, EpollSelectDispatcher epoll ) { - const backlog = 20; + static immutable backlog = 20; auto params = new ConnectionSetupParams; params.epoll = epoll; diff --git a/src/fakedht/Storage.d b/src/fakedht/Storage.d index 819d3c37..80e6e7b3 100644 --- a/src/fakedht/Storage.d +++ b/src/fakedht/Storage.d @@ -72,7 +72,7 @@ struct DHT public Channel get (cstring channel_name) { - auto channel = channel_name in this.channels; + auto channel = channel_name in (&this).channels; if (channel is null) return null; return *channel; @@ -93,7 +93,7 @@ struct DHT public Channel getVerify ( cstring channel_name ) { - auto channel = channel_name in this.channels; + auto channel = channel_name in (&this).channels; enforce!(MissingChannelException)(channel !is null, idup(channel_name)); return *channel; } @@ -112,11 +112,11 @@ struct DHT public Channel getCreate (cstring channel_name) { - auto channel = channel_name in this.channels; + auto channel = channel_name in (&this).channels; if (channel is null) { - this.channels[idup(channel_name)] = new Channel; - channel = channel_name in this.channels; + (&this).channels[idup(channel_name)] = new Channel; + channel = channel_name in (&this).channels; } return *channel; } @@ -132,11 +132,11 @@ struct DHT public void remove (cstring channel_name) { - auto channel = this.get(channel_name); + auto channel = (&this).get(channel_name); if (channel !is null) { channel.listeners.trigger(DhtListener.Code.Finish, ""); - this.channels.remove(idup(channel_name)); + (&this).channels.remove(idup(channel_name)); } } @@ -148,10 +148,10 @@ struct DHT public void clear ( ) { - auto names = this.channels.keys; + auto names = (&this).channels.keys; foreach (name; names) { - auto channel = this.getVerify(name); + auto channel = (&this).getVerify(name); channel.data = null; } } @@ -167,7 +167,7 @@ struct DHT public void dropAllListeners ( ) { - foreach (channel; this.channels) + foreach (channel; (&this).channels) { channel.listeners = channel.new Listeners; } @@ -184,7 +184,7 @@ struct DHT { istring[] result; - foreach (key, value; this.channels) + foreach (key, value; (&this).channels) result ~= key; return result; diff --git a/src/turtle/env/Dht.d b/src/turtle/env/Dht.d index 52a0c373..04116e4b 100644 --- a/src/turtle/env/Dht.d +++ b/src/turtle/env/Dht.d @@ -136,7 +136,7 @@ public class Dht : Node!(DhtNode, "dht") unittest { struct NotVersioned { int x; } - struct Versioned { const StructVersion = 0; int x; } + struct Versioned { enum StructVersion = 0; int x; } // ensures compilation void stub ( ) @@ -360,7 +360,7 @@ public class Dht : Node!(DhtNode, "dht") ***************************************************************************/ public void expectRecordCondition ( cstring channel, hash_t key, - bool delegate ( in void[] record ) dg, + scope bool delegate ( in void[] record ) dg, double timeout = 1.0, double check_interval = 0.05 ) { char[Hash.HashDigits] str_key; @@ -593,7 +593,7 @@ unittest { struct Something { - const StructVersion = 1; + enum StructVersion = 1; int a, b; }