Skip to content

Commit ca3335b

Browse files
committed
Fix the use of the runtime enum tools.
1 parent a117f25 commit ca3335b

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

src/protocol/dns/server.d

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ nothrow @nogc:
9898
{
9999
if (r.length)
100100
r ~= ',';
101-
r ~= enum_keys!NSProtocol[i];
101+
r ~= enum_key_by_decl_index!NSProtocol(i);
102102
}
103103
}
104104
// TODO: we should be able to promote MutableString to String!!
@@ -109,9 +109,9 @@ nothrow @nogc:
109109
// populate the bitfield
110110
foreach (ref v; value)
111111
{
112-
NSProtocol p = enum_from_string!NSProtocol(v[]);
113-
if (p != ubyte.max)
114-
_protocols |= 1 << p;
112+
const NSProtocol* p = enum_from_key!NSProtocol(v[]);
113+
if (p)
114+
_protocols |= 1 << *p;
115115
}
116116
}
117117

src/protocol/http/client.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ private:
281281
}
282282

283283
MutableString!0 message;
284-
message.concat(enum_keys!HTTPMethod[request.method], ' ', request.url, get, " HTTP/", request.http_version >> 4, '.', request.http_version & 0xF,
284+
message.concat(enum_key_from_value!HTTPMethod(request.method), ' ', request.url, get, " HTTP/", request.http_version >> 4, '.', request.http_version & 0xF,
285285
"\r\nHost: ", _host,
286286
"\r\nUser-Agent: OpenWatt\r\nAccept-Encoding: gzip, deflate\r\n");
287287
if (request.http_version == HTTPVersion.V1_1)
@@ -319,7 +319,7 @@ private:
319319

320320
version (DebugHTTPMessageFlow) {
321321
import urt.log;
322-
writeDebug("HTTP: request to ", host, " - ", enum_keys!HTTPMethod[request.method], " ", request.url, " (", request.content.length, " bytes)");
322+
writeDebug("HTTP: request to ", host, " - ", enum_key_from_value!HTTPMethod(request.method), " ", request.url, " (", request.content.length, " bytes)");
323323
}
324324
}
325325

src/protocol/http/message.d

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ private:
386386

387387
static int read_request_line(ref const(char)[] msg, ref HTTPMessage message)
388388
{
389-
HTTPMethod method = msg.split!(' ', false).enum_from_string!HTTPMethod;
390-
if (byte(method) == -1)
389+
const HTTPMethod* method = msg.split!(' ', false).enum_from_key!HTTPMethod;
390+
if (!method)
391391
return -1;
392392

393393
if (int result = read_request_target(msg, message))
@@ -562,8 +562,8 @@ void http_field_lines(scope const HTTPParam[] params, ref MutableString!0 str)
562562

563563
void http_date(ref const DateTime date, ref MutableString!0 str)
564564
{
565-
const(char)[] day = enum_keys!Day[date.wday];
566-
const(char)[] month = enum_keys!Month[date.month];
565+
const(char)[] day = enum_key_by_decl_index!Day(date.wday);
566+
const(char)[] month = enum_key_by_decl_index!Month(date.month - 1);
567567

568568
// IMF-fixdate
569569
// Sun, 06 Nov 1994 08:49:37 GMT

src/protocol/modbus/package.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ nothrow @nogc:
384384
{
385385
if (response.functionCode & 0x80)
386386
{
387-
import urt.meta : enum_keys;
388-
session.writeLine("Exception response from ", slave[], ", code: ", enum_keys!ExceptionCode[response.data[0]]);
387+
import urt.meta : enum_key_from_value;
388+
session.writeLine("Exception response from ", slave[], ", code: ", enum_key_from_value!ExceptionCode(response.data[0]));
389389
}
390390
else
391391
{

0 commit comments

Comments
 (0)