From 480d5ab62b6fa320a0f098575020b3cae08a3f14 Mon Sep 17 00:00:00 2001 From: David Reiss Date: Mon, 30 Aug 2010 22:05:26 +0000 Subject: [PATCH] erlang: Separate out thrift_protocol:read_specific By giving a different name to the function that reads from the protocol implementation, we can get a slightly more enforcible spec. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@990977 13f79535-47bb-0310-9956-ffa450edef68 --- lib/erl/include/thrift_protocol_impl.hrl | 2 +- lib/erl/src/thrift_protocol.erl | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/erl/include/thrift_protocol_impl.hrl b/lib/erl/include/thrift_protocol_impl.hrl index 92f3a003..ae0f0f7f 100644 --- a/lib/erl/include/thrift_protocol_impl.hrl +++ b/lib/erl/include/thrift_protocol_impl.hrl @@ -27,7 +27,7 @@ -spec write(state(), term()) -> ok | {error, _Reason}. -%% NOTE: Keep this in sync with thrift_protocol:read. +%% NOTE: Keep this in sync with thrift_protocol:read and read_specific. -spec read (state(), tprot_empty_tag()) -> ok | {error, _Reason}; (state(), tprot_header_tag()) -> tprot_header_val() | {error, _Reason}; diff --git a/lib/erl/src/thrift_protocol.erl b/lib/erl/src/thrift_protocol.erl index a207bca5..3da526cd 100644 --- a/lib/erl/src/thrift_protocol.erl +++ b/lib/erl/src/thrift_protocol.erl @@ -158,8 +158,16 @@ read(IProto, {set, Type}) -> ok = read(IProto, set_end), {ok, sets:from_list(List)}; -read(#protocol{module = Module, - data = ModuleData}, ProtocolType) -> +read(Protocol, ProtocolType) -> + read_specific(Protocol, ProtocolType). + +%% NOTE: Keep this in sync with thrift_protocol_impl:read +-spec read_specific + (#protocol{}, tprot_empty_tag()) -> ok | {error, _Reason}; + (#protocol{}, tprot_header_tag()) -> tprot_header_val() | {error, _Reason}; + (#protocol{}, tprot_data_tag()) -> {ok, term()} | {error, _Reason}. +read_specific(#protocol{module = Module, + data = ModuleData}, ProtocolType) -> Module:read(ModuleData, ProtocolType). read_struct_loop(IProto, SDict, RTuple) -> -- 2.17.1