brotorift 0.6.3 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d7b4aba3ca4b3d1188fbb06f07f1dd973f8fbf4f779905c419c55e06a71c74a
|
4
|
+
data.tar.gz: d13b8813a3b2510adf4080bb5631c74908ab2f582a3e4f75ce578514382ba92a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6443d6e4e249e4281f08956a93293704466cb595f22238a7e93449bdee99c66940cc30d245f8b027f788dcd30d9af14d5ccaf7ac1f2ff488937004693055d22
|
7
|
+
data.tar.gz: 5359f85e8252c70a19bce2c88372e15f619160403563aab07678b5207e4aaf96fb8e458d873575a8b81e68937b149692b35622f2eb4366d27db128e69696229c
|
@@ -1,43 +1,3 @@
|
|
1
|
-
defmodule <%= node.namespace %>.Enums do<% for e in runtime.enums.values %>
|
2
|
-
def <%= e.elixir_read_name %>(data) do
|
3
|
-
<<value::32-little, data::binary>> = data
|
4
|
-
case value do<% for v in e.elements.values %>
|
5
|
-
<%= v.value %> -> {data, <%= v.elixir_name %>}<% end %>
|
6
|
-
_ -> :error
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def <%= e.elixir_write_name %>(data, value) do
|
11
|
-
case value do<% for v in e.elements.values %>
|
12
|
-
<%= v.elixir_name %> -> <<data::binary, <%= v.value %>::32-little>><% end %>
|
13
|
-
_ -> :error
|
14
|
-
end
|
15
|
-
end
|
16
|
-
<% end %>end
|
17
|
-
|
18
|
-
<% for s in runtime.structs.values %>
|
19
|
-
defmodule <%= node.namespace %>.<%= s.name %> do
|
20
|
-
defstruct [<%= s.elixir_members %>]
|
21
|
-
|
22
|
-
import <%= node.namespace %>.Enums
|
23
|
-
|
24
|
-
@typedoc """
|
25
|
-
<%= s.doc %><% for m in s.members %>
|
26
|
-
`:<%= m.elixir_name %>`: <%= m.doc %><% end %>
|
27
|
-
"""
|
28
|
-
@type t :: %<%= node.namespace %>.<%= s.name %>{<%= s.elixir_members_with_types node %>}
|
29
|
-
|
30
|
-
def read(data) do<% for m in s.members %>
|
31
|
-
{data, <%= m.elixir_name %>} = <%= m.type.elixir_read node %><% end %>
|
32
|
-
{data, %<%= node.namespace %>.<%= s.name %>{<%= s.elixir_members_with_values %>}}
|
33
|
-
end
|
34
|
-
|
35
|
-
def write(data, value) do<% for m in s.members %>
|
36
|
-
data = <%= m.type.elixir_write node, 'value.' + m.elixir_name %><% end %>
|
37
|
-
data
|
38
|
-
end
|
39
|
-
end
|
40
|
-
<% end %>
|
41
1
|
<% for n in runtime.get_node_directions node, :server %>
|
42
2
|
defmodule <%= node.namespace %>.<%= node.elixir_connection %> do
|
43
3
|
use GenServer, restart: :temporary
|
@@ -422,14 +422,19 @@ class ElixirServerGenerator < Generator
|
|
422
422
|
end
|
423
423
|
|
424
424
|
def generate node, runtime
|
425
|
+
self.generate_file node, runtime, 'elixir_server_types_generator', "#{node.elixir_name}_types"
|
426
|
+
self.generate_file node, runtime, 'elixir_server_generator', node.elixir_name
|
427
|
+
end
|
428
|
+
|
429
|
+
def generate_file node, runtime, template_file, generated_file
|
425
430
|
folder = File.expand_path File.dirname __FILE__
|
426
|
-
erb_file = folder +
|
431
|
+
erb_file = folder + "/#{template_file}.ex.erb"
|
427
432
|
template = File.read erb_file
|
428
433
|
erb = ERB.new template
|
429
434
|
content = erb.result binding
|
430
435
|
|
431
436
|
output_dir = File.dirname runtime.filename
|
432
|
-
output_path = File.join output_dir, "#{
|
437
|
+
output_path = File.join output_dir, "#{generated_file}.ex"
|
433
438
|
File.write output_path, content
|
434
439
|
end
|
435
440
|
end
|