Skip to content

Commit

Permalink
Auto-convert to D2
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-wende-sociomantic committed May 22, 2019
1 parent 5c22893 commit 82e1059
Show file tree
Hide file tree
Showing 23 changed files with 125 additions and 125 deletions.
2 changes: 1 addition & 1 deletion integrationtest/channelserializer/main.d
Expand Up @@ -85,7 +85,7 @@ int main ( istring[] args )
{
auto ser = new ChannelSerializer!(S)("failed_channel");

void dumpRecord ( void delegate ( hash_t, ref Contiguous!(S) ) record_dg )
void dumpRecord ( scope void delegate ( hash_t, ref Contiguous!(S) ) record_dg )
{
throw new Exception("File write error");
}
Expand Down
58 changes: 29 additions & 29 deletions src/dhtproto/client/DhtClient.d
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
12 changes: 6 additions & 6 deletions src/dhtproto/client/helper/ChannelSerializer.d
Expand Up @@ -97,7 +97,7 @@ public class ChannelSerializer ( S )

public this ( istring path )
{
const buffer_size = 64 * 1024;
static immutable buffer_size = 64 * 1024;

this.path = path;
this.buffered_output = new BufferedOutput(null, buffer_size);
Expand All @@ -124,7 +124,7 @@ public class ChannelSerializer ( S )

public bool dump ( Contiguous!(S)[hash_t] aa, bool block = false )
{
void dumpAA ( void delegate ( hash_t, ref Contiguous!(S) ) dump_record )
void dumpAA ( scope void delegate ( hash_t, ref Contiguous!(S) ) dump_record )
{
foreach ( k, v; aa)
dump_record(k, v);
Expand All @@ -148,7 +148,7 @@ public class ChannelSerializer ( S )

public bool dump ( Map!(Contiguous!(S), hash_t) map, bool block = false )
{
void dumpMap ( void delegate ( hash_t, ref Contiguous!(S) ) dump_record )
void dumpMap ( scope void delegate ( hash_t, ref Contiguous!(S) ) dump_record )
{
foreach ( k, v; map)
dump_record(k, v);
Expand All @@ -171,7 +171,7 @@ public class ChannelSerializer ( S )
***************************************************************************/

public bool dump ( DumpRecordDg record_dump_dg, bool block = false )
public bool dump ( scope DumpRecordDg record_dump_dg, bool block = false )
{
this.record_dump_dg = record_dump_dg;
return this.fork.call(block);
Expand Down Expand Up @@ -222,7 +222,7 @@ public class ChannelSerializer ( S )
***************************************************************************/

public void load ( LoadRecordDg record_load_dg )
public void load ( scope LoadRecordDg record_load_dg )
{
size_t num_records;
scope file = new File(this.path, File.ReadExisting);
Expand Down Expand Up @@ -346,7 +346,7 @@ unittest
void dumpChannelFromContainer ( )
{
void containerIterator (
void delegate ( hash_t, ref Contiguous!(S) ) dump_record )
scope void delegate ( hash_t, ref Contiguous!(S) ) dump_record )
{
Contiguous!(S) v;

Expand Down
6 changes: 3 additions & 3 deletions src/dhtproto/client/legacy/DhtConst.d
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
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
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
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
Expand Up @@ -391,7 +391,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 @@ -568,8 +568,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

0 comments on commit 82e1059

Please sign in to comment.