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: 89d252d998fd9325e68a6d94de1089cf25fcb7eaee49d5b765b9194cf8da0d8a
4
- data.tar.gz: d6a34e8307e59f6b0526c9f495bb9ddf1784492359720af92ea722d12185e197
3
+ metadata.gz: 1d7b4aba3ca4b3d1188fbb06f07f1dd973f8fbf4f779905c419c55e06a71c74a
4
+ data.tar.gz: d13b8813a3b2510adf4080bb5631c74908ab2f582a3e4f75ce578514382ba92a
5
5
  SHA512:
6
- metadata.gz: 6c3e769db37d95bbcf15ce6cffeb453ee63ced140ef3d43b54ea2c5eb9218387481cfb65abbc1f2708af9d68bde1d20023d0355c66ef9c169fd0a1c8a59d21ab
7
- data.tar.gz: af59ab37fffd8449517f65a0bdc3cf1e3cd20240d0c52d2894f10300b8c3f8b421cfe361c60a3fad590c87fc81ad9e9d921938edbb55eaaa4acaf3d460831def
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 + '/elixir_server_generator.ex.erb'
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, "#{node.elixir_name}.ex"
437
+ output_path = File.join output_dir, "#{generated_file}.ex"
433
438
  File.write output_path, content
434
439
  end
435
440
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brotorift
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ren