[thrift] iolists and binaries in Erlang
Summary: three related changes:
* for numeric types in tBinaryProtocol call effectful_write with binary(), not [char()]
* tBinaryProtocol:writeString now takes either [char()], iolist(), or binary() ... now you can use any of the three where a Thrift string is required
* tBufferedTransport now buffers by building an iolist() rather than Buffer++Data. zomg.
Reviewed By: eletuchy
Test Plan: everything seems to work as usual, and binary() works as expected
Revert Plan: ok
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665447 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/erl/src/transport/tBufferedTransport.erl b/lib/erl/src/transport/tBufferedTransport.erl
index 18d9af9..2b3e0aa 100644
--- a/lib/erl/src/transport/tBufferedTransport.erl
+++ b/lib/erl/src/transport/tBufferedTransport.erl
@@ -72,9 +72,9 @@
Transport = oop:get(This, transport),
?R1(Transport, read, Sz).
-effectful_write(This, Buf) -> % be sure to rebind This to the retval
+effectful_write(This, Data) -> % be sure to rebind This to the retval
Wbuf = oop:get(This, wbuf),
- This1 = oop:set(This, wbuf, Wbuf++Buf), % TODO: ++ efficiency?
+ This1 = oop:set(This, wbuf, [Wbuf, Data]), % build an iolist()
{ok, This1}.
effectful_flush(This) ->
@@ -82,5 +82,5 @@
Transport = oop:get(This, transport),
?R1(Transport, effectful_write, Wbuf),
?R0(Transport, effectful_flush),
- This1 = oop:set(This, wbuf, ""),
+ This1 = oop:set(This, wbuf, []),
{ok, This1}.
diff --git a/lib/erl/src/transport/tSocket.erl b/lib/erl/src/transport/tSocket.erl
index 1792893..f23cdee 100644
--- a/lib/erl/src/transport/tSocket.erl
+++ b/lib/erl/src/transport/tSocket.erl
@@ -85,16 +85,10 @@
isOpen(This) ->
oop:get(This, handle) /= nil.
-effectful_write(This, Str) ->
+effectful_write(This, Data) ->
Handle = oop:get(This, handle),
- Val = gen_tcp:send(Handle, Str),
- %% DEBUG
- %% error_logger:info_msg("tSocket: wrote ~p~n", [Str]),
-
- %% error_logger:info_msg("WRITE |~p| (~p)", [Str,Val]),
-
- case Val of
+ case gen_tcp:send(Handle, Data) of
{error, _} ->
tException:throw(tTransportException, [?tTransportException_NOT_OPEN, "in write"]);
ok ->