Hello,
I believe I'm having some of the same problems that yinhm reported. I'm
attempting to wrap an in-house, non-QT library using Shiboken (1.0.6,
from the Natty PPA for pyside), and have been unable to access functions
defined in a templated parent from either a derived child or a typedefed
instantiation.
I have a header containing the following (derived from the binding
tutorial):
template <typename T>
class MathT
{
public:
MathT() {}
virtual ~MathT() {}
T squared(T x) { return x*x; }
};
typedef MathT<float> MathTDef;
class MathTWrap : public MathT<double> { };
A typesystem file, thus:
<?xml version="1.0"?>
<typesystem package="foo">
<primitive-type name="double"/>
<object-type name="MathTDef" />
<object-type name="MathTWrap" />
</typesystem>
And, given Hugo's comment about typedefs, I duplicated the typedef in
global.h:
#include <foo.h>
typedef MathT<float> MathTDef;
When I invoke generatorrunner, it warns that:
template baseclass 'MathT<float>' of 'MathTDef' is not known
template baseclass 'MathT<double>' of 'MathTWrap' is not known
After this warning, it's unsurprising that this fails in python:
import foo
mw = foo.MathTWrap()
mw.squared(5) # AttributeError: 'foo.MathTWrap' object has no
attribute 'squared'
md = foo.MathTDef()
md.squared(5) # AttributeError: 'foo.MathTDef' object has no attribute
'squared'
So: is it possible to expose the functions of a templated parent /
typedefed template instantiation through Shiboken? I'm guessing that I
need to teach Shiboken about MathT<> somehow, but all of my wild stabs
at typesystem entries have failed. Also, I haven't been able to find
any examples of templated base classes in the pyside bindings, but it's
entirely possible that I'm just missing them.
I've modified the binding tutorial to form a minimal demonstration of
the problems I'm having, and have posted a (7k) source tarball at
http://www.sellner.org/drop/template-inheritance-binding.tgz. To reproduce:
tar -xzf template-inheritance-binding.tgz
cd template-inheritance-binding
make
make test
The test will fail when trying to access MathTWrap::squared(). If you
shuffle the test (in foobinding/Makefile) to put MathTDef above
MathTWrap, you can see that the typedef approach fails in the same fashion.
I'd appreciate any pointers!
Thanks,
-Brennan
_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside