From 4f5f2fe36732d7809a4c0e0856cb9aca02e9ce24 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 21 Jan 2010 14:49:21 -0200 Subject: new function 'luaL_cpcall' --- lauxlib.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lauxlib.c') diff --git a/lauxlib.c b/lauxlib.c index 2eaa163b..0e449ac3 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.195 2009/12/17 16:20:01 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.196 2009/12/22 15:32:50 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -773,3 +773,14 @@ LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver) { ver, *v); } + +LUALIB_API int luaL_cpcall (lua_State *L, lua_CFunction f, int nargs, + int nresults) { + nargs++; /* to include function itself */ + lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_CPCALL); + lua_insert(L, -nargs); + lua_pushlightuserdata(L, &f); + lua_insert(L, -nargs); + return lua_pcall(L, nargs, nresults, 0); +} + -- cgit v1.2.3-55-g6feb