From d628212254edde5395a5a4889164ddd870234d0f Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 1 Jul 2017 17:39:39 -0400 Subject: [PATCH] Lua API: Use CallWithCatchWrapper for a few more functions This produces more readable backtraces when native functions that aren't wrapped using wrap_function() throw exceptions. --- library/LuaApi.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index 8d0fa22b8..39b4b41cb 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -1372,6 +1372,7 @@ static void OpenModule(lua_State *state, const char *mname, #define WRAPM(module, function) { #function, df::wrap_function(module::function,true) } #define WRAP(function) { #function, df::wrap_function(function,true) } #define WRAPN(name, function) { #name, df::wrap_function(function,true) } +#define CWRAP(name, function) { #name, &Lua::CallWithCatchWrapper } /***** DFHack module *****/ @@ -2082,10 +2083,10 @@ static const luaL_Reg dfhack_buildings_funcs[] = { { "findAtTile", buildings_findAtTile }, { "findCivzonesAt", buildings_findCivzonesAt }, { "getCorrectSize", buildings_getCorrectSize }, - { "setSize", &Lua::CallWithCatchWrapper }, - { "getStockpileContents", buildings_getStockpileContents }, + CWRAP(setSize, buildings_setSize), + CWRAP(getStockpileContents, buildings_getStockpileContents), { "findPenPitAt", buildings_findPenPitAt }, - { "getCageOccupants", &Lua::CallWithCatchWrapper }, + CWRAP(getCageOccupants, buildings_getCageOccupants), { NULL, NULL } }; @@ -2316,9 +2317,9 @@ static const luaL_Reg dfhack_screen_funcs[] = { { "paintString", screen_paintString }, { "fillRect", screen_fillRect }, { "findGraphicsTile", screen_findGraphicsTile }, - { "show", &Lua::CallWithCatchWrapper }, - { "dismiss", screen_dismiss }, - { "isDismissed", screen_isDismissed }, + CWRAP(show, screen_show), + CWRAP(dismiss, screen_dismiss), + CWRAP(isDismissed, screen_isDismissed), { "_doSimulateInput", screen_doSimulateInput }, { "keyToChar", screen_keyToChar }, { "charToKey", screen_charToKey },