SIP Python bindings generator - nested templates

Jim jbublitzNO at SPAMnwinternet.com
Fri Jan 17 15:28:25 EST 2003


Pakewak wrote:
> Jim wrote:
>  
> 
>>// in your sip files, you can either assign
>>// a new name to the template type, or just
>>// use it as the identifier - sip will accept
>>// the <'s and >'s as part of the identifier
>>%MappedType plSMat<plSquareMatrix<double>, 3>

> The line above causes a parse error. When I remove the second template 
> parameter it works:

Sorry - I've never had to try a nested
template.

> %MappedType plSMat<plSquareMatrix<double>>

> I'll stick to my manual hack until the next SIP release.

The semantics of:

%MappedType  plSMat<plSquareMatrix<double>, 3>

is the same as:

%MappedType SomeTypenameSipLikes

"SomeTypeNameSipLikes" is just a name for the
mapping - it has no other significance (other
than sip has to be able to parse it). In the
.sip file you then replace the template based
name with the new name:

plSMat<plSquareMatrix<double>, 3> someMethod ();

becomes:

SomeTypenameSipLikes someMethod ();

Inside the %Convert* blocks you use the
original template-based name, unless you
typedef the original name to the new name
someplace (like in the %MappedType's
%HeaderCode block) - the %Convert* code
gets parsed by gcc, but not by sip (more
or less).

You can modify the sip-generated C++ code,
but it's a pain when you do maintenance
or upgrades or if you find another bug in
your .sip file - any time you have to
re-generate the code you have to re-patch.


Jim





More information about the Python-list mailing list