diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2021-11-12 19:30:53 +0000 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2021-11-12 19:30:53 +0000 |
commit | 01eb2e0aa99acaace2ebe406ef069cfb3f2420e1 (patch) | |
tree | d5725f6e2f5023a133f5e5c477cc2943d632762e | |
parent | 842ed6ca9dc5c8d6b46e31f34ed22556f025f61c (diff) | |
download | swig-01eb2e0aa99acaace2ebe406ef069cfb3f2420e1.tar.gz |
Lua int ref typemap improvements
Fixes complex typedefs to const int& and const unsigned int&.
Fixes cpp11_type_aliasing testcase
-rw-r--r-- | Lib/lua/luatypemaps.swg | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/lua/luatypemaps.swg b/Lib/lua/luatypemaps.swg index 6c92e3b59..3f531bd05 100644 --- a/Lib/lua/luatypemaps.swg +++ b/Lib/lua/luatypemaps.swg @@ -39,12 +39,12 @@ $1 = ($type)lua_tonumber(L, $input);%} // SWIG assumes that this code will need a pointer to int to be passed in // (this might be ok for objects by const ref, but not for numeric primitives) // therefore we add a set of typemaps to fix this (for both in & out) -%typemap(in,checkfn="lua_isnumber") const int&($basetype temp) -%{ temp=($basetype)lua_tonumber(L,$input); $1=&temp;%} +%typemap(in,checkfn="lua_isnumber") const int&($*1_ltype temp) +%{ temp=($*1_ltype)lua_tonumber(L,$input); $1=&temp;%} -%typemap(in,checkfn="lua_isnumber") const unsigned int&($basetype temp) +%typemap(in,checkfn="lua_isnumber") const unsigned int&($*1_ltype temp) %{SWIG_contract_assert((lua_tonumber(L,$input)>=0),"number must not be negative") -temp=($basetype)lua_tonumber(L,$input); $1=&temp;%} +temp=($*1_ltype)lua_tonumber(L,$input); $1=&temp;%} %typemap(out) const int&, const unsigned int& %{ lua_pushnumber(L, (lua_Number) *$1); SWIG_arg++;%} |