#1332 C++ SWIG Signatures for templates with default parameters not always right

open
nobody
7
2013-08-27
2013-08-27
No

I'll refer to the simplified example I have attached.

I've got two modules. In signal.i, I created a template class, Listener which has a default argument, SIGNAL_POLICY. The signature in C++ swig for the Listener class, which I instantiate with %template, is _p_ListenerT_SIGNAL_POLICY_t. I also typedef Listener<> to TListener.

In signal_user.i, I've got 4 classes. They are purposely out of order in the interface file, where I'll get a 'Base Class 'fwg::Folder' ignored warning message. The Profile class in here is derived off of hwTListener, which is the typedef I mentioned earlier in signal.i.

I'm using the -builtin argument when generating the wrapped code to make the problem easier to reproduce. I can reproduce the issue differently without it as well.

If one builds and imports signal_user, the following error message is spit out:

TypeError: Could not create type 'Profile' as base 'Listener<()>' has not been initialized.

I take a look in the C++ code and noticed this:

builtin_basetype = SWIG_MangledTypeQuery("_p_ListenerT_t");

That signature is the wrong one!
The problem is that with the order of the classes in signal_user.i, the signature it uses for TListener is _p_ListenerT_t instead of _p_ListenerT_SIGNAL_POLICY_t.

I tried to follow the swig code to figure this out myself and it seems the scope is incorrect ("Folder") when it's generating the signature. That's as far as I could get, however.

I know I can reorder the classes, and I plan on doing this. But, I am wrapping quite a bit and am seeing this error in several places. There may be other iterations of this same issue, or maybe it's all the same one - not sure yet...

Thanks!

4 Attachments

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks