[thrift] change up Erlang crash reports, cleanups in t{,Binary}Protocol
Summary: crash reports aren't too important so don't be so verbose -- all the pertinent info shows up elsewhere anyway. refactor while we're at it.
Reviewed By: eletuchy
Test Plan: ok
Revert Plan: ok
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665342 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/erl/src/protocol/tBinaryProtocol.erl b/lib/erl/src/protocol/tBinaryProtocol.erl
index 9430e39..207f305 100644
--- a/lib/erl/src/protocol/tBinaryProtocol.erl
+++ b/lib/erl/src/protocol/tBinaryProtocol.erl
@@ -1,6 +1,6 @@
%%% Copyright (c) 2007- Facebook
%%% Distributed under the Thrift Software License
-%%%
+%%%
%%% See accompanying file LICENSE or visit the Thrift site at:
%%% http://developers.facebook.com/thrift/
@@ -25,16 +25,16 @@
writeListBegin/3,
writeSetBegin/3,
- writeBool/2, writeByte/2, writeI16/2, writeI32/2,
- writeI64/2, writeDouble/2, writeString/2,
+ writeBool/2, writeByte/2, writeI16/2, writeI32/2,
+ writeI64/2, writeDouble/2, writeString/2,
- readMessageBegin/1,
- readFieldBegin/1,
- readMapBegin/1,
- readListBegin/1,
- readSetBegin/1,
+ readMessageBegin/1,
+ readFieldBegin/1,
+ readMapBegin/1,
+ readListBegin/1,
+ readSetBegin/1,
- readBool/1, readByte/1, readI16/1, readI32/1,
+ readBool/1, readByte/1, readI16/1, readI32/1,
readI64/1, readDouble/1, readString/1
]).
@@ -44,11 +44,11 @@
%%%
?DEFINE_ATTR(super).
-
+
%%%
%%% behavior callbacks
%%%
-
+
%%% super() -> SuperModule = atom()
%%% | none
@@ -106,9 +106,9 @@
%
writeBool(This, Bool) ->
- case Bool of
- true -> ?L1(writeByte, 1);
- false -> ?L1(writeByte, 0)
+ case Bool of
+ true -> ?L1(writeByte, 1);
+ false -> ?L1(writeByte, 0)
end.
writeByte(This, Byte) ->
@@ -140,11 +140,11 @@
readMessageBegin(This) ->
Version = ?L0(readI32),
- if
- (Version band ?VERSION_MASK) /= ?VERSION_1 ->
- throw(tProtocolException:new(?tProtocolException_BAD_VERSION,
- "Missing version identifier"));
- true -> ok
+ if
+ (Version band ?VERSION_MASK) /= ?VERSION_1 ->
+ throw(tProtocolException:new(?tProtocolException_BAD_VERSION,
+ "Missing version identifier"));
+ true -> ok
end,
Type = Version band 16#000000ff,
Name = ?L0(readString),
@@ -153,12 +153,12 @@
readFieldBegin(This) ->
Type = ?L0(readByte),
- case Type of
- ?tType_STOP ->
- { nil, Type, 0 }; % WATCH
- _ ->
- Id = ?L0(readI16),
- { nil, Type, Id }
+ case Type of
+ ?tType_STOP ->
+ { nil, Type, 0 }; % WATCH
+ _ ->
+ Id = ?L0(readI16),
+ { nil, Type, Id }
end.
readMapBegin(This) ->
diff --git a/lib/erl/src/protocol/tProtocol.erl b/lib/erl/src/protocol/tProtocol.erl
index 8900c5d..4ef67b8 100644
--- a/lib/erl/src/protocol/tProtocol.erl
+++ b/lib/erl/src/protocol/tProtocol.erl
@@ -1,6 +1,6 @@
%%% Copyright (c) 2007- Facebook
%%% Distributed under the Thrift Software License
-%%%
+%%%
%%% See accompanying file LICENSE or visit the Thrift site at:
%%% http://developers.facebook.com/thrift/
@@ -15,72 +15,30 @@
-export([attr/4, super/0, inspect/1]).
-%% -export([interface/1]). %%
-
-export([
- new/1,
- skip/2,
+ new/1,
+ skip/2,
- writeMessageBegin/4, writeMessageEnd/1,
- writeStructBegin/2, writeStructEnd/1,
- writeFieldBegin/4, writeFieldEnd/1, writeFieldStop/1,
- writeMapBegin/4, writeMapEnd/1,
- writeListBegin/3, writeListEnd/1,
- writeSetBegin/3, writeSetEnd/1,
+ writeMessageBegin/4, writeMessageEnd/1,
+ writeStructBegin/2, writeStructEnd/1,
+ writeFieldBegin/4, writeFieldEnd/1, writeFieldStop/1,
+ writeMapBegin/4, writeMapEnd/1,
+ writeListBegin/3, writeListEnd/1,
+ writeSetBegin/3, writeSetEnd/1,
- writeBool/2, writeByte/2, writeI16/2, writeI32/2,
- writeI64/2, writeDouble/2, writeString/2,
+ writeBool/2, writeByte/2, writeI16/2, writeI32/2,
+ writeI64/2, writeDouble/2, writeString/2,
- readMessageBegin/1, readMessageEnd/1,
- readStructBegin/1, readStructEnd/1,
- readFieldBegin/1, readFieldEnd/1,
- readMapBegin/1, readMapEnd/1,
- readListBegin/1, readListEnd/1,
- readSetBegin/1, readSetEnd/1,
+ readMessageBegin/1, readMessageEnd/1,
+ readStructBegin/1, readStructEnd/1,
+ readFieldBegin/1, readFieldEnd/1,
+ readMapBegin/1, readMapEnd/1,
+ readListBegin/1, readListEnd/1,
+ readSetBegin/1, readSetEnd/1,
- readBool/1, readByte/1, readI16/1, readI32/1,
- readI64/1, readDouble/1, readString/1
-]).
-
-%%%
-%%% server interface
-%%%
-
-%% %%% modules we can instantiate from the server %%
-%% interface(subclasses) -> %%
-%% [ %%
-%% tBinaryProtocol %%
-%% ]; %%
-%% %%
-%% %%% synchronous calls to pass %%
-%% interface(call) -> %%
-%% [ %%
-%% skip, %%
-%% %%
-%% writeMessageBegin, writeMessageEnd, %%
-%% writeStructBegin, writeStructEnd, %%
-%% writeFieldBegin, writeFieldEnd, writeFieldStop, %%
-%% writeMapBegin, writeMapEnd, %%
-%% writeListBegin, writeListEnd, %%
-%% writeSetBegin, writeSetEnd, %%
-%% %%
-%% writeBool, writeByte, writeI16, writeI32, %%
-%% writeI64, writeDouble, writeString, %%
-%% %%
-%% readMessageBegin, readMessageEnd, %%
-%% readStructBegin, readStructEnd, %%
-%% readFieldBegin, readFieldEnd, %%
-%% readMapBegin, readMapEnd, %%
-%% readListBegin, readListEnd, %%
-%% readSetBegin, readSetEnd, %%
-%% %%
-%% readBool, readByte, readI16, readI32, %%
-%% readI64, readDouble, readString %%
-%% ]; %%
-%% %%
-%% %%% asynchronous casts to pass %%
-%% interface(cast) -> %%
-%% []. %%
+ readBool/1, readByte/1, readI16/1, readI32/1,
+ readI64/1, readDouble/1, readString/1
+ ]).
%%%
%%% define attributes
@@ -88,11 +46,11 @@
%%%
?DEFINE_ATTR(trans).
-
+
%%%
%%% behavior callbacks
%%%
-
+
%%% super() -> SuperModule = atom()
%%% | none
@@ -159,54 +117,54 @@
readString(_This) -> ok.
skip(This, Type) ->
- case Type of
- ?tType_STOP -> nil; % WATCH
- ?tType_BOOL -> ?L0(readBool);
- ?tType_BYTE -> ?L0(readByte);
- ?tType_I16 -> ?L0(readI16);
- ?tType_I32 -> ?L0(readI32);
- ?tType_I64 -> ?L0(readI64);
- ?tType_DOUBLE -> ?L0(readDouble);
- ?tType_STRING -> ?L0(readString);
+ case Type of
+ ?tType_STOP -> nil; % WATCH
+ ?tType_BOOL -> ?L0(readBool);
+ ?tType_BYTE -> ?L0(readByte);
+ ?tType_I16 -> ?L0(readI16);
+ ?tType_I32 -> ?L0(readI32);
+ ?tType_I64 -> ?L0(readI64);
+ ?tType_DOUBLE -> ?L0(readDouble);
+ ?tType_STRING -> ?L0(readString);
- ?tType_STRUCT ->
- ?L0(readStructBegin),
- skip_struct_loop(This),
+ ?tType_STRUCT ->
+ ?L0(readStructBegin),
+ skip_struct_loop(This),
- %% cpiro: this isn't here in the original tprotocol.rb, but i think it's a bug
- ?L0(readStructEnd);
+ %% cpiro: this isn't here in the original tprotocol.rb, but i think it's a bug
+ ?L0(readStructEnd);
- ?tType_MAP ->
- {Ktype, Vtype, Size} = ?L0(readMapBegin),
- skip_map_repeat(This, Ktype, Vtype, Size),
- ?L0(readMapEnd);
+ ?tType_MAP ->
+ {Ktype, Vtype, Size} = ?L0(readMapBegin),
+ skip_map_repeat(This, Ktype, Vtype, Size),
+ ?L0(readMapEnd);
- ?tType_SET ->
- {Etype, Size} = ?L0(readSetBegin),
- skip_set_repeat(This, Etype, Size),
- ?L0(readSetEnd);
+ ?tType_SET ->
+ {Etype, Size} = ?L0(readSetBegin),
+ skip_set_repeat(This, Etype, Size),
+ ?L0(readSetEnd);
- ?tType_LIST ->
- {Etype, Size} = ?L0(readListBegin),
- skip_set_repeat(This, Etype, Size), % [sic] skipping same as for SET
- ?L0(readListEnd)
+ ?tType_LIST ->
+ {Etype, Size} = ?L0(readListBegin),
+ skip_set_repeat(This, Etype, Size), % [sic] skipping same as for SET
+ ?L0(readListEnd)
end.
skip_struct_loop(This) ->
{ _Name, Type, _Id } = ?L0(readFieldBegin),
if
- Type == ?tType_STOP ->
- ok;
-
- true ->
- ?L1(skip, Type),
- ?L0(readFieldEnd),
+ Type == ?tType_STOP ->
+ ok;
- %% cpiro: this is here in original tprotocol.rb, but i think it's a bug
- % ?L0(readStructEnd),
- skip_struct_loop(This)
+ true ->
+ ?L1(skip, Type),
+ ?L0(readFieldEnd),
+
+ %% cpiro: this is here in original tprotocol.rb, but i think it's a bug
+ %% ?L0(readStructEnd),
+ skip_struct_loop(This)
end.
-
+
skip_map_repeat(This, Ktype, Vtype, Times) ->
?L1(skip, Ktype),
?L1(skip, Vtype),