Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix the erlang tutorial

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1071148 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit 10a8743f6a7bc2faefb39ba476f508ddcf62a068 1 parent b005c1f
Anthony F. Molinaro authored
4 tutorial/erl/client.erl
View
@@ -44,7 +44,7 @@ t() ->
{Client3, {ok, Sum1}} = thrift_client:call(Client2, add, [1, 4]),
io:format("1+4=~p~n", [Sum1]),
- Work = #work{op=?tutorial_SUBTRACT,
+ Work = #work{op=?tutorial_Operation_SUBTRACT,
num1=15,
num2=10},
{Client4, {ok, Diff}} = thrift_client:call(Client3, calculate, [1, Work]),
@@ -55,7 +55,7 @@ t() ->
Client6 =
try
- Work1 = #work{op=?tutorial_DIVIDE,
+ Work1 = #work{op=?tutorial_Operation_DIVIDE,
num1=1,
num2=0},
{ClientS1, {ok, _Quot}} = thrift_client:call(Client5, calculate, [2, Work1]),
18 tutorial/erl/server.erl
View
@@ -39,17 +39,17 @@ calculate(Logid, Work) ->
{ Op, Num1, Num2 } = { Work#work.op, Work#work.num1, Work#work.num2 },
debug("calculate(~p, {~p,~p,~p})", [Logid, Op, Num1, Num2]),
case Op of
- ?tutorial_ADD -> Num1 + Num2;
- ?tutorial_SUBTRACT -> Num1 - Num2;
- ?tutorial_MULTIPLY -> Num1 * Num2;
+ ?tutorial_Operation_ADD -> Num1 + Num2;
+ ?tutorial_Operation_SUBTRACT -> Num1 - Num2;
+ ?tutorial_Operation_MULTIPLY -> Num1 * Num2;
- ?tutorial_DIVIDE when Num2 == 0 ->
- throw(#invalidOperation{what=Op, why="Cannot divide by 0"});
- ?tutorial_DIVIDE ->
- Num1 div Num2;
+ ?tutorial_Operation_DIVIDE when Num2 == 0 ->
+ throw(#invalidOperation{what=Op, why="Cannot divide by 0"});
+ ?tutorial_Operation_DIVIDE ->
+ Num1 div Num2;
- _Else ->
- throw(#invalidOperation{what=Op, why="Invalid operation"})
+ _Else ->
+ throw(#invalidOperation{what=Op, why="Invalid operation"})
end.
getStruct(Key) ->
12 tutorial/erl/server.sh
View
@@ -26,12 +26,12 @@ if ! [ -d ${ERL_THRIFT}/ebin ]; then
exit 1
fi
-if ! [ -d ../gen-erl ]; then
- echo "Please run thrift first to generate ../gen-erl/"
- exit 1
+if ! [ -d gen-erl ]; then
+ ../../compiler/cpp/thrift -r --gen erl ../tutorial.thrift
fi
-erlc -I ${ERL_THRIFT}/include -I ../gen-erl -o ../gen-erl ../gen-erl/*.erl &&
- erlc -I ${ERL_THRIFT}/include -I ../gen-erl *.erl &&
- erl +K true -pa ${ERL_THRIFT}/ebin -pa ../gen-erl
+erlc -I ${ERL_THRIFT}/include -I ${ERL_THRIFT}/ebin \
+ -I gen-erl -o gen-erl gen-erl/*.erl &&
+ erlc -I ${ERL_THRIFT}/include -I gen-erl *.erl &&
+ erl +K true -pa ${ERL_THRIFT}/ebin -pa gen-erl
Please sign in to comment.
Something went wrong with that request. Please try again.