View Source Luex.Functions (luex v0.0.2)

Link to this section Summary

Types

You can import beam functions with this signature

t()

Functions

Import an elixir / erlang function into the lua vm to be called by lua code.

Link to this section Types

@type input() :: ([Luex.lua_value()], Luex.vm() -> Luex.lua_call([Luex.lua_value()]))

You can import beam functions with this signature

@type t() :: Luex.lua_fun()

Link to this section Functions

@spec call(Luex.vm(), t(), [Luex.lua_value()]) :: Luex.lua_call([Luex.lua_value()])
@spec new(Luex.vm(), input()) :: Luex.lua_call(t())

Import an elixir / erlang function into the lua vm to be called by lua code.

Example

iex> fun = fn([a], fun_vm) ->
...>    {["hello " <> a], fun_vm}
...> end
iex> vm = Luex.init() |> Luex.Functions.new(fun) |> Luex.set_value(["a", "b"])
iex> %Luex.CallResult{return: result} = Luex.do_inline(vm, """
...>   return a.b("Demo")
...> """)
iex> result
["hello Demo"]