View Source Luex.Table (luex v0.0.2)
Link to this section Summary
Functions
fold over each key value pair of a referenced table
turn a call result into an elixir map. not recrusive!
get data from a lua table, not recursive
allocate a new table in the virtual machine
Link to this section Types
@type data() :: %{required(key()) => Luex.lua_value()}
@type folder(acc) :: (key(), Luex.lua_value(), acc -> acc)
@type key() :: Luex.lua_bool() | Luex.lua_string() | Luex.lua_number() | Luex.lua_table() | Luex.lua_userdata() | Luex.lua_fun()
Every lua type, execpt for nil can be used as key in a table.
Link to this section Functions
@spec fold(Luex.vm(), Luex.lua_table(), acc, folder(acc)) :: acc when acc: any()
fold over each key value pair of a referenced table
@spec get_data(Luex.lua_call(Luex.lua_table())) :: %{ required(key()) => Luex.lua_value() }
turn a call result into an elixir map. not recrusive!
Example
iex> Luex.init()
...> |> Luex.do_inline("""
...> a = {}
...> a.x = 42
...> a.hello = "world"
...> """)
...> |> Luex.get_value(["a"])
...> |> Luex.Table.get_data()
%{"x" => 42, "hello" => "world"}
@spec get_data(Luex.vm(), Luex.lua_table()) :: %{required(key()) => Luex.lua_value()}
get data from a lua table, not recursive
Example
iex> %Luex.CallResult{vm: vm} = Luex.init() |> Luex.do_inline("""
...> a = {}
...> a.x = 42
...> a.hello = "world"
...> """)
iex> %Luex.CallResult{return: a_tref, vm: vm} = Luex.get_value(vm, ["a"])
iex> Luex.Table.get_data(vm, a_tref)
%{"x" => 42, "hello" => "world"}
@spec get_key(Luex.vm(), Luex.lua_table(), key()) :: Luex.lua_call(Luex.lua_value())
@spec get_keys(Luex.vm(), Luex.lua_table()) :: [key()]
@spec new(Luex.vm(), %{required(key()) => Luex.lua_value()}) :: Luex.lua_call(Luex.lua_table())
allocate a new table in the virtual machine
@spec set_key(Luex.vm(), Luex.lua_table(), key(), Luex.lua_value()) :: Luex.vm()