W-LUA

Wlua is Lua language interpreter with W support.  Lua is an
extendable, dynamically typed, small language especially intended for
embedding. You can get more information about Lua from it's homepage
at:
	http://www.lua.org/

Because of Lua incompatibilities different files are needed for
different Lua files.  Current version compiles by default for Lua v5.1
(latest version of Lua), but there are also files supporting Lua v4.


REQUIREMENTS

To compile W-Lua, you need 'tolua' utility, Lua 5.1 libraries and
development files.  A working W window system enviroment with W and Wt
libraries installed on your system would be a plus too. :-)


FILES

fixwlib.sh	script for generating Wlib.pkg from current Wlib.h
		and coverting it to a Wlib wrapper with 'tolua'.
		Dumps all stuff to 'wlib' module.

fixwt.sh	script for generating W toolkit wrapper from 'wt.pkg'
		with 'tolua'.  Dumps all stuff to 'wt' module.

wlib.pkg	cleaned Wlib.h generated by 'fixwlib.sh'
wlib.c		code generated from above code by 'fixwlib.sh'

wt.pkg		manually cleaned version of Wt.h
wlib.c		code generated by 'fixwt.sh' from above code

lua4.c.diff     Diff from Lua v4 interpreter to wlua4.c
wlua4.c		code for Lua v4 interpreter initializing
		the 'wt' and 'wlib' modules

lua5.c.diff     Diff from Lua v5.1 interpreter to wlua5.c
wlua5.c		code for Lua v5.1 interpreter initializing
		the 'wt' and 'wlib' modules

wlua		compiled W Lua interpreter
Makefile	rules for compiling above

test-wlib.lua	example file demoing some wlib module functions,
		after you've compiled wlua, just run 'wlua test-wlib.lua'
test-wt.lua	example file demoing wt module dialogs
test-both.lua	example file demoing wlib + wt module 3d draw functions


WLIB NOTES

LUA numbers are all floating point and it doesn't support bit
operations. Bitmasks have to be done with 'mask1 + mask2'. For opening
windows, I have added the SIMPLEWIN window attribute constant, which
contains all the usual flags.

'wlib' module has everything that 'Wlib.h' declares except for macros,
W_SEL_* clipboard (string) defines, w_convertFunction() function and
structures (as tolua doesn't support structures with same member names
within the same module). All the stuff is straight under 'wlib'
module.

The redundant 'w_' and 'W_' prefixes have been stripped from Wlib
function and define names and '_t' postfix from the structure names on
conversion from C to Lua. For example, w_open() function can be called
with wlib.open() function and so on.  For usage reference, use W
manual pages (start from 'man Wlib').


W TOOLKIT NOTES

This is work in progress.

The redundant 'wt_' and 'WT_' prefixes have been stripped from W
toolkit function and define names and '_t' postfix from the structure
names on conversion from C to Lua. 'wt.break' was renamed to 'wt.quit'
because Lua (v4.01) interpreter didn't like from a table member named
'break'.

'wt' module has everything that 'Wt.h' declares except for:
- additional input/output (fd) functions
- timeout handling functions
- wt_menu widget and wt_popup utility function
- wt_getopt, wt_setopt, wt_entrybox and wt_dialog functions can
  take only one argument (getopt & setopt are overloaded)
- because 'tolua' doesn't understand callbacks, and most of the
  widgets need at least callback for a function that gets notified
  when widget action happens, ATM you can't do much with 'wt' module.

Because of the last one, until at least ACTION_CB setopt handling has
been implemented, only things you can ATM do with the 'wt' module are:
- use simple info dialog
- get strings from user
- use file selector
- draw 3d boxes, circles and arrows


TODO, FOR W TOOLKIT

Fixing ACTION_CB callback would mean writing separate setopt
(overload?) function handling ACTION_CB type / option, saving Lua
function pointer somewhere else (widget structure?), and giving widget
a separate callback that would work as an intermediary. Widget calls
the intermediary, that pushes it's args to Lua and calls stored Lua
function.  There are different ACTION_CB signatures, for each of them
an intermediary function has to be written + widget type has to be
checked so that correct type of intermediary is used. If widget is of
unknown type (ACTION_CB signature unknown), a Lua error should be
reported.  Quite a bit of stuff...

Wt allocates everything that it returns, but Lua doesn't free them
automatically. This means that memory leaks everytime you get a string
from wt widget.  Fixing this would mean writing quite a few wrapper
functions using tolua.takeownership().

(Above TODO notes were from Lua v4, for Lua v5 something else might
(also) need to be done.)


Enjoy!


1st Oct 2000, 25th May 2003, 30th August 2009,

	- Eero
