[lldb] Remove extern "C" from lldb-swig-lua interface

This is the lua equivalent of 9a14adeae0.
This commit is contained in:
Pavel Labath
2021-12-06 14:56:40 +01:00
parent fdc1638b5c
commit a52af6d371
4 changed files with 11 additions and 66 deletions

View File

@@ -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.");
}

View File

@@ -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"

View File

@@ -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");

View File

@@ -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");