From cafef75fda7a5cbdc45803492eeaadc29c32df2a Mon Sep 17 00:00:00 2001 From: Dave Lucia Date: Mon, 9 Sep 2024 09:45:50 -0400 Subject: [PATCH] walk it back --- lib/lua.ex | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/lib/lua.ex b/lib/lua.ex index d440117..521052f 100644 --- a/lib/lua.ex +++ b/lib/lua.ex @@ -162,7 +162,7 @@ defmodule Lua do `Lua.set!/3` can also be used to expose Elixir functions - iex> lua = Lua.set!(Lua.new!(), [:sum], &Enum.sum/1) + iex> lua = Lua.set!(Lua.new(), [:sum], fn args -> [Enum.sum(args)] end) iex> {[10], _lua} = Lua.eval!(lua, "return sum(1, 2, 3, 4)") """ @@ -183,13 +183,6 @@ defmodule Lua do end end) - value = - if is_function(value) do - wrap_anonymous_function(value) - else - value - end - case :luerl_new.set_table_keys_dec(keys, value, state) do {:ok, _value, state} -> wrap(state) @@ -504,24 +497,6 @@ defmodule Lua do |> Lua.API.install(module, scope, opts[:data]) end - defp wrap_anonymous_function(func) when is_function(func, 1) do - fn args -> - case func.(args) do - {ret, %Lua{state: state}} -> {List.wrap(ret), state} - other -> List.wrap(other) - end - end - end - - defp wrap_anonymous_function(func) when is_function(func, 2) do - fn args, state -> - case func.(args, state) do - {ret, %Lua{state: state}} -> {List.wrap(ret), state} - other -> List.wrap(other) - end - end - end - defp wrap_variadic_function(module, function_name, with_state?) do # formatted = Util.format_function(module.scope() ++ [function_name], 0)