From: James M. <jam...@gm...> - 2008-12-05 20:23:24
|
Hi all, I am attempting to wrap a very large set of C++ classes (for Ruby) of which I do not own the header files. I am having an issue with wrapping templates and using those templates as a base class. Here is a simplified example of a header file: template <class T> class ArrayBase {}; template <class T> class Array : public ArrayBase<T> {}; class IntArray : public Array<int> {}; According to my knowledge, in order to properly wrap the templates Array and ArrayBase and in order to have inheritance work properly, I need to somehow put %template declarations after the template definitions but before a class derives from a template instantiation. So in other words, I would need the SWIG interface to look like this: template <class T> class ArrayBase {}; template <class T> class Array : public ArrayBase<T> {}; %template("IArrayBase") ArrayBase<int>; %template("IArray") Array<int>; class IntArray : public Array<int> {}; Given that I do not own the header files, I cannot embed %template in between as shown above. I would really like to just define %template after the header files are read in, but that results in: % swig -ruby -c++ basetest.i basetest.i:7: Warning(401): Base class 'Array< int >' undefined. basetest.i:10: Warning(401): 'Array< int >' must be defined before it is used as a base class. And in the generated code IntArray does not inherit from Array<int>. Please advise if there is a work-around to this situation. Thanks, -James |