[pygccxml-development] Template constructors
Brought to you by:
mbaas,
roman_yakovenko
From: Matthias B. <mat...@gm...> - 2008-03-16 21:08:17
|
Hi, after being away from the "wrapping business" for quite a while I'm now back and trying to wrap another library that is heavily template based. As I'm starting from scratch, I'm now using the official module builder instead of my own version. So as a first general question, is there meanwhile some special support for templates? Can I tell Py++ what template arguments to use and it takes care of instantiating it? I'm assuming that's not (yet) the case, so I was instantiating the stuff myself. But I ran into a problem with a template constructor inside a template class. I could only wrap the non-template constructors whereas the other ones don't seem to be reported by gccxml. Here is an example: ///////////////////// File: header.h template<class T> class Spam { T x; T y; public: Spam() : x(0),y(0) {} template<class V> Spam(V a, V b) : x(a),y(b) {} }; // Instantiate the template inline void dummy() { Spam<double> c0(1, 2); } ####################### File: generate.py from pyplusplus.module_builder import module_builder_t mb = module_builder_t(files = ['header.h']) spam = mb.class_("Spam<double>") spam.include() # Print all declarations that are available on the class decls = spam.decls() for decl in decls: print decl mb.build_code_creator(module_name="spammod") mb.split_module(dir_name="bindings") When I run the Python script, the declarations that get printed are the following: Spam<double>::Spam(Spam<double> const & arg0) [copy constructor] Spam<double>::Spam() [constructor] Spam<double>::x [variable] Spam<double>::y [variable] I would also have expected a constructor that takes two ints, but it isn't there and so it isn't wrapped. Is there another way to instantiate the class that would make the constructor visible? I'm using the latest official versions of pygccxml/pyplusplus and gccxml from cvs (and everything is on OSX 10.4.11). Cheers, - Matthias - |