SIP Python bindings generator - nested templates
Phil Thompson
phil at river-bank.demon.co.uk
Thu Jan 16 18:43:19 EST 2003
On Thursday 16 January 2003 7:31 pm, Pakewak wrote:
> Hi,
>
> The SIP generator doesn't seem to allow nested template types. I have a
> method called:
>
> virtual plSMat<plSquareMatrix<double>,3> GetOrientationMatrix() const;
>
> Now I manually added the code for this function in the generated code,
> which works, but this is not very convenient. Is there a work-around for
> SIP for this problem?
SIP doesn't support nested templates, but there is no reason not to. One for
the TODO list.
See below for a workaround.
> I also searched for a directive (like %HeaderCode) that just copies the
> enclosed code into the generated code without processing. There doesn't
> seem to be one. Something like "%HeaderCode", but one which doesn't replace
> the code at the top.
What you need to do is to decide how you want to represent the type in Python
- perhaps a nested tuple in this example. Then you use %MappedType to define
the C++ code that will convert to and from the Python and C++
representations. Because SIP doesn't support nested templates you will have
to invent a new type to keep SIP happy - but your %MappedType code deals with
the real C++ type.
An alternative would be to invent a class (in SIP - it doesn't have to
correspond to a real C++ class) so long as you provide C++ code (using
%MemberCode) for each of the methods you want to implement.
Phil
More information about the Python-list
mailing list