summaryrefslogtreecommitdiff
path: root/compiler/cpp/src/generate/t_hs_generator.cc
diff options
context:
space:
mode:
authorNobuaki Sukegawa <nsuke@apache.org>2015-12-13 21:45:39 +0900
committerNobuaki Sukegawa <nsuke@apache.org>2015-12-13 23:48:22 +0900
commite68ccc23bebde961767e47e6751dcf764b8503f2 (patch)
tree9112b830eedaffd1fc1c22cb14f2504a5bd42a6d /compiler/cpp/src/generate/t_hs_generator.cc
parentef2b5285f3be08e52000a60d3de2e2f8a30f892b (diff)
downloadthrift-e68ccc23bebde961767e47e6751dcf764b8503f2.tar.gz
THRIFT-3482 Haskell JSON protocol does not encode binary field as Base64
Diffstat (limited to 'compiler/cpp/src/generate/t_hs_generator.cc')
-rw-r--r--compiler/cpp/src/generate/t_hs_generator.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/cpp/src/generate/t_hs_generator.cc b/compiler/cpp/src/generate/t_hs_generator.cc
index d2867ea80..247c9a888 100644
--- a/compiler/cpp/src/generate/t_hs_generator.cc
+++ b/compiler/cpp/src/generate/t_hs_generator.cc
@@ -1367,6 +1367,11 @@ void t_hs_generator::generate_deserialize_type(ofstream& out, t_type* type, stri
out << "E.decodeUtf8 ";
}
out << val;
+ if (((t_base_type*)type)->is_binary()) {
+ // Since wire type of binary is the same as string, we actually receive T.TString not
+ // T.TBinary
+ out << "; T.TString " << val << " -> " << val;
+ }
} else if (type->is_enum()) {
out << "P.toEnum $ P.fromIntegral " << val;
@@ -1539,7 +1544,7 @@ string t_hs_generator::type_to_enum(t_type* type) {
case t_base_type::TYPE_VOID:
return "T.T_VOID";
case t_base_type::TYPE_STRING:
- return "T.T_STRING";
+ return ((t_base_type*)type)->is_binary() ? "T.T_BINARY" : "T.T_STRING";
case t_base_type::TYPE_BOOL:
return "T.T_BOOL";
case t_base_type::TYPE_I8:
@@ -1687,7 +1692,7 @@ string t_hs_generator::type_to_constructor(t_type* type) {
case t_base_type::TYPE_VOID:
throw "invalid type: T_VOID";
case t_base_type::TYPE_STRING:
- return "T.TString";
+ return ((t_base_type*)type)->is_binary() ? "T.TBinary" : "T.TString";
case t_base_type::TYPE_BOOL:
return "T.TBool";
case t_base_type::TYPE_I8: