Skip to content

Commit a52af6d

Browse files
committed
[lldb] Remove extern "C" from lldb-swig-lua interface
This is the lua equivalent of 9a14ade.
1 parent fdc1638 commit a52af6d

File tree

4 files changed

+11
-66
lines changed

4 files changed

+11
-66
lines changed

lldb/bindings/lua/lua-wrapper.swig

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,9 @@ template <typename T>
44
void
55
PushSBClass(lua_State* L, T* obj);
66

7-
%}
8-
9-
%runtime %{
10-
#ifdef __cplusplus
11-
extern "C" {
12-
#endif
13-
14-
void LLDBSwigLuaCallLuaLogOutputCallback(const char *str, void *baton);
15-
int LLDBSwigLuaCloseFileHandle(lua_State *L);
16-
17-
#ifdef __cplusplus
18-
}
19-
#endif
20-
%}
21-
22-
%wrapper %{
23-
247
// This function is called from Lua::CallBreakpointCallback
25-
SWIGEXPORT llvm::Expected<bool>
26-
LLDBSwigLuaBreakpointCallbackFunction
8+
llvm::Expected<bool>
9+
lldb_private::LLDBSwigLuaBreakpointCallbackFunction
2710
(
2811
lua_State *L,
2912
lldb::StackFrameSP stop_frame_sp,
@@ -67,8 +50,8 @@ LLDBSwigLuaBreakpointCallbackFunction
6750
}
6851

6952
// This function is called from Lua::CallWatchpointCallback
70-
SWIGEXPORT llvm::Expected<bool>
71-
LLDBSwigLuaWatchpointCallbackFunction
53+
llvm::Expected<bool>
54+
lldb_private::LLDBSwigLuaWatchpointCallbackFunction
7255
(
7356
lua_State *L,
7457
lldb::StackFrameSP stop_frame_sp,
@@ -101,7 +84,7 @@ LLDBSwigLuaWatchpointCallbackFunction
10184
return stop;
10285
}
10386

104-
SWIGEXPORT void
87+
static void
10588
LLDBSwigLuaCallLuaLogOutputCallback(const char *str, void *baton) {
10689
lua_State *L = (lua_State *)baton;
10790

@@ -113,7 +96,7 @@ LLDBSwigLuaCallLuaLogOutputCallback(const char *str, void *baton) {
11396
lua_pcall(L, 1, 0, 0);
11497
}
11598

116-
int LLDBSwigLuaCloseFileHandle(lua_State *L) {
99+
static int LLDBSwigLuaCloseFileHandle(lua_State *L) {
117100
return luaL_error(L, "You cannot close a file handle used by lldb.");
118101
}
119102

lldb/bindings/lua/lua.swig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "llvm/Support/Error.h"
1818
#include "llvm/Support/FormatVariadic.h"
1919
#include "../bindings/lua/lua-swigsafecast.swig"
20+
#include "../source/Plugins/ScriptInterpreter/Lua/SWIGLuaBridge.h"
2021

2122
// required headers for typemaps
2223
#include "lldb/Host/File.h"

lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "Lua.h"
10+
#include "SWIGLuaBridge.h"
1011
#include "lldb/Host/FileSystem.h"
1112
#include "lldb/Utility/FileSpec.h"
1213
#include "llvm/Support/Error.h"
@@ -15,30 +16,6 @@
1516
using namespace lldb_private;
1617
using namespace lldb;
1718

18-
#pragma clang diagnostic push
19-
#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
20-
21-
// Disable warning C4190: 'LLDBSwigPythonBreakpointCallbackFunction' has
22-
// C-linkage specified, but returns UDT 'llvm::Expected<bool>' which is
23-
// incompatible with C
24-
#if _MSC_VER
25-
#pragma warning (push)
26-
#pragma warning (disable : 4190)
27-
#endif
28-
29-
extern "C" llvm::Expected<bool> LLDBSwigLuaBreakpointCallbackFunction(
30-
lua_State *L, lldb::StackFrameSP stop_frame_sp,
31-
lldb::BreakpointLocationSP bp_loc_sp, StructuredDataImpl *extra_args_impl);
32-
33-
extern "C" llvm::Expected<bool> LLDBSwigLuaWatchpointCallbackFunction(
34-
lua_State *L, lldb::StackFrameSP stop_frame_sp, lldb::WatchpointSP wp_sp);
35-
36-
#if _MSC_VER
37-
#pragma warning (pop)
38-
#endif
39-
40-
#pragma clang diagnostic pop
41-
4219
static int lldb_print(lua_State *L) {
4320
int n = lua_gettop(L);
4421
lua_getglobal(L, "io");

lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,24 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "Plugins/ScriptInterpreter/Lua/Lua.h"
10+
#include "Plugins/ScriptInterpreter/Lua/SWIGLuaBridge.h"
1011
#include "gtest/gtest.h"
1112

1213
using namespace lldb_private;
1314

1415
extern "C" int luaopen_lldb(lua_State *L) { return 0; }
1516

16-
#pragma clang diagnostic push
17-
#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
18-
19-
// Disable warning C4190: 'LLDBSwigPythonBreakpointCallbackFunction' has
20-
// C-linkage specified, but returns UDT 'llvm::Expected<bool>' which is
21-
// incompatible with C
22-
#if _MSC_VER
23-
#pragma warning (push)
24-
#pragma warning (disable : 4190)
25-
#endif
26-
27-
extern "C" llvm::Expected<bool> LLDBSwigLuaBreakpointCallbackFunction(
17+
llvm::Expected<bool> lldb_private::LLDBSwigLuaBreakpointCallbackFunction(
2818
lua_State *L, lldb::StackFrameSP stop_frame_sp,
2919
lldb::BreakpointLocationSP bp_loc_sp, StructuredDataImpl *extra_args_impl) {
3020
return false;
3121
}
3222

33-
extern "C" llvm::Expected<bool> LLDBSwigLuaWatchpointCallbackFunction(
23+
llvm::Expected<bool> lldb_private::LLDBSwigLuaWatchpointCallbackFunction(
3424
lua_State *L, lldb::StackFrameSP stop_frame_sp, lldb::WatchpointSP wp_sp) {
3525
return false;
3626
}
3727

38-
#if _MSC_VER
39-
#pragma warning (pop)
40-
#endif
41-
42-
#pragma clang diagnostic pop
43-
4428
TEST(LuaTest, RunValid) {
4529
Lua lua;
4630
llvm::Error error = lua.Run("foo = 1");

0 commit comments

Comments
 (0)