charlie | 14 Nov 06:13

Template Functions Taking Function Pointer as Argument

Hi swig-users,

I am trying to wrap up a template function which take a template function pointer as argument.
Is the following interface file and header file correct way?
test.i:

%module test
%{
#include "test.h"
%}
%include"test.h"
%template(fab) TF<A, B>(A, B&, B (*f)(const A&), int n)

test.h:
class A { /* .. */ }
class B { /* .. */ }
class E { /*... */ }
B f( A& ) {/* ... */}
template <class C, class D>  E TF(C, D&, D (*f)(const D&), int n) { /*...*/ }

Then in python I supposed to use fab by following:
>>> import test
>>> a=A()
>>> b=B()
>>> e=fab(a, b, &f, 10)

Am I right? I tested my header file and implicit deduction using c++. They all went through good.
However in SWIG, I see stranger erorr like "symbol undifiened: blahblah"
Your help is greatly appreciated.

Thanks

Charlie

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Swig-user mailing list
Swig-user <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swig-user
charlie | 14 Nov 06:24

Re: Template Functions Taking Function Pointer as Argument

sorry, a small typo.
It should be:
template <class C, class D>  E TF(C, D&, D (*f)(const C&), int n) { /*...*/ }

On Thu, Nov 13, 2008 at 9:16 PM, charlie <charlie.xia.fdu <at> gmail.com> wrote:
Hi swig-users,

I am trying to wrap up a template function which take a template function pointer as argument.
Is the following interface file and header file correct way?
test.i:

%module test
%{
#include "test.h"
%}
%include"test.h"
%template(fab) TF<A, B>(A, B&, B (*f)(const A&), int n)

test.h:
class A { /* .. */ }
class B { /* .. */ }
class E { /*... */ }
B f( A& ) {/* ... */}
template <class C, class D>  E TF(C, D&, D (*f)(const D&), int n) { /*...*/ }

Then in python I supposed to use fab by following:
>>> import test
>>> a=A()
>>> b=B()
>>> e=fab(a, b, &f, 10)

Am I right? I tested my header file and implicit deduction using c++. They all went through good.
However in SWIG, I see stranger erorr like "symbol undifiened: blahblah"
Your help is greatly appreciated.

Thanks

Charlie

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Swig-user mailing list
Swig-user <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swig-user

Gmane