MCPcopy Create free account
hub / github.com/dail8859/NotepadNext / call_function

Function call_function

src/LuaExtension.cpp:257–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255}
256
257[[maybe_unused]] static bool call_function(lua_State *L, int nargs, bool ignoreFunctionReturnValue=false) {
258 bool handled = false;
259 if (L) {
260 int traceback = 0;
261 if (tracebackEnabled) {
262 lua_getglobal(L, "debug");
263 lua_getfield(L, -1, "traceback");
264 lua_remove(L, -2);
265 if (lua_isfunction(L, -1)) {
266 traceback = lua_gettop(L) - nargs - 1;
267 lua_insert(L, traceback);
268 } else {
269 lua_pop(L, 1);
270 }
271 }
272
273 int result = lua_pcall(L, nargs, ignoreFunctionReturnValue ? 0 : 1, traceback);
274
275 if (traceback) {
276 lua_remove(L, traceback);
277 }
278
279 if (result == LUA_OK) {
280 if (ignoreFunctionReturnValue) {
281 handled = true;
282 } else {
283 handled = (0 != lua_toboolean(L, -1));
284 lua_pop(L, 1);
285 }
286 } else if (result == LUA_ERRRUN) {
287 lua_getglobal(L, "print");
288 lua_insert(L, -2); // use pushed error message
289 lua_pcall(L, 1, 0, 0);
290 } else {
291 lua_pop(L, 1);
292 if (result == LUA_ERRMEM) {
293 hostTraceError("Memory allocation error\n");
294 } else if (result == LUA_ERRERR) {
295 hostTraceError("An error occurred, but cannot be reported due to failure in _TRACEBACK\n");
296 } else {
297 hostTraceError("Unexpected error\n");
298 }
299 }
300 }
301 return handled;
302}
303
304struct ScintillaFailure {
305 sptr_t status;

Callers

nothing calls this directly

Calls 1

hostTraceErrorFunction · 0.85

Tested by

no test coverage detected