Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'lastcanal/table_interface' into new-engine
- Loading branch information
Showing
2 changed files
with
24 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
EXAMPLES = hello \ | ||
hello2 \ | ||
EXAMPLES = hello \ | ||
hello2 \ | ||
hello_table | ||
|
||
ROOTDIR = ../.. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
%% File : hello_table.erl | ||
%% Purpose : Brief demonstration of Luerl table access. | ||
%% Use $ erlc hello_table.erl && erl -pa ../../ebin -s hello_table run -s init stop -noshell | ||
|
||
-module(hello_table). | ||
-export([run/0]). | ||
|
||
run() -> | ||
LuaScript = <<"hello_table = { hello=\"world\" }; return hello_table">>, | ||
{[_Table], Lua0} = luerl:do(LuaScript), | ||
|
||
{World, Lua1} = luerl:get_table([hello_table, hello], Lua0), | ||
{HelloDict, Lua2} = luerl:set_table([hello_table, hello], there, Lua1), | ||
{There, Lua3} = luerl:get_table([hello_table, hello], Lua2), | ||
{HelloDict, Lua4} = luerl:get_table([hello_table], Lua3), | ||
io:format("(1) hello ~s ~s - ~p~n", [There, World, HelloDict]), | ||
|
||
{HelloTab, Lua5} = luerl:set_table1([<<"hello_table">>, <<"goodbye">>], <<"bye">>, Lua4), | ||
{Bye, Lua6} = luerl:get_table1([<<"hello_table">>, <<"goodbye">>], Lua5), | ||
{HelloTab, _Lua7} = luerl:get_table1([<<"hello_table">>], Lua6), | ||
io:format("(2) ~s - ~p~n", [Bye, HelloTab]), | ||
done. |