This document describes:
The standalone version has been built in a number of configurations:
The main program is defined in "mlux.c", which gets expanded to "lux.c" during the build. This is an equivalent version, but with all Lux-related includes merged into a single source file (the "onesrc.tcl" script does this). Similarly, the Lux core is defined in "mluxsys.c", which gets expanded to "luxsys.c" during the build. This represents the main code, and incorporates all of Lua 4.0 with a few minor modifications.
The logic which defines the startup process for standalone use is in "run.lua", which is compiled with "luac" and then converted into a C array datastructure by 'examples/bin2c.lua'. A similar approach is used for "preload.lua", but this script gets incorporated into all Lux configurations, not just the standalone one. In its current form, this script defines functions to decode zip archives.
The code in "mlux.c" does the following:
% load ./tclux.so
% tclux gs dostring {lux.ZipBoot('./tclux.so')}
Finally, a "scripted document" approach can be used, by creating a file which starts off as shell script - followed by a zip archive with the bootstrap. On Unix, the following will create such a runnable scripted document:
$ echo '#!/usr/bin/env lux' >myapp
$ cat myapp.zip >>myapp
$ chmod +x myapp
On Win32, you'll need to also create a "myapp.bat" file, containing just:
@lux myappThis will make the scripted document "runnable" / "double-clickable".
Some points to keep in mind: if you use the "luxr" runtime (which is a few Kb smaller), make sure the scripts you put into the archive are pre-compiled by "luac". And if you don't, be careful to store scripts with only LF's as line endings, since the extracted files do not get converted according to the different ways Windows and Macintosh treat line endings.
TcLux lets you run Lux/Lua scripts from Tcl. The wrapper source is "tclux.c", it will eventually be merged into "luxsys.c".
TcLux defines a single tclux command, which takes a format string plus a variable number of arguments. Each character in the format string describes one argument, the size of the format string must correspond to the number of remaining arguments. The types currently defined are:
PyLux lets you run Lux/Lua scripts from Python. The wrapper source is "pylux.c", it will eventually be merged into "luxsys.c".
PyLux defines a pylux module with a single eval command, which takes a format string plus a variable number of arguments. Each character in the format string describes one argument, the size of the format string must correspond to the number of remaining arguments. The types currently defined are:
The "r" (reference) mechanism is useful during callbacks, because PyLux sets up references for tables and userdata, and then passes those references. In the callback, you can then use those references to call back (yes, it gets confusing!) into Lux, e.g. to extract individual values as needed. Note that references do not remain valid after the callback returns.
PerLux lets you run Lux/Lua scripts from Perl. The wrapper source is "perlux.c", it will eventually be merged into "luxsys.c".
This interface is still limited to string-only evaluation, e.g.:
perlux::eval("print('Hello Lux!')");
A better interface, similar to TcLux and PyLux, will be implemented.
RubyLux lets you run Lux/Lua scripts from Ruby. The wrapper source is "rubylux.c", it will eventually be merged into "luxsys.c".
This interface is still limited to string-only evaluation, e.g.:
Rubylux.eval("print('Hello Lux!')");
A better interface, similar to TcLux and PyLux, will be implemented.
-- Coen Siegerink <[email protected]>
Mission Impossible 5oftware Team https://www.equi4.com/lux/