forked from cucumber/common
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cucumber#1223 from cucumber/elixir-messages-parall…
…el-compiling elixir messages multiple file generation -> parallel compiling
- Loading branch information
Showing
57 changed files
with
8,453 additions
and
13,054 deletions.
There are no files selected for viewing
193 changes: 193 additions & 0 deletions
193
messages/elixir/lib/cucumber_messages/generated/elixir_cucumber_messages_attachment.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
# credo:disable-for-this-file | ||
defmodule(CucumberMessages.Attachment) do | ||
@moduledoc(false) | ||
( | ||
defstruct(source: nil, test_step_id: "", test_case_started_id: "", body: "", media_type: "", content_encoding: :IDENTITY, __uf__: []) | ||
( | ||
@spec(encode(struct) :: {:ok, iodata} | {:error, any}) | ||
def(encode(msg)) do | ||
try do | ||
{:ok, encode!(msg)} | ||
rescue | ||
e -> | ||
{:error, e} | ||
end | ||
end | ||
@spec(encode!(struct) :: iodata | no_return) | ||
def(encode!(msg)) do | ||
[] |> encode_source(msg) |> encode_test_step_id(msg) |> encode_test_case_started_id(msg) |> encode_body(msg) |> encode_media_type(msg) |> encode_content_encoding(msg) |> encode_unknown_fields(msg) | ||
end | ||
[] | ||
[defp(encode_source(acc, msg)) do | ||
field_value = msg.source() | ||
if(field_value == nil) do | ||
acc | ||
else | ||
[acc, "\n", Protox.Encode.encode_message(field_value)] | ||
end | ||
end, defp(encode_test_step_id(acc, msg)) do | ||
field_value = msg.test_step_id() | ||
if(field_value == "") do | ||
acc | ||
else | ||
[acc, <<18>>, Protox.Encode.encode_string(field_value)] | ||
end | ||
end, defp(encode_test_case_started_id(acc, msg)) do | ||
field_value = msg.test_case_started_id() | ||
if(field_value == "") do | ||
acc | ||
else | ||
[acc, <<26>>, Protox.Encode.encode_string(field_value)] | ||
end | ||
end, defp(encode_body(acc, msg)) do | ||
field_value = msg.body() | ||
if(field_value == "") do | ||
acc | ||
else | ||
[acc, "\"", Protox.Encode.encode_string(field_value)] | ||
end | ||
end, defp(encode_media_type(acc, msg)) do | ||
field_value = msg.media_type() | ||
if(field_value == "") do | ||
acc | ||
else | ||
[acc, "*", Protox.Encode.encode_string(field_value)] | ||
end | ||
end, defp(encode_content_encoding(acc, msg)) do | ||
field_value = msg.content_encoding() | ||
if(field_value == :IDENTITY) do | ||
acc | ||
else | ||
[acc, "0", field_value |> CucumberMessages.Attachment.ContentEncoding.encode() |> Protox.Encode.encode_enum()] | ||
end | ||
end] | ||
defp(encode_unknown_fields(acc, msg)) do | ||
Enum.reduce(msg.__struct__.unknown_fields(msg), acc, fn {tag, wire_type, bytes}, acc -> case(wire_type) do | ||
0 -> | ||
[acc, Protox.Encode.make_key_bytes(tag, :int32), bytes] | ||
1 -> | ||
[acc, Protox.Encode.make_key_bytes(tag, :double), bytes] | ||
2 -> | ||
len_bytes = bytes |> byte_size() |> Protox.Varint.encode() | ||
[acc, Protox.Encode.make_key_bytes(tag, :packed), len_bytes, bytes] | ||
5 -> | ||
[acc, Protox.Encode.make_key_bytes(tag, :float), bytes] | ||
end end) | ||
end | ||
) | ||
( | ||
@spec(decode(binary) :: {:ok, struct} | {:error, any}) | ||
def(decode(bytes)) do | ||
try do | ||
{:ok, decode!(bytes)} | ||
rescue | ||
e -> | ||
{:error, e} | ||
end | ||
end | ||
( | ||
@spec(decode!(binary) :: struct | no_return) | ||
def(decode!(bytes)) do | ||
parse_key_value(bytes, struct(CucumberMessages.Attachment)) | ||
end | ||
) | ||
( | ||
@spec(parse_key_value(binary, struct) :: struct) | ||
defp(parse_key_value(<<>>, msg)) do | ||
msg | ||
end | ||
defp(parse_key_value(bytes, msg)) do | ||
{field, rest} = case(Protox.Decode.parse_key(bytes)) do | ||
{0, _, _} -> | ||
raise(%Protox.IllegalTagError{}) | ||
{1, _, bytes} -> | ||
{len, bytes} = Protox.Varint.decode(bytes) | ||
<<delimited::binary-size(len), rest::binary>> = bytes | ||
value = CucumberMessages.SourceReference.decode!(delimited) | ||
field = {:source, Protox.Message.merge(msg.source(), value)} | ||
{field, rest} | ||
{2, _, bytes} -> | ||
{len, bytes} = Protox.Varint.decode(bytes) | ||
<<delimited::binary-size(len), rest::binary>> = bytes | ||
value = delimited | ||
field = {:test_step_id, value} | ||
{field, rest} | ||
{3, _, bytes} -> | ||
{len, bytes} = Protox.Varint.decode(bytes) | ||
<<delimited::binary-size(len), rest::binary>> = bytes | ||
value = delimited | ||
field = {:test_case_started_id, value} | ||
{field, rest} | ||
{4, _, bytes} -> | ||
{len, bytes} = Protox.Varint.decode(bytes) | ||
<<delimited::binary-size(len), rest::binary>> = bytes | ||
value = delimited | ||
field = {:body, value} | ||
{field, rest} | ||
{5, _, bytes} -> | ||
{len, bytes} = Protox.Varint.decode(bytes) | ||
<<delimited::binary-size(len), rest::binary>> = bytes | ||
value = delimited | ||
field = {:media_type, value} | ||
{field, rest} | ||
{6, _, bytes} -> | ||
{value, rest} = Protox.Decode.parse_enum(bytes, CucumberMessages.Attachment.ContentEncoding) | ||
field = {:content_encoding, value} | ||
{field, rest} | ||
{tag, wire_type, rest} -> | ||
{value, new_rest} = Protox.Decode.parse_unknown(tag, wire_type, rest) | ||
field = {msg.__struct__.unknown_fields_name, [value | msg.__struct__.unknown_fields(msg)]} | ||
{field, new_rest} | ||
end | ||
msg_updated = struct(msg, [field]) | ||
parse_key_value(rest, msg_updated) | ||
end | ||
) | ||
[] | ||
) | ||
@spec(defs() :: %{required(non_neg_integer) => {atom, Protox.Types.kind(), Protox.Types.type()}}) | ||
def(defs()) do | ||
%{1 => {:source, {:default, nil}, {:message, CucumberMessages.SourceReference}}, 2 => {:test_step_id, {:default, ""}, :string}, 3 => {:test_case_started_id, {:default, ""}, :string}, 4 => {:body, {:default, ""}, :string}, 5 => {:media_type, {:default, ""}, :string}, 6 => {:content_encoding, {:default, :IDENTITY}, {:enum, CucumberMessages.Attachment.ContentEncoding}}} | ||
end | ||
@spec(defs_by_name() :: %{required(atom) => {non_neg_integer, Protox.Types.kind(), Protox.Types.type()}}) | ||
def(defs_by_name()) do | ||
%{body: {4, {:default, ""}, :string}, content_encoding: {6, {:default, :IDENTITY}, {:enum, CucumberMessages.Attachment.ContentEncoding}}, media_type: {5, {:default, ""}, :string}, source: {1, {:default, nil}, {:message, CucumberMessages.SourceReference}}, test_case_started_id: {3, {:default, ""}, :string}, test_step_id: {2, {:default, ""}, :string}} | ||
end | ||
@spec(required_fields() :: []) | ||
def(required_fields()) do | ||
[] | ||
end | ||
@spec(unknown_fields(struct) :: [{non_neg_integer, Protox.Types.tag(), binary}]) | ||
def(unknown_fields(msg)) do | ||
msg.__uf__() | ||
end | ||
@spec(unknown_fields_name() :: :__uf__) | ||
def(unknown_fields_name()) do | ||
:__uf__ | ||
end | ||
@spec(clear_unknown_fields(struct) :: struct) | ||
def(clear_unknown_fields(msg)) do | ||
struct!(msg, [{unknown_fields_name(), []}]) | ||
end | ||
@spec(syntax() :: atom) | ||
def(syntax()) do | ||
:proto3 | ||
end | ||
[@spec(default(atom) :: {:ok, boolean | integer | String.t() | float} | {:error, atom}), [def(default(:source)) do | ||
{:ok, nil} | ||
end, def(default(:test_step_id)) do | ||
{:ok, ""} | ||
end, def(default(:test_case_started_id)) do | ||
{:ok, ""} | ||
end, def(default(:body)) do | ||
{:ok, ""} | ||
end, def(default(:media_type)) do | ||
{:ok, ""} | ||
end, def(default(:content_encoding)) do | ||
{:ok, :IDENTITY} | ||
end], def(default(_)) do | ||
{:error, :no_such_field} | ||
end] | ||
) | ||
[] | ||
end |
35 changes: 35 additions & 0 deletions
35
...r/lib/cucumber_messages/generated/elixir_cucumber_messages_attachment_content_encoding.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# credo:disable-for-this-file | ||
defmodule(CucumberMessages.Attachment.ContentEncoding) do | ||
@moduledoc(false) | ||
( | ||
( | ||
@spec(default() :: :IDENTITY) | ||
def(default()) do | ||
:IDENTITY | ||
end | ||
) | ||
@spec(encode(atom) :: integer | atom) | ||
[def(encode(:IDENTITY)) do | ||
0 | ||
end, def(encode(:BASE64)) do | ||
1 | ||
end] | ||
def(encode(x)) do | ||
x | ||
end | ||
@spec(decode(integer) :: atom | integer) | ||
[def(decode(0)) do | ||
:IDENTITY | ||
end, def(decode(1)) do | ||
:BASE64 | ||
end] | ||
def(decode(x)) do | ||
x | ||
end | ||
@spec(constants() :: [{integer, atom}]) | ||
def(constants()) do | ||
[{0, :IDENTITY}, {1, :BASE64}] | ||
end | ||
) | ||
[] | ||
end |
131 changes: 131 additions & 0 deletions
131
messages/elixir/lib/cucumber_messages/generated/elixir_cucumber_messages_duration.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
# credo:disable-for-this-file | ||
defmodule(CucumberMessages.Duration) do | ||
@moduledoc(false) | ||
( | ||
defstruct(seconds: 0, nanos: 0, __uf__: []) | ||
( | ||
@spec(encode(struct) :: {:ok, iodata} | {:error, any}) | ||
def(encode(msg)) do | ||
try do | ||
{:ok, encode!(msg)} | ||
rescue | ||
e -> | ||
{:error, e} | ||
end | ||
end | ||
@spec(encode!(struct) :: iodata | no_return) | ||
def(encode!(msg)) do | ||
[] |> encode_seconds(msg) |> encode_nanos(msg) |> encode_unknown_fields(msg) | ||
end | ||
[] | ||
[defp(encode_seconds(acc, msg)) do | ||
field_value = msg.seconds() | ||
if(field_value == 0) do | ||
acc | ||
else | ||
[acc, "\b", Protox.Encode.encode_int64(field_value)] | ||
end | ||
end, defp(encode_nanos(acc, msg)) do | ||
field_value = msg.nanos() | ||
if(field_value == 0) do | ||
acc | ||
else | ||
[acc, <<16>>, Protox.Encode.encode_int32(field_value)] | ||
end | ||
end] | ||
defp(encode_unknown_fields(acc, msg)) do | ||
Enum.reduce(msg.__struct__.unknown_fields(msg), acc, fn {tag, wire_type, bytes}, acc -> case(wire_type) do | ||
0 -> | ||
[acc, Protox.Encode.make_key_bytes(tag, :int32), bytes] | ||
1 -> | ||
[acc, Protox.Encode.make_key_bytes(tag, :double), bytes] | ||
2 -> | ||
len_bytes = bytes |> byte_size() |> Protox.Varint.encode() | ||
[acc, Protox.Encode.make_key_bytes(tag, :packed), len_bytes, bytes] | ||
5 -> | ||
[acc, Protox.Encode.make_key_bytes(tag, :float), bytes] | ||
end end) | ||
end | ||
) | ||
( | ||
@spec(decode(binary) :: {:ok, struct} | {:error, any}) | ||
def(decode(bytes)) do | ||
try do | ||
{:ok, decode!(bytes)} | ||
rescue | ||
e -> | ||
{:error, e} | ||
end | ||
end | ||
( | ||
@spec(decode!(binary) :: struct | no_return) | ||
def(decode!(bytes)) do | ||
parse_key_value(bytes, struct(CucumberMessages.Duration)) | ||
end | ||
) | ||
( | ||
@spec(parse_key_value(binary, struct) :: struct) | ||
defp(parse_key_value(<<>>, msg)) do | ||
msg | ||
end | ||
defp(parse_key_value(bytes, msg)) do | ||
{field, rest} = case(Protox.Decode.parse_key(bytes)) do | ||
{0, _, _} -> | ||
raise(%Protox.IllegalTagError{}) | ||
{1, _, bytes} -> | ||
{value, rest} = Protox.Decode.parse_int64(bytes) | ||
field = {:seconds, value} | ||
{field, rest} | ||
{2, _, bytes} -> | ||
{value, rest} = Protox.Decode.parse_int32(bytes) | ||
field = {:nanos, value} | ||
{field, rest} | ||
{tag, wire_type, rest} -> | ||
{value, new_rest} = Protox.Decode.parse_unknown(tag, wire_type, rest) | ||
field = {msg.__struct__.unknown_fields_name, [value | msg.__struct__.unknown_fields(msg)]} | ||
{field, new_rest} | ||
end | ||
msg_updated = struct(msg, [field]) | ||
parse_key_value(rest, msg_updated) | ||
end | ||
) | ||
[] | ||
) | ||
@spec(defs() :: %{required(non_neg_integer) => {atom, Protox.Types.kind(), Protox.Types.type()}}) | ||
def(defs()) do | ||
%{1 => {:seconds, {:default, 0}, :int64}, 2 => {:nanos, {:default, 0}, :int32}} | ||
end | ||
@spec(defs_by_name() :: %{required(atom) => {non_neg_integer, Protox.Types.kind(), Protox.Types.type()}}) | ||
def(defs_by_name()) do | ||
%{nanos: {2, {:default, 0}, :int32}, seconds: {1, {:default, 0}, :int64}} | ||
end | ||
@spec(required_fields() :: []) | ||
def(required_fields()) do | ||
[] | ||
end | ||
@spec(unknown_fields(struct) :: [{non_neg_integer, Protox.Types.tag(), binary}]) | ||
def(unknown_fields(msg)) do | ||
msg.__uf__() | ||
end | ||
@spec(unknown_fields_name() :: :__uf__) | ||
def(unknown_fields_name()) do | ||
:__uf__ | ||
end | ||
@spec(clear_unknown_fields(struct) :: struct) | ||
def(clear_unknown_fields(msg)) do | ||
struct!(msg, [{unknown_fields_name(), []}]) | ||
end | ||
@spec(syntax() :: atom) | ||
def(syntax()) do | ||
:proto3 | ||
end | ||
[@spec(default(atom) :: {:ok, boolean | integer | String.t() | float} | {:error, atom}), [def(default(:seconds)) do | ||
{:ok, 0} | ||
end, def(default(:nanos)) do | ||
{:ok, 0} | ||
end], def(default(_)) do | ||
{:error, :no_such_field} | ||
end] | ||
) | ||
[] | ||
end |
Oops, something went wrong.