[thrift] whole ball of whitespace normalizations in Erlang
Summary: ill-formatted comments, trailing whitespace, and (gasp) tabs: all pwned. better now than later.
Reviewed By: eletuchy
Test Plan: ok
Revert Plan: ok
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665339 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/erl/include/thrift.hrl b/lib/erl/include/thrift.hrl
index 395d45e..4bc994e 100644
--- a/lib/erl/include/thrift.hrl
+++ b/lib/erl/include/thrift.hrl
@@ -5,10 +5,10 @@
%%% http://developers.facebook.com/thrift/
-define(ERROR(F, D),
- error_logger:format(F, D)).
+ error_logger:format(F, D)).
-define(INFO(F, D),
- error_logger:info_msg(F, D)).
+ error_logger:info_msg(F, D)).
-include("thrift_macros.hrl").
-include("thrift_constants.hrl").
diff --git a/lib/erl/src/thrift_oop_server.erl b/lib/erl/src/thrift_oop_server.erl
index 57c4772..052578c 100644
--- a/lib/erl/src/thrift_oop_server.erl
+++ b/lib/erl/src/thrift_oop_server.erl
@@ -1,11 +1,11 @@
%%% 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/
%%%-------------------------------------------------------------------
-%%% @doc
+%%% @doc
%%% @end
%%%-------------------------------------------------------------------
-module(thrift_oop_server).
@@ -22,9 +22,9 @@
%% External exports
%%--------------------------------------------------------------------
-export([
- start_link/0,
- stop/0
- ]).
+ start_link/0,
+ stop/0
+ ]).
%%--------------------------------------------------------------------
%% gen_server callbacks
@@ -75,11 +75,11 @@
init({Class, Args}) ->
process_flag(trap_exit, true),
try
- State = apply(Class, new, Args),
- ?INFO("thrift ~p:new(~s) = ~s", [Class, thrift_utils:unbrack(Args), oop:inspect(State)]),
- {ok, State}
+ State = apply(Class, new, Args),
+ ?INFO("thrift ~p:new(~s) = ~s", [Class, thrift_utils:unbrack(Args), oop:inspect(State)]),
+ {ok, State}
catch
- E -> {stop, {new_failed, E}}
+ E -> {stop, {new_failed, E}}
end;
init(_) ->
@@ -114,57 +114,57 @@
handle_either(cast, {Method, Args}, undefined, State).
-define(REPLY(Value, State),
- case Type of
- call -> {reply, Value, State};
- cast -> {noreply, State}
- end
-).
+ case Type of
+ call -> {reply, Value, State};
+ cast -> {noreply, State}
+ end
+).
handle_either(Type, Request, From, State) ->
%% error_logger:info_msg("~p: ~p", [?SERVER, oop:inspect(State)]),
%% error_logger:info_msg("handle_call(Request=~p, From=~p, State)", [Request, From]),
- case Request of
- {get, [Field]} ->
- Value = oop:get(State, Field),
- ?REPLY(Value, State);
+ case Request of
+ {get, [Field]} ->
+ Value = oop:get(State, Field),
+ ?REPLY(Value, State);
- {set, [Field, Value]} ->
- State1 = oop:set(State, Field, Value),
- ?REPLY(Value, State1);
+ {set, [Field, Value]} ->
+ State1 = oop:set(State, Field, Value),
+ ?REPLY(Value, State1);
- {class, []} ->
- ?REPLY(?CLASS(State), State);
+ {class, []} ->
+ ?REPLY(?CLASS(State), State);
- {Method, Args} ->
- handle_method(Type, State, Method, Args);
+ {Method, Args} ->
+ handle_method(Type, State, Method, Args);
- _ ->
- error_logger:format("no match for Request = ~p", [Request]),
- %% {stop, server_error, State}
- {reply, server_error, State}
+ _ ->
+ error_logger:format("no match for Request = ~p", [Request]),
+ %% {stop, server_error, State}
+ {reply, server_error, State}
end.
handle_method(Type, State, Method, Args) ->
%% is an effectful call?
Is_effectful = lists:prefix("effectful_", atom_to_list(Method)),
Call = oop:call(State, Method, Args),
-
+
%% TODO(cpiro): maybe add error handling here? = catch oop:call?
-
- case {Is_effectful, Call} of
- {true, {Retval, State1}} ->
- ?REPLY(Retval, State1);
-
- {true, _MalformedReturn} ->
- %% TODO(cpiro): bad match -- remove when we're done converting
- error_logger:format("oop:call(effectful_*,..,..) malformed return value ~p",
- [_MalformedReturn]),
- %% {stop, server_error, State}
- {noreply, State};
-
- {false, Retval} ->
- ?REPLY(Retval, State)
+
+ case {Is_effectful, Call} of
+ {true, {Retval, State1}} ->
+ ?REPLY(Retval, State1);
+
+ {true, _MalformedReturn} ->
+ %% TODO(cpiro): bad match -- remove when we're done converting
+ error_logger:format("oop:call(effectful_*,..,..) malformed return value ~p",
+ [_MalformedReturn]),
+ %% {stop, server_error, State}
+ {noreply, State};
+
+ {false, Retval} ->
+ ?REPLY(Retval, State)
end.
%%--------------------------------------------------------------------
@@ -176,18 +176,18 @@
%%--------------------------------------------------------------------
handle_info({'EXIT', Pid, Except} = All, State) ->
Result = try
- oop:call(State, catches, [Pid, Except])
+ oop:call(State, catches, [Pid, Except])
catch
- exit:{missing_method, _} ->
- unhandled
+ exit:{missing_method, _} ->
+ unhandled
end,
case Result of
- unhandled ->
- error_logger:format("unhandled exit ~p", [All]),
- {stop, All, State};
- _WasHandled ->
- {noreply, State}
+ unhandled ->
+ error_logger:format("unhandled exit ~p", [All]),
+ {stop, All, State};
+ _WasHandled ->
+ {noreply, State}
end;
handle_info(Info, State) ->
diff --git a/lib/erl/src/transport/tBufferedTransportFactory.erl b/lib/erl/src/transport/tBufferedTransportFactory.erl
index 5bc5012..de2570e 100644
--- a/lib/erl/src/transport/tBufferedTransportFactory.erl
+++ b/lib/erl/src/transport/tBufferedTransportFactory.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/
@@ -26,7 +26,7 @@
%%%
%%% behavior callbacks
%%%
-
+
%%% super() -> SuperModule = atom()
%%% | none
diff --git a/lib/erl/src/transport/tErlAcceptor.erl b/lib/erl/src/transport/tErlAcceptor.erl
index 7586f60..8398924 100644
--- a/lib/erl/src/transport/tErlAcceptor.erl
+++ b/lib/erl/src/transport/tErlAcceptor.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/
@@ -30,11 +30,11 @@
?DEFINE_ATTR(serverPid);
?DEFINE_ATTR(transportFactory);
?DEFINE_ATTR(protocolFactory).
-
+
%%%
%%% behavior callbacks
%%%
-
+
%%% super() -> SuperModule = atom()
%%% | none
@@ -54,11 +54,11 @@
new(ServerPid, TF, PF) ->
Super = (super()):new(),
- #?MODULE{super = Super,
- serverPid = ServerPid,
- transportFactory = TF,
- protocolFactory = PF
- }.
+ #?MODULE{super = Super,
+ serverPid = ServerPid,
+ transportFactory = TF,
+ protocolFactory = PF
+ }.
%%%
%%% instance methods
@@ -68,66 +68,66 @@
ServerPid = oop:get(This, serverPid),
case catch gen_tcp:accept(ListenSocket) of
- {ok, Socket} ->
- ?C0(ServerPid, effectful_new_acceptor), %% cast to create new acceptor
+ {ok, Socket} ->
+ ?C0(ServerPid, effectful_new_acceptor), %% cast to create new acceptor
- AddrString = render_addr(Socket),
- ?INFO("thrift connection accepted from ~s", [AddrString]),
+ AddrString = render_addr(Socket),
+ ?INFO("thrift connection accepted from ~s", [AddrString]),
- %% start_new(tSocket, [])
- Client = oop:start_new(tSocket, []),
- ?R1(Client, effectful_setHandle, Socket), %% TODO(cpiro): should we just let this be a param to the constructor?
+ %% start_new(tSocket, [])
+ Client = oop:start_new(tSocket, []),
+ ?R1(Client, effectful_setHandle, Socket), %% TODO(cpiro): should we just let this be a param to the constructor?
- %% cpiro: OPAQUE!! Trans = Client
- TF = oop:get(This, transportFactory),
- Trans = ?F1(TF, getTransport, Client),
+ %% cpiro: OPAQUE!! Trans = Client
+ TF = oop:get(This, transportFactory),
+ Trans = ?F1(TF, getTransport, Client),
- %% cpiro: OPAQUE!! Prot = start_new(tBinaryProtocol, [Trans])
- PF = oop:get(This, protocolFactory),
- Prot = ?F1(PF, getProtocol, Trans),
+ %% cpiro: OPAQUE!! Prot = start_new(tBinaryProtocol, [Trans])
+ PF = oop:get(This, protocolFactory),
+ Prot = ?F1(PF, getProtocol, Trans),
- %% start_new(, ...)
- Processor = oop:start_new(tErlProcessor, [GP, Handler]), %% TODO
+ %% start_new(, ...)
+ Processor = oop:start_new(tErlProcessor, [GP, Handler]), %% TODO
- case receive_loop(This, Processor, Prot, Prot) of
- conn_timeout ->
- ?INFO("thrift connection timed out from ~s", [AddrString]);
- conn_closed ->
- ?INFO("thrift connection closed from ~s", [AddrString]);
- {Class, Else} ->
- ?ERROR("unhandled ~p in tErlAcceptor: ~p", [Class, Else])
- end,
- exit(normal);
+ case receive_loop(This, Processor, Prot, Prot) of
+ conn_timeout ->
+ ?INFO("thrift connection timed out from ~s", [AddrString]);
+ conn_closed ->
+ ?INFO("thrift connection closed from ~s", [AddrString]);
+ {Class, Else} ->
+ ?ERROR("unhandled ~p in tErlAcceptor: ~p", [Class, Else])
+ end,
+ exit(normal);
- Else ->
- R = thrift_utils:sformat("accept() failed: ~p", [Else]),
- exit(tTransportException:new(R))
+ Else ->
+ R = thrift_utils:sformat("accept() failed: ~p", [Else]),
+ exit(tTransportException:new(R))
end.
receive_loop(This, Processor, Iprot, Oprot) ->
try ?R2(Processor, process, Iprot, Oprot) of
- {error, TAE} when is_record(TAE, tApplicationException),
- TAE#tApplicationException.type == ?tApplicationException_HANDLER_ERROR ->
- ?ERROR("thrift handler returned an error: ~p", [oop:get(TAE, message)]),
- receive_loop(This, Processor, Iprot, Oprot);
- Value ->
- ?INFO("thrift request: ~p", [Value]),
- receive_loop(This, Processor, Iprot, Oprot)
+ {error, TAE} when is_record(TAE, tApplicationException),
+ TAE#tApplicationException.type == ?tApplicationException_HANDLER_ERROR ->
+ ?ERROR("thrift handler returned an error: ~p", [oop:get(TAE, message)]),
+ receive_loop(This, Processor, Iprot, Oprot);
+ Value ->
+ ?INFO("thrift request: ~p", [Value]),
+ receive_loop(This, Processor, Iprot, Oprot)
catch
- exit:{timeout, _} ->
- conn_timeout;
+ exit:{timeout, _} ->
+ conn_timeout;
- %% the following clause must be last
- %% cpiro: would be best to implement an is_a/2 guard BIF
- %% cpiro: breaks if it's a subclass of tTransportException
- %% since unnest_record knows nothing about oop
- Class:Else ->
- case thrift_utils:unnest_record(Else, tTransportException) of
- {ok, TTE} when TTE#tTransportException.type == ?tTransportException_NOT_OPEN ->
- conn_closed;
- _ ->
- {Class, Else}
- end
+ %% the following clause must be last
+ %% cpiro: would be best to implement an is_a/2 guard BIF
+ %% cpiro: breaks if it's a subclass of tTransportException
+ %% since unnest_record knows nothing about oop
+ Class:Else ->
+ case thrift_utils:unnest_record(Else, tTransportException) of
+ {ok, TTE} when TTE#tTransportException.type == ?tTransportException_NOT_OPEN ->
+ conn_closed;
+ _ ->
+ {Class, Else}
+ end
end.
%% helper functions
@@ -140,14 +140,14 @@
{ok, {Peer, Port}} = inet:peername(Socket),
case Peer of
- _ when DoLookup ->
- case catch inet:gethostbyaddr(Peer) of
- {ok, Hostent} ->
- thrift_utils:sformat("~s:~p", [Hostent#hostent.h_name, Port]);
- _ ->
- "??"
- end;
+ _ when DoLookup ->
+ case catch inet:gethostbyaddr(Peer) of
+ {ok, Hostent} ->
+ thrift_utils:sformat("~s:~p", [Hostent#hostent.h_name, Port]);
+ _ ->
+ "??"
+ end;
- {A,B,C,D} when not DoLookup ->
- thrift_utils:sformat("~p.~p.~p.~p:~p", [A,B,C,D,Port])
+ {A,B,C,D} when not DoLookup ->
+ thrift_utils:sformat("~p.~p.~p.~p:~p", [A,B,C,D,Port])
end.
diff --git a/lib/erl/src/transport/tServerSocket.erl b/lib/erl/src/transport/tServerSocket.erl
index d0cbf92..76257c1 100644
--- a/lib/erl/src/transport/tServerSocket.erl
+++ b/lib/erl/src/transport/tServerSocket.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/
@@ -24,11 +24,11 @@
?DEFINE_ATTR(super);
?DEFINE_ATTR(port);
?DEFINE_ATTR(handle).
-
+
%%%
%%% behavior callbacks
%%%
-
+
%%% super() -> SuperModule = atom()
%%% | none
@@ -57,40 +57,40 @@
Port = oop:get(This, port),
Options = [binary, {packet, 0}, {active, false}], % was []
- case gen_tcp:listen(Port, Options) of
- {ok, ListenSocket} ->
- This1 = oop:set(This, handle, ListenSocket),
- {ok, This1}
-
- % {error, _} ->
- % TODO: no error handling in Ruby version?
+ case gen_tcp:listen(Port, Options) of
+ {ok, ListenSocket} ->
+ This1 = oop:set(This, handle, ListenSocket),
+ {ok, This1}
+
+ %% {error, _} ->
+ %% TODO: no error handling in Ruby version?
end.
accept(This) ->
- case oop:get(This, handle) of
- nil ->
- nil; % cpiro: sic the Ruby code
+ case oop:get(This, handle) of
+ nil ->
+ nil; % cpiro: sic the Ruby code
- Handle ->
- case gen_tcp:accept(Handle) of
- {ok, Sock} ->
- Trans = oop:start_new(tSocket, []),
- ?R1(Trans, effectful_setHandle, Sock),
- Trans
- % {error, _} ->
- % TODO: no error handling in Ruby version?
- end
+ Handle ->
+ case gen_tcp:accept(Handle) of
+ {ok, Sock} ->
+ Trans = oop:start_new(tSocket, []),
+ ?R1(Trans, effectful_setHandle, Sock),
+ Trans
+ %% {error, _} ->
+ %% TODO: no error handling in Ruby version?
+ end
end.
effectful_close(This) ->
- case oop:get(This, handle) of
- nil ->
- {nil, This};
- Handle ->
- case gen_tcp:close(Handle) of
- ok ->
- {ok, This} % cpiro: sic the Ruby version: don't set handle to nil
- % {error, _} ->
- % TODO: no error handling in Ruby version?
- end
+ case oop:get(This, handle) of
+ nil ->
+ {nil, This};
+ Handle ->
+ case gen_tcp:close(Handle) of
+ ok ->
+ {ok, This} % cpiro: sic the Ruby version: don't set handle to nil
+ %% {error, _} ->
+ %% TODO: no error handling in Ruby version?
+ end
end.
diff --git a/lib/erl/src/transport/tServerTransport.erl b/lib/erl/src/transport/tServerTransport.erl
index dfc9ccb..f007d54 100644
--- a/lib/erl/src/transport/tServerTransport.erl
+++ b/lib/erl/src/transport/tServerTransport.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,7 +25,7 @@
%%%
%%% behavior callbacks
%%%
-
+
%%% super() -> SuperModule = atom()
%%% | none
diff --git a/lib/erl/src/transport/tTransportException.erl b/lib/erl/src/transport/tTransportException.erl
index 43a7afa..b7dc43d 100644
--- a/lib/erl/src/transport/tTransportException.erl
+++ b/lib/erl/src/transport/tTransportException.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/
@@ -24,11 +24,11 @@
?DEFINE_ATTR(super);
?DEFINE_ATTR(type).
-
+
%%%
%%% behavior callbacks
%%%
-
+
%%% super() -> SuperModule = atom()
%%% | none
diff --git a/lib/erl/src/transport/tTransportFactory.erl b/lib/erl/src/transport/tTransportFactory.erl
index 1c8ca61..77a9e01 100644
--- a/lib/erl/src/transport/tTransportFactory.erl
+++ b/lib/erl/src/transport/tTransportFactory.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,7 +25,7 @@
%%%
%%% behavior callbacks
%%%
-
+
%%% super() -> SuperModule = atom()
%%% | none