Skip to content

Commit

Permalink
Remove support for deprecated format of bundlex.exs
Browse files Browse the repository at this point in the history
  • Loading branch information
mickel8 committed Jul 22, 2020
1 parent 213c1b9 commit 7f901a8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
4 changes: 2 additions & 2 deletions bundlex.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ defmodule Unifex.BundlexProject do
deps: [shmex: :lib_nif],
src_base: "unifex/nif/unifex",
sources: ["unifex.c", "payload.c"],
interfaces: [:nif]
interface: :nif
],
unifex: [
src_base: "unifex/cnode/unifex",
sources: ["unifex.c", "cnode.c", "payload.c"],
interfaces: [:cnode]
interface: :cnode
]
]
end
Expand Down
29 changes: 12 additions & 17 deletions lib/unifex/code_generator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,18 @@ defmodule Unifex.CodeGenerator do

defp get_generator(%Specs{name: name, interface: nil}) do
{:ok, bundlex_project} = Bundlex.Project.get()

[:nifs, :cnodes, :natives, :libs]
|> Enum.find(&(bundlex_project.config |> Keyword.get(&1, []) |> Keyword.has_key?(name)))
|> case do
:nifs ->
Unifex.CodeGenerators.NIF

:cnodes ->
Unifex.CodeGenerators.CNode

:natives ->
interfaces = bundlex_project.config[:natives][name][:interfaces]
get_generator(get_generator_module_name(List.first(interfaces)))

_ ->
Unifex.CodeGenerators.NIF
end
config = bundlex_project.config

[:natives, :libs]
|> Enum.find(&(config |> Keyword.get(&1, []) |> Keyword.has_key?(name)))
|> (fn type ->
interfaces = Keyword.get(config[type][name], :interface, []) |> Bunch.listify()

case interfaces do
[] -> Unifex.CodeGenerators.NIF
_ -> get_generator(get_generator_module_name(List.first(interfaces)))
end
end).()
end

defp get_generator(%Specs{interface: interface}) do
Expand Down
2 changes: 1 addition & 1 deletion lib/unifex/loader.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule Unifex.Loader do
arg_names = args |> Keyword.keys() |> Enum.map(&Macro.var(&1, nil))

quote do
defnifp unquote(wrapped_name)(unquote_splicing(arg_names))
defnifp(unquote(wrapped_name)(unquote_splicing(arg_names)))

@compile {:inline, [unquote({name, length(args)})]}
def unquote(name)(unquote_splicing(arg_names)) do
Expand Down

0 comments on commit 7f901a8

Please sign in to comment.