Skip to content

Commit

Permalink
Eliminate redundant 'Elixir.' prefixes (#515)
Browse files Browse the repository at this point in the history
Minor refactor for readability of compiled code.
  • Loading branch information
pguillory committed Oct 19, 2020
1 parent d6bfeea commit 8e9aec6
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 49 deletions.
48 changes: 15 additions & 33 deletions example/lib/calculator/generated/service.ex

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/lib/calculator/generated/vector_product_result.ex

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions lib/thrift/generator/binary/framed/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ defmodule Thrift.Generator.Binary.Framed.Server do

quote do
def handle_thrift(unquote(fn_name), binary_data, handler_module) do
case unquote(args_module).BinaryProtocol.deserialize(binary_data) do
case unquote(Module.concat(args_module, BinaryProtocol)).deserialize(binary_data) do
{%unquote(args_module){unquote_splicing(struct_matches)}, ""} ->
unquote(build_handler_call(file_group, function, response_module))

Expand Down Expand Up @@ -92,7 +92,9 @@ defmodule Thrift.Generator.Binary.Framed.Server do
quote do
:error, %unquote(dest_module){} = unquote(error_var) ->
response = %unquote(response_module){unquote(field_setter)}
{:reply, unquote(response_module).BinaryProtocol.serialize(response)}

{:reply,
unquote(Module.concat(response_module, BinaryProtocol)).serialize(response)}
end
end)

Expand Down Expand Up @@ -132,7 +134,7 @@ defmodule Thrift.Generator.Binary.Framed.Server do
quote do
result = handler_module.unquote(handler_fn_name)(unquote_splicing(handler_args))
response = %unquote(response_module){success: result}
{:reply, unquote(response_module).BinaryProtocol.serialize(response)}
{:reply, unquote(Module.concat(response_module, BinaryProtocol)).serialize(response)}
end
end
end
24 changes: 12 additions & 12 deletions lib/thrift/generator/struct_binary_protocol.ex
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ defmodule Thrift.Generator.StructBinaryProtocol do
<<unquote(Type.struct()), unquote(field.id)::16-signed, rest::binary>>,
acc
) do
case unquote(dest_module).BinaryProtocol.deserialize(rest) do
case unquote(Module.concat(dest_module, BinaryProtocol)).deserialize(rest) do
{value, rest} ->
unquote(name)(rest, %{acc | unquote(field.name) => value})

Expand All @@ -241,7 +241,7 @@ defmodule Thrift.Generator.StructBinaryProtocol do
<<unquote(Type.struct()), unquote(field.id)::16-signed, rest::binary>>,
acc
) do
case unquote(dest_module).BinaryProtocol.deserialize(rest) do
case unquote(Module.concat(dest_module, BinaryProtocol)).deserialize(rest) do
{value, rest} ->
unquote(name)(rest, %{acc | unquote(field.name) => value})

Expand All @@ -260,7 +260,7 @@ defmodule Thrift.Generator.StructBinaryProtocol do
<<unquote(Type.struct()), unquote(field.id)::16-signed, rest::binary>>,
acc
) do
case unquote(dest_module).BinaryProtocol.deserialize(rest) do
case unquote(Module.concat(dest_module, BinaryProtocol)).deserialize(rest) do
{value, rest} ->
unquote(name)(rest, %{acc | unquote(field.name) => value})

Expand Down Expand Up @@ -435,7 +435,7 @@ defmodule Thrift.Generator.StructBinaryProtocol do

quote do
defp unquote(key_name)(<<rest::binary>>, stack) do
case unquote(dest_module).BinaryProtocol.deserialize(rest) do
case unquote(Module.concat(dest_module, BinaryProtocol)).deserialize(rest) do
{key, rest} ->
unquote(value_name)(rest, key, stack)

Expand All @@ -451,7 +451,7 @@ defmodule Thrift.Generator.StructBinaryProtocol do

quote do
defp unquote(key_name)(<<rest::binary>>, stack) do
case unquote(dest_module).BinaryProtocol.deserialize(rest) do
case unquote(Module.concat(dest_module, BinaryProtocol)).deserialize(rest) do
{key, rest} ->
unquote(value_name)(rest, key, stack)

Expand All @@ -467,7 +467,7 @@ defmodule Thrift.Generator.StructBinaryProtocol do

quote do
defp unquote(key_name)(<<rest::binary>>, stack) do
case unquote(dest_module).BinaryProtocol.deserialize(rest) do
case unquote(Module.concat(dest_module, BinaryProtocol)).deserialize(rest) do
{key, rest} ->
unquote(value_name)(rest, key, stack)

Expand Down Expand Up @@ -655,7 +655,7 @@ defmodule Thrift.Generator.StructBinaryProtocol do

quote do
defp unquote(value_name)(<<rest::binary>>, key, [map, remaining | stack]) do
case unquote(dest_module).BinaryProtocol.deserialize(rest) do
case unquote(Module.concat(dest_module, BinaryProtocol)).deserialize(rest) do
{value, rest} ->
unquote(key_name)(rest, [Map.put(map, key, value), remaining - 1 | stack])

Expand All @@ -671,7 +671,7 @@ defmodule Thrift.Generator.StructBinaryProtocol do

quote do
defp unquote(value_name)(<<rest::binary>>, key, [map, remaining | stack]) do
case unquote(dest_module).BinaryProtocol.deserialize(rest) do
case unquote(Module.concat(dest_module, BinaryProtocol)).deserialize(rest) do
{value, rest} ->
unquote(key_name)(rest, [Map.put(map, key, value), remaining - 1 | stack])

Expand All @@ -687,7 +687,7 @@ defmodule Thrift.Generator.StructBinaryProtocol do

quote do
defp unquote(value_name)(<<rest::binary>>, key, [map, remaining | stack]) do
case unquote(dest_module).BinaryProtocol.deserialize(rest) do
case unquote(Module.concat(dest_module, BinaryProtocol)).deserialize(rest) do
{value, rest} ->
unquote(key_name)(rest, [Map.put(map, key, value), remaining - 1 | stack])

Expand Down Expand Up @@ -865,7 +865,7 @@ defmodule Thrift.Generator.StructBinaryProtocol do

quote do
defp unquote(name)(<<rest::binary>>, [list, remaining | stack]) do
case unquote(dest_module).BinaryProtocol.deserialize(rest) do
case unquote(Module.concat(dest_module, BinaryProtocol)).deserialize(rest) do
{element, rest} ->
unquote(name)(rest, [[element | list], remaining - 1 | stack])

Expand All @@ -881,7 +881,7 @@ defmodule Thrift.Generator.StructBinaryProtocol do

quote do
defp unquote(name)(<<rest::binary>>, [list, remaining | stack]) do
case unquote(dest_module).BinaryProtocol.deserialize(rest) do
case unquote(Module.concat(dest_module, BinaryProtocol)).deserialize(rest) do
{element, rest} ->
unquote(name)(rest, [[element | list], remaining - 1 | stack])

Expand All @@ -897,7 +897,7 @@ defmodule Thrift.Generator.StructBinaryProtocol do

quote do
defp unquote(name)(<<rest::binary>>, [list, remaining | stack]) do
case unquote(dest_module).BinaryProtocol.deserialize(rest) do
case unquote(Module.concat(dest_module, BinaryProtocol)).deserialize(rest) do
{element, rest} ->
unquote(name)(rest, [[element | list], remaining - 1 | stack])

Expand Down

0 comments on commit 8e9aec6

Please sign in to comment.