lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


This is my first foray into writing my first Lua C module. I've patched lots of them for my z/OS port and have a reasonable understanding of the API
but I'm looking for best practice.

On z/OS the UI is called ISPF and everybody uses it. In recent years there have been Eclipse GUIs for most of the products but nobody uses them. ISPF is very simple and uses an arcane panel markup language backed by a services API http://pic.dhe.ibm.com/infocenter/zos/v1r11/index.jsp?topic=/com.ibm.zos.r11.f54sg00/ispzsg80.htm.

The ISPF services APIs are function pointers which are dynamically loaded similar to a shared object.

// ISPF API functions.
typedef int (isplink_t)();
typedef int (ispexec_t)( size_t, const char * );

struct ISPF_services
{
   isplink_t * isplink;
   ispexec_t * ispexec;
} api;

// load ISPLINK/ISPEXEC services
api.isplink = ( isplink_t * ) fetch("ISPLINK");
api.ispexec = ( ispexec_t * ) fetch("ISPEXEC");

Is it better to return the API as userdata or create a table? I'm a neophyte so bear with me.

I want to be able to do something like this

ispf = require("ispf")

while ispf:exec("DISPLAY PANEL(P)") == 0 do
   -- process the panel
end