rrthomas/luaposix — pull request #21 by gvvaughan (2011-12-26 18:17:00+00:00)
Title: refactor: use lposix-style macro splicing in lcurses.

Make the style of lcurses.c more like lposix.c, with the aid of
splice and stringify macros, and judicious renaming to make
their usage pattern the same too.
* lcurses.c (LCURSES_SPLICE, LCURSES_STR, LCURSES_STR_1):
Analagous to LPOSIX_SPLICE, LPOSIX_STR and LPOSIX_STR_1
respectively.
(LC_NUMBER, LC_NUMBER2, LC_STRING, LC_STRING2, LC_BOOL)
(LC_BOOL2, LC_BOOLOK, LC_BOOLOK2): Change prefix of generated
functions from `lc_' to `C' so that LCURSES_STR_1 can be used
idiomatically.
(LCW_BOOLOK): Likewise, only changing from `lcw_' to `W' prefix.
(LCW_BOOLOK2): New macre used when the curses symbol and the lua
api have different names.
(lcw_new, lcw_get, lcw_check, lc_checkch, lc_optch): Rename from
these...
(lc_newwin, lc_getwin, lc_checkwin, checkch, optch): ...to
these, respectively, no need to namespace static symbols so
carefully. Adjust all callers.
(CC2): Remove.
(CF): New macro for generating FN key exports into lua. Use it
to export all 64 valid FN keys.
(LCW_WIN2): New macro.
(Wsyncup, Wcursyncup, Wsyncdown): Use it to define these
functions.
(LCW_WIN2YX): New macro.
(Wgetyx, Wgetparyx, Wgetbegyx, getmaxyx): Use it to define these
functions.
(LC_ATTROK): New macro.
(Cslk_attron, Cslk_attroff, Cslk_attrset): Use it to define
these functions.
(LC_TOGGLEOK): New macro.
(Ccbreak, Cecho, Craw, Cnl): Use it to define these functions.
(LCW_WINBOOLOK): New macro.
(Wintrflush, Wmeta, Wnodelay, Widlok, Wleaveok, Wscrollok): Use
it to define these functions.
(LCW_WININTOK): New macro.
(Wattroff, Wattron, Wattrset): Use it to define these functions.
(chstrlib, windowlib, curseslib): Much simplified by naming
implementation functions more carefully, and defining temporary
MENTRY macro to expand and splice arguments that populate the
tables.