<feed xmlns='http://www.w3.org/2005/Atom'>
<title>luci/contrib/package/ucode-mod-lua/src/lua.c, branch master</title>
<subtitle>Lua Configuration Interface (mirror)</subtitle>
<id>https://git-03.infra.openwrt.org/project/luci/atom?h=master</id>
<link rel='self' href='https://git-03.infra.openwrt.org/project/luci/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/luci/'/>
<updated>2022-10-24T23:03:36Z</updated>
<entry>
<title>ucode-mod-lua: improve error reporting</title>
<updated>2022-10-24T23:03:36Z</updated>
<author>
<name>Jo-Philipp Wich</name>
</author>
<published>2022-09-15T14:25:27Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/luci/commit/?id=c1ceeebdd037e0d3e591fff1241482f118eef286'/>
<id>urn:sha1:c1ceeebdd037e0d3e591fff1241482f118eef286</id>
<content type='text'>
Avoid redundancies in generated exception messages and include Lua
tracebacks when catching exceptions in protected calls.

Signed-off-by: Jo-Philipp Wich &lt;jo@mein.io&gt;
</content>
</entry>
<entry>
<title>ucode-mod-lua: various fixes</title>
<updated>2022-08-29T22:06:15Z</updated>
<author>
<name>Jo-Philipp Wich</name>
</author>
<published>2022-08-26T12:11:57Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/luci/commit/?id=629eb171b7ec47c7f608962d013a4f7894fac00d'/>
<id>urn:sha1:629eb171b7ec47c7f608962d013a4f7894fac00d</id>
<content type='text'>
Properly handle accesses to properties of the userdatum itself in the
lua_uv_index() __index metamethod and treat integer keys as array indexes
in case of wrapped ucode array values. Also fix an incorrect refcount
decrement in the function.

Also fix uc_lua_vm_get() and uc_lua_lv_getraw() to gracefully handle
accesses to not defined or non-table values and ensure that those functions
properly reset the Lua stack after they complete.

Signed-off-by: Jo-Philipp Wich &lt;jo@mein.io&gt;
</content>
</entry>
<entry>
<title>ucode-mod-lua: support prototype lookups and method calls on ucode values</title>
<updated>2022-08-26T08:11:17Z</updated>
<author>
<name>Jo-Philipp Wich</name>
</author>
<published>2022-08-20T23:32:12Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/luci/commit/?id=42201e336d53412c63dbfde934786841d7bf29d2'/>
<id>urn:sha1:42201e336d53412c63dbfde934786841d7bf29d2</id>
<content type='text'>
Expose ucode arrays and objects with prototypes as userdata proxy objects
to Lua and extend the userdata metadatable with an __index metamethod to
lookup not found properties in the ucode values prototype chain.

Also extend the __call metamethod implementation to infer method call
status from the activation record in order to invoke ucode functions with
the correct `this` context when called as method from Lua.

Signed-off-by: Jo-Philipp Wich &lt;jo@mein.io&gt;
</content>
</entry>
<entry>
<title>ucode-mod-lua: add workaround for dynamic Lua extension loading</title>
<updated>2022-07-27T14:22:25Z</updated>
<author>
<name>Jo-Philipp Wich</name>
</author>
<published>2022-07-27T14:18:52Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/luci/commit/?id=26afb7cbec6108b23c9381937489bb05a833c7e6'/>
<id>urn:sha1:26afb7cbec6108b23c9381937489bb05a833c7e6</id>
<content type='text'>
Reopen self with dlopen(RTLD_GLOBAL) in order to export liblua symbols for
runtime loading of dynamic Lua extensions.

Reported-by: Stijn Tintel &lt;stijn@linux-ipv6.be&gt;
Tested-by: Stijn Tintel &lt;stijn@linux-ipv6.be&gt;
Signed-off-by: Jo-Philipp Wich &lt;jo@mein.io&gt;
</content>
</entry>
<entry>
<title>contrib: introduce ucode-mod-lua</title>
<updated>2022-05-30T12:25:33Z</updated>
<author>
<name>Jo-Philipp Wich</name>
</author>
<published>2022-05-19T15:10:17Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/luci/commit/?id=70ff5c3c4a0c30f15cc0d115011f5d9ac6146ef6'/>
<id>urn:sha1:70ff5c3c4a0c30f15cc0d115011f5d9ac6146ef6</id>
<content type='text'>
The ucode-mod-lua library provides an ucode-to-Lua bridge and a set of
functions to instantiate Lua VMs, invoke Lua functions as well as
exchanging data structures between ucode and Lua.

Example usage:

    #!/usr/bin/ucode

    'use strict';

    const lua = require("lua");

    let vm = lua.create();

    vm.set({
    	hello: function(...args) {
    		print(`A ucode "Hello world" function called from Lua! Got arguments: ${args}\n`);
    	},

    	data_from_ucode: {
    		bool: true,
    		float: 1.3,
    		int: 0x11223344,
    		string: "Hello from ucode!",
    		array: [ 1, 2, 3, null, 5 ],
    		object: {
    			apple: "green",
    			banana: "yellow",
    			[5]: "foo",
    			[-1]: null,
    			nested: {
    				a: [ 5, 6 ],
    				b: { c: NaN }
    			}
    		},
    		regexp: /foo/
    	}
    });

    vm.invoke("hello", true, 123, "Foo");
    vm.eval('print("Print from Lua!", data_from_ucode.int * data_from_ucode.float);');

    try {
    	vm.invoke("error", "Throwing a Lua exception...");
    }
    catch (e) {
    	print(`Caught exception: ${e}\n`);
    }

    print(`Lua VM version is: ${vm.get('_G', '_VERSION').value()}\n`);

Signed-off-by: Jo-Philipp Wich &lt;jo@mein.io&gt;
</content>
</entry>
</feed>
