Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s/body/do/ in contracts, valid for ~4 years #246

Merged
merged 1 commit into from
Aug 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions source/mysql/connection.d
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ package:
{
assert(_open == OpenState.authenticated);
}
body
do
{
initConnection();
auto greeting = this.parseGreeting();
Expand Down Expand Up @@ -600,7 +600,7 @@ public:
case MySQLSocketType.vibed: assert(openSocketVibeD !is null); break;
}
}
body
do
{
enforce!MYX(capFlags & SvrCapFlags.PROTOCOL41, "This client only supports protocol v4.1");
enforce!MYX(capFlags & SvrCapFlags.SECURE_CONNECTION, "This client only supports protocol v4.1 connection");
Expand Down Expand Up @@ -724,7 +724,7 @@ public:
{
assert(_open == OpenState.authenticated);
}
body
do
{
this.sendCmd(CommandType.QUIT, []);
// No response is sent for a quit packet
Expand Down
2 changes: 1 addition & 1 deletion source/mysql/prepared.d
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ package struct PreparedRegistrations(Payload)
// let's make sure that doesn't change.
assert(!info.queuedForRelease);
}
body
do
{
if(auto pInfo = sql in directLookup)
{
Expand Down
14 changes: 7 additions & 7 deletions source/mysql/protocol/comms.d
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ out(result)
{
assert(result.length == numFields);
}
body
do
{
bool[] nulls;
nulls.length = numFields;
Expand Down Expand Up @@ -642,7 +642,7 @@ in
{
assert(rh.fieldCount <= uint.max);
}
body
do
{
scope(failure) conn.kill();

Expand Down Expand Up @@ -716,7 +716,7 @@ in
{
assert(packet.length > 4); // at least 1 byte more than header
}
body
do
{
_socket.write(packet);
}
Expand All @@ -726,7 +726,7 @@ in
{
assert(header.length == 4 || header.length == 5/*command type included*/);
}
body
do
{
_socket.write(header);
if(data.length)
Expand Down Expand Up @@ -756,7 +756,7 @@ out
// at this point we should have sent a command
assert(conn.pktNumber == 1);
}
body
do
{
scope(failure) conn.kill();

Expand Down Expand Up @@ -797,7 +797,7 @@ in
{
assert(token.length == 20);
}
body
do
{
ubyte[] packet;
packet.reserve(4/*header*/ + 4 + 4 + 1 + 23 + conn._user.length+1 + token.length+1 + conn._db.length+1);
Expand Down Expand Up @@ -981,7 +981,7 @@ out
{
assert(conn._open == Connection.OpenState.authenticated);
}
body
do
{
auto token = makeToken(conn._pwd, greeting);
auto authPacket = conn.buildAuthPacket(token);
Expand Down
38 changes: 19 additions & 19 deletions source/mysql/protocol/packet_helpers.d
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ in
{
assert(packet.length >= N);
}
body
do
{
return cast(string)packet.consume(N);
}
Expand All @@ -365,7 +365,7 @@ in
{
assert(packet.length >= N);
}
body
do
{
auto result = packet[0..N];
packet = packet[N..$];
Expand Down Expand Up @@ -404,7 +404,7 @@ in
{
static assert(N == T.sizeof);
}
body
do
{
enforce!MYXProtocol(packet.length, "Supplied byte array is zero length");
uint length = packet.front;
Expand All @@ -427,7 +427,7 @@ in
{
static assert(N == T.sizeof);
}
body
do
{
return toDate(packet.consume(5));
}
Expand All @@ -438,7 +438,7 @@ in
assert(packet.length);
assert(N == T.sizeof);
}
body
do
{
auto numBytes = packet.consume!ubyte();
if(numBytes == 0)
Expand Down Expand Up @@ -468,7 +468,7 @@ in
{
static assert(T.sizeof >= N, T.stringof~" not large enough to store "~to!string(N)~" bytes");
}
body
do
{
return packet.length >= N;
}
Expand All @@ -481,7 +481,7 @@ in
static assert(T.sizeof >= N, T.stringof~" not large enough to store "~to!string(N)~" bytes");
assert(packet.hasEnoughBytes!(T,N), "packet not long enough to contain all bytes needed for "~T.stringof);
}
body
do
{
T value = 0;
static if(N == 8) // 64 bit
Expand Down Expand Up @@ -518,7 +518,7 @@ in
static assert(T.sizeof >= N, T.stringof~" not large enough to store "~to!string(N)~" bytes");
assert(packet.hasEnoughBytes!(T,N), "packet not long enough to contain all bytes needed for "~T.stringof);
}
body
do
{
// The uncommented line triggers a template deduction error,
// so we need to store a temporary first
Expand Down Expand Up @@ -548,7 +548,7 @@ in
static assert((is(T == float) && N == float.sizeof)
|| is(T == double) && N == double.sizeof);
}
body
do
{
T result = 0;
(cast(ubyte*)&result)[0..T.sizeof] = packet[0..T.sizeof];
Expand All @@ -562,7 +562,7 @@ in
static assert((is(T == float) && N == float.sizeof)
|| is(T == double) && N == double.sizeof);
}
body
do
{
return packet.consume(T.sizeof).decode!T();
}
Expand Down Expand Up @@ -785,7 +785,7 @@ in
{
assert(packet.length >= 1, "packet has to include at least the LCB length byte");
}
body
do
{
auto lcb = packet.decodeLCBHeader();
if(lcb.isNull || lcb.isIncomplete)
Expand All @@ -809,7 +809,7 @@ in
{
assert(packet.length >= 1, "packet has to include at least the LCB length byte");
}
body
do
{
LCB lcb;
lcb.numBytes = getNumLCBBytes(packet.front);
Expand Down Expand Up @@ -849,7 +849,7 @@ in
{
assert(packet.length >= 1, "packet has to include at least the LCB length byte");
}
body
do
{
auto lcb = packet.decodeLCBHeader();
if(lcb.isNull || lcb.isIncomplete)
Expand Down Expand Up @@ -879,7 +879,7 @@ in
{
assert(packet.length >= 1, "LCS packet needs to store at least the LCB header");
}
body
do
{
auto lcb = packet.consumeIfComplete!LCB();
assert(!lcb.isIncomplete);
Expand All @@ -898,7 +898,7 @@ in
{
assert(n <= array.length);
}
body
do
{
array = array[n..$];
return array;
Expand All @@ -921,7 +921,7 @@ in
else
assert(array.length >= T.sizeof, "Not enough space to unpack "~T.stringof);
}
body
do
{
static if(T.sizeof >= 1)
{
Expand Down Expand Up @@ -957,7 +957,7 @@ out(result)
{
assert(result.length >= 1);
}
body
do
{
ubyte[] t;
if (!l)
Expand Down Expand Up @@ -1122,7 +1122,7 @@ in
// packet should include header, and possibly data
assert(packet.length >= 4);
}
body
do
{
auto dataLength = packet.length - 4; // don't include header in calculated size
assert(dataLength <= uint.max);
Expand All @@ -1137,7 +1137,7 @@ in
// Length is always a 24-bit int
assert(dataLength <= 0xffff_ffff_ffff);
}
body
do
{
dataLength.packInto!(uint, true)(packet);
packet[3] = packetNumber;
Expand Down
6 changes: 3 additions & 3 deletions source/mysql/protocol/packets.d
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public:
{
assert(!packet.length, "not all bytes read during FieldDescription construction");
}
body
do
{
packet.skip(4); // Skip catalog - it's always 'def'
_db = packet.consume!LCS();
Expand Down Expand Up @@ -245,7 +245,7 @@ in
{
assert(!packet.empty);
}
body
do
{
return packet.front == ResultPacketMarker.eof && packet.length < 9;
}
Expand Down Expand Up @@ -286,7 +286,7 @@ public:
{
assert(!packet.length);
}
body
do
{
packet.popFront(); // eof marker
_warnings = packet.consume!short();
Expand Down
2 changes: 1 addition & 1 deletion source/mysql/result.d
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public:
/// Explicitly clean up the MySQL resources and cancel pending results
void close()
out{ assert(!isValid); }
body
do
{
if(isValid)
_con.purgeResult();
Expand Down