From bcf47bc67cf3e1c2f410a81e26ceab1bdab06b4a Mon Sep 17 00:00:00 2001 From: kwolekr Date: Wed, 5 Aug 2015 00:49:35 -0400 Subject: Improve Script CPP API diagnostics --- src/script/common/c_internal.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/script/common/c_internal.h') diff --git a/src/script/common/c_internal.h b/src/script/common/c_internal.h index eb9181b09..54cdd7da7 100644 --- a/src/script/common/c_internal.h +++ b/src/script/common/c_internal.h @@ -34,6 +34,16 @@ extern "C" { #include "common/c_types.h" +#define PCALL_RESL(L, RES) do { \ + int result_ = (RES); \ + if (result_ != 0) { \ + script_error((L), result_, __FUNCTION__); \ + } \ +} while (0) + +#define script_run_callbacks(L, nargs, mode) \ + script_run_callbacks_f((L), (nargs), (mode), __FUNCTION__) + // What script_run_callbacks does with the return values of callbacks. // Regardless of the mode, if only one callback is defined, // its return value is the total return value. @@ -67,8 +77,9 @@ enum RunCallbacksMode std::string script_get_backtrace(lua_State *L); int script_error_handler(lua_State *L); int script_exception_wrapper(lua_State *L, lua_CFunction f); -void script_error(lua_State *L); -void script_run_callbacks(lua_State *L, int nargs, RunCallbacksMode mode); -void log_deprecated(lua_State *L, std::string message); +void script_error(lua_State *L, int pcall_result, const char *fxn); +void script_run_callbacks_f(lua_State *L, int nargs, + RunCallbacksMode mode, const char *fxn); +void log_deprecated(lua_State *L, const std::string &message); #endif /* C_INTERNAL_H_ */ -- cgit v1.2.3