| 2152 | } |
| 2153 | |
| 2154 | int |
| 2155 | nhl_pcall_handle(lua_State *L, int nargs, int nresults, const char *name, |
| 2156 | NHL_pcall_action npa) |
| 2157 | { |
| 2158 | int rv = nhl_pcall(L, nargs, nresults, name); |
| 2159 | if (rv) { |
| 2160 | nhl_user_data *nud; |
| 2161 | (void) lua_getallocf(L, (void **) &nud); |
| 2162 | /* XXX can we get a lua stack trace as well? */ |
| 2163 | switch (npa) { |
| 2164 | case NHLpa_panic: |
| 2165 | panic("Lua error %d:%s %s", nud->sid, |
| 2166 | nud->name ? nud->name : "(unknown)", lua_tostring(L, -1)); |
| 2167 | /*NOTREACHED*/ |
| 2168 | break; |
| 2169 | case NHLpa_impossible: |
| 2170 | impossible("Lua error: %d:%s %s", nud->sid, |
| 2171 | nud->name ? nud->name : "(unknown)", |
| 2172 | lua_tostring(L, -1)); |
| 2173 | /* Drop the error. If the caller cares, use nhl_pcall(). */ |
| 2174 | lua_pop(L, 1); |
| 2175 | } |
| 2176 | } |
| 2177 | return rv; |
| 2178 | } |
| 2179 | |
| 2180 | /* XXX impossible() should be swappable with pline/nothing/panic via flag */ |
| 2181 | /* read lua code/data from a dlb module or an external file |
no test coverage detected