lua-users home
lua-l archive

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


Hey lua-l,

I'm writing a binding to libedit, and there's a function el_set with
the following signature:

int el_set(EditLine *el, int op, ...)

When op is EL_BIND, the varargs accepted are:

const char *, ..., NULL

I'm wondering what the best practice for binding this function to Lua
would be.  I figure I have two choices:

1) Write function calls for a reasonable number of arguments.  Ex.

if(lua_gettop(L) == 1) {
  el_set(el, EL_BIND, something, luaL_checkstring(L, 1), NULL);
} else if(lua_gettop(L) == 2) {
  el_set(el, EL_BIND, something, luaL_checkstring(L, 1), luaL_checkstring(L, 2), NULL);
} /* etc. */

2) Use libffi to make the call to el_set.

What would be the recommended way to do this?

Thanks,
Rob

Attachment: signature.asc
Description: PGP signature