« Return to Thread: function template uses templated header - swig interface file

Re: function template uses templated header - swig interface file

by wsfulton :: Rate this Message:

Reply to Author | View in Thread

Rubin, Jared wrote:

> How does one create the swig interface file for a function (in a
> separate file) that uses a templated header file?
> My Bar.C uses a template instance of Foo.h. I am not seeing the code
> being wrapped correctly
> Thanks
>
>
> # A function template that uses a class template
> Foo.h
> ==============
> template <class T> class Foo {
>   private:
>     T* data;
>   public Foo(T *d)
>   {
>     data = t;
>   }
> }
>
> Bar.h
> =================
> #include "Foo.h"
> void bar(Foo<int> f);
>
> Bar.C
> =================
> #include "Bar.h"
> void bar(Foo<int> f) {
>   // do something;
>   return;
> }
>
> FooBar.i
> =========
> %module FooBar
> %include "Foo.h"
> %template(FooI) Foo<int>;
> %include "Bar.h"
>
How is it not being wrapped correctly? Assuming you fix the C++ code so
that it compiles, it should generate wrappers, although you'd have a
SWIGTYPE_p_int type wrapper class which isn't great. See the docs for
improving the wrapping pointers to primitive types.

William

------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

 « Return to Thread: function template uses templated header - swig interface file