[thrift] maps, lists, sets, and service inheritance for Erlang

Reviewed by: cpiro

Test Plan: tested wit tutorial/tutorial.thrift

Revert Plan: ok


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665175 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/tutorial/erl/server.erl b/tutorial/erl/server.erl
index c924589..0d5c1a9 100644
--- a/tutorial/erl/server.erl
+++ b/tutorial/erl/server.erl
@@ -9,34 +9,38 @@
 
 -include("calculator.hrl").
 
--export([start/0, stop/1, ping/0, add/2, calculate/2, getStruct/1, zip/0]).
+
+-export([start/0, start/1, stop/1, ping/0, add/2, calculate/2, getStruct/1, zip/0]).
 
 ping() ->
     io:format("ping()~n",[]),
-    {ok, nil}.
+    nil.
 
 add(N1, N2) ->
     io:format("add(~p,~p)~n",[N1,N2]),
-    {ok, N1+N2}.
+    N1+N2.
 
 calculate(Logid, Work) ->
     { Op, Num1, Num2 } = { Work#work.op, Work#work.num1, Work#work.num2 },
     io:format("calculate(~p, {~p,~p,~p})~n", [Logid, Op, Num1, Num2]),
     case Op of
-        ?ADD      -> {ok, Num1 + Num2};
-	?SUBTRACT -> {ok, Num1 - Num2};
-	?MULTIPLY -> {ok, Num1 * Num2};
-	?DIVIDE ->
-	    if 	Num2 == 0 -> {error, #invalidOperation{what=Op, why="Cannot divide by 0"}};
-		true      -> {ok, Num1 / Num2}
-	    end;
-	true ->
-	    {error, #invalidOperation{what=Op, why="Invalid operation"}}
+        ?tutorial_ADD      -> Num1 + Num2;
+	?tutorial_SUBTRACT -> Num1 - Num2;
+	?tutorial_MULTIPLY -> Num1 * Num2;
+
+	?tutorial_DIVIDE when Num2 == 0 ->
+	    throw(#invalidOperation{what=Op, why="Cannot divide by 0"});
+	?tutorial_DIVIDE ->
+	    Num1 div Num2;
+
+	_Else ->
+	    throw(#invalidOperation{what=Op, why="Invalid operation"})
+
     end.
 
 getStruct(Key) ->
     io:format("getStruct(~p)~n", [Key]),
-    {ok, get(Key)}.
+    #sharedStruct{key=Key, value="RARG"}.
 
 zip() ->
     io:format("zip~n").
@@ -44,9 +48,11 @@
 %%
 
 start() ->
-    Handler   = ?MODULE, % cpiro: or generated handler?
+    start(9090).
+
+start(Port) ->
+    Handler   = ?MODULE,
     Processor = calculator,
-    Port      = 9090,
 
     TF = tBufferedTransportFactory:new(),
     PF = tBinaryProtocolFactory:new(),
@@ -63,4 +69,3 @@
 stop(Server) ->
     ?C0(Server, stop),
     ok.
-
diff --git a/tutorial/rb/RubyClient.rb b/tutorial/rb/RubyClient.rb
index bcf1300..9ee6e79 100755
--- a/tutorial/rb/RubyClient.rb
+++ b/tutorial/rb/RubyClient.rb
@@ -2,27 +2,40 @@
 
 $:.push('../gen-rb')
 
-require 'thrift/transport/tsocket'
-require 'thrift/protocol/tbinaryprotocol'
+require 'thrift/transport/tsocket.rb'
+require 'thrift/protocol/tbinaryprotocol.rb'
 
 require 'Calculator'
 
 begin
+  port = ARGV[0] || 9090
   
-  transport = TBufferedTransport.new(TSocket.new('localhost', 9090))
+  transport = TBufferedTransport.new(TSocket.new('localhost', port))
   protocol = TBinaryProtocol.new(transport)
   client = Calculator::Client.new(protocol)
-  
+
   transport.open()
-  
+
   client.ping()
   print "ping()\n"
-  
+
   sum = client.add(1,1)
   print "1+1=", sum, "\n"
-  
+
+  sum = client.add(1,4)
+  print "1+4=", sum, "\n"
+
   work = Work.new()
-  
+
+  work.op = Operation::SUBTRACT
+  work.num1 = 15
+  work.num2 = 10
+  diff = client.calculate(1, work)
+  print "15-10=", diff, "\n"
+
+  log = client.getStruct(1)
+  print "Log: ", log.value, "\n"
+
   begin
     work.op = Operation::DIVIDE
     work.num1 = 1
@@ -32,16 +45,10 @@
   rescue InvalidOperation => io
     print "InvalidOperation: ", io.why, "\n"
   end
-  
-  work.op = Operation::SUBTRACT
-  work.num1 = 15
-  work.num2 = 10
-  diff = client.calculate(1, work)
-  print "15-10=", diff, "\n"
-  
-  log = client.getStruct(1)
-  print "Log: ", log.value, "\n"
-  
+
+  client.zip()
+  print "zip\n"
+
   transport.close()
 
 rescue TException => tx