brotorift 0.4.5 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ast.rb +10 -0
- data/lib/compiler.rb +2 -1
- data/lib/generators/elixir_server_generator.ex.erb +9 -1
- data/lib/generators/unity_client_generator.cs.erb +3 -0
- data/lib/lexer.rb +1 -0
- data/lib/parser.rb +9 -0
- data/lib/runtime.rb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8dd2908d1aaf2325114a587b14657d7199a7ba5db291c58bd3d935d9671eec5
|
4
|
+
data.tar.gz: f9c6d28421e7b7fb49721df7947a2e300b81fb3446ba7e96ddfda3731434887a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cee1927befbfcdfa63c01709926be18794293a4dc602bf7b6cb97899cdfae261135eaa6d59ec3a4c3959104d5969f90cbd73850c7c89cf694b1ac45ffe05b2d
|
7
|
+
data.tar.gz: 436bad9efd9fd12c515f4148810eed58c9a7d81cc13a6d6f57b9cd400886fc798684701f8ecefcfeb8d06b2d751c71b45174adfdeefe6b695d194116d3fedccc
|
data/lib/ast.rb
CHANGED
@@ -41,6 +41,16 @@ end
|
|
41
41
|
class TopDecl < ASTNode
|
42
42
|
end
|
43
43
|
|
44
|
+
class FileDecl < ASTNode
|
45
|
+
value :version, Integer
|
46
|
+
value :decls, [TopDecl]
|
47
|
+
|
48
|
+
def to_s
|
49
|
+
decls_str = decls.join "\n"
|
50
|
+
"version #{version}\n\n#{decls_str}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
44
54
|
class IncludeDecl < TopDecl
|
45
55
|
value :filename, String
|
46
56
|
|
data/lib/compiler.rb
CHANGED
@@ -42,6 +42,10 @@ end
|
|
42
42
|
defmodule <%= node.namespace %>.<%= node.elixir_connection %> do
|
43
43
|
use GenServer, restart: :temporary
|
44
44
|
|
45
|
+
@version <%= runtime.version %>
|
46
|
+
|
47
|
+
@sc_packet_data 128
|
48
|
+
|
45
49
|
import <%= node.namespace %>.Enums
|
46
50
|
|
47
51
|
@behaviour Brotorift.ConnectionBehaviour
|
@@ -64,6 +68,10 @@ defmodule <%= node.namespace %>.<%= node.elixir_connection %> do
|
|
64
68
|
GenServer.cast(connection, {:<%= m.elixir_name %><%= m.elixir_params %>})
|
65
69
|
end
|
66
70
|
<% end %>
|
71
|
+
def version() do
|
72
|
+
@version
|
73
|
+
end
|
74
|
+
|
67
75
|
def start_link(args) do
|
68
76
|
GenServer.start_link(__MODULE__, args)
|
69
77
|
end
|
@@ -89,7 +97,7 @@ defmodule <%= node.namespace %>.<%= node.elixir_connection %> do
|
|
89
97
|
def handle_cast({:<%= m.elixir_name %><%= m.elixir_params %>}, {socket, transport, handler, state}) do
|
90
98
|
data = <<<%= m.elixir_header_name %>::32-little>><% for p in m.members %>
|
91
99
|
data = <%= p.type.elixir_write node, p.elixir_name %><% end %>
|
92
|
-
data =
|
100
|
+
data = <<@sc_packet_data::8, byte_size(data)::32-little, data::binary>>
|
93
101
|
transport.send(socket, data)
|
94
102
|
{:noreply, {socket, transport, handler, state}}
|
95
103
|
end
|
@@ -62,12 +62,15 @@ namespace <%= node.namespace %>
|
|
62
62
|
|
63
63
|
public class <%= node_direction.connector_name %> : Client
|
64
64
|
{
|
65
|
+
public const int ClientVersion = <%= runtime.version %>;
|
66
|
+
|
65
67
|
public <%= node_direction.handler_name %> handler { get; set; }
|
66
68
|
|
67
69
|
public PacketProcessPolicy policy { get; set; }
|
68
70
|
|
69
71
|
public <%= node_direction.connector_name %>( <%= node_direction.handler_name %> handler, long dataHead )
|
70
72
|
{
|
73
|
+
this.Version = ClientVersion;
|
71
74
|
this.handler = handler;
|
72
75
|
this.dataHead = dataHead;
|
73
76
|
this.policy = PacketProcessPolicy.Discard;
|
data/lib/lexer.rb
CHANGED
data/lib/parser.rb
CHANGED
@@ -16,6 +16,15 @@ end
|
|
16
16
|
class Parser < RLTK::Parser
|
17
17
|
@@enum_value = 0
|
18
18
|
|
19
|
+
production(:file) do
|
20
|
+
clause('version_decl decl_list') { |version_number, decls| FileDecl.new self.position, version_number, decls }
|
21
|
+
clause('decl_list') { |decls| FileDecl.new self.position, 1, decls }
|
22
|
+
end
|
23
|
+
|
24
|
+
production(:version_decl) do
|
25
|
+
clause('VERSION NUMBER') { |_, version_number| version_number }
|
26
|
+
end
|
27
|
+
|
19
28
|
list(:decl_list, :decl)
|
20
29
|
|
21
30
|
production(:decl) do
|
data/lib/runtime.rb
CHANGED
@@ -188,6 +188,7 @@ end
|
|
188
188
|
class Runtime
|
189
189
|
attr_reader :filename
|
190
190
|
attr_reader :builtins
|
191
|
+
attr_accessor :version
|
191
192
|
attr_reader :nodes
|
192
193
|
attr_reader :enums
|
193
194
|
attr_reader :structs
|
@@ -197,6 +198,7 @@ class Runtime
|
|
197
198
|
def initialize filename
|
198
199
|
@filename = filename
|
199
200
|
@builtins = {}
|
201
|
+
@version = 1
|
200
202
|
@enums = {}
|
201
203
|
@nodes = {}
|
202
204
|
@structs = {}
|