Eliminate redundant 'Elixir.' prefixes (#515)

Minor refactor for readability of compiled code.
This commit is contained in:
Preston Guillory 2020-10-19 11:39:31 -07:00 committed by GitHub
parent d6bfeea36b
commit 8e9aec629a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 49 deletions

View File

@ -307,7 +307,7 @@ defmodule(Calculator.Generated.Service) do
end
defp(deserialize(<<12, 1::16-signed, rest::binary>>, acc)) do
case(Elixir.Calculator.Generated.Vector.BinaryProtocol.deserialize(rest)) do
case(Calculator.Generated.Vector.BinaryProtocol.deserialize(rest)) do
{value, rest} ->
deserialize(rest, %{acc | left: value})
@ -317,7 +317,7 @@ defmodule(Calculator.Generated.Service) do
end
defp(deserialize(<<12, 2::16-signed, rest::binary>>, acc)) do
case(Elixir.Calculator.Generated.Vector.BinaryProtocol.deserialize(rest)) do
case(Calculator.Generated.Vector.BinaryProtocol.deserialize(rest)) do
{value, rest} ->
deserialize(rest, %{acc | right: value})
@ -464,7 +464,7 @@ defmodule(Calculator.Generated.Service) do
end
defp(deserialize(<<12, 1::16-signed, rest::binary>>, acc)) do
case(Elixir.Calculator.Generated.DivideByZeroError.BinaryProtocol.deserialize(rest)) do
case(Calculator.Generated.DivideByZeroError.BinaryProtocol.deserialize(rest)) do
{value, rest} ->
deserialize(rest, %{acc | e: value})
@ -654,7 +654,7 @@ defmodule(Calculator.Generated.Service) do
end
defp(deserialize(<<12, 0::16-signed, rest::binary>>, acc)) do
case(Elixir.Calculator.Generated.VectorProductResult.BinaryProtocol.deserialize(rest)) do
case(Calculator.Generated.VectorProductResult.BinaryProtocol.deserialize(rest)) do
{value, rest} ->
deserialize(rest, %{acc | success: value})
@ -833,14 +833,12 @@ defmodule(Calculator.Generated.Service) do
end
def(handle_thrift("add", binary_data, handler_module)) do
case(Elixir.Calculator.Generated.Service.AddArgs.BinaryProtocol.deserialize(binary_data)) do
case(Calculator.Generated.Service.AddArgs.BinaryProtocol.deserialize(binary_data)) do
{%Calculator.Generated.Service.AddArgs{left: left, right: right}, ""} ->
try do
result = handler_module.add(left, right)
response = %Calculator.Generated.Service.AddResponse{success: result}
{:reply,
Elixir.Calculator.Generated.Service.AddResponse.BinaryProtocol.serialize(response)}
{:reply, Calculator.Generated.Service.AddResponse.BinaryProtocol.serialize(response)}
catch
kind, reason ->
formatted_exception = Exception.format(kind, reason, System.stacktrace())
@ -867,24 +865,20 @@ defmodule(Calculator.Generated.Service) do
end
def(handle_thrift("divide", binary_data, handler_module)) do
case(
Elixir.Calculator.Generated.Service.DivideArgs.BinaryProtocol.deserialize(binary_data)
) do
case(Calculator.Generated.Service.DivideArgs.BinaryProtocol.deserialize(binary_data)) do
{%Calculator.Generated.Service.DivideArgs{left: left, right: right}, ""} ->
try do
result = handler_module.divide(left, right)
response = %Calculator.Generated.Service.DivideResponse{success: result}
{:reply,
Elixir.Calculator.Generated.Service.DivideResponse.BinaryProtocol.serialize(response)}
Calculator.Generated.Service.DivideResponse.BinaryProtocol.serialize(response)}
catch
:error, %Calculator.Generated.DivideByZeroError{} = e ->
response = %Calculator.Generated.Service.DivideResponse{e: e}
{:reply,
Elixir.Calculator.Generated.Service.DivideResponse.BinaryProtocol.serialize(
response
)}
Calculator.Generated.Service.DivideResponse.BinaryProtocol.serialize(response)}
kind, reason ->
formatted_exception = Exception.format(kind, reason, System.stacktrace())
@ -911,18 +905,14 @@ defmodule(Calculator.Generated.Service) do
end
def(handle_thrift("multiply", binary_data, handler_module)) do
case(
Elixir.Calculator.Generated.Service.MultiplyArgs.BinaryProtocol.deserialize(binary_data)
) do
case(Calculator.Generated.Service.MultiplyArgs.BinaryProtocol.deserialize(binary_data)) do
{%Calculator.Generated.Service.MultiplyArgs{left: left, right: right}, ""} ->
try do
result = handler_module.multiply(left, right)
response = %Calculator.Generated.Service.MultiplyResponse{success: result}
{:reply,
Elixir.Calculator.Generated.Service.MultiplyResponse.BinaryProtocol.serialize(
response
)}
Calculator.Generated.Service.MultiplyResponse.BinaryProtocol.serialize(response)}
catch
kind, reason ->
formatted_exception = Exception.format(kind, reason, System.stacktrace())
@ -949,18 +939,14 @@ defmodule(Calculator.Generated.Service) do
end
def(handle_thrift("subtract", binary_data, handler_module)) do
case(
Elixir.Calculator.Generated.Service.SubtractArgs.BinaryProtocol.deserialize(binary_data)
) do
case(Calculator.Generated.Service.SubtractArgs.BinaryProtocol.deserialize(binary_data)) do
{%Calculator.Generated.Service.SubtractArgs{left: left, right: right}, ""} ->
try do
result = handler_module.subtract(left, right)
response = %Calculator.Generated.Service.SubtractResponse{success: result}
{:reply,
Elixir.Calculator.Generated.Service.SubtractResponse.BinaryProtocol.serialize(
response
)}
Calculator.Generated.Service.SubtractResponse.BinaryProtocol.serialize(response)}
catch
kind, reason ->
formatted_exception = Exception.format(kind, reason, System.stacktrace())
@ -988,9 +974,7 @@ defmodule(Calculator.Generated.Service) do
def(handle_thrift("vectorProduct", binary_data, handler_module)) do
case(
Elixir.Calculator.Generated.Service.VectorProductArgs.BinaryProtocol.deserialize(
binary_data
)
Calculator.Generated.Service.VectorProductArgs.BinaryProtocol.deserialize(binary_data)
) do
{%Calculator.Generated.Service.VectorProductArgs{left: left, right: right, type: type},
""} ->
@ -999,9 +983,7 @@ defmodule(Calculator.Generated.Service) do
response = %Calculator.Generated.Service.VectorProductResponse{success: result}
{:reply,
Elixir.Calculator.Generated.Service.VectorProductResponse.BinaryProtocol.serialize(
response
)}
Calculator.Generated.Service.VectorProductResponse.BinaryProtocol.serialize(response)}
catch
kind, reason ->
formatted_exception = Exception.format(kind, reason, System.stacktrace())

View File

@ -36,7 +36,7 @@ defmodule(Calculator.Generated.VectorProductResult) do
end
defp(deserialize(<<12, 2::16-signed, rest::binary>>, acc)) do
case(Elixir.Calculator.Generated.Vector.BinaryProtocol.deserialize(rest)) do
case(Calculator.Generated.Vector.BinaryProtocol.deserialize(rest)) do
{value, rest} ->
deserialize(rest, %{acc | vector: value})

View File

@ -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))
@ -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)
@ -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

View File

@ -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})
@ -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})
@ -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})
@ -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)
@ -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)
@ -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)
@ -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])
@ -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])
@ -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])
@ -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])
@ -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])
@ -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])