THRIFT-2706 D library does not support "oneway" message type
Client: D
Patch: Konrad Grochowski
This closes #220
diff --git a/lib/d/src/thrift/codegen/client.d b/lib/d/src/thrift/codegen/client.d
index 9755ea8..09753da 100644
--- a/lib/d/src/thrift/codegen/client.d
+++ b/lib/d/src/thrift/codegen/client.d
@@ -184,8 +184,10 @@
"TPargsStruct!(Interface, `" ~ methodName ~ "`)";
code ~= paramStructType ~ " args = " ~ paramStructType ~ "();\n";
code ~= paramAssignCode;
- code ~= "oprot_.writeMessageBegin(TMessage(`" ~ methodName ~
- "`, TMessageType.CALL, ++seqid_));\n";
+ code ~= "oprot_.writeMessageBegin(TMessage(`" ~ methodName ~ "`, ";
+ code ~= ((methodMetaFound && methodMeta.type == TMethodType.ONEWAY)
+ ? "TMessageType.ONEWAY" : "TMessageType.CALL");
+ code ~= ", ++seqid_));\n";
code ~= "args.write(oprot_);\n";
code ~= "oprot_.writeMessageEnd();\n";
code ~= "oprot_.transport.flush();\n";
diff --git a/lib/d/src/thrift/protocol/compact.d b/lib/d/src/thrift/protocol/compact.d
index e03b67d..9155c81 100644
--- a/lib/d/src/thrift/protocol/compact.d
+++ b/lib/d/src/thrift/protocol/compact.d
@@ -133,8 +133,8 @@
void writeMessageBegin(TMessage msg) {
writeByte(cast(byte)PROTOCOL_ID);
- writeByte((VERSION_N & VERSION_MASK) |
- ((cast(int)msg.type << TYPE_SHIFT_AMOUNT) & TYPE_MASK));
+ writeByte(cast(byte)((VERSION_N & VERSION_MASK) |
+ ((cast(int)msg.type << TYPE_SHIFT_AMOUNT) & TYPE_MASK)));
writeVarint32(msg.seqid);
writeString(msg.name);
}
@@ -391,7 +391,7 @@
writeByte(cast(byte)(size << 4 | toCType(elemType)));
} else {
assert(size <= int.max);
- writeByte(0xf0 | toCType(elemType));
+ writeByte(cast(byte)(0xf0 | toCType(elemType)));
writeVarint32(cast(int)size);
}
}