diff --git a/CHANGES.current b/CHANGES.current index 83a03e262..9c2cbbc2d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,13 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-09-19: wsfulton + Fix regression introduced in swig-2.0.1 reported by Teemu Ikonone leading to uncompilable code + when using typedef and function pointer references, for example: + + typedef int FN(const int &a, int b); + void *typedef_call1(FN *& precallback, FN * postcallback); + 2011-09-14: wsfulton [Lua] Patch #3408012 from Raman Gopalan - add support for embedded Lua (eLua) including options for targeting Lua Tiny RAM (LTR). diff --git a/Examples/test-suite/funcptr_cpp.i b/Examples/test-suite/funcptr_cpp.i index a3d46ea39..015164ed9 100644 --- a/Examples/test-suite/funcptr_cpp.i +++ b/Examples/test-suite/funcptr_cpp.i @@ -20,3 +20,14 @@ int call3(int & (*d)(const int &, int), int a, int b) { return d(a, b); } %constant int (*ADD_BY_VALUE)(const int &, int) = addByValue; %constant int * (*ADD_BY_POINTER)(const int &, int) = addByPointer; %constant int & (*ADD_BY_REFERENCE)(const int &, int) = addByReference; + + +%inline %{ +typedef int AddByValueTypedef(const int &a, int b); +typedef int * AddByPointerTypedef(const int &a, int b); +typedef int & AddByReferenceTypedef(const int &a, int b); +void *typedef_call1(AddByValueTypedef *& precallback, AddByValueTypedef * postcallback) { return 0; } +void *typedef_call2(AddByPointerTypedef *& precallback, AddByPointerTypedef * postcallback) { return 0; } +void *typedef_call3(AddByReferenceTypedef *& precallback, AddByReferenceTypedef * postcallback) { return 0; } +%} + diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index b8a9c9c80..6250e0b15 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -823,7 +823,8 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) { Insert(result, 0, "("); Append(result, ")"); } - isreference = 1; + if (!isfunction) + isreference = 1; } else if (SwigType_isarray(element)) { DOH *size; if (firstarray && !isreference) { @@ -869,10 +870,8 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) { cast = NewStringf("(%s)", result); } if (name) { - if (!isfunction) { - if (isreference) { - Append(cast, "*"); - } + if (isreference) { + Append(cast, "*"); } Append(cast, name); }