Skip to content

Commit

Permalink
Auto-convert to D2
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin Norman committed May 15, 2018
1 parent 7411488 commit cc4600b
Show file tree
Hide file tree
Showing 20 changed files with 110 additions and 110 deletions.
58 changes: 29 additions & 29 deletions src/dhtproto/client/DhtClient.d
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,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);
Expand All @@ -428,7 +428,7 @@ public class DhtClient : IClient
***********************************************************************/

private void reset ( RequestParams.GetBoolDg output,
private void reset ( scope RequestParams.GetBoolDg output,
NotifierDg user_notifier )
{
this.output = output;
Expand Down Expand Up @@ -686,8 +686,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);
}
Expand Down Expand Up @@ -759,8 +759,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();
Expand Down Expand Up @@ -799,8 +799,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();
Expand Down Expand Up @@ -837,8 +837,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();
Expand Down Expand Up @@ -870,7 +870,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();
Expand Down Expand Up @@ -915,8 +915,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);
Expand Down Expand Up @@ -960,8 +960,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);
Expand Down Expand Up @@ -1004,8 +1004,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);
Expand Down Expand Up @@ -1047,8 +1047,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);
}
Expand Down Expand Up @@ -1088,7 +1088,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);
}
Expand Down Expand Up @@ -1131,7 +1131,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);
Expand Down Expand Up @@ -1165,7 +1165,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);
Expand Down Expand Up @@ -1206,8 +1206,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);
Expand Down Expand Up @@ -1250,8 +1250,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);
}
Expand Down Expand Up @@ -1292,8 +1292,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);
Expand All @@ -1316,7 +1316,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);
Expand Down
6 changes: 3 additions & 3 deletions src/dhtproto/client/legacy/DhtConst.d
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static:
***************************************************************************/

public const ApiVersion = "20110401";
public enum ApiVersion = "20110401";


/***************************************************************************
Expand All @@ -66,7 +66,7 @@ static:
***************************************************************************/

public const RecordSizeLimit = RecordBatch.DefaultMaxBatchSize;
public enum RecordSizeLimit = RecordBatch.DefaultMaxBatchSize;


/***************************************************************************
Expand Down Expand Up @@ -221,6 +221,6 @@ public struct NodeHashRange

public equals_t opEquals ( NodeHashRange rhs )
{
return this.opCmp(rhs) == 0;
return (&this).opCmp(rhs) == 0;
}
}
4 changes: 2 additions & 2 deletions src/dhtproto/client/legacy/common/NodeRecordBatcher.d
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,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;
Expand Down
12 changes: 6 additions & 6 deletions src/dhtproto/client/legacy/internal/helper/ChannelMirror.d
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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 )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,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);
Expand Down Expand Up @@ -312,7 +312,7 @@ unittest
istring toString ( )
{
return format("[{}, {}, {}]",
this.update_time, this.id, this.count);
(&this).update_time, (&this).id, (&this).count);
}
}

Expand All @@ -331,7 +331,7 @@ unittest
enforce(handshake_ok);

// 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 )
Expand Down Expand Up @@ -520,7 +520,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)
{
Expand Down
6 changes: 3 additions & 3 deletions src/dhtproto/client/legacy/internal/helper/Mirror.d
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,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;
Expand Down Expand Up @@ -548,8 +548,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 )
{
Expand Down
14 changes: 7 additions & 7 deletions src/dhtproto/client/legacy/internal/helper/RetryHandshake.d
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,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;

Expand Down Expand Up @@ -244,16 +244,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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,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;
}
}

Expand Down
Loading

0 comments on commit cc4600b

Please sign in to comment.