Author: Pavel Labath Date: 2021-12-06T14:57:44+01:00 New Revision: a52af6d3714fa6ea749783400a98dcfad94814b0
URL: https://github.com/llvm/llvm-project/commit/a52af6d3714fa6ea749783400a98dcfad94814b0 DIFF: https://github.com/llvm/llvm-project/commit/a52af6d3714fa6ea749783400a98dcfad94814b0.diff LOG: [lldb] Remove extern "C" from lldb-swig-lua interface This is the lua equivalent of 9a14adeae0. Added: Modified: lldb/bindings/lua/lua-wrapper.swig lldb/bindings/lua/lua.swig lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp Removed: ################################################################################ diff --git a/lldb/bindings/lua/lua-wrapper.swig b/lldb/bindings/lua/lua-wrapper.swig index c51911bb6bf73..4ca406137d6cf 100644 --- a/lldb/bindings/lua/lua-wrapper.swig +++ b/lldb/bindings/lua/lua-wrapper.swig @@ -4,26 +4,9 @@ template <typename T> void PushSBClass(lua_State* L, T* obj); -%} - -%runtime %{ -#ifdef __cplusplus -extern "C" { -#endif - -void LLDBSwigLuaCallLuaLogOutputCallback(const char *str, void *baton); -int LLDBSwigLuaCloseFileHandle(lua_State *L); - -#ifdef __cplusplus -} -#endif -%} - -%wrapper %{ - // This function is called from Lua::CallBreakpointCallback -SWIGEXPORT llvm::Expected<bool> -LLDBSwigLuaBreakpointCallbackFunction +llvm::Expected<bool> +lldb_private::LLDBSwigLuaBreakpointCallbackFunction ( lua_State *L, lldb::StackFrameSP stop_frame_sp, @@ -67,8 +50,8 @@ LLDBSwigLuaBreakpointCallbackFunction } // This function is called from Lua::CallWatchpointCallback -SWIGEXPORT llvm::Expected<bool> -LLDBSwigLuaWatchpointCallbackFunction +llvm::Expected<bool> +lldb_private::LLDBSwigLuaWatchpointCallbackFunction ( lua_State *L, lldb::StackFrameSP stop_frame_sp, @@ -101,7 +84,7 @@ LLDBSwigLuaWatchpointCallbackFunction return stop; } -SWIGEXPORT void +static void LLDBSwigLuaCallLuaLogOutputCallback(const char *str, void *baton) { lua_State *L = (lua_State *)baton; @@ -113,7 +96,7 @@ LLDBSwigLuaCallLuaLogOutputCallback(const char *str, void *baton) { lua_pcall(L, 1, 0, 0); } -int LLDBSwigLuaCloseFileHandle(lua_State *L) { +static int LLDBSwigLuaCloseFileHandle(lua_State *L) { return luaL_error(L, "You cannot close a file handle used by lldb."); } diff --git a/lldb/bindings/lua/lua.swig b/lldb/bindings/lua/lua.swig index 21fa44c8b4d86..92f85fee22fc3 100644 --- a/lldb/bindings/lua/lua.swig +++ b/lldb/bindings/lua/lua.swig @@ -17,6 +17,7 @@ #include "llvm/Support/Error.h" #include "llvm/Support/FormatVariadic.h" #include "../bindings/lua/lua-swigsafecast.swig" +#include "../source/Plugins/ScriptInterpreter/Lua/SWIGLuaBridge.h" // required headers for typemaps #include "lldb/Host/File.h" diff --git a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp index e99b7b88379a7..ce726c8de6254 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "Lua.h" +#include "SWIGLuaBridge.h" #include "lldb/Host/FileSystem.h" #include "lldb/Utility/FileSpec.h" #include "llvm/Support/Error.h" @@ -15,30 +16,6 @@ using namespace lldb_private; using namespace lldb; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wreturn-type-c-linkage" - -// Disable warning C4190: 'LLDBSwigPythonBreakpointCallbackFunction' has -// C-linkage specified, but returns UDT 'llvm::Expected<bool>' which is -// incompatible with C -#if _MSC_VER -#pragma warning (push) -#pragma warning (disable : 4190) -#endif - -extern "C" llvm::Expected<bool> LLDBSwigLuaBreakpointCallbackFunction( - lua_State *L, lldb::StackFrameSP stop_frame_sp, - lldb::BreakpointLocationSP bp_loc_sp, StructuredDataImpl *extra_args_impl); - -extern "C" llvm::Expected<bool> LLDBSwigLuaWatchpointCallbackFunction( - lua_State *L, lldb::StackFrameSP stop_frame_sp, lldb::WatchpointSP wp_sp); - -#if _MSC_VER -#pragma warning (pop) -#endif - -#pragma clang diagnostic pop - static int lldb_print(lua_State *L) { int n = lua_gettop(L); lua_getglobal(L, "io"); diff --git a/lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp b/lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp index 8d849cae4fbaa..7483fdeb0c306 100644 --- a/lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp +++ b/lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp @@ -7,40 +7,24 @@ //===----------------------------------------------------------------------===// #include "Plugins/ScriptInterpreter/Lua/Lua.h" +#include "Plugins/ScriptInterpreter/Lua/SWIGLuaBridge.h" #include "gtest/gtest.h" using namespace lldb_private; extern "C" int luaopen_lldb(lua_State *L) { return 0; } -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wreturn-type-c-linkage" - -// Disable warning C4190: 'LLDBSwigPythonBreakpointCallbackFunction' has -// C-linkage specified, but returns UDT 'llvm::Expected<bool>' which is -// incompatible with C -#if _MSC_VER -#pragma warning (push) -#pragma warning (disable : 4190) -#endif - -extern "C" llvm::Expected<bool> LLDBSwigLuaBreakpointCallbackFunction( +llvm::Expected<bool> lldb_private::LLDBSwigLuaBreakpointCallbackFunction( lua_State *L, lldb::StackFrameSP stop_frame_sp, lldb::BreakpointLocationSP bp_loc_sp, StructuredDataImpl *extra_args_impl) { return false; } -extern "C" llvm::Expected<bool> LLDBSwigLuaWatchpointCallbackFunction( +llvm::Expected<bool> lldb_private::LLDBSwigLuaWatchpointCallbackFunction( lua_State *L, lldb::StackFrameSP stop_frame_sp, lldb::WatchpointSP wp_sp) { return false; } -#if _MSC_VER -#pragma warning (pop) -#endif - -#pragma clang diagnostic pop - TEST(LuaTest, RunValid) { Lua lua; llvm::Error error = lua.Run("foo = 1"); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits