diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-01-21 14:49:21 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-01-21 14:49:21 -0200 |
| commit | 4f5f2fe36732d7809a4c0e0856cb9aca02e9ce24 (patch) | |
| tree | cf1a2ef6793c58c4424248b2aff88e457a46a000 /lauxlib.c | |
| parent | 01586d539e214f844fc34dd552ff06843ac0c4f9 (diff) | |
| download | lua-4f5f2fe36732d7809a4c0e0856cb9aca02e9ce24.tar.gz lua-4f5f2fe36732d7809a4c0e0856cb9aca02e9ce24.tar.bz2 lua-4f5f2fe36732d7809a4c0e0856cb9aca02e9ce24.zip | |
new function 'luaL_cpcall'
Diffstat (limited to 'lauxlib.c')
| -rw-r--r-- | lauxlib.c | 13 |
1 files changed, 12 insertions, 1 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.c,v 1.195 2009/12/17 16:20:01 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.196 2009/12/22 15:32:50 roberto Exp roberto $ |
| 3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -773,3 +773,14 @@ LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver) { | |||
| 773 | ver, *v); | 773 | ver, *v); |
| 774 | } | 774 | } |
| 775 | 775 | ||
| 776 | |||
| 777 | LUALIB_API int luaL_cpcall (lua_State *L, lua_CFunction f, int nargs, | ||
| 778 | int nresults) { | ||
| 779 | nargs++; /* to include function itself */ | ||
| 780 | lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_CPCALL); | ||
| 781 | lua_insert(L, -nargs); | ||
| 782 | lua_pushlightuserdata(L, &f); | ||
| 783 | lua_insert(L, -nargs); | ||
| 784 | return lua_pcall(L, nargs, nresults, 0); | ||
| 785 | } | ||
| 786 | |||
