Skip to content

Commit 80a1e3f

Browse files
committed
Update references and fix warnings
Now using the FFI to define functions in ElixirScript.JS module. This is to prevent warnings that pop up about missing implementations.
1 parent ad421cf commit 80a1e3f

File tree

5 files changed

+30
-28
lines changed

5 files changed

+30
-28
lines changed

lib/elixir_script/lib/js.ex

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,47 @@ defmodule ElixirScript.JS do
55
Elixir. For instance, creating a new object
66
"""
77

8+
use ElixirScript.FFI, global: true
9+
810
@doc """
911
Creates new JavaScript objects.
1012
1113
ex:
1214
ElixirScript.JS.new User, ["first_name", "last_name"]
1315
"""
14-
defmacro new(module, params)
16+
defexternal new(module, params)
1517

1618
@doc """
1719
Returns the type of the given value
1820
"""
19-
defmacro typeof(value)
21+
defexternal typeof(value)
2022

2123
@doc """
2224
Determines if value is an instance of type.
2325
"""
24-
defmacro instanceof(value, type)
26+
defexternal instanceof(value, type)
2527

2628
@doc """
2729
Throws the term given
2830
"""
29-
defmacro throw(term)
31+
defexternal throw(term)
3032

3133
@doc """
3234
Creates a breakpoint for JavaScript debuggers to stop at
3335
"""
34-
defmacro debugger()
36+
defexternal debugger()
3537

3638
@doc """
3739
The current JavaScript context
3840
"""
39-
defmacro this()
41+
defexternal this()
4042

4143
@doc """
4244
Mutates an existing JavaScript object.
4345
ex:
4446
ElixirScript.JS.mutate elem, "width", 100
4547
"""
46-
defmacro mutate(object, key, value)
48+
defexternal mutate(object, key, value)
4749

4850

4951
@doc """
@@ -53,5 +55,5 @@ defmodule ElixirScript.JS do
5355
ex:
5456
ElixirScript.JS.map_to_object(%{my: "map"})
5557
"""
56-
defmacro map_to_object(object)
58+
defexternal map_to_object(object)
5759
end

lib/elixir_script/passes/translate/clause.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
defmodule ElixirScript.Translate.Clause do
2+
@moduledoc false
3+
4+
# Handles translation of all of the clause ASTs
5+
26
alias ESTree.Tools.Builder, as: J
37
alias ElixirScript.Translate.Form
48
alias ElixirScript.Translate.Forms.Pattern
59
alias ElixirScript.Translate.Function
610

7-
@moduledoc """
8-
Handles translation of all of the clause ASTs
9-
"""
10-
1111
@patterns J.member_expression(
1212
J.member_expression(
1313
J.identifier("ElixirScript"),

lib/elixir_script/passes/translate/form.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
defmodule ElixirScript.Translate.Form do
2+
@moduledoc false
3+
4+
# Handles translation of all forms that are not functions or clauses
5+
26
alias ESTree.Tools.Builder, as: J
37
alias ElixirScript.Translate.Forms.{Bitstring, Match, Try, For, Receive, Remote, Pattern, With}
48
alias ElixirScript.Translate.Clause
59
require Logger
610

7-
@moduledoc """
8-
Handles translation of all forms that are not functions or clauses
9-
"""
10-
1111
def compile!(ast, state) do
1212
{js_ast, _} = compile(ast, state)
1313

lib/elixir_script/passes/translate/function.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
defmodule ElixirScript.Translate.Function do
2+
@moduledoc false
3+
4+
# Translates the given Elixir function AST into the
5+
# equivalent JavaScript AST.
6+
27
alias ESTree.Tools.Builder, as: J
38
alias ElixirScript.Translate.{Clause, Form}
49
alias ElixirScript.Translate.Forms.Pattern
510

6-
@moduledoc """
7-
Translates the given Elixir function AST into the
8-
equivalent JavaScript AST.
9-
"""
10-
1111
def patterns_ast() do
1212
J.member_expression(
1313
J.member_expression(

mix.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
%{"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"},
2-
"certifi": {:hex, :certifi, "1.2.1", "c3904f192bd5284e5b13f20db3ceac9626e14eeacfbb492e19583cf0e37b22be", [:rebar3], [], "hexpm"},
3-
"credo": {:hex, :credo, "0.8.3", "efe6e9078de64cefdd25d8df7a97292e29e63f42a8988990340eaf1f40d93224", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"},
4-
"earmark": {:hex, :earmark, "1.2.2", "f718159d6b65068e8daeef709ccddae5f7fdc770707d82e7d126f584cd925b74", [:mix], [], "hexpm"},
2+
"certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], [], "hexpm"},
3+
"credo": {:hex, :credo, "0.8.4", "4e50acac058cf6292d6066e5b0d03da5e1483702e1ccde39abba385c9f03ead4", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"},
4+
"earmark": {:hex, :earmark, "1.2.3", "206eb2e2ac1a794aa5256f3982de7a76bf4579ff91cb28d0e17ea2c9491e46a4", [:mix], [], "hexpm"},
55
"estree": {:hex, :estree, "2.6.1", "0a17cc0e9e35315dc4fcd79d30a746b1f3e9ed654be6084ce882ab491165ae22", [:mix], [], "hexpm"},
66
"ex_doc": {:hex, :ex_doc, "0.16.2", "3b3e210ebcd85a7c76b4e73f85c5640c011d2a0b2f06dcdf5acdb2ae904e5084", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
7-
"excoveralls": {:hex, :excoveralls, "0.7.1", "3dd659db19c290692b5e2c4a2365ae6d4488091a1ba58f62dcbdaa0c03da5491", [:mix], [{:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: false]}, {:hackney, ">= 0.12.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
7+
"excoveralls": {:hex, :excoveralls, "0.7.2", "f69ede8c122ccd3b60afc775348a53fc8c39fe4278aee2f538f0d81cc5e7ff3a", [:mix], [{:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: false]}, {:hackney, ">= 0.12.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
88
"exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm"},
99
"fs": {:hex, :fs, "3.4.0", "6d18575c250b415b3cad559e6f97a4c822516c7bc2c10bfbb2493a8f230f5132", [:rebar3], [], "hexpm"},
10-
"hackney": {:hex, :hackney, "1.8.6", "21a725db3569b3fb11a6af17d5c5f654052ce9624219f1317e8639183de4a423", [:rebar3], [{:certifi, "1.2.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.0.2", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
11-
"idna": {:hex, :idna, "5.0.2", "ac203208ada855d95dc591a764b6e87259cb0e2a364218f215ad662daa8cd6b4", [:rebar3], [{:unicode_util_compat, "0.2.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
10+
"hackney": {:hex, :hackney, "1.9.0", "51c506afc0a365868469dcfc79a9d0b94d896ec741cfd5bd338f49a5ec515bfe", [:rebar3], [{:certifi, "2.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
11+
"idna": {:hex, :idna, "5.1.0", "d72b4effeb324ad5da3cab1767cb16b17939004e789d8c0ad5b70f3cea20c89a", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
1212
"jsx": {:hex, :jsx, "2.8.2", "7acc7d785b5abe8a6e9adbde926a24e481f29956dd8b4df49e3e4e7bcc92a018", [:mix, :rebar3], [], "hexpm"},
1313
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"},
1414
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"},
1515
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"},
16-
"unicode_util_compat": {:hex, :unicode_util_compat, "0.2.0", "dbbccf6781821b1c0701845eaf966c9b6d83d7c3bfc65ca2b78b88b8678bfa35", [:rebar3], [], "hexpm"}}
16+
"unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], [], "hexpm"}}

0 commit comments

Comments
 (0)