From 58e26c8dbcfa60a9a1550f026b5cf7059d29fdd7 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 5 May 2014 17:35:13 +1000 Subject: Support light user data in the Lua argument support functions. --- src/libraries/Runnr.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/libraries') diff --git a/src/libraries/Runnr.c b/src/libraries/Runnr.c index a24e7f5..f316755 100644 --- a/src/libraries/Runnr.c +++ b/src/libraries/Runnr.c @@ -45,6 +45,7 @@ void dumpStack(lua_State *L, int i) // str $ // bool ! // C func & +// lightuserdata * // table.field @ Expects an integer and a string. // nil ~ // table {} Starts and stops filling up a new table. @@ -53,7 +54,6 @@ void dumpStack(lua_State *L, int i) // FIXME: Still to do, if we ever use them - // stack = Get a value from the stack, expects a stack index. // userdata + -// lightuserdata * // thread ^ static char *_push_name(lua_State *L, char *q, int *idx) // Stack usage [-0, +1, e or m] @@ -167,6 +167,17 @@ int pull_lua(lua_State *L, int i, char *params, ...) // Stack usage - } break; } + case '*': + { + if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, e] + if (lua_islightuserdata(L, j)) // Stack usage [-0, +0, -] + { + void **v = va_arg(vl, void **); + *v = lua_touserdata(L, j); // Stack usage [-0, +0, -] + n++; + } + break; + } default: { get = EINA_FALSE; @@ -257,6 +268,12 @@ int push_lua(lua_State *L, char *params, ...) // Stack usage [-0, +n, em] lua_getfield(L, tabl, field); // Stack usage [-0, +1, e] break; } + case '*': + { + if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] + lua_pushlightuserdata(L, va_arg(vl, void *)); // Stack usage [-0, +1, m] + break; + } case '&': { if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] -- cgit v1.1