From 01eb2e0aa99acaace2ebe406ef069cfb3f2420e1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Nov 2021 19:30:53 +0000 Subject: [PATCH] Lua int ref typemap improvements Fixes complex typedefs to const int& and const unsigned int&. Fixes cpp11_type_aliasing testcase --- Lib/lua/luatypemaps.swg | 8 ++++---- 1 file 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++;%}