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 4c498b9 commit f1f9f87
Show file tree
Hide file tree
Showing 49 changed files with 366 additions and 366 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 @@ -560,7 +560,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 @@ -585,7 +585,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 @@ -993,8 +993,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 @@ -1066,8 +1066,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 @@ -1106,8 +1106,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 @@ -1144,8 +1144,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 @@ -1177,7 +1177,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 @@ -1222,8 +1222,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 @@ -1267,8 +1267,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 @@ -1311,8 +1311,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 @@ -1354,8 +1354,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 @@ -1395,7 +1395,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 @@ -1438,7 +1438,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 @@ -1472,7 +1472,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 @@ -1513,8 +1513,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 @@ -1557,8 +1557,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 @@ -1599,8 +1599,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 @@ -1623,7 +1623,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/NotifierTypes.d
Expand Up @@ -47,12 +47,12 @@ public struct RequestRecordInfo
***************************************************************************/

public void toString ( void delegate ( cstring chunk ) sink )
public void toString ( scope void delegate ( cstring chunk ) sink )
{
Formatter.sformat(
sink,
"Request #{} provided the record 0x{:x16}:{}",
this.request_id, this.key, this.value);
(&this).request_id, (&this).key, (&this).value);
}
}

Expand Down Expand Up @@ -92,12 +92,12 @@ public struct RequestDataUpdateInfo
***************************************************************************/

public void toString ( void delegate ( cstring chunk ) sink )
public void toString ( scope void delegate ( cstring chunk ) sink )
{
Formatter.sformat(
sink,
"Request #{} provided the record {} to be updated",
this.request_id, this.value);
(&this).request_id, (&this).value);
}
}

Expand Down Expand Up @@ -126,12 +126,12 @@ public struct RequestKeyInfo
***************************************************************************/

public void toString ( void delegate ( cstring chunk ) sink )
public void toString ( scope void delegate ( cstring chunk ) sink )
{
Formatter.sformat(
sink,
"Request #{} provided the key 0x{:x16}",
this.request_id, this.key);
(&this).request_id, (&this).key);
}
}

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
14 changes: 7 additions & 7 deletions src/dhtproto/client/internal/NodeHashRanges.d
Expand Up @@ -53,7 +53,7 @@ public final class NodeHashRanges : NodeHashRangesBase
***************************************************************************/

public this ( ConnectionSet connections, NewNodeNotifier new_node_dg )
public this ( ConnectionSet connections, scope NewNodeNotifier new_node_dg )
{
this.connections = connections;
this.new_node_dg = new_node_dg;
Expand Down Expand Up @@ -88,8 +88,8 @@ public final class NodeHashRanges : NodeHashRangesBase
***************************************************************************/

public void getFromNode ( hash_t h,
VoidBufferAsArrayOf!(NodeHashRange) node_hash_ranges, UseNodeDg use_node,
bool delegate ( RequestOnConn.EventDispatcher ) get )
VoidBufferAsArrayOf!(NodeHashRange) node_hash_ranges, scope UseNodeDg use_node,
scope bool delegate ( RequestOnConn.EventDispatcher ) get )
{
auto nodes = this.getNodesForHash(h, node_hash_ranges);
if ( nodes.length == 0 )
Expand Down Expand Up @@ -146,8 +146,8 @@ public final class NodeHashRanges : NodeHashRangesBase
***************************************************************************/

public void removeFromNodes ( hash_t h,
VoidBufferAsArrayOf!(NodeHashRange) node_hash_ranges, UseNodeDg use_node,
bool delegate ( RequestOnConn.EventDispatcher ) remove )
VoidBufferAsArrayOf!(NodeHashRange) node_hash_ranges, scope UseNodeDg use_node,
scope bool delegate ( RequestOnConn.EventDispatcher ) remove )
{
auto nodes = this.getNodesForHash(h, node_hash_ranges);
if ( nodes.length == 0 )
Expand Down Expand Up @@ -190,8 +190,8 @@ public final class NodeHashRanges : NodeHashRangesBase
***************************************************************************/

public void putToNode ( hash_t h,
VoidBufferAsArrayOf!(NodeHashRange) node_hash_ranges, UseNodeDg use_node,
void delegate ( RequestOnConn.EventDispatcher ) put )
VoidBufferAsArrayOf!(NodeHashRange) node_hash_ranges, scope UseNodeDg use_node,
scope void delegate ( RequestOnConn.EventDispatcher ) put )
{
auto nodes = this.getNodesForHash(h, node_hash_ranges);
if ( nodes.length == 0 )
Expand Down
2 changes: 1 addition & 1 deletion src/dhtproto/client/internal/SharedResources.d
Expand Up @@ -245,7 +245,7 @@ public final class SharedResources
***********************************************************************/

public MessageFiber getFiber ( void delegate ( ) fiber_method )
public MessageFiber getFiber ( scope void delegate ( ) fiber_method )
{
bool new_fiber = false;

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 = RecordBatcher.DefaultMaxBatchSize;
public enum RecordSizeLimit = RecordBatcher.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

0 comments on commit f1f9f87

Please sign in to comment.