Skip to content

Commit a5bc48a

Browse files
committed
[Lua] Fix type resolution between SWIG-wrapped modules
See swig#2126
1 parent 867e49d commit a5bc48a

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

CHANGES.current

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
77
Version 4.1.0 (in progress)
88
===========================
99

10+
2022-10-19: olly
11+
[Lua] #2126 Fix type resolution between multiple SWIG-wrapped
12+
modules.
13+
1014
2022-10-17: wsfulton
1115
[R] #2385 Add support for std::vector<std::vector<std::string>>.
1216

Examples/test-suite/lua/mod_runme.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require("import") -- the import fn
2+
import("mod_a") -- import lib
3+
import("mod_b") -- import lib
4+
5+
-- catch "undefined" global variables
6+
local env = _ENV -- Lua 5.2
7+
if not env then env = getfenv () end -- Lua 5.1
8+
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
9+
10+
c = mod_b.C()
11+
d = mod_b.D()
12+
d:DoSomething(c)

Lib/lua/luarun.swg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,7 @@ SWIGRUNTIME int SWIG_Lua_ConvertPtr(lua_State *L,int index,void **ptr,swig_type
17891789
}
17901790
else
17911791
{
1792-
cast=SWIG_TypeCheckStruct(usr->type,type); /* performs normal type checking */
1792+
cast=SWIG_TypeCheck(usr->type->name,type); /* performs normal type checking */
17931793
if (cast)
17941794
{
17951795
int newmemory = 0;

0 commit comments

Comments
 (0)