#554 %callback and typedefs

open
nobody
None
5
2012-12-21
2005-04-11
Josh Cherry
No

It seems that if I use %callback when typedefs are used
as parameter types, things don't work right. Here's a
simple example:

%module cb

%callback(1) CallMe1;
%callback(1) CallMe2;

%inline %{

class CBar
{
};

CBar& CallMe1(CBar& bar) {
return bar;
}

typedef CBar TBar;
CBar& CallMe2(TBar& bar) {
return bar;
}

void Foo1(CBar& (*func)(CBar&)) {
}

void Foo2(CBar& (*func)(TBar&)) {
}

%}

CallMe1 and CallMe2 have the same signature when the
typedef is taken into account, as do Foo1 and Foo2.
Yet in Python, cb.Foo1(cb.CallMe2) and cb.Foo2
(cb.CallMe1) give type errors, whereas cb.Foo1
(cb.CallMe1) and cb.Foo2(cb.CallMe2) succeed. All
four should succeed.

Discussion