swig/r12814.patch
Ismail Dönmez bbab5343cc Accepting request 113033 from home:adra:branches:devel:tools:building
Added a patch to fix regression leading to uncompilable code when using typedef and function pointer references

OBS-URL: https://build.opensuse.org/request/show/113033
OBS-URL: https://build.opensuse.org/package/show/devel:tools:building/swig?expand=0&rev=33
2012-04-10 08:43:19 +00:00

60 lines
2.1 KiB
Diff

--- a/CHANGES.current
+++ b/CHANGES.current
@@ -2,6 +2,14 @@ This file contains the changes for the c
See the CHANGES file for changes in older releases.
See the RELEASENOTES file for a summary of changes in each release.
+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);
+
+
Version 2.0.4 (in progress)
===========================
2011-05-19: wsfulton
--- a/Source/Swig/stype.c
+++ b/Source/Swig/stype.c
@@ -823,7 +823,8 @@ String *SwigType_rcaststr(const SwigType
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
cast = NewStringf("(%s)", result);
}
if (name) {
- if (!isfunction) {
- if (isreference) {
- Append(cast, "*");
- }
+ if (isreference) {
+ Append(cast, "*");
}
Append(cast, name);
}
--- 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),
%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; }
+%}
+