erlang: Add some initial specs to thrift_client and thrift_protocol
Also add a special header for use in thrift_protocol implementations
that gives specs for the callbacks.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@990972 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/erl/src/thrift_protocol.erl b/lib/erl/src/thrift_protocol.erl
index 1bfb0a4..3ccb4ee 100644
--- a/lib/erl/src/thrift_protocol.erl
+++ b/lib/erl/src/thrift_protocol.erl
@@ -49,10 +49,12 @@
{ok, #protocol{module = Module,
data = Data}}.
+-spec flush_transport(#protocol{}) -> ok.
flush_transport(#protocol{module = Module,
data = Data}) ->
Module:flush_transport(Data).
+-spec close_transport(#protocol{}) -> ok.
close_transport(#protocol{module = Module,
data = Data}) ->
Module:close_transport(Data).
@@ -86,6 +88,7 @@
%% Structure is like:
%% [{Fid, Type}, ...]
+-spec read(#protocol{}, {struct, _StructDef}, atom()) -> {ok, tuple()}.
read(IProto, {struct, Structure}, Tag)
when is_list(Structure), is_atom(Tag) ->
@@ -112,6 +115,8 @@
RTuple2 = read_struct_loop(IProto, SDict, RTuple1),
{ok, RTuple2}.
+-spec read(#protocol{}, term()) -> term().
+
read(IProto, {struct, {Module, StructureName}}) when is_atom(Module),
is_atom(StructureName) ->
read(IProto, Module:struct_info(StructureName), StructureName);
@@ -183,6 +188,7 @@
read(IProto, field_end),
read_struct_loop(IProto, SDict, RTuple).
+-spec skip(#protocol{}, term()) -> ok.
skip(Proto, struct) ->
ok = read(Proto, struct_begin),
@@ -271,6 +277,8 @@
%%
%% Description:
%%--------------------------------------------------------------------
+-spec write(#protocol{}, term()) -> ok | {error, _Reason}.
+
write(Proto, {{struct, StructDef}, Data})
when is_list(StructDef), is_tuple(Data), length(StructDef) == size(Data) - 1 ->