aboutsummaryrefslogtreecommitdiff
path: root/src/script/common/c_internal.h
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-08-05 00:49:35 -0400
committerkwolekr <kwolekr@minetest.net>2015-08-05 21:13:03 -0400
commitbcf47bc67cf3e1c2f410a81e26ceab1bdab06b4a (patch)
tree11bd99b70ceb33175d7883cea4ab287cc5b09175 /src/script/common/c_internal.h
parent3183d5a4038f16b5b4cbcfd0dac5f8d458bf8ba2 (diff)
downloadminetest-bcf47bc67cf3e1c2f410a81e26ceab1bdab06b4a.tar.gz
minetest-bcf47bc67cf3e1c2f410a81e26ceab1bdab06b4a.tar.bz2
minetest-bcf47bc67cf3e1c2f410a81e26ceab1bdab06b4a.zip
Improve Script CPP API diagnostics
Diffstat (limited to 'src/script/common/c_internal.h')
-rw-r--r--src/script/common/c_internal.h17
1 files changed, 14 insertions, 3 deletions
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_ */